create-nx-workspace 23.0.0-beta.0 → 23.0.0-beta.10

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.
@@ -1026,10 +1026,6 @@ async function determineReactOptions(parsedArgs) {
1026
1026
  name: 'less',
1027
1027
  message: 'LESS [ https://lesscss.org ]',
1028
1028
  },
1029
- {
1030
- name: 'tailwind',
1031
- message: 'tailwind [ https://tailwindcss.com ]',
1032
- },
1033
1029
  {
1034
1030
  name: 'styled-components',
1035
1031
  message: 'styled-components [ https://styled-components.com ]',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-nx-workspace",
3
- "version": "23.0.0-beta.0",
3
+ "version": "23.0.0-beta.10",
4
4
  "private": false,
5
5
  "description": "Smart Monorepos · Fast Builds",
6
6
  "repository": {
@@ -30,12 +30,12 @@
30
30
  },
31
31
  "homepage": "https://nx.dev",
32
32
  "dependencies": {
33
- "axios": "1.15.0",
33
+ "axios": "1.16.0",
34
34
  "chalk": "^4.1.0",
35
35
  "enquirer": "~2.3.6",
36
36
  "flat": "^5.0.2",
37
37
  "open": "^8.4.0",
38
- "ora": "5.3.0",
38
+ "ora": "^5.3.0",
39
39
  "tmp": "~0.2.1",
40
40
  "tslib": "^2.3.0",
41
41
  "yargs": "^17.6.2"
@@ -1 +1 @@
1
- {"version":3,"file":"create-workspace.d.ts","sourceRoot":"","sources":["../../../../packages/create-nx-workspace/src/create-workspace.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAGpE,OAAO,EAIL,aAAa,EACd,MAAM,iBAAiB,CAAC;AA6BzB,wBAAgB,4BAA4B,IAAI;IAC9C,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;CAChC,CAEA;AAED,wBAAsB,eAAe,CAAC,CAAC,SAAS,sBAAsB,EACpE,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,OAAO,EAAE,CAAC,EACV,OAAO,CAAC,EAAE,CAAC;;;;;;GA+RZ;AAUD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAI7D;AASD,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEjE"}
1
+ {"version":3,"file":"create-workspace.d.ts","sourceRoot":"","sources":["../../../../packages/create-nx-workspace/src/create-workspace.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAGpE,OAAO,EAIL,aAAa,EACd,MAAM,iBAAiB,CAAC;AA+BzB,wBAAgB,4BAA4B,IAAI;IAC9C,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;CAChC,CAEA;AAED,wBAAsB,eAAe,CAAC,CAAC,SAAS,sBAAsB,EACpE,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,OAAO,EAAE,CAAC,EACV,OAAO,CAAC,EAAE,CAAC;;;;;;GAgTZ;AAUD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAI7D;AASD,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEjE"}
@@ -21,6 +21,8 @@ const update_readme_1 = require("./utils/template/update-readme");
21
21
  const child_process_utils_1 = require("./utils/child-process-utils");
22
22
  const package_manager_1 = require("./utils/package-manager");
23
23
  const ai_output_1 = require("./utils/ai/ai-output");
24
+ const prompts_1 = require("./internal-utils/prompts");
25
+ const error_utils_2 = require("./utils/error-utils");
24
26
  // State for SIGINT handler - only set after workspace is fully installed
25
27
  let workspaceDirectory;
26
28
  let cloudConnectUrl;
@@ -96,6 +98,16 @@ async function createWorkspace(preset, options, rawArgs) {
96
98
  if (!preset) {
97
99
  throw new Error('Preset is required when not using a template. Please provide --preset or --template.');
98
100
  }
101
+ // If the preset is a third-party preset, warn the user before installing
102
+ // the npm package. A preset name like "core" silently installs an
103
+ // unrelated npm package; this confirmation makes that explicit.
104
+ const thirdPartyPackageName = (0, get_third_party_preset_1.getPackageNameFromThirdPartyPreset)(preset);
105
+ if (thirdPartyPackageName) {
106
+ const confirmed = await (0, prompts_1.confirmThirdPartyPreset)(thirdPartyPackageName, options.interactive);
107
+ if (!confirmed) {
108
+ throw new error_utils_2.CnwError('INVALID_PRESET', `Aborted: not installing third-party preset '${thirdPartyPackageName}'.`);
109
+ }
110
+ }
99
111
  const tmpDir = await (0, create_sandbox_1.createSandbox)(packageManager);
100
112
  const workspaceGlobs = getWorkspaceGlobsFromPreset(preset);
101
113
  // nx new requires a preset currently. We should probably make it optional.
@@ -112,7 +124,6 @@ async function createWorkspace(preset, options, rawArgs) {
112
124
  // If the preset is a third-party preset, we need to call createPreset to install it
113
125
  // For first-party presets, it will be created by createEmptyWorkspace instead.
114
126
  // In createEmptyWorkspace, it will call `nx new` -> `@nx/workspace newGenerator` -> `@nx/workspace generatePreset`.
115
- const thirdPartyPackageName = (0, get_third_party_preset_1.getPackageNameFromThirdPartyPreset)(preset);
116
127
  if (thirdPartyPackageName) {
117
128
  await (0, create_preset_1.createPreset)(thirdPartyPackageName, options, packageManager, directory);
118
129
  }
@@ -28,6 +28,20 @@ export declare function determineAnalytics(parsedArgs: yargs.Arguments<{
28
28
  export declare function determineDefaultBase(parsedArgs: yargs.Arguments<{
29
29
  defaultBase?: string;
30
30
  }>): Promise<string>;
31
+ /**
32
+ * Confirm with the user before installing a third-party preset npm package.
33
+ *
34
+ * `--preset=<name>` will install any npm package whose name matches when the
35
+ * preset is not a known Nx preset. A typo (e.g. `--preset=core`) can silently
36
+ * install an unrelated package from the registry, which is a supply-chain
37
+ * risk. This prompt makes that step explicit.
38
+ *
39
+ * In non-interactive / CI / AI-agent contexts we cannot prompt, so we emit a
40
+ * warning and proceed — automated workflows like
41
+ * `--preset=@my-org/nx-plugin --no-interactive` keep working, but the warning
42
+ * still appears in the logs.
43
+ */
44
+ export declare function confirmThirdPartyPreset(packageName: string, interactive: boolean | undefined): Promise<boolean>;
31
45
  export declare function determinePackageManager(parsedArgs: yargs.Arguments<{
32
46
  packageManager: string;
33
47
  }>): Promise<PackageManager>;
@@ -1 +1 @@
1
- {"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../../../../packages/create-nx-workspace/src/internal-utils/prompts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAO1B,OAAO,EAEL,cAAc,EAEf,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,OAAO,EACL,KAAK,EAGN,MAAM,6BAA6B,CAAC;AAIrC,wBAAsB,gBAAgB,CACpC,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,GAChD,OAAO,CAAC,OAAO,CAAC,CAQlB;AAED,wBAAsB,kBAAkB,CACtC,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,GACvE,OAAO,CAAC,KAAK,GAAG,MAAM,GAAG,OAAO,CAAC,CAiBnC;AAED,wBAAsB,2BAA2B,CAC/C,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,GACrE,OAAO,CAAC,OAAO,CAAC,CAelB;AA4BD,wBAAsB,iBAAiB,CACrC,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC,GACD,OAAO,CA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cAAc,EAAE,MAAM,CAAA;CAAE,CAAC,GACtD,OAAO,CAAC,cAAc,CAAC,CAiCzB"}
@@ -7,6 +7,7 @@ exports.determineTemplate = determineTemplate;
7
7
  exports.determineAiAgents = determineAiAgents;
8
8
  exports.determineAnalytics = determineAnalytics;
9
9
  exports.determineDefaultBase = determineDefaultBase;
10
+ exports.confirmThirdPartyPreset = confirmThirdPartyPreset;
10
11
  exports.determinePackageManager = determinePackageManager;
11
12
  const tslib_1 = require("tslib");
12
13
  const enquirer_1 = tslib_1.__importDefault(require("enquirer"));
@@ -20,6 +21,7 @@ const is_ci_1 = require("../utils/ci/is-ci");
20
21
  const create_workspace_options_1 = require("../create-workspace-options");
21
22
  const ai_output_1 = require("../utils/ai/ai-output");
22
23
  const error_utils_1 = require("../utils/error-utils");
24
+ const output_1 = require("../utils/output");
23
25
  async function determineNxCloud(parsedArgs) {
24
26
  if (parsedArgs.nxCloud) {
25
27
  return parsedArgs.nxCloud;
@@ -200,6 +202,42 @@ async function determineDefaultBase(parsedArgs) {
200
202
  }
201
203
  return (0, default_base_1.deduceDefaultBase)();
202
204
  }
205
+ /**
206
+ * Confirm with the user before installing a third-party preset npm package.
207
+ *
208
+ * `--preset=<name>` will install any npm package whose name matches when the
209
+ * preset is not a known Nx preset. A typo (e.g. `--preset=core`) can silently
210
+ * install an unrelated package from the registry, which is a supply-chain
211
+ * risk. This prompt makes that step explicit.
212
+ *
213
+ * In non-interactive / CI / AI-agent contexts we cannot prompt, so we emit a
214
+ * warning and proceed — automated workflows like
215
+ * `--preset=@my-org/nx-plugin --no-interactive` keep working, but the warning
216
+ * still appears in the logs.
217
+ */
218
+ async function confirmThirdPartyPreset(packageName, interactive) {
219
+ output_1.output.warn({
220
+ title: `About to install '${packageName}' from the npm registry as a preset.`,
221
+ bodyLines: [
222
+ `'${packageName}' is not a built-in Nx preset.`,
223
+ `Nx will download this npm package and run its preset generator.`,
224
+ `Only proceed if you trust the publisher of '${packageName}'.`,
225
+ ],
226
+ });
227
+ if (interactive === false || (0, is_ci_1.isCI)() || (0, ai_output_1.isAiAgent)()) {
228
+ return true;
229
+ }
230
+ const { confirm } = await enquirer_1.default.prompt([
231
+ {
232
+ name: 'confirm',
233
+ message: `Install third-party preset '${packageName}'?`,
234
+ type: 'autocomplete',
235
+ choices: [{ name: 'No' }, { name: 'Yes' }],
236
+ initial: 0,
237
+ },
238
+ ]);
239
+ return confirm === 'Yes';
240
+ }
203
241
  async function determinePackageManager(parsedArgs) {
204
242
  const packageManager = parsedArgs.packageManager;
205
243
  if (packageManager) {