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');
public async initialize(options: T & Arguments): Promise {
await super.initialize(options);
this._registry = new json.schema.CoreSchemaRegistry();
this._registry.addPostTransform(json.schema.transforms.addUndefinedDefaults);
const { workspace } = await workspaces.readWorkspace(
this.workspace.root,
workspaces.createWorkspaceHost(new NodeJsSyncHost()),
);
this._workspace = workspace;
this._architectHost = new WorkspaceNodeModulesArchitectHost(workspace, this.workspace.root);
this._architect = new Architect(this._architectHost, this._registry);
if (!this.target) {
if (options.help) {
// This is a special case where we just return.
return;
}
const specifier = this._makeTargetSpecifier(options);
if (!specifier.project || !specifier.target) {
throw new Error('Cannot determine project or target for command.');
}
return;
}
beforeEach(async () => {
const registry = new schema.CoreSchemaRegistry();
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);
});
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);
}
beforeEach(async () => {
await host.initialize().toPromise();
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);
});
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);
}
return handleErrors(logger, isVerbose, async () => {
const fsHost = new NodeJsSyncHost();
const workspace = await new experimental.workspace.Workspace(
normalize(root) as any,
fsHost
)
.loadWorkspaceFromHost('workspace.json' as any)
.toPromise();
const opts = parseRunOpts(args, workspace.getDefaultProjectName(), logger);
validateTargetAndConfiguration(workspace, opts);
const registry = new json.schema.CoreSchemaRegistry();
registry.addPostTransform(schema.transforms.addUndefinedDefaults);
const architectHost = new WorkspaceNodeModulesArchitectHost(
workspace,
root
);
const architect = new Architect(architectHost, registry);
const builderConf = await architectHost.getBuilderNameForTarget({
project: opts.project,
target: opts.target
});
const builderDesc = await architectHost.resolveBuilder(builderConf);
const flattenedSchema = await registry
.flatten(builderDesc.optionSchema! as json.JsonObject)
.toPromise();
if (opts.help) {
printRunHelp(opts, flattenedSchema as any, logger);
beforeEach(async () => {
await host.initialize().toPromise();
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);
});