Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function _executeTarget(
parentLogger: logging.Logger,
workspace: workspaces.WorkspaceDefinition,
root: string,
argv: minimist.ParsedArgs,
registry: schema.SchemaRegistry,
) {
const architectHost = new WorkspaceNodeModulesArchitectHost(workspace, root);
const architect = new Architect(architectHost, registry);
// Split a target into its parts.
const targetStr = argv._.shift() || '';
const [project, target, configuration] = targetStr.split(':');
const targetSpec = { project, target, configuration };
delete argv['help'];
delete argv['_'];
const logger = new logging.Logger('jobs');
const logs: logging.LogEntry[] = [];
logger.subscribe(entry => logs.push({ ...entry, message: `${entry.name}: ` + entry.message }));
const run = await architect.scheduleTarget(targetSpec, argv, { logger });
const bars = new MultiProgressBar(':name :bar (:current/:total) :status');
registry.addPostTransform(schema.transforms.addUndefinedDefaults);
const { workspace } = await workspaces.readWorkspace(
workspaceRoot,
workspaces.createWorkspaceHost(host)
);
await host.initialize().toPromise();
testArchitectHost = new TestingArchitectHost(
getSystemPath(host.root()),
getSystemPath(host.root()),
new WorkspaceNodeModulesArchitectHost(workspace, workspaceRoot)
);
architect = new Architect(testArchitectHost, registry);
});
export async function getTestArchitect() {
const architectHost = new TestingArchitectHost('/root', '/root');
const registry = new schema.CoreSchemaRegistry();
registry.addPostTransform(schema.transforms.addUndefinedDefaults);
const architect = new Architect(architectHost, registry);
await architectHost.addBuilderFromPackage(join(__dirname, '../..'));
return [architect, architectHost] as [Architect, TestingArchitectHost];
}
it('runs', (done) => {
const architect = new Architect(normalize(root), host);
architect.loadWorkspaceFromJson(getWorkspace()).pipe(
concatMap((architect) => architect.run(architect.getTarget())),
toArray(),
tap(events => expect(events.length).toBe(0)),
).subscribe(done, done.fail);
}, 30000);
});
it('runs', (done) => {
const architect = new Architect(normalize(root), host);
architect.loadWorkspaceFromJson(getWorkspace()).pipe(
concatMap((architect) => architect.run(architect.getTarget())),
take(1),
).subscribe(done, done.fail);
}, 30000);
});
it('runs', (done) => {
const architect = new Architect(normalize(root), host);
architect.loadWorkspaceFromJson(getWorkspace()).pipe(
concatMap((architect) => architect.run(architect.getTarget())),
toArray(),
tap(events => expect(events.length).toBe(0)),
).subscribe(done, done.fail);
}, 30000);
});
async function createArchitect(workspaceRoot: string) {
vfHost = new NodeJsSyncHost();
const registry = new schema.CoreSchemaRegistry();
registry.addPostTransform(schema.transforms.addUndefinedDefaults);
const { workspace } = await workspaces.readWorkspace(
workspaceRoot,
workspaces.createWorkspaceHost(vfHost),
);
testArchitectHost = new TestingArchitectHost(workspaceRoot, workspaceRoot,
new WorkspaceNodeModulesArchitectHost(workspace, workspaceRoot));
architect = new Architect(testArchitectHost, registry);
}
const root = path.dirname(this.angularConfigPath);
this.registry = new schema.CoreSchemaRegistry();
this.registry.addPostTransform(schema.transforms.addUndefinedDefaults);
this.host = new NodeJsSyncHost();
const { workspace } = await workspaces.readWorkspace(
this.angularConfigPath,
workspaces.createWorkspaceHost(this.host),
);
this.workspace = workspace;
this.architectHost = new WorkspaceNodeModulesArchitectHost(this.workspace, root);
this.architect = new Architect(this.architectHost, this.registry);
const targetString = this.args.target;
if (!targetString) {
throw new Error('Must either have --target');
}
this.universalOptions = await this.validateTargetOptions(targetString);
this.browserOptions = await this.validateTargetOptions(
this.universalOptions.browserTarget,
{ watch: true },
);
this.serverOptions = await this.validateTargetOptions(
this.universalOptions.serverTarget,
{ watch: true },
);
return workspaceLoader.loadWorkspace(this.project.root).pipe(operators_1.tap((workspace) => this._workspace = workspace), operators_1.concatMap((workspace) => {
return new architect_1.Architect(workspace).loadArchitect();
}), operators_1.tap((architect) => this._architect = architect));
}
const registry = new schema.CoreSchemaRegistry();
registry.addPostTransform(schema.transforms.addUndefinedDefaults);
const workspaceSysPath = getSystemPath(host.root());
const { workspace } = await workspaces.readWorkspace(
workspaceSysPath,
workspaces.createWorkspaceHost(host),
);
const architectHost = new TestingArchitectHost(
workspaceSysPath,
workspaceSysPath,
new WorkspaceNodeModulesArchitectHost(workspace, workspaceSysPath),
);
architect = new Architect(architectHost, registry);
});