workspace-tools 0.18.1 → 0.18.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
CHANGED
|
@@ -2,7 +2,22 @@
|
|
|
2
2
|
"name": "workspace-tools",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "Fri, 07 Jan 2022
|
|
5
|
+
"date": "Fri, 07 Jan 2022 18:15:30 GMT",
|
|
6
|
+
"tag": "workspace-tools_v0.18.2",
|
|
7
|
+
"version": "0.18.2",
|
|
8
|
+
"comments": {
|
|
9
|
+
"patch": [
|
|
10
|
+
{
|
|
11
|
+
"author": "riacarmin@microsoft.com",
|
|
12
|
+
"package": "workspace-tools",
|
|
13
|
+
"comment": "Makes the output of parseLockFile for npm v7+ lock file compatible with queryLockFile.",
|
|
14
|
+
"commit": "caf984c0c569579a316c4cec9808a63a744abb09"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"date": "Fri, 07 Jan 2022 17:07:22 GMT",
|
|
6
21
|
"tag": "workspace-tools_v0.18.1",
|
|
7
22
|
"version": "0.18.1",
|
|
8
23
|
"comments": {
|
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
# Change Log - workspace-tools
|
|
2
2
|
|
|
3
|
-
This log was last generated on Fri, 07 Jan 2022
|
|
3
|
+
This log was last generated on Fri, 07 Jan 2022 18:15:30 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 0.18.2
|
|
8
|
+
|
|
9
|
+
Fri, 07 Jan 2022 18:15:30 GMT
|
|
10
|
+
|
|
11
|
+
### Patches
|
|
12
|
+
|
|
13
|
+
- Makes the output of parseLockFile for npm v7+ lock file compatible with queryLockFile. (riacarmin@microsoft.com)
|
|
14
|
+
|
|
7
15
|
## 0.18.1
|
|
8
16
|
|
|
9
|
-
Fri, 07 Jan 2022 17:07:
|
|
17
|
+
Fri, 07 Jan 2022 17:07:22 GMT
|
|
10
18
|
|
|
11
19
|
### Patches
|
|
12
20
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const setupFixture_1 = require("../helpers/setupFixture");
|
|
4
|
+
const __1 = require("..");
|
|
5
|
+
/**
|
|
6
|
+
* These tests rely on the "@microsoft/task-scheduler" package and its version as defined in package.json in
|
|
7
|
+
* fixtures:
|
|
8
|
+
* - monorepo-npm
|
|
9
|
+
* - basic-yarn
|
|
10
|
+
* - monorepo-pnpm
|
|
11
|
+
*
|
|
12
|
+
* If making any changes to those fixtures and "@microsoft/task-scheduler" dependency, update the `packageName` and
|
|
13
|
+
* `packageVersion` constants.
|
|
14
|
+
*/
|
|
15
|
+
const packageName = "@microsoft/task-scheduler";
|
|
16
|
+
const packageVersion = "2.7.1";
|
|
17
|
+
describe("queryLockFile()", () => {
|
|
18
|
+
// NPM
|
|
19
|
+
it("retrieves a dependency from a lock generated by npm", async () => {
|
|
20
|
+
const packageRoot = await (0, setupFixture_1.setupFixture)("monorepo-npm");
|
|
21
|
+
const parsedLockFile = await (0, __1.parseLockFile)(packageRoot);
|
|
22
|
+
const result = (0, __1.queryLockFile)(packageName, packageVersion, parsedLockFile);
|
|
23
|
+
expect(result).toBeDefined();
|
|
24
|
+
expect(result.version).toBe(packageVersion);
|
|
25
|
+
});
|
|
26
|
+
// Yarn
|
|
27
|
+
it("retrieves a dependency from a lock generated by yarn", async () => {
|
|
28
|
+
const packageRoot = await (0, setupFixture_1.setupFixture)("basic-yarn");
|
|
29
|
+
const parsedLockFile = await (0, __1.parseLockFile)(packageRoot);
|
|
30
|
+
// NOTE: Yarn’s locks include ranges.
|
|
31
|
+
const result = (0, __1.queryLockFile)(packageName, `^${packageVersion}`, parsedLockFile);
|
|
32
|
+
expect(result).toBeDefined();
|
|
33
|
+
expect(result.version).toBe(packageVersion);
|
|
34
|
+
});
|
|
35
|
+
// PNPM
|
|
36
|
+
it("retrieves a dependency from a lock generated by pnpm", async () => {
|
|
37
|
+
const packageRoot = await (0, setupFixture_1.setupFixture)("monorepo-pnpm");
|
|
38
|
+
const parsedLockFile = await (0, __1.parseLockFile)(packageRoot);
|
|
39
|
+
const result = (0, __1.queryLockFile)(packageName, packageVersion, parsedLockFile);
|
|
40
|
+
expect(result).toBeDefined();
|
|
41
|
+
expect(result.version).toBe(packageVersion);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseNpmLock = void 0;
|
|
4
|
+
const nameAtVersion_1 = require("./nameAtVersion");
|
|
5
|
+
/**
|
|
6
|
+
* formatNpmLock reformats the dependencies object, so the key includes the version, similarly to yarn.lock. For
|
|
7
|
+
* example, `"@microsoft/task-scheduler": { }` will become `"@microsoft/task-scheduler@2.7.1": { }`.
|
|
8
|
+
*/
|
|
9
|
+
const formatNpmLock = (previousValue, currentValue) => {
|
|
10
|
+
const [key, dependency] = currentValue;
|
|
11
|
+
previousValue[(0, nameAtVersion_1.nameAtVersion)(key, dependency.version)] = dependency;
|
|
12
|
+
return previousValue;
|
|
13
|
+
};
|
|
4
14
|
const parseNpmLock = (lock) => {
|
|
5
15
|
var _a;
|
|
6
|
-
|
|
7
|
-
|
|
16
|
+
const dependencies = Object.entries((_a = lock.dependencies) !== null && _a !== void 0 ? _a : {}).reduce(formatNpmLock, {});
|
|
17
|
+
return {
|
|
18
|
+
object: dependencies,
|
|
8
19
|
type: "success",
|
|
9
|
-
}
|
|
20
|
+
};
|
|
10
21
|
};
|
|
11
22
|
exports.parseNpmLock = parseNpmLock;
|