@nx/js 21.4.0-beta.5 → 21.4.0-beta.7
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 +4 -4
- package/src/generators/library/library.d.ts.map +1 -1
- package/src/generators/library/library.js +2 -0
- package/src/release/version-actions.d.ts.map +1 -1
- package/src/release/version-actions.js +7 -1
- package/src/utils/typescript/ts-solution-setup.d.ts +1 -0
- package/src/utils/typescript/ts-solution-setup.d.ts.map +1 -1
- package/src/utils/typescript/ts-solution-setup.js +44 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/js",
|
|
3
|
-
"version": "21.4.0-beta.
|
|
3
|
+
"version": "21.4.0-beta.7",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The JS plugin for Nx contains executors and generators that provide the best experience for developing JavaScript and TypeScript projects. ",
|
|
6
6
|
"repository": {
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"@babel/preset-env": "^7.23.2",
|
|
40
40
|
"@babel/preset-typescript": "^7.22.5",
|
|
41
41
|
"@babel/runtime": "^7.22.6",
|
|
42
|
-
"@nx/devkit": "21.4.0-beta.
|
|
43
|
-
"@nx/workspace": "21.4.0-beta.
|
|
42
|
+
"@nx/devkit": "21.4.0-beta.7",
|
|
43
|
+
"@nx/workspace": "21.4.0-beta.7",
|
|
44
44
|
"@zkochan/js-yaml": "0.0.7",
|
|
45
45
|
"babel-plugin-const-enum": "^1.0.1",
|
|
46
46
|
"babel-plugin-macros": "^3.1.0",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"tslib": "^2.3.0"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
|
-
"nx": "21.4.0-beta.
|
|
66
|
+
"nx": "21.4.0-beta.7"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
69
|
"verdaccio": "^6.0.5"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"library.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/generators/library/library.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,iBAAiB,EAYjB,IAAI,EAKL,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"library.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/generators/library/library.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,iBAAiB,EAYjB,IAAI,EAKL,MAAM,YAAY,CAAC;AAyCpB,OAAO,KAAK,EAEV,sBAAsB,EACtB,iCAAiC,EAClC,MAAM,UAAU,CAAC;AASlB,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,sBAAsB,8BAO/B;AAED,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,sBAAsB,8BAsL/B;AA4HD,MAAM,MAAM,cAAc,GAAG,IAAI,CAC/B,iCAAiC,EAC/B,MAAM,GACN,QAAQ,GACR,aAAa,GACb,gBAAgB,GAChB,IAAI,GACJ,yBAAyB,GACzB,aAAa,GACb,SAAS,GACT,WAAW,CACd,CAAC;AAEF,wBAAsB,OAAO,CAC3B,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,iBAAiB,CAAC,CAqG5B;AA4vBD,eAAe,gBAAgB,CAAC"}
|
|
@@ -34,11 +34,13 @@ async function libraryGenerator(tree, schema) {
|
|
|
34
34
|
}
|
|
35
35
|
async function libraryGeneratorInternal(tree, schema) {
|
|
36
36
|
const tasks = [];
|
|
37
|
+
const addTsPlugin = (0, ts_solution_setup_1.shouldConfigureTsSolutionSetup)(tree, schema.addPlugin);
|
|
37
38
|
tasks.push(await (0, init_1.default)(tree, {
|
|
38
39
|
...schema,
|
|
39
40
|
skipFormat: true,
|
|
40
41
|
tsConfigName: schema.rootProject ? 'tsconfig.json' : 'tsconfig.base.json',
|
|
41
42
|
addTsConfigBase: true,
|
|
43
|
+
addTsPlugin,
|
|
42
44
|
// In the new setup, Prettier is prompted for and installed during `create-nx-workspace`.
|
|
43
45
|
formatter: (0, ts_solution_setup_1.isUsingTsSolutionSetup)(tree) ? 'none' : 'prettier',
|
|
44
46
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version-actions.d.ts","sourceRoot":"","sources":["../../../../../packages/js/src/release/version-actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,YAAY,EAEZ,IAAI,EAGL,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,yBAAyB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACvE,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,uBAAuB,CAAC;AAK3E,eAAO,MAAM,yBAAyB,EAAE,yBAmBvC,CAAC;AAKF,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,cAAc;IAC1D,sBAAsB,WAAoB;IAEpC,oCAAoC,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC;QAC9D,cAAc,EAAE,MAAM,CAAC;QACvB,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC;IAkBI,8BAA8B,CAClC,IAAI,EAAE,IAAI,EACV,8BAA8B,EAAE,6BAA6B,CAAC,gCAAgC,CAAC,GAC9F,OAAO,CAAC;QACT,cAAc,EAAE,MAAM,CAAC;QACvB,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;
|
|
1
|
+
{"version":3,"file":"version-actions.d.ts","sourceRoot":"","sources":["../../../../../packages/js/src/release/version-actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,YAAY,EAEZ,IAAI,EAGL,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,yBAAyB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACvE,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,uBAAuB,CAAC;AAK3E,eAAO,MAAM,yBAAyB,EAAE,yBAmBvC,CAAC;AAKF,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,cAAc;IAC1D,sBAAsB,WAAoB;IAEpC,oCAAoC,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC;QAC9D,cAAc,EAAE,MAAM,CAAC;QACvB,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC;IAkBI,8BAA8B,CAClC,IAAI,EAAE,IAAI,EACV,8BAA8B,EAAE,6BAA6B,CAAC,gCAAgC,CAAC,GAC9F,OAAO,CAAC;QACT,cAAc,EAAE,MAAM,CAAC;QACvB,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IAkEI,8BAA8B,CAClC,IAAI,EAAE,IAAI,EACV,YAAY,EAAE,YAAY,EAC1B,qBAAqB,EAAE,MAAM,GAC5B,OAAO,CAAC;QACT,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;QAC9B,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAC;KACrC,CAAC;IA+BI,oBAAoB,CACxB,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,MAAM,EAAE,CAAC;IAcd,yBAAyB,CAC7B,IAAI,EAAE,IAAI,EACV,YAAY,EAAE,YAAY,EAC1B,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC3C,OAAO,CAAC,MAAM,EAAE,CAAC;IA+DpB,OAAO,CAAC,yBAAyB;CAyClC"}
|
|
@@ -66,7 +66,13 @@ class JsVersionActions extends release_1.VersionActions {
|
|
|
66
66
|
if (error) {
|
|
67
67
|
return reject(error);
|
|
68
68
|
}
|
|
69
|
-
|
|
69
|
+
// Only reject on stderr if it contains actual errors, not just npm warnings
|
|
70
|
+
// npm 11+ writes "npm warn" messages to stderr even on successful commands
|
|
71
|
+
if (stderr &&
|
|
72
|
+
!stderr
|
|
73
|
+
.trim()
|
|
74
|
+
.split('\n')
|
|
75
|
+
.every((line) => line.startsWith('npm warn'))) {
|
|
70
76
|
return reject(stderr);
|
|
71
77
|
}
|
|
72
78
|
return resolve(stdout.trim());
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type ProjectConfiguration, type Tree } from '@nx/devkit';
|
|
2
2
|
export declare function isUsingTypeScriptPlugin(tree: Tree): boolean;
|
|
3
|
+
export declare function shouldConfigureTsSolutionSetup(tree: Tree, addPlugins: boolean, addTsPlugin?: boolean): boolean;
|
|
3
4
|
export declare function isUsingTsSolutionSetup(tree?: Tree): boolean;
|
|
4
5
|
export declare function assertNotUsingTsSolutionSetup(tree: Tree, pluginName: string, generatorName: string): void;
|
|
5
6
|
export declare function findRuntimeTsConfigName(projectRoot: string, tree?: Tree): string | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ts-solution-setup.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/utils/typescript/ts-solution-setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,oBAAoB,EAGzB,KAAK,IAAI,EAGV,MAAM,YAAY,CAAC;AAWpB,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAU3D;AAED,wBAAgB,sBAAsB,CAAC,IAAI,CAAC,EAAE,IAAI,GAAG,OAAO,CAO3D;
|
|
1
|
+
{"version":3,"file":"ts-solution-setup.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/utils/typescript/ts-solution-setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,oBAAoB,EAGzB,KAAK,IAAI,EAGV,MAAM,YAAY,CAAC;AAWpB,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAU3D;AAED,wBAAgB,8BAA8B,CAC5C,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,OAAO,EACnB,WAAW,CAAC,EAAE,OAAO,GACpB,OAAO,CAsBT;AAED,wBAAgB,sBAAsB,CAAC,IAAI,CAAC,EAAE,IAAI,GAAG,OAAO,CAO3D;AAuDD,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,MAAM,GACpB,IAAI,CAsBN;AAED,wBAAgB,uBAAuB,CACrC,WAAW,EAAE,MAAM,EACnB,IAAI,CAAC,EAAE,IAAI,GACV,MAAM,GAAG,IAAI,CAOf;AAED,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,MAAM,EACnB,uBAAuB,EAAE,MAAM,EAC/B,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,EAAE,CAAC,EAC5D,OAAO,GAAE,MAAM,EAAO,EACtB,OAAO,SAAQ,QAoFhB;AAED,wBAAsB,+BAA+B,CACnD,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,MAAM,iBAqDnB;AAED,wBAAgB,cAAc,CAC5B,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,MAAM,EACnB,WAAW,CAAC,EAAE,SAAS,GAAG,aAAa,GACtC,SAAS,GAAG,aAAa,CAoB3B;AAED,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,oBAAoB,EAC7B,IAAI,CAAC,EAAE,IAAI,GACV,MAAM,CAgBR"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isUsingTypeScriptPlugin = isUsingTypeScriptPlugin;
|
|
4
|
+
exports.shouldConfigureTsSolutionSetup = shouldConfigureTsSolutionSetup;
|
|
4
5
|
exports.isUsingTsSolutionSetup = isUsingTsSolutionSetup;
|
|
5
6
|
exports.assertNotUsingTsSolutionSetup = assertNotUsingTsSolutionSetup;
|
|
6
7
|
exports.findRuntimeTsConfigName = findRuntimeTsConfigName;
|
|
@@ -20,11 +21,39 @@ function isUsingTypeScriptPlugin(tree) {
|
|
|
20
21
|
? p === '@nx/js/typescript'
|
|
21
22
|
: p.plugin === '@nx/js/typescript') ?? false);
|
|
22
23
|
}
|
|
24
|
+
function shouldConfigureTsSolutionSetup(tree, addPlugins, addTsPlugin) {
|
|
25
|
+
if (addTsPlugin !== undefined) {
|
|
26
|
+
return addTsPlugin;
|
|
27
|
+
}
|
|
28
|
+
if (addPlugins === undefined) {
|
|
29
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
30
|
+
addPlugins =
|
|
31
|
+
process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
32
|
+
nxJson.useInferencePlugins !== false;
|
|
33
|
+
}
|
|
34
|
+
if (!addPlugins) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
if (!(0, package_manager_workspaces_1.isUsingPackageManagerWorkspaces)(tree)) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
// if there are no root tsconfig files, we should configure the TS solution setup
|
|
41
|
+
return !tree.exists('tsconfig.base.json') && !tree.exists('tsconfig.json');
|
|
42
|
+
}
|
|
23
43
|
function isUsingTsSolutionSetup(tree) {
|
|
24
44
|
tree ??= new tree_1.FsTree(devkit_1.workspaceRoot, false);
|
|
25
45
|
return ((0, package_manager_workspaces_1.isUsingPackageManagerWorkspaces)(tree) &&
|
|
26
46
|
isWorkspaceSetupWithTsSolution(tree));
|
|
27
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* The TS solution setup requires:
|
|
50
|
+
* - `tsconfig.base.json`: TS config with common compiler options needed by the
|
|
51
|
+
* majority of projects in the workspace. It's meant to be extended by other
|
|
52
|
+
* tsconfig files in the workspace to reuse them.
|
|
53
|
+
* - `tsconfig.json`: TS solution config file that references all other projects
|
|
54
|
+
* in the repo. It shouldn't include any file and it's not meant to be
|
|
55
|
+
* extended or define any common compiler options.
|
|
56
|
+
*/
|
|
28
57
|
function isWorkspaceSetupWithTsSolution(tree) {
|
|
29
58
|
if (!tree.exists('tsconfig.base.json') || !tree.exists('tsconfig.json')) {
|
|
30
59
|
return false;
|
|
@@ -34,27 +63,30 @@ function isWorkspaceSetupWithTsSolution(tree) {
|
|
|
34
63
|
return false;
|
|
35
64
|
}
|
|
36
65
|
/**
|
|
37
|
-
*
|
|
38
|
-
* - `files`
|
|
39
|
-
* -
|
|
40
|
-
*
|
|
66
|
+
* TS solution setup requires:
|
|
67
|
+
* - One of `files` or `include` defined
|
|
68
|
+
* - If set, they must be empty arrays
|
|
69
|
+
*
|
|
70
|
+
* Note: while the TS solution setup uses TS project references, in the initial
|
|
71
|
+
* state of the workspace, where there are no projects, `references` is not
|
|
72
|
+
* required to be defined.
|
|
41
73
|
*/
|
|
42
|
-
if (!tsconfigJson.files ||
|
|
43
|
-
tsconfigJson.files
|
|
44
|
-
|
|
45
|
-
!!tsconfigJson.include?.length) {
|
|
74
|
+
if ((!tsconfigJson.files && !tsconfigJson.include) ||
|
|
75
|
+
tsconfigJson.files?.length > 0 ||
|
|
76
|
+
tsconfigJson.include?.length > 0) {
|
|
46
77
|
return false;
|
|
47
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* TS solution setup requires:
|
|
81
|
+
* - `compilerOptions.composite`: true
|
|
82
|
+
* - `compilerOptions.declaration`: true or not set (default to true)
|
|
83
|
+
*/
|
|
48
84
|
const baseTsconfigJson = (0, devkit_1.readJson)(tree, 'tsconfig.base.json');
|
|
49
85
|
if (!baseTsconfigJson.compilerOptions ||
|
|
50
86
|
!baseTsconfigJson.compilerOptions.composite ||
|
|
51
87
|
baseTsconfigJson.compilerOptions.declaration === false) {
|
|
52
88
|
return false;
|
|
53
89
|
}
|
|
54
|
-
const { compilerOptions, ...rest } = baseTsconfigJson;
|
|
55
|
-
if (Object.keys(rest).length > 0) {
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
90
|
return true;
|
|
59
91
|
}
|
|
60
92
|
function assertNotUsingTsSolutionSetup(tree, pluginName, generatorName) {
|