@nx/js 23.1.0 → 23.1.2
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/dist/babel.js +11 -0
- package/dist/internal.d.ts +4 -3
- package/dist/internal.js +16 -17
- package/dist/src/executors/copy-workspace-modules/copy-workspace-modules.js +4 -6
- package/dist/src/executors/node/lib/output-file.js +4 -4
- package/dist/src/executors/node/node.impl.js +9 -10
- package/dist/src/executors/prune-lockfile/prune-lockfile.d.ts +1 -1
- package/dist/src/executors/prune-lockfile/prune-lockfile.js +4 -9
- package/dist/src/executors/release-publish/extract-npm-publish-json-data.js +92 -52
- package/dist/src/executors/release-publish/log-tar.js +6 -2
- package/dist/src/executors/release-publish/release-publish.impl.js +15 -0
- package/dist/src/executors/tsc/lib/batch/watch.js +3 -3
- package/dist/src/executors/tsc/tsc.batch-impl.d.ts +1 -1
- package/dist/src/executors/tsc/tsc.batch-impl.js +2 -2
- package/dist/src/executors/verdaccio/verdaccio.impl.js +8 -1
- package/dist/src/generators/library/library.d.ts +1 -1
- package/dist/src/generators/library/library.js +4 -4
- package/dist/src/generators/library/schema.d.ts +4 -0
- package/dist/src/generators/library/schema.json +8 -2
- package/dist/src/generators/library/utils/add-release-config.js +2 -2
- package/dist/src/generators/setup-build/generator.js +2 -7
- package/dist/src/generators/typescript-sync/typescript-sync.d.ts +1 -1
- package/dist/src/generators/typescript-sync/typescript-sync.js +2 -2
- package/dist/src/index.d.ts +2 -2
- package/dist/src/index.js +5 -7
- package/dist/src/migrations/update-23-1-0/add-ignore-deprecations-for-ts6.d.ts +3 -2
- package/dist/src/migrations/update-23-1-0/add-ignore-deprecations-for-ts6.js +17 -11
- package/dist/src/plugins/jest/start-local-registry.js +6 -1
- package/dist/src/plugins/typescript/plugin.js +9 -14
- package/dist/src/plugins/typescript/util.d.ts +1 -1
- package/dist/src/release/utils/update-lock-file.js +5 -7
- package/dist/src/release/version-actions.d.ts +12 -3
- package/dist/src/release/version-actions.js +232 -74
- package/dist/src/utils/assets/copy-assets-handler.d.ts +1 -1
- package/dist/src/utils/assets/copy-assets-handler.js +2 -2
- package/dist/src/utils/buildable-libs-utils.js +10 -13
- package/dist/src/utils/find-npm-dependencies.js +7 -10
- package/dist/src/utils/generate-globs.js +11 -14
- package/dist/src/utils/get-main-file-dir.js +2 -2
- package/dist/src/utils/npm-config.d.ts +1 -1
- package/dist/src/utils/package-json/update-package-json.d.ts +1 -1
- package/dist/src/utils/package-json/update-package-json.js +6 -11
- package/dist/src/utils/package-manager-workspaces.js +2 -2
- package/dist/src/utils/swc/add-swc-dependencies.js +6 -0
- package/dist/src/utils/typescript/configuration.js +3 -5
- package/dist/src/utils/typescript/create-ts-config.d.ts +1 -1
- package/dist/src/utils/typescript/create-ts-config.js +5 -5
- package/dist/src/utils/typescript/plugin.js +2 -2
- package/dist/src/utils/typescript/run-type-check.js +2 -2
- package/dist/src/utils/typescript/ts-config.d.ts +51 -1
- package/dist/src/utils/typescript/ts-config.js +114 -0
- package/dist/src/utils/typescript/ts-solution-setup.d.ts +1 -1
- package/dist/src/utils/typescript/ts-solution-setup.js +3 -3
- package/dist/src/utils/watch-for-single-file-changes.js +2 -2
- package/migrations.json +1 -1
- package/package.json +8 -5
package/dist/babel.js
CHANGED
|
@@ -41,6 +41,17 @@ module.exports = function (api, options = {}) {
|
|
|
41
41
|
options.decorators ?? { legacy: true },
|
|
42
42
|
],
|
|
43
43
|
[require.resolve('@babel/plugin-transform-class-properties'), { loose }],
|
|
44
|
+
// class-properties runs babel's shared class-features plugin, which hard-errors
|
|
45
|
+
// on private methods and static blocks unless their transforms are loaded too.
|
|
46
|
+
// This bites when an ESM-only dep using that syntax is transformed (un-ignored
|
|
47
|
+
// via transformIgnorePatterns). private-property-in-object completes babel's
|
|
48
|
+
// loose-consistency trio so `loose` stays uniform across the class-features transforms.
|
|
49
|
+
[require.resolve('@babel/plugin-transform-private-methods'), { loose }],
|
|
50
|
+
[
|
|
51
|
+
require.resolve('@babel/plugin-transform-private-property-in-object'),
|
|
52
|
+
{ loose },
|
|
53
|
+
],
|
|
54
|
+
require.resolve('@babel/plugin-transform-class-static-block'),
|
|
44
55
|
].filter(Boolean);
|
|
45
56
|
return {
|
|
46
57
|
presets: [
|
package/dist/internal.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
export { forceRegisterEsmLoader, loadTsFile, registerTsProject, registerTsConfigPaths, requireWithTsconfigFallback, } from 'nx/
|
|
2
|
-
export { TargetProjectLocator, isBuiltinModuleImport, } from 'nx/
|
|
3
|
-
export { findProjectsNpmDependencies } from 'nx/
|
|
1
|
+
export { forceRegisterEsmLoader, loadTsFile, registerTsProject, registerTsConfigPaths, requireWithTsconfigFallback, } from '@nx/devkit/internal';
|
|
2
|
+
export { TargetProjectLocator, isBuiltinModuleImport, } from '@nx/devkit/internal';
|
|
3
|
+
export { findProjectsNpmDependencies } from '@nx/devkit/internal';
|
|
4
4
|
export { walkTsconfigExtendsChain, type RawTsconfigJsonCache, } from './src/utils/typescript/raw-tsconfig';
|
|
5
5
|
export { isEsmProject } from './src/utils/module-format/is-esm-project';
|
|
6
6
|
export { TS_SOLUTION_SETUP_TSCONFIG_INPUT, addProjectToTsSolutionWorkspace, assertNotUsingTsSolutionSetup, findRuntimeTsConfigName, getDefinedCustomConditionName, getProjectSourceRoot, getProjectType, isUsingTsSolutionSetup, shouldConfigureTsSolutionSetup, updateTsconfigFiles, } from './src/utils/typescript/ts-solution-setup';
|
|
7
7
|
export { getTsConfigBaseOptions } from './src/utils/typescript/create-ts-config';
|
|
8
|
+
export { createTreeParseConfigHost, type TreeParseConfigHost, } from './src/utils/typescript/ts-config';
|
|
8
9
|
export { ensureTypescript } from './src/utils/typescript/ensure-typescript';
|
|
9
10
|
export { getRangeMinimum, getTsConfigModuleResolution, isTypescriptVersionAtLeast, } from './src/utils/is-typescript-version-at-least';
|
|
10
11
|
export { getNeededCompilerOptionOverrides } from './src/utils/typescript/configuration';
|
package/dist/internal.js
CHANGED
|
@@ -5,23 +5,20 @@
|
|
|
5
5
|
// internal consumers and may change without semver protection. Consider it
|
|
6
6
|
// the @nx/js equivalent of `@nx/devkit/internal`.
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.
|
|
9
|
-
exports.typesNodeVersion = exports.tsLibVersion = exports.swcNodeVersion = exports.swcHelpersVersion = exports.swcCoreVersion = exports.swcCliVersion = exports.prettierVersion = exports.esbuildVersion = exports.nxVersion = exports.releaseTasks = exports.addReleaseConfigForTsSolution = void 0;
|
|
10
|
-
// Re-exports of nx-source internals
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
Object.defineProperty(exports, "
|
|
14
|
-
Object.defineProperty(exports, "
|
|
15
|
-
Object.defineProperty(exports, "
|
|
16
|
-
Object.defineProperty(exports, "
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
Object.defineProperty(exports, "
|
|
22
|
-
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
|
23
|
-
var create_package_json_1 = require("nx/src/plugins/js/package-json/create-package-json");
|
|
24
|
-
Object.defineProperty(exports, "findProjectsNpmDependencies", { enumerable: true, get: function () { return create_package_json_1.findProjectsNpmDependencies; } });
|
|
8
|
+
exports.addLocalRegistryScripts = exports.stripGlobToBaseDir = exports.getImportPath = exports.createGlobPatternsForDependencies = exports.normalizeUnitTestRunnerOption = exports.normalizeLinterOption = exports.isValidPackageJsonBuildConfig = exports.addBuildAndWatchDepsTargets = exports.findNpmDependencies = exports.getProjectPackageManagerWorkspaceStateWarningTask = exports.getProjectPackageManagerWorkspaceState = exports.getNpmScope = exports.sortPackageJsonFields = exports.CopyAssetsHandler = exports.addSwcRegisterDependencies = exports.addSwcDependencies = exports.addSwcTestConfig = exports.addSwcConfig = exports.createTmpTsConfig = exports.computeCompilerOptionsPaths = exports.calculateProjectDependencies = exports.calculateProjectBuildableDependencies = exports.compileTypeScript = exports.getNeededCompilerOptionOverrides = exports.isTypescriptVersionAtLeast = exports.getTsConfigModuleResolution = exports.getRangeMinimum = exports.ensureTypescript = exports.createTreeParseConfigHost = exports.getTsConfigBaseOptions = exports.updateTsconfigFiles = exports.shouldConfigureTsSolutionSetup = exports.isUsingTsSolutionSetup = exports.getProjectType = exports.getProjectSourceRoot = exports.getDefinedCustomConditionName = exports.findRuntimeTsConfigName = exports.assertNotUsingTsSolutionSetup = exports.addProjectToTsSolutionWorkspace = exports.TS_SOLUTION_SETUP_TSCONFIG_INPUT = exports.isEsmProject = exports.walkTsconfigExtendsChain = exports.findProjectsNpmDependencies = exports.isBuiltinModuleImport = exports.TargetProjectLocator = exports.requireWithTsconfigFallback = exports.registerTsConfigPaths = exports.registerTsProject = exports.loadTsFile = exports.forceRegisterEsmLoader = void 0;
|
|
9
|
+
exports.typesNodeVersion = exports.tsLibVersion = exports.swcNodeVersion = exports.swcHelpersVersion = exports.swcCoreVersion = exports.swcCliVersion = exports.prettierVersion = exports.esbuildVersion = exports.nxVersion = exports.releaseTasks = exports.addReleaseConfigForTsSolution = exports.addReleaseConfigForNonTsSolution = void 0;
|
|
10
|
+
// Re-exports of nx-source internals.
|
|
11
|
+
var internal_1 = require("@nx/devkit/internal");
|
|
12
|
+
Object.defineProperty(exports, "forceRegisterEsmLoader", { enumerable: true, get: function () { return internal_1.forceRegisterEsmLoader; } });
|
|
13
|
+
Object.defineProperty(exports, "loadTsFile", { enumerable: true, get: function () { return internal_1.loadTsFile; } });
|
|
14
|
+
Object.defineProperty(exports, "registerTsProject", { enumerable: true, get: function () { return internal_1.registerTsProject; } });
|
|
15
|
+
Object.defineProperty(exports, "registerTsConfigPaths", { enumerable: true, get: function () { return internal_1.registerTsConfigPaths; } });
|
|
16
|
+
Object.defineProperty(exports, "requireWithTsconfigFallback", { enumerable: true, get: function () { return internal_1.requireWithTsconfigFallback; } });
|
|
17
|
+
var internal_2 = require("@nx/devkit/internal");
|
|
18
|
+
Object.defineProperty(exports, "TargetProjectLocator", { enumerable: true, get: function () { return internal_2.TargetProjectLocator; } });
|
|
19
|
+
Object.defineProperty(exports, "isBuiltinModuleImport", { enumerable: true, get: function () { return internal_2.isBuiltinModuleImport; } });
|
|
20
|
+
var internal_3 = require("@nx/devkit/internal");
|
|
21
|
+
Object.defineProperty(exports, "findProjectsNpmDependencies", { enumerable: true, get: function () { return internal_3.findProjectsNpmDependencies; } });
|
|
25
22
|
// Raw tsconfig walkers (the other AST utils ship via the public @nx/js entry)
|
|
26
23
|
var raw_tsconfig_1 = require("./src/utils/typescript/raw-tsconfig");
|
|
27
24
|
Object.defineProperty(exports, "walkTsconfigExtendsChain", { enumerable: true, get: function () { return raw_tsconfig_1.walkTsconfigExtendsChain; } });
|
|
@@ -47,6 +44,8 @@ Object.defineProperty(exports, "updateTsconfigFiles", { enumerable: true, get: f
|
|
|
47
44
|
// re-exported here so internal consumers can import it from @nx/js/internal.
|
|
48
45
|
var create_ts_config_1 = require("./src/utils/typescript/create-ts-config");
|
|
49
46
|
Object.defineProperty(exports, "getTsConfigBaseOptions", { enumerable: true, get: function () { return create_ts_config_1.getTsConfigBaseOptions; } });
|
|
47
|
+
var ts_config_1 = require("./src/utils/typescript/ts-config");
|
|
48
|
+
Object.defineProperty(exports, "createTreeParseConfigHost", { enumerable: true, get: function () { return ts_config_1.createTreeParseConfigHost; } });
|
|
50
49
|
var ensure_typescript_1 = require("./src/utils/typescript/ensure-typescript");
|
|
51
50
|
Object.defineProperty(exports, "ensureTypescript", { enumerable: true, get: function () { return ensure_typescript_1.ensureTypescript; } });
|
|
52
51
|
var is_typescript_version_at_least_1 = require("./src/utils/is-typescript-version-at-least");
|
|
@@ -2,12 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = copyWorkspaceModules;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const
|
|
5
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
6
6
|
const node_fs_1 = require("node:fs");
|
|
7
7
|
const path_1 = require("path");
|
|
8
8
|
const fs_1 = require("fs");
|
|
9
|
-
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
|
10
|
-
const get_workspace_packages_from_graph_1 = require("nx/src/plugins/js/utils/get-workspace-packages-from-graph");
|
|
11
9
|
const strip_glob_to_base_dir_1 = require("../../utils/strip-glob-to-base-dir");
|
|
12
10
|
async function copyWorkspaceModules(schema, context) {
|
|
13
11
|
devkit_1.logger.log('Copying Workspace Modules to Build Directory...');
|
|
@@ -22,7 +20,7 @@ function handleWorkspaceModules(outputDirectory, packageJson, projectGraph) {
|
|
|
22
20
|
if (!packageJson.dependencies) {
|
|
23
21
|
return;
|
|
24
22
|
}
|
|
25
|
-
const workspaceModules = (0,
|
|
23
|
+
const workspaceModules = (0, internal_1.getWorkspacePackagesFromGraph)(projectGraph);
|
|
26
24
|
const processedModules = new Set();
|
|
27
25
|
const workspaceModulesDir = (0, path_1.join)(outputDirectory, 'workspace_modules');
|
|
28
26
|
function calculateRelativePath(fromPkgName, toPkgName) {
|
|
@@ -43,7 +41,7 @@ function handleWorkspaceModules(outputDirectory, packageJson, projectGraph) {
|
|
|
43
41
|
processedModules.add(pkgName);
|
|
44
42
|
devkit_1.logger.verbose(`Copying ${pkgName}.`);
|
|
45
43
|
const workspaceModuleProject = workspaceModules.get(pkgName);
|
|
46
|
-
const workspaceModuleRoot = workspaceModuleProject.data.root;
|
|
44
|
+
const workspaceModuleRoot = (0, path_1.join)(devkit_1.workspaceRoot, workspaceModuleProject.data.root);
|
|
47
45
|
const newWorkspaceModulePath = (0, path_1.join)(workspaceModulesDir, pkgName);
|
|
48
46
|
// Copy the module
|
|
49
47
|
(0, node_fs_1.mkdirSync)(newWorkspaceModulePath, { recursive: true });
|
|
@@ -114,7 +112,7 @@ function getOutputDir(schema, context) {
|
|
|
114
112
|
if (!maybeOutputPath) {
|
|
115
113
|
throw new Error(`Could not infer an output directory from the '${schema.buildTarget}' target. Please provide 'outputPath'.`);
|
|
116
114
|
}
|
|
117
|
-
maybeOutputPath = (0,
|
|
115
|
+
maybeOutputPath = (0, internal_1.interpolate)(maybeOutputPath, {
|
|
118
116
|
workspaceRoot: devkit_1.workspaceRoot,
|
|
119
117
|
projectRoot: project.root,
|
|
120
118
|
projectName: project.name,
|
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getOutputFileName = getOutputFileName;
|
|
4
4
|
const path_1 = require("path");
|
|
5
|
-
const path_2 = require("nx/src/utils/path");
|
|
6
5
|
const get_main_file_dir_1 = require("../../../utils/get-main-file-dir");
|
|
6
|
+
const devkit_1 = require("@nx/devkit");
|
|
7
7
|
function getOutputFileName({ buildTargetExecutor, main, outputPath, rootDir, }) {
|
|
8
8
|
const fileName = `${(0, path_1.parse)(main).name}.js`;
|
|
9
9
|
if (buildTargetExecutor !== '@nx/js:tsc' &&
|
|
10
10
|
buildTargetExecutor !== '@nx/js:swc') {
|
|
11
11
|
return fileName;
|
|
12
12
|
}
|
|
13
|
-
const mainDirectory = (0,
|
|
14
|
-
const normalizedOutputPath = (0,
|
|
13
|
+
const mainDirectory = (0, devkit_1.normalizePath)((0, path_1.dirname)(main));
|
|
14
|
+
const normalizedOutputPath = (0, devkit_1.normalizePath)(outputPath);
|
|
15
15
|
const isMainInsideOutputPath = mainDirectory === normalizedOutputPath ||
|
|
16
16
|
mainDirectory.startsWith(`${normalizedOutputPath}/`);
|
|
17
17
|
const base = isMainInsideOutputPath ? normalizedOutputPath : rootDir;
|
|
18
|
-
return (0,
|
|
18
|
+
return (0, devkit_1.joinPathFragments)((0, get_main_file_dir_1.getRelativeDirectoryToProjectRoot)(main, base), fileName);
|
|
19
19
|
}
|
|
@@ -6,16 +6,12 @@ const internal_1 = require("@nx/devkit/internal");
|
|
|
6
6
|
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
7
7
|
const child_process_1 = require("child_process");
|
|
8
8
|
const devkit_1 = require("@nx/devkit");
|
|
9
|
-
const client_1 = require("nx/src/daemon/client/client");
|
|
10
9
|
const crypto_1 = require("crypto");
|
|
11
10
|
const path = tslib_1.__importStar(require("path"));
|
|
12
11
|
const path_1 = require("path");
|
|
13
12
|
const buildable_libs_utils_1 = require("../../utils/buildable-libs-utils");
|
|
14
|
-
const native_1 = require("nx/src/native");
|
|
15
13
|
const line_aware_writer_1 = require("./lib/line-aware-writer");
|
|
16
14
|
const coalescing_debounce_1 = require("./lib/coalescing-debounce");
|
|
17
|
-
const fileutils_1 = require("nx/src/utils/fileutils");
|
|
18
|
-
const utils_1 = require("nx/src/tasks-runner/utils");
|
|
19
15
|
const detect_module_format_1 = require("./lib/detect-module-format");
|
|
20
16
|
const output_file_1 = require("./lib/output-file");
|
|
21
17
|
const strip_glob_to_base_dir_1 = require("../../utils/strip-glob-to-base-dir");
|
|
@@ -175,7 +171,7 @@ async function* nodeExecutor(options, context) {
|
|
|
175
171
|
// Windows cannot deliver graceful signals through this API, so
|
|
176
172
|
// skip the grace period and force-kill immediately (matching the
|
|
177
173
|
// previous taskkill /F behavior).
|
|
178
|
-
await (0,
|
|
174
|
+
await (0, internal_1.killProcessTreeGraceful)(task.childProcess.pid, signal, process.platform === 'win32' ? 0 : undefined);
|
|
179
175
|
}
|
|
180
176
|
if (task.id === globalLineAwareWriter.currentProcessId) {
|
|
181
177
|
globalLineAwareWriter.setActiveProcess(null);
|
|
@@ -237,7 +233,7 @@ async function* nodeExecutor(options, context) {
|
|
|
237
233
|
await debouncedProcessQueue.trigger();
|
|
238
234
|
};
|
|
239
235
|
if ((0, devkit_1.isDaemonEnabled)()) {
|
|
240
|
-
additionalExitHandler = await
|
|
236
|
+
additionalExitHandler = await internal_1.daemonClient.registerFileWatcher({
|
|
241
237
|
watchProjects: [context.projectName],
|
|
242
238
|
includeDependencies: true,
|
|
243
239
|
}, async (err, data) => {
|
|
@@ -279,9 +275,12 @@ async function* nodeExecutor(options, context) {
|
|
|
279
275
|
}, context);
|
|
280
276
|
while (true) {
|
|
281
277
|
const event = await output.next();
|
|
278
|
+
if (event.done) {
|
|
279
|
+
break;
|
|
280
|
+
}
|
|
282
281
|
await addToQueue(null, Promise.resolve(event.value));
|
|
283
282
|
await debouncedProcessQueue.trigger();
|
|
284
|
-
if (
|
|
283
|
+
if (!options.watch) {
|
|
285
284
|
break;
|
|
286
285
|
}
|
|
287
286
|
}
|
|
@@ -337,7 +336,7 @@ function getFileToRun(context, project, buildOptions, buildTargetExecutor) {
|
|
|
337
336
|
// {workspaceRoot}/dist/{projectRoot} -> dist/my-app
|
|
338
337
|
const outputPath = project.data.targets[buildOptions.target]?.outputs?.[0];
|
|
339
338
|
if (outputPath) {
|
|
340
|
-
const outputFilePath = (0,
|
|
339
|
+
const outputFilePath = (0, internal_1.interpolate)(outputPath, {
|
|
341
340
|
projectName: project.name,
|
|
342
341
|
projectRoot: project.data.root,
|
|
343
342
|
workspaceRoot: context.root,
|
|
@@ -366,12 +365,12 @@ function getFileToRun(context, project, buildOptions, buildTargetExecutor) {
|
|
|
366
365
|
return (0, path_1.join)(context.root, buildOptions.outputPath, outputFileName);
|
|
367
366
|
}
|
|
368
367
|
function fileToRunCorrectPath(fileToRun) {
|
|
369
|
-
if ((0,
|
|
368
|
+
if ((0, internal_1.fileExists)(fileToRun))
|
|
370
369
|
return fileToRun;
|
|
371
370
|
const extensionsToTry = ['.cjs', '.mjs', '.cjs.js', '.esm.js'];
|
|
372
371
|
for (const ext of extensionsToTry) {
|
|
373
372
|
const file = fileToRun.replace(/\.js$/, ext);
|
|
374
|
-
if ((0,
|
|
373
|
+
if ((0, internal_1.fileExists)(file))
|
|
375
374
|
return file;
|
|
376
375
|
}
|
|
377
376
|
throw new Error(`Could not find ${fileToRun}. Make sure your build succeeded.`);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ExecutorContext } from '@nx/devkit';
|
|
2
|
-
import { type PackageJson } from 'nx/
|
|
2
|
+
import { type PackageJson } from '@nx/devkit/internal';
|
|
3
3
|
import { type PruneLockfileOptions } from './schema';
|
|
4
4
|
export default function pruneLockfileExecutor(schema: PruneLockfileOptions, context: ExecutorContext): Promise<{
|
|
5
5
|
success: boolean;
|
|
@@ -6,11 +6,6 @@ const devkit_1 = require("@nx/devkit");
|
|
|
6
6
|
const internal_1 = require("@nx/devkit/internal");
|
|
7
7
|
const fs_1 = require("fs");
|
|
8
8
|
const path_1 = require("path");
|
|
9
|
-
const utils_1 = require("nx/src/tasks-runner/utils");
|
|
10
|
-
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
|
11
|
-
const lock_file_1 = require("nx/src/plugins/js/lock-file/lock-file");
|
|
12
|
-
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
|
13
|
-
const get_workspace_packages_from_graph_1 = require("nx/src/plugins/js/utils/get-workspace-packages-from-graph");
|
|
14
9
|
const strip_glob_to_base_dir_1 = require("../../utils/strip-glob-to-base-dir");
|
|
15
10
|
async function pruneLockfileExecutor(schema, context) {
|
|
16
11
|
devkit_1.logger.log('Pruning lockfile...');
|
|
@@ -35,9 +30,9 @@ async function pruneLockfileExecutor(schema, context) {
|
|
|
35
30
|
}
|
|
36
31
|
function createPrunedLockfile(packageJson, graph) {
|
|
37
32
|
const packageManager = (0, devkit_1.detectPackageManager)(devkit_1.workspaceRoot);
|
|
38
|
-
const lockfileName = (0,
|
|
39
|
-
const lockFile = (0,
|
|
40
|
-
const workspacePackages = (0,
|
|
33
|
+
const lockfileName = (0, internal_1.getLockFileName)(packageManager);
|
|
34
|
+
const lockFile = (0, internal_1.createLockFile)(packageJson, graph, packageManager);
|
|
35
|
+
const workspacePackages = (0, internal_1.getWorkspacePackagesFromGraph)(graph);
|
|
41
36
|
for (const [pkgName, pkgVersion] of Object.entries(packageJson.dependencies ?? {})) {
|
|
42
37
|
if (pkgVersion.startsWith('workspace:') ||
|
|
43
38
|
pkgVersion.startsWith('file:') ||
|
|
@@ -127,7 +122,7 @@ function getOutputDir(schema, context) {
|
|
|
127
122
|
if (!maybeOutputPath) {
|
|
128
123
|
throw new Error(`Could not infer an output directory from the '${schema.buildTarget}' target. Please provide 'outputPath'.`);
|
|
129
124
|
}
|
|
130
|
-
maybeOutputPath = (0,
|
|
125
|
+
maybeOutputPath = (0, internal_1.interpolate)(maybeOutputPath, {
|
|
131
126
|
workspaceRoot: devkit_1.workspaceRoot,
|
|
132
127
|
projectRoot: project.root,
|
|
133
128
|
projectName: project.name,
|
|
@@ -8,67 +8,107 @@ const expectedNpmPublishJsonKeys = [
|
|
|
8
8
|
'size',
|
|
9
9
|
'filename',
|
|
10
10
|
];
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
//
|
|
20
|
-
//
|
|
21
|
-
//
|
|
22
|
-
//
|
|
23
|
-
|
|
11
|
+
// Pair each '{' with its matching '}' in the publish output. The output is npm's
|
|
12
|
+
// pretty-printed JSON summary interleaved with arbitrary lifecycle-script text,
|
|
13
|
+
// so we recognize only genuine JSON structure and treat everything else as
|
|
14
|
+
// opaque, without interpreting it as JSON (unlike a JSONC parser):
|
|
15
|
+
// - Braces and quotes inside a JSON string value are ignored, so a files[].path
|
|
16
|
+
// like "templates/{{name}}/file.txt" doesn't throw off the pairing (#36236).
|
|
17
|
+
// - '//' and '/*' are not comments; lifecycle output legitimately prints globs
|
|
18
|
+
// and paths such as dist/*.js, and npm/pnpm emit plain JSON.
|
|
19
|
+
// - A raw newline ends a string. A valid JSON string never contains one (it is
|
|
20
|
+
// escaped as \n), so this can't truncate a real value, but it stops a stray
|
|
21
|
+
// unpaired '"' in log text from swallowing the summary on a later line.
|
|
22
|
+
// - A quote only opens a string inside an object, so a lone '"' in the preamble
|
|
23
|
+
// or between objects stays inert.
|
|
24
|
+
// Stray unmatched braces are left unpaired.
|
|
25
|
+
function matchBracePositions(str) {
|
|
26
|
+
const matches = new Map();
|
|
27
|
+
const openBraceStack = [];
|
|
28
|
+
let inString = false;
|
|
29
|
+
for (let i = 0; i < str.length; i++) {
|
|
30
|
+
const char = str[i];
|
|
31
|
+
if (inString) {
|
|
32
|
+
if (char === '\\') {
|
|
33
|
+
i++; // skip the escaped character
|
|
34
|
+
}
|
|
35
|
+
else if (char === '"' || char === '\n' || char === '\r') {
|
|
36
|
+
inString = false;
|
|
37
|
+
}
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
if (char === '"') {
|
|
41
|
+
if (openBraceStack.length > 0) {
|
|
42
|
+
inString = true;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
else if (char === '{') {
|
|
46
|
+
openBraceStack.push(i);
|
|
47
|
+
}
|
|
48
|
+
else if (char === '}') {
|
|
49
|
+
const openIndex = openBraceStack.pop();
|
|
50
|
+
if (openIndex !== undefined) {
|
|
51
|
+
matches.set(openIndex, i);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return matches;
|
|
56
|
+
}
|
|
57
|
+
// Yield every balanced {...} object in the output, left to right by start
|
|
58
|
+
// position, so an outer wrapper is seen before the objects nested inside it.
|
|
59
|
+
function* iterateBalancedJsonObjects(str) {
|
|
60
|
+
const closeByOpen = matchBracePositions(str);
|
|
61
|
+
for (let i = 0; i < str.length; i++) {
|
|
62
|
+
const closeIndex = closeByOpen.get(i);
|
|
63
|
+
if (closeIndex !== undefined) {
|
|
64
|
+
yield { text: str.slice(i, closeIndex + 1), index: i };
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
24
68
|
function isNpmPublishSummary(value) {
|
|
25
69
|
return (typeof value === 'object' &&
|
|
26
70
|
value !== null &&
|
|
27
71
|
expectedNpmPublishJsonKeys.every((key) => value[key] !== undefined));
|
|
28
72
|
}
|
|
29
73
|
function extractNpmPublishJsonData(str) {
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
publishData = value;
|
|
58
|
-
break;
|
|
59
|
-
}
|
|
74
|
+
for (const { text: match, index } of iterateBalancedJsonObjects(str)) {
|
|
75
|
+
// Cheap check to skip candidates that can't be the summary before parsing
|
|
76
|
+
if (!expectedNpmPublishJsonKeys.every((key) => match.includes(key))) {
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
// Full JSON parsing to identify the JSON object
|
|
80
|
+
let parsedJson;
|
|
81
|
+
try {
|
|
82
|
+
parsedJson = JSON.parse(match);
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
// Ignore parsing errors for unrelated JSON blocks
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
// npm <= 11.13 emits the summary as a flat object, while npm >= 11.16 (and
|
|
89
|
+
// pnpm publish run from the workspace root) nest it one level deep under the
|
|
90
|
+
// package name. Support both by unwrapping a single level when the matched
|
|
91
|
+
// object isn't itself the summary.
|
|
92
|
+
let publishData = null;
|
|
93
|
+
if (isNpmPublishSummary(parsedJson)) {
|
|
94
|
+
publishData = parsedJson;
|
|
95
|
+
}
|
|
96
|
+
else if (typeof parsedJson === 'object' && parsedJson !== null) {
|
|
97
|
+
for (const value of Object.values(parsedJson)) {
|
|
98
|
+
if (isNpmPublishSummary(value)) {
|
|
99
|
+
publishData = value;
|
|
100
|
+
break;
|
|
60
101
|
}
|
|
61
102
|
}
|
|
62
|
-
if (!publishData) {
|
|
63
|
-
continue;
|
|
64
|
-
}
|
|
65
|
-
const jsonStartIndex = str.indexOf(match);
|
|
66
|
-
return {
|
|
67
|
-
beforeJsonData: str.slice(0, jsonStartIndex),
|
|
68
|
-
jsonData: publishData,
|
|
69
|
-
afterJsonData: str.slice(jsonStartIndex + match.length),
|
|
70
|
-
};
|
|
71
103
|
}
|
|
104
|
+
if (!publishData) {
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
return {
|
|
108
|
+
beforeJsonData: str.slice(0, index),
|
|
109
|
+
jsonData: publishData,
|
|
110
|
+
afterJsonData: str.slice(index + match.length),
|
|
111
|
+
};
|
|
72
112
|
}
|
|
73
113
|
// No applicable jsonData detected, the whole contents is the beforeJsonData
|
|
74
114
|
return {
|
|
@@ -14,9 +14,13 @@ const logTar = (tarball, opts = {}) => {
|
|
|
14
14
|
console.log(chalk_1.default.magenta('=== Tarball Contents ==='));
|
|
15
15
|
if (tarball.files.length) {
|
|
16
16
|
console.log('');
|
|
17
|
-
const columnData = (0, columnify_1.default)(
|
|
17
|
+
const columnData = (0, columnify_1.default)(
|
|
18
|
+
// Sort for a stable listing: pnpm 11 orders files differently than
|
|
19
|
+
// npm and pnpm 10.
|
|
20
|
+
[...tarball.files]
|
|
21
|
+
.sort((a, b) => (a.path < b.path ? -1 : a.path > b.path ? 1 : 0))
|
|
18
22
|
.map((f) => {
|
|
19
|
-
const bytes = (0, format_bytes_1.formatBytes)(f.size, false);
|
|
23
|
+
const bytes = typeof f.size === 'number' ? (0, format_bytes_1.formatBytes)(f.size, false) : '';
|
|
20
24
|
return /^node_modules\//.test(f.path)
|
|
21
25
|
? null
|
|
22
26
|
: { path: f.path, size: `${bytes}` };
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.default = runExecutor;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const child_process_1 = require("child_process");
|
|
6
|
+
const fs_1 = require("fs");
|
|
6
7
|
const npm_run_path_1 = require("npm-run-path");
|
|
7
8
|
const path_1 = require("path");
|
|
8
9
|
const is_locally_linked_package_version_1 = require("../../utils/is-locally-linked-package-version");
|
|
@@ -349,6 +350,20 @@ function runPublish(ctx) {
|
|
|
349
350
|
success: false,
|
|
350
351
|
};
|
|
351
352
|
}
|
|
353
|
+
// pnpm 11 dropped the per-file size field from its publish --json output,
|
|
354
|
+
// so recover the sizes from disk for the tarball contents log.
|
|
355
|
+
if (Array.isArray(jsonData.files)) {
|
|
356
|
+
for (const file of jsonData.files) {
|
|
357
|
+
if (typeof file.size !== 'number' && typeof file.path === 'string') {
|
|
358
|
+
try {
|
|
359
|
+
file.size = (0, fs_1.statSync)((0, path_1.join)(packageRoot, file.path)).size;
|
|
360
|
+
}
|
|
361
|
+
catch {
|
|
362
|
+
// leave the size unknown, logTar omits it
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}
|
|
352
367
|
if (isDryRun) {
|
|
353
368
|
for (const [key, val] of Object.entries(jsonData)) {
|
|
354
369
|
if (typeof val !== 'string') {
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.watchTaskProjectsPackageJsonFileChanges = watchTaskProjectsPackageJsonFileChanges;
|
|
4
4
|
exports.watchTaskProjectsFileChangesForAssets = watchTaskProjectsFileChangesForAssets;
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
|
-
const client_1 = require("nx/src/daemon/client/client");
|
|
7
6
|
const path_1 = require("path");
|
|
7
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
8
8
|
async function watchTaskProjectsPackageJsonFileChanges(taskInfos, callback) {
|
|
9
9
|
const projects = [];
|
|
10
10
|
const packageJsonTaskInfoMap = new Map();
|
|
@@ -12,7 +12,7 @@ async function watchTaskProjectsPackageJsonFileChanges(taskInfos, callback) {
|
|
|
12
12
|
projects.push(t.context.projectName);
|
|
13
13
|
packageJsonTaskInfoMap.set((0, path_1.join)(t.options.projectRoot, 'package.json'), t);
|
|
14
14
|
});
|
|
15
|
-
const unregisterFileWatcher = await
|
|
15
|
+
const unregisterFileWatcher = await internal_1.daemonClient.registerFileWatcher({ watchProjects: projects }, (err, data) => {
|
|
16
16
|
if (err === 'reconnecting') {
|
|
17
17
|
// Silent - daemon restarts automatically on lockfile changes
|
|
18
18
|
return;
|
|
@@ -43,7 +43,7 @@ async function watchTaskProjectsPackageJsonFileChanges(taskInfos, callback) {
|
|
|
43
43
|
return () => unregisterFileWatcher();
|
|
44
44
|
}
|
|
45
45
|
async function watchTaskProjectsFileChangesForAssets(taskInfos) {
|
|
46
|
-
const unregisterFileWatcher = await
|
|
46
|
+
const unregisterFileWatcher = await internal_1.daemonClient.registerFileWatcher({
|
|
47
47
|
watchProjects: taskInfos.map((t) => t.context.projectName),
|
|
48
48
|
includeDependencies: true,
|
|
49
49
|
includeGlobalWorkspaceFiles: true,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ExecutorContext, TaskGraph } from '@nx/devkit';
|
|
2
|
-
import type { BatchExecutorTaskResult } from 'nx/src/config/misc-interfaces';
|
|
3
2
|
import type { ExecutorOptions } from '../../utils/schema';
|
|
3
|
+
import { type BatchExecutorTaskResult } from '@nx/devkit/internal';
|
|
4
4
|
export declare function tscBatchExecutor(taskGraph: TaskGraph, inputs: Record<string, ExecutorOptions>, overrides: ExecutorOptions, context: ExecutorContext): AsyncGenerator<BatchExecutorTaskResult, any, unknown>;
|
|
5
5
|
export default tscBatchExecutor;
|
|
@@ -3,12 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.tscBatchExecutor = tscBatchExecutor;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const fs_1 = require("fs");
|
|
6
|
-
const async_iterator_1 = require("nx/src/utils/async-iterator");
|
|
7
6
|
const update_package_json_1 = require("../../utils/package-json/update-package-json");
|
|
8
7
|
const tsc_impl_1 = require("./tsc.impl");
|
|
9
8
|
const lib_1 = require("./lib");
|
|
10
9
|
const batch_1 = require("./lib/batch");
|
|
11
10
|
const create_entry_points_1 = require("../../utils/package-json/create-entry-points");
|
|
11
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
12
12
|
async function* tscBatchExecutor(taskGraph, inputs, overrides, context) {
|
|
13
13
|
const tasksOptions = (0, batch_1.normalizeTasksOptions)(inputs, context);
|
|
14
14
|
let shouldWatch = false;
|
|
@@ -89,7 +89,7 @@ async function* tscBatchExecutor(taskGraph, inputs, overrides, context) {
|
|
|
89
89
|
process.on('SIGTERM', () => handleTermination(128 + 15));
|
|
90
90
|
return yield* mapAsyncIterable(typescriptCompilation, async (iterator) => {
|
|
91
91
|
// drain the iterator, we don't use the results
|
|
92
|
-
await (0,
|
|
92
|
+
await (0, internal_1.getLastValueFromAsyncIterableIterator)(iterator);
|
|
93
93
|
return { value: undefined, done: true };
|
|
94
94
|
});
|
|
95
95
|
}
|
|
@@ -66,12 +66,19 @@ async function verdaccioExecutor(options, context) {
|
|
|
66
66
|
port: options.port,
|
|
67
67
|
};
|
|
68
68
|
}
|
|
69
|
+
function getVerdaccioBinPath() {
|
|
70
|
+
const { packageJson, path: packageJsonPath } = (0, internal_1.readModulePackageJson)('verdaccio');
|
|
71
|
+
const bin = typeof packageJson.bin === 'string'
|
|
72
|
+
? packageJson.bin
|
|
73
|
+
: packageJson.bin['verdaccio'];
|
|
74
|
+
return (0, path_1.join)((0, path_1.dirname)(packageJsonPath), bin);
|
|
75
|
+
}
|
|
69
76
|
/**
|
|
70
77
|
* Fork the verdaccio process: https://verdaccio.org/docs/verdaccio-programmatically/#using-fork-from-child_process-module
|
|
71
78
|
*/
|
|
72
79
|
function startVerdaccio(options, workspaceRoot) {
|
|
73
80
|
return new Promise((resolve, reject) => {
|
|
74
|
-
childProcess = (0, child_process_1.fork)(
|
|
81
|
+
childProcess = (0, child_process_1.fork)(getVerdaccioBinPath(), createVerdaccioOptions(options, workspaceRoot), {
|
|
75
82
|
env: {
|
|
76
83
|
...process.env,
|
|
77
84
|
VERDACCIO_HANDLE_KILL_SIGNALS: 'true',
|
|
@@ -2,6 +2,6 @@ import { GeneratorCallback, Tree } from '@nx/devkit';
|
|
|
2
2
|
import type { LibraryGeneratorSchema, NormalizedLibraryGeneratorOptions } from './schema';
|
|
3
3
|
export declare function libraryGenerator(tree: Tree, schema: LibraryGeneratorSchema): Promise<GeneratorCallback>;
|
|
4
4
|
export declare function libraryGeneratorInternal(tree: Tree, schema: LibraryGeneratorSchema): Promise<GeneratorCallback>;
|
|
5
|
-
export type AddLintOptions = Pick<NormalizedLibraryGeneratorOptions, 'name' | 'linter' | 'projectRoot' | 'unitTestRunner' | 'js' | 'setParserOptionsProject' | 'rootProject' | 'bundler' | 'addPlugin' | 'isUsingTsSolutionConfig'>;
|
|
5
|
+
export type AddLintOptions = Pick<NormalizedLibraryGeneratorOptions, 'name' | 'linter' | 'projectRoot' | 'unitTestRunner' | 'js' | 'enableTypedLinting' | 'setParserOptionsProject' | 'rootProject' | 'bundler' | 'addPlugin' | 'isUsingTsSolutionConfig'>;
|
|
6
6
|
export declare function addLint(tree: Tree, options: AddLintOptions): Promise<GeneratorCallback>;
|
|
7
7
|
export default libraryGenerator;
|
|
@@ -249,6 +249,9 @@ async function configureProject(tree, options) {
|
|
|
249
249
|
}
|
|
250
250
|
async function addLint(tree, options) {
|
|
251
251
|
const { lintProjectGenerator } = (0, devkit_1.ensurePackage)('@nx/eslint', versions_1.nxVersion);
|
|
252
|
+
const { addOverrideToLintConfig, lintConfigHasOverride, isEslintConfigSupported, updateOverrideInLintConfig, addIgnoresToLintConfig, isTypedLintingEnabled,
|
|
253
|
+
// nx-ignore-next-line
|
|
254
|
+
} = require('@nx/eslint/internal');
|
|
252
255
|
const projectConfiguration = (0, devkit_1.readProjectConfiguration)(tree, options.name);
|
|
253
256
|
const task = await lintProjectGenerator(tree, {
|
|
254
257
|
project: options.name,
|
|
@@ -258,15 +261,12 @@ async function addLint(tree, options) {
|
|
|
258
261
|
(0, devkit_1.joinPathFragments)(options.projectRoot, 'tsconfig.lib.json'),
|
|
259
262
|
],
|
|
260
263
|
unitTestRunner: options.unitTestRunner,
|
|
261
|
-
|
|
264
|
+
enableTypedLinting: isTypedLintingEnabled(options),
|
|
262
265
|
rootProject: options.rootProject,
|
|
263
266
|
addPlugin: options.addPlugin,
|
|
264
267
|
// Since the build target is inferred now, we need to let the generator know to add @nx/dependency-checks regardless.
|
|
265
268
|
addPackageJsonDependencyChecks: options.bundler !== 'none',
|
|
266
269
|
});
|
|
267
|
-
const { addOverrideToLintConfig, lintConfigHasOverride, isEslintConfigSupported, updateOverrideInLintConfig, addIgnoresToLintConfig,
|
|
268
|
-
// nx-ignore-next-line
|
|
269
|
-
} = require('@nx/eslint/internal');
|
|
270
270
|
// if config is not supported, we don't need to do anything
|
|
271
271
|
if (!isEslintConfigSupported(tree)) {
|
|
272
272
|
return task;
|
|
@@ -23,6 +23,10 @@ export interface LibraryGeneratorSchema {
|
|
|
23
23
|
strict?: boolean;
|
|
24
24
|
publishable?: boolean;
|
|
25
25
|
buildable?: boolean;
|
|
26
|
+
enableTypedLinting?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* @deprecated Use `enableTypedLinting` instead. This option will be removed in Nx v24.
|
|
29
|
+
*/
|
|
26
30
|
setParserOptionsProject?: boolean;
|
|
27
31
|
config?: 'workspace' | 'project' | 'npm-scripts';
|
|
28
32
|
compiler?: Compiler;
|