@nrwl/workspace 13.4.4-beta.4 → 13.4.5-beta.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. package/package.json +5 -6
  2. package/src/command-line/affected.js +4 -4
  3. package/src/command-line/affected.js.map +1 -1
  4. package/src/command-line/dep-graph.js +1 -2
  5. package/src/command-line/dep-graph.js.map +1 -1
  6. package/src/command-line/reset.d.ts +1 -1
  7. package/src/command-line/reset.js +8 -12
  8. package/src/command-line/reset.js.map +1 -1
  9. package/src/command-line/run-many.js +2 -2
  10. package/src/command-line/run-many.js.map +1 -1
  11. package/src/command-line/run-one.js +2 -2
  12. package/src/command-line/run-one.js.map +1 -1
  13. package/src/core/file-map-utils.d.ts +10 -0
  14. package/src/core/file-map-utils.js +94 -0
  15. package/src/core/file-map-utils.js.map +1 -0
  16. package/src/core/file-utils.d.ts +2 -11
  17. package/src/core/file-utils.js +19 -177
  18. package/src/core/file-utils.js.map +1 -1
  19. package/src/core/hasher/file-hasher-base.d.ts +12 -0
  20. package/src/core/hasher/file-hasher-base.js +63 -0
  21. package/src/core/hasher/file-hasher-base.js.map +1 -0
  22. package/src/core/hasher/file-hasher.d.ts +2 -24
  23. package/src/core/hasher/file-hasher.js +12 -86
  24. package/src/core/hasher/file-hasher.js.map +1 -1
  25. package/src/core/hasher/git-based-file-hasher.d.ts +10 -0
  26. package/src/core/hasher/git-based-file-hasher.js +50 -0
  27. package/src/core/hasher/git-based-file-hasher.js.map +1 -0
  28. package/src/core/hasher/git-hasher.d.ts +6 -24
  29. package/src/core/hasher/git-hasher.js +89 -147
  30. package/src/core/hasher/git-hasher.js.map +1 -1
  31. package/src/core/hasher/node-based-file-hasher.d.ts +7 -0
  32. package/src/core/hasher/node-based-file-hasher.js +78 -0
  33. package/src/core/hasher/node-based-file-hasher.js.map +1 -0
  34. package/src/core/nx-deps/nx-deps-cache.d.ts +0 -1
  35. package/src/core/nx-deps/nx-deps-cache.js +6 -8
  36. package/src/core/nx-deps/nx-deps-cache.js.map +1 -1
  37. package/src/core/project-graph/build-project-graph.js +3 -1
  38. package/src/core/project-graph/build-project-graph.js.map +1 -1
  39. package/src/core/project-graph/daemon/client/client.js +3 -0
  40. package/src/core/project-graph/daemon/client/client.js.map +1 -1
  41. package/src/core/project-graph/daemon/server/project-graph-incremental-recomputation.js +49 -44
  42. package/src/core/project-graph/daemon/server/project-graph-incremental-recomputation.js.map +1 -1
  43. package/src/core/project-graph/daemon/server/server.js +3 -1
  44. package/src/core/project-graph/daemon/server/server.js.map +1 -1
  45. package/src/core/project-graph/daemon/tmp-dir.d.ts +0 -4
  46. package/src/core/project-graph/daemon/tmp-dir.js +2 -45
  47. package/src/core/project-graph/daemon/tmp-dir.js.map +1 -1
  48. package/src/core/project-graph/project-graph.js +2 -0
  49. package/src/core/project-graph/project-graph.js.map +1 -1
  50. package/src/executors/run-commands/run-commands.impl.js +1 -1
  51. package/src/executors/run-commands/run-commands.impl.js.map +1 -1
  52. package/src/generators/convert-to-nx-project/convert-to-nx-project.js +3 -1
  53. package/src/generators/convert-to-nx-project/convert-to-nx-project.js.map +1 -1
  54. package/src/generators/convert-to-nx-project/schema.d.ts +1 -0
  55. package/src/generators/convert-to-nx-project/schema.json +5 -0
  56. package/src/generators/workspace/files/package.json__tmpl__ +1 -1
  57. package/src/tasks-runner/cache.js +2 -3
  58. package/src/tasks-runner/cache.js.map +1 -1
  59. package/src/utilities/cache-directory.d.ts +1 -2
  60. package/src/utilities/cache-directory.js +3 -3
  61. package/src/utilities/cache-directory.js.map +1 -1
  62. package/src/utilities/is_ci.js +1 -0
  63. package/src/utilities/is_ci.js.map +1 -1
  64. package/src/utilities/perf-logging.js +1 -1
  65. package/src/utilities/perf-logging.js.map +1 -1
  66. package/src/utils/perf-logging.js +1 -1
  67. package/src/utils/perf-logging.js.map +1 -1
  68. package/src/utils/versions.js +1 -1
  69. package/src/core/hasher/spawn-process.d.ts +0 -6
  70. package/src/core/hasher/spawn-process.js +0 -27
  71. package/src/core/hasher/spawn-process.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"file-utils.js","sourceRoot":"","sources":["../../../../../packages/workspace/src/core/file-utils.ts"],"names":[],"mappings":";;;AAAA,8DAIwC;AAMxC,yCAA0E;AAC1E,iDAAyC;AACzC,2BAAqE;AACrE,+BAAoD;AACpD,2CAAyC;AAEzC,2DAA2D;AAC3D,8CAAiD;AACjD,sDAAoD;AACpD,sDAAkD;AAClD,sDAAyD;AAGzD,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAUjC,MAAa,eAAe;IAA5B;QACE,SAAI,GAAG,iBAAiB,CAAC;IAC3B,CAAC;CAAA;AAFD,0CAEC;AAED,SAAgB,iBAAiB,CAAC,MAAc;IAC9C,OAAO,MAAM,CAAC,IAAI,KAAK,iBAAiB,CAAC;AAC3C,CAAC;AAFD,8CAEC;AAED,SAAgB,oBAAoB,CAClC,KAAe,EACf,MAAe,EACf,qBAGc,yBAAyB,EACvC,MAAM,GAAG,eAAe,EAAE;IAE1B,IAAI,MAAM,EAAE;QACV,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;KACjD;IAED,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QACrB,MAAM,GAAG,GAAG,IAAA,cAAO,EAAC,CAAC,CAAC,CAAC;QACvB,MAAM,IAAI,GAAG,+BAAiB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QAE3C,OAAO;YACL,IAAI,EAAE,CAAC;YACP,GAAG;YACH,IAAI;YACJ,UAAU,EAAE,GAAa,EAAE;gBACzB,IAAI,CAAC,MAAM,EAAE;oBACX,OAAO,CAAC,IAAI,eAAe,EAAE,CAAC,CAAC;iBAChC;gBAED,IAAI,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE;oBAC5C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K,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACvD,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;YACrB,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC;SAChB;QACD,oDAAoD;QACpD,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;KAChC;SAAM;QACL,OAAO,EAAE,CAAC;KACX;AACH,CAAC;AAXD,sDAWC"}
