create-nx-workspace 19.0.1 → 19.0.3

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-nx-workspace",
3
- "version": "19.0.1",
3
+ "version": "19.0.3",
4
4
  "private": false,
5
5
  "description": "Smart Monorepos · Fast CI",
6
6
  "repository": {
@@ -7,7 +7,6 @@ const child_process_utils_1 = require("./utils/child-process-utils");
7
7
  const error_utils_1 = require("./utils/error-utils");
8
8
  const output_1 = require("./utils/output");
9
9
  const package_manager_1 = require("./utils/package-manager");
10
- const string_utils_1 = require("./utils/string-utils");
11
10
  const unparse_1 = require("./utils/unparse");
12
11
  /**
13
12
  * Create a new Nx workspace
@@ -23,7 +22,6 @@ async function createEmptyWorkspace(tmpDir, name, packageManager, options) {
23
22
  if (!options.packageManager) {
24
23
  options.packageManager = packageManager;
25
24
  }
26
- options.name = (0, string_utils_1.getFileName)(name);
27
25
  const directory = options.name;
28
26
  const args = (0, unparse_1.unparse)({
29
27
  ...options,
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.recordStat = exports.messages = exports.PromptMessages = exports.NxCloudChoices = void 0;
4
+ const node_child_process_1 = require("node:child_process");
4
5
  const is_ci_1 = require("../ci/is-ci");
6
+ const package_manager_1 = require("../package-manager");
5
7
  exports.NxCloudChoices = ['yes', 'github', 'circleci', 'skip'];
6
8
  const messageOptions = {
7
9
  setupCI: [
@@ -81,12 +83,9 @@ exports.messages = new PromptMessages();
81
83
  */
82
84
  async function recordStat(opts) {
83
85
  try {
84
- const major = Number(opts.nxVersion.split('.')[0]);
85
- if (process.env.NX_VERBOSE_LOGGING === 'true') {
86
- console.log(`Record stat. Major: ${major}`);
86
+ if (!shouldRecordStats()) {
87
+ return;
87
88
  }
88
- if (major < 10 || major > 19)
89
- return; // test version, skip it
90
89
  const axios = require('axios');
91
90
  await (axios['default'] ?? axios)
92
91
  .create({
@@ -107,3 +106,16 @@ async function recordStat(opts) {
107
106
  }
108
107
  }
109
108
  exports.recordStat = recordStat;
109
+ function shouldRecordStats() {
110
+ const pmc = (0, package_manager_1.getPackageManagerCommand)();
111
+ try {
112
+ const stdout = (0, node_child_process_1.execSync)(pmc.getRegistryUrl, { encoding: 'utf-8' });
113
+ const url = new URL(stdout.trim());
114
+ // don't record stats when testing locally
115
+ return url.hostname !== 'localhost';
116
+ }
117
+ catch {
118
+ // fallback to true if we can't detect the registry
119
+ return true;
120
+ }
121
+ }
@@ -18,6 +18,7 @@ export declare function getPackageManagerCommand(packageManager?: PackageManager
18
18
  exec: string;
19
19
  preInstall?: string;
20
20
  globalAdd: string;
21
+ getRegistryUrl: string;
21
22
  };
22
23
  export declare function generatePackageManagerFiles(root: string, packageManager?: PackageManager): void;
23
24
  export declare function getPackageManagerVersion(packageManager: PackageManager, cwd?: string): string;
@@ -44,6 +44,9 @@ function getPackageManagerCommand(packageManager = detectPackageManager()) {
44
44
  // using npx is necessary to avoid yarn classic manipulating the version detection when using berry
45
45
  exec: useBerry ? 'npx' : 'yarn',
46
46
  globalAdd: 'yarn global add',
47
+ getRegistryUrl: useBerry
48
+ ? 'yarn config get npmRegistryServer'
49
+ : 'yarn config get registry',
47
50
  };
48
51
  case 'pnpm':
49
52
  let useExec = false;
@@ -54,12 +57,14 @@ function getPackageManagerCommand(packageManager = detectPackageManager()) {
54
57
  install: 'pnpm install --no-frozen-lockfile --silent --ignore-scripts',
55
58
  exec: useExec ? 'pnpm exec' : 'pnpx',
56
59
  globalAdd: 'pnpm add -g',
60
+ getRegistryUrl: 'pnpm config get registry',
57
61
  };
58
62
  case 'npm':
59
63
  return {
60
64
  install: 'npm install --silent --ignore-scripts',
61
65
  exec: 'npx',
62
66
  globalAdd: 'npm i -g',
67
+ getRegistryUrl: 'npm config get registry',
63
68
  };
64
69
  }
65
70
  }
@@ -1,2 +1 @@
1
1
  export declare function stringifyCollection(items: string[]): string;
2
- export declare function getFileName(name: string): string;
@@ -1,14 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getFileName = exports.stringifyCollection = void 0;
3
+ exports.stringifyCollection = void 0;
4
4
  function stringifyCollection(items) {
5
5
  return items.map((item) => `"${item}"`).join(', ');
6
6
  }
7
7
  exports.stringifyCollection = stringifyCollection;
8
- function getFileName(name) {
9
- return name
10
- .replace(/([a-z\d])([A-Z])/g, '$1_$2')
11
- .toLowerCase()
12
- .replace(/[ _]/g, '-');
13
- }
14
- exports.getFileName = getFileName;