示例#1
0
        /// <nodoc/>
        public RushPipConstructor(
            FrontEndContext context,
            FrontEndHost frontEndHost,
            ModuleDefinition moduleDefinition,
            RushConfiguration rushConfiguration,
            IRushResolverSettings resolverSettings,
            IEnumerable <KeyValuePair <string, string> > userDefinedEnvironment,
            IEnumerable <string> userDefinedPassthroughVariables,
            IReadOnlyDictionary <string, IReadOnlyList <RushArgument> > customCommands)
        {
            Contract.RequiresNotNull(context);
            Contract.RequiresNotNull(frontEndHost);
            Contract.RequiresNotNull(moduleDefinition);
            Contract.RequiresNotNull(resolverSettings);
            Contract.RequiresNotNull(userDefinedEnvironment);
            Contract.RequiresNotNull(userDefinedPassthroughVariables);
            Contract.RequiresNotNull(customCommands);

            m_context                         = context;
            m_frontEndHost                    = frontEndHost;
            m_moduleDefinition                = moduleDefinition;
            m_rushConfiguration               = rushConfiguration;
            m_resolverSettings                = resolverSettings;
            m_userDefinedEnvironment          = userDefinedEnvironment;
            m_userDefinedPassthroughVariables = userDefinedPassthroughVariables;
            m_customCommands                  = customCommands;
        }
示例#2
0
        private bool ValidateResolverSettings(IRushResolverSettings rushResolverSettings)
        {
            var pathToFile = rushResolverSettings.File.ToString(m_context.PathTable);

            if (!rushResolverSettings.Root.IsValid)
            {
                Tracing.Logger.Log.InvalidResolverSettings(m_context.LoggingContext, Location.FromFile(pathToFile), "The root must be specified.");
                return(false);
            }

            string rushJson = rushResolverSettings.Root.Combine(m_context.PathTable, "rush.json").ToString(m_context.PathTable);

            if (!FileUtilities.Exists(rushJson))
            {
                Tracing.Logger.Log.InvalidResolverSettings(m_context.LoggingContext, Location.FromFile(pathToFile),
                                                           $"Rush configuration file 'rush.json' was not found under the specified root '{rushJson}'.");
                return(false);
            }

            if (string.IsNullOrEmpty(rushResolverSettings.ModuleName))
            {
                Tracing.Logger.Log.InvalidResolverSettings(m_context.LoggingContext, Location.FromFile(pathToFile), "The module name must not be empty.");
                return(false);
            }

            return(true);
        }
示例#3
0
        /// <nodoc/>
        public RushGraphConstructionFailure(IRushResolverSettings settings, PathTable pathTable)
        {
            Contract.Requires(settings != null);
            Contract.Requires(pathTable != null);

            m_settings  = settings;
            m_pathTable = pathTable;
        }
 /// <nodoc/>
 public RushResolverSettings(
     IRushResolverSettings resolverSettings,
     PathRemapper pathRemapper)
     : base(resolverSettings, pathRemapper)
 {
     RushLibBaseLocation = resolverSettings.RushLibBaseLocation;
     TrackDependenciesWithShrinkwrapDepsFile = resolverSettings.TrackDependenciesWithShrinkwrapDepsFile;
 }
示例#5
0
 /// <nodoc/>
 public RushResolverSettings(
     IRushResolverSettings resolverSettings,
     PathRemapper pathRemapper)
     : base(resolverSettings, pathRemapper)
 {
     Root       = pathRemapper.Remap(resolverSettings.Root);
     ModuleName = resolverSettings.ModuleName;
     UntrackedDirectoryScopes = resolverSettings.UntrackedDirectoryScopes;
     UntrackedFiles           = resolverSettings.UntrackedFiles;
     UntrackedDirectories     = resolverSettings.UntrackedDirectories;
     Environment                 = resolverSettings.Environment;
     KeepProjectGraphFile        = resolverSettings.KeepProjectGraphFile;
     NodeExeLocation             = resolverSettings.NodeExeLocation;
     AdditionalOutputDirectories = resolverSettings.AdditionalOutputDirectories;
 }