@@ -0,0 +1,12 @@
1
+ import { FileData } from '@nrwl/tao/src/shared/project-graph';
2
+ export declare abstract class FileHasherBase {
3
+ protected fileHashes: Map<string, string>;
4
+ protected isInitialized: boolean;
5
+ clear(): void;
6
+ abstract init(): Promise<void>;
7
+ abstract hashFiles(files: string[]): Promise<Map<string, string>>;
8
+ ensureInitialized(): Promise<void>;
9
+ allFileData(): FileData[];
10
+ incrementalUpdate(updatedFiles: Map<string, string>, deletedFiles?: string[]): void;
11
+ hashFile(path: string): string;
12
+ }
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FileHasherBase = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const app_root_1 = require("@nrwl/tao/src/utils/app-root");
6
+ const perf_hooks_1 = require("perf_hooks");
7
+ const hashing_impl_1 = require("./hashing-impl");
8
+ class FileHasherBase {
9
+ constructor() {
10
+ this.isInitialized = false;
11
+ }
12
+ clear() {
13
+ this.fileHashes = new Map();
14
+ this.isInitialized = false;
15
+ }
16
+ ensureInitialized() {
17
+ return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
18
+ if (!this.isInitialized) {
19
+ yield this.init();
20
+ }
21
+ });
22
+ }
23
+ allFileData() {
24
+ const res = [];
25
+ this.fileHashes.forEach((hash, file) => {
26
+ res.push({
27
+ file,
28
+ hash,
29
+ });
30
+ });
31
+ res.sort((x, y) => x.file.localeCompare(y.file));
32
+ return res;
33
+ }
34
+ incrementalUpdate(updatedFiles, deletedFiles = []) {
35
+ perf_hooks_1.performance.mark('incremental hashing:start');
36
+ updatedFiles.forEach((hash, filename) => {
37
+ this.fileHashes.set(filename, hash);
38
+ });
39
+ for (const deletedFile of deletedFiles) {
40
+ this.fileHashes.delete(deletedFile);
41
+ }
42
+ perf_hooks_1.performance.mark('incremental hashing:end');
43
+ perf_hooks_1.performance.measure('incremental hashing', 'incremental hashing:start', 'incremental hashing:end');
44
+ }
45
+ hashFile(path) {
46
+ const relativePath = path.startsWith(app_root_1.appRootPath)
47
+ ? path.substr(app_root_1.appRootPath.length + 1)
48
+ : path;
49
+ if (this.fileHashes[relativePath]) {
50
+ return this.fileHashes[relativePath];
51
+ }
52
+ else {
53
+ try {
54
+ return hashing_impl_1.defaultHashing.hashFile(path);
55
+ }
56
+ catch (_a) {
57
+ return '';
58
+ }
59
+ }
60
+ }
61
+ }
62
+ exports.FileHasherBase = FileHasherBase;
63
+ //# sourceMappingURL=file-hasher-base.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-hasher-base.js","sourceRoot":"","sources":["../../../../../../packages/workspace/src/core/hasher/file-hasher-base.ts"],"names":[],"mappings":";;;;AAAA,2DAA2D;AAC3D,2CAAyC;AAEzC,iDAAgD;AAIhD,MAAsB,cAAc;IAApC;QAEY,kBAAa,GAAG,KAAK,CAAC;IAiElC,CAAC;IA/DC,KAAK;QACH,IAAI,CAAC,UAAU,GAAG,IAAI,GAAG,EAAkB,CAAC;QAC5C,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC;IAC7B,CAAC;IAMK,iBAAiB;;YACrB,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE;gBACvB,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;aACnB;QACH,CAAC;KAAA;IAED,WAAW;QACT,MAAM,GAAG,GAAG,EAAE,CAAC;QACf,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CA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OAAO,EAAE,CAAC;aACX;SACF;IACH,CAAC;CACF;AAnED,wCAmEC"}
@@ -1,24 +1,2 @@
1
- import { HashingImpl } from './hashing-impl';
2
- export declare class FileHasher {
3
- private readonly hashing;
4
- fileHashes: {
5
- [path: string]: string;
6
- };
7
- workspaceFiles: Set<string>;
8
- usesGitForHashing: boolean;
9
- private isInitialized;
10
- constructor(hashing: HashingImpl);
11
- clear(): void;
12
- /**
13
- * For the project graph daemon server use-case we can potentially skip expensive work
14
- * by leveraging knowledge of the uncommitted and untracked files, so the init() method
15
- * returns a Map containing this data.
16
- */
17
- init(): Map<string, string>;
18
- incrementalUpdate(updatedFiles: Map<string, string>, deletedFiles?: string[]): void;
19
- hashFile(path: string): string;
20
- ensureInitialized(): void;
21
- private applyFileHashes;
22
- private processPath;
23
- }
24
- export declare const defaultFileHasher: FileHasher;
1
+ import { FileHasherBase } from './file-hasher-base';
2
+ export declare const defaultFileHasher: FileHasherBase;
@@ -1,93 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.defaultFileHasher = exports.FileHasher = void 0;
3
+ exports.defaultFileHasher = void 0;
4
+ const git_based_file_hasher_1 = require("./git-based-file-hasher");
5
+ const devkit_1 = require("@nrwl/devkit");
4
6
  const app_root_1 = require("@nrwl/tao/src/utils/app-root");
