@lage-run/hasher 1.9.2 → 1.9.4

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.
Files changed (51) hide show
  1. package/README.md +1 -1
  2. package/lib/FileHasher.js +6 -8
  3. package/lib/FileHasher.js.map +1 -1
  4. package/lib/PackageTree.d.ts +2 -2
  5. package/lib/PackageTree.js.map +1 -1
  6. package/lib/TargetHasher.d.ts +15 -22
  7. package/lib/TargetHasher.js +17 -35
  8. package/lib/TargetHasher.js.map +1 -1
  9. package/package.json +14 -11
  10. package/CHANGELOG.json +0 -735
  11. package/CHANGELOG.md +0 -323
  12. package/jest.config.js +0 -1
  13. package/lib/__fixtures__/config/backfill.config.d.ts +0 -1
  14. package/lib/__fixtures__/config/packages/package-1/backfill.config.d.ts +0 -0
  15. package/lib/__fixtures__/monorepo-nested/packages/package-a/build/another/file.d.ts +0 -1
  16. package/lib/__fixtures__/monorepo-nested/packages/package-a/build/another/file.js +0 -2
  17. package/lib/__fixtures__/monorepo-nested/packages/package-a/build/another/file.js.map +0 -1
  18. package/lib/__fixtures__/monorepo-with-global-files/some-global.config.d.ts +0 -1
  19. package/lib/__fixtures__/monorepo-with-global-files/some-global2.config.d.ts +0 -1
  20. package/lib/__fixtures__/monorepo-with-global-files-different-tasks/some-global.config.d.ts +0 -1
  21. package/lib/__tests__/PackageTree.test.d.ts +0 -1
  22. package/lib/__tests__/PackageTree.test.js +0 -76
  23. package/lib/__tests__/PackageTree.test.js.map +0 -1
  24. package/lib/__tests__/TargetHasher.test.d.ts +0 -1
  25. package/lib/__tests__/TargetHasher.test.js +0 -213
  26. package/lib/__tests__/TargetHasher.test.js.map +0 -1
  27. package/lib/__tests__/getPackageDeps.test.d.ts +0 -1
  28. package/lib/__tests__/getPackageDeps.test.js +0 -310
  29. package/lib/__tests__/getPackageDeps.test.js.map +0 -1
  30. package/lib/__tests__/resolveDependenciesHelper.d.ts +0 -3
  31. package/lib/__tests__/resolveDependenciesHelper.js +0 -66
  32. package/lib/__tests__/resolveDependenciesHelper.js.map +0 -1
  33. package/lib/__tests__/resolveExternalDependencies.test.d.ts +0 -1
  34. package/lib/__tests__/resolveExternalDependencies.test.js +0 -154
  35. package/lib/__tests__/resolveExternalDependencies.test.js.map +0 -1
  36. package/lib/__tests__/resolveInternalDependencies.test.d.ts +0 -1
  37. package/lib/__tests__/resolveInternalDependencies.test.js +0 -131
  38. package/lib/__tests__/resolveInternalDependencies.test.js.map +0 -1
  39. package/lib/getPackageDeps.d.ts +0 -45
  40. package/lib/getPackageDeps.js +0 -259
  41. package/lib/getPackageDeps.js.map +0 -1
  42. package/lib/nameAtVersion.d.ts +0 -1
  43. package/lib/nameAtVersion.js +0 -13
  44. package/lib/nameAtVersion.js.map +0 -1
  45. package/lib/resolveExternalDependencies.d.ts +0 -11
  46. package/lib/resolveExternalDependencies.js +0 -75
  47. package/lib/resolveExternalDependencies.js.map +0 -1
  48. package/lib/resolveInternalDependencies.d.ts +0 -6
  49. package/lib/resolveInternalDependencies.js +0 -26
  50. package/lib/resolveInternalDependencies.js.map +0 -1
  51. package/tsconfig.json +0 -7
