@yarn-tool/is-published 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 ADDED
@@ -0,0 +1,12 @@
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-09-10)
7
+
8
+
9
+
10
+ ### đŸ”–ă€€Miscellaneous
11
+
12
+ * @yarn-tool/is-published ([a6ecd7a](https://github.com/bluelovers/ws-yarn-workspaces/commit/a6ecd7abc76cd143988ab6742a27911e34c22ccf))
package/README.md ADDED
@@ -0,0 +1,12 @@
1
+ # README.md
2
+
3
+
4
+
5
+ ## install
6
+
7
+ ```bash
8
+ yarn add @yarn-tool/is-published
9
+ yarn-tool add @yarn-tool/is-published
10
+ yt add @yarn-tool/is-published
11
+ ```
12
+
package/index.d.ts ADDED
@@ -0,0 +1,53 @@
1
+ import { IOptions } from '@yarn-tool/npa-to-deps-query';
2
+ import { ITSResolvable } from 'ts-type';
3
+ import { IDepsResult } from '@yarn-tool/npa-to-deps';
4
+ import Bluebird from 'bluebird';
5
+ import { IResult } from '@yarn-tool/npm-package-arg-util';
6
+ export declare const enum EnumIsPublishedState {
7
+ VersionPublished = 0,
8
+ VersionNotFound = 1,
9
+ PackageNotFound = 2
10
+ }
11
+ export interface IPublishedResultBase {
12
+ depsResult: IDepsResult<IResult>;
13
+ exists: boolean;
14
+ isPublished: null | boolean;
15
+ state: EnumIsPublishedState;
16
+ }
17
+ export interface IPublishedResultVersionPublished extends IPublishedResultBase {
18
+ queryResult: {
19
+ name: string;
20
+ value: string;
21
+ };
22
+ exists: true;
23
+ isPublished: true;
24
+ state: EnumIsPublishedState.VersionPublished;
25
+ }
26
+ export interface IPublishedResultVersionNotFound extends IPublishedResultBase {
27
+ queryResult?: {
28
+ name: string;
29
+ value: string;
30
+ };
31
+ exists: true;
32
+ isPublished: false;
33
+ state: EnumIsPublishedState.VersionNotFound;
34
+ }
35
+ export interface IPublishedResultPackageNotFound extends IPublishedResultBase {
36
+ exists: false;
37
+ isPublished: null;
38
+ state: EnumIsPublishedState.PackageNotFound;
39
+ }
40
+ export type IPublishedResult = IPublishedResultVersionPublished | IPublishedResultVersionNotFound | IPublishedResultPackageNotFound;
41
+ export declare function _isPublishedCoreByNpaResult(depsResult: ITSResolvable<IDepsResult<IResult>>, options?: IOptions): Bluebird<IPublishedResult>;
42
+ export declare function _isPublishedCore(input: string, options?: IOptions): Bluebird<IPublishedResult>;
43
+ export declare function _isPublishedCoreByPackageJSON(pkg: {
44
+ name: string;
45
+ version: string;
46
+ }, options?: IOptions): Bluebird<IPublishedResult>;
47
+ export declare function isPublishedByNpaResult(depsResult: ITSResolvable<IDepsResult>, options?: IOptions): Bluebird<boolean>;
48
+ export declare function isPublished(input: string, options?: IOptions): Bluebird<boolean>;
49
+ export declare function isPublishedByPackageJSON(pkg: {
50
+ name: string;
51
+ version: string;
52
+ }, options?: IOptions): Bluebird<boolean>;
53
+ export default isPublishedByPackageJSON;
package/index.js ADDED
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isPublishedByPackageJSON = exports.isPublished = exports.isPublishedByNpaResult = exports._isPublishedCoreByPackageJSON = exports._isPublishedCore = exports._isPublishedCoreByNpaResult = exports.EnumIsPublishedState = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const npa_to_deps_query_1 = require("@yarn-tool/npa-to-deps-query");
6
+ const npa_to_deps_1 = require("@yarn-tool/npa-to-deps");
7
+ const bluebird_1 = tslib_1.__importDefault(require("bluebird"));
8
+ const package_json_1 = require("package-json");
9
+ var EnumIsPublishedState;
10
+ (function (EnumIsPublishedState) {
11
+ EnumIsPublishedState[EnumIsPublishedState["VersionPublished"] = 0] = "VersionPublished";
12
+ EnumIsPublishedState[EnumIsPublishedState["VersionNotFound"] = 1] = "VersionNotFound";
13
+ EnumIsPublishedState[EnumIsPublishedState["PackageNotFound"] = 2] = "PackageNotFound";
14
+ })(EnumIsPublishedState = exports.EnumIsPublishedState || (exports.EnumIsPublishedState = {}));
15
+ function _isPublishedCoreByNpaResult(depsResult, options) {
16
+ return bluebird_1.default.resolve(depsResult)
17
+ .then(depsResult => {
18
+ return (0, npa_to_deps_query_1.queryDepsValueByNpaResult)({
19
+ ...depsResult,
20
+ operator: '',
21
+ fetchQuery: true,
22
+ }, options)
23
+ .then((queryResult) => {
24
+ const isPublished = depsResult.semver === queryResult.value;
25
+ return {
26
+ depsResult,
27
+ queryResult,
28
+ exists: true,
29
+ isPublished,
30
+ state: isPublished ? 0 /* EnumIsPublishedState.VersionPublished */ : 1 /* EnumIsPublishedState.VersionNotFound */,
31
+ };
32
+ })
33
+ .catch(package_json_1.VersionNotFoundError, err => {
34
+ return {
35
+ depsResult,
36
+ exists: true,
37
+ isPublished: false,
38
+ state: 1 /* EnumIsPublishedState.VersionNotFound */,
39
+ };
40
+ })
41
+ .catch(package_json_1.PackageNotFoundError, err => {
42
+ return {
43
+ depsResult,
44
+ exists: false,
45
+ isPublished: null,
46
+ state: 2 /* EnumIsPublishedState.PackageNotFound */,
47
+ };
48
+ });
49
+ });
50
+ }
51
+ exports._isPublishedCoreByNpaResult = _isPublishedCoreByNpaResult;
52
+ function _isPublishedCore(input, options) {
53
+ return bluebird_1.default.resolve()
54
+ .then(() => {
55
+ return (0, npa_to_deps_1.npaToDepsValue)(input, options);
56
+ })
57
+ .then((result) => {
58
+ return _isPublishedCoreByNpaResult(result, options);
59
+ });
60
+ }
61
+ exports._isPublishedCore = _isPublishedCore;
62
+ function _isPublishedCoreByPackageJSON(pkg, options) {
63
+ return _isPublishedCore(`${pkg.name}@${pkg.version}`, options);
64
+ }
65
+ exports._isPublishedCoreByPackageJSON = _isPublishedCoreByPackageJSON;
66
+ function isPublishedByNpaResult(depsResult, options) {
67
+ return _isPublishedCoreByNpaResult(depsResult, options)
68
+ .then(data => data === null || data === void 0 ? void 0 : data.isPublished);
69
+ }
70
+ exports.isPublishedByNpaResult = isPublishedByNpaResult;
71
+ function isPublished(input, options) {
72
+ return _isPublishedCore(input, options)
73
+ .then(data => data === null || data === void 0 ? void 0 : data.isPublished);
74
+ }
75
+ exports.isPublished = isPublished;
76
+ function isPublishedByPackageJSON(pkg, options) {
77
+ return isPublished(`${pkg.name}@${pkg.version}`, options);
78
+ }
79
+ exports.isPublishedByPackageJSON = isPublishedByPackageJSON;
80
+ exports.default = isPublishedByPackageJSON;
81
+ //# 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,oEAAmF;AAEnF,wDAAqE;AACrE,gEAAgC;AAChC,+CAA0E;AAG1E,IAAkB,oBAKjB;AALD,WAAkB,oBAAoB;IAErC,uFAAoB,CAAA;IACpB,qFAAmB,CAAA;IACnB,qFAAmB,CAAA;AACpB,CAAC,EALiB,oBAAoB,GAApB,4BAAoB,KAApB,4BAAoB,QAKrC;AAyCD,SAAgB,2BAA2B,CAAC,UAA+C,EAAE,OAAkB;IAE9G,OAAO,kBAAQ,CAAC,OAAO,CAAC,UAAU,CAAC;SACjC,IAAI,CAAC,UAAU,CAAC,EAAE;QAElB,OAAO,IAAA,6CAAyB,EAAC;YAChC,GAAG,UAAU;YACb,QAAQ,EAAE,EAAE;YACZ,UAAU,EAAE,IAAI;SAChB,EAAE,OAAO,CAAC;aACT,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE;YAErB,MAAM,WAAW,GAAG,UAAU,CAAC,MAAM,KAAK,WAAW,CAAC,KAAK,CAAC;YAE5D,OAAO;gBACN,UAAU;gBACV,WAAW;gBACX,MAAM,EAAE,IAAa;gBACrB,WAAW;gBACX,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,6CAA8C,CAAC,CAAC,CAAC,4CAA6C;aACnH,CAAA;QACF,CAAC,CAAC;aACD,K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K,EAAE,OAAO,CAAC;SACrC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,CAAC,CAAA;AAClC,CAAC;AAJD,kCAIC;AAED,SAAgB,wBAAwB,CAAC,GAGxC,EAAE,OAAkB;IAEpB,OAAO,WAAW,CAAC,GAAG,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,OAAO,EAAE,EAAE,OAAO,CAAC,CAAA;AAC1D,CAAC;AAND,4DAMC;AAED,kBAAe,wBAAwB,CAAA","sourcesContent":["import { IOptions, queryDepsValueByNpaResult } from '@yarn-tool/npa-to-deps-query';\nimport { ITSResolvable } from 'ts-type';\nimport { IDepsResult, npaToDepsValue } from '@yarn-tool/npa-to-deps';\nimport Bluebird from 'bluebird';\nimport { PackageNotFoundError, VersionNotFoundError } from 'package-json';\nimport { IResult } from '@yarn-tool/npm-package-arg-util';\n\nexport const enum EnumIsPublishedState\n{\n\tVersionPublished = 0,\n\tVersionNotFound = 1,\n\tPackageNotFound = 2,\n}\n\nexport interface IPublishedResultBase\n{\n\tdepsResult: IDepsResult<IResult>;\n\texists: boolean;\n\tisPublished: null | boolean;\n\tstate: EnumIsPublishedState;\n}\n\nexport interface IPublishedResultVersionPublished extends IPublishedResultBase\n{\n\tqueryResult: {\n\t\tname: string;\n\t\tvalue: string;\n\t};\n\texists: true;\n\tisPublished: true;\n\tstate: EnumIsPublishedState.VersionPublished;\n}\n\nexport interface IPublishedResultVersionNotFound extends IPublishedResultBase\n{\n\tqueryResult?: {\n\t\tname: string;\n\t\tvalue: string;\n\t};\n\texists: true;\n\tisPublished: false;\n\tstate: EnumIsPublishedState.VersionNotFound;\n}\n\nexport interface IPublishedResultPackageNotFound extends IPublishedResultBase\n{\n\texists: false;\n\tisPublished: null;\n\tstate: EnumIsPublishedState.PackageNotFound;\n}\n\nexport type IPublishedResult = IPublishedResultVersionPublished | IPublishedResultVersionNotFound | IPublishedResultPackageNotFound;\n\nexport function _isPublishedCoreByNpaResult(depsResult: ITSResolvable<IDepsResult<IResult>>, options?: IOptions)\n{\n\treturn Bluebird.resolve(depsResult)\n\t\t.then(depsResult =>\n\t\t{\n\t\t\treturn queryDepsValueByNpaResult({\n\t\t\t\t...depsResult,\n\t\t\t\toperator: '',\n\t\t\t\tfetchQuery: true,\n\t\t\t}, options)\n\t\t\t\t.then((queryResult) =>\n\t\t\t\t{\n\t\t\t\t\tconst isPublished = depsResult.semver === queryResult.value;\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tdepsResult,\n\t\t\t\t\t\tqueryResult,\n\t\t\t\t\t\texists: true as const,\n\t\t\t\t\t\tisPublished,\n\t\t\t\t\t\tstate: isPublished ? EnumIsPublishedState.VersionPublished as const : EnumIsPublishedState.VersionNotFound as const,\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t\t.catch(VersionNotFoundError, err => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tdepsResult,\n\t\t\t\t\t\texists: true as const,\n\t\t\t\t\t\tisPublished: false as const,\n\t\t\t\t\t\tstate: EnumIsPublishedState.VersionNotFound as const,\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t\t.catch(PackageNotFoundError, err =>\n\t\t\t\t{\n\t\t\t\t\treturn {\n\t\t\t\t\t\tdepsResult,\n\t\t\t\t\t\texists: false as const,\n\t\t\t\t\t\tisPublished: null as null,\n\t\t\t\t\t\tstate: EnumIsPublishedState.PackageNotFound as const,\n\t\t\t\t\t}\n\t\t\t\t}) as Bluebird<IPublishedResult>\n\t\t})\n}\n\nexport function _isPublishedCore(input: string, options?: IOptions)\n{\n\treturn Bluebird.resolve()\n\t\t.then(() =>\n\t\t{\n\t\t\treturn npaToDepsValue(input, options)\n\t\t})\n\t\t.then((result) =>\n\t\t{\n\t\t\treturn _isPublishedCoreByNpaResult(result, options)\n\t\t})\n}\n\nexport function _isPublishedCoreByPackageJSON(pkg: {\n\tname: string,\n\tversion: string,\n}, options?: IOptions)\n{\n\treturn _isPublishedCore(`${pkg.name}@${pkg.version}`, options)\n}\n\nexport function isPublishedByNpaResult(depsResult: ITSResolvable<IDepsResult>, options?: IOptions)\n{\n\treturn _isPublishedCoreByNpaResult(depsResult, options)\n\t\t.then(data => data?.isPublished)\n}\n\nexport function isPublished(input: string, options?: IOptions)\n{\n\treturn _isPublishedCore(input, options)\n\t\t.then(data => data?.isPublished)\n}\n\nexport function isPublishedByPackageJSON(pkg: {\n\tname: string,\n\tversion: string,\n}, options?: IOptions)\n{\n\treturn isPublished(`${pkg.name}@${pkg.version}`, options)\n}\n\nexport default isPublishedByPackageJSON\n"]}
package/package.json ADDED
@@ -0,0 +1,81 @@
1
+ {
2
+ "name": "@yarn-tool/is-published",
3
+ "version": "1.0.1",
4
+ "description": "check package is published or not",
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/is-published#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
+ "directory": "packages/@yarn-tool/is-published"
28
+ },
29
+ "license": "ISC",
30
+ "author": "bluelovers",
31
+ "sideEffects": false,
32
+ "main": "index.js",
33
+ "scripts": {
34
+ "review": "yarn run review:coverage",
35
+ "review:coverage": "yarn run lint && yarn run coverage",
36
+ "review:test": "yarn run lint && yarn run test",
37
+ "coverage": "yarn run test -- --coverage",
38
+ "lint": "yarn run lint:eslint",
39
+ "lint:eslint": "ynpx eslint --ext .ts,.tsx,.mts,.cts ./",
40
+ "pretest": "echo pretest",
41
+ "test": "jest --passWithNoTests",
42
+ "test:jest": "jest --passWithNoTests",
43
+ "test:jest:snapshot": "yarn run test:jest -- -u",
44
+ "test:mocha": "ynpx --quiet -p ts-node -p mocha mocha -- --require ts-node/register \"!(node_modules)/**/*.{test,spec}.{ts,tsx}\"",
45
+ "test:snapshot": "yarn run test -- -u",
46
+ "test:tsdx": "ynpx @bluelovers/tsdx test --passWithNoTests",
47
+ "build:dts:bundle": "ynpx dts-bundle-generator -o ./dist/index.d.ts ./src/index.ts --no-banner --inline-declare-global & echo build:dts:bundle",
48
+ "build:dts:copy": "copy .\\src\\index.d.ts .\\dist\\index.d.ts & echo build:dts",
49
+ "build:dts:tsc": "yarn run build:dts:tsc:emit && yarn run build:dts:copy",
50
+ "build:dts:tsc:emit": "tsc --emitDeclarationOnly --declaration --noEmit false",
51
+ "build:microbundle": "ynpx microbundle --target node",
52
+ "build:tsdx": "ynpx @bluelovers/tsdx build --target node --name index",
53
+ "ci:install": "echo ci:install",
54
+ "ci:build": "echo ci:build",
55
+ "preversion": "echo preversion && yarn run test",
56
+ "version": "echo version",
57
+ "postversion": "echo postversion",
58
+ "prepublish": "echo prepublish",
59
+ "prepare": "echo prepare",
60
+ "prepublishOnly": "echo prepublishOnly",
61
+ "prepublishOnly:update": "yarn run ncu && yarn run sort-package-json",
62
+ "prepack": "echo prepack",
63
+ "pack": "echo pack",
64
+ "postpack": "echo postpack",
65
+ "publish": "echo publish",
66
+ "postpublish": "echo postpublish",
67
+ "postpublishOnly": "echo postpublishOnly",
68
+ "ncu": "yarn-tool ncu -u",
69
+ "sort-package-json": "yarn-tool sort",
70
+ "tsc:showConfig": "ynpx get-current-tsconfig -p"
71
+ },
72
+ "dependencies": {
73
+ "@yarn-tool/npa-to-deps-query": "^2.0.8",
74
+ "tslib": ">=2"
75
+ },
76
+ "packageManager": "yarn@1.22.19",
77
+ "publishConfig": {
78
+ "access": "public"
79
+ },
80
+ "gitHead": "5d2376805123a3e87de1fc5fd4938e1c5d2e4bf0"
81
+ }