@nx/js 16.4.0-beta.0 → 16.4.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.
Files changed (171) hide show
  1. package/babel.js +0 -1
  2. package/executors.json +1 -0
  3. package/generators.json +12 -0
  4. package/package.json +6 -5
  5. package/plugins/jest/local-registry.d.ts +1 -0
  6. package/plugins/jest/local-registry.js +4 -0
  7. package/src/executors/node/compat.js +0 -1
  8. package/src/executors/node/lib/kill-tree.js +0 -1
  9. package/src/executors/node/node-with-require-overrides.js +0 -1
  10. package/src/executors/node/node.impl.js +64 -13
  11. package/src/executors/swc/compat.js +0 -1
  12. package/src/executors/swc/swc.impl.js +0 -1
  13. package/src/executors/tsc/compat.js +0 -1
  14. package/src/executors/tsc/lib/batch/build-task-info-per-tsconfig-map.d.ts +4 -0
  15. package/src/executors/tsc/lib/batch/build-task-info-per-tsconfig-map.js +54 -0
  16. package/src/executors/tsc/lib/batch/generate-temp-tsconfig.d.ts +3 -0
  17. package/src/executors/tsc/lib/batch/generate-temp-tsconfig.js +52 -0
  18. package/src/executors/tsc/lib/batch/get-task-options.d.ts +3 -0
  19. package/src/executors/tsc/lib/batch/get-task-options.js +24 -0
  20. package/src/executors/tsc/lib/batch/index.d.ts +8 -0
  21. package/src/executors/tsc/lib/batch/index.js +11 -0
  22. package/src/executors/tsc/lib/batch/normalize-tasks-options.d.ts +3 -0
  23. package/src/executors/tsc/lib/batch/normalize-tasks-options.js +14 -0
  24. package/src/executors/tsc/lib/batch/types.d.ts +12 -0
  25. package/src/executors/tsc/lib/batch/types.js +2 -0
  26. package/src/executors/tsc/lib/batch/typescript-compilation.d.ts +7 -0
  27. package/src/executors/tsc/lib/batch/typescript-compilation.js +195 -0
  28. package/src/executors/tsc/lib/batch/typescript-diagnostic-reporters.d.ts +4 -0
  29. package/src/executors/tsc/lib/batch/typescript-diagnostic-reporters.js +44 -0
  30. package/src/executors/tsc/lib/batch/watch.d.ts +3 -0
  31. package/src/executors/tsc/lib/batch/watch.js +63 -0
  32. package/src/executors/tsc/lib/get-custom-transformers-factory.d.ts +3 -0
  33. package/src/executors/tsc/lib/get-custom-transformers-factory.js +13 -0
  34. package/src/executors/tsc/lib/index.d.ts +2 -0
  35. package/src/executors/tsc/lib/index.js +5 -0
  36. package/src/executors/tsc/lib/normalize-options.d.ts +2 -0
  37. package/src/executors/tsc/lib/normalize-options.js +32 -0
  38. package/src/executors/tsc/tsc.batch-impl.d.ts +4 -0
  39. package/src/executors/tsc/tsc.batch-impl.js +47 -0
  40. package/src/executors/tsc/tsc.impl.d.ts +0 -1
  41. package/src/executors/tsc/tsc.impl.js +4 -40
  42. package/src/executors/verdaccio/compat.js +0 -1
  43. package/src/executors/verdaccio/verdaccio.impl.d.ts +1 -0
  44. package/src/executors/verdaccio/verdaccio.impl.js +25 -23
  45. package/src/generators/convert-to-swc/convert-to-swc.js +0 -1
  46. package/src/generators/init/init.js +0 -1
  47. package/src/generators/library/library.js +2 -11
  48. package/src/generators/library/schema.json +7 -6
  49. package/src/generators/setup-build/generator.d.ts +5 -0
  50. package/src/generators/setup-build/generator.js +133 -0
  51. package/src/generators/setup-build/schema.d.ts +7 -0
  52. package/src/generators/setup-build/schema.json +42 -0
  53. package/src/generators/setup-verdaccio/files/config.yml +1 -1
  54. package/src/generators/setup-verdaccio/generator.js +5 -2
  55. package/src/index.d.ts +1 -0
  56. package/src/index.js +1 -1
  57. package/src/internal.js +0 -1
  58. package/src/migrations/update-13-10-1/update-lib-swcrc-exclude.js +0 -1
  59. package/src/migrations/update-13-8-5/update-node-executor.js +0 -1
  60. package/src/migrations/update-13-8-5/update-swcrc.js +0 -1
  61. package/src/migrations/update-14-0-0/exclude-jest-config-swcrc.js +0 -1
  62. package/src/migrations/update-14-1-5/update-swcrc-path.js +0 -1
  63. package/src/migrations/update-15-8-0/rename-swcrc-config.js +0 -1
  64. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +0 -1
  65. package/src/plugins/jest/start-local-registry.d.ts +12 -0
  66. package/src/plugins/jest/start-local-registry.js +61 -0
  67. package/src/utils/add-babel-inputs.d.ts +1 -0
  68. package/src/utils/add-babel-inputs.js +2 -1
  69. package/src/utils/add-local-registry-scripts.d.ts +5 -0
  70. package/src/utils/add-local-registry-scripts.js +57 -0
  71. package/src/utils/assets/assets.js +0 -1
  72. package/src/utils/assets/copy-assets-handler.d.ts +5 -1
  73. package/src/utils/assets/copy-assets-handler.js +34 -24
  74. package/src/utils/assets/index.js +0 -1
  75. package/src/utils/buildable-libs-utils.js +0 -1
  76. package/src/utils/check-dependencies.js +0 -1
  77. package/src/utils/code-frames/highlight.js +0 -1
  78. package/src/utils/code-frames/identifiers.js +0 -1
  79. package/src/utils/compiler-helper-dependency.js +0 -1
  80. package/src/utils/generate-globs.js +0 -1
  81. package/src/utils/get-import-path.js +0 -1
  82. package/src/utils/inline.d.ts +1 -1
  83. package/src/utils/inline.js +3 -4
  84. package/src/utils/minimal-publish-script.js +2 -6
  85. package/src/utils/package-json/get-npm-scope.js +0 -1
  86. package/src/utils/package-json/index.js +0 -1
  87. package/src/utils/package-json/update-package-json.js +0 -1
  88. package/src/utils/prettier.js +0 -1
  89. package/src/utils/schema.d.ts +3 -2
  90. package/src/utils/swc/add-swc-config.d.ts +1 -1
  91. package/src/utils/swc/add-swc-config.js +0 -1
  92. package/src/utils/swc/add-swc-dependencies.js +0 -1
  93. package/src/utils/swc/compile-swc.js +0 -1
  94. package/src/utils/swc/get-swcrc-path.js +0 -1
  95. package/src/utils/swc/inline.js +0 -1
  96. package/src/utils/typescript/__mocks__/plugin-a.js +0 -1
  97. package/src/utils/typescript/__mocks__/plugin-b.js +0 -1
  98. package/src/utils/typescript/add-tslib-dependencies.js +0 -1
  99. package/src/utils/typescript/ast-utils.js +0 -1
  100. package/src/utils/typescript/compile-typescript-files.js +0 -1
  101. package/src/utils/typescript/create-ts-config.js +0 -1
  102. package/src/utils/typescript/ensure-typescript.js +0 -1
  103. package/src/utils/typescript/get-source-nodes.js +0 -1
  104. package/src/utils/typescript/load-ts-transformers.js +0 -1
  105. package/src/utils/typescript/print-diagnostics.js +0 -1
  106. package/src/utils/typescript/run-type-check.js +0 -1
  107. package/src/utils/typescript/ts-config.js +0 -1
  108. package/src/utils/typescript/types.js +0 -1
  109. package/src/utils/versions.js +0 -1
  110. package/src/utils/watch-for-single-file-changes.js +0 -1
  111. package/babel.js.map +0 -1
  112. package/src/executors/node/compat.js.map +0 -1
  113. package/src/executors/node/lib/kill-tree.js.map +0 -1
  114. package/src/executors/node/node-with-require-overrides.js.map +0 -1
  115. package/src/executors/node/node.impl.js.map +0 -1
  116. package/src/executors/swc/compat.js.map +0 -1
  117. package/src/executors/swc/swc.impl.js.map +0 -1
  118. package/src/executors/tsc/compat.js.map +0 -1
  119. package/src/executors/tsc/tsc.impl.js.map +0 -1
  120. package/src/executors/verdaccio/compat.js.map +0 -1
  121. package/src/executors/verdaccio/verdaccio.impl.js.map +0 -1
  122. package/src/generators/convert-to-swc/convert-to-swc.js.map +0 -1
  123. package/src/generators/init/init.js.map +0 -1
  124. package/src/generators/library/library.js.map +0 -1
  125. package/src/generators/setup-verdaccio/generator.js.map +0 -1
  126. package/src/index.js.map +0 -1
  127. package/src/internal.js.map +0 -1
  128. package/src/migrations/update-13-10-1/update-lib-swcrc-exclude.js.map +0 -1
  129. package/src/migrations/update-13-8-5/update-node-executor.js.map +0 -1
  130. package/src/migrations/update-13-8-5/update-swcrc.js.map +0 -1
  131. package/src/migrations/update-14-0-0/exclude-jest-config-swcrc.js.map +0 -1
  132. package/src/migrations/update-14-1-5/update-swcrc-path.js.map +0 -1
  133. package/src/migrations/update-15-8-0/rename-swcrc-config.js.map +0 -1
  134. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js.map +0 -1
  135. package/src/utils/add-babel-inputs.js.map +0 -1
  136. package/src/utils/assets/assets.js.map +0 -1
  137. package/src/utils/assets/copy-assets-handler.js.map +0 -1
  138. package/src/utils/assets/index.js.map +0 -1
  139. package/src/utils/buildable-libs-utils.js.map +0 -1
  140. package/src/utils/check-dependencies.js.map +0 -1
  141. package/src/utils/code-frames/highlight.js.map +0 -1
  142. package/src/utils/code-frames/identifiers.js.map +0 -1
  143. package/src/utils/compiler-helper-dependency.js.map +0 -1
  144. package/src/utils/generate-globs.js.map +0 -1
  145. package/src/utils/get-import-path.js.map +0 -1
  146. package/src/utils/inline.js.map +0 -1
  147. package/src/utils/minimal-publish-script.js.map +0 -1
  148. package/src/utils/package-json/get-npm-scope.js.map +0 -1
  149. package/src/utils/package-json/index.js.map +0 -1
  150. package/src/utils/package-json/update-package-json.js.map +0 -1
  151. package/src/utils/prettier.js.map +0 -1
  152. package/src/utils/swc/add-swc-config.js.map +0 -1
  153. package/src/utils/swc/add-swc-dependencies.js.map +0 -1
  154. package/src/utils/swc/compile-swc.js.map +0 -1
  155. package/src/utils/swc/get-swcrc-path.js.map +0 -1
  156. package/src/utils/swc/inline.js.map +0 -1
  157. package/src/utils/typescript/__mocks__/plugin-a.js.map +0 -1
  158. package/src/utils/typescript/__mocks__/plugin-b.js.map +0 -1
  159. package/src/utils/typescript/add-tslib-dependencies.js.map +0 -1
  160. package/src/utils/typescript/ast-utils.js.map +0 -1
  161. package/src/utils/typescript/compile-typescript-files.js.map +0 -1
  162. package/src/utils/typescript/create-ts-config.js.map +0 -1
  163. package/src/utils/typescript/ensure-typescript.js.map +0 -1
  164. package/src/utils/typescript/get-source-nodes.js.map +0 -1
  165. package/src/utils/typescript/load-ts-transformers.js.map +0 -1
  166. package/src/utils/typescript/print-diagnostics.js.map +0 -1
  167. package/src/utils/typescript/run-type-check.js.map +0 -1
  168. package/src/utils/typescript/ts-config.js.map +0 -1
  169. package/src/utils/typescript/types.js.map +0 -1
  170. package/src/utils/versions.js.map +0 -1
  171. package/src/utils/watch-for-single-file-changes.js.map +0 -1