示例#6
0
        /// <nodoc/>
        public RushPipConstructor(
            FrontEndContext context,
            FrontEndHost frontEndHost,
            ModuleDefinition moduleDefinition,
            RushConfiguration rushConfiguration,
            IRushResolverSettings resolverSettings,
            IEnumerable <KeyValuePair <string, string> > userDefinedEnvironment,
            IEnumerable <string> userDefinedPassthroughVariables,
            IReadOnlyDictionary <string, IReadOnlyList <JavaScriptArgument> > customCommands)
            : base(context, frontEndHost, moduleDefinition, resolverSettings, userDefinedEnvironment, userDefinedPassthroughVariables, customCommands)
        {
            Contract.RequiresNotNull(rushConfiguration);

            m_rushConfiguration = rushConfiguration;
            m_resolverSettings  = resolverSettings;
        }
示例#7
0
 /// <nodoc/>
 public RushResolverSettings(
     IRushResolverSettings resolverSettings,
     PathRemapper pathRemapper)
     : base(resolverSettings, pathRemapper)
 {
     Root       = pathRemapper.Remap(resolverSettings.Root);
     ModuleName = resolverSettings.ModuleName;
     UntrackedDirectoryScopes = resolverSettings.UntrackedDirectoryScopes;
     UntrackedFiles           = resolverSettings.UntrackedFiles;
     UntrackedDirectories     = resolverSettings.UntrackedDirectories;
     Environment                 = resolverSettings.Environment;
     KeepProjectGraphFile        = resolverSettings.KeepProjectGraphFile;
     NodeExeLocation             = resolverSettings.NodeExeLocation;
     AdditionalOutputDirectories = resolverSettings.AdditionalOutputDirectories;
     Execute             = resolverSettings.Execute;
     CustomCommands      = resolverSettings.CustomCommands;
     RushLibBaseLocation = resolverSettings.RushLibBaseLocation;
     Exports             = resolverSettings.Exports;
     TrackDependenciesWithShrinkwrapDepsFile = resolverSettings.TrackDependenciesWithShrinkwrapDepsFile;
 }
示例#8
0
        /// <inheritdoc/>
        public Task <bool> InitResolverAsync(IResolverSettings resolverSettings, object workspaceResolver)
        {
            Name = resolverSettings.Name;
            m_rushResolverSettings = resolverSettings as IRushResolverSettings;
            Contract.Assert(
                m_rushResolverSettings != null,
                I($"Wrong type for resolver settings, expected {nameof(IRushResolverSettings)} but got {nameof(resolverSettings.GetType)}"));

            m_rushWorkspaceResolver = workspaceResolver as RushWorkspaceResolver;
            if (m_rushWorkspaceResolver == null)
            {
                Contract.Assert(false, I($"Wrong type for resolver, expected {nameof(RushWorkspaceResolver)} but got {nameof(workspaceResolver.GetType)}"));
            }

            if (!ValidateResolverSettings(m_rushResolverSettings))
            {
                return(Task.FromResult(false));
            }

            return(Task.FromResult(true));
        }
示例#9
0
        /// <nodoc/>
        public RushPipConstructor(
            FrontEndContext context,
            FrontEndHost frontEndHost,
            ModuleDefinition moduleDefinition,
            IRushResolverSettings resolverSettings,
            IEnumerable <KeyValuePair <string, string> > userDefinedEnvironment,
            IEnumerable <string> userDefinedPassthroughVariables)
        {
            Contract.Requires(context != null);
            Contract.Requires(frontEndHost != null);
            Contract.Requires(moduleDefinition != null);
            Contract.Requires(resolverSettings != null);
            Contract.Requires(userDefinedEnvironment != null);
            Contract.Requires(userDefinedPassthroughVariables != null);

            m_context                         = context;
            m_frontEndHost                    = frontEndHost;
            m_moduleDefinition                = moduleDefinition;
            m_resolverSettings                = resolverSettings;
            m_userDefinedEnvironment          = userDefinedEnvironment;
            m_userDefinedPassthroughVariables = userDefinedPassthroughVariables;
        }
