@lage-run/hasher 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +16 -1
- package/CHANGELOG.md +10 -2
- package/lib/__tests__/createPackageHashes.test.js +13 -12
- package/lib/__tests__/getPackageDeps.test.js +149 -131
- package/lib/__tests__/getRepoDeps.test.js +106 -91
- package/lib/__tests__/getRepoState.test.js +70 -33
- package/lib/__tests__/hashOfFiles.test.js +71 -68
- package/lib/__tests__/helpers.test.js +12 -11
- package/lib/__tests__/index.test.js +50 -39
- package/lib/__tests__/resolveDependenciesHelper.js +44 -25
- package/lib/__tests__/resolveExternalDependencies.test.js +114 -68
- package/lib/__tests__/resolveInternalDependencies.test.js +98 -67
- package/lib/createPackageHashes.js +27 -20
- package/lib/getPackageDeps.js +118 -125
- package/lib/getRepoState.js +86 -101
- package/lib/hashOfFiles.js +59 -53
- package/lib/hashOfPackage.js +41 -28
- package/lib/helpers.js +35 -19
- package/lib/index.js +50 -41
- package/lib/repoInfo.js +26 -29
- package/lib/resolveExternalDependencies.js +32 -22
- package/lib/resolveInternalDependencies.js +16 -8
- package/package.json +2 -2
- package/lib/__fixtures__/config/backfill.config.js +0 -5
- package/lib/__fixtures__/config/backfill.config.js.map +0 -1
- package/lib/__fixtures__/config/packages/package-1/backfill.config.js +0 -2
- package/lib/__fixtures__/config/packages/package-1/backfill.config.js.map +0 -1
- package/lib/__tests__/createPackageHashes.test.js.map +0 -1
- package/lib/__tests__/getPackageDeps.test.js.map +0 -1
- package/lib/__tests__/getRepoDeps.test.js.map +0 -1
- package/lib/__tests__/getRepoState.test.js.map +0 -1
- package/lib/__tests__/hashOfFiles.test.js.map +0 -1
- package/lib/__tests__/helpers.test.js.map +0 -1
- package/lib/__tests__/index.test.js.map +0 -1
- package/lib/__tests__/resolveDependenciesHelper.js.map +0 -1
- package/lib/__tests__/resolveExternalDependencies.test.js.map +0 -1
- package/lib/__tests__/resolveInternalDependencies.test.js.map +0 -1
- package/lib/createPackageHashes.js.map +0 -1
- package/lib/getPackageDeps.js.map +0 -1
- package/lib/getRepoState.js.map +0 -1
- package/lib/hashOfFiles.js.map +0 -1
- package/lib/hashOfPackage.js.map +0 -1
- package/lib/helpers.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/repoInfo.js.map +0 -1
- package/lib/resolveExternalDependencies.js.map +0 -1
- package/lib/resolveInternalDependencies.js.map +0 -1
package/CHANGELOG.json
CHANGED
|
@@ -2,7 +2,22 @@
|
|
|
2
2
|
"name": "@lage-run/hasher",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "
|
|
5
|
+
"date": "Fri, 18 Nov 2022 19:52:27 GMT",
|
|
6
|
+
"tag": "@lage-run/hasher_v0.1.2",
|
|
7
|
+
"version": "0.1.2",
|
|
8
|
+
"comments": {
|
|
9
|
+
"patch": [
|
|
10
|
+
{
|
|
11
|
+
"author": "email not defined",
|
|
12
|
+
"package": "@lage-run/hasher",
|
|
13
|
+
"commit": "0970a6aa757664bd8fa9338982ef6e051500577c",
|
|
14
|
+
"comment": "Update dependency workspace-tools to v0.29.1"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"date": "Wed, 02 Nov 2022 06:27:27 GMT",
|
|
6
21
|
"tag": "@lage-run/hasher_v0.1.1",
|
|
7
22
|
"version": "0.1.1",
|
|
8
23
|
"comments": {
|
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
# Change Log - @lage-run/hasher
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Fri, 18 Nov 2022 19:52:27 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 0.1.2
|
|
8
|
+
|
|
9
|
+
Fri, 18 Nov 2022 19:52:27 GMT
|
|
10
|
+
|
|
11
|
+
### Patches
|
|
12
|
+
|
|
13
|
+
- Update dependency workspace-tools to v0.29.1 (email not defined)
|
|
14
|
+
|
|
7
15
|
## 0.1.1
|
|
8
16
|
|
|
9
|
-
Wed, 02 Nov 2022 06:27:
|
|
17
|
+
Wed, 02 Nov 2022 06:27:27 GMT
|
|
10
18
|
|
|
11
19
|
### Patches
|
|
12
20
|
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
const _createPackageHashes = require("../createPackageHashes");
|
|
6
|
+
describe("createPackageHashes", ()=>{
|
|
7
|
+
it("creates packages hashes for repo hashes", ()=>{
|
|
8
|
+
const packageHashes = (0, _createPackageHashes.createPackageHashes)("/repo", [
|
|
7
9
|
{
|
|
8
10
|
path: "/repo/packages/package-a",
|
|
9
11
|
name: "package-a",
|
|
10
12
|
packageJson: {
|
|
11
13
|
name: "package-a",
|
|
12
14
|
packageJsonPath: "/packages/package-a/package.json",
|
|
13
|
-
version: "1.0.0"
|
|
14
|
-
}
|
|
15
|
+
version: "1.0.0"
|
|
16
|
+
}
|
|
15
17
|
},
|
|
16
18
|
{
|
|
17
19
|
path: "/repo/packages/package-b",
|
|
@@ -19,15 +21,15 @@ describe("createPackageHashes", () => {
|
|
|
19
21
|
packageJson: {
|
|
20
22
|
name: "package-b",
|
|
21
23
|
packageJsonPath: "/packages/package-b/package.json",
|
|
22
|
-
version: "1.0.0"
|
|
23
|
-
}
|
|
24
|
-
}
|
|
24
|
+
version: "1.0.0"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
25
27
|
], {
|
|
26
28
|
"packages/package-a/foo.ts": "hash-a-foo.ts",
|
|
27
29
|
"packages/package-a/package.json": "hash-a-package.json",
|
|
28
30
|
"packages/package-b/1.ts": "hash-b-1.ts",
|
|
29
31
|
"packages/package-b/2.ts": "hash-b-2.ts",
|
|
30
|
-
"packages/package-b/3.ts": "hash-b-3.ts"
|
|
32
|
+
"packages/package-b/3.ts": "hash-b-3.ts"
|
|
31
33
|
});
|
|
32
34
|
expect(packageHashes["packages/package-a"].length).toEqual(2);
|
|
33
35
|
// packageHashes["packageName"] is an array of tuples of the form [filePath, hash]
|
|
@@ -40,4 +42,3 @@ describe("createPackageHashes", () => {
|
|
|
40
42
|
expect(packageHashes["packages/package-b"][2][1]).toEqual("hash-b-3.ts");
|
|
41
43
|
});
|
|
42
44
|
});
|
|
43
|
-
//# sourceMappingURL=createPackageHashes.test.js.map
|
|
@@ -1,129 +1,146 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
17
4
|
});
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
5
|
+
const _path = /*#__PURE__*/ _interopRequireWildcard(require("path"));
|
|
6
|
+
const _fs = /*#__PURE__*/ _interopRequireWildcard(require("fs"));
|
|
7
|
+
const _childProcess = require("child_process");
|
|
8
|
+
const _getPackageDeps = require("../getPackageDeps");
|
|
9
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
10
|
+
if (typeof WeakMap !== "function") return null;
|
|
11
|
+
var cacheBabelInterop = new WeakMap();
|
|
12
|
+
var cacheNodeInterop = new WeakMap();
|
|
13
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
14
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
15
|
+
})(nodeInterop);
|
|
16
|
+
}
|
|
17
|
+
function _interopRequireWildcard(obj, nodeInterop) {
|
|
18
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
19
|
+
return obj;
|
|
20
|
+
}
|
|
21
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
22
|
+
return {
|
|
23
|
+
default: obj
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
27
|
+
if (cache && cache.has(obj)) {
|
|
28
|
+
return cache.get(obj);
|
|
29
|
+
}
|
|
30
|
+
var newObj = {};
|
|
31
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
32
|
+
for(var key in obj){
|
|
33
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
34
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
35
|
+
if (desc && (desc.get || desc.set)) {
|
|
36
|
+
Object.defineProperty(newObj, key, desc);
|
|
37
|
+
} else {
|
|
38
|
+
newObj[key] = obj[key];
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
newObj.default = obj;
|
|
43
|
+
if (cache) {
|
|
44
|
+
cache.set(obj, newObj);
|
|
45
|
+
}
|
|
46
|
+
return newObj;
|
|
47
|
+
}
|
|
48
|
+
const SOURCE_PATH = _path.join(__dirname).replace(_path.join("lib", "__tests__"), _path.join("src", "__tests__"));
|
|
49
|
+
const TEST_PROJECT_PATH = _path.join(SOURCE_PATH, "testProject");
|
|
50
|
+
const NESTED_TEST_PROJECT_PATH = _path.join(SOURCE_PATH, "nestedTestProject");
|
|
33
51
|
const FileSystem = {
|
|
34
|
-
writeFile:
|
|
35
|
-
deleteFile:
|
|
52
|
+
writeFile: _fs.writeFileSync,
|
|
53
|
+
deleteFile: _fs.rmSync
|
|
36
54
|
};
|
|
37
|
-
describe(
|
|
38
|
-
it("can parse backslash-escaped filenames", ()
|
|
39
|
-
expect((0,
|
|
40
|
-
expect((0,
|
|
41
|
-
expect((0,
|
|
42
|
-
expect((0,
|
|
43
|
-
expect((0,
|
|
44
|
-
expect((0,
|
|
45
|
-
expect((0,
|
|
46
|
-
expect((0,
|
|
55
|
+
describe(_getPackageDeps.parseGitFilename.name, ()=>{
|
|
56
|
+
it("can parse backslash-escaped filenames", ()=>{
|
|
57
|
+
expect((0, _getPackageDeps.parseGitFilename)("some/path/to/a/file name")).toEqual("some/path/to/a/file name");
|
|
58
|
+
expect((0, _getPackageDeps.parseGitFilename)('"some/path/to/a/file?name"')).toEqual("some/path/to/a/file?name");
|
|
59
|
+
expect((0, _getPackageDeps.parseGitFilename)('"some/path/to/a/file\\\\name"')).toEqual("some/path/to/a/file\\name");
|
|
60
|
+
expect((0, _getPackageDeps.parseGitFilename)('"some/path/to/a/file\\"name"')).toEqual('some/path/to/a/file"name');
|
|
61
|
+
expect((0, _getPackageDeps.parseGitFilename)('"some/path/to/a/file\\"name"')).toEqual('some/path/to/a/file"name');
|
|
62
|
+
expect((0, _getPackageDeps.parseGitFilename)('"some/path/to/a/file\\347\\275\\221\\347\\275\\221name"')).toEqual("some/path/to/a/file网网name");
|
|
63
|
+
expect((0, _getPackageDeps.parseGitFilename)('"some/path/to/a/file\\\\347\\\\\\347\\275\\221name"')).toEqual("some/path/to/a/file\\347\\网name");
|
|
64
|
+
expect((0, _getPackageDeps.parseGitFilename)('"some/path/to/a/file\\\\\\347\\275\\221\\347\\275\\221name"')).toEqual("some/path/to/a/file\\网网name");
|
|
47
65
|
});
|
|
48
66
|
});
|
|
49
|
-
describe(
|
|
50
|
-
it("can handle a blob", ()
|
|
67
|
+
describe(_getPackageDeps.parseGitLsTree.name, ()=>{
|
|
68
|
+
it("can handle a blob", ()=>{
|
|
51
69
|
const filename = "src/typings/tsd.d.ts";
|
|
52
70
|
const hash = "3451bccdc831cb43d7a70ed8e628dcf9c7f888c8";
|
|
53
71
|
const output = `100644 blob ${hash}\t${filename}`;
|
|
54
|
-
const changes = (0,
|
|
72
|
+
const changes = (0, _getPackageDeps.parseGitLsTree)(output);
|
|
55
73
|
expect(changes.size).toEqual(1); // Expect there to be exactly 1 change
|
|
56
74
|
expect(changes.get(filename)).toEqual(hash); // Expect the hash to be ${hash}
|
|
57
75
|
});
|
|
58
|
-
it("can handle a submodule", ()
|
|
76
|
+
it("can handle a submodule", ()=>{
|
|
59
77
|
const filename = "rushstack";
|
|
60
78
|
const hash = "c5880bf5b0c6c1f2e2c43c95beeb8f0a808e8bac";
|
|
61
79
|
const output = `160000 commit ${hash}\t${filename}`;
|
|
62
|
-
const changes = (0,
|
|
80
|
+
const changes = (0, _getPackageDeps.parseGitLsTree)(output);
|
|
63
81
|
expect(changes.size).toEqual(1); // Expect there to be exactly 1 change
|
|
64
82
|
expect(changes.get(filename)).toEqual(hash); // Expect the hash to be ${hash}
|
|
65
83
|
});
|
|
66
|
-
it("can handle multiple lines", ()
|
|
84
|
+
it("can handle multiple lines", ()=>{
|
|
67
85
|
const filename1 = "src/typings/tsd.d.ts";
|
|
68
86
|
const hash1 = "3451bccdc831cb43d7a70ed8e628dcf9c7f888c8";
|
|
69
87
|
const filename2 = "src/foo bar/tsd.d.ts";
|
|
70
88
|
const hash2 = "0123456789abcdef1234567890abcdef01234567";
|
|
71
89
|
const output = `100644 blob ${hash1}\t${filename1}\n100666 blob ${hash2}\t${filename2}`;
|
|
72
|
-
const changes = (0,
|
|
90
|
+
const changes = (0, _getPackageDeps.parseGitLsTree)(output);
|
|
73
91
|
expect(changes.size).toEqual(2); // Expect there to be exactly 2 changes
|
|
74
92
|
expect(changes.get(filename1)).toEqual(hash1); // Expect the hash to be ${hash1}
|
|
75
93
|
expect(changes.get(filename2)).toEqual(hash2); // Expect the hash to be ${hash2}
|
|
76
94
|
});
|
|
77
|
-
it("throws with malformed input", ()
|
|
78
|
-
expect(
|
|
95
|
+
it("throws with malformed input", ()=>{
|
|
96
|
+
expect(_getPackageDeps.parseGitLsTree.bind(undefined, "some super malformed input")).toThrow();
|
|
79
97
|
});
|
|
80
98
|
});
|
|
81
|
-
describe(
|
|
82
|
-
it("can parse committed file", ()
|
|
83
|
-
const results = (0,
|
|
99
|
+
describe(_getPackageDeps.getPackageDeps.name, ()=>{
|
|
100
|
+
it("can parse committed file", ()=>{
|
|
101
|
+
const results = (0, _getPackageDeps.getPackageDeps)(TEST_PROJECT_PATH);
|
|
84
102
|
const expectedFiles = {
|
|
85
103
|
"file1.txt": "c7b2f707ac99ca522f965210a7b6b0b109863f34",
|
|
86
104
|
"file 2.txt": "a385f754ec4fede884a4864d090064d9aeef8ccb",
|
|
87
105
|
"file蝴蝶.txt": "ae814af81e16cb2ae8c57503c77e2cab6b5462ba",
|
|
88
|
-
"package.json": "18a1e415e56220fa5122428a4ef8eb8874756576"
|
|
106
|
+
"package.json": "18a1e415e56220fa5122428a4ef8eb8874756576"
|
|
89
107
|
};
|
|
90
108
|
const filePaths = Array.from(results.keys()).sort();
|
|
91
|
-
filePaths.forEach((filePath)
|
|
109
|
+
filePaths.forEach((filePath)=>expect(results.get(filePath)).toEqual(expectedFiles[filePath]));
|
|
92
110
|
});
|
|
93
|
-
it("can handle files in subfolders", ()
|
|
94
|
-
const results = (0,
|
|
111
|
+
it("can handle files in subfolders", ()=>{
|
|
112
|
+
const results = (0, _getPackageDeps.getPackageDeps)(NESTED_TEST_PROJECT_PATH);
|
|
95
113
|
const expectedFiles = {
|
|
96
114
|
"src/file 1.txt": "c7b2f707ac99ca522f965210a7b6b0b109863f34",
|
|
97
|
-
"package.json": "18a1e415e56220fa5122428a4ef8eb8874756576"
|
|
115
|
+
"package.json": "18a1e415e56220fa5122428a4ef8eb8874756576"
|
|
98
116
|
};
|
|
99
117
|
const filePaths = Array.from(results.keys()).sort();
|
|
100
|
-
filePaths.forEach((filePath)
|
|
118
|
+
filePaths.forEach((filePath)=>expect(results.get(filePath)).toEqual(expectedFiles[filePath]));
|
|
101
119
|
});
|
|
102
|
-
it("can handle adding one file", ()
|
|
103
|
-
const tempFilePath =
|
|
120
|
+
it("can handle adding one file", ()=>{
|
|
121
|
+
const tempFilePath = _path.join(TEST_PROJECT_PATH, "a.txt");
|
|
104
122
|
FileSystem.writeFile(tempFilePath, "a");
|
|
105
|
-
const results = (0,
|
|
123
|
+
const results = (0, _getPackageDeps.getPackageDeps)(TEST_PROJECT_PATH);
|
|
106
124
|
try {
|
|
107
125
|
const expectedFiles = {
|
|
108
126
|
"a.txt": "2e65efe2a145dda7ee51d1741299f848e5bf752e",
|
|
109
127
|
"file1.txt": "c7b2f707ac99ca522f965210a7b6b0b109863f34",
|
|
110
128
|
"file 2.txt": "a385f754ec4fede884a4864d090064d9aeef8ccb",
|
|
111
129
|
"file蝴蝶.txt": "ae814af81e16cb2ae8c57503c77e2cab6b5462ba",
|
|
112
|
-
"package.json": "18a1e415e56220fa5122428a4ef8eb8874756576"
|
|
130
|
+
"package.json": "18a1e415e56220fa5122428a4ef8eb8874756576"
|
|
113
131
|
};
|
|
114
132
|
const filePaths = Array.from(results.keys()).sort();
|
|
115
|
-
filePaths.forEach((filePath)
|
|
116
|
-
}
|
|
117
|
-
finally {
|
|
133
|
+
filePaths.forEach((filePath)=>expect(results.get(filePath)).toEqual(expectedFiles[filePath]));
|
|
134
|
+
} finally{
|
|
118
135
|
FileSystem.deleteFile(tempFilePath);
|
|
119
136
|
}
|
|
120
137
|
});
|
|
121
|
-
it("can handle adding two files", ()
|
|
122
|
-
const tempFilePath1 =
|
|
123
|
-
const tempFilePath2 =
|
|
138
|
+
it("can handle adding two files", ()=>{
|
|
139
|
+
const tempFilePath1 = _path.join(TEST_PROJECT_PATH, "a.txt");
|
|
140
|
+
const tempFilePath2 = _path.join(TEST_PROJECT_PATH, "b.txt");
|
|
124
141
|
FileSystem.writeFile(tempFilePath1, "a");
|
|
125
142
|
FileSystem.writeFile(tempFilePath2, "a");
|
|
126
|
-
const results = (0,
|
|
143
|
+
const results = (0, _getPackageDeps.getPackageDeps)(TEST_PROJECT_PATH);
|
|
127
144
|
try {
|
|
128
145
|
const expectedFiles = {
|
|
129
146
|
"a.txt": "2e65efe2a145dda7ee51d1741299f848e5bf752e",
|
|
@@ -131,157 +148,158 @@ describe(getPackageDeps_1.getPackageDeps.name, () => {
|
|
|
131
148
|
"file1.txt": "c7b2f707ac99ca522f965210a7b6b0b109863f34",
|
|
132
149
|
"file 2.txt": "a385f754ec4fede884a4864d090064d9aeef8ccb",
|
|
133
150
|
"file蝴蝶.txt": "ae814af81e16cb2ae8c57503c77e2cab6b5462ba",
|
|
134
|
-
"package.json": "18a1e415e56220fa5122428a4ef8eb8874756576"
|
|
151
|
+
"package.json": "18a1e415e56220fa5122428a4ef8eb8874756576"
|
|
135
152
|
};
|
|
136
153
|
const filePaths = Array.from(results.keys()).sort();
|
|
137
|
-
filePaths.forEach((filePath)
|
|
138
|
-
}
|
|
139
|
-
finally {
|
|
154
|
+
filePaths.forEach((filePath)=>expect(results.get(filePath)).toEqual(expectedFiles[filePath]));
|
|
155
|
+
} finally{
|
|
140
156
|
FileSystem.deleteFile(tempFilePath1);
|
|
141
157
|
FileSystem.deleteFile(tempFilePath2);
|
|
142
158
|
}
|
|
143
159
|
});
|
|
144
|
-
it("can handle removing one file", ()
|
|
145
|
-
const testFilePath =
|
|
160
|
+
it("can handle removing one file", ()=>{
|
|
161
|
+
const testFilePath = _path.join(TEST_PROJECT_PATH, "file1.txt");
|
|
146
162
|
FileSystem.deleteFile(testFilePath);
|
|
147
|
-
const results = (0,
|
|
163
|
+
const results = (0, _getPackageDeps.getPackageDeps)(TEST_PROJECT_PATH);
|
|
148
164
|
try {
|
|
149
165
|
const expectedFiles = {
|
|
150
166
|
"file 2.txt": "a385f754ec4fede884a4864d090064d9aeef8ccb",
|
|
151
167
|
"file蝴蝶.txt": "ae814af81e16cb2ae8c57503c77e2cab6b5462ba",
|
|
152
|
-
"package.json": "18a1e415e56220fa5122428a4ef8eb8874756576"
|
|
168
|
+
"package.json": "18a1e415e56220fa5122428a4ef8eb8874756576"
|
|
153
169
|
};
|
|
154
170
|
const filePaths = Array.from(results.keys()).sort();
|
|
155
|
-
filePaths.forEach((filePath)
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
|
|
171
|
+
filePaths.forEach((filePath)=>expect(results.get(filePath)).toEqual(expectedFiles[filePath]));
|
|
172
|
+
} finally{
|
|
173
|
+
(0, _childProcess.execSync)(`git checkout ${testFilePath}`, {
|
|
174
|
+
stdio: "ignore"
|
|
175
|
+
});
|
|
159
176
|
}
|
|
160
177
|
});
|
|
161
|
-
it("can handle changing one file", ()
|
|
162
|
-
const testFilePath =
|
|
178
|
+
it("can handle changing one file", ()=>{
|
|
179
|
+
const testFilePath = _path.join(TEST_PROJECT_PATH, "file1.txt");
|
|
163
180
|
FileSystem.writeFile(testFilePath, "abc");
|
|
164
|
-
const results = (0,
|
|
181
|
+
const results = (0, _getPackageDeps.getPackageDeps)(TEST_PROJECT_PATH);
|
|
165
182
|
try {
|
|
166
183
|
const expectedFiles = {
|
|
167
184
|
"file1.txt": "f2ba8f84ab5c1bce84a7b441cb1959cfc7093b7f",
|
|
168
185
|
"file 2.txt": "a385f754ec4fede884a4864d090064d9aeef8ccb",
|
|
169
186
|
"file蝴蝶.txt": "ae814af81e16cb2ae8c57503c77e2cab6b5462ba",
|
|
170
|
-
"package.json": "18a1e415e56220fa5122428a4ef8eb8874756576"
|
|
187
|
+
"package.json": "18a1e415e56220fa5122428a4ef8eb8874756576"
|
|
171
188
|
};
|
|
172
189
|
const filePaths = Array.from(results.keys()).sort();
|
|
173
|
-
filePaths.forEach((filePath)
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
|
|
190
|
+
filePaths.forEach((filePath)=>expect(results.get(filePath)).toEqual(expectedFiles[filePath]));
|
|
191
|
+
} finally{
|
|
192
|
+
(0, _childProcess.execSync)(`git checkout ${testFilePath}`, {
|
|
193
|
+
stdio: "ignore"
|
|
194
|
+
});
|
|
177
195
|
}
|
|
178
196
|
});
|
|
179
|
-
it("can exclude a committed file", ()
|
|
180
|
-
const results = (0,
|
|
197
|
+
it("can exclude a committed file", ()=>{
|
|
198
|
+
const results = (0, _getPackageDeps.getPackageDeps)(TEST_PROJECT_PATH, [
|
|
199
|
+
"file1.txt",
|
|
200
|
+
"file 2.txt",
|
|
201
|
+
"file蝴蝶.txt"
|
|
202
|
+
]);
|
|
181
203
|
const expectedFiles = {
|
|
182
|
-
"package.json": "18a1e415e56220fa5122428a4ef8eb8874756576"
|
|
204
|
+
"package.json": "18a1e415e56220fa5122428a4ef8eb8874756576"
|
|
183
205
|
};
|
|
184
206
|
const filePaths = Array.from(results.keys()).sort();
|
|
185
|
-
filePaths.forEach((filePath)
|
|
207
|
+
filePaths.forEach((filePath)=>expect(results.get(filePath)).toEqual(expectedFiles[filePath]));
|
|
186
208
|
});
|
|
187
|
-
it("can exclude an added file", ()
|
|
188
|
-
const tempFilePath =
|
|
209
|
+
it("can exclude an added file", ()=>{
|
|
210
|
+
const tempFilePath = _path.join(TEST_PROJECT_PATH, "a.txt");
|
|
189
211
|
FileSystem.writeFile(tempFilePath, "a");
|
|
190
|
-
const results = (0,
|
|
212
|
+
const results = (0, _getPackageDeps.getPackageDeps)(TEST_PROJECT_PATH, [
|
|
213
|
+
"a.txt"
|
|
214
|
+
]);
|
|
191
215
|
try {
|
|
192
216
|
const expectedFiles = {
|
|
193
217
|
"file1.txt": "c7b2f707ac99ca522f965210a7b6b0b109863f34",
|
|
194
218
|
"file 2.txt": "a385f754ec4fede884a4864d090064d9aeef8ccb",
|
|
195
219
|
"file蝴蝶.txt": "ae814af81e16cb2ae8c57503c77e2cab6b5462ba",
|
|
196
|
-
"package.json": "18a1e415e56220fa5122428a4ef8eb8874756576"
|
|
220
|
+
"package.json": "18a1e415e56220fa5122428a4ef8eb8874756576"
|
|
197
221
|
};
|
|
198
222
|
const filePaths = Array.from(results.keys()).sort();
|
|
199
223
|
expect(filePaths).toHaveLength(Object.keys(expectedFiles).length);
|
|
200
|
-
filePaths.forEach((filePath)
|
|
201
|
-
}
|
|
202
|
-
finally {
|
|
224
|
+
filePaths.forEach((filePath)=>expect(results.get(filePath)).toEqual(expectedFiles[filePath]));
|
|
225
|
+
} finally{
|
|
203
226
|
FileSystem.deleteFile(tempFilePath);
|
|
204
227
|
}
|
|
205
228
|
});
|
|
206
|
-
it("can handle a filename with spaces", ()
|
|
207
|
-
const tempFilePath =
|
|
229
|
+
it("can handle a filename with spaces", ()=>{
|
|
230
|
+
const tempFilePath = _path.join(TEST_PROJECT_PATH, "a file.txt");
|
|
208
231
|
FileSystem.writeFile(tempFilePath, "a");
|
|
209
|
-
const results = (0,
|
|
232
|
+
const results = (0, _getPackageDeps.getPackageDeps)(TEST_PROJECT_PATH);
|
|
210
233
|
try {
|
|
211
234
|
const expectedFiles = {
|
|
212
235
|
"file1.txt": "c7b2f707ac99ca522f965210a7b6b0b109863f34",
|
|
213
236
|
"file 2.txt": "a385f754ec4fede884a4864d090064d9aeef8ccb",
|
|
214
237
|
"file蝴蝶.txt": "ae814af81e16cb2ae8c57503c77e2cab6b5462ba",
|
|
215
238
|
"a file.txt": "2e65efe2a145dda7ee51d1741299f848e5bf752e",
|
|
216
|
-
"package.json": "18a1e415e56220fa5122428a4ef8eb8874756576"
|
|
239
|
+
"package.json": "18a1e415e56220fa5122428a4ef8eb8874756576"
|
|
217
240
|
};
|
|
218
241
|
const filePaths = Array.from(results.keys()).sort();
|
|
219
242
|
expect(filePaths).toHaveLength(Object.keys(expectedFiles).length);
|
|
220
|
-
filePaths.forEach((filePath)
|
|
221
|
-
}
|
|
222
|
-
finally {
|
|
243
|
+
filePaths.forEach((filePath)=>expect(results.get(filePath)).toEqual(expectedFiles[filePath]));
|
|
244
|
+
} finally{
|
|
223
245
|
FileSystem.deleteFile(tempFilePath);
|
|
224
246
|
}
|
|
225
247
|
});
|
|
226
|
-
it("can handle a filename with multiple spaces", ()
|
|
227
|
-
const tempFilePath =
|
|
248
|
+
it("can handle a filename with multiple spaces", ()=>{
|
|
249
|
+
const tempFilePath = _path.join(TEST_PROJECT_PATH, "a file name.txt");
|
|
228
250
|
FileSystem.writeFile(tempFilePath, "a");
|
|
229
|
-
const results = (0,
|
|
251
|
+
const results = (0, _getPackageDeps.getPackageDeps)(TEST_PROJECT_PATH);
|
|
230
252
|
try {
|
|
231
253
|
const expectedFiles = {
|
|
232
254
|
"file1.txt": "c7b2f707ac99ca522f965210a7b6b0b109863f34",
|
|
233
255
|
"file 2.txt": "a385f754ec4fede884a4864d090064d9aeef8ccb",
|
|
234
256
|
"file蝴蝶.txt": "ae814af81e16cb2ae8c57503c77e2cab6b5462ba",
|
|
235
257
|
"a file name.txt": "2e65efe2a145dda7ee51d1741299f848e5bf752e",
|
|
236
|
-
"package.json": "18a1e415e56220fa5122428a4ef8eb8874756576"
|
|
258
|
+
"package.json": "18a1e415e56220fa5122428a4ef8eb8874756576"
|
|
237
259
|
};
|
|
238
260
|
const filePaths = Array.from(results.keys()).sort();
|
|
239
261
|
expect(filePaths).toHaveLength(Object.keys(expectedFiles).length);
|
|
240
|
-
filePaths.forEach((filePath)
|
|
241
|
-
}
|
|
242
|
-
finally {
|
|
262
|
+
filePaths.forEach((filePath)=>expect(results.get(filePath)).toEqual(expectedFiles[filePath]));
|
|
263
|
+
} finally{
|
|
243
264
|
FileSystem.deleteFile(tempFilePath);
|
|
244
265
|
}
|
|
245
266
|
});
|
|
246
|
-
it("can handle a filename with non-standard characters", ()
|
|
247
|
-
const tempFilePath =
|
|
267
|
+
it("can handle a filename with non-standard characters", ()=>{
|
|
268
|
+
const tempFilePath = _path.join(TEST_PROJECT_PATH, "newFile批把.txt");
|
|
248
269
|
FileSystem.writeFile(tempFilePath, "a");
|
|
249
|
-
const results = (0,
|
|
270
|
+
const results = (0, _getPackageDeps.getPackageDeps)(TEST_PROJECT_PATH);
|
|
250
271
|
try {
|
|
251
272
|
const expectedFiles = {
|
|
252
273
|
"file1.txt": "c7b2f707ac99ca522f965210a7b6b0b109863f34",
|
|
253
274
|
"file 2.txt": "a385f754ec4fede884a4864d090064d9aeef8ccb",
|
|
254
275
|
"file蝴蝶.txt": "ae814af81e16cb2ae8c57503c77e2cab6b5462ba",
|
|
255
276
|
"newFile批把.txt": "2e65efe2a145dda7ee51d1741299f848e5bf752e",
|
|
256
|
-
"package.json": "18a1e415e56220fa5122428a4ef8eb8874756576"
|
|
277
|
+
"package.json": "18a1e415e56220fa5122428a4ef8eb8874756576"
|
|
257
278
|
};
|
|
258
279
|
const filePaths = Array.from(results.keys()).sort();
|
|
259
280
|
expect(filePaths).toHaveLength(Object.keys(expectedFiles).length);
|
|
260
|
-
filePaths.forEach((filePath)
|
|
261
|
-
}
|
|
262
|
-
finally {
|
|
281
|
+
filePaths.forEach((filePath)=>expect(results.get(filePath)).toEqual(expectedFiles[filePath]));
|
|
282
|
+
} finally{
|
|
263
283
|
FileSystem.deleteFile(tempFilePath);
|
|
264
284
|
}
|
|
265
285
|
});
|
|
266
|
-
it("can handle a filename with non-standard characters", ()
|
|
267
|
-
const tempFilePath =
|
|
286
|
+
it("can handle a filename with non-standard characters", ()=>{
|
|
287
|
+
const tempFilePath = _path.join(TEST_PROJECT_PATH, "newFile批把.txt");
|
|
268
288
|
FileSystem.writeFile(tempFilePath, "a");
|
|
269
|
-
const results = (0,
|
|
289
|
+
const results = (0, _getPackageDeps.getPackageDeps)(TEST_PROJECT_PATH);
|
|
270
290
|
try {
|
|
271
291
|
const expectedFiles = {
|
|
272
292
|
"file1.txt": "c7b2f707ac99ca522f965210a7b6b0b109863f34",
|
|
273
293
|
"file 2.txt": "a385f754ec4fede884a4864d090064d9aeef8ccb",
|
|
274
294
|
"file蝴蝶.txt": "ae814af81e16cb2ae8c57503c77e2cab6b5462ba",
|
|
275
295
|
"newFile批把.txt": "2e65efe2a145dda7ee51d1741299f848e5bf752e",
|
|
276
|
-
"package.json": "18a1e415e56220fa5122428a4ef8eb8874756576"
|
|
296
|
+
"package.json": "18a1e415e56220fa5122428a4ef8eb8874756576"
|
|
277
297
|
};
|
|
278
298
|
const filePaths = Array.from(results.keys()).sort();
|
|
279
299
|
expect(filePaths).toHaveLength(Object.keys(expectedFiles).length);
|
|
280
|
-
filePaths.forEach((filePath)
|
|
281
|
-
}
|
|
282
|
-
finally {
|
|
300
|
+
filePaths.forEach((filePath)=>expect(results.get(filePath)).toEqual(expectedFiles[filePath]));
|
|
301
|
+
} finally{
|
|
283
302
|
FileSystem.deleteFile(tempFilePath);
|
|
284
303
|
}
|
|
285
304
|
});
|
|
286
305
|
});
|
|
287
|
-
//# sourceMappingURL=getPackageDeps.test.js.map
|