nx 19.7.0-beta.3 → 19.7.0-beta.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. package/package.json +12 -12
  2. package/release/changelog-renderer/index.d.ts +1 -1
  3. package/release/changelog-renderer/index.js +46 -11
  4. package/schemas/nx-schema.json +5 -0
  5. package/src/command-line/add/command-object.js +2 -2
  6. package/src/command-line/affected/command-object.js +1 -1
  7. package/src/command-line/connect/command-object.js +11 -4
  8. package/src/command-line/connect/connect-to-nx-cloud.d.ts +3 -1
  9. package/src/command-line/connect/connect-to-nx-cloud.js +7 -4
  10. package/src/command-line/daemon/command-object.js +1 -1
  11. package/src/command-line/deprecated/command-objects.js +2 -2
  12. package/src/command-line/exec/command-object.js +1 -1
  13. package/src/command-line/format/command-object.js +4 -4
  14. package/src/command-line/generate/command-object.js +4 -4
  15. package/src/command-line/graph/command-object.js +6 -6
  16. package/src/command-line/import/command-object.js +9 -5
  17. package/src/command-line/import/import.d.ts +4 -0
  18. package/src/command-line/import/import.js +147 -12
  19. package/src/command-line/import/utils/prepare-source-repo.d.ts +1 -1
  20. package/src/command-line/import/utils/prepare-source-repo.js +31 -85
  21. package/src/command-line/list/command-object.js +1 -1
  22. package/src/command-line/login/command-object.js +1 -1
  23. package/src/command-line/logout/command-object.js +1 -1
  24. package/src/command-line/migrate/command-object.js +9 -9
  25. package/src/command-line/new/command-object.js +2 -2
  26. package/src/command-line/release/changelog.js +53 -12
  27. package/src/command-line/release/command-object.d.ts +2 -0
  28. package/src/command-line/release/command-object.js +37 -33
  29. package/src/command-line/release/config/version-plans.d.ts +14 -1
  30. package/src/command-line/release/config/version-plans.js +33 -1
  31. package/src/command-line/release/plan-check.js +8 -61
  32. package/src/command-line/release/plan.js +131 -37
  33. package/src/command-line/release/publish.js +3 -0
  34. package/src/command-line/release/release.js +1 -1
  35. package/src/command-line/release/utils/get-touched-projects-for-group.d.ts +7 -0
  36. package/src/command-line/release/utils/get-touched-projects-for-group.js +78 -0
  37. package/src/command-line/release/utils/git.d.ts +1 -1
  38. package/src/command-line/release/utils/git.js +46 -19
  39. package/src/command-line/release/version.js +1 -1
  40. package/src/command-line/report/command-object.js +1 -1
  41. package/src/command-line/reset/command-object.js +1 -1
  42. package/src/command-line/run/command-object.js +1 -1
  43. package/src/command-line/run-many/command-object.js +1 -1
  44. package/src/command-line/show/command-object.js +10 -10
  45. package/src/command-line/watch/command-object.js +1 -1
  46. package/src/command-line/yargs-utils/shared-options.d.ts +2 -1
  47. package/src/command-line/yargs-utils/shared-options.js +26 -29
  48. package/src/core/graph/main.js +1 -1
  49. package/src/daemon/server/sync-generators.d.ts +4 -0
  50. package/src/daemon/server/sync-generators.js +172 -52
  51. package/src/native/nx.wasm32-wasi.wasm +0 -0
  52. package/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.d.ts +2 -1
  53. package/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +17 -50
  54. package/src/nx-cloud/generators/connect-to-nx-cloud/schema.json +4 -0
  55. package/src/plugins/js/project-graph/build-dependencies/target-project-locator.js +8 -1
  56. package/src/project-graph/plugins/isolation/plugin-pool.js +1 -1
  57. package/src/tasks-runner/cache.d.ts +2 -0
  58. package/src/tasks-runner/cache.js +15 -1
  59. package/src/tasks-runner/run-command.js +4 -1
  60. package/src/tasks-runner/task-orchestrator.js +1 -10
  61. package/src/utils/command-line-utils.d.ts +1 -0
  62. package/src/utils/git-utils.d.ts +7 -10
  63. package/src/utils/git-utils.js +61 -44
  64. package/src/utils/sync-generators.d.ts +2 -2
  65. package/src/utils/squash.d.ts +0 -1
  66. package/src/utils/squash.js +0 -12
