nx 20.0.0-beta.2 → 20.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +9 -1
- package/package.json +14 -13
- package/schemas/nx-schema.json +26 -21
- package/src/command-line/graph/graph.js +9 -9
- package/src/command-line/init/implementation/add-nx-to-nest.js +5 -5
- package/src/command-line/init/implementation/react/clean-up-files.js +7 -7
- package/src/command-line/init/implementation/react/index.js +19 -12
- package/src/command-line/init/implementation/react/rename-js-to-jsx.js +3 -3
- package/src/command-line/release/changelog.js +1 -2
- package/src/command-line/release/config/version-plans.js +6 -7
- package/src/command-line/release/plan.js +6 -5
- package/src/command-line/release/release.js +2 -2
- package/src/command-line/release/version.js +5 -3
- package/src/command-line/reset/reset.js +4 -4
- package/src/core/graph/main.js +1 -1
- package/src/core/graph/styles.css +1 -1
- package/src/core/graph/styles.js +1 -1
- package/src/daemon/cache.d.ts +1 -2
- package/src/daemon/cache.js +12 -21
- package/src/daemon/client/client.js +9 -8
- package/src/daemon/tmp-dir.js +6 -7
- package/src/generators/tree.d.ts +1 -1
- package/src/generators/tree.js +11 -11
- package/src/native/nx.wasm32-wasi.wasm +0 -0
- package/src/plugins/js/index.js +1 -2
- package/src/project-graph/nx-deps-cache.js +5 -6
- package/src/tasks-runner/cache.js +17 -16
- package/src/tasks-runner/life-cycles/dynamic-run-many-terminal-output-life-cycle.js +5 -0
- package/src/tasks-runner/life-cycles/static-run-many-terminal-output-life-cycle.js +7 -0
- package/src/tasks-runner/remove-old-cache-records.js +2 -3
- package/src/utils/fileutils.d.ts +9 -1
- package/src/utils/fileutils.js +29 -12
- package/src/utils/ignore.js +2 -2
- package/src/utils/package-manager.js +2 -2
- package/src/utils/plugins/core-plugins.js +4 -0
package/src/utils/fileutils.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { JsonParseOptions, JsonSerializeOptions } from './json';
|
2
|
-
import { PathLike } from 'fs';
|
2
|
+
import { PathLike } from 'node:fs';
|
3
3
|
export interface JsonReadOptions extends JsonParseOptions {
|
4
4
|
/**
|
5
5
|
* mutable field recording whether JSON ends with new line
|
@@ -43,6 +43,14 @@ export declare function readYamlFile<T extends object = any>(path: string, optio
|
|
43
43
|
* @param options JSON serialize options
|
44
44
|
*/
|
45
45
|
export declare function writeJsonFile<T extends object = object>(path: string, data: T, options?: JsonWriteOptions): void;
|
46
|
+
/**
|
47
|
+
* Serializes the given data to JSON and writes it to a file asynchronously.
|
48
|
+
*
|
49
|
+
* @param path A path to a file.
|
50
|
+
* @param data data which should be serialized to JSON and written to the file
|
51
|
+
* @param options JSON serialize options
|
52
|
+
*/
|
53
|
+
export declare function writeJsonFileAsync<T extends object = object>(path: string, data: T, options?: JsonWriteOptions): Promise<void>;
|
46
54
|
/**
|
47
55
|
* Check if a directory exists
|
48
56
|
* @param path Path to directory
|
package/src/utils/fileutils.js
CHANGED
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.readJsonFile = readJsonFile;
|
4
4
|
exports.readYamlFile = readYamlFile;
|
5
5
|
exports.writeJsonFile = writeJsonFile;
|
6
|
+
exports.writeJsonFileAsync = writeJsonFileAsync;
|
6
7
|
exports.directoryExists = directoryExists;
|
7
8
|
exports.fileExists = fileExists;
|
8
9
|
exports.createDirectory = createDirectory;
|
@@ -10,7 +11,8 @@ exports.isRelativePath = isRelativePath;
|
|
10
11
|
exports.extractFileFromTarball = extractFileFromTarball;
|
11
12
|
exports.readFileIfExisting = readFileIfExisting;
|
12
13
|
const json_1 = require("./json");
|
13
|
-
const
|
14
|
+
const node_fs_1 = require("node:fs");
|
15
|
+
const promises_1 = require("node:fs/promises");
|
14
16
|
const path_1 = require("path");
|
15
17
|
const tar = require("tar-stream");
|
16
18
|
const zlib_1 = require("zlib");
|
@@ -22,7 +24,7 @@ const zlib_1 = require("zlib");
|
|
22
24
|
* @returns Object the JSON content of the file represents
|
23
25
|
*/
|
24
26
|
function readJsonFile(path, options) {
|
25
|
-
const content = (0,
|
27
|
+
const content = (0, node_fs_1.readFileSync)(path, 'utf-8');
|
26
28
|
if (options) {
|
27
29
|
options.endsWithNewline = content.charCodeAt(content.length - 1) === 10;
|
28
30
|
}
|
@@ -41,7 +43,7 @@ function readJsonFile(path, options) {
|
|
41
43
|
* @returns
|
42
44
|
*/
|
43
45
|
function readYamlFile(path, options) {
|
44
|
-
const content = (0,
|
46
|
+
const content = (0, node_fs_1.readFileSync)(path, 'utf-8');
|
45
47
|
const { load } = require('@zkochan/js-yaml');
|
46
48
|
return load(content, { ...options, filename: path });
|
47
49
|
}
|
@@ -53,12 +55,27 @@ function readYamlFile(path, options) {
|
|
53
55
|
* @param options JSON serialize options
|
54
56
|
*/
|
55
57
|
function writeJsonFile(path, data, options) {
|
56
|
-
(0,
|
58
|
+
(0, node_fs_1.mkdirSync)((0, path_1.dirname)(path), { recursive: true });
|
57
59
|
const serializedJson = (0, json_1.serializeJson)(data, options);
|
58
60
|
const content = options?.appendNewLine
|
59
61
|
? `${serializedJson}\n`
|
60
62
|
: serializedJson;
|
61
|
-
(0,
|
63
|
+
(0, node_fs_1.writeFileSync)(path, content, { encoding: 'utf-8' });
|
64
|
+
}
|
65
|
+
/**
|
66
|
+
* Serializes the given data to JSON and writes it to a file asynchronously.
|
67
|
+
*
|
68
|
+
* @param path A path to a file.
|
69
|
+
* @param data data which should be serialized to JSON and written to the file
|
70
|
+
* @param options JSON serialize options
|
71
|
+
*/
|
72
|
+
async function writeJsonFileAsync(path, data, options) {
|
73
|
+
await (0, promises_1.mkdir)((0, path_1.dirname)(path), { recursive: true });
|
74
|
+
const serializedJson = (0, json_1.serializeJson)(data, options);
|
75
|
+
const content = options?.appendNewLine
|
76
|
+
? `${serializedJson}\n`
|
77
|
+
: serializedJson;
|
78
|
+
await (0, promises_1.writeFile)(path, content, { encoding: 'utf-8' });
|
62
79
|
}
|
63
80
|
/**
|
64
81
|
* Check if a directory exists
|
@@ -66,7 +83,7 @@ function writeJsonFile(path, data, options) {
|
|
66
83
|
*/
|
67
84
|
function directoryExists(path) {
|
68
85
|
try {
|
69
|
-
return (0,
|
86
|
+
return (0, node_fs_1.statSync)(path).isDirectory();
|
70
87
|
}
|
71
88
|
catch {
|
72
89
|
return false;
|
@@ -78,14 +95,14 @@ function directoryExists(path) {
|
|
78
95
|
*/
|
79
96
|
function fileExists(path) {
|
80
97
|
try {
|
81
|
-
return (0,
|
98
|
+
return (0, node_fs_1.statSync)(path).isFile();
|
82
99
|
}
|
83
100
|
catch {
|
84
101
|
return false;
|
85
102
|
}
|
86
103
|
}
|
87
104
|
function createDirectory(path) {
|
88
|
-
(0,
|
105
|
+
(0, node_fs_1.mkdirSync)(path, { recursive: true });
|
89
106
|
}
|
90
107
|
function isRelativePath(path) {
|
91
108
|
return (path === '.' ||
|
@@ -102,9 +119,9 @@ function isRelativePath(path) {
|
|
102
119
|
*/
|
103
120
|
async function extractFileFromTarball(tarballPath, file, destinationFilePath) {
|
104
121
|
return new Promise((resolve, reject) => {
|
105
|
-
(0,
|
122
|
+
(0, node_fs_1.mkdirSync)((0, path_1.dirname)(destinationFilePath), { recursive: true });
|
106
123
|
var tarExtractStream = tar.extract();
|
107
|
-
const destinationFileStream = (0,
|
124
|
+
const destinationFileStream = (0, node_fs_1.createWriteStream)(destinationFilePath);
|
108
125
|
let isFileExtracted = false;
|
109
126
|
tarExtractStream.on('entry', function (header, stream, next) {
|
110
127
|
if (header.name === file) {
|
@@ -126,9 +143,9 @@ async function extractFileFromTarball(tarballPath, file, destinationFilePath) {
|
|
126
143
|
reject();
|
127
144
|
}
|
128
145
|
});
|
129
|
-
(0,
|
146
|
+
(0, node_fs_1.createReadStream)(tarballPath).pipe((0, zlib_1.createGunzip)()).pipe(tarExtractStream);
|
130
147
|
});
|
131
148
|
}
|
132
149
|
function readFileIfExisting(path) {
|
133
|
-
return (0,
|
150
|
+
return (0, node_fs_1.existsSync)(path) ? (0, node_fs_1.readFileSync)(path, 'utf-8') : '';
|
134
151
|
}
|
package/src/utils/ignore.js
CHANGED
@@ -4,7 +4,7 @@ exports.ALWAYS_IGNORE = void 0;
|
|
4
4
|
exports.getIgnoredGlobs = getIgnoredGlobs;
|
5
5
|
exports.getAlwaysIgnore = getAlwaysIgnore;
|
6
6
|
exports.getIgnoreObject = getIgnoreObject;
|
7
|
-
const
|
7
|
+
const node_fs_1 = require("node:fs");
|
8
8
|
const ignore_1 = require("ignore");
|
9
9
|
const fileutils_1 = require("./fileutils");
|
10
10
|
const path_1 = require("./path");
|
@@ -48,7 +48,7 @@ function getIgnoreObject(root = workspace_root_1.workspaceRoot) {
|
|
48
48
|
function getIgnoredGlobsFromFile(file, root) {
|
49
49
|
try {
|
50
50
|
const results = [];
|
51
|
-
const contents = (0,
|
51
|
+
const contents = (0, node_fs_1.readFileSync)(file, 'utf-8');
|
52
52
|
const lines = contents.split('\n');
|
53
53
|
for (const line of lines) {
|
54
54
|
const trimmed = line.trim();
|
@@ -15,7 +15,7 @@ exports.packageRegistryView = packageRegistryView;
|
|
15
15
|
exports.packageRegistryPack = packageRegistryPack;
|
16
16
|
const child_process_1 = require("child_process");
|
17
17
|
const fs_1 = require("fs");
|
18
|
-
const
|
18
|
+
const promises_1 = require("node:fs/promises");
|
19
19
|
const path_1 = require("path");
|
20
20
|
const semver_1 = require("semver");
|
21
21
|
const tmp_1 = require("tmp");
|
@@ -301,7 +301,7 @@ function createTempNpmDirectory() {
|
|
301
301
|
copyPackageManagerConfigurationFiles(workspace_root_1.workspaceRoot, dir);
|
302
302
|
const cleanup = async () => {
|
303
303
|
try {
|
304
|
-
await (0,
|
304
|
+
await (0, promises_1.rm)(dir, { recursive: true, force: true });
|
305
305
|
}
|
306
306
|
catch {
|
307
307
|
// It's okay if this fails, the OS will clean it up eventually
|