Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (target) {
target.selected = true;
targets = target.transitiveDeps(targets);
}
} else { // (:?)
for (let j = 0; j < project.targetList.length; j += 1) {
const target = project.targetList[j];
target.selected = true;
targets = target.transitiveDeps(targets);
}
}
} else {
const output = Unicode.stringOutput(OutputSettings.styled());
OutputStyle.redBold(output);
output.write("unknown project");
OutputStyle.reset(output);
output.write(" ");
OutputStyle.yellow(output);
output.write(projectId);
OutputStyle.reset(output);
console.log(output.bind());
}
} else if (targetId) { // :
for (let j = 0; j < this.projectList.length; j += 1) {
const target = this.projectList[j].targets[targetId];
if (target) {
target.selected = true;
targets = target.transitiveDeps(targets);
}
}
}
}
specifiers = specifiers.split(",");
}
if (i < specifiers.length) {
const specifier = specifiers[i];
const [projectId] = specifier.split(":");
const project = this.projects[projectId];
if (project) {
const result = callback(project);
if (result) {
return result.then(this.forEachProject.bind(this, specifiers, callback, i + 1));
}
} else {
const output = Unicode.stringOutput(OutputSettings.styled());
OutputStyle.redBold(output);
output.write("unknown project");
OutputStyle.reset(output);
output.write(" ");
OutputStyle.yellow(output);
output.write(projectId);
OutputStyle.reset(output);
console.log(output.bind());
}
return Promise.resolve(void 0).then(this.forEachProject.bind(this, specifiers, callback, i + 1));
} else {
return Promise.resolve(void 0);
}
}
doc(): Promise {
let output = Unicode.stringOutput(OutputSettings.styled());
OutputStyle.greenBold(output);
output.write("documenting");
OutputStyle.reset(output);
output.write(" ");
OutputStyle.yellow(output);
output.write(this.uid);
OutputStyle.reset(output);
console.log(output.bind());
const configPath = ts.findConfigFile(this.baseDir, ts.sys.fileExists, "tsconfig.json");
const outDir = path.join(this.project.baseDir, "doc", "/");
const doc = new typedoc.Application({
name: this.project.name,
readme: "none",
mode: "modules",
tsconfig: configPath,
gaID: this.project.build.gaID,
excludeNotExported: true,
excludePrivate: true,
hideGenerator: true,
});
protected onCompileSuccess() {
const dt = Date.now() - this.compileStart;
this.compileStart = 0;
const output = Unicode.stringOutput(OutputSettings.styled());
OutputStyle.greenBold(output);
output.write("compiled");
OutputStyle.reset(output);
output.write(" ");
OutputStyle.yellow(output);
output.write(this.uid);
OutputStyle.reset(output);
output.write(" in ");
output.debug(dt);
output.write("ms");
console.log(output.bind());
console.log();
}
protected onCompileFailure() {
this.compileStart = 0;
const output = Unicode.stringOutput(OutputSettings.styled());
OutputStyle.redBold(output);
output.write("failed to compile");
OutputStyle.reset(output);
output.write(" ");
OutputStyle.yellow(output);
output.write(this.uid);
OutputStyle.reset(output);
console.log(output.bind());
console.log();
}
printProjects(): void {
const output = Unicode.stringOutput(OutputSettings.styled());
OutputStyle.greenBold(output);
output.write("projects");
OutputStyle.reset(output);
console.log(output.bind());
for (let i = 0; i < this.projectList.length; i += 1) {
const project = this.projectList[i];
const output = Unicode.stringOutput(OutputSettings.styled());
output.write(" - ");
OutputStyle.yellow(output);
output.write(project.id);
OutputStyle.reset(output);
console.log(output.bind());
}
}
bundle(): Promise {
this.cancelBundle();
this.bundleTimer = -1;
const output = Unicode.stringOutput(OutputSettings.styled());
OutputStyle.greenBold(output);
output.write("bundling");
OutputStyle.reset(output);
output.write(" ");
OutputStyle.yellow(output);
output.write(this.uid);
OutputStyle.reset(output);
console.log(output.bind());
const bundleConfig = this.project.bundleConfig[this.id] as rollup.RollupOptions | undefined;
if (bundleConfig) {
const t0 = Date.now();
const cwd = process.cwd();
process.chdir(this.project.baseDir);
return rollup.rollup(bundleConfig)
.then((build: rollup.RollupBuild): Promise => {
process.chdir(cwd);
if (this.watching) {
bundleConfig.cache = build.cache;
protected onBundleError(error: Error): void {
let output = Unicode.stringOutput(OutputSettings.styled());
OutputStyle.redBold(output);
output.write("error:");
OutputStyle.reset(output);
output.write(" ");
output.write(error.message);
console.log(output.bind());
console.log();
output = Unicode.stringOutput(OutputSettings.styled());
OutputStyle.redBold(output);
output.write("failed to bundle");
OutputStyle.reset(output);
output.write(" ");
OutputStyle.yellow(output);
output.write(this.uid);
OutputStyle.reset(output);
console.log(output.bind());
}
bundle(): Promise {
this.cancelBundle();
this.bundleTimer = -1;
const output = Unicode.stringOutput(OutputSettings.styled());
OutputStyle.greenBold(output);
output.write("bundling");
OutputStyle.reset(output);
output.write(" ");
OutputStyle.yellow(output);
output.write(this.uid);
OutputStyle.reset(output);
console.log(output.bind());
const bundleConfig = this.project.bundleConfig[this.id] as rollup.RollupOptions | undefined;
if (bundleConfig) {
const t0 = Date.now();
const cwd = process.cwd();
process.chdir(this.project.baseDir);
return rollup.rollup(bundleConfig)
.then((build: rollup.RollupBuild): Promise => {
process.chdir(cwd);
if (this.watching) {
bundleConfig.cache = build.cache;
}
return build.generate(bundleConfig.output!);
})
.then((bundle: rollup.RollupOutput): rollup.RollupOutput => {
watch(): void {
const output = Unicode.stringOutput(OutputSettings.styled());
OutputStyle.greenBold(output);
output.write("watching");
OutputStyle.reset(output);
output.write(" ");
OutputStyle.yellow(output);
output.write(this.uid);
OutputStyle.reset(output);
console.log(output.bind());
const configPath = ts.findConfigFile(this.baseDir, ts.sys.fileExists, "tsconfig.json");
const commandLine = ts.getParsedCommandLineOfConfigFile(configPath!, this.compilerOptions, ts.sys as any)!;
const projectReferences = this.injectProjectReferences(commandLine.projectReferences, commandLine.options);
this.injectCompilerOptions(commandLine.options);
const rootNames = projectReferences.map(ref => ref.path);
rootNames.push(this.baseDir);
const solutionBuilderHost = ts.createSolutionBuilderWithWatchHost(ts.sys, this.createWatchProgram, this.onCompileError,
this.onCompileUpdate, this.onCompileResult);
const solutionBuilder = ts.createSolutionBuilderWithWatch(solutionBuilderHost, rootNames, {incremental: true, watch: true});