@@ -2,16 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GitRepository = void 0;
4
4
  exports.cloneFromUpstream = cloneFromUpstream;
5
- exports.updateRebaseFile = updateRebaseFile;
6
- exports.fetchGitRemote = fetchGitRemote;
7
5
  exports.getGithubSlugOrNull = getGithubSlugOrNull;
8
6
  exports.extractUserAndRepoFromGitHubUrl = extractUserAndRepoFromGitHubUrl;
9
7
  exports.commitChanges = commitChanges;
10
8
  exports.getLatestCommitSha = getLatestCommitSha;
11
9
  const child_process_1 = require("child_process");
12
- const devkit_exports_1 = require("../devkit-exports");
13
10
  const path_1 = require("path");
14
- const SQUASH_EDITOR = (0, path_1.join)(__dirname, 'squash.js');
11
+ const devkit_exports_1 = require("../devkit-exports");
15
12
  function execAsync(command, execOptions) {
16
13
  return new Promise((res, rej) => {
17
14
  (0, child_process_1.exec)(command, execOptions, (err, stdout, stderr) => {
@@ -22,9 +19,12 @@ function execAsync(command, execOptions) {
22
19
  });
23
20
  });
24
21
  }
25
- async function cloneFromUpstream(url, destination, { originName } = { originName: 'origin' }) {
26
- await execAsync(`git clone ${url} ${destination} --depth 1 --origin ${originName}`, {
22
+ async function cloneFromUpstream(url, destination, { originName, depth } = {
23
+ originName: 'origin',
24
+ }) {
25
+ await execAsync(`git clone ${url} ${destination} ${depth ? `--depth ${depth}` : ''} --origin ${originName}`, {
27
26
  cwd: (0, path_1.dirname)(destination),
27
+ maxBuffer: 10 * 1024 * 1024,
28
28
  });
29
29
  return new GitRepository(destination);
30
30
  }
@@ -40,13 +40,8 @@ class GitRepository {
40
40
  .toString()
41
41
  .trim();
42
42
  }
43
- addFetchRemote(remoteName, branch) {
44
- return this.execAsync(`git config --add remote.${remoteName}.fetch "+refs/heads/${branch}:refs/remotes/${remoteName}/${branch}"`);
45
- }
46
- execAsync(command) {
47
- return execAsync(command, {
48
- cwd: this.root,
49
- });
43
+ async addFetchRemote(remoteName, branch) {
44
+ return await this.execAsync(`git config --add remote.${remoteName}.fetch "+refs/heads/${branch}:refs/remotes/${remoteName}/${branch}"`);
50
45
  }
51
46
  async showStat() {
52
47
  return await this.execAsync(`git show --stat`);
@@ -61,62 +56,84 @@ class GitRepository {
61
56
  .replace('refs/heads/', ''));
62
57
  }
63
58
  async getGitFiles(path) {
64
- return (await this.execAsync(`git ls-files ${path}`))
59
+ // Use -z to return file names exactly as they are stored in git, separated by NULL (\x00) character.
60
+ // This avoids problems with special characters in file names.
61
+ return (await this.execAsync(`git ls-files -z ${path}`))
65
62
  .trim()
66
- .split('\n')
63
+ .split('\x00')
67
64
  .map((s) => s.trim())
68
65
  .filter(Boolean);
69
66
  }
70
67
  async reset(ref) {
71
- return this.execAsync(`git reset ${ref} --hard`);
72
- }
73
- async squashLastTwoCommits() {
74
- return this.execAsync(`git -c core.editor="node ${SQUASH_EDITOR}" rebase --interactive --no-autosquash HEAD~2`);
68
+ return await this.execAsync(`git reset ${ref} --hard`);
75
69
  }
76
70
  async mergeUnrelatedHistories(ref, message) {
77
- return this.execAsync(`git merge ${ref} -X ours --allow-unrelated-histories -m "${message}"`);
71
+ return await this.execAsync(`git merge ${ref} -X ours --allow-unrelated-histories -m "${message}"`);
78
72
  }
79
73
  async fetch(remote, ref) {
80
- return this.execAsync(`git fetch ${remote}${ref ? ` ${ref}` : ''}`);
74
+ return await this.execAsync(`git fetch ${remote}${ref ? ` ${ref}` : ''}`);
81
75
  }
82
76
  async checkout(branch, opts) {
83
- return this.execAsync(`git checkout ${opts.new ? '-b ' : ' '}${branch}${opts.base ? ' ' + opts.base : ''}`);
77
+ return await this.execAsync(`git checkout ${opts.new ? '-b ' : ' '}${branch}${opts.base ? ' ' + opts.base : ''}`);
84
78
  }
85
79
  async move(path, destination) {
86
- return this.execAsync(`git mv "${path}" "${destination}"`);
80
+ return await this.execAsync(`git mv ${this.quotePath(path)} ${this.quotePath(destination)}`);
87
81
  }
88
82
  async push(ref, remoteName) {
89
- return this.execAsync(`git push -u -f ${remoteName} ${ref}`);
83
+ return await this.execAsync(`git push -u -f ${remoteName} ${ref}`);
90
84
  }
91
85
  async commit(message) {
92
- return this.execAsync(`git commit -am "${message}"`);
86
+ return await this.execAsync(`git commit -am "${message}"`);
93
87
  }
94
88
  async amendCommit() {
95
- return this.execAsync(`git commit --amend -a --no-edit`);
89
+ return await this.execAsync(`git commit --amend -a --no-edit`);
96
90
  }
97
- deleteGitRemote(name) {
98
- return this.execAsync(`git remote rm ${name}`);
91
+ async deleteGitRemote(name) {
92
+ return await this.execAsync(`git remote rm ${name}`);
99
93
  }
100
- deleteBranch(branch) {
101
- return this.execAsync(`git branch -D ${branch}`);
94
+ async addGitRemote(name, url) {
95
+ return await this.execAsync(`git remote add ${name} ${url}`);
96
+ }
97
+ async hasFilterRepoInstalled() {
98
+ try {
99
+ await this.execAsync(`git filter-repo --help`);
100
+ return true;
101
+ }
102
+ catch {
103
+ return false;
104
+ }
102
105
  }
103
- addGitRemote(name, url) {
104
- return this.execAsync(`git remote add ${name} ${url}`);
106
+ // git-filter-repo is much faster than filter-branch, but needs to be installed by user
107
+ // Use `hasFilterRepoInstalled` to check if it's installed
108
+ async filterRepo(subdirectory) {
109
+ // filter-repo requires POSIX path to work
110
+ const posixPath = subdirectory.split(path_1.sep).join(path_1.posix.sep);
111
+ return await this.execAsync(`git filter-repo -f --subdirectory-filter ${this.quotePath(posixPath)}`);
112
+ }
113
+ async filterBranch(subdirectory, branchName) {
114
+ // filter-repo requires POSIX path to work
115
+ const posixPath = subdirectory.split(path_1.sep).join(path_1.posix.sep);
116
+ // We need non-ASCII file names to not be quoted, or else filter-branch will exclude them.
117
+ await this.execAsync(`git config core.quotepath false`);
118
+ return await this.execAsync(`git filter-branch --subdirectory-filter ${this.quotePath(posixPath)} -- ${branchName}`);
119
+ }
120
+ execAsync(command) {
121
+ return execAsync(command, {
122
+ cwd: this.root,
123
+ maxBuffer: 10 * 1024 * 1024,
124
+ });
125
+ }
126
+ quotePath(path) {
127
+ return process.platform === 'win32'
128
+ ? // Windows/CMD only understands double-quotes, single-quotes are treated as part of the file name
129
+ // Bash and other shells will substitute `$` in file names with a variable value.
130
+ `"${path}"`
131
+ : // e.g. `git mv "$$file.txt" "libs/a/$$file.txt"` will not work since `$$` is swapped with the PID of the last process.
132
+ // Using single-quotes prevents this substitution.
133
+ `'${path}'`;
105
134
  }
106
135
  }
107
136
  exports.GitRepository = GitRepository;
108
- /**
109
- * This is used by the squash editor script to update the rebase file.
110
- */
111
- function updateRebaseFile(contents) {
112
- const lines = contents.split('\n');
113
- const lastCommitIndex = lines.findIndex((line) => line === '') - 1;
114
- lines[lastCommitIndex] = lines[lastCommitIndex].replace('pick', 'fixup');
115
- return lines.join('\n');
116
- }
117
- function fetchGitRemote(name, branch, execOptions) {
118
- return (0, child_process_1.execSync)(`git fetch ${name} ${branch} --depth 1`, execOptions);
119
- }
120
137
  /**
121
138
  * This is currently duplicated in Nx Console. Please let @MaxKless know if you make changes here.
122
139
  */
@@ -3,7 +3,7 @@ import { type NxJsonConfiguration } from '../config/nx-json';
3
3
  import type { ProjectGraph } from '../config/project-graph';
4
4
  import type { TaskGraph } from '../config/task-graph';
5
5
  import type { ProjectConfiguration } from '../config/workspace-json-project-json';
6
- import { FsTree, type FileChange, type Tree } from '../generators/tree';
6
+ import { type FileChange, type Tree } from '../generators/tree';
7
7
  export type SyncGeneratorResult = void | {
8
8
  callback?: GeneratorCallback;
9
9
  outOfSyncMessage?: string;
@@ -18,7 +18,7 @@ export type SyncGeneratorChangesResult = {
18
18
  export declare function getSyncGeneratorChanges(generators: string[]): Promise<SyncGeneratorChangesResult[]>;
19
19
  export declare function flushSyncGeneratorChanges(results: SyncGeneratorChangesResult[]): Promise<void>;
20
20
  export declare function collectAllRegisteredSyncGenerators(projectGraph: ProjectGraph, nxJson: NxJsonConfiguration): Promise<string[]>;
21
- export declare function runSyncGenerator(tree: FsTree, generatorSpecifier: string, projects: Record<string, ProjectConfiguration>): Promise<SyncGeneratorChangesResult>;
21
+ export declare function runSyncGenerator(tree: Tree, generatorSpecifier: string, projects: Record<string, ProjectConfiguration>): Promise<SyncGeneratorChangesResult>;
22
22
  export declare function collectEnabledTaskSyncGeneratorsFromProjectGraph(projectGraph: ProjectGraph, nxJson: NxJsonConfiguration): Set<string>;
23
23
  export declare function collectEnabledTaskSyncGeneratorsFromTaskGraph(taskGraph: TaskGraph, projectGraph: ProjectGraph, nxJson: NxJsonConfiguration): Set<string>;
24
24
  export declare function collectRegisteredGlobalSyncGenerators(nxJson?: NxJsonConfiguration<string[] | "*">): Set<string>;
@@ -1 +0,0 @@
1
- export {};
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const fs_1 = require("fs");
4
- const git_utils_1 = require("./git-utils");
5
- // This script is used as an editor for git rebase -i
6
- // This is the file which git creates. When this script exits, the updates should be written to this file.
7
- const filePath = process.argv[2];
8
- // Change the second commit from pick to fixup
9
- const contents = (0, fs_1.readFileSync)(filePath).toString();
10
- const newContents = (0, git_utils_1.updateRebaseFile)(contents);
11
- // Write the updated contents back to the file
12
- (0, fs_1.writeFileSync)(filePath, newContents);