Skip to content

Commit 8ef3167

Browse files
clydinmgechev
authored andcommitted
refactor(@angular-devkit/architect-cli): use stable workspace API
1 parent d3e2267 commit 8ef3167

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

packages/angular_devkit/architect_cli/bin/architect.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,15 @@
99
import { Architect, BuilderInfo, BuilderProgressState, Target } from '@angular-devkit/architect';
1010
import { WorkspaceNodeModulesArchitectHost } from '@angular-devkit/architect/node';
1111
import {
12-
experimental,
1312
json,
1413
logging,
15-
normalize,
1614
schema,
1715
tags,
1816
terminal,
17+
workspaces,
1918
} from '@angular-devkit/core';
2019
import { NodeJsSyncHost, createConsoleLogger } from '@angular-devkit/core/node';
21-
import { existsSync, readFileSync } from 'fs';
20+
import { existsSync } from 'fs';
2221
import * as minimist from 'minimist';
2322
import * as path from 'path';
2423
import { tap } from 'rxjs/operators';
@@ -82,7 +81,7 @@ interface BarInfo {
8281
8382
async function _executeTarget(
8483
parentLogger: logging.Logger,
85-
workspace: experimental.workspace.Workspace,
84+
workspace: workspaces.WorkspaceDefinition,
8685
root: string,
8786
argv: minimist.ParsedArgs,
8887
registry: json.schema.SchemaRegistry,
@@ -213,16 +212,14 @@ async function main(args: string[]): Promise<number> {
213212
}
214213

215214
const root = path.dirname(configFilePath);
216-
const configContent = readFileSync(configFilePath, 'utf-8');
217-
const workspaceJson = JSON.parse(configContent);
218215

219216
const registry = new schema.CoreSchemaRegistry();
220217
registry.addPostTransform(schema.transforms.addUndefinedDefaults);
221218

222-
const host = new NodeJsSyncHost();
223-
const workspace = new experimental.workspace.Workspace(normalize(root), host);
224-
225-
await workspace.loadWorkspaceFromJson(workspaceJson).toPromise();
219+
const { workspace } = await workspaces.readWorkspace(
220+
configFilePath,
221+
workspaces.createWorkspaceHost(new NodeJsSyncHost()),
222+
);
226223

227224
// Clear the console.
228225
process.stdout.write('\u001Bc');

0 commit comments

Comments
 (0)