@@ -44,12 +44,10 @@ function projectGenerator(tree, schema, destinationDir, filesDir) {
44
44
  includeVitest: options.unitTestRunner === 'vitest',
45
45
  includeLib: true,
46
46
  skipFormat: true,
47
+ testEnvironment: options.testEnvironment,
47
48
  });
48
49
  tasks.push(viteTask);
49
50
  }
50
- if (options.bundler === 'rollup') {
51
- ensureBabelRootConfigExists(tree);
52
- }
53
51
  if (options.linter !== 'none') {
54
52
  const lintCallback = yield addLint(tree, options);
55
53
  tasks.push(lintCallback);
@@ -70,6 +68,7 @@ function projectGenerator(tree, schema, destinationDir, filesDir) {
70
68
  uiFramework: 'none',
71
69
  coverageProvider: 'c8',
72
70
  skipFormat: true,
71
+ testEnvironment: options.testEnvironment,
73
72
  });
74
73
  tasks.push(vitestTask);
75
74
  }
@@ -384,13 +383,6 @@ function getBuildExecutor(bundler) {
384
383
  return undefined;
385
384
  }
386
385
  }
387
- function ensureBabelRootConfigExists(tree) {
388
- if (tree.exists('babel.config.json'))
389
- return;
390
- (0, devkit_1.writeJson)(tree, 'babel.config.json', {
391
- babelrcRoots: ['*'],
392
- });
393
- }
394
386
  function getOutputPath(options, destinationDir) {
395
387
  const parts = ['dist'];
396
388
  if (destinationDir) {
@@ -422,4 +414,3 @@ function createProjectTsConfigJson(tree, options) {
422
414
  }
423
415
  exports.default = libraryGenerator;
424
416
  exports.librarySchematic = (0, devkit_1.convertNxGenerator)(libraryGenerator);
425
- //# sourceMappingURL=library.js.map
@@ -56,12 +56,8 @@
56
56
  "testEnvironment": {
57
57
  "type": "string",
58
58
  "enum": ["jsdom", "node"],
59
- "description": "The test environment to use if unitTestRunner is set to jest.",
60
- "default": "jsdom"
61
- },
62
- "importPath": {
63
- "type": "string",
64
- "description": "The library name used to import it, like @myorg/my-awesome-lib."
59
+ "description": "The test environment to use if unitTestRunner is set to jest or vitest.",
60
+ "default": "node"
65
61
  },
66
62
  "pascalCaseFiles": {
67
63
  "type": "boolean",
@@ -85,6 +81,11 @@
85
81
  "description": "Generate a publishable library.",
86
82
  "x-priority": "important"
87
83
  },
84
+ "importPath": {
85
+ "type": "string",
86
+ "description": "The library name used to import it, like @myorg/my-awesome-lib. Required for publishable library.",
87
+ "x-priority": "important"
88
+ },
88
89
  "buildable": {
89
90
  "type": "boolean",
90
91
  "default": true,
@@ -0,0 +1,5 @@
1
+ import { type GeneratorCallback, type Tree } from '@nx/devkit';
2
+ import { SetupBuildGeneratorSchema } from './schema';
3
+ export declare function setupBuildGenerator(tree: Tree, options: SetupBuildGeneratorSchema): Promise<GeneratorCallback>;
4
+ export default setupBuildGenerator;
5
+ export declare const setupBuildSchematic: (generatorOptions: SetupBuildGeneratorSchema) => (tree: any, context: any) => Promise<any>;
@@ -0,0 +1,133 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setupBuildSchematic = exports.setupBuildGenerator = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const devkit_1 = require("@nx/devkit");
6
+ const add_swc_config_1 = require("../../utils/swc/add-swc-config");
7
+ const add_swc_dependencies_1 = require("../../utils/swc/add-swc-dependencies");
8
+ const versions_1 = require("../../utils/versions");
9
+ function setupBuildGenerator(tree, options) {
10
+ var _a, _b, _c;
11
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
12
+ const tasks = [];
13
+ const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
14
+ const buildTarget = (_a = options.buildTarget) !== null && _a !== void 0 ? _a : 'build';
15
+ (_b = project.targets) !== null && _b !== void 0 ? _b : (project.targets = {});
16
+ let mainFile;
17
+ if (options.main) {
18
+ mainFile = options.main;
19
+ }
20
+ else {
21
+ const root = (_c = project.sourceRoot) !== null && _c !== void 0 ? _c : project.root;
22
+ for (const f of [
23
+ (0, devkit_1.joinPathFragments)(root, 'main.ts'),
24
+ (0, devkit_1.joinPathFragments)(root, 'main.js'),
25
+ (0, devkit_1.joinPathFragments)(root, 'index.ts'),
26
+ (0, devkit_1.joinPathFragments)(root, 'index.js'),
27
+ ]) {
28
+ if (tree.exists(f)) {
29
+ mainFile = f;
30
+ break;
31
+ }
32
+ }
33
+ }
34
+ if (!mainFile || !tree.exists(mainFile)) {
35
+ throw new Error(`Cannot locate a main file for ${options.project}. Please specify one using --main=<file-path>.`);
36
+ }
37
+ let tsConfigFile;
38
+ if (options.tsConfig) {
39
+ tsConfigFile = options.tsConfig;
40
+ }
41
+ else {
42
+ for (const f of [
43
+ 'tsconfig.lib.json',
44
+ 'tsconfig.app.json',
45
+ 'tsconfig.json',
46
+ ]) {
47
+ const candidate = (0, devkit_1.joinPathFragments)(project.root, f);
48
+ if (tree.exists(candidate)) {
49
+ tsConfigFile = candidate;
50
+ break;
51
+ }
52
+ }
53
+ }
54
+ if (!tsConfigFile || !tree.exists(tsConfigFile)) {
55
+ throw new Error(`Cannot locate a tsConfig file for ${options.project}. Please specify one using --tsConfig=<file-path>.`);
56
+ }
57
+ switch (options.bundler) {
58
+ case 'vite': {
59
+ const { viteConfigurationGenerator } = (0, devkit_1.ensurePackage)('@nx/vite', versions_1.nxVersion);
60
+ const task = yield viteConfigurationGenerator(tree, {
61
+ buildTarget: options.buildTarget,
62
+ project: options.project,
63
+ newProject: true,
64
+ uiFramework: 'none',
65
+ includeVitest: false,
66
+ includeLib: true,
67
+ skipFormat: true,
68
+ });
69
+ tasks.push(task);
70
+ break;
71
+ }
72
+ case 'esbuild': {
73
+ const { esbuildProjectGenerator } = (0, devkit_1.ensurePackage)('@nx/esbuild', versions_1.nxVersion);
74
+ const task = yield esbuildProjectGenerator(tree, {
75
+ main: mainFile,
76
+ buildTarget: options.buildTarget,
77
+ project: options.project,
78
+ skipFormat: true,
79
+ });
80
+ tasks.push(task);
81
+ break;
82
+ }
83
+ case 'rollup': {
84
+ const { rollupProjectGenerator } = (0, devkit_1.ensurePackage)('@nx/rollup', versions_1.nxVersion);
85
+ const task = yield rollupProjectGenerator(tree, {
86
+ buildTarget: options.buildTarget,
87
+ main: mainFile,
88
+ project: options.project,
89
+ skipFormat: true,
90
+ compiler: 'tsc',
91
+ });
92
+ tasks.push(task);
93
+ break;
94
+ }
95
+ case 'tsc': {
96
+ const outputPath = (0, devkit_1.joinPathFragments)('dist', project.root);
97
+ project.targets[buildTarget] = {
98
+ executor: `@nx/js:tsc`,
99
+ outputs: ['{options.outputPath}'],
100
+ options: {
101
+ outputPath,
102
+ main: mainFile,
103
+ tsConfig: tsConfigFile,
104
+ assets: [],
105
+ },
106
+ };
107
+ (0, devkit_1.updateProjectConfiguration)(tree, options.project, project);
108
+ break;
109
+ }
110
+ case 'swc': {
111
+ const outputPath = (0, devkit_1.joinPathFragments)('dist', project.root);
112
+ project.targets[buildTarget] = {
113
+ executor: `@nx/js:swc`,
114
+ outputs: ['{options.outputPath}'],
115
+ options: {
116
+ outputPath,
117
+ main: mainFile,
118
+ tsConfig: tsConfigFile,
119
+ assets: [],
120
+ },
121
+ };
122
+ (0, devkit_1.updateProjectConfiguration)(tree, options.project, project);
123
+ (0, add_swc_dependencies_1.addSwcDependencies)(tree);
124
+ (0, add_swc_config_1.addSwcConfig)(tree, project.root, 'es6');
125
+ }
126
+ }
127
+ yield (0, devkit_1.formatFiles)(tree);
128
+ return (0, devkit_1.runTasksInSerial)(...tasks);
129
+ });
130
+ }
131
+ exports.setupBuildGenerator = setupBuildGenerator;
132
+ exports.default = setupBuildGenerator;
133
+ exports.setupBuildSchematic = (0, devkit_1.convertNxGenerator)(setupBuildGenerator);
@@ -0,0 +1,7 @@
1
+ export interface SetupBuildGeneratorSchema {
2
+ project: string;
3
+ bundler: 'tsc' | 'swc' | 'vite' | 'rollup' | 'esbuild';
4
+ main?: string;
5
+ tsConfig?: string;
6
+ buildTarget?: string;
7
+ }
@@ -0,0 +1,42 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "$id": "SetupBuild",
4
+ "title": "Setup Build",
5
+ "description": "Sets up build target for a project.",
6
+ "type": "object",
7
+ "properties": {
8
+ "project": {
9
+ "type": "string",
10
+ "description": "Project to add the build target to.",
11
+ "$default": {
12
+ "$source": "argv",
13
+ "index": 0
14
+ },
15
+ "x-prompt": "Which project do you want to add build to?",
16
+ "x-dropdown": "projects",
17
+ "x-priority": "important"
18
+ },
19
+ "bundler": {
20
+ "description": "The bundler to use to build the project.",
21
+ "type": "string",
22
+ "enum": ["tsc", "swc", "rollup", "vite", "esbuild"],
23
+ "default": "tsc",
24
+ "x-prompt": "Which bundler would you like to use to build the project?",
25
+ "x-priority": "important"
26
+ },
27
+ "main": {
28
+ "description": "The path to the main entry file, relative to workspace root. Defaults to <project>/src/index.ts or <project>/src/main.ts.",
29
+ "type": "string"
30
+ },
31
+ "tsConfig": {
32
+ "description": "The path to the tsConfig file, relative to workspace root. Defaults to <project>/tsconfig.lib.json or <project>/tsconfig.app.json depending on project type.",
33
+ "type": "string"
34
+ },
35
+ "buildTarget": {
36
+ "description": "The build target to add.",
37
+ "type": "string",
38
+ "default": "build"
39
+ }
40
+ },
41
+ "required": ["project", "bundler"]
42
+ }
@@ -8,7 +8,7 @@ auth:
8
8
  # a list of other known repositories we can talk to