5
- const perf_hooks_1 = require("perf_hooks");
6
- const git_hasher_1 = require("./git-hasher");
7
- const hashing_impl_1 = require("./hashing-impl");
8
- class FileHasher {
9
- constructor(hashing) {
10
- this.hashing = hashing;
11
- this.fileHashes = {};
12
- this.workspaceFiles = new Set();
13
- this.usesGitForHashing = false;
14
- this.isInitialized = false;
7
+ const node_based_file_hasher_1 = require("./node-based-file-hasher");
8
+ const fs_1 = require("fs");
9
+ function createFileHasher() {
10
+ try {
11
+ (0, fs_1.statSync)((0, devkit_1.joinPathFragments)(app_root_1.appRootPath, '.git')).isDirectory();
12
+ return new git_based_file_hasher_1.GitBasedFileHasher();
15
13
  }
16
- clear() {
17
- this.fileHashes = {};
18
- this.workspaceFiles = new Set();
19
- this.usesGitForHashing = false;
20
- this.isInitialized = false;
21
- }
22
- /**
23
- * For the project graph daemon server use-case we can potentially skip expensive work
24
- * by leveraging knowledge of the uncommitted and untracked files, so the init() method
25
- * returns a Map containing this data.
26
- */
27
- init() {
28
- perf_hooks_1.performance.mark('init hashing:start');
29
- this.clear();
30
- const getFileHashesResult = (0, git_hasher_1.getFileHashes)(app_root_1.appRootPath);
31
- this.applyFileHashes(getFileHashesResult.allFiles);
32
- this.usesGitForHashing = Object.keys(this.fileHashes).length > 0;
33
- this.isInitialized = true;
34
- perf_hooks_1.performance.mark('init hashing:end');
35
- perf_hooks_1.performance.measure('init hashing', 'init hashing:start', 'init hashing:end');
36
- return getFileHashesResult.untrackedUncommittedFiles;
37
- }
38
- incrementalUpdate(updatedFiles, deletedFiles = []) {
39
- this.ensureInitialized();
40
- perf_hooks_1.performance.mark('incremental hashing:start');
41
- updatedFiles.forEach((hash, filename) => {
42
- this.fileHashes[filename] = hash;
43
- /**
44
- * we have to store it separately because fileHashes can be modified
45
- * later on and can contain files that do not exist in the workspace
46
- */
47
- this.workspaceFiles.add(filename);
48
- });
49
- for (const deletedFile of deletedFiles) {
50
- delete this.fileHashes[deletedFile];
51
- this.workspaceFiles.delete(deletedFile);
52
- }
53
- perf_hooks_1.performance.mark('incremental hashing:end');
54
- perf_hooks_1.performance.measure('incremental hashing', 'incremental hashing:start', 'incremental hashing:end');
55
- }
56
- hashFile(path) {
57
- this.ensureInitialized();
58
- const relativePath = path.startsWith(app_root_1.appRootPath)
59
- ? path.substr(app_root_1.appRootPath.length + 1)
60
- : path;
61
- if (!this.fileHashes[relativePath]) {
62
- this.fileHashes[relativePath] = this.processPath(path);
63
- }
64
- return this.fileHashes[relativePath];
65
- }
66
- ensureInitialized() {
67
- if (!this.isInitialized) {
68
- this.init();
69
- }
70
- }
71
- applyFileHashes(allFiles) {
72
- const sliceIndex = app_root_1.appRootPath.length + 1;
73
- allFiles.forEach((hash, filename) => {
74
- this.fileHashes[filename.substr(sliceIndex)] = hash;
75
- /**
76
- * we have to store it separately because fileHashes can be modified
77
- * later on and can contain files that do not exist in the workspace
78
- */
79
- this.workspaceFiles.add(filename.substr(sliceIndex));
80
- });
81
- }
82
- processPath(path) {
83
- try {
84
- return this.hashing.hashFile(path);
85
- }
86
- catch (_a) {
87
- return '';
88
- }
14
+ catch (err) {
15
+ return new node_based_file_hasher_1.NodeBasedFileHasher();
89
16
  }
90
17
  }
91
- exports.FileHasher = FileHasher;
92
- exports.defaultFileHasher = new FileHasher(hashing_impl_1.defaultHashing);
18
+ exports.defaultFileHasher = createFileHasher();
93
19
  //# sourceMappingURL=file-hasher.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"file-hasher.js","sourceRoot":"","sources":["../../../../../../packages/workspace/src/core/hasher/file-hasher.ts"],"names":[],"mappings":";;;AAAA,2DAA2D;AAC3D,2CAAyC;AACzC,6CAGsB;AACtB,iDAA6D;AAE7D,MAAa,UAAU;IAMrB,YAA6B,OAAoB;QAApB,YAAO,GAAP,OAAO,CAAa;QALjD,eAAU,GAA+B,EAAE,CAAC;QAC5C,mBAAc,GAAG,IAAI,GAAG,EAAU,CAAC;QACnC,sBAAiB,GAAG,KAAK,CAAC;QAClB,kBAAa,GAAG,KAAK,CAAC;IAEsB,CAAC;IAErD,KAAK;QACH,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;QACrB,IAAI,CAAC,cAAc,GAAG,IAAI,GAAG,EAAU,CAAC;QACxC,IAAI,CAAC,iBAAiB,GAAG,KAAK,CAAC;QAC/B,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC;IAC7B,CAAC;IAED;;;;OAIG;IACH,IAAI;QACF,wBAAW,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;QACvC,IAAI,CAAC,KAAK,EAAE,CAAC;QAEb,MAAM,mBAAmB,GAAG,IAAA,0BAAa,EAAC,sBAAW,CAAC,CAAC;Q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M,CAAC,sBAAW,CAAC,MAAM,GAAG,CAAC,CAAC;YACrC,CAAC,CAAC,IAAI,CAAC;QACT,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE;YAClC,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;SACxD;QACD,OAAO,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;IACvC,CAAC;IAED,iBAAiB;QACf,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE;YACvB,IAAI,CAAC,IAAI,EAAE,CAAC;SACb;IACH,CAAC;IAEO,eAAe,CAAC,QAA6B;QACnD,MAAM,UAAU,GAAG,sBAAW,CAAC,MAAM,GAAG,CAAC,CAAC;QAC1C,QAAQ,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE;YAClC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,GAAG,IAAI,CAAC;YACpD;;;eAGG;YACH,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;QACvD,CAAC,CAAC,CAAC;IACL,CAAC;IAEO,WAAW,CAAC,IAAY;QAC9B,IAAI;YACF,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;SACpC;QAAC,WAAM;YACN,OAAO,EAAE,CAAC;SACX;IACH,CAAC;CACF;AAzGD,gCAyGC;AAEY,QAAA,iBAAiB,GAAG,IAAI,UAAU,CAAC,6BAAc,CAAC,CAAC"}
1
+ {"version":3,"file":"file-hasher.js","sourceRoot":"","sources":["../../../../../../packages/workspace/src/core/hasher/file-hasher.ts"],"names":[],"mappings":";;;AAAA,mEAA6D;AAC7D,yCAAiD;AACjD,2DAA2D;AAC3D,qEAA+D;AAE/D,2BAA8B;AAE9B,SAAS,gBAAgB;IACvB,IAAI;QACF,IAAA,aAAQ,EAAC,IAAA,0BAAiB,EAAC,sBAAW,EAAE,MAAM,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;QAC/D,OAAO,IAAI,0CAAkB,EAAE,CAAC;KACjC;IAAC,OAAO,GAAG,EAAE;QACZ,OAAO,IAAI,4CAAmB,EAAE,CAAC;KAClC;AACH,CAAC;AAEY,QAAA,iBAAiB,GAAG,gBAAgB,EAAE,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { FileHasherBase } from './file-hasher-base';
2
+ export declare class GitBasedFileHasher extends FileHasherBase {
3
+ /**
4
+ * For the project graph daemon server use-case we can potentially skip expensive work
5
+ * by leveraging knowledge of the uncommitted and untracked files, so the init() method
6
+ * returns a Map containing this data.
7
+ */
8
+ init(): Promise<void>;
9
+ hashFiles(files: string[]): Promise<Map<string, string>>;
10
+ }
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GitBasedFileHasher = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const app_root_1 = require("@nrwl/tao/src/utils/app-root");
6
+ const perf_hooks_1 = require("perf_hooks");
7
+ const git_hasher_1 = require("./git-hasher");
8
+ const fs_1 = require("fs");
9
+ const file_hasher_base_1 = require("./file-hasher-base");
10
+ const ignore = require('ignore');
11
+ class GitBasedFileHasher extends file_hasher_base_1.FileHasherBase {
12
+ /**
13
+ * For the project graph daemon server use-case we can potentially skip expensive work
14
+ * by leveraging knowledge of the uncommitted and untracked files, so the init() method
15
+ * returns a Map containing this data.
16
+ */
17
+ init() {
18
+ return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
19
+ perf_hooks_1.performance.mark('init hashing:start');
20
+ this.clear();
21
+ const gitResult = yield (0, git_hasher_1.getFileHashes)(app_root_1.appRootPath);
22
+ const ignore = getIgnoredGlobs();
23
+ gitResult.allFiles.forEach((hash, filename) => {
24
+ if (!ignore.ignores(filename)) {
25
+ this.fileHashes.set(filename, hash);
26
+ }
27
+ });
28
+ this.isInitialized = true;
29
+ perf_hooks_1.performance.mark('init hashing:end');
30
+ perf_hooks_1.performance.measure('init hashing', 'init hashing:start', 'init hashing:end');
31
+ });
32
+ }
33
+ hashFiles(files) {
34
+ return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
35
+ return (yield (0, git_hasher_1.getGitHashForFiles)(files, app_root_1.appRootPath)).hashes;
36
+ });
37
+ }
38
+ }
39
+ exports.GitBasedFileHasher = GitBasedFileHasher;
40
+ function getIgnoredGlobs() {
41
+ if ((0, fs_1.existsSync)(`${app_root_1.appRootPath}/.nxignore`)) {
42
+ const ig = ignore();
43
+ ig.add((0, fs_1.readFileSync)(`${app_root_1.appRootPath}/.nxignore`, 'utf-8'));
44
+ return ig;
45
+ }
46
+ else {
47
+ return { ignores: (file) => false };
48
+ }
49
+ }
50
+ //# sourceMappingURL=git-based-file-hasher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git-based-file-hasher.js","sourceRoot":"","sources":["../../../../../../packages/workspace/src/core/hasher/git-based-file-hasher.ts"],"names":[],"mappings":";;;;AAAA,2DAA2D;AAC3D,2CAAyC;AACzC,6CAAiE;AACjE,2BAA8C;AAC9C,yDAAoD;AAEpD,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAEjC,MAAa,kBAAmB,SAAQ,iCAAc;IACpD;;;;OAIG;IACG,IAAI;;YACR,wBAAW,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;YACvC,IAAI,CAAC,KAAK,EAAE,CAAC;YAEb,MAAM,SAAS,GAAG,MAAM,IAAA,0BAAa,EAAC,sBAAW,CAAC,CAAC;YACnD,MAAM,MAAM,GAAG,eAAe,EAAE,CAAC;YACjC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE;gBAC5C,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;oBAC7B,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;iBACrC;YACH,CAAC,CAAC,CAAC;YACH,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;YAC1B,wBAAW,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;YACrC,wBAAW,CAAC,OAAO,CACjB,cAAc,EACd,oBAAoB,EACpB,kBAAkB,CACnB,CAAC;QACJ,CAAC;KAAA;IAEK,SAAS,CAAC,KAAe;;YAC7B,OAAO,CAAC,MAAM,IAAA,+BAAkB,EAAC,KAAK,EAAE,sBAAW,CAAC,CAAC,CAAC,MAAM,CAAC;QAC/D,CAAC;KAAA;CACF;AA7BD,gDA6BC;AAED,SAAS,eAAe;IACtB,IAAI,IAAA,eAAU,EAAC,GAAG,sBAAW,YAAY,CAAC,EAAE;QAC1C,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;QACpB,EAAE,CAAC,GAAG,CAAC,IAAA,iBAAY,EAAC,GAAG,sBAAW,YAAY,EAAE,OAAO,CAAC,CAAC,CAAC;QAC1D,OAAO,EAAE,CAAC;KACX;SAAM;QACL,OAAO,EAAE,OAAO,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC;KAC7C;AACH,CAAC"}
@@ -1,25 +1,7 @@
1
- export declare function getGitHashForFiles(filesToHash: string[], path: string): Map<string, string>;
2
- export declare function gitRevParseHead(path: string): string;
3
- /**
4
- * getFileHashes() figures out both committed changes to the git tree as well as untracked
5
- * and uncommitted file changes.
6
- *
7
- * For some utilities the origin of a file hash (i.e. was it committed or not) is unimportant,
8
- * but for other tooling like the project graph daemon server it can leverage this distinction
9
- * when figuring out what expensive work to skip during project graph construction.
10
- *
11
- * We therefore return both a Map of all filenames to their hashes, as well as a Map of just
12
- * the uncommitted/untracked filenames to hashes.
13
- */
14
- export declare function getFileHashes(path: string): {
1
+ export declare function getGitHashForFiles(potentialFilesToHash: string[], path: string): Promise<{
2
+ hashes: Map<string, string>;
3
+ deleted: string[];
4
+ }>;
5
+ export declare function getFileHashes(path: string): Promise<{
15
6
  allFiles: Map<string, string>;
16
- untrackedUncommittedFiles: Map<string, string>;
17
- };
18
- /**
19
- * This utility is used to return a Map of filenames to hashes, where those filenames come from
20
- * git's knowledge of:
21
- *
22
- * - files which are untracked (newly created)
23
- * - files which are modified in some way (but NOT deleted) and either staged or unstaged
24
- */
25
- export declare function getUntrackedAndUncommittedFileHashes(path: string): Map<string, string>;
7
+ }>;
@@ -1,168 +1,110 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getUntrackedAndUncommittedFileHashes = exports.getFileHashes = exports.gitRevParseHead = exports.getGitHashForFiles = void 0;
4
- const fs_1 = require("fs");
5
- const path_1 = require("path");
6
- const spawn_process_1 = require("./spawn-process");
7
- function parseGitLsTree(output) {
8
- const changes = new Map();
9
- if (output) {
10
- const gitRegex = /([0-9]{6})\s(blob|commit)\s([a-f0-9]{40})\s*(.*)/;
11
- output.split('\0').forEach((line) => {
12
- if (line) {
13
- const matches = line.match(gitRegex);
14
- if (matches && matches[3] && matches[4]) {
15
- const hash = matches[3];
16
- const filename = matches[4];
17
- changes.set(filename, hash);
18
- }
19
- else {
20
- throw new Error(`Cannot parse git ls-tree input: "${line}"`);
21
- }
3
+ exports.getFileHashes = exports.getGitHashForFiles = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const child_process_1 = require("child_process");
6
+ const fileutils_1 = require("../../utilities/fileutils");
7
+ const devkit_1 = require("@nrwl/devkit");
8
+ function getGitHashForFiles(potentialFilesToHash, path) {
9
+ return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
10
+ const filesToHash = [];
11
+ const deleted = [];
12
+ for (let f of potentialFilesToHash) {
13
+ if ((0, fileutils_1.fileExists)((0, devkit_1.joinPathFragments)(path, f))) {
14
+ filesToHash.push(f);
22
15
  }
23
- });
24
- }
25
- return changes;
26
- }
27
- function parseGitStatus(path) {
28
- const output = (0, spawn_process_1.spawnProcess)('git', ['status', '-s', '-u', '-z', '.'], path);
29
- const changes = new Map();
30
- if (!output) {
31
- return changes;
32
- }
33
- // Because `-z` doesn't respect the relative paths configuration,
34
- // we need to manually strip the root path from the filenames.
35
- const prefix = (0, spawn_process_1.spawnProcess)('git', ['rev-parse', '--show-prefix'], path);
36
- const chunks = output.split('\0');
37
- for (let i = 0; i < chunks.length; i++) {
38
- const chunk = chunks[i];
39
- if (chunk.length) {
40
- // The XY is the two-letter status code.
41
- // See: https://git-scm.com/docs/git-status#_short_format
42
- const X = chunk[0].trim();
43
- const Y = chunk[1].trim();
44
- const filename = chunk.substring(3).replace(new RegExp(`^${prefix}`), '');
45
- if (X === 'R') {
46
- changes.set(chunks[++i], 'D');
16
+ else {
17
+ deleted.push(f);
47
18
  }
48
- // If both present, Y shows the status of the working tree
49
- changes.set(filename, Y || X);
50
- }
51
- }
52
- return changes;
53
- }
54
- function getGitHashForFiles(filesToHash, path) {
55
- const changes = new Map();
56
- if (filesToHash.length) {
57
- const hashStdout = (0, spawn_process_1.spawnProcess)('git', ['hash-object', ...filesToHash], path);
58
- const hashes = hashStdout.split('\n');
59
- if (hashes.length !== filesToHash.length) {
60
- throw new Error(`Passed ${filesToHash.length} file paths to Git to hash, but received ${hashes.length} hashes.`);
61
19
  }
62
- for (let i = 0; i < hashes.length; i++) {
63
- const hash = hashes[i];
64
- const filePath = filesToHash[i];
65
- changes.set(filePath, hash);
20
+ const res = new Map();
21
+ if (filesToHash.length) {
22
+ const hashStdout = yield spawnProcess('git', ['hash-object', ...filesToHash], path);
23
+ const hashes = hashStdout.split('\n').filter((s) => !!s);
24
+ if (hashes.length !== filesToHash.length) {
25
+ throw new Error(`Passed ${filesToHash.length} file paths to Git to hash, but received ${hashes.length} hashes.`);
26
+ }
27
+ for (let i = 0; i < hashes.length; i++) {
28
+ const hash = hashes[i];
29
+ const filePath = filesToHash[i];
30
+ res.set(filePath, hash);
31
+ }
66
32
  }
67
- }
68
- return changes;
33
+ return { hashes: res, deleted };
34
+ });
69
35
  }
70
36
  exports.getGitHashForFiles = getGitHashForFiles;
71
- function gitLsTree(path) {
72
- return parseGitLsTree((0, spawn_process_1.spawnProcess)('git', ['ls-tree', 'HEAD', '-r', '-z'], path));
73
- }
74
- function gitRevParseHead(path) {
75
- return (0, spawn_process_1.spawnProcess)('git', ['rev-parse', 'HEAD'], path);
76
- }
77
- exports.gitRevParseHead = gitRevParseHead;
78
- function gitStatus(path) {
79
- const deletedFiles = [];
80
- const filesToHash = [];
81
- parseGitStatus(path).forEach((changeType, filename) => {
82
- if (changeType !== 'D') {
83
- filesToHash.push(filename);
37
+ function spawnProcess(command, args, cwd) {
38
+ var e_1, _a;
39
+ return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
40
+ const cp = (0, child_process_1.spawn)(command, args, {
41
+ windowsHide: true,
42
+ shell: false,
43
+ cwd,
44
+ });
45
+ let s = '';
46
+ try {
47
+ for (var _b = (0, tslib_1.__asyncValues)(cp.stdout), _c; _c = yield _b.next(), !_c.done;) {
48
+ const data = _c.value;
49
+ s += data;
50
+ }
84
51
  }
85
- else {
86
- deletedFiles.push(filename);
52
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
53
+ finally {
54
+ try {
55
+ if (_c && !_c.done && (_a = _b.return)) yield _a.call(_b);
56
+ }
57
+ finally { if (e_1) throw e_1.error; }
87
58
  }
59
+ return s;
88
60
  });
89
- const updated = checkForDeletedFiles(path, filesToHash, deletedFiles);
90
- const status = getGitHashForFiles(updated.filesToHash, path);
91
- return { deletedFiles: updated.deletedFiles, status };
92
61
  }
93
- /**
94
- * This is only needed because of potential issues with interpreting "git status".
95
- * We had a few issues where we didn't interpret renames correctly. Even though
96
- * doing this somewhat slow, we will keep it for now.
97
- *
98
- * @vsavkin remove it in nx 10.2
99
- */
100
- function checkForDeletedFiles(path, files, deletedFiles) {
101
- let filesToHash = [];
102
- files.forEach((f) => {
103
- try {
104
- (0, fs_1.statSync)((0, path_1.join)(path, f)).isFile();
105
- filesToHash.push(f);
106
- }
107
- catch (_a) {
108
- throw new Error(`Error: Fell back to using 'fs' to identify ${f} as deleted. Please open an issue at https://github.com/nrwl/nx so we can investigate.`);
62
+ function getStagedFiles(path) {
63
+ return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
64
+ const staged = yield spawnProcess('git', ['ls-files', '-s', '-z', '--exclude-standard', '.'], path);
65
+ const res = new Map();
66
+ for (let line of staged.split('\0')) {
67
+ if (!line)
68
+ continue;
69
+ const [_, hash, __, ...fileParts] = line.split(/\s/);
70
+ const fileName = fileParts.join(' ');
71
+ res.set(fileName, hash);
109
72
  }
73
+ return res;
74
+ });
75
+ }
76
+ function getUnstagedFiles(path) {
77
+ return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
78
+ const unstaged = yield spawnProcess('git', ['ls-files', '-m', '-z', '--exclude-standard', '.'], path);
79
+ const lines = unstaged.split('\0').filter((f) => !!f);
80
+ return getGitHashForFiles(lines, path);
81
+ });
82
+ }
83
+ function getUntrackedFiles(path) {
84
+ return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
85
+ const untracked = yield spawnProcess('git', ['ls-files', '--other', '-z', '--exclude-standard', '.'], path);
86
+ const lines = untracked.split('\0').filter((f) => !!f);
87
+ return getGitHashForFiles(lines, path);
110
88
  });
111
- return { filesToHash, deletedFiles };
112
89
  }
113
- /**
114
- * getFileHashes() figures out both committed changes to the git tree as well as untracked
115
- * and uncommitted file changes.
116
- *
117
- * For some utilities the origin of a file hash (i.e. was it committed or not) is unimportant,
118
- * but for other tooling like the project graph daemon server it can leverage this distinction
119
- * when figuring out what expensive work to skip during project graph construction.
120
- *
121
- * We therefore return both a Map of all filenames to their hashes, as well as a Map of just
122
- * the uncommitted/untracked filenames to hashes.
123
- */
124
90
  function getFileHashes(path) {
125
- const allFiles = new Map();
126
- try {
127
- const { deletedFiles, status } = gitStatus(path);
128
- const m1 = gitLsTree(path);
129
- m1.forEach((hash, filename) => {
130
- if (deletedFiles.indexOf(filename) === -1) {
131
- allFiles.set(`${path}/${filename}`, hash);
132
- }
91
+ return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
92
+ const [staged, unstaged, untracked] = yield Promise.all([
93
+ getStagedFiles(path),
94
+ getUnstagedFiles(path),
95
+ getUntrackedFiles(path),
96
+ ]);
97
+ unstaged.hashes.forEach((hash, filename) => {
98
+ staged.set(filename, hash);
133
99
  });
134
- status.forEach((hash, filename) => {
135
- allFiles.set(`${path}/${filename}`, hash);
100
+ unstaged.deleted.forEach((filename) => {
101
+ staged.delete(filename);
136
102
  });
137
- return {
138
- allFiles,
139
- untrackedUncommittedFiles: status,
140
- };
141
- }
142
- catch (e) {
143
- // this strategy is only used for speeding things up.
144
- // ignoring all the errors
145
- if (process.env.NX_GIT_HASHER_LOGGING) {
146
- console.error(`Internal error:`);
147
- console.error(e);
148
- }
149
- return {
150
- allFiles: new Map(),
151
- untrackedUncommittedFiles: new Map(),
152
- };
153
- }
103
+ untracked.hashes.forEach((hash, filename) => {
104
+ staged.set(filename, hash);
105
+ });
106
+ return { allFiles: staged };
107
+ });
154
108
  }
155
109
  exports.getFileHashes = getFileHashes;
156
- /**
157
- * This utility is used to return a Map of filenames to hashes, where those filenames come from
158
- * git's knowledge of:
159
- *
160
- * - files which are untracked (newly created)
161
- * - files which are modified in some way (but NOT deleted) and either staged or unstaged
162
- */
163
- function getUntrackedAndUncommittedFileHashes(path) {
164
- const { status } = gitStatus(path);
165
- return status;
166
- }
167
- exports.getUntrackedAndUncommittedFileHashes = getUntrackedAndUncommittedFileHashes;
168
110
  //# sourceMappingURL=git-hasher.js.map