@yarn-tool/npa-to-deps 1.0.1
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 +11 -0
- package/README.md +12 -0
- package/index.d.ts +22 -0
- package/index.js +78 -0
- package/index.js.map +1 -0
- package/package.json +59 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
## 1.0.1 (2021-11-23)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### đŸ”–ă€€Miscellaneous
|
|
10
|
+
|
|
11
|
+
* `@yarn-tool/npa-to-deps-query` ([c288090](https://github.com/bluelovers/ws-yarn-workspaces/commit/c2880907ca72c74307f093e503e3d10d21778e01))
|
package/README.md
ADDED
package/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { IResult } from '@yarn-tool/npm-package-arg-util';
|
|
2
|
+
export interface IOptions {
|
|
3
|
+
where?: string;
|
|
4
|
+
/**
|
|
5
|
+
* when input is tag, preserve it
|
|
6
|
+
*/
|
|
7
|
+
preserveTag?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* when input is range, preserve it
|
|
10
|
+
*/
|
|
11
|
+
preserveRange?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface IDepsResult<T extends IResult = IResult> {
|
|
14
|
+
name: string;
|
|
15
|
+
semver?: string;
|
|
16
|
+
operator?: string;
|
|
17
|
+
fetchQuery?: boolean;
|
|
18
|
+
result: T;
|
|
19
|
+
}
|
|
20
|
+
export declare function npaResultToDepsValue<T extends IResult>(result: T, options?: IOptions): IDepsResult<T>;
|
|
21
|
+
export declare function npaToDepsValue<T extends IResult = IResult>(arg: string, options?: IOptions): IDepsResult<T>;
|
|
22
|
+
export default npaToDepsValue;
|
package/index.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.npaToDepsValue = exports.npaResultToDepsValue = void 0;
|
|
4
|
+
const npm_package_arg_util_1 = require("@yarn-tool/npm-package-arg-util");
|
|
5
|
+
const parseSimpleSemVerRange_1 = require("@lazy-node/semver-simple-parse/lib/parseSimpleSemVerRange");
|
|
6
|
+
function npaResultToDepsValue(result, options) {
|
|
7
|
+
var _a, _b, _c;
|
|
8
|
+
let semver;
|
|
9
|
+
let operator;
|
|
10
|
+
let fetchQuery;
|
|
11
|
+
switch (result.type) {
|
|
12
|
+
case 'git':
|
|
13
|
+
semver = result.saveSpec;
|
|
14
|
+
break;
|
|
15
|
+
case 'tag':
|
|
16
|
+
if (((_a = result.fetchSpec) === null || _a === void 0 ? void 0 : _a.length) && (options === null || options === void 0 ? void 0 : options.preserveTag)) {
|
|
17
|
+
semver = result.fetchSpec;
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
operator = '^';
|
|
21
|
+
fetchQuery = true;
|
|
22
|
+
}
|
|
23
|
+
break;
|
|
24
|
+
case 'range':
|
|
25
|
+
if ((_b = result.fetchSpec) === null || _b === void 0 ? void 0 : _b.length) {
|
|
26
|
+
let ls = (0, parseSimpleSemVerRange_1.parseSimpleSemVerRange)(result.fetchSpec);
|
|
27
|
+
if (ls.length > 1) {
|
|
28
|
+
semver = result.fetchSpec;
|
|
29
|
+
}
|
|
30
|
+
else if (options === null || options === void 0 ? void 0 : options.preserveRange) {
|
|
31
|
+
semver = result.fetchSpec;
|
|
32
|
+
}
|
|
33
|
+
else if (ls.length === 1) {
|
|
34
|
+
let entry = ls[0];
|
|
35
|
+
if (!entry.operator) {
|
|
36
|
+
semver = result.fetchSpec;
|
|
37
|
+
fetchQuery = true;
|
|
38
|
+
}
|
|
39
|
+
else if (entry.operator !== '^') {
|
|
40
|
+
semver = result.fetchSpec;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
operator = '^';
|
|
44
|
+
fetchQuery = true;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
operator = '^';
|
|
49
|
+
fetchQuery = true;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
operator = '^';
|
|
54
|
+
fetchQuery = true;
|
|
55
|
+
}
|
|
56
|
+
break;
|
|
57
|
+
default:
|
|
58
|
+
if ((_c = result.fetchSpec) === null || _c === void 0 ? void 0 : _c.length) {
|
|
59
|
+
semver = result.fetchSpec;
|
|
60
|
+
}
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
name: result.name,
|
|
65
|
+
semver,
|
|
66
|
+
operator,
|
|
67
|
+
fetchQuery,
|
|
68
|
+
result,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
exports.npaResultToDepsValue = npaResultToDepsValue;
|
|
72
|
+
function npaToDepsValue(arg, options) {
|
|
73
|
+
let result = (0, npm_package_arg_util_1.npa)(arg, options === null || options === void 0 ? void 0 : options.where);
|
|
74
|
+
return npaResultToDepsValue(result);
|
|
75
|
+
}
|
|
76
|
+
exports.npaToDepsValue = npaToDepsValue;
|
|
77
|
+
exports.default = npaToDepsValue;
|
|
78
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;AAAA,0EAA+D;AAC/D,sGAAmG;AAyBnG,SAAgB,oBAAoB,CAAoB,MAAS,EAAE,OAAkB;;IAEpF,IAAI,MAAc,CAAC;IACnB,IAAI,QAAgB,CAAC;IACrB,IAAI,UAAmB,CAAC;IAExB,QAAQ,MAAM,CAAC,IAAI,EACnB;QACC,KAAK,KAAK;YACT,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAA;YACxB,MAAM;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AS,0CAAE,MAAM,EAC5B;gBACC,MAAM,GAAG,MAAM,CAAC,SAAS,CAAA;aACzB;YAED,MAAM;KACP;IAED,OAAO;QACN,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,MAAM;QACN,QAAQ;QACR,UAAU;QACV,MAAM;KACN,CAAA;AACF,CAAC;AAtFD,oDAsFC;AAED,SAAgB,cAAc,CAA8B,GAAW,EAAE,OAAkB;IAE1F,IAAI,MAAM,GAAG,IAAA,0BAAG,EAAC,GAAG,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK,CAAC,CAAC;IAEtC,OAAO,oBAAoB,CAAI,MAAa,CAAC,CAAA;AAC9C,CAAC;AALD,wCAKC;AAED,kBAAe,cAAc,CAAA","sourcesContent":["import { IResult, npa } from '@yarn-tool/npm-package-arg-util';\nimport { parseSimpleSemVerRange } from '@lazy-node/semver-simple-parse/lib/parseSimpleSemVerRange';\n\nexport interface IOptions\n{\n\twhere?: string,\n\t/**\n\t * when input is tag, preserve it\n\t */\n\tpreserveTag?: boolean,\n\n\t/**\n\t * when input is range, preserve it\n\t */\n\tpreserveRange?: boolean,\n}\n\nexport interface IDepsResult<T extends IResult = IResult>\n{\n name: string;\n semver?: string;\n operator?: string;\n fetchQuery?: boolean;\n result: T;\n}\n\nexport function npaResultToDepsValue<T extends IResult>(result: T, options?: IOptions): IDepsResult<T>\n{\n\tlet semver: string;\n\tlet operator: string;\n\tlet fetchQuery: boolean;\n\n\tswitch (result.type)\n\t{\n\t\tcase 'git':\n\t\t\tsemver = result.saveSpec\n\t\t\tbreak;\n\t\tcase 'tag':\n\t\t\tif (result.fetchSpec?.length && options?.preserveTag)\n\t\t\t{\n\t\t\t\tsemver = result.fetchSpec\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\toperator = '^';\n\t\t\t\tfetchQuery = true;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase 'range':\n\n\t\t\tif (result.fetchSpec?.length)\n\t\t\t{\n\t\t\t\tlet ls = parseSimpleSemVerRange(result.fetchSpec);\n\n\t\t\t\tif (ls.length > 1)\n\t\t\t\t{\n\t\t\t\t\tsemver = result.fetchSpec\n\t\t\t\t}\n\t\t\t\telse if (options?.preserveRange)\n\t\t\t\t{\n\t\t\t\t\tsemver = result.fetchSpec\n\t\t\t\t}\n\t\t\t\telse if (ls.length === 1)\n\t\t\t\t{\n\t\t\t\t\tlet entry = ls[0];\n\n\t\t\t\t\tif (!entry.operator)\n\t\t\t\t\t{\n\t\t\t\t\t\tsemver = result.fetchSpec\n\t\t\t\t\t\tfetchQuery = true;\n\t\t\t\t\t}\n\t\t\t\t\telse if (entry.operator !== '^')\n\t\t\t\t\t{\n\t\t\t\t\t\tsemver = result.fetchSpec\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\toperator = '^';\n\t\t\t\t\t\tfetchQuery = true;\n\t\t\t\t\t}\n\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\toperator = '^';\n\t\t\t\t\tfetchQuery = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\toperator = '^';\n\t\t\t\tfetchQuery = true;\n\t\t\t}\n\n\t\t\tbreak;\n\t\tdefault:\n\n\t\t\tif (result.fetchSpec?.length)\n\t\t\t{\n\t\t\t\tsemver = result.fetchSpec\n\t\t\t}\n\n\t\t\tbreak;\n\t}\n\n\treturn {\n\t\tname: result.name,\n\t\tsemver,\n\t\toperator,\n\t\tfetchQuery,\n\t\tresult,\n\t}\n}\n\nexport function npaToDepsValue<T extends IResult = IResult>(arg: string, options?: IOptions)\n{\n\tlet result = npa(arg, options?.where);\n\n\treturn npaResultToDepsValue<T>(result as any)\n}\n\nexport default npaToDepsValue\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@yarn-tool/npa-to-deps",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"yarn",
|
|
7
|
+
"yarn-tool",
|
|
8
|
+
"npm",
|
|
9
|
+
"lerna",
|
|
10
|
+
"workspaces",
|
|
11
|
+
"pkg",
|
|
12
|
+
"dependencies",
|
|
13
|
+
"monorepo",
|
|
14
|
+
"yarnlock",
|
|
15
|
+
"node-modules",
|
|
16
|
+
"packages",
|
|
17
|
+
"package"
|
|
18
|
+
],
|
|
19
|
+
"homepage": "https://github.com/bluelovers/ws-yarn-workspaces/tree/master/packages/@yarn-tool/npa-to-deps#readme",
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "https://github.com/bluelovers/ws-yarn-workspaces/issues"
|
|
22
|
+
},
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "git+https://github.com/bluelovers/ws-yarn-workspaces.git"
|
|
26
|
+
},
|
|
27
|
+
"license": "ISC",
|
|
28
|
+
"author": "bluelovers",
|
|
29
|
+
"main": "index.js",
|
|
30
|
+
"scripts": {
|
|
31
|
+
"coverage": "yarn run test -- --coverage",
|
|
32
|
+
"lint": "ynpx --quiet eslint -- **/*.ts",
|
|
33
|
+
"test": "jest --passWithNoTests",
|
|
34
|
+
"test:jest": "jest --passWithNoTests",
|
|
35
|
+
"test:mocha": "ynpx --quiet -p ts-node -p mocha mocha -- --require ts-node/register \"!(node_modules)/**/*.{test,spec}.{ts,tsx}\"",
|
|
36
|
+
"preversion": "echo preversion && yarn run test",
|
|
37
|
+
"version": "echo version",
|
|
38
|
+
"postversion": "echo postversion",
|
|
39
|
+
"prepublish": "echo prepublish",
|
|
40
|
+
"prepublishOnly": "echo prepublishOnly",
|
|
41
|
+
"prepublishOnly:update": "yarn run ncu && yarn run sort-package-json",
|
|
42
|
+
"publish": "echo publish",
|
|
43
|
+
"postpublish": "echo postpublish",
|
|
44
|
+
"postpublishOnly": "echo postpublishOnly",
|
|
45
|
+
"ncu": "yarn-tool ncu -u",
|
|
46
|
+
"sort-package-json": "yarn-tool sort",
|
|
47
|
+
"tsc:showConfig": "ynpx get-current-tsconfig -p"
|
|
48
|
+
},
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"@lazy-node/semver-simple-parse": "^1.1.19",
|
|
51
|
+
"@yarn-tool/npm-package-arg-util": "^1.0.21",
|
|
52
|
+
"tslib": "^2.3.1"
|
|
53
|
+
},
|
|
54
|
+
"publishConfig": {
|
|
55
|
+
"access": "public"
|
|
56
|
+
},
|
|
57
|
+
"packageManager": "yarn@^1.22.11",
|
|
58
|
+
"gitHead": "131c97352e084d1e39cafded98b6bc967b7a9eee"
|
|
59
|
+
}
|