@definitelytyped/utils 0.1.9 → 0.1.10
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 +7 -0
- package/dist/io.d.ts +1 -1
- package/dist/miscellany.d.ts +1 -1
- package/dist/npm.d.ts +7 -10
- package/dist/npm.js +32 -58
- package/dist/npm.js.map +1 -1
- package/package.json +5 -3
package/CHANGELOG.md
CHANGED
package/dist/io.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { LoggerWithErrors } from "./logging";
|
|
|
4
4
|
export declare function readFile(path: string): Promise<string>;
|
|
5
5
|
export declare function readFileSync(path: string): string;
|
|
6
6
|
/** If a file doesn't exist, warn and tell the step it should have been generated by. */
|
|
7
|
-
export declare function readFileAndWarn(generatedBy: string, filePath: string): Promise<
|
|
7
|
+
export declare function readFileAndWarn(generatedBy: string, filePath: string): Promise<Record<string, unknown>>;
|
|
8
8
|
export declare function readJsonSync(path: string): unknown;
|
|
9
9
|
export declare function readJsonSync<T>(path: string, predicate: (parsed: unknown) => parsed is T): T;
|
|
10
10
|
export declare function readJson(path: string): Promise<unknown>;
|
package/dist/miscellany.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export declare function tryParseJson<T>(text: string, predicate: (parsed: unknow
|
|
|
3
3
|
export declare function parseJson<T>(text: string): unknown;
|
|
4
4
|
export declare function parseJson<T>(text: string, predicate?: (parsed: unknown) => parsed is T): T;
|
|
5
5
|
export declare function identity<T>(t: T): T;
|
|
6
|
-
export declare function isObject(value: unknown): value is
|
|
6
|
+
export declare function isObject(value: unknown): value is Record<string, unknown>;
|
|
7
7
|
export declare function withoutStart(s: string, start: string): string | undefined;
|
|
8
8
|
export declare function computeHash(content: string): string;
|
|
9
9
|
export declare function isScopedPackage(packageName: string): boolean;
|
package/dist/npm.d.ts
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import { Logger } from "./logging";
|
|
2
|
-
export declare const npmRegistryHostName = "registry.npmjs.org";
|
|
3
|
-
export declare const npmRegistry = "https://registry.npmjs.org/";
|
|
4
2
|
export declare const cacheDir: string;
|
|
5
|
-
|
|
3
|
+
export interface NpmPublishClientConfig {
|
|
4
|
+
defaultTag?: string;
|
|
5
|
+
}
|
|
6
6
|
export declare class NpmPublishClient {
|
|
7
|
-
private readonly
|
|
8
|
-
private readonly
|
|
9
|
-
|
|
10
|
-
static create(token: string, config?: NeedToFixNpmRegistryClientTypings): Promise<NpmPublishClient>;
|
|
7
|
+
private readonly token;
|
|
8
|
+
private readonly defaultTag;
|
|
9
|
+
static create(token: string, config?: NpmPublishClientConfig): Promise<NpmPublishClient>;
|
|
11
10
|
private constructor();
|
|
12
|
-
publish(publishedDirectory: string, packageJson:
|
|
11
|
+
publish(publishedDirectory: string, packageJson: Record<string, unknown>, dry: boolean, log: Logger): Promise<void>;
|
|
13
12
|
tag(packageName: string, version: string, distTag: string, dry: boolean, log: Logger): Promise<void>;
|
|
14
|
-
deprecate(packageName: string, version: string, message: string): Promise<void>;
|
|
15
13
|
}
|
|
16
|
-
export {};
|
package/dist/npm.js
CHANGED
|
@@ -36,81 +36,55 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
36
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.NpmPublishClient = exports.cacheDir =
|
|
39
|
+
exports.NpmPublishClient = exports.cacheDir = void 0;
|
|
40
40
|
const os = __importStar(require("os"));
|
|
41
41
|
const process_1 = __importDefault(require("process"));
|
|
42
42
|
const fs_1 = __importDefault(require("fs"));
|
|
43
|
-
const
|
|
44
|
-
const
|
|
43
|
+
const libnpmpublish_1 = require("libnpmpublish");
|
|
44
|
+
const npm_registry_fetch_1 = __importDefault(require("npm-registry-fetch"));
|
|
45
45
|
const fs_2 = require("./fs");
|
|
46
46
|
const io_1 = require("./io");
|
|
47
|
-
exports.npmRegistryHostName = "registry.npmjs.org";
|
|
48
|
-
exports.npmRegistry = `https://${exports.npmRegistryHostName}/`;
|
|
49
47
|
exports.cacheDir = (0, fs_2.joinPaths)(process_1.default.env.GITHUB_ACTIONS ? (0, fs_2.joinPaths)(__dirname, "../../..") : os.tmpdir(), "cache");
|
|
50
48
|
class NpmPublishClient {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
return new NpmPublishClient(new npm_registry_client_1.default(config), { token }, exports.npmRegistry);
|
|
49
|
+
token;
|
|
50
|
+
defaultTag;
|
|
51
|
+
static async create(token, config = {}) {
|
|
52
|
+
return new NpmPublishClient(token, config.defaultTag);
|
|
56
53
|
}
|
|
57
|
-
constructor(
|
|
58
|
-
this.
|
|
59
|
-
this.
|
|
60
|
-
this.registry = registry;
|
|
54
|
+
constructor(token, defaultTag) {
|
|
55
|
+
this.token = token;
|
|
56
|
+
this.defaultTag = defaultTag;
|
|
61
57
|
}
|
|
62
58
|
async publish(publishedDirectory, packageJson, dry, log) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
metadata: metadata,
|
|
77
|
-
body: body,
|
|
78
|
-
}, cb);
|
|
79
|
-
}));
|
|
59
|
+
if (dry) {
|
|
60
|
+
log(`(dry) Skip publish of ${publishedDirectory}`);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const readme = await fs_1.default.promises.readFile((0, fs_2.joinPaths)(publishedDirectory, "README.md"), "utf-8");
|
|
64
|
+
const tarballBuffer = await (0, io_1.streamToBuffer)((0, io_1.createTgz)(publishedDirectory, (err) => {
|
|
65
|
+
throw err;
|
|
66
|
+
}));
|
|
67
|
+
const manifest = { ...packageJson, readme };
|
|
68
|
+
await (0, libnpmpublish_1.publish)(manifest, tarballBuffer, {
|
|
69
|
+
forceAuth: { token: this.token },
|
|
70
|
+
access: "public",
|
|
71
|
+
defaultTag: this.defaultTag,
|
|
80
72
|
});
|
|
81
73
|
}
|
|
82
|
-
tag(packageName, version, distTag, dry, log) {
|
|
74
|
+
async tag(packageName, version, distTag, dry, log) {
|
|
83
75
|
if (dry) {
|
|
84
76
|
log(`(dry) Skip tag of ${packageName}@${distTag} as ${version}`);
|
|
85
|
-
return
|
|
77
|
+
return;
|
|
86
78
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
message,
|
|
95
|
-
version,
|
|
96
|
-
auth: this.auth,
|
|
97
|
-
};
|
|
98
|
-
return promisifyVoid((cb) => {
|
|
99
|
-
this.client.deprecate(url, params, cb);
|
|
79
|
+
await (0, npm_registry_fetch_1.default)(`/-/package/${encodeURIComponent(packageName)}/dist-tags/${encodeURIComponent(distTag)}`, {
|
|
80
|
+
method: "PUT",
|
|
81
|
+
forceAuth: { token: this.token },
|
|
82
|
+
body: JSON.stringify(version),
|
|
83
|
+
headers: {
|
|
84
|
+
"content-type": "application/json",
|
|
85
|
+
},
|
|
100
86
|
});
|
|
101
87
|
}
|
|
102
88
|
}
|
|
103
89
|
exports.NpmPublishClient = NpmPublishClient;
|
|
104
|
-
function promisifyVoid(callsBack) {
|
|
105
|
-
return new Promise((resolve, reject) => {
|
|
106
|
-
callsBack((error) => {
|
|
107
|
-
if (error) {
|
|
108
|
-
reject(error);
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
resolve();
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
90
|
//# sourceMappingURL=npm.js.map
|
package/dist/npm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"npm.js","sourceRoot":"","sources":["../src/npm.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;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Z,CAAC,CAAC,CACH,CAAC;QAEF,MAAM,QAAQ,GAAG,EAAE,GAAG,WAAW,EAAE,MAAM,EAAkD,CAAC;QAC5F,MAAM,IAAA,uBAAO,EAAC,QAAQ,EAAE,aAAa,EAAE;YACrC,SAAS,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE;YAChC,MAAM,EAAE,QAAQ;YAChB,UAAU,EAAE,IAAI,CAAC,UAAU;SAC5B,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,WAAmB,EAAE,OAAe,EAAE,OAAe,EAAE,GAAY,EAAE,GAAW;QACxF,IAAI,GAAG,EAAE,CAAC;YACR,GAAG,CAAC,qBAAqB,WAAW,IAAI,OAAO,OAAO,OAAO,EAAE,CAAC,CAAC;YACjE,OAAO;QACT,CAAC;QAED,MAAM,IAAA,4BAAQ,EAAC,cAAc,kBAAkB,CAAC,WAAW,CAAC,cAAc,kBAAkB,CAAC,OAAO,CAAC,EAAE,EAAE;YACvG,MAAM,EAAE,KAAK;YACb,SAAS,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE;YAChC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;YAC7B,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;aACnC;SACF,CAAC,CAAC;IACL,CAAC;CACF;AAnDD,4CAmDC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@definitelytyped/utils",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
4
4
|
"description": "Shared utilities for DefinitelyTyped tools",
|
|
5
5
|
"homepage": "https://github.com/microsoft/DefinitelyTyped-tools/tree/main/packages/utils#readme",
|
|
6
6
|
"license": "MIT",
|
|
@@ -15,18 +15,20 @@
|
|
|
15
15
|
"url": "https://github.com/microsoft/DefinitelyTyped-tools/issues"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@qiwi/npm-registry-client": "^8.9.1",
|
|
19
18
|
"@types/node": "^25.1.0",
|
|
20
19
|
"cachedir": "^2.4.0",
|
|
21
20
|
"charm": "^1.0.2",
|
|
21
|
+
"libnpmpublish": "^11.1.3",
|
|
22
22
|
"minimatch": "^10.1.1",
|
|
23
|
+
"npm-registry-fetch": "^19.1.1",
|
|
23
24
|
"tar": "^7.5.7",
|
|
24
25
|
"tar-stream": "^3.1.7",
|
|
25
26
|
"which": "^6.0.0"
|
|
26
27
|
},
|
|
27
28
|
"devDependencies": {
|
|
28
|
-
"@qiwi/npm-types": "^1.0.3",
|
|
29
29
|
"@types/charm": "^1.0.6",
|
|
30
|
+
"@types/libnpmpublish": "^9.0.1",
|
|
31
|
+
"@types/npm-registry-fetch": "^8.0.8",
|
|
30
32
|
"@types/tar-stream": "^3.1.4",
|
|
31
33
|
"@types/which": "^3.0.4"
|
|
32
34
|
},
|