Skip to content

Commit

Permalink
fix(core): workspace-generator signature
Browse files Browse the repository at this point in the history
  • Loading branch information
meeroslav committed Oct 11, 2022
1 parent a250b61 commit d6f1353
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
10 changes: 4 additions & 6 deletions e2e/nx-misc/src/workspace.test.ts
Expand Up @@ -24,9 +24,7 @@ describe('Workspace Tests', () => {
proj = newProject();
});

afterAll(() => {
cleanupProject();
});
afterAll(() => cleanupProject());

describe('@nrwl/workspace:library', () => {
it('should create a library that can be tested and linted', async () => {
Expand Down Expand Up @@ -196,6 +194,7 @@ describe('Workspace Tests', () => {
description: 'skip changes to tsconfig',
};
json.properties['inlineprop'] = json.properties['name'];
json.required = ['inlineprop'];
delete json.properties['name'];

updateFile(
Expand All @@ -208,7 +207,7 @@ describe('Workspace Tests', () => {
`tools/generators/${custom}/index.ts`,
indexFile.replace(
'name: schema.name',
'inlineprop: schema.inlineprop, directory: schema.directory, skipTsConfig: schema.skipTsConfig'
'name: schema.inlineprop, directory: schema.directory, skipTsConfig: schema.skipTsConfig'
)
);

Expand All @@ -228,11 +227,10 @@ describe('Workspace Tests', () => {
`CREATE libs/dir/${workspace}/src/index.ts`
);

const output = runCLI(
runCLI(
`workspace-generator ${custom} ${workspace} --no-interactive --directory=dir`
);
checkFilesExist(`libs/dir/${workspace}/src/index.ts`);
expect(output).not.toContain('UPDATE nx.json');

const jsonFailing = readJson(`tools/generators/${failing}/schema.json`);
jsonFailing.properties = {};
Expand Down
30 changes: 17 additions & 13 deletions packages/nx/src/command-line/nx-commands.ts
Expand Up @@ -259,12 +259,7 @@ export const commandsObject = yargs
await withWorkspaceGeneratorOptions(yargs, process.argv.slice(3)),
'workspace-generator'
),
handler: async () => {
await (
await import('./workspace-generators')
).workspaceGenerators(process.argv.slice(3));
process.exit(0);
},
handler: workspaceGeneratorHandler,
})
.command({
command: 'migrate [packageAndVersion]',
Expand Down Expand Up @@ -847,23 +842,32 @@ async function withCustomGeneratorOptions(
command += ' [options]';
}

yargs.wrap(yargs.terminalWidth()).command(
yargs.command({
// this is the default and only command
command,
schema.description || '',
(yargs) => {
describe: schema.description || '',
builder: (y) => {
options.forEach(({ name, definition }) => {
yargs.option(name, definition);
y.option(name, definition);
});
positionals.forEach(({ name, definition }) => {
yargs.positional(name, definition);
y.positional(name, definition);
});
}
);
return linkToNxDevAndExamples(y, 'workspace-generator');
},
handler: workspaceGeneratorHandler,
});

return yargs;
}

async function workspaceGeneratorHandler() {
await (
await import('./workspace-generators')
).workspaceGenerators(process.argv.slice(3));
process.exit(0);
}

function withMigrationOptions(yargs: yargs.Argv) {
const defaultCommitPrefix = 'chore: [nx migration] ';

Expand Down

0 comments on commit d6f1353

Please sign in to comment.