@@ -1,131 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- const _workspacetools = require("workspace-tools");
6
- const _resolveInternalDependencies = require("../resolveInternalDependencies");
7
- const _resolveDependenciesHelper = require("./resolveDependenciesHelper");
8
- const _path = /*#__PURE__*/ _interop_require_default(require("path"));
9
- const _monorepofixture = require("@lage-run/monorepo-fixture");
10
- function _interop_require_default(obj) {
11
- return obj && obj.__esModule ? obj : {
12
- default: obj
13
- };
14
- }
15
- const fixturesPath = _path.default.join(__dirname, "..", "__fixtures__");
16
- describe("filterInternalDependencies() for yarn", ()=>{
17
- it("only lists internal dependencies", async ()=>{
18
- const results = await (0, _resolveDependenciesHelper.filterDependenciesInYarnFixture)("monorepo", _resolveInternalDependencies.filterInternalDependencies);
19
- expect(results).toEqual([
20
- "package-a"
21
- ]);
22
- });
23
- it("lists no internal packages if there are no workspaces", async ()=>{
24
- const results = await (0, _resolveDependenciesHelper.filterDependenciesInYarnFixture)("basic", _resolveInternalDependencies.filterInternalDependencies);
25
- expect(results).toEqual([]);
26
- });
27
- });
28
- describe("resolveInternalDependencies() for yarn", ()=>{
29
- it("adds internal dependency names to the processedPackages list", async ()=>{
30
- const monorepo = new _monorepofixture.Monorepo("monorepo");
31
- await monorepo.init(_path.default.join(fixturesPath, "monorepo"));
32
- const packageRoot = monorepo.root;
33
- const workspaces = (0, _workspacetools.getYarnWorkspaces)(packageRoot);
34
- const dependencies = {
35
- "package-a": "1.0.0",
36
- foo: "1.0.0"
37
- };
38
- const resolvedDependencies = (0, _resolveInternalDependencies.resolveInternalDependencies)(dependencies, workspaces);
39
- expect(resolvedDependencies).toEqual([
40
- "package-a"
41
- ]);
42
- await monorepo.cleanup();
43
- });
44
- });
45
- describe("filterInternalDependencies() for pnpm", ()=>{
46
- it("only lists internal dependencies", async ()=>{
47
- const results = await (0, _resolveDependenciesHelper.filterDependenciesInPnpmFixture)("monorepo-pnpm", _resolveInternalDependencies.filterInternalDependencies);
48
- expect(results).toEqual([
49
- "package-a"
50
- ]);
51
- });
52
- it("lists no internal packages if there are no workspaces", async ()=>{
53
- const results = await (0, _resolveDependenciesHelper.filterDependenciesInPnpmFixture)("basic", _resolveInternalDependencies.filterInternalDependencies);
54
- expect(results).toEqual([]);
55
- });
56
- });
57
- describe("resolveInternalDependencies() for pnpm", ()=>{
58
- it("adds internal dependency names to the processedPackages list", async ()=>{
59
- const monorepo = new _monorepofixture.Monorepo("monorepo");
60
- await monorepo.init(_path.default.join(fixturesPath, "monorepo-pnpm"));
61
- const packageRoot = monorepo.root;
62
- const workspaces = (0, _workspacetools.getPnpmWorkspaces)(packageRoot);
63
- const dependencies = {
64
- "package-a": "1.0.0",
65
- foo: "1.0.0"
66
- };
67
- const resolvedDependencies = (0, _resolveInternalDependencies.resolveInternalDependencies)(dependencies, workspaces);
68
- expect(resolvedDependencies).toEqual([
69
- "package-a"
70
- ]);
71
- await monorepo.cleanup();
72
- });
73
- });
74
- describe("filterInternalDependencies() for rush+pnpm", ()=>{
75
- it("only lists internal dependencies", async ()=>{
76
- const results = await (0, _resolveDependenciesHelper.filterDependenciesInRushFixture)("monorepo-rush-pnpm", _resolveInternalDependencies.filterInternalDependencies);
77
- expect(results).toEqual([
78
- "package-a"
79
- ]);
80
- });
81
- it("lists no internal packages if there are no workspaces", async ()=>{
82
- const results = await (0, _resolveDependenciesHelper.filterDependenciesInRushFixture)("basic", _resolveInternalDependencies.filterInternalDependencies);
83
- expect(results).toEqual([]);
84
- });
85
- });
86
- describe("resolveInternalDependencies() for rush+pnpm", ()=>{
87
- it("adds internal dependency names to the processedPackages list", async ()=>{
88
- const monorepo = new _monorepofixture.Monorepo("monorepo");
89
- await monorepo.init(_path.default.join(fixturesPath, "monorepo-rush-pnpm"));
90
- const packageRoot = monorepo.root;
91
- const workspaces = (0, _workspacetools.getRushWorkspaces)(packageRoot);
92
- const dependencies = {
93
- "package-a": "1.0.0",
94
- foo: "1.0.0"
95
- };
96
- const resolvedDependencies = (0, _resolveInternalDependencies.resolveInternalDependencies)(dependencies, workspaces);
97
- expect(resolvedDependencies).toEqual([
98
- "package-a"
99
- ]);
100
- await monorepo.cleanup();
101
- });
102
- });
103
- describe("filterInternalDependencies() for rush+yarn", ()=>{
104
- it("only lists internal dependencies", async ()=>{
105
- const results = await (0, _resolveDependenciesHelper.filterDependenciesInRushFixture)("monorepo-rush-yarn", _resolveInternalDependencies.filterInternalDependencies);
106
- expect(results).toEqual([
107
- "package-a"
108
- ]);
109
- });
110
- it("lists no internal packages if there are no workspaces", async ()=>{
111
- const results = await (0, _resolveDependenciesHelper.filterDependenciesInRushFixture)("basic", _resolveInternalDependencies.filterInternalDependencies);
112
- expect(results).toEqual([]);
113
- });
114
- });
115
- describe("resolveInternalDependencies() for rush+yarn", ()=>{
116
- it("adds internal dependency names to the processedPackages list", async ()=>{
117
- const monorepo = new _monorepofixture.Monorepo("monorepo");
118
- await monorepo.init(_path.default.join(fixturesPath, "monorepo-rush-yarn"));
119
- const packageRoot = monorepo.root;
120
- const workspaces = (0, _workspacetools.getRushWorkspaces)(packageRoot);
121
- const dependencies = {
122
- "package-a": "1.0.0",
123
- foo: "1.0.0"
124
- };
125
- const resolvedDependencies = (0, _resolveInternalDependencies.resolveInternalDependencies)(dependencies, workspaces);
126
- expect(resolvedDependencies).toEqual([
127
- "package-a"
128
- ]);
129
- await monorepo.cleanup();
130
- });
131
- });
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/__tests__/resolveInternalDependencies.test.ts"],"sourcesContent":["import { getPnpmWorkspaces, getRushWorkspaces, getYarnWorkspaces } from \"workspace-tools\";\n\nimport { filterInternalDependencies, resolveInternalDependencies } from \"../resolveInternalDependencies\";\nimport {\n filterDependenciesInYarnFixture,\n filterDependenciesInPnpmFixture,\n filterDependenciesInRushFixture,\n} from \"./resolveDependenciesHelper\";\nimport path from \"path\";\nimport { Monorepo } from \"@lage-run/monorepo-fixture\";\nconst fixturesPath = path.join(__dirname, \"..\", \"__fixtures__\");\n\ndescribe(\"filterInternalDependencies() for yarn\", () => {\n it(\"only lists internal dependencies\", async () => {\n const results = await filterDependenciesInYarnFixture(\"monorepo\", filterInternalDependencies);\n\n expect(results).toEqual([\"package-a\"]);\n });\n\n it(\"lists no internal packages if there are no workspaces\", async () => {\n const results = await filterDependenciesInYarnFixture(\"basic\", filterInternalDependencies);\n\n expect(results).toEqual([]);\n });\n});\n\ndescribe(\"resolveInternalDependencies() for yarn\", () => {\n it(\"adds internal dependency names to the processedPackages list\", async () => {\n const monorepo = new Monorepo(\"monorepo\");\n await monorepo.init(path.join(fixturesPath, \"monorepo\"));\n const packageRoot = monorepo.root;\n const workspaces = getYarnWorkspaces(packageRoot);\n\n const dependencies = { \"package-a\": \"1.0.0\", foo: \"1.0.0\" };\n\n const resolvedDependencies = resolveInternalDependencies(dependencies, workspaces);\n\n expect(resolvedDependencies).toEqual([\"package-a\"]);\n await monorepo.cleanup();\n });\n});\n\ndescribe(\"filterInternalDependencies() for pnpm\", () => {\n it(\"only lists internal dependencies\", async () => {\n const results = await filterDependenciesInPnpmFixture(\"monorepo-pnpm\", filterInternalDependencies);\n\n expect(results).toEqual([\"package-a\"]);\n });\n\n it(\"lists no internal packages if there are no workspaces\", async () => {\n const results = await filterDependenciesInPnpmFixture(\"basic\", filterInternalDependencies);\n\n expect(results).toEqual([]);\n });\n});\n\ndescribe(\"resolveInternalDependencies() for pnpm\", () => {\n it(\"adds internal dependency names to the processedPackages list\", async () => {\n const monorepo = new Monorepo(\"monorepo\");\n await monorepo.init(path.join(fixturesPath, \"monorepo-pnpm\"));\n const packageRoot = monorepo.root;\n const workspaces = getPnpmWorkspaces(packageRoot);\n\n const dependencies = { \"package-a\": \"1.0.0\", foo: \"1.0.0\" };\n\n const resolvedDependencies = resolveInternalDependencies(dependencies, workspaces);\n\n expect(resolvedDependencies).toEqual([\"package-a\"]);\n await monorepo.cleanup();\n });\n});\n\ndescribe(\"filterInternalDependencies() for rush+pnpm\", () => {\n it(\"only lists internal dependencies\", async () => {\n const results = await filterDependenciesInRushFixture(\"monorepo-rush-pnpm\", filterInternalDependencies);\n\n expect(results).toEqual([\"package-a\"]);\n });\n\n it(\"lists no internal packages if there are no workspaces\", async () => {\n const results = await filterDependenciesInRushFixture(\"basic\", filterInternalDependencies);\n\n expect(results).toEqual([]);\n });\n});\n\ndescribe(\"resolveInternalDependencies() for rush+pnpm\", () => {\n it(\"adds internal dependency names to the processedPackages list\", async () => {\n const monorepo = new Monorepo(\"monorepo\");\n await monorepo.init(path.join(fixturesPath, \"monorepo-rush-pnpm\"));\n const packageRoot = monorepo.root;\n\n const workspaces = getRushWorkspaces(packageRoot);\n\n const dependencies = { \"package-a\": \"1.0.0\", foo: \"1.0.0\" };\n\n const resolvedDependencies = resolveInternalDependencies(dependencies, workspaces);\n\n expect(resolvedDependencies).toEqual([\"package-a\"]);\n await monorepo.cleanup();\n });\n});\n\ndescribe(\"filterInternalDependencies() for rush+yarn\", () => {\n it(\"only lists internal dependencies\", async () => {\n const results = await filterDependenciesInRushFixture(\"monorepo-rush-yarn\", filterInternalDependencies);\n\n expect(results).toEqual([\"package-a\"]);\n });\n\n it(\"lists no internal packages if there are no workspaces\", async () => {\n const results = await filterDependenciesInRushFixture(\"basic\", filterInternalDependencies);\n\n expect(results).toEqual([]);\n });\n});\n\ndescribe(\"resolveInternalDependencies() for rush+yarn\", () => {\n it(\"adds internal dependency names to the processedPackages list\", async () => {\n const monorepo = new Monorepo(\"monorepo\");\n await monorepo.init(path.join(fixturesPath, \"monorepo-rush-yarn\"));\n const packageRoot = monorepo.root;\n const workspaces = getRushWorkspaces(packageRoot);\n\n const dependencies = { \"package-a\": \"1.0.0\", foo: \"1.0.0\" };\n\n const resolvedDependencies = resolveInternalDependencies(dependencies, workspaces);\n\n expect(resolvedDependencies).toEqual([\"package-a\"]);\n await monorepo.cleanup();\n });\n});\n"],"names":["fixturesPath","path","join","__dirname","describe","it","results","filterDependenciesInYarnFixture","filterInternalDependencies","expect","toEqual","monorepo","Monorepo","init","packageRoot","root","workspaces","getYarnWorkspaces","dependencies","foo","resolvedDependencies","resolveInternalDependencies","cleanup","filterDependenciesInPnpmFixture","getPnpmWorkspaces","filterDependenciesInRushFixture","getRushWorkspaces"],"mappings":";;;;gCAAwE;6CAEA;2CAKjE;6DACU;iCACQ;;;;;;AACzB,MAAMA,eAAeC,aAAI,CAACC,IAAI,CAACC,WAAW,MAAM;AAEhDC,SAAS,yCAAyC;IAChDC,GAAG,oCAAoC;QACrC,MAAMC,UAAU,MAAMC,IAAAA,0DAA+B,EAAC,YAAYC,uDAA0B;QAE5FC,OAAOH,SAASI,OAAO,CAAC;YAAC;SAAY;IACvC;IAEAL,GAAG,yDAAyD;QAC1D,MAAMC,UAAU,MAAMC,IAAAA,0DAA+B,EAAC,SAASC,uDAA0B;QAEzFC,OAAOH,SAASI,OAAO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MC,uBAAuBC,IAAAA,wDAA2B,EAACH,cAAcF;QAEvEP,OAAOW,sBAAsBV,OAAO,CAAC;YAAC;SAAY;QAClD,MAAMC,SAASW,OAAO;IACxB;AACF"}
@@ -1,45 +0,0 @@
1
- /**
2
- * Parses a quoted filename sourced from the output of the "git status" command.
3
- *
4
- * Paths with non-standard characters will be enclosed with double-quotes, and non-standard
5
- * characters will be backslash escaped (ex. double-quotes, non-ASCII characters). The
6
- * escaped chars can be included in one of two ways:
7
- * - backslash-escaped chars (ex. \")
8
- * - octal encoded chars (ex. \347)
9
- *
10
- * See documentation: https://git-scm.com/docs/git-status
11
- */
12
- export declare function parseGitFilename(filename: string): string;
13
- /**
14
- * Parses the output of the "git ls-tree" command
15
- */
16
- export declare function parseGitLsTree(output: string): Map<string, string>;
17
- /**
18
- * Parses the output of the "git status" command
19
- */
20
- export declare function parseGitStatus(output: string): Map<string, string>;
21
- /**
22
- * Takes a list of files and returns the current git hashes for them
23
- *
24
- * @public
25
- */
26
- export declare function getGitHashForFiles(filesToHash: string[], packagePath: string, gitPath?: string): Map<string, string>;
27
- /**
28
- * Executes "git ls-tree" in a folder
29
- */
30
- export declare function gitLsTree(path: string, gitPath?: string): string;
31
- /**
32
- * Executes "git status" in a folder
33
- */
34
- export declare function gitStatus(path: string, gitPath?: string): string;
35
- /**
36
- * Builds an object containing hashes for the files under the specified `packagePath` folder.
37
- * @param packagePath - The folder path to derive the package dependencies from. This is typically the folder
38
- * containing package.json. If omitted, the default value is the current working directory.
39
- * @param excludedPaths - An optional array of file path exclusions. If a file should be omitted from the list
40
- * of dependencies, use this to exclude it.
41
- * @returns the package-deps.json file content
42
- *
43
- * @public
44
- */
45
- export declare function getPackageDeps(packagePath?: string, excludedPaths?: string[], gitPath?: string): Map<string, string>;
@@ -1,259 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: Object.getOwnPropertyDescriptor(all, name).get
9
- });
10
- }
11
- _export(exports, {
12
- get getGitHashForFiles () {
13
- return getGitHashForFiles;
14
- },
15
- get getPackageDeps () {
16
- return getPackageDeps;
17
- },
18
- get gitLsTree () {
19
- return gitLsTree;
20
- },
21
- get gitStatus () {
22
- return gitStatus;
23
- },
24
- get parseGitFilename () {
25
- return parseGitFilename;
26
- },
27
- get parseGitLsTree () {
28
- return parseGitLsTree;
29
- },
30
- get parseGitStatus () {
31
- return parseGitStatus;
32
- }
33
- });
34
- const _path = /*#__PURE__*/ _interop_require_wildcard(require("path"));
35
- const _execa = /*#__PURE__*/ _interop_require_default(require("execa"));
36
- function _interop_require_default(obj) {
37
- return obj && obj.__esModule ? obj : {
38
- default: obj
39
- };
40
- }
41
- function _getRequireWildcardCache(nodeInterop) {
42
- if (typeof WeakMap !== "function") return null;
43
- var cacheBabelInterop = new WeakMap();
44
- var cacheNodeInterop = new WeakMap();
45
- return (_getRequireWildcardCache = function(nodeInterop) {
46
- return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
47
- })(nodeInterop);
48
- }
49
- function _interop_require_wildcard(obj, nodeInterop) {
50
- if (!nodeInterop && obj && obj.__esModule) {
51
- return obj;
52
- }
53
- if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
54
- return {
55
- default: obj
56
- };
57
- }
58
- var cache = _getRequireWildcardCache(nodeInterop);
59
- if (cache && cache.has(obj)) {
60
- return cache.get(obj);
61
- }
62
- var newObj = {
63
- __proto__: null
64
- };
65
- var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
66
- for(var key in obj){
67
- if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
68
- var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
69
- if (desc && (desc.get || desc.set)) {
70
- Object.defineProperty(newObj, key, desc);
71
- } else {
72
- newObj[key] = obj[key];
73
- }
74
- }
75
- }
76
- newObj.default = obj;
77
- if (cache) {
78
- cache.set(obj, newObj);
79
- }
80
- return newObj;
81
- }
82
- function parseGitFilename(filename) {
83
- // If there are no double-quotes around the string, then there are no escaped characters
84
- // to decode, so just return
85
- if (!filename.match(/^".+"$/)) {
86
- return filename;
87
- }
88
- // Need to hex encode '%' since we will be decoding the converted octal values from hex
89
- filename = filename.replace(/%/g, "%25");
90
- // Replace all instances of octal literals with percent-encoded hex (ex. '\347\275\221' -> '%E7%BD%91').
91
- // This is done because the octal literals represent UTF-8 bytes, and by converting them to percent-encoded
92
- // hex, we can use decodeURIComponent to get the Unicode chars.
93
- filename = filename.replace(/(?:\\(\d{1,3}))/g, (match, ...[octalValue, index, source])=>{
94
- // We need to make sure that the backslash is intended to escape the octal value. To do this, walk
95
- // backwards from the match to ensure that it's already escaped.
96
- const trailingBackslashes = source.slice(0, index).match(/\\*$/);
97
- return trailingBackslashes && trailingBackslashes.length > 0 && trailingBackslashes[0].length % 2 === 0 ? `%${parseInt(octalValue, 8).toString(16)}` : match;
98
- });
99
- // Finally, decode the filename and unescape the escaped UTF-8 chars
100
- return JSON.parse(decodeURIComponent(filename));
101
- }
102
- function parseGitLsTree(output) {
103
- const changes = new Map();
104
- if (output) {
105
- // A line is expected to look like:
106
- // 100644 blob 3451bccdc831cb43d7a70ed8e628dcf9c7f888c8 src/typings/tsd.d.ts
107
- // 160000 commit c5880bf5b0c6c1f2e2c43c95beeb8f0a808e8bac rushstack
108
- const gitRegex = /([0-9]{6})\s(blob|commit)\s([a-f0-9]{40})\s*(.*)/;
109
- // Note: The output of git ls-tree uses \n newlines regardless of OS.
110
- const outputLines = output.trim().split("\n");
111
- for (const line of outputLines){
112
- if (line) {
113
- // Take everything after the "100644 blob", which is just the hash and filename
114
- const matches = line.match(gitRegex);
115
- if (matches && matches[3] && matches[4]) {
116
- const hash = matches[3];
117
- const filename = parseGitFilename(matches[4]);
118
- changes.set(filename, hash);
119
- } else {
120
- throw new Error(`Cannot parse git ls-tree input: "${line}"`);
121
- }
122
- }
123
- }
124
- }
125
- return changes;
126
- }
127
- function parseGitStatus(output) {
128
- const changes = new Map();
129
- /*
130
- * Typically, output will look something like:
131
- * M temp_modules/rush-package-deps-hash/package.json
132
- * D package-deps-hash/src/index.ts
133
- */ // If there was an issue with `git ls-tree`, or there are no current changes, processOutputBlocks[1]
134
- // will be empty or undefined
135
- if (!output) {
136
- return changes;
137
- }
138
- // Note: The output of git hash-object uses \n newlines regardless of OS.
139
- const outputLines = output.trim().split("\n");
140
- for (const line of outputLines){
141
- /*
142
- * changeType is in the format of "XY" where "X" is the status of the file in the index and "Y" is the status of
143
- * the file in the working tree. Some example statuses:
144
- * - 'D' == deletion
145
- * - 'M' == modification
146
- * - 'A' == addition
147
- * - '??' == untracked
148
- * - 'R' == rename
149
- * - 'RM' == rename with modifications
150
- * - '[MARC]D' == deleted in work tree
151
- * Full list of examples: https://git-scm.com/docs/git-status#_short_format
152
- */ const match = line.match(/("(\\"|[^"])+")|(\S+\s*)/g);
153
- if (match && match.length > 1) {
154
- const [changeType, ...filenameMatches] = match;
155
- // We always care about the last filename in the filenames array. In the case of non-rename changes,
156
- // the filenames array only contains one file, so we can join all segments that were split on spaces.
157
- // In the case of rename changes, the last item in the array is the path to the file in the working tree,
158
- // which is the only one that we care about. It is also surrounded by double-quotes if spaces are
159
- // included, so no need to worry about joining different segments
160
- let lastFilename = changeType.startsWith("R") ? filenameMatches[filenameMatches.length - 1] : filenameMatches.join("");
161
- lastFilename = parseGitFilename(lastFilename);
162
- changes.set(lastFilename, changeType.trimRight());
163
- }
164
- }
165
- return changes;
166
- }
167
- function getGitHashForFiles(filesToHash, packagePath, gitPath) {
168
- const changes = new Map();
169
- if (filesToHash.length) {
170
- // Use --stdin-paths arg to pass the list of files to git in order to avoid issues with
171
- // command length
172
- const result = _execa.default.sync(gitPath || "git", [
173
- "hash-object",
174
- "--stdin-paths"
175
- ], {
176
- input: filesToHash.map((x)=>_path.resolve(packagePath, x)).join("\n")
177
- });
178
- if (result.exitCode !== 0) {
179
- throw new Error(`git hash-object exited with status ${result.exitCode}: ${result.stderr}`);
180
- }
181
- const hashStdout = result.stdout.trim();
182
- // The result of "git hash-object" will be a list of file hashes delimited by newlines
183
- const hashes = hashStdout.split("\n");
184
- if (hashes.length !== filesToHash.length) {
185
- throw new Error(`Passed ${filesToHash.length} file paths to Git to hash, but received ${hashes.length} hashes.`);
186
- }
187
- for(let i = 0; i < hashes.length; i++){
188
- const hash = hashes[i];
189
- const filePath = filesToHash[i];
190
- changes.set(filePath, hash);
191
- }
192
- }
193
- return changes;
194
- }
195
- function gitLsTree(path, gitPath) {
196
- const result = _execa.default.sync(gitPath || "git", [
197
- "ls-tree",
198
- "HEAD",
199
- "-r"
200
- ], {
201
- cwd: path
202
- });
203
- if (result.exitCode !== 0) {
204
- throw new Error(`git ls-tree exited with status ${result.exitCode}: ${result.stderr}`);
205
- }
206
- return result.stdout;
207
- }
208
- function gitStatus(path, gitPath) {
209
- /**
210
- * -s - Short format. Will be printed as 'XY PATH' or 'XY ORIG_PATH -> PATH'. Paths with non-standard
211
- * characters will be escaped using double-quotes, and non-standard characters will be backslash
212
- * escaped (ex. spaces, tabs, double-quotes)
213
- * -u - Untracked files are included
214
- *
215
- * See documentation here: https://git-scm.com/docs/git-status
216
- */ const result = _execa.default.sync(gitPath || "git", [
217
- "status",
218
- "-s",
219
- "-u",
220
- "."
221
- ], {
222
- cwd: path
223
- });
224
- if (result.exitCode !== 0) {
225
- throw new Error(`git status exited with status ${result.exitCode}: ${result.stderr}`);
226
- }
227
- return result.stdout;
228
- }
229
- function getPackageDeps(packagePath = process.cwd(), excludedPaths, gitPath) {
230
- const gitLsOutput = gitLsTree(packagePath, gitPath);
231
- // Add all the checked in hashes
232
- const result = parseGitLsTree(gitLsOutput);
233
- // Remove excluded paths
234
- if (excludedPaths) {
235
- for (const excludedPath of excludedPaths){
236
- result.delete(excludedPath);
237
- }
238
- }
239
- // Update the checked in hashes with the current repo status
240
- const gitStatusOutput = gitStatus(packagePath, gitPath);
241
- const currentlyChangedFiles = parseGitStatus(gitStatusOutput);
242
- const filesToHash = [];
243
- const excludedPathSet = new Set(excludedPaths);
244
- for (const [filename, changeType] of currentlyChangedFiles){
245
- // See comments inside parseGitStatus() for more information
246
- if (changeType === "D" || changeType.length === 2 && changeType.charAt(1) === "D") {
247
- result.delete(filename);
248
- } else {
249
- if (!excludedPathSet.has(filename)) {
250
- filesToHash.push(filename);
251
- }
252
- }
253
- }
254
- const currentlyChangedFileHashes = getGitHashForFiles(filesToHash, packagePath, gitPath);
255
- for (const [filename, hash] of currentlyChangedFileHashes){
256
- result.set(filename, hash);
257
- }
258
- return result;
259
- }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/getPackageDeps.ts"],"sourcesContent":["import * as path from \"path\";\nimport execa from \"execa\";\n\n/**\n * Parses a quoted filename sourced from the output of the \"git status\" command.\n *\n * Paths with non-standard characters will be enclosed with double-quotes, and non-standard\n * characters will be backslash escaped (ex. double-quotes, non-ASCII characters). The\n * escaped chars can be included in one of two ways:\n * - backslash-escaped chars (ex. \\\")\n * - octal encoded chars (ex. \\347)\n *\n * See documentation: https://git-scm.com/docs/git-status\n */\nexport function parseGitFilename(filename: string): string {\n // If there are no double-quotes around the string, then there are no escaped characters\n // to decode, so just return\n if (!filename.match(/^\".+\"$/)) {\n return filename;\n }\n\n // Need to hex encode '%' since we will be decoding the converted octal values from hex\n filename = filename.replace(/%/g, \"%25\");\n // Replace all instances of octal literals with percent-encoded hex (ex. '\\347\\275\\221' -> '%E7%BD%91').\n // This is done because the octal literals represent UTF-8 bytes, and by converting them to percent-encoded\n // hex, we can use decodeURIComponent to get the Unicode chars.\n filename = filename.replace(/(?:\\\\(\\d{1,3}))/g, (match, ...[octalValue, index, source]) => {\n // We need to make sure that the backslash is intended to escape the octal value. To do this, walk\n // backwards from the match to ensure that it's already escaped.\n const trailingBackslashes: RegExpMatchArray | null = (source as string).slice(0, index as number).match(/\\\\*$/);\n return trailingBackslashes && trailingBackslashes.length > 0 && trailingBackslashes[0].length % 2 === 0\n ? `%${parseInt(octalValue, 8).toString(16)}`\n : match;\n });\n\n // Finally, decode the filename and unescape the escaped UTF-8 chars\n return JSON.parse(decodeURIComponent(filename));\n}\n\n/**\n * Parses the output of the \"git ls-tree\" command\n */\nexport function parseGitLsTree(output: string): Map<string, string> {\n const changes: Map<string, string> = new Map<string, string>();\n\n if (output) {\n // A line is expected to look like:\n // 100644 blob 3451bccdc831cb43d7a70ed8e628dcf9c7f888c8 src/typings/tsd.d.ts\n // 160000 commit c5880bf5b0c6c1f2e2c43c95beeb8f0a808e8bac rushstack\n const gitRegex = /([0-9]{6})\\s(blob|commit)\\s([a-f0-9]{40})\\s*(.*)/;\n\n // Note: The output of git ls-tree uses \\n newlines regardless of OS.\n const outputLines: string[] = output.trim().split(\"\\n\");\n for (const line of outputLines) {\n if (line) {\n // Take everything after the \"100644 blob\", which is just the hash and filename\n const matches: RegExpMatchArray | null = line.match(gitRegex);\n if (matches && matches[3] && matches[4]) {\n const hash: string = matches[3];\n const filename: string = parseGitFilename(matches[4]);\n\n changes.set(filename, hash);\n } else {\n throw new Error(`Cannot parse git ls-tree input: \"${line}\"`);\n }\n }\n }\n }\n\n return changes;\n}\n\n/**\n * Parses the output of the \"git status\" command\n */\nexport function parseGitStatus(output: string): Map<string, string> {\n const changes: Map<string, string> = new Map<string, string>();\n\n /*\n * Typically, output will look something like:\n * M temp_modules/rush-package-deps-hash/package.json\n * D package-deps-hash/src/index.ts\n */\n\n // If there was an issue with `git ls-tree`, or there are no current changes, processOutputBlocks[1]\n // will be empty or undefined\n if (!output) {\n return changes;\n }\n\n // Note: The output of git hash-object uses \\n newlines regardless of OS.\n const outputLines: string[] = output.trim().split(\"\\n\");\n for (const line of outputLines) {\n /*\n * changeType is in the format of \"XY\" where \"X\" is the status of the file in the index and \"Y\" is the status of\n * the file in the working tree. Some example statuses:\n * - 'D' == deletion\n * - 'M' == modification\n * - 'A' == addition\n * - '??' == untracked\n * - 'R' == rename\n * - 'RM' == rename with modifications\n * - '[MARC]D' == deleted in work tree\n * Full list of examples: https://git-scm.com/docs/git-status#_short_format\n */\n const match: RegExpMatchArray | null = line.match(/(\"(\\\\\"|[^\"])+\")|(\\S+\\s*)/g);\n\n if (match && match.length > 1) {\n const [changeType, ...filenameMatches] = match;\n\n // We always care about the last filename in the filenames array. In the case of non-rename changes,\n // the filenames array only contains one file, so we can join all segments that were split on spaces.\n // In the case of rename changes, the last item in the array is the path to the file in the working tree,\n // which is the only one that we care about. It is also surrounded by double-quotes if spaces are\n // included, so no need to worry about joining different segments\n let lastFilename: string = changeType.startsWith(\"R\") ? filenameMatches[filenameMatches.length - 1] : filenameMatches.join(\"\");\n lastFilename = parseGitFilename(lastFilename);\n\n changes.set(lastFilename, changeType.trimRight());\n }\n }\n\n return changes;\n}\n\n/**\n * Takes a list of files and returns the current git hashes for them\n *\n * @public\n */\nexport function getGitHashForFiles(filesToHash: string[], packagePath: string, gitPath?: string): Map<string, string> {\n const changes: Map<string, string> = new Map<string, string>();\n\n if (filesToHash.length) {\n // Use --stdin-paths arg to pass the list of files to git in order to avoid issues with\n // command length\n const result = execa.sync(gitPath || \"git\", [\"hash-object\", \"--stdin-paths\"], {\n input: filesToHash.map((x) => path.resolve(packagePath, x)).join(\"\\n\"),\n });\n\n if (result.exitCode !== 0) {\n throw new Error(`git hash-object exited with status ${result.exitCode}: ${result.stderr}`);\n }\n\n const hashStdout: string = result.stdout.trim();\n\n // The result of \"git hash-object\" will be a list of file hashes delimited by newlines\n const hashes: string[] = hashStdout.split(\"\\n\");\n\n if (hashes.length !== filesToHash.length) {\n throw new Error(`Passed ${filesToHash.length} file paths to Git to hash, but received ${hashes.length} hashes.`);\n }\n\n for (let i = 0; i < hashes.length; i++) {\n const hash: string = hashes[i];\n const filePath: string = filesToHash[i];\n changes.set(filePath, hash);\n }\n }\n\n return changes;\n}\n\n/**\n * Executes \"git ls-tree\" in a folder\n */\nexport function gitLsTree(path: string, gitPath?: string): string {\n const result = execa.sync(gitPath || \"git\", [\"ls-tree\", \"HEAD\", \"-r\"], {\n cwd: path,\n });\n\n if (result.exitCode !== 0) {\n throw new Error(`git ls-tree exited with status ${result.exitCode}: ${result.stderr}`);\n }\n\n return result.stdout;\n}\n\n/**\n * Executes \"git status\" in a folder\n */\nexport function gitStatus(path: string, gitPath?: string): string {\n /**\n * -s - Short format. Will be printed as 'XY PATH' or 'XY ORIG_PATH -> PATH'. Paths with non-standard\n * characters will be escaped using double-quotes, and non-standard characters will be backslash\n * escaped (ex. spaces, tabs, double-quotes)\n * -u - Untracked files are included\n *\n * See documentation here: https://git-scm.com/docs/git-status\n */\n const result = execa.sync(gitPath || \"git\", [\"status\", \"-s\", \"-u\", \".\"], {\n cwd: path,\n });\n\n if (result.exitCode !== 0) {\n throw new Error(`git status exited with status ${result.exitCode}: ${result.stderr}`);\n }\n\n return result.stdout;\n}\n\n/**\n * Builds an object containing hashes for the files under the specified `packagePath` folder.\n * @param packagePath - The folder path to derive the package dependencies from. This is typically the folder\n * containing package.json. If omitted, the default value is the current working directory.\n * @param excludedPaths - An optional array of file path exclusions. If a file should be omitted from the list\n * of dependencies, use this to exclude it.\n * @returns the package-deps.json file content\n *\n * @public\n */\nexport function getPackageDeps(packagePath: string = process.cwd(), excludedPaths?: string[], gitPath?: string): Map<string, string> {\n const gitLsOutput: string = gitLsTree(packagePath, gitPath);\n\n // Add all the checked in hashes\n const result: Map<string, string> = parseGitLsTree(gitLsOutput);\n\n // Remove excluded paths\n if (excludedPaths) {\n for (const excludedPath of excludedPaths) {\n result.delete(excludedPath);\n }\n }\n\n // Update the checked in hashes with the current repo status\n const gitStatusOutput: string = gitStatus(packagePath, gitPath);\n const currentlyChangedFiles: Map<string, string> = parseGitStatus(gitStatusOutput);\n const filesToHash: string[] = [];\n const excludedPathSet: Set<string> = new Set<string>(excludedPaths);\n for (const [filename, changeType] of currentlyChangedFiles) {\n // See comments inside parseGitStatus() for more information\n if (changeType === \"D\" || (changeType.length === 2 && changeType.charAt(1) === \"D\")) {\n result.delete(filename);\n } else {\n if (!excludedPathSet.has(filename)) {\n filesToHash.push(filename);\n }\n }\n }\n\n const currentlyChangedFileHashes: Map<string, string> = getGitHashForFiles(filesToHash, packagePath, gitPath);\n for (const [filename, hash] of currentlyChangedFileHashes) {\n result.set(filename, hash);\n }\n\n return result;\n}\n"],"names":["getGitHashForFiles","getPackageDeps","gitLsTree","gitStatus","parseGitFilename","parseGitLsTree","parseGitStatus","filename","match","replace","octalValue","index","source","trailingBackslashes","slice","length","parseInt","toString","JSON","parse","decodeURIComponent","output","changes","Map","gitRegex","outputLines","trim","split","line","matches","hash","set","Error","changeType","filenameMatches","lastFilename","startsWith","join","trimRight","filesToHash","packagePath","gitPath","result","execa","sync","input","map","x","path","resolve","exitCode","stderr","hashStdout","stdout","hashes","i","filePath","cwd","process","excludedPaths","gitLsOutput","excludedPath","delete","gitStatusOutput","currentlyChangedFiles","excludedPathSet","Set","charAt","has","push","currentlyChangedFileHashes"],"mappings":";;;;;;;;;;;QAkIgBA;eAAAA;;QAiFAC;eAAAA;;QA7CAC;eAAAA;;QAeAC;eAAAA;;QAvKAC;eAAAA;;QA4BAC;eAAAA;;QAiCAC;eAAAA;;;8DA3EM;8DACJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaX,SAASF,iBAAiBG,QAAgB;IAC/C,wFAAwF;IACxF,4BAA4B;IAC5B,IAAI,CAACA,SAASC,KAAK,CAAC,WAAW;QAC7B,OAAOD;IACT;IAEA,uFAAuF;IACvFA,WAAWA,SAASE,OAAO,CAAC,MAAM;IAClC,wGAAwG;IACxG,2GAA2G;IAC3G,+DAA+D;IAC/DF,WAAWA,SAASE,OAAO,CAAC,oBAAoB,CAACD,OAAO,GAAG,CAACE,YAAYC,OAAOC,OAAO;QACpF,kGAAkG;QAClG,gEAAgE;QAChE,MAAMC,sBAA+C,AAACD,OAAkBE,KAAK,CAAC,GAAGH,OAAiBH,KAAK,CAAC;Q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AK,MAAM,CAACpD,UAAU0B,WAAW,IAAI+B,sBAAuB;QAC1D,4DAA4D;QAC5D,IAAI/B,eAAe,OAAQA,WAAWlB,MAAM,KAAK,KAAKkB,WAAWkC,MAAM,CAAC,OAAO,KAAM;YACnFzB,OAAOoB,MAAM,CAACvD;QAChB,OAAO;YACL,IAAI,CAAC0D,gBAAgBG,GAAG,CAAC7D,WAAW;gBAClCgC,YAAY8B,IAAI,CAAC9D;YACnB;QACF;IACF;IAEA,MAAM+D,6BAAkDtE,mBAAmBuC,aAAaC,aAAaC;IACrG,KAAK,MAAM,CAAClC,UAAUuB,KAAK,IAAIwC,2BAA4B;QACzD5B,OAAOX,GAAG,CAACxB,UAAUuB;IACvB;IAEA,OAAOY;AACT"}
@@ -1 +0,0 @@
1
- export declare function nameAtVersion(name: string, version: string): string;
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "nameAtVersion", {
6
- enumerable: true,
7
- get: function() {
8
- return nameAtVersion;
9
- }
10
- });
11
- function nameAtVersion(name, version) {
12
- return `${name}@${version}`;
13
- }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/nameAtVersion.ts"],"sourcesContent":["export function nameAtVersion(name: string, version: string): string {\n return `${name}@${version}`;\n}\n"],"names":["nameAtVersion","name","version"],"mappings":";;;;+BAAgBA;;;eAAAA;;;AAAT,SAASA,cAAcC,IAAY,EAAEC,OAAe;IACzD,OAAO,GAAGD,KAAK,CAAC,EAAEC,SAAS;AAC7B"}
@@ -1,11 +0,0 @@
1
- import type { ParsedLock, WorkspaceInfos } from "workspace-tools";
2
- export type Dependencies = {
3
- [key in string]: string;
4
- };
5
- export type ExternalDependenciesQueue = {
6
- name: string;
7
- versionRange: string;
8
- }[];
9
- export declare function filterExternalDependencies(dependencies: Dependencies, workspaces: WorkspaceInfos): Dependencies;
10
- export declare function addToQueue(dependencies: Dependencies | undefined, done: string[], queue: [string, string][]): void;
11
- export declare function resolveExternalDependencies(allDependencies: Dependencies, workspaces: WorkspaceInfos, lockInfo: ParsedLock): string[];
@@ -1,75 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: Object.getOwnPropertyDescriptor(all, name).get
9
- });
10
- }
11
- _export(exports, {
12
- get addToQueue () {
13
- return addToQueue;
14
- },
15
- get filterExternalDependencies () {
16
- return filterExternalDependencies;
17
- },
18
- get resolveExternalDependencies () {
19
- return resolveExternalDependencies;
20
- }
21
- });
22
- const _workspacetools = require("workspace-tools");
23
- const _nameAtVersion = require("./nameAtVersion.js");
24
- function filterExternalDependencies(dependencies, workspaces) {
25
- const workspacePackageNames = workspaces.map((ws)=>ws.name);
26
- const externalDependencies = {};
27
- Object.entries(dependencies).forEach(([name, versionRange])=>{
28
- if (workspacePackageNames.indexOf(name) < 0) {
29
- externalDependencies[name] = versionRange;
30
- }
31
- });
32
- return externalDependencies;
33
- }
34
- function isDone(done, key) {
35
- return done.indexOf(key) >= 0;
36
- }
37
- function isInQueue(queue, key) {
38
- return Boolean(queue.find(([name, versionRange])=>(0, _nameAtVersion.nameAtVersion)(name, versionRange) === key));
39
- }
40
- function addToQueue(dependencies, done, queue) {
41
- if (dependencies) {
42
- Object.entries(dependencies).forEach(([name, versionRange])=>{
43
- const versionRangeSignature = (0, _nameAtVersion.nameAtVersion)(name, versionRange);
44
- if (!isDone(done, versionRangeSignature) && !isInQueue(queue, versionRangeSignature)) {
45
- queue.push([
46
- name,
47
- versionRange
48
- ]);
49
- }
50
- });
51
- }
52
- }
53
- function resolveExternalDependencies(allDependencies, workspaces, lockInfo) {
54
- const externalDependencies = filterExternalDependencies(allDependencies, workspaces);
55
- const done = [];
56
- const doneRange = [];
57
- const queue = Object.entries(externalDependencies);
58
- while(queue.length > 0){
59
- const next = queue.shift();
60
- if (!next) {
61
- continue;
62
- }
63
- const [name, versionRange] = next;
64
- doneRange.push((0, _nameAtVersion.nameAtVersion)(name, versionRange));
65
- const lockFileResult = (0, _workspacetools.queryLockFile)(name, versionRange, lockInfo);
66
- if (lockFileResult) {
67
- const { version, dependencies } = lockFileResult;
68
- addToQueue(dependencies, doneRange, queue);
69
- done.push((0, _nameAtVersion.nameAtVersion)(name, version));
70
- } else {
71
- done.push((0, _nameAtVersion.nameAtVersion)(name, versionRange));
72
- }
73
- }
74
- return done;
75
- }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/resolveExternalDependencies.ts"],"sourcesContent":["import type { ParsedLock, WorkspaceInfos } from \"workspace-tools\";\nimport { queryLockFile } from \"workspace-tools\";\nimport { nameAtVersion } from \"./nameAtVersion.js\";\n\nexport type Dependencies = { [key in string]: string };\n\nexport type ExternalDependenciesQueue = {\n name: string;\n versionRange: string;\n}[];\n\nexport function filterExternalDependencies(dependencies: Dependencies, workspaces: WorkspaceInfos): Dependencies {\n const workspacePackageNames = workspaces.map((ws) => ws.name);\n const externalDependencies: Dependencies = {};\n\n Object.entries(dependencies).forEach(([name, versionRange]) => {\n if (workspacePackageNames.indexOf(name) < 0) {\n externalDependencies[name] = versionRange;\n }\n });\n\n return externalDependencies;\n}\n\nfunction isDone(done: string[], key: string): boolean {\n return done.indexOf(key) >= 0;\n}\n\nfunction isInQueue(queue: [string, string][], key: string): boolean {\n return Boolean(queue.find(([name, versionRange]) => nameAtVersion(name, versionRange) === key));\n}\n\nexport function addToQueue(dependencies: Dependencies | undefined, done: string[], queue: [string, string][]): void {\n if (dependencies) {\n Object.entries(dependencies).forEach(([name, versionRange]) => {\n const versionRangeSignature = nameAtVersion(name, versionRange);\n\n if (!isDone(done, versionRangeSignature) && !isInQueue(queue, versionRangeSignature)) {\n queue.push([name, versionRange]);\n }\n });\n }\n}\n\nexport function resolveExternalDependencies(allDependencies: Dependencies, workspaces: WorkspaceInfos, lockInfo: ParsedLock): string[] {\n const externalDependencies = filterExternalDependencies(allDependencies, workspaces);\n\n const done: string[] = [];\n const doneRange: string[] = [];\n const queue = Object.entries(externalDependencies);\n\n while (queue.length > 0) {\n const next = queue.shift();\n\n if (!next) {\n continue;\n }\n\n const [name, versionRange] = next;\n doneRange.push(nameAtVersion(name, versionRange));\n\n const lockFileResult = queryLockFile(name, versionRange, lockInfo);\n\n if (lockFileResult) {\n const { version, dependencies } = lockFileResult;\n\n addToQueue(dependencies, doneRange, queue);\n done.push(nameAtVersion(name, version));\n } else {\n done.push(nameAtVersion(name, versionRange));\n }\n }\n\n return done;\n}\n"],"names":["addToQueue","filterExternalDependencies","resolveExternalDependencies","dependencies","workspaces","workspacePackageNames","map","ws","name","externalDependencies","Object","entries","forEach","versionRange","indexOf","isDone","done","key","isInQueue","queue","Boolean","find","nameAtVersion","versionRangeSignature","push","allDependencies","lockInfo","doneRange","length","next","shift","lockFileResult","queryLockFile","version"],"mappings":";;;;;;;;;;;QAgCgBA;eAAAA;;QArBAC;eAAAA;;QAiCAC;eAAAA;;;gCA3Cc;+BACA;AASvB,SAASD,2BAA2BE,YAA0B,EAAEC,UAA0B;IAC/F,MAAMC,wBAAwBD,WAAWE,GAAG,CAAC,CAACC,KAAOA,GAAGC,IAAI;IAC5D,MAAMC,uBAAqC,CAAC;IAE5CC,OAAOC,OAAO,CAACR,cAAcS,OAAO,CAAC,CAAC,CAACJ,MAAMK,aAAa;QACxD,IAAIR,sBAAsBS,OAAO,CAACN,QAAQ,GAAG;YAC3CC,oBAAoB,CAACD,KAAK,GAAGK;QAC/B;IACF;IAEA,OAAOJ;AACT;AAEA,SAASM,OAAOC,IAAc,EAAEC,GAAW;IACzC,OAAOD,KAAKF,OAAO,CAACG,QAAQ;AAC9B;AAEA,SAASC,UAAUC,KAAyB,EAAEF,GAAW;IACvD,OAAOG,QAAQD,MAAME,IAAI,CAAC,CAAC,CAACb,MAAMK,aAAa,GAAKS,IAAAA,4BAAa,EAACd,MAAMK,kBAAkBI;AAC5F;AAEO,SAASjB,WAAWG,YAAsC,EAAEa,IAAc,EAAEG,KAAyB;IAC1G,IAAIhB,cAAc;QAChBO,OAAOC,OAAO,CAACR,cAAcS,OAAO,CAAC,CAAC,CAACJ,MAAMK,aAAa;YACxD,MAAMU,wBAAwBD,IAAAA,4BAAa,EAACd,MAAMK;YAElD,IAAI,CAACE,OAAOC,MAAMO,0BAA0B,CAACL,UAAUC,OAAOI,wBAAwB;gBACpFJ,MAAMK,IAAI,CAAC;oBAAChB;oBAAMK;iBAAa;YACjC;QACF;IACF;AACF;AAEO,SAASX,4BAA4BuB,eAA6B,EAAErB,UAA0B,EAAEsB,QAAoB;IACzH,MAAMjB,uBAAuBR,2BAA2BwB,iBAAiBrB;IAEzE,MAAMY,OAAiB,EAAE;IACzB,MAAMW,YAAsB,EAAE;IAC9B,MAAMR,QAAQT,OAAOC,OAAO,CAACF;IAE7B,MAAOU,MAAMS,MAAM,GAAG,EAAG;QACvB,MAAMC,OAAOV,MAAMW,KAAK;QAExB,IAAI,CAACD,MAAM;YACT;QACF;QAEA,MAAM,CAACrB,MAAMK,aAAa,GAAGgB;QAC7BF,UAAUH,IAAI,CAACF,IAAAA,4BAAa,EAACd,MAAMK;QAEnC,MAAMkB,iBAAiBC,IAAAA,6BAAa,EAACxB,MAAMK,cAAca;QAEzD,IAAIK,gBAAgB;YAClB,MAAM,EAAEE,OAAO,EAAE9B,YAAY,EAAE,GAAG4B;YAElC/B,WAAWG,cAAcwB,WAAWR;YACpCH,KAAKQ,IAAI,CAACF,IAAAA,4BAAa,EAACd,MAAMyB;QAChC,OAAO;YACLjB,KAAKQ,IAAI,CAACF,IAAAA,4BAAa,EAACd,MAAMK;QAChC;IACF;IAEA,OAAOG;AACT"}
@@ -1,6 +0,0 @@
1
- import type { WorkspaceInfos } from "workspace-tools";
2
- export type Dependencies = {
3
- [key in string]: string;
4
- };
5
- export declare function filterInternalDependencies(dependencies: Dependencies, workspaces: WorkspaceInfos): string[];
6
- export declare function resolveInternalDependencies(allDependencies: Dependencies, workspaces: WorkspaceInfos): string[];
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: Object.getOwnPropertyDescriptor(all, name).get
9
- });
10
- }
11
- _export(exports, {
12
- get filterInternalDependencies () {
13
- return filterInternalDependencies;
14
- },
15
- get resolveInternalDependencies () {
16
- return resolveInternalDependencies;
17
- }
18
- });
19
- function filterInternalDependencies(dependencies, workspaces) {
20
- const workspacePackageNames = workspaces.map((ws)=>ws.name);
21
- return Object.keys(dependencies).filter((dependency)=>workspacePackageNames.indexOf(dependency) >= 0);
22
- }
23
- function resolveInternalDependencies(allDependencies, workspaces) {
24
- const dependencyNames = filterInternalDependencies(allDependencies, workspaces);
25
- return dependencyNames;
26
- }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/resolveInternalDependencies.ts"],"sourcesContent":["import type { WorkspaceInfos } from \"workspace-tools\";\n\nexport type Dependencies = { [key in string]: string };\n\nexport function filterInternalDependencies(dependencies: Dependencies, workspaces: WorkspaceInfos): string[] {\n const workspacePackageNames = workspaces.map((ws) => ws.name);\n return Object.keys(dependencies).filter((dependency) => workspacePackageNames.indexOf(dependency) >= 0);\n}\n\nexport function resolveInternalDependencies(allDependencies: Dependencies, workspaces: WorkspaceInfos): string[] {\n const dependencyNames = filterInternalDependencies(allDependencies, workspaces);\n\n return dependencyNames;\n}\n"],"names":["filterInternalDependencies","resolveInternalDependencies","dependencies","workspaces","workspacePackageNames","map","ws","name","Object","keys","filter","dependency","indexOf","allDependencies","dependencyNames"],"mappings":";;;;;;;;;;;QAIgBA;eAAAA;;QAKAC;eAAAA;;;AALT,SAASD,2BAA2BE,YAA0B,EAAEC,UAA0B;IAC/F,MAAMC,wBAAwBD,WAAWE,GAAG,CAAC,CAACC,KAAOA,GAAGC,IAAI;IAC5D,OAAOC,OAAOC,IAAI,CAACP,cAAcQ,MAAM,CAAC,CAACC,aAAeP,sBAAsBQ,OAAO,CAACD,eAAe;AACvG;AAEO,SAASV,4BAA4BY,eAA6B,EAAEV,UAA0B;IACnG,MAAMW,kBAAkBd,2BAA2Ba,iBAAiBV;IAEpE,OAAOW;AACT"}