示例#10
0
        private bool ValidateResolverSettings(IRushResolverSettings rushResolverSettings)
        {
            var pathToFile = rushResolverSettings.File.ToString(m_context.PathTable);

            if (!rushResolverSettings.Root.IsValid)
            {
                Tracing.Logger.Log.InvalidResolverSettings(m_context.LoggingContext, Location.FromFile(pathToFile), "The root must be specified.");
                return(false);
            }

            string rushJson = rushResolverSettings.Root.Combine(m_context.PathTable, "rush.json").ToString(m_context.PathTable);

            if (!FileUtilities.Exists(rushJson))
            {
                Tracing.Logger.Log.InvalidResolverSettings(m_context.LoggingContext, Location.FromFile(pathToFile),
                                                           $"Rush configuration file 'rush.json' was not found under the specified root '{rushJson}'.");
                return(false);
            }

            if (string.IsNullOrEmpty(rushResolverSettings.ModuleName))
            {
                Tracing.Logger.Log.InvalidResolverSettings(m_context.LoggingContext, Location.FromFile(pathToFile), "The module name must not be empty.");
                return(false);
            }

            if (rushResolverSettings.CustomCommands != null)
            {
                var commandNames = new HashSet <string>();
                foreach (var customCommand in rushResolverSettings.CustomCommands)
                {
                    if (string.IsNullOrEmpty(customCommand.Command))
                    {
                        Tracing.Logger.Log.InvalidResolverSettings(m_context.LoggingContext, Location.FromFile(pathToFile), "A non-empty custom command name must be defined.");
                        return(false);
                    }

                    if (!commandNames.Add(customCommand.Command))
                    {
                        Tracing.Logger.Log.InvalidResolverSettings(m_context.LoggingContext, Location.FromFile(pathToFile), $"Duplicated custom command name '{customCommand.Command}'.");
                        return(false);
                    }

                    if (customCommand.ExtraArguments == null)
                    {
                        Tracing.Logger.Log.InvalidResolverSettings(m_context.LoggingContext, Location.FromFile(pathToFile), $"Extra arguments for custom command '{customCommand.Command}' must be defined.");
                        return(false);
                    }
                }
            }

            // If the rush-lib base location is specified, it has to be valid
            if (rushResolverSettings.RushLibBaseLocation?.IsValid == false)
            {
                Tracing.Logger.Log.InvalidResolverSettings(m_context.LoggingContext, Location.FromFile(pathToFile), "The specified rush-lib base location is invalid.");
                return(false);
            }

            if (rushResolverSettings.Exports != null)
            {
                var symbolNames = new HashSet <FullSymbol>();
                foreach (var rushExport in rushResolverSettings.Exports)
                {
                    if (!rushExport.SymbolName.IsValid)
                    {
                        Tracing.Logger.Log.InvalidResolverSettings(m_context.LoggingContext, Location.FromFile(pathToFile), $"Symbol name is undefined.");
                        return(false);
                    }

                    if (!symbolNames.Add(rushExport.SymbolName))
                    {
                        Tracing.Logger.Log.InvalidResolverSettings(m_context.LoggingContext, Location.FromFile(pathToFile), $"Duplicate symbol name '{rushExport.SymbolName.ToString(m_context.SymbolTable)}'.");
                        return(false);
                    }

                    // Each specified project must be non-empty
                    foreach (var project in rushExport.Content)
                    {
                        object projectValue = project.GetValue();

                        string packageName = projectValue is string?(string)projectValue : ((IRushProjectOutputs)projectValue).PackageName;
                        if (string.IsNullOrEmpty(packageName))
                        {
                            Tracing.Logger.Log.InvalidResolverSettings(m_context.LoggingContext, Location.FromFile(pathToFile), "Package name must be defined.");
                            return(false);
                        }

                        if (projectValue is IRushProjectOutputs rushProjectCommand)
                        {
                            if (rushProjectCommand.Commands == null)
                            {
                                Tracing.Logger.Log.InvalidResolverSettings(m_context.LoggingContext, Location.FromFile(pathToFile), $"Commands for Rush export '{rushExport.SymbolName.ToString(m_context.SymbolTable)}' must be defined.");
                                return(false);
                            }

                            foreach (var command in rushProjectCommand.Commands)
                            {
                                if (string.IsNullOrEmpty(command))
                                {
                                    Tracing.Logger.Log.InvalidResolverSettings(m_context.LoggingContext, Location.FromFile(pathToFile), $"Command name for Rush export '{rushExport.SymbolName.ToString(m_context.SymbolTable)}' must be defined.");
                                    return(false);
                                }
                            }
                        }
                    }
                }
            }

            return(true);
        }