create-nx-workspace 18.0.0-beta.0 → 18.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -103,7 +103,7 @@ exports.commandsObject = yargs
103
103
  }, [
104
104
  normalizeArgsMiddleware,
105
105
  normalizeAndWarnOnDeprecatedPreset({
106
- // TODO(v18): Remove Empty and Core presets
106
+ // TODO(v19): Remove Empty and Core presets
107
107
  [preset_1.Preset.Core]: preset_1.Preset.NPM,
108
108
  [preset_1.Preset.Empty]: preset_1.Preset.Apps,
109
109
  }),
@@ -114,10 +114,6 @@ exports.commandsObject = yargs
114
114
  async function main(parsedArgs) {
115
115
  output_1.output.log({
116
116
  title: `Creating your v${nx_version_1.nxVersion} workspace.`,
117
- bodyLines: [
118
- 'To make sure the command works reliably in all environments, and that the preset is applied correctly,',
119
- `Nx will run "${parsedArgs.packageManager} install" several times. Please wait.`,
120
- ],
121
117
  });
122
118
  const workspaceInfo = await (0, create_workspace_1.createWorkspace)(parsedArgs.preset, parsedArgs);
123
119
  (0, show_nx_warning_1.showNxWarning)(parsedArgs.name);
@@ -170,8 +166,6 @@ async function normalizeArgsMiddleware(argv) {
170
166
  });
171
167
  try {
172
168
  let thirdPartyPreset;
173
- // Node options
174
- let docker;
175
169
  try {
176
170
  thirdPartyPreset = await (0, get_third_party_preset_1.getThirdPartyPreset)(argv.preset);
177
171
  }
@@ -448,11 +442,11 @@ async function determineReactOptions(parsedArgs) {
448
442
  },
449
443
  {
450
444
  name: 'scss',
451
- message: 'SASS(.scss) [ http://sass-lang.com ]',
445
+ message: 'SASS(.scss) [ https://sass-lang.com ]',
452
446
  },
453
447
  {
454
448
  name: 'less',
455
- message: 'LESS [ http://lesscss.org ]',
449
+ message: 'LESS [ https://lesscss.org ]',
456
450
  },
457
451
  {
458
452
  name: 'styled-components',
@@ -539,11 +533,11 @@ async function determineVueOptions(parsedArgs) {
539
533
  },
540
534
  {
541
535
  name: 'scss',
542
- message: 'SASS(.scss) [ http://sass-lang.com ]',
536
+ message: 'SASS(.scss) [ https://sass-lang.com ]',
543
537
  },
544
538
  {
545
539
  name: 'less',
546
- message: 'LESS [ http://lesscss.org ]',
540
+ message: 'LESS [ https://lesscss.org ]',
547
541
  },
548
542
  {
549
543
  name: 'none',
@@ -626,11 +620,11 @@ async function determineAngularOptions(parsedArgs) {
626
620
  },
627
621
  {
628
622
  name: 'scss',
629
- message: 'SASS(.scss) [ http://sass-lang.com ]',
623
+ message: 'SASS(.scss) [ https://sass-lang.com ]',
630
624
  },
631
625
  {
632
626
  name: 'less',
633
- message: 'LESS [ http://lesscss.org ]',
627
+ message: 'LESS [ https://lesscss.org ]',
634
628
  },
635
629
  ],
636
630
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-nx-workspace",
3
- "version": "18.0.0-beta.0",
3
+ "version": "18.0.0-beta.2",
4
4
  "private": false,
5
5
  "description": "Smart Monorepos · Fast CI",
6
6
  "repository": {
@@ -36,7 +36,7 @@
36
36
  "tmp": "~0.2.1",
37
37
  "tslib": "^2.3.0",
38
38
  "yargs": "^17.6.2",
39
- "axios": "^1.5.1"
39
+ "axios": "^1.6.0"
40
40
  },
41
41
  "publishConfig": {
42
42
  "access": "public"
@@ -16,10 +16,10 @@ async function createWorkspace(preset, options) {
16
16
  output_1.output.setCliName(cliName ?? 'NX');
17
17
  }
18
18
  const tmpDir = await (0, create_sandbox_1.createSandbox)(packageManager);
19
- // nx new requires preset currently. We should probably make it optional.
19
+ // nx new requires a preset currently. We should probably make it optional.
20
20
  const directory = await (0, create_empty_workspace_1.createEmptyWorkspace)(tmpDir, name, packageManager, { ...options, preset });
21
21
  // If the preset is a third-party preset, we need to call createPreset to install it
22
- // For first-party presets, it will created by createEmptyWorkspace instead.
22
+ // For first-party presets, it will be created by createEmptyWorkspace instead.
23
23
  // In createEmptyWorkspace, it will call `nx new` -> `@nx/workspace newGenerator` -> `@nx/workspace generatePreset`.
24
24
  const thirdPartyPreset = await (0, get_third_party_preset_1.getThirdPartyPreset)(preset);
25
25
  if (thirdPartyPreset) {
@@ -27,7 +27,7 @@ async function createWorkspace(preset, options) {
27
27
  }
28
28
  let nxCloudInstallRes;
29
29
  if (nxCloud !== 'skip') {
30
- nxCloudInstallRes = await (0, nx_cloud_1.setupNxCloud)(directory, packageManager);
30
+ nxCloudInstallRes = await (0, nx_cloud_1.setupNxCloud)(directory, packageManager, nxCloud);
31
31
  if (nxCloud !== 'yes') {
32
32
  await (0, setup_ci_1.setupCI)(directory, nxCloud, packageManager, nxCloudInstallRes?.code === 0);
33
33
  }
@@ -1,6 +1,6 @@
1
1
  import { PackageManager } from '../package-manager';
2
2
  export type NxCloud = 'yes' | 'github' | 'circleci' | 'skip';
3
- export declare function setupNxCloud(directory: string, packageManager: PackageManager): Promise<{
3
+ export declare function setupNxCloud(directory: string, packageManager: PackageManager, nxCloud: NxCloud): Promise<{
4
4
  code: number;
5
5
  stdout: string;
6
6
  }>;
@@ -6,12 +6,17 @@ const child_process_utils_1 = require("../child-process-utils");
6
6
  const output_1 = require("../output");
7
7
  const package_manager_1 = require("../package-manager");
8
8
  const error_utils_1 = require("../error-utils");
9
- async function setupNxCloud(directory, packageManager) {
9
+ async function setupNxCloud(directory, packageManager, nxCloud) {
10
10
  const nxCloudSpinner = ora(`Setting up Nx Cloud`).start();
11
11
  try {
12
12
  const pmc = (0, package_manager_1.getPackageManagerCommand)(packageManager);
13
13
  const res = await (0, child_process_utils_1.execAndWait)(`${pmc.exec} nx g nx:connect-to-nx-cloud --no-interactive --quiet`, directory);
14
- nxCloudSpinner.succeed('Nx Cloud has been set up successfully');
14
+ if (nxCloud !== 'yes') {
15
+ nxCloudSpinner.succeed('CI workflow with Nx Cloud has been generated successfully');
16
+ }
17
+ else {
18
+ nxCloudSpinner.succeed('Nx Cloud has been set up successfully');
19
+ }
15
20
  return res;
16
21
  }
17
22
  catch (e) {
@@ -33,12 +38,19 @@ async function setupNxCloud(directory, packageManager) {
33
38
  }
34
39
  exports.setupNxCloud = setupNxCloud;
35
40
  function printNxCloudSuccessMessage(nxCloudOut) {
36
- const bodyLines = nxCloudOut
37
- .split('Remote caching via Nx Cloud has been enabled')[1]
38
- .trim();
39
- output_1.output.note({
40
- title: `Remote caching via Nx Cloud has been enabled`,
41
- bodyLines: bodyLines.split('\n').map((r) => r.trim()),
41
+ // remove leading Nx carret and any new lines
42
+ const logContent = nxCloudOut.split('> NX ')[1];
43
+ const indexOfTitleEnd = logContent.indexOf('\n');
44
+ const title = logContent.slice(0, logContent.indexOf('\n')).trim();
45
+ const bodyLines = logContent
46
+ .slice(indexOfTitleEnd)
47
+ .replace(/^\n*/, '') // remove leading new lines
48
+ .replace(/\n*$/, '') // remove trailing new lines
49
+ .split('\n')
50
+ .map((r) => r.trim());
51
+ output_1.output.warn({
52
+ title,
53
+ bodyLines,
42
54
  });
43
55
  }
44
56
  exports.printNxCloudSuccessMessage = printNxCloudSuccessMessage;
@@ -4,6 +4,7 @@ exports.showNxWarning = void 0;
4
4
  const child_process_1 = require("child_process");
5
5
  const path_1 = require("path");
6
6
  const output_1 = require("../output");
7
+ const package_manager_1 = require("../package-manager");
7
8
  function showNxWarning(workspaceName) {
8
9
  try {
9
10
  const pathToRunNxCommand = (0, path_1.resolve)(process.cwd(), workspaceName);
@@ -14,12 +15,13 @@ function showNxWarning(workspaceName) {
14
15
  }
15
16
  catch (e) {
16
17
  // no nx found
18
+ const { exec, globalAdd } = (0, package_manager_1.getPackageManagerCommand)();
17
19
  output_1.output.addVerticalSeparator();
18
20
  output_1.output.note({
19
21
  title: `Nx CLI is not installed globally.`,
20
22
  bodyLines: [
21
- `This means that you might have to use "yarn nx" or "npx nx" to execute commands in the workspace.`,
22
- `Run "yarn global add nx" or "npm install -g nx" to be able to execute command directly.`,
23
+ `This means that you will have to use "${exec} nx" to execute commands in the workspace.`,
24
+ `Run "${globalAdd} nx" to be able to execute command directly.`,
23
25
  ],
24
26
  });
25
27
  }
@@ -17,6 +17,7 @@ export declare function getPackageManagerCommand(packageManager?: PackageManager
17
17
  install: string;
18
18
  exec: string;
19
19
  preInstall?: string;
20
+ globalAdd: string;
20
21
  };
21
22
  export declare function generatePackageManagerFiles(root: string, packageManager?: PackageManager): void;
22
23
  export declare function getPackageManagerVersion(packageManager: PackageManager, cwd?: string): string;
@@ -43,6 +43,7 @@ function getPackageManagerCommand(packageManager = detectPackageManager()) {
43
43
  : `${installCommand} --ignore-scripts`,
44
44
  // using npx is necessary to avoid yarn classic manipulating the version detection when using berry
45
45
  exec: useBerry ? 'npx' : 'yarn',
46
+ globalAdd: 'yarn global add',
46
47
  };
47
48
  case 'pnpm':
48
49
  let useExec = false;
@@ -52,11 +53,13 @@ function getPackageManagerCommand(packageManager = detectPackageManager()) {
52
53
  return {
53
54
  install: 'pnpm install --no-frozen-lockfile --silent --ignore-scripts',
54
55
  exec: useExec ? 'pnpm exec' : 'pnpx',
56
+ globalAdd: 'pnpm add -g',
55
57
  };
56
58
  case 'npm':
57
59
  return {
58
60
  install: 'npm install --silent --ignore-scripts',
59
61
  exec: 'npx',
62
+ globalAdd: 'npm i -g',
60
63
  };
61
64
  }
62
65
  }