@nx/js 17.0.2 → 17.0.4
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/LICENSE +1 -1
- package/README.md +9 -4
- package/babel.js +37 -16
- package/executors.json +1 -1
- package/migrations.json +62 -0
- package/package.json +10 -9
- package/src/executors/node/node.impl.js +1 -1
- package/src/executors/node/schema.json +1 -1
- package/src/executors/release-publish/release-publish.impl.js +135 -32
- package/src/executors/release-publish/schema.d.ts +2 -0
- package/src/executors/release-publish/schema.json +1 -1
- package/src/executors/swc/schema.json +1 -1
- package/src/executors/swc/swc.impl.js +6 -7
- package/src/executors/verdaccio/schema.json +1 -1
- package/src/executors/verdaccio/verdaccio.impl.js +1 -1
- package/src/generators/convert-to-swc/schema.json +1 -1
- package/src/generators/init/init.js +3 -2
- package/src/generators/init/schema.d.ts +1 -0
- package/src/generators/init/schema.json +7 -1
- package/src/generators/library/files/lib/tsconfig.lib.json__tmpl__ +5 -1
- package/src/generators/library/files/{lib → readme}/README.md +1 -1
- package/src/generators/library/library.d.ts +1 -1
- package/src/generators/library/library.js +173 -29
- package/src/generators/library/schema.json +8 -2
- package/src/generators/release-version/release-version.d.ts +2 -1
- package/src/generators/release-version/release-version.js +341 -86
- package/src/generators/release-version/schema.json +26 -4
- package/src/generators/release-version/utils/resolve-local-package-dependencies.d.ts +7 -1
- package/src/generators/release-version/utils/resolve-local-package-dependencies.js +14 -4
- package/src/generators/release-version/utils/resolve-version-spec.js +4 -1
- package/src/generators/release-version/utils/update-lock-file.d.ts +5 -0
- package/src/generators/release-version/utils/update-lock-file.js +105 -0
- package/src/generators/setup-build/generator.js +3 -0
- package/src/generators/setup-build/schema.json +1 -1
- package/src/generators/setup-verdaccio/schema.json +1 -1
- package/src/migrations/update-17-0-0/remove-deprecated-build-options.js +2 -1
- package/src/utils/add-local-registry-scripts.js +26 -6
- package/src/utils/assets/copy-assets-handler.js +4 -4
- package/src/utils/buildable-libs-utils.js +6 -2
- package/src/utils/find-npm-dependencies.d.ts +2 -1
- package/src/utils/find-npm-dependencies.js +28 -11
- package/src/utils/inline.js +6 -4
- package/src/utils/npm-config.d.ts +25 -0
- package/src/utils/npm-config.js +90 -0
- package/src/utils/schema.d.ts +3 -0
- package/src/utils/swc/get-swcrc-path.d.ts +4 -1
- package/src/utils/swc/get-swcrc-path.js +6 -1
- package/src/utils/swc/inline.d.ts +1 -1
- package/src/utils/swc/inline.js +1 -2
- package/src/utils/typescript/ast-utils.js +2 -3
- package/src/utils/typescript/ts-config.js +1 -0
- package/src/utils/versions.d.ts +4 -4
- package/src/utils/versions.js +4 -4
- package/src/utils/minimal-publish-script.d.ts +0 -2
- package/src/utils/minimal-publish-script.js +0 -74
|
@@ -14,6 +14,6 @@ Run `<%= cliCommand %> build <%= name %>` to build the library.
|
|
|
14
14
|
|
|
15
15
|
## Running unit tests
|
|
16
16
|
|
|
17
|
-
Run `<%= cliCommand %> test <%= name %>` to execute the unit tests via [Jest](https://jestjs.io).
|
|
17
|
+
Run `<%= cliCommand %> test <%= name %>` to execute the unit tests via <% if(unitTestRunner === 'jest') { %>[Jest](https://jestjs.io)<% } else { %>[Vitest](https://vitest.dev/)<% } %>.
|
|
18
18
|
|
|
19
19
|
<% } %>
|
|
@@ -11,6 +11,6 @@ export interface NormalizedSchema extends LibraryGeneratorSchema {
|
|
|
11
11
|
parsedTags: string[];
|
|
12
12
|
importPath?: string;
|
|
13
13
|
}
|
|
14
|
-
export type AddLintOptions = Pick<NormalizedSchema, 'name' | 'linter' | 'projectRoot' | 'unitTestRunner' | 'js' | 'setParserOptionsProject' | 'rootProject' | 'bundler'>;
|
|
14
|
+
export type AddLintOptions = Pick<NormalizedSchema, 'name' | 'linter' | 'projectRoot' | 'unitTestRunner' | 'js' | 'setParserOptionsProject' | 'rootProject' | 'bundler' | 'addPlugin'>;
|
|
15
15
|
export declare function addLint(tree: Tree, options: AddLintOptions): Promise<GeneratorCallback>;
|
|
16
16
|
export default libraryGenerator;
|
|
@@ -3,17 +3,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.addLint = exports.libraryGeneratorInternal = exports.libraryGenerator = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
|
|
6
|
-
const
|
|
6
|
+
const add_build_target_defaults_1 = require("@nx/devkit/src/generators/add-build-target-defaults");
|
|
7
|
+
const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-project-command");
|
|
8
|
+
const find_matching_projects_1 = require("nx/src/utils/find-matching-projects");
|
|
7
9
|
const path_1 = require("path");
|
|
8
|
-
const minimal_publish_script_1 = require("../../utils/minimal-publish-script");
|
|
9
10
|
const add_swc_config_1 = require("../../utils/swc/add-swc-config");
|
|
10
11
|
const add_swc_dependencies_1 = require("../../utils/swc/add-swc-dependencies");
|
|
12
|
+
const create_ts_config_1 = require("../../utils/typescript/create-ts-config");
|
|
13
|
+
const ts_config_1 = require("../../utils/typescript/ts-config");
|
|
11
14
|
const versions_1 = require("../../utils/versions");
|
|
12
15
|
const init_1 = require("../init/init");
|
|
13
16
|
const generator_1 = require("../setup-verdaccio/generator");
|
|
14
|
-
const
|
|
17
|
+
const defaultOutputDirectory = 'dist';
|
|
15
18
|
async function libraryGenerator(tree, schema) {
|
|
16
19
|
return await libraryGeneratorInternal(tree, {
|
|
20
|
+
addPlugin: false,
|
|
17
21
|
// provide a default projectNameAndRootFormat to avoid breaking changes
|
|
18
22
|
// to external generators invoking this one
|
|
19
23
|
projectNameAndRootFormat: 'derived',
|
|
@@ -22,7 +26,6 @@ async function libraryGenerator(tree, schema) {
|
|
|
22
26
|
}
|
|
23
27
|
exports.libraryGenerator = libraryGenerator;
|
|
24
28
|
async function libraryGeneratorInternal(tree, schema) {
|
|
25
|
-
const filesDir = (0, path_1.join)(__dirname, './files');
|
|
26
29
|
const tasks = [];
|
|
27
30
|
tasks.push(await (0, init_1.default)(tree, {
|
|
28
31
|
...schema,
|
|
@@ -30,9 +33,11 @@ async function libraryGeneratorInternal(tree, schema) {
|
|
|
30
33
|
tsConfigName: schema.rootProject ? 'tsconfig.json' : 'tsconfig.base.json',
|
|
31
34
|
}));
|
|
32
35
|
const options = await normalizeOptions(tree, schema);
|
|
33
|
-
createFiles(tree, options
|
|
34
|
-
addProject(tree, options);
|
|
35
|
-
|
|
36
|
+
createFiles(tree, options);
|
|
37
|
+
await addProject(tree, options);
|
|
38
|
+
if (!options.skipPackageJson) {
|
|
39
|
+
tasks.push(addProjectDependencies(tree, options));
|
|
40
|
+
}
|
|
36
41
|
if (options.publishable) {
|
|
37
42
|
tasks.push(await (0, generator_1.default)(tree, { ...options, skipFormat: true }));
|
|
38
43
|
}
|
|
@@ -46,12 +51,14 @@ async function libraryGeneratorInternal(tree, schema) {
|
|
|
46
51
|
includeLib: true,
|
|
47
52
|
skipFormat: true,
|
|
48
53
|
testEnvironment: options.testEnvironment,
|
|
54
|
+
addPlugin: options.addPlugin,
|
|
49
55
|
});
|
|
50
56
|
tasks.push(viteTask);
|
|
51
57
|
createOrEditViteConfig(tree, {
|
|
52
58
|
project: options.name,
|
|
53
59
|
includeLib: true,
|
|
54
60
|
includeVitest: options.unitTestRunner === 'vitest',
|
|
61
|
+
testEnvironment: options.testEnvironment,
|
|
55
62
|
}, false);
|
|
56
63
|
}
|
|
57
64
|
if (options.linter !== 'none') {
|
|
@@ -62,7 +69,7 @@ async function libraryGeneratorInternal(tree, schema) {
|
|
|
62
69
|
const jestCallback = await addJest(tree, options);
|
|
63
70
|
tasks.push(jestCallback);
|
|
64
71
|
if (options.bundler === 'swc' || options.bundler === 'rollup') {
|
|
65
|
-
replaceJestConfig(tree, options
|
|
72
|
+
replaceJestConfig(tree, options);
|
|
66
73
|
}
|
|
67
74
|
}
|
|
68
75
|
else if (options.unitTestRunner === 'vitest' &&
|
|
@@ -72,7 +79,7 @@ async function libraryGeneratorInternal(tree, schema) {
|
|
|
72
79
|
const vitestTask = await vitestGenerator(tree, {
|
|
73
80
|
project: options.name,
|
|
74
81
|
uiFramework: 'none',
|
|
75
|
-
coverageProvider: '
|
|
82
|
+
coverageProvider: 'v8',
|
|
76
83
|
skipFormat: true,
|
|
77
84
|
testEnvironment: options.testEnvironment,
|
|
78
85
|
});
|
|
@@ -81,6 +88,7 @@ async function libraryGeneratorInternal(tree, schema) {
|
|
|
81
88
|
project: options.name,
|
|
82
89
|
includeLib: false,
|
|
83
90
|
includeVitest: true,
|
|
91
|
+
testEnvironment: options.testEnvironment,
|
|
84
92
|
}, true);
|
|
85
93
|
}
|
|
86
94
|
if (!schema.skipTsConfig) {
|
|
@@ -94,10 +102,18 @@ async function libraryGeneratorInternal(tree, schema) {
|
|
|
94
102
|
if (!options.skipFormat) {
|
|
95
103
|
await (0, devkit_1.formatFiles)(tree);
|
|
96
104
|
}
|
|
105
|
+
if (options.publishable) {
|
|
106
|
+
tasks.push(() => {
|
|
107
|
+
logNxReleaseDocsInfo();
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
tasks.push(() => {
|
|
111
|
+
(0, log_show_project_command_1.logShowProjectCommand)(options.name);
|
|
112
|
+
});
|
|
97
113
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
98
114
|
}
|
|
99
115
|
exports.libraryGeneratorInternal = libraryGeneratorInternal;
|
|
100
|
-
function addProject(tree, options) {
|
|
116
|
+
async function addProject(tree, options) {
|
|
101
117
|
const projectConfiguration = {
|
|
102
118
|
root: options.projectRoot,
|
|
103
119
|
sourceRoot: (0, devkit_1.joinPathFragments)(options.projectRoot, 'src'),
|
|
@@ -109,8 +125,10 @@ function addProject(tree, options) {
|
|
|
109
125
|
options.bundler !== 'none' &&
|
|
110
126
|
options.config !== 'npm-scripts') {
|
|
111
127
|
const outputPath = getOutputPath(options);
|
|
128
|
+
const executor = getBuildExecutor(options.bundler);
|
|
129
|
+
(0, add_build_target_defaults_1.addBuildTargetDefaults)(tree, executor);
|
|
112
130
|
projectConfiguration.targets.build = {
|
|
113
|
-
executor
|
|
131
|
+
executor,
|
|
114
132
|
outputs: ['{options.outputPath}'],
|
|
115
133
|
options: {
|
|
116
134
|
outputPath,
|
|
@@ -138,11 +156,24 @@ function addProject(tree, options) {
|
|
|
138
156
|
projectConfiguration.targets.build.options.assets.push((0, devkit_1.joinPathFragments)(options.projectRoot, '*.md'));
|
|
139
157
|
}
|
|
140
158
|
if (options.publishable) {
|
|
141
|
-
const
|
|
142
|
-
projectConfiguration.targets
|
|
143
|
-
|
|
144
|
-
|
|
159
|
+
const packageRoot = (0, path_1.join)(defaultOutputDirectory, '{projectRoot}');
|
|
160
|
+
projectConfiguration.targets ??= {};
|
|
161
|
+
projectConfiguration.targets['nx-release-publish'] = {
|
|
162
|
+
options: {
|
|
163
|
+
packageRoot,
|
|
164
|
+
},
|
|
145
165
|
};
|
|
166
|
+
projectConfiguration.release = {
|
|
167
|
+
version: {
|
|
168
|
+
generatorOptions: {
|
|
169
|
+
packageRoot,
|
|
170
|
+
// using git tags to determine the current version is required here because
|
|
171
|
+
// the version in the package root is overridden with every build
|
|
172
|
+
currentVersionResolver: 'git-tag',
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
};
|
|
176
|
+
await addProjectToNxReleaseConfig(tree, options, projectConfiguration);
|
|
146
177
|
}
|
|
147
178
|
}
|
|
148
179
|
if (options.config === 'workspace' || options.config === 'project') {
|
|
@@ -158,11 +189,8 @@ function addProject(tree, options) {
|
|
|
158
189
|
}
|
|
159
190
|
async function addLint(tree, options) {
|
|
160
191
|
const { lintProjectGenerator } = (0, devkit_1.ensurePackage)('@nx/eslint', versions_1.nxVersion);
|
|
161
|
-
const { mapLintPattern } =
|
|
162
|
-
// nx-ignore-next-line
|
|
163
|
-
require('@nx/eslint/src/generators/lint-project/lint-project');
|
|
164
192
|
const projectConfiguration = (0, devkit_1.readProjectConfiguration)(tree, options.name);
|
|
165
|
-
const task = lintProjectGenerator(tree, {
|
|
193
|
+
const task = await lintProjectGenerator(tree, {
|
|
166
194
|
project: options.name,
|
|
167
195
|
linter: options.linter,
|
|
168
196
|
skipFormat: true,
|
|
@@ -170,11 +198,9 @@ async function addLint(tree, options) {
|
|
|
170
198
|
(0, devkit_1.joinPathFragments)(options.projectRoot, 'tsconfig.lib.json'),
|
|
171
199
|
],
|
|
172
200
|
unitTestRunner: options.unitTestRunner,
|
|
173
|
-
eslintFilePatterns: [
|
|
174
|
-
mapLintPattern(options.projectRoot, options.js ? 'js' : 'ts', options.rootProject),
|
|
175
|
-
],
|
|
176
201
|
setParserOptionsProject: options.setParserOptionsProject,
|
|
177
202
|
rootProject: options.rootProject,
|
|
203
|
+
addPlugin: options.addPlugin,
|
|
178
204
|
});
|
|
179
205
|
const { addOverrideToLintConfig, lintConfigHasOverride, isEslintConfigSupported, updateOverrideInLintConfig,
|
|
180
206
|
// nx-ignore-next-line
|
|
@@ -276,10 +302,10 @@ function addBabelRc(tree, options) {
|
|
|
276
302
|
};
|
|
277
303
|
(0, devkit_1.writeJson)(tree, (0, path_1.join)(options.projectRoot, filename), babelrc);
|
|
278
304
|
}
|
|
279
|
-
function createFiles(tree, options
|
|
305
|
+
function createFiles(tree, options) {
|
|
280
306
|
const { className, name, propertyName } = (0, devkit_1.names)(options.projectNames.projectFileName);
|
|
281
307
|
createProjectTsConfigJson(tree, options);
|
|
282
|
-
(0, devkit_1.generateFiles)(tree,
|
|
308
|
+
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, './files/lib'), options.projectRoot, {
|
|
283
309
|
...options,
|
|
284
310
|
dot: '.',
|
|
285
311
|
className,
|
|
@@ -293,6 +319,22 @@ function createFiles(tree, options, filesDir) {
|
|
|
293
319
|
buildable: options.bundler && options.bundler !== 'none',
|
|
294
320
|
hasUnitTestRunner: options.unitTestRunner !== 'none',
|
|
295
321
|
});
|
|
322
|
+
if (!options.rootProject) {
|
|
323
|
+
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, './files/readme'), options.projectRoot, {
|
|
324
|
+
...options,
|
|
325
|
+
dot: '.',
|
|
326
|
+
className,
|
|
327
|
+
name,
|
|
328
|
+
propertyName,
|
|
329
|
+
js: !!options.js,
|
|
330
|
+
cliCommand: 'nx',
|
|
331
|
+
strict: undefined,
|
|
332
|
+
tmpl: '',
|
|
333
|
+
offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.projectRoot),
|
|
334
|
+
buildable: options.bundler && options.bundler !== 'none',
|
|
335
|
+
hasUnitTestRunner: options.unitTestRunner !== 'none',
|
|
336
|
+
});
|
|
337
|
+
}
|
|
296
338
|
if (options.bundler === 'swc' || options.bundler === 'rollup') {
|
|
297
339
|
(0, add_swc_dependencies_1.addSwcDependencies)(tree);
|
|
298
340
|
(0, add_swc_config_1.addSwcConfig)(tree, options.projectRoot, options.bundler === 'swc' ? 'commonjs' : 'es6');
|
|
@@ -316,6 +358,9 @@ function createFiles(tree, options, filesDir) {
|
|
|
316
358
|
if (json.private && (options.publishable || options.rootProject)) {
|
|
317
359
|
delete json.private;
|
|
318
360
|
}
|
|
361
|
+
if (!options.publishable && !options.rootProject) {
|
|
362
|
+
json.private = true;
|
|
363
|
+
}
|
|
319
364
|
return {
|
|
320
365
|
...json,
|
|
321
366
|
dependencies: {
|
|
@@ -327,12 +372,16 @@ function createFiles(tree, options, filesDir) {
|
|
|
327
372
|
});
|
|
328
373
|
}
|
|
329
374
|
else {
|
|
330
|
-
|
|
375
|
+
const packageJson = {
|
|
331
376
|
name: options.importPath,
|
|
332
377
|
version: '0.0.1',
|
|
333
378
|
dependencies: determineDependencies(options),
|
|
334
379
|
...determineEntryFields(options),
|
|
335
|
-
}
|
|
380
|
+
};
|
|
381
|
+
if (!options.publishable && !options.rootProject) {
|
|
382
|
+
packageJson.private = true;
|
|
383
|
+
}
|
|
384
|
+
(0, devkit_1.writeJson)(tree, packageJsonPath, packageJson);
|
|
336
385
|
}
|
|
337
386
|
if (options.config === 'npm-scripts') {
|
|
338
387
|
(0, devkit_1.updateJson)(tree, packageJsonPath, (json) => {
|
|
@@ -369,7 +418,8 @@ async function addJest(tree, options) {
|
|
|
369
418
|
: undefined,
|
|
370
419
|
});
|
|
371
420
|
}
|
|
372
|
-
function replaceJestConfig(tree, options
|
|
421
|
+
function replaceJestConfig(tree, options) {
|
|
422
|
+
const filesDir = (0, path_1.join)(__dirname, './files/jest-config');
|
|
373
423
|
// the existing config has to be deleted otherwise the new config won't overwrite it
|
|
374
424
|
const existingJestConfig = (0, devkit_1.joinPathFragments)(filesDir, `jest.config.${options.js ? 'js' : 'ts'}`);
|
|
375
425
|
if (tree.exists(existingJestConfig)) {
|
|
@@ -386,6 +436,10 @@ function replaceJestConfig(tree, options, filesDir) {
|
|
|
386
436
|
});
|
|
387
437
|
}
|
|
388
438
|
async function normalizeOptions(tree, options) {
|
|
439
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
440
|
+
const addPlugin = process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
441
|
+
nxJson.useInferencePlugins !== false;
|
|
442
|
+
options.addPlugin ??= addPlugin;
|
|
389
443
|
/**
|
|
390
444
|
* We are deprecating the compiler and the buildable options.
|
|
391
445
|
* However, we want to keep the existing behavior for now.
|
|
@@ -420,7 +474,7 @@ async function normalizeOptions(tree, options) {
|
|
|
420
474
|
options.bundler = 'tsc';
|
|
421
475
|
}
|
|
422
476
|
}
|
|
423
|
-
// This is to preserve old
|
|
477
|
+
// This is to preserve old behavior, buildable: false
|
|
424
478
|
if (options.publishable === false && options.buildable === false) {
|
|
425
479
|
options.bundler = 'none';
|
|
426
480
|
}
|
|
@@ -512,7 +566,7 @@ function getBuildExecutor(bundler) {
|
|
|
512
566
|
}
|
|
513
567
|
}
|
|
514
568
|
function getOutputPath(options) {
|
|
515
|
-
const parts = [
|
|
569
|
+
const parts = [defaultOutputDirectory];
|
|
516
570
|
if (options.projectRoot === '.') {
|
|
517
571
|
parts.push(options.name);
|
|
518
572
|
}
|
|
@@ -604,4 +658,94 @@ function determineEntryFields(options) {
|
|
|
604
658
|
}
|
|
605
659
|
}
|
|
606
660
|
}
|
|
661
|
+
function projectsConfigMatchesProject(projectsConfig, project) {
|
|
662
|
+
if (!projectsConfig) {
|
|
663
|
+
return false;
|
|
664
|
+
}
|
|
665
|
+
if (typeof projectsConfig === 'string') {
|
|
666
|
+
projectsConfig = [projectsConfig];
|
|
667
|
+
}
|
|
668
|
+
const graph = {
|
|
669
|
+
[project.name]: project,
|
|
670
|
+
};
|
|
671
|
+
const matchingProjects = (0, find_matching_projects_1.findMatchingProjects)(projectsConfig, graph);
|
|
672
|
+
return matchingProjects.includes(project.name);
|
|
673
|
+
}
|
|
674
|
+
async function addProjectToNxReleaseConfig(tree, options, projectConfiguration) {
|
|
675
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
676
|
+
const addPreVersionCommand = () => {
|
|
677
|
+
const pmc = (0, devkit_1.getPackageManagerCommand)();
|
|
678
|
+
nxJson.release = {
|
|
679
|
+
...nxJson.release,
|
|
680
|
+
version: {
|
|
681
|
+
preVersionCommand: `${pmc.dlx} nx run-many -t build`,
|
|
682
|
+
...nxJson.release?.version,
|
|
683
|
+
},
|
|
684
|
+
};
|
|
685
|
+
};
|
|
686
|
+
if (!nxJson.release || (!nxJson.release.projects && !nxJson.release.groups)) {
|
|
687
|
+
// skip adding any projects configuration since the new project should be
|
|
688
|
+
// automatically included by nx release's default project detection logic
|
|
689
|
+
addPreVersionCommand();
|
|
690
|
+
(0, devkit_1.writeJson)(tree, 'nx.json', nxJson);
|
|
691
|
+
return;
|
|
692
|
+
}
|
|
693
|
+
const project = {
|
|
694
|
+
name: options.name,
|
|
695
|
+
type: 'lib',
|
|
696
|
+
data: {
|
|
697
|
+
root: projectConfiguration.root,
|
|
698
|
+
tags: projectConfiguration.tags,
|
|
699
|
+
},
|
|
700
|
+
};
|
|
701
|
+
if (projectsConfigMatchesProject(nxJson.release.projects, project)) {
|
|
702
|
+
devkit_1.output.log({
|
|
703
|
+
title: `Project already included in existing release configuration`,
|
|
704
|
+
});
|
|
705
|
+
addPreVersionCommand();
|
|
706
|
+
(0, devkit_1.writeJson)(tree, 'nx.json', nxJson);
|
|
707
|
+
return;
|
|
708
|
+
}
|
|
709
|
+
if (Array.isArray(nxJson.release.projects)) {
|
|
710
|
+
nxJson.release.projects.push(options.name);
|
|
711
|
+
addPreVersionCommand();
|
|
712
|
+
(0, devkit_1.writeJson)(tree, 'nx.json', nxJson);
|
|
713
|
+
devkit_1.output.log({
|
|
714
|
+
title: `Added project to existing release configuration`,
|
|
715
|
+
});
|
|
716
|
+
}
|
|
717
|
+
if (nxJson.release.groups) {
|
|
718
|
+
const allGroups = Object.entries(nxJson.release.groups);
|
|
719
|
+
for (const [name, group] of allGroups) {
|
|
720
|
+
if (projectsConfigMatchesProject(group.projects, project)) {
|
|
721
|
+
addPreVersionCommand();
|
|
722
|
+
(0, devkit_1.writeJson)(tree, 'nx.json', nxJson);
|
|
723
|
+
return `Project already included in existing release configuration for group ${name}`;
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
devkit_1.output.warn({
|
|
727
|
+
title: `Could not find a release group that includes ${options.name}`,
|
|
728
|
+
bodyLines: [
|
|
729
|
+
`Ensure that ${options.name} is included in a release group's "projects" list in nx.json so it can be published with "nx release"`,
|
|
730
|
+
],
|
|
731
|
+
});
|
|
732
|
+
addPreVersionCommand();
|
|
733
|
+
(0, devkit_1.writeJson)(tree, 'nx.json', nxJson);
|
|
734
|
+
return;
|
|
735
|
+
}
|
|
736
|
+
if (typeof nxJson.release.projects === 'string') {
|
|
737
|
+
nxJson.release.projects = [nxJson.release.projects, options.name];
|
|
738
|
+
addPreVersionCommand();
|
|
739
|
+
(0, devkit_1.writeJson)(tree, 'nx.json', nxJson);
|
|
740
|
+
devkit_1.output.log({
|
|
741
|
+
title: `Added project to existing release configuration`,
|
|
742
|
+
});
|
|
743
|
+
return;
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
function logNxReleaseDocsInfo() {
|
|
747
|
+
devkit_1.output.log({
|
|
748
|
+
title: `📦 To learn how to publish this library, see https://nx.dev/core-features/manage-releases.`,
|
|
749
|
+
});
|
|
750
|
+
}
|
|
607
751
|
exports.default = libraryGenerator;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
3
|
"$id": "NxTypescriptLibrary",
|
|
4
4
|
"cli": "nx",
|
|
5
5
|
"title": "Create a TypeScript Library",
|
|
@@ -48,6 +48,12 @@
|
|
|
48
48
|
"default": false,
|
|
49
49
|
"x-priority": "internal"
|
|
50
50
|
},
|
|
51
|
+
"skipPackageJson": {
|
|
52
|
+
"description": "Do not add dependencies to `package.json`.",
|
|
53
|
+
"type": "boolean",
|
|
54
|
+
"default": false,
|
|
55
|
+
"x-priority": "internal"
|
|
56
|
+
},
|
|
51
57
|
"skipTsConfig": {
|
|
52
58
|
"type": "boolean",
|
|
53
59
|
"description": "Do not update tsconfig.json for development experience.",
|
|
@@ -83,7 +89,7 @@
|
|
|
83
89
|
"publishable": {
|
|
84
90
|
"type": "boolean",
|
|
85
91
|
"default": false,
|
|
86
|
-
"description": "
|
|
92
|
+
"description": "Configure the library ready for use with `nx release` (https://nx.dev/core-features/manage-releases).",
|
|
87
93
|
"x-priority": "important"
|
|
88
94
|
},
|
|
89
95
|
"importPath": {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Tree } from '@nx/devkit';
|
|
2
|
+
import { ReleaseVersionGeneratorResult } from 'nx/src/command-line/release/version';
|
|
2
3
|
import { ReleaseVersionGeneratorSchema } from './schema';
|
|
3
|
-
export declare function releaseVersionGenerator(tree: Tree, options: ReleaseVersionGeneratorSchema): Promise<
|
|
4
|
+
export declare function releaseVersionGenerator(tree: Tree, options: ReleaseVersionGeneratorSchema): Promise<ReleaseVersionGeneratorResult>;
|
|
4
5
|
export default releaseVersionGenerator;
|