Skip to content

Commit

Permalink
fix(misc): move --useDotNxInstallation to yargs config (#18475)
Browse files Browse the repository at this point in the history
  • Loading branch information
AgentEnder committed Aug 3, 2023
1 parent 4fe0bd6 commit c175fc3
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 14 deletions.
8 changes: 8 additions & 0 deletions docs/generated/cli/init.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ Type: `boolean`

Set up distributed caching with Nx Cloud.

### useDotNxInstallation

Type: `boolean`

Default: `false`

Initialize an Nx workspace setup in the .nx directory of the current repository.

### version

Type: `boolean`
Expand Down
8 changes: 8 additions & 0 deletions docs/generated/packages/nx/documents/init.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ Type: `boolean`

Set up distributed caching with Nx Cloud.

### useDotNxInstallation

Type: `boolean`

Default: `false`

Initialize an Nx workspace setup in the .nx directory of the current repository.

### version

Type: `boolean`
Expand Down
14 changes: 10 additions & 4 deletions packages/nx/src/command-line/init/command-object.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CommandModule, Argv } from 'yargs';
import { CommandModule, Argv, boolean } from 'yargs';
import { parseCSV } from '../yargs-utils/shared-options';

export const yargsInitCommand: CommandModule = {
Expand All @@ -14,7 +14,7 @@ export const yargsInitCommand: CommandModule = {

function withInitOptions(yargs: Argv) {
return yargs
.options('nxCloud', {
.option('nxCloud', {
type: 'boolean',
description: 'Set up distributed caching with Nx Cloud.',
})
Expand All @@ -35,18 +35,24 @@ function withInitOptions(yargs: Argv) {
type: 'boolean',
default: false,
})
.option('useDotNxInstallation', {
type: 'boolean',
description:
'Initialize an Nx workspace setup in the .nx directory of the current repository.',
default: false,
})
.option('force', {
describe:
'Force the migration to continue and ignore custom webpack setup or uncommitted changes. Only for CRA projects.',
type: 'boolean',
default: false,
})
.options('vite', {
.option('vite', {
type: 'boolean',
description: 'Use Vite as the bundler. Only for CRA projects.',
default: true,
})
.options('cacheable', {
.option('cacheable', {
type: 'string',
description:
'Comma-separated list of cacheable operations. Only used for internal testing.',
Expand Down
12 changes: 2 additions & 10 deletions packages/nx/src/command-line/init/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,19 @@ export interface InitArgs {
vite: boolean;
nxCloud?: boolean;
cacheable?: string[];
useDotNxInstallation?: boolean;
}

export async function initHandler(options: InitArgs) {
// strip the 'init' command itself so we don't forward it
const args = process.argv.slice(3).join(' ');
const flags = parser(args, {
boolean: ['useDotNxInstallation'],
alias: {
useDotNxInstallation: ['encapsulated'],
},
default: {
useDotNxInstallation: false,
},
}) as any as { useDotNxInstallation: boolean };

const version =
process.env.NX_VERSION ?? (prerelease(nxVersion) ? 'next' : 'latest');
if (process.env.NX_VERSION) {
console.log(`Using version ${process.env.NX_VERSION}`);
}
if (flags.useDotNxInstallation === true) {
if (options.useDotNxInstallation === true) {
setupDotNxInstallation(version);
} else if (existsSync('package.json')) {
const packageJson: PackageJson = readJsonFile('package.json');
Expand Down

1 comment on commit c175fc3

@vercel
Copy link

@vercel vercel bot commented on c175fc3 Aug 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nx-dev – ./

nx-dev-nrwl.vercel.app
nx-dev-git-master-nrwl.vercel.app
nx-five.vercel.app
nx.dev

Please sign in to comment.