Skip to content

Commit

Permalink
fix(core): ngcli-adapter should work on windows without workspace.jso…
Browse files Browse the repository at this point in the history
…n present (#9163)
  • Loading branch information
AgentEnder committed Mar 18, 2022
1 parent 2d57ac0 commit 6284eb6
Showing 1 changed file with 9 additions and 37 deletions.
46 changes: 9 additions & 37 deletions packages/nx/src/commands/ngcli-adapter.ts
Expand Up @@ -54,7 +54,7 @@ export async function scheduleTarget(
} = require('@angular-devkit/architect/node');

const logger = getTargetLogger(opts.executor, verbose);
const fsHost = new NxScopedHost(normalize(root));
const fsHost = new NxScopedHost(root);
const { workspace } = await workspaces.readWorkspace(
workspaceConfigName(root),
workspaces.createWorkspaceHost(fsHost)
Expand Down Expand Up @@ -214,8 +214,8 @@ type AngularJsonConfiguration = WorkspaceJsonConfiguration &
export class NxScopedHost extends virtualFs.ScopedHost<any> {
protected __nxInMemoryWorkspace: WorkspaceJsonConfiguration | null;

constructor(root: Path) {
super(new NodeJsSyncHost(), root);
constructor(private root: string) {
super(new NodeJsSyncHost(), normalize(root));
}

protected __readWorkspaceConfiguration = (
Expand Down Expand Up @@ -243,7 +243,7 @@ export class NxScopedHost extends virtualFs.ScopedHost<any> {
.read(configFileName)
.pipe(map((data) => parseJson(Buffer.from(data).toString())));
} else {
const staticProjects = globForProjectFiles(this._root);
const staticProjects = globForProjectFiles(this.root);
this.__nxInMemoryWorkspace = buildWorkspaceConfigurationFromGlobs(
nxJson,
staticProjects.filter((x) => basename(x) !== 'package.json')
Expand Down Expand Up @@ -569,33 +569,8 @@ type ChangeContext = {
isNewFormat: boolean;
};

/**
* This host contains the workaround needed to run Angular migrations
*/
export class NxScopedHostForMigrations extends NxScopedHost {
constructor(root: Path) {
super(root);
}

read(path: Path): Observable<FileBuffer> {
if (isWorkspaceConfigPath(path)) {
return super.read(path).pipe(map(processConfigWhenReading));
} else {
return super.read(path);
}
}

write(path: Path, content: FileBuffer) {
if (isWorkspaceConfigPath(path)) {
return super.write(path, processConfigWhenWriting(content));
} else {
return super.write(path, content);
}
}
}

export class NxScopeHostUsedForWrappedSchematics extends NxScopedHost {
constructor(root: Path, private readonly host: Tree) {
constructor(root: string, private readonly host: Tree) {
super(root);
}

Expand Down Expand Up @@ -835,7 +810,7 @@ export async function generate(
verbose: boolean
) {
const logger = getLogger(verbose);
const fsHost = new NxScopedHost(normalize(root));
const fsHost = new NxScopedHost(root);
const workflow = createWorkflow(fsHost, root, opts);
const collection = getCollection(workflow, opts.collectionName);
const schematic = collection.createSchematic(opts.generatorName, true);
Expand Down Expand Up @@ -921,7 +896,7 @@ export async function runMigration(
isVerbose: boolean
) {
const logger = getLogger(isVerbose);
const fsHost = new NxScopedHost(normalize(root));
const fsHost = new NxScopedHost(root);
const workflow = createWorkflow(fsHost, root, {});
const collection = resolveMigrationsCollection(packageName);
return workflow
Expand Down Expand Up @@ -1131,10 +1106,7 @@ export function wrapAngularDevkitSchematic(
}
};

const fsHost = new NxScopeHostUsedForWrappedSchematics(
normalize(host.root),
host
);
const fsHost = new NxScopeHostUsedForWrappedSchematics(host.root, host);

const options = {
generatorOptions,
Expand Down Expand Up @@ -1186,7 +1158,7 @@ export async function invokeNew(
verbose: boolean
) {
const logger = getLogger(verbose);
const fsHost = new NxScopedHost(normalize(root));
const fsHost = new NxScopedHost(root);
const workflow = createWorkflow(fsHost, root, opts);
const collection = getCollection(workflow, opts.collectionName);
const schematic = collection.createSchematic('new', true);
Expand Down

0 comments on commit 6284eb6

Please sign in to comment.