@zeroheight/adoption-cli 0.4.4 → 1.1.0
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.md +24 -0
- package/README.md +49 -10
- package/dist/cli.js +6 -4
- package/dist/commands/monitor-repo.d.ts +9 -0
- package/dist/commands/monitor-repo.js +36 -0
- package/dist/commands/monitor-repo.utils.d.ts +31 -0
- package/dist/commands/monitor-repo.utils.js +81 -0
- package/dist/commands/track-package.d.ts +5 -1
- package/dist/commands/track-package.js +15 -5
- package/dist/commands/track-package.utils.d.ts +8 -14
- package/dist/commands/track-package.utils.js +24 -15
- package/dist/common/api.d.ts +30 -2
- package/dist/common/api.js +13 -1
- package/dist/common/types/package-file.d.ts +8 -0
- package/dist/common/types/package-file.js +1 -0
- package/dist/components/analyze/analyze.js +16 -3
- package/dist/components/auth/auth.js +16 -2
- package/dist/components/auth/no-credentials-onboarding.d.ts +2 -1
- package/dist/components/auth/no-credentials-onboarding.js +13 -3
- package/dist/components/monitor-repo/monitor-repo.d.ts +2 -0
- package/dist/components/monitor-repo/monitor-repo.js +9 -0
- package/dist/components/monitor-repo/non-interactive-monitor-repo.d.ts +6 -0
- package/dist/components/monitor-repo/non-interactive-monitor-repo.js +112 -0
- package/dist/components/track-package/non-interactive-track-package.d.ts +2 -0
- package/dist/components/track-package/non-interactive-track-package.js +113 -0
- package/dist/components/track-package/track-package.js +119 -11
- package/dist/lockfile-parsers/lock-parser.d.ts +9 -0
- package/dist/lockfile-parsers/lock-parser.js +5 -0
- package/dist/lockfile-parsers/npm-lock-parser.d.ts +6 -0
- package/dist/lockfile-parsers/npm-lock-parser.js +54 -0
- package/dist/lockfile-parsers/pnpm-lock-parser.d.ts +6 -0
- package/dist/lockfile-parsers/pnpm-lock-parser.js +45 -0
- package/dist/lockfile-parsers/yarn-lock-parser.d.ts +6 -0
- package/dist/lockfile-parsers/yarn-lock-parser.js +67 -0
- package/package.json +7 -4
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
2
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
3
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
4
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
|
+
};
|
|
6
|
+
var _YarnLockParser_instances, _YarnLockParser_parseV1, _YarnLockParser_parseV4, _YarnLockParser_sanitizeName;
|
|
7
|
+
import { parse as parseYAML } from "yaml";
|
|
8
|
+
import { LockParser } from "./lock-parser.js";
|
|
9
|
+
class YarnLockParser extends LockParser {
|
|
10
|
+
constructor(lockContent) {
|
|
11
|
+
super();
|
|
12
|
+
_YarnLockParser_instances.add(this);
|
|
13
|
+
Object.defineProperty(this, "packages", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
configurable: true,
|
|
16
|
+
writable: true,
|
|
17
|
+
value: void 0
|
|
18
|
+
});
|
|
19
|
+
this.packages = [];
|
|
20
|
+
try {
|
|
21
|
+
const data = parseYAML(lockContent);
|
|
22
|
+
// All version >= 4 use a consistent format
|
|
23
|
+
if (data.__metadata) {
|
|
24
|
+
const packageData = { ...data };
|
|
25
|
+
delete packageData?.__metadata;
|
|
26
|
+
this.packages = __classPrivateFieldGet(this, _YarnLockParser_instances, "m", _YarnLockParser_parseV4).call(this, packageData);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
// V1 doesn't use real YAML syntax so wait until error trhown before default to V1
|
|
31
|
+
this.packages = __classPrivateFieldGet(this, _YarnLockParser_instances, "m", _YarnLockParser_parseV1).call(this, lockContent);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
_YarnLockParser_instances = new WeakSet(), _YarnLockParser_parseV1 = function _YarnLockParser_parseV1(rawContent) {
|
|
36
|
+
const groups = rawContent
|
|
37
|
+
.split("\n\n") // Split into groups
|
|
38
|
+
.filter((group) => !group.startsWith("#")) // Remove line-level comments
|
|
39
|
+
.map((group) => group.trimStart()); // Cleanup leading newlines
|
|
40
|
+
const nameMatcher = /[^"\s](\S+)(?<!")(?=@)/gi;
|
|
41
|
+
const versionMatcher = /(?<=")(.+)(?<!")/gi; // Pull out value in quotes
|
|
42
|
+
return groups.reduce((packages, group) => {
|
|
43
|
+
const lines = group.split("\n").map((line) => line.trim());
|
|
44
|
+
const name = lines
|
|
45
|
+
.at(0) // Name should be the first line
|
|
46
|
+
?.match(nameMatcher)?.[0]
|
|
47
|
+
?.replace('"', ""); // Remove quotes if present
|
|
48
|
+
const version = lines
|
|
49
|
+
.slice(1) // Properties are from line 1 onwards
|
|
50
|
+
.find((line) => line.startsWith("version"))
|
|
51
|
+
?.match(versionMatcher)?.[0];
|
|
52
|
+
if (name && version) {
|
|
53
|
+
return packages.concat([{ name, version }]);
|
|
54
|
+
}
|
|
55
|
+
return packages;
|
|
56
|
+
}, []);
|
|
57
|
+
}, _YarnLockParser_parseV4 = function _YarnLockParser_parseV4(data) {
|
|
58
|
+
return Object.entries(data)
|
|
59
|
+
.map(([key, properties]) => ({
|
|
60
|
+
name: __classPrivateFieldGet(this, _YarnLockParser_instances, "m", _YarnLockParser_sanitizeName).call(this, key),
|
|
61
|
+
version: properties.version.toString(),
|
|
62
|
+
}))
|
|
63
|
+
.filter((p) => p.name);
|
|
64
|
+
}, _YarnLockParser_sanitizeName = function _YarnLockParser_sanitizeName(name) {
|
|
65
|
+
return name.split("@").at(0);
|
|
66
|
+
};
|
|
67
|
+
export default YarnLockParser;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeroheight/adoption-cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"main": "dist/cli.js",
|
|
6
6
|
"bin": {
|
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
"cleanup": "rm -rf dist",
|
|
15
15
|
"setup": "npm run build && npm i -g",
|
|
16
16
|
"start": "node dist/cli.js",
|
|
17
|
-
"start-dev": "export NODE_ENV=dev &&
|
|
17
|
+
"start-dev": "export NODE_ENV=dev && node dist/cli.js",
|
|
18
18
|
"build": "tsc",
|
|
19
19
|
"dev": "tsc --watch",
|
|
20
|
-
"lint": "prettier .",
|
|
20
|
+
"lint": "prettier --write .",
|
|
21
21
|
"test": "vitest"
|
|
22
22
|
},
|
|
23
23
|
"files": [
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"glob": "^10.3.15",
|
|
33
33
|
"ignore": "^5.3.1",
|
|
34
34
|
"ink": "^5.0.0",
|
|
35
|
+
"ink-checkbox": "^1.0.12",
|
|
35
36
|
"ink-link": "^4.1.0",
|
|
36
37
|
"ink-render-string": "^1.0.0",
|
|
37
38
|
"ink-select-input": "^6.0.0",
|
|
@@ -39,6 +40,7 @@
|
|
|
39
40
|
"ink-text-input": "^6.0.0",
|
|
40
41
|
"oxc-parser": "^0.22.0",
|
|
41
42
|
"react": "^18.2.0",
|
|
43
|
+
"yaml": "^2.5.1",
|
|
42
44
|
"yn": "^5.0.0"
|
|
43
45
|
},
|
|
44
46
|
"devDependencies": {
|
|
@@ -47,6 +49,7 @@
|
|
|
47
49
|
"@typescript-eslint/eslint-plugin": "^7.7.1",
|
|
48
50
|
"@typescript-eslint/parser": "^7.7.1",
|
|
49
51
|
"@vdemedes/prettier-config": "^2.0.1",
|
|
52
|
+
"@vitest/coverage-v8": "^2.1.2",
|
|
50
53
|
"eslint-plugin-react": "^7.32.2",
|
|
51
54
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
52
55
|
"ink-testing-library": "^4.0.0",
|
|
@@ -55,7 +58,7 @@
|
|
|
55
58
|
"prettier": "^2.8.8",
|
|
56
59
|
"ts-node": "^10.9.1",
|
|
57
60
|
"typescript": "^5.4.5",
|
|
58
|
-
"vitest": "^1.
|
|
61
|
+
"vitest": "^2.1.2"
|
|
59
62
|
},
|
|
60
63
|
"types": "./dist/cli.d.ts",
|
|
61
64
|
"description": "CLI for measuring component usage",
|