Exemple #1
0
        public ProjectOptions AddProject(string path, bool enableSpritting)
        {
            var projectDir = PathUtils.Normalize(new DirectoryInfo(path).FullName);
            var dirCache   = _dc.TryGetItem(projectDir) as IDirectoryCache;
            var proj       = TSProject.Get(dirCache, _dc, _logger);

            proj.IsRootProject = true;
            if (proj.ProjectOptions != null)
            {
                return(proj.ProjectOptions);
            }
            proj.ProjectOptions = new ProjectOptions
            {
                Tools      = _tools,
                BuildCache = _buildCache,
                Owner      = proj,
                Defines    = new Dictionary <string, bool> {
                    { "DEBUG", true }
                },
                SpriteGeneration = enableSpritting
            };
            lock (_projectsLock)
            {
                _projects.Add(proj.ProjectOptions);
            }

            _currentProject = proj.ProjectOptions;
            if (_mainServer != null)
            {
                _mainServer.Project = _currentProject;
            }
            return(proj.ProjectOptions);
        }
        void RunYarnWithParam(IDirectoryCache projectDirectory, string param)
        {
            var fullPath = projectDirectory.FullPath;
            var project  = TSProject.Get(projectDirectory, _diskCache, _logger, null);

            project.LoadProjectJson(true);
            if (project.ProjectOptions.NpmRegistry != null)
            {
                if (!(projectDirectory.TryGetChildNoVirtual(".npmrc") is IFileCache))
                {
                    File.WriteAllText(PathUtils.Join(fullPath, ".npmrc"),
                                      "registry =" + project.ProjectOptions.NpmRegistry);
                }
            }

            var par = param;

            par += " --no-emoji --non-interactive";
            if (!string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("BBCoreNoLinks")))
            {
                par += " --no-bin-links";
            }

            RunYarn(fullPath, par);
        }
Exemple #3
0
        BuildResult BuildProject(Action <ProjectOptions> configure = null)
        {
            dc.CheckForTrueChange();
            var ctx      = new BuildCtx(_compilerPool, false, (_) => { });
            var dirCache = dc.TryGetItem(projdir) as IDirectoryCache;
            var proj     = TSProject.Get(dirCache, dc, new DummyLogger(), null);

            proj.IsRootProject = true;
            if (proj.ProjectOptions.Tools == null)
            {
                proj.ProjectOptions = new ProjectOptions
                {
                    Tools   = _tools,
                    Owner   = proj,
                    Defines = new Dictionary <string, bool> {
                        { "DEBUG", true }
                    },
                    BuildCache = new DummyBuildCache()
                };
                proj.LoadProjectJson(true);
                proj.ProjectOptions.RefreshMainFile();
                proj.ProjectOptions.RefreshTestSources();
                proj.ProjectOptions.DetectBobrilJsxDts();
                proj.ProjectOptions.RefreshExampleSources();
            }

            configure?.Invoke(proj.ProjectOptions);
            ctx.TSCompilerOptions = new TSCompilerOptions
            {
                sourceMap           = true,
                skipLibCheck        = true,
                skipDefaultLibCheck = true,
                target             = ScriptTarget.Es5,
                preserveConstEnums = false,
                jsx                    = JsxEmit.React,
                reactNamespace         = "b",
                experimentalDecorators = true,
                noEmitHelpers          = true,
                allowJs                = true,
                checkJs                = false,
                removeComments         = false,
                types                  = new string[0],
                lib                    = new HashSet <string>
                {
                    "es5", "dom", "es2015.core", "es2015.promise", "es2015.iterable", "es2015.collection"
                }
            };
            ctx.Sources = new HashSet <string>();
            ctx.Sources.Add(proj.MainFile);
            proj.ProjectOptions.ExampleSources.ForEach(s => ctx.Sources.Add(s));
            if (proj.ProjectOptions.BobrilJsxDts != null)
            {
                ctx.Sources.Add(proj.ProjectOptions.BobrilJsxDts);
            }
            proj.Build(ctx);
            return(ctx.BuildResult);
        }