9
9
  uplinks:
10
10
  npmjs:
11
- url: https://registry.npmjs.org/
11
+ url: <%= npmUplinkRegistry %>
12
12
  maxage: 60m
13
13
 
14
14
  packages:
@@ -5,10 +5,14 @@ const tslib_1 = require("tslib");
5
5
  const devkit_1 = require("@nx/devkit");
6
6
  const path = require("path");
7
7
  const versions_1 = require("../../utils/versions");
8
+ const child_process_1 = require("child_process");
8
9
  function setupVerdaccio(tree, options) {
10
+ var _a, _b, _c;
9
11
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
10
12
  if (!tree.exists('.verdaccio/config.yml')) {
11
- (0, devkit_1.generateFiles)(tree, path.join(__dirname, 'files'), '.verdaccio', {});
13
+ (0, devkit_1.generateFiles)(tree, path.join(__dirname, 'files'), '.verdaccio', {
14
+ npmUplinkRegistry: (_c = (_b = (_a = (0, child_process_1.execSync)('npm config get registry')) === null || _a === void 0 ? void 0 : _a.toString()) === null || _b === void 0 ? void 0 : _b.trim()) !== null && _c !== void 0 ? _c : 'https://registry.npmjs.org',
15
+ });
12
16
  }
13
17
  const verdaccioTarget = {
14
18
  executor: '@nx/js:verdaccio',
@@ -48,4 +52,3 @@ function setupVerdaccio(tree, options) {
48
52
  exports.setupVerdaccio = setupVerdaccio;
49
53
  exports.default = setupVerdaccio;
50
54
  exports.setupVerdaccioSchematic = (0, devkit_1.convertNxGenerator)(setupVerdaccio);
51
- //# sourceMappingURL=generator.js.map
package/src/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export * from './utils/typescript/add-tslib-dependencies';
1
2
  export * from './utils/typescript/load-ts-transformers';
2
3
  export * from './utils/typescript/print-diagnostics';
3
4
  export * from './utils/typescript/run-type-check';
package/src/index.js CHANGED
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createPackageJson = exports.getLockFileName = exports.createLockFile = exports.initGenerator = exports.libraryGenerator = void 0;
4
4
  const tslib_1 = require("tslib");
5
+ tslib_1.__exportStar(require("./utils/typescript/add-tslib-dependencies"), exports);
5
6
  tslib_1.__exportStar(require("./utils/typescript/load-ts-transformers"), exports);
6
7
  tslib_1.__exportStar(require("./utils/typescript/print-diagnostics"), exports);
7
8
  tslib_1.__exportStar(require("./utils/typescript/run-type-check"), exports);
@@ -24,4 +25,3 @@ Object.defineProperty(exports, "getLockFileName", { enumerable: true, get: funct
24
25
  // eslint-disable-next-line @typescript-eslint/no-restricted-imports
25
26
  var create_package_json_1 = require("nx/src/plugins/js/package-json/create-package-json");
26
27
  Object.defineProperty(exports, "createPackageJson", { enumerable: true, get: function () { return create_package_json_1.createPackageJson; } });
27
- //# sourceMappingURL=index.js.map
package/src/internal.js CHANGED
@@ -10,4 +10,3 @@ Object.defineProperty(exports, "registerTsConfigPaths", { enumerable: true, get:
10
10
  // eslint-disable-next-line @typescript-eslint/no-restricted-imports
11
11
  var target_project_locator_1 = require("nx/src/plugins/js/project-graph/build-dependencies/target-project-locator");
12
12
  Object.defineProperty(exports, "TargetProjectLocator", { enumerable: true, get: function () { return target_project_locator_1.TargetProjectLocator; } });
13
- //# sourceMappingURL=internal.js.map
@@ -29,4 +29,3 @@ function updateSwcRcExclude(tree) {
29
29
  });
30
30
  }
31
31
  exports.default = updateSwcRcExclude;
32
- //# sourceMappingURL=update-lib-swcrc-exclude.js.map
@@ -25,4 +25,3 @@ function update(host) {
25
25
  });
26
26
  }
27
27
  exports.default = update;
28
- //# sourceMappingURL=update-node-executor.js.map
@@ -32,4 +32,3 @@ function update(host) {
32
32
  });
33
33
  }
34
34
  exports.default = update;
35
- //# sourceMappingURL=update-swcrc.js.map
@@ -24,4 +24,3 @@ function excludeJestConfigSwcrc(tree) {
24
24
  }
25
25
  exports.excludeJestConfigSwcrc = excludeJestConfigSwcrc;
26
26
  exports.default = excludeJestConfigSwcrc;
27
- //# sourceMappingURL=exclude-jest-config-swcrc.js.map
@@ -27,4 +27,3 @@ function updateSwcrcPath(tree) {
27
27
  }
28
28
  exports.updateSwcrcPath = updateSwcrcPath;
29
29
  exports.default = updateSwcrcPath;
30
- //# sourceMappingURL=update-swcrc-path.js.map
@@ -78,4 +78,3 @@ ${node.getFullText()}
78
78
  });
