@yarn-tool/normalize-deps-value 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 +5 -0
- package/index.js +61 -0
- package/index.js.map +1 -0
- package/package.json +80 -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 (2022-08-15)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### đŸ”–ă€€Miscellaneous
|
|
10
|
+
|
|
11
|
+
* @yarn-tool/normalize-deps-value ([b7e64fc](https://github.com/bluelovers/ws-yarn-workspaces/commit/b7e64fc829d14688017657797237ebb239556097))
|
package/README.md
ADDED
package/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { IResult } from '@yarn-tool/npm-package-arg-util';
|
|
2
|
+
export declare function normalizeResultToDepsValue(result: ReturnType<typeof _getNpaResult>): string;
|
|
3
|
+
export declare function _getNpaResult(value: string): IResult;
|
|
4
|
+
export declare function normalizeDepsValue(value: string): string;
|
|
5
|
+
export default normalizeDepsValue;
|
package/index.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeDepsValue = exports._getNpaResult = exports.normalizeResultToDepsValue = void 0;
|
|
4
|
+
const npm_package_arg_util_1 = require("@yarn-tool/npm-package-arg-util");
|
|
5
|
+
const buildRangeSet_1 = require("@lazy-node/semver-ampersand/lib/range/buildRangeSet");
|
|
6
|
+
const stringifyRangeSet_1 = require("@lazy-node/semver-ampersand/lib/range/stringifyRangeSet");
|
|
7
|
+
const toRangeString_1 = require("@lazy-node/semver-ampersand/lib/range/toRangeString");
|
|
8
|
+
const Range_1 = require("@lazy-node/semver-ampersand/lib/Range");
|
|
9
|
+
const FAKE_NAME = '@fake/fake';
|
|
10
|
+
function normalizeResultToDepsValue(result) {
|
|
11
|
+
let value;
|
|
12
|
+
if (typeof result === 'string') {
|
|
13
|
+
value = result;
|
|
14
|
+
}
|
|
15
|
+
else if (result) {
|
|
16
|
+
if (result.type === 'range') {
|
|
17
|
+
const rangeSet = (0, buildRangeSet_1.buildRangeSet)(result.rawSpec);
|
|
18
|
+
value = (0, toRangeString_1.toRangeString)((0, stringifyRangeSet_1.stringifyRangeSet)(rangeSet));
|
|
19
|
+
}
|
|
20
|
+
else if (result.type === 'tag' && result.rawSpec === "" /* EnumSemverVersion.ANY */ && result.raw !== `${FAKE_NAME}@`) {
|
|
21
|
+
value = result.name;
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
value = result.rawSpec;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (value === "" /* EnumSemverVersion.ANY */) {
|
|
28
|
+
value = void 0;
|
|
29
|
+
}
|
|
30
|
+
return value !== null && value !== void 0 ? value : "*" /* EnumSemverVersion.STAR */;
|
|
31
|
+
}
|
|
32
|
+
exports.normalizeResultToDepsValue = normalizeResultToDepsValue;
|
|
33
|
+
function _getNpaResult(value) {
|
|
34
|
+
let result;
|
|
35
|
+
try {
|
|
36
|
+
let sr = new Range_1.SemverRange(value);
|
|
37
|
+
result = (0, npm_package_arg_util_1.npa)(`${FAKE_NAME}@${value}`);
|
|
38
|
+
}
|
|
39
|
+
catch (e) {
|
|
40
|
+
try {
|
|
41
|
+
result = (0, npm_package_arg_util_1.npa)(`${value}`);
|
|
42
|
+
}
|
|
43
|
+
catch (e) {
|
|
44
|
+
try {
|
|
45
|
+
result = (0, npm_package_arg_util_1.npa)(`${FAKE_NAME}@${value}`);
|
|
46
|
+
}
|
|
47
|
+
catch (e2) {
|
|
48
|
+
throw e;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return result;
|
|
53
|
+
}
|
|
54
|
+
exports._getNpaResult = _getNpaResult;
|
|
55
|
+
function normalizeDepsValue(value) {
|
|
56
|
+
const result = _getNpaResult(value);
|
|
57
|
+
return normalizeResultToDepsValue(result);
|
|
58
|
+
}
|
|
59
|
+
exports.normalizeDepsValue = normalizeDepsValue;
|
|
60
|
+
exports.default = normalizeDepsValue;
|
|
61
|
+
//# 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,uFAAoF;AACpF,+FAA4F;AAC5F,uFAAoF;AAEpF,iEAAoE;AAEpE,MAAM,SAAS,GAAG,YAAqB,CAAA;AAEvC,SAAgB,0BAA0B,CAAC,MAAwC;IAElF,IAAI,KAAa,CAAC;IAClB,IAAI,OAAO,MAAM,KAAK,QAAQ,EAC9B;QACC,KAAK,GAAG,MAAM,CAAC;KACf;SACI,IAAI,MAAM,EACf;QACC,IAAI,MAAM,CAAC,IAAI,KAAK,OAAO,EAC3B;YACC,MAAM,QAAQ,GAAG,IAAA,6BAAa,EAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YAC/C,KAAK,GAAG,IAAA,6BAAa,EAAC,IAAA,qCAAiB,EAAC,QAAQ,CAAC,CAAC,CAAA;SAClD;aACI,IAAI,MAAM,CAAC,IAAI,KAAK,KAAK,IAAI,MAAM,CAAC,OAAO,mCAA0B,IAAI,MAAM,CAAC,GAAG,KAAK,GAAG,SAAS,GAAG,EAC5G;YACC,KAAK,GAAG,MAAM,CAAC,IAAI,CAAA;SACnB;aAED;YACC,KAAK,GAAG,MAAM,CAAC,OAAO,CAAA;SACtB;KACD;IACD,IAAI,KAAK,mCAA0B,EACnC;QACC,KAAK,GAAG,KAAK,CAAC,CAAC;KACf;IAED,OAAO,KAAK,aAAL,KAAK,cAAL,KAAK,mCAA0B,CAAA;AACvC,CAAC;AA7BD,gEA6BC;AAED,SAAgB,aAAa,CAAC,KAAa;IAE1C,IAAI,MAAwB,CAAC;IAE7B,IACA;QACC,IAAI,EAAE,GAAG,IAAI,mBAAW,CAAC,KAAK,CAAC,CAAC;QAChC,MAAM,GAAG,IAAA,0BAAG,EAAC,GAAG,SAAS,IAAI,KAAK,EAAE,CAAC,CAAA;KACrC;IACD,OAAO,CAAC,EACR;QACC,IACA;YACC,MAAM,GAAG,IAAA,0BAAG,EAAC,GAAG,KAAK,EAAE,CAAC,CAAA;SACxB;QACD,OAAO,CAAC,EACR;YACC,IACA;gBACC,MAAM,GAAG,IAAA,0BAAG,EAAC,GAAG,SAAS,IAAI,KAAK,EAAE,CAAC,CAAA;aACrC;YACD,OAAO,EAAE,EACT;gBACC,MAAM,CAAC,CAAA;aACP;SACD;KACD;IAED,OAAO,MAAM,CAAA;AACd,CAAC;AA7BD,sCA6BC;AAED,SAAgB,kBAAkB,CAAC,KAAa;IAE/C,MAAM,MAAM,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;IACpC,OAAO,0BAA0B,CAAC,MAAM,CAAC,CAAA;AAC1C,CAAC;AAJD,gDAIC;AAED,kBAAe,kBAAkB,CAAA","sourcesContent":["import { IResult, npa } from '@yarn-tool/npm-package-arg-util';\nimport { buildRangeSet } from '@lazy-node/semver-ampersand/lib/range/buildRangeSet';\nimport { stringifyRangeSet } from '@lazy-node/semver-ampersand/lib/range/stringifyRangeSet';\nimport { toRangeString } from '@lazy-node/semver-ampersand/lib/range/toRangeString';\nimport { EnumSemverVersion } from '@lazy-node/semver-ampersand/lib/const';\nimport { SemverRange } from '@lazy-node/semver-ampersand/lib/Range';\n\nconst FAKE_NAME = '@fake/fake' as const\n\nexport function normalizeResultToDepsValue(result: ReturnType<typeof _getNpaResult>)\n{\n\tlet value: string;\n\tif (typeof result === 'string')\n\t{\n\t\tvalue = result;\n\t}\n\telse if (result)\n\t{\n\t\tif (result.type === 'range')\n\t\t{\n\t\t\tconst rangeSet = buildRangeSet(result.rawSpec);\n\t\t\tvalue = toRangeString(stringifyRangeSet(rangeSet))\n\t\t}\n\t\telse if (result.type === 'tag' && result.rawSpec === EnumSemverVersion.ANY && result.raw !== `${FAKE_NAME}@`)\n\t\t{\n\t\t\tvalue = result.name\n\t\t}\n\t\telse\n\t\t{\n\t\t\tvalue = result.rawSpec\n\t\t}\n\t}\n\tif (value === EnumSemverVersion.ANY)\n\t{\n\t\tvalue = void 0;\n\t}\n\n\treturn value ?? EnumSemverVersion.STAR\n}\n\nexport function _getNpaResult(value: string)\n{\n\tlet result: IResult | string;\n\n\ttry\n\t{\n\t\tlet sr = new SemverRange(value);\n\t\tresult = npa(`${FAKE_NAME}@${value}`)\n\t}\n\tcatch (e)\n\t{\n\t\ttry\n\t\t{\n\t\t\tresult = npa(`${value}`)\n\t\t}\n\t\tcatch (e)\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tresult = npa(`${FAKE_NAME}@${value}`)\n\t\t\t}\n\t\t\tcatch (e2)\n\t\t\t{\n\t\t\t\tthrow e\n\t\t\t}\n\t\t}\n\t}\n\n\treturn result\n}\n\nexport function normalizeDepsValue(value: string)\n{\n\tconst result = _getNpaResult(value);\n\treturn normalizeResultToDepsValue(result)\n}\n\nexport default normalizeDepsValue\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@yarn-tool/normalize-deps-value",
|
|
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
|
+
"create-by-yarn-tool"
|
|
19
|
+
],
|
|
20
|
+
"homepage": "https://github.com/bluelovers/ws-yarn-workspaces/tree/master/packages/@yarn-tool/normalize-deps-value#readme",
|
|
21
|
+
"bugs": {
|
|
22
|
+
"url": "https://github.com/bluelovers/ws-yarn-workspaces/issues"
|
|
23
|
+
},
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "git+https://github.com/bluelovers/ws-yarn-workspaces.git"
|
|
27
|
+
},
|
|
28
|
+
"license": "ISC",
|
|
29
|
+
"author": "bluelovers",
|
|
30
|
+
"sideEffects": false,
|
|
31
|
+
"main": "index.js",
|
|
32
|
+
"scripts": {
|
|
33
|
+
"review": "yarn run review:coverage",
|
|
34
|
+
"review:coverage": "yarn run lint && yarn run coverage",
|
|
35
|
+
"review:test": "yarn run lint && yarn run test",
|
|
36
|
+
"coverage": "yarn run test -- --coverage",
|
|
37
|
+
"lint": "yarn run lint:eslint",
|
|
38
|
+
"lint:eslint": "ynpx eslint --ext .ts,.tsx,.mts,.cts ./",
|
|
39
|
+
"pretest": "echo pretest",
|
|
40
|
+
"test": "jest --passWithNoTests",
|
|
41
|
+
"test:jest": "jest --passWithNoTests",
|
|
42
|
+
"test:mocha": "ynpx --quiet -p ts-node -p mocha mocha -- --require ts-node/register \"!(node_modules)/**/*.{test,spec}.{ts,tsx}\"",
|
|
43
|
+
"test:snapshot": "yarn run test -- -u",
|
|
44
|
+
"test:tsdx": "ynpx @bluelovers/tsdx test --passWithNoTests",
|
|
45
|
+
"build:dts:bundle": "ynpx dts-bundle-generator -o ./dist/index.d.ts ./src/index.ts --no-banner --inline-declare-global & echo build:dts:bundle",
|
|
46
|
+
"build:dts:copy": "copy .\\src\\index.d.ts .\\dist\\index.d.ts & echo build:dts",
|
|
47
|
+
"build:dts:tsc": "yarn run build:dts:tsc:emit && yarn run build:dts:copy",
|
|
48
|
+
"build:dts:tsc:emit": "tsc --emitDeclarationOnly --declaration --noEmit false",
|
|
49
|
+
"build:microbundle": "ynpx microbundle --target node",
|
|
50
|
+
"build:tsdx": "ynpx @bluelovers/tsdx build --target node --name index",
|
|
51
|
+
"ci:install": "echo ci:install",
|
|
52
|
+
"ci:build": "echo ci:build",
|
|
53
|
+
"preversion": "echo preversion && yarn run test",
|
|
54
|
+
"version": "echo version",
|
|
55
|
+
"postversion": "echo postversion",
|
|
56
|
+
"prepublish": "echo prepublish",
|
|
57
|
+
"prepare": "echo prepare",
|
|
58
|
+
"prepublishOnly": "echo prepublishOnly",
|
|
59
|
+
"prepublishOnly:update": "yarn run ncu && yarn run sort-package-json",
|
|
60
|
+
"prepack": "echo prepack",
|
|
61
|
+
"pack": "echo pack",
|
|
62
|
+
"postpack": "echo postpack",
|
|
63
|
+
"publish": "echo publish",
|
|
64
|
+
"postpublish": "echo postpublish",
|
|
65
|
+
"postpublishOnly": "echo postpublishOnly",
|
|
66
|
+
"ncu": "yarn-tool ncu -u",
|
|
67
|
+
"sort-package-json": "yarn-tool sort",
|
|
68
|
+
"tsc:showConfig": "ynpx get-current-tsconfig -p"
|
|
69
|
+
},
|
|
70
|
+
"dependencies": {
|
|
71
|
+
"@lazy-node/semver-ampersand": "^2.0.3",
|
|
72
|
+
"@yarn-tool/npm-package-arg-util": "^1.0.30",
|
|
73
|
+
"tslib": "^2"
|
|
74
|
+
},
|
|
75
|
+
"packageManager": "yarn@1.22.19",
|
|
76
|
+
"publishConfig": {
|
|
77
|
+
"access": "public"
|
|
78
|
+
},
|
|
79
|
+
"gitHead": "f45f0e9d80c682395ccb7feda4375511f177579c"
|
|
80
|
+
}
|