79
79
  }
80
80
  exports.default = default_1;
81
- //# sourceMappingURL=rename-swcrc-config.js.map
@@ -10,4 +10,3 @@ function replacePackage(tree) {
10
10
  });
11
11
  }
12
12
  exports.default = replacePackage;
13
- //# sourceMappingURL=update-16-0-0-add-nx-packages.js.map
@@ -0,0 +1,12 @@
1
+ /**
2
+ * This function is used to start a local registry for testing purposes.
3
+ * @param localRegistryTarget the target to run to start the local registry e.g. workspace:local-registry
4
+ * @param storage the storage location for the local registry
5
+ * @param verbose whether to log verbose output
6
+ */
7
+ export declare function startLocalRegistry({ localRegistryTarget, storage, verbose, }: {
8
+ localRegistryTarget: string;
9
+ storage?: string;
10
+ verbose?: boolean;
11
+ }): Promise<() => void>;
12
+ export default startLocalRegistry;
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.startLocalRegistry = void 0;
4
+ const child_process_1 = require("child_process");
5
+ /**
6
+ * This function is used to start a local registry for testing purposes.
7
+ * @param localRegistryTarget the target to run to start the local registry e.g. workspace:local-registry
8
+ * @param storage the storage location for the local registry
9
+ * @param verbose whether to log verbose output
10
+ */
11
+ function startLocalRegistry({ localRegistryTarget, storage, verbose, }) {
12
+ if (!localRegistryTarget) {
13
+ throw new Error(`localRegistryTarget is required`);
14
+ }
15
+ return new Promise((resolve, reject) => {
16
+ var _a, _b;
17
+ const childProcess = (0, child_process_1.fork)(require.resolve('nx'), [
18
+ ...`run ${localRegistryTarget} --location none --clear true`.split(' '),
19
+ ...(storage ? [`--storage`, storage] : []),
20
+ ], { stdio: 'pipe' });
21
+ const listener = (data) => {
22
+ var _a, _b, _c;
23
+ if (verbose) {
24
+ process.stdout.write(data);
25
+ }
26
+ if (data.toString().includes('http://localhost:')) {
27
+ const port = parseInt((_b = (_a = data.toString().match(/localhost:(?<port>\d+)/)) === null || _a === void 0 ? void 0 : _a.groups) === null || _b === void 0 ? void 0 : _b.port);
28
+ console.log('Local registry started on port ' + port);
29
+ const registry = `http://localhost:${port}`;
30
+ process.env.npm_config_registry = registry;
31
+ process.env.YARN_REGISTRY = registry;
32
+ (0, child_process_1.execSync)(`npm config set //localhost:${port}/:_authToken "secretVerdaccioToken"`);
33
+ console.log('Set npm and yarn config registry to ' + registry);
34
+ resolve(() => {
35
+ childProcess.kill();
36
+ (0, child_process_1.execSync)(`npm config delete //localhost:${port}/:_authToken`);
37
+ });
38
+ (_c = childProcess === null || childProcess === void 0 ? void 0 : childProcess.stdout) === null || _c === void 0 ? void 0 : _c.off('data', listener);
39
+ }
40
+ };
41
+ (_a = childProcess === null || childProcess === void 0 ? void 0 : childProcess.stdout) === null || _a === void 0 ? void 0 : _a.on('data', listener);
42
+ (_b = childProcess === null || childProcess === void 0 ? void 0 : childProcess.stderr) === null || _b === void 0 ? void 0 : _b.on('data', (data) => {
43
+ process.stderr.write(data);
44
+ });
45
+ childProcess.on('error', (err) => {
46
+ console.log('local registry error', err);
47
+ reject(err);
48
+ });
49
+ childProcess.on('exit', (code) => {
50
+ console.log('local registry exit', code);
51
+ if (code !== 0) {
52
+ reject(code);
53
+ }
54
+ else {
55
+ resolve(() => { });
56
+ }
57
+ });
58
+ });
59
+ }
60
+ exports.startLocalRegistry = startLocalRegistry;
61
+ exports.default = startLocalRegistry;
@@ -1,2 +1,3 @@
1
1
  import { Tree } from '@nx/devkit';
2
+ /** @deprecated Do not use this function as the root babel.config.json file is no longer needed */
2
3
  export declare function addBabelInputs(tree: Tree): void;
@@ -2,6 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addBabelInputs = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
+ /** @deprecated Do not use this function as the root babel.config.json file is no longer needed */
6
+ // TODO(jack): Remove This in Nx 17 once we don't need to support Nx 15 anymore. Currently this function is used in v15 migrations.
5
7
  function addBabelInputs(tree) {
6
8
  var _a;
7
9
  const nxJson = (0, devkit_1.readNxJson)(tree);
@@ -20,4 +22,3 @@ function addBabelInputs(tree) {
20
22
  (0, devkit_1.updateNxJson)(tree, nxJson);
21
23
  }
22
24
  exports.addBabelInputs = addBabelInputs;
23
- //# sourceMappingURL=add-babel-inputs.js.map
@@ -0,0 +1,5 @@
1
+ import { type Tree } from '@nx/devkit';
2
+ export declare function addLocalRegistryScripts(tree: Tree): {
3
+ startLocalRegistryPath: string;
4
+ stopLocalRegistryPath: string;
5
+ };
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addLocalRegistryScripts = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const startLocalRegistryScript = (localRegistryTarget) => `
6
+ /**
7
+ * This script starts a local registry for e2e testing purposes.
8
+ * It is meant to be called in jest's globalSetup.
9
+ */
10
+ import { startLocalRegistry } from '@nx/js/plugins/jest/local-registry';
11
+ import { execFileSync } from 'child_process';
12
+
13
+ export default async () => {
14
+ // local registry target to run
15
+ const localRegistryTarget = '${localRegistryTarget}';
16
+ // storage folder for the local registry
17
+ const storage = './tmp/local-registry/storage';
18
+
19
+ global.stopLocalRegistry = await startLocalRegistry({
20
+ localRegistryTarget,
21
+ storage,
22
+ verbose: false,
23
+ });
24
+ const nx = require.resolve('nx');
25
+ execFileSync(
26
+ nx,
27
+ ['run-many', '--targets', 'publish', '--ver', '1.0.0', '--tag', 'e2e'],
28
+ { env: process.env, stdio: 'inherit' }
29
+ );
30
+ };
31
+ `;
32
+ const stopLocalRegistryScript = `
33
+ /**
34
+ * This script stops the local registry for e2e testing purposes.
35
+ * It is meant to be called in jest's globalTeardown.
36
+ */
37
+
38
+ export default () => {
39
+ if (global.stopLocalRegistry) {
40
+ global.stopLocalRegistry();
41
+ }
42
+ };
43
+ `;
44
+ function addLocalRegistryScripts(tree) {
45
+ const startLocalRegistryPath = 'tools/scripts/start-local-registry.ts';
46
+ const stopLocalRegistryPath = 'tools/scripts/stop-local-registry.ts';
47
+ const projectConfiguration = (0, devkit_1.readJson)(tree, 'project.json');
48
+ const localRegistryTarget = `${projectConfiguration.name}:local-registry`;
49
+ if (!tree.exists(startLocalRegistryPath)) {
50
+ tree.write(startLocalRegistryPath, startLocalRegistryScript(localRegistryTarget));
51
+ }
52
+ if (!tree.exists(stopLocalRegistryPath)) {
53
+ tree.write(stopLocalRegistryPath, stopLocalRegistryScript);
54
+ }
55
+ return { startLocalRegistryPath, stopLocalRegistryPath };
56
+ }
57
+ exports.addLocalRegistryScripts = addLocalRegistryScripts;
@@ -35,4 +35,3 @@ function assetGlobsToFiles(assets, rootDir, outDir) {
35
35
  return files;
36
36
  }
37
37
  exports.assetGlobsToFiles = assetGlobsToFiles;
38
- //# sourceMappingURL=assets.js.map
@@ -1,4 +1,5 @@
1
1
  import { AssetGlob } from './assets';
2
+ import { ChangedFile } from 'nx/src/daemon/client/client';
2
3
  export type FileEventType = 'create' | 'update' | 'delete';
3
4
  export interface FileEvent {
4
5
  type: FileEventType;
@@ -22,7 +23,10 @@ export declare class CopyAssetsHandler {
22
23
  private readonly callback;
23
24
  constructor(opts: CopyAssetHandlerOptions);
24
25
  processAllAssetsOnce(): Promise<void>;
26
+ processAllAssetsOnceSync(): void;
25
27
  watchAndProcessOnAssetChange(): Promise<() => void>;
26
- private processEvents;
28
+ processWatchEvents(events: ChangedFile[]): Promise<void>;
29
+ private filesToEvent;
30
+ private normalizeAssetPattern;
27
31
  }
28
32
  export {};
@@ -74,35 +74,27 @@ class CopyAssetsHandler {
74
74
  processAllAssetsOnce() {
75
75
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
76
76
  yield Promise.all(this.assetGlobs.map((ag) => tslib_1.__awaiter(this, void 0, void 0, function* () {
77
- let pattern;
78
- if (typeof ag === 'string') {
79
- pattern = ag;
80
- }
81
- else {
82
- pattern = ag.pattern;
83
- }
77
+ const pattern = this.normalizeAssetPattern(ag);
84
78
  // fast-glob only supports Unix paths
85
79
  const files = yield fg(pattern.replace(/\\/g, '/'), {
86
80
  cwd: this.rootDir,
87
81
  dot: true, // enable hidden files
88
82
  });
89
- this.callback(files.reduce((acc, src) => {
90
- var _a;
91
- if (!((_a = ag.ignore) === null || _a === void 0 ? void 0 : _a.some((ig) => minimatch(src, ig))) &&
92
- !this.ignore.ignores(src)) {
93
- const relPath = path.relative(ag.input, src);
94
- const dest = relPath.startsWith('..') ? src : relPath;
95
- acc.push({
96
- type: 'create',
97
- src: path.join(this.rootDir, src),
98
- dest: path.join(this.rootDir, ag.output, dest),
99
- });
100
- }
101
- return acc;
102
- }, []));
83
+ this.callback(this.filesToEvent(files, ag));
103
84
  })));
104
85
  });
105
86
  }
87
+ processAllAssetsOnceSync() {
88
+ this.assetGlobs.forEach((ag) => {
89
+ const pattern = this.normalizeAssetPattern(ag);
90
+ // fast-glob only supports Unix paths
91
+ const files = fg.sync(pattern.replace(/\\/g, '/'), {
92
+ cwd: this.rootDir,
93
+ dot: true, // enable hidden files
94
+ });
95
+ this.callback(this.filesToEvent(files, ag));
96
+ });
97
+ }
106
98
  watchAndProcessOnAssetChange() {
107
99
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
108
100
  const unregisterFileWatcher = yield client_1.daemonClient.registerFileWatcher({
@@ -118,13 +110,13 @@ class CopyAssetsHandler {
118
110
  devkit_1.logger.error(`Watch error: ${(_a = err === null || err === void 0 ? void 0 : err.message) !== null && _a !== void 0 ? _a : 'Unknown'}`);
119
111
  }
120
112
  else {
121
- this.processEvents(data.changedFiles);
113
+ this.processWatchEvents(data.changedFiles);
122
114
  }
123
115
  });
124
116
  return () => unregisterFileWatcher();
125
117
  });
126
118
  }
127
- processEvents(events) {
119
+ processWatchEvents(events) {
128
120
  var _a;
129
121
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
130
122
  const fileEvents = [];
@@ -150,6 +142,24 @@ class CopyAssetsHandler {
150
142
  this.callback(fileEvents);
151
143
  });
152
144
  }
145
+ filesToEvent(files, assetGlob) {
146
+ return files.reduce((acc, src) => {
147
+ var _a;
148
+ if (!((_a = assetGlob.ignore) === null || _a === void 0 ? void 0 : _a.some((ig) => minimatch(src, ig))) &&
149
+ !this.ignore.ignores(src)) {
150
+ const relPath = path.relative(assetGlob.input, src);
151
+ const dest = relPath.startsWith('..') ? src : relPath;
152
+ acc.push({
153
+ type: 'create',
154
+ src: path.join(this.rootDir, src),
155
+ dest: path.join(this.rootDir, assetGlob.output, dest),
156
+ });
157
+ }
158
+ return acc;
159
+ }, []);
160
+ }
161
+ normalizeAssetPattern(assetEntry) {
162
+ return typeof assetEntry === 'string' ? assetEntry : assetEntry.pattern;
163
+ }
153
164
  }
154
165
  exports.CopyAssetsHandler = CopyAssetsHandler;
155
- //# sourceMappingURL=copy-assets-handler.js.map
@@ -28,4 +28,3 @@ function copyAssets(options, context) {
28
28
  });
29
29
  }
30
30
  exports.copyAssets = copyAssets;
31
- //# sourceMappingURL=index.js.map
@@ -281,4 +281,3 @@ function hasDependency(outputJson, depConfigName, packageName) {
281
281
  return false;
282
282
  }
283
283
  }
284
- //# sourceMappingURL=buildable-libs-utils.js.map
@@ -21,4 +21,3 @@ function checkDependencies(context, tsConfigPath) {
21
21
  };
22
22
  }
23
23
  exports.checkDependencies = checkDependencies;
24
- //# sourceMappingURL=check-dependencies.js.map