monoship 1.8.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/LICENSE +21 -0
- package/README.md +241 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +597 -0
- package/dist/index.d.mts +310 -0
- package/dist/index.mjs +616 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +86 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
//#region src/core/error.d.ts
|
|
2
|
+
declare class BaseError extends Error {
|
|
3
|
+
readonly code: string;
|
|
4
|
+
readonly statusCode: number;
|
|
5
|
+
constructor(message: string, options: {
|
|
6
|
+
code: string;
|
|
7
|
+
statusCode: number;
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/core/filesystem/types.d.ts
|
|
12
|
+
interface IFileSystem {
|
|
13
|
+
readFile(filePath: string): Promise<string>;
|
|
14
|
+
writeFile(filePath: string, content: string): Promise<void>;
|
|
15
|
+
glob(patterns: string[], options: {
|
|
16
|
+
cwd?: string;
|
|
17
|
+
ignore?: string[];
|
|
18
|
+
}): Promise<string[]>;
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/core/filesystem/memory.d.ts
|
|
22
|
+
declare class MemoryFileSystem implements IFileSystem {
|
|
23
|
+
private readonly files;
|
|
24
|
+
constructor(files?: Record<string, string>);
|
|
25
|
+
readFile(filePath: string): Promise<string>;
|
|
26
|
+
writeFile(filePath: string, content: string): Promise<void>;
|
|
27
|
+
glob(patterns: string[], options?: {
|
|
28
|
+
cwd?: string;
|
|
29
|
+
ignore?: string[];
|
|
30
|
+
}): Promise<string[]>;
|
|
31
|
+
getFile(filePath: string): string | undefined;
|
|
32
|
+
private normalize;
|
|
33
|
+
private matchGlobPattern;
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region src/core/filesystem/node.d.ts
|
|
37
|
+
declare class NodeFileSystem implements IFileSystem {
|
|
38
|
+
readFile(filePath: string): Promise<string>;
|
|
39
|
+
writeFile(filePath: string, content: string): Promise<void>;
|
|
40
|
+
glob(patterns: string[], options?: {
|
|
41
|
+
cwd?: string;
|
|
42
|
+
ignore?: string[];
|
|
43
|
+
}): Promise<string[]>;
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/core/logger/types.d.ts
|
|
47
|
+
interface ILogger {
|
|
48
|
+
info(message: string): void;
|
|
49
|
+
success(message: string): void;
|
|
50
|
+
warn(message: string): void;
|
|
51
|
+
error(message: string): void;
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region src/core/logger/consola.d.ts
|
|
55
|
+
declare class ConsolaLogger implements ILogger {
|
|
56
|
+
info(message: string): void;
|
|
57
|
+
success(message: string): void;
|
|
58
|
+
warn(message: string): void;
|
|
59
|
+
error(message: string): void;
|
|
60
|
+
}
|
|
61
|
+
//#endregion
|
|
62
|
+
//#region src/core/logger/noop.d.ts
|
|
63
|
+
declare class NoopLogger implements ILogger {
|
|
64
|
+
info(_message: string): void;
|
|
65
|
+
success(_message: string): void;
|
|
66
|
+
warn(_message: string): void;
|
|
67
|
+
error(_message: string): void;
|
|
68
|
+
}
|
|
69
|
+
//#endregion
|
|
70
|
+
//#region src/core/package/types.d.ts
|
|
71
|
+
type PackageJson = {
|
|
72
|
+
name: string;
|
|
73
|
+
private?: boolean;
|
|
74
|
+
version: string;
|
|
75
|
+
publishConfig?: Record<string, any>;
|
|
76
|
+
workspaces?: string[];
|
|
77
|
+
dependencies?: Record<string, string>;
|
|
78
|
+
peerDependencies?: Record<string, string>;
|
|
79
|
+
devDependencies?: Record<string, string>;
|
|
80
|
+
};
|
|
81
|
+
type Package = {
|
|
82
|
+
path: string;
|
|
83
|
+
content: PackageJson;
|
|
84
|
+
published?: boolean;
|
|
85
|
+
publishable?: boolean;
|
|
86
|
+
modified?: boolean;
|
|
87
|
+
valid?: boolean;
|
|
88
|
+
};
|
|
89
|
+
//#endregion
|
|
90
|
+
//#region src/core/publisher/error.d.ts
|
|
91
|
+
declare class PublishError extends BaseError {
|
|
92
|
+
constructor(message: string, options?: {
|
|
93
|
+
cause?: Error;
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
//#endregion
|
|
97
|
+
//#region src/core/publisher/types.d.ts
|
|
98
|
+
type ExecFn = (command: string, args: string[], options: {
|
|
99
|
+
cwd: string;
|
|
100
|
+
env: Record<string, string | undefined>;
|
|
101
|
+
}) => Promise<{
|
|
102
|
+
stdout: string;
|
|
103
|
+
stderr: string;
|
|
104
|
+
}>;
|
|
105
|
+
interface IPackagePublisher {
|
|
106
|
+
/**
|
|
107
|
+
* Publish a package to a registry.
|
|
108
|
+
*
|
|
109
|
+
* @param packagePath - Absolute path to the package directory.
|
|
110
|
+
* @param manifest - Parsed package.json contents.
|
|
111
|
+
* @param options - Registry/auth options (e.g. auth token, access level, tag).
|
|
112
|
+
* @returns `true` if published, `false` if the version already exists (conflict).
|
|
113
|
+
* @throws {PublishError} On non-conflict publish failures.
|
|
114
|
+
*/
|
|
115
|
+
publish(packagePath: string, manifest: PackageJson, options: Record<string, any>): Promise<boolean>;
|
|
116
|
+
}
|
|
117
|
+
//#endregion
|
|
118
|
+
//#region src/core/publisher/memory.d.ts
|
|
119
|
+
declare class MemoryPublisher implements IPackagePublisher {
|
|
120
|
+
published: Array<{
|
|
121
|
+
packagePath: string;
|
|
122
|
+
manifest: PackageJson;
|
|
123
|
+
options: Record<string, any>;
|
|
124
|
+
}>;
|
|
125
|
+
constructor();
|
|
126
|
+
publish(packagePath: string, manifest: PackageJson, options: Record<string, any>): Promise<boolean>;
|
|
127
|
+
}
|
|
128
|
+
//#endregion
|
|
129
|
+
//#region src/core/publisher/npm.d.ts
|
|
130
|
+
declare class NpmPublisher implements IPackagePublisher {
|
|
131
|
+
/**
|
|
132
|
+
* Publish a package using libnpmpack + libnpmpublish.
|
|
133
|
+
*
|
|
134
|
+
* @returns `true` if published, `false` if the version already exists.
|
|
135
|
+
* @throws {PublishError} On non-conflict failures (network errors, auth failures, etc.).
|
|
136
|
+
*/
|
|
137
|
+
publish(packagePath: string, manifest: PackageJson, options: Record<string, any>): Promise<boolean>;
|
|
138
|
+
/**
|
|
139
|
+
* Determines whether an exception represents a version conflict
|
|
140
|
+
* when publishing to the npmjs.org registry.
|
|
141
|
+
*/
|
|
142
|
+
private isNpmJsVersionConflict;
|
|
143
|
+
/**
|
|
144
|
+
* Determines whether an exception represents a version conflict
|
|
145
|
+
* when publishing to GitHub Packages (npm.pkg.github.com).
|
|
146
|
+
*/
|
|
147
|
+
private isNpmPkgGitHubVersionConflict;
|
|
148
|
+
}
|
|
149
|
+
//#endregion
|
|
150
|
+
//#region src/core/publisher/npm-cli.d.ts
|
|
151
|
+
type ReadFileFn = (filePath: string, encoding: string) => Promise<string>;
|
|
152
|
+
type WriteFileFn = (filePath: string, content: string, encoding: string) => Promise<void>;
|
|
153
|
+
type UnlinkFn = (filePath: string) => Promise<void>;
|
|
154
|
+
type NpmCliPublisherOptions = {
|
|
155
|
+
execFn?: ExecFn;
|
|
156
|
+
readFileFn?: ReadFileFn;
|
|
157
|
+
writeFileFn?: WriteFileFn;
|
|
158
|
+
unlinkFn?: UnlinkFn;
|
|
159
|
+
};
|
|
160
|
+
declare class NpmCliPublisher implements IPackagePublisher {
|
|
161
|
+
private readonly execFn;
|
|
162
|
+
private readonly readFileFn;
|
|
163
|
+
private readonly writeFileFn;
|
|
164
|
+
private readonly unlinkFn;
|
|
165
|
+
constructor(options?: NpmCliPublisherOptions);
|
|
166
|
+
/**
|
|
167
|
+
* Publish a package by shelling out to `npm publish`.
|
|
168
|
+
*
|
|
169
|
+
* Writes a temporary `.npmrc` for auth when a token is present and
|
|
170
|
+
* restores/removes it after the command completes (even on failure).
|
|
171
|
+
*
|
|
172
|
+
* @returns `true` if published, `false` if the version already exists.
|
|
173
|
+
* @throws {PublishError} On non-conflict failures (network errors, auth failures, etc.).
|
|
174
|
+
*/
|
|
175
|
+
publish(packagePath: string, _manifest: PackageJson, options: Record<string, any>): Promise<boolean>;
|
|
176
|
+
private isVersionConflict;
|
|
177
|
+
}
|
|
178
|
+
//#endregion
|
|
179
|
+
//#region src/core/publisher/resolve.d.ts
|
|
180
|
+
declare function resolvePublisher(options?: {
|
|
181
|
+
execFn?: ExecFn;
|
|
182
|
+
}): Promise<IPackagePublisher>;
|
|
183
|
+
//#endregion
|
|
184
|
+
//#region src/core/registry-client/error.d.ts
|
|
185
|
+
declare class RegistryError extends BaseError {
|
|
186
|
+
constructor(message: string, statusCode: number);
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Duck-type check for RegistryError shape.
|
|
190
|
+
*
|
|
191
|
+
* Validates the error has `message` (string), `statusCode` (number),
|
|
192
|
+
* and `code` (string) — matching the BaseError contract.
|
|
193
|
+
*
|
|
194
|
+
* @param input The value to check.
|
|
195
|
+
* @returns `true` if the value has the RegistryError shape.
|
|
196
|
+
*/
|
|
197
|
+
declare function isRegistryError(input: unknown): input is RegistryError;
|
|
198
|
+
//#endregion
|
|
199
|
+
//#region src/core/registry-client/types.d.ts
|
|
200
|
+
type PackumentVersion = {
|
|
201
|
+
name: string;
|
|
202
|
+
version: string;
|
|
203
|
+
};
|
|
204
|
+
type Packument = {
|
|
205
|
+
name: string;
|
|
206
|
+
'dist-tags': Record<string, string>;
|
|
207
|
+
versions: Record<string, PackumentVersion>;
|
|
208
|
+
};
|
|
209
|
+
interface IRegistryClient {
|
|
210
|
+
getPackument(name: string, options: {
|
|
211
|
+
registry: string;
|
|
212
|
+
token?: string;
|
|
213
|
+
}): Promise<Packument>;
|
|
214
|
+
}
|
|
215
|
+
//#endregion
|
|
216
|
+
//#region src/core/registry-client/hapic.d.ts
|
|
217
|
+
declare class HapicRegistryClient implements IRegistryClient {
|
|
218
|
+
getPackument(name: string, options: {
|
|
219
|
+
registry: string;
|
|
220
|
+
token?: string;
|
|
221
|
+
}): Promise<Packument>;
|
|
222
|
+
}
|
|
223
|
+
//#endregion
|
|
224
|
+
//#region src/core/registry-client/memory.d.ts
|
|
225
|
+
declare class MemoryRegistryClient implements IRegistryClient {
|
|
226
|
+
private readonly items;
|
|
227
|
+
constructor(items?: Record<string, Packument>);
|
|
228
|
+
getPackument(name: string): Promise<Packument>;
|
|
229
|
+
addPackument(name: string, packument: Packument): void;
|
|
230
|
+
}
|
|
231
|
+
//#endregion
|
|
232
|
+
//#region src/core/token-provider/types.d.ts
|
|
233
|
+
interface ITokenProvider {
|
|
234
|
+
getToken(packageName: string, registry: string): Promise<string | undefined>;
|
|
235
|
+
}
|
|
236
|
+
//#endregion
|
|
237
|
+
//#region src/core/token-provider/chain.d.ts
|
|
238
|
+
declare class ChainTokenProvider implements ITokenProvider {
|
|
239
|
+
private readonly providers;
|
|
240
|
+
constructor(providers: ITokenProvider[]);
|
|
241
|
+
getToken(packageName: string, registry: string): Promise<string | undefined>;
|
|
242
|
+
}
|
|
243
|
+
//#endregion
|
|
244
|
+
//#region src/core/token-provider/env.d.ts
|
|
245
|
+
declare class EnvTokenProvider implements ITokenProvider {
|
|
246
|
+
getToken(_packageName: string, _registry: string): Promise<string | undefined>;
|
|
247
|
+
}
|
|
248
|
+
//#endregion
|
|
249
|
+
//#region src/core/token-provider/memory.d.ts
|
|
250
|
+
declare class MemoryTokenProvider implements ITokenProvider {
|
|
251
|
+
private readonly token?;
|
|
252
|
+
constructor(token?: string);
|
|
253
|
+
getToken(_packageName: string, _registry: string): Promise<string | undefined>;
|
|
254
|
+
}
|
|
255
|
+
//#endregion
|
|
256
|
+
//#region src/core/token-provider/oidc.d.ts
|
|
257
|
+
type FetchFn = (url: string, init?: RequestInit) => Promise<Response>;
|
|
258
|
+
type OidcTokenProviderOptions = {
|
|
259
|
+
requestUrl: string;
|
|
260
|
+
requestToken: string;
|
|
261
|
+
fetchFn?: FetchFn;
|
|
262
|
+
maxRetries?: number;
|
|
263
|
+
retryDelayMs?: number;
|
|
264
|
+
};
|
|
265
|
+
declare class OidcTokenProvider implements ITokenProvider {
|
|
266
|
+
private readonly requestUrl;
|
|
267
|
+
private readonly requestToken;
|
|
268
|
+
private readonly fetchFn;
|
|
269
|
+
private readonly maxRetries;
|
|
270
|
+
private readonly retryDelayMs;
|
|
271
|
+
private readonly tokenCache;
|
|
272
|
+
constructor(options: OidcTokenProviderOptions);
|
|
273
|
+
getToken(packageName: string, registry: string): Promise<string | undefined>;
|
|
274
|
+
private fetchWithRetry;
|
|
275
|
+
private delay;
|
|
276
|
+
}
|
|
277
|
+
//#endregion
|
|
278
|
+
//#region src/types.d.ts
|
|
279
|
+
type PublishOptions = {
|
|
280
|
+
cwd?: string;
|
|
281
|
+
rootPackage?: boolean;
|
|
282
|
+
registry?: string;
|
|
283
|
+
token?: string;
|
|
284
|
+
dryRun?: boolean;
|
|
285
|
+
fileSystem?: IFileSystem;
|
|
286
|
+
registryClient?: IRegistryClient;
|
|
287
|
+
publisher?: IPackagePublisher;
|
|
288
|
+
tokenProvider?: ITokenProvider;
|
|
289
|
+
logger?: ILogger;
|
|
290
|
+
};
|
|
291
|
+
//#endregion
|
|
292
|
+
//#region src/module.d.ts
|
|
293
|
+
declare function publish(options?: PublishOptions): Promise<Package[]>;
|
|
294
|
+
//#endregion
|
|
295
|
+
//#region src/package.d.ts
|
|
296
|
+
declare function isPackagePublished(pkg: Package, registryClient: IRegistryClient, options: {
|
|
297
|
+
registry: string;
|
|
298
|
+
token?: string;
|
|
299
|
+
}): Promise<boolean>;
|
|
300
|
+
declare function publishPackage(pkg: Package, publisher: IPackagePublisher, options: {
|
|
301
|
+
token?: string;
|
|
302
|
+
registry: string;
|
|
303
|
+
}): Promise<boolean>;
|
|
304
|
+
declare function isPackagePublishable(pkg: Package): boolean;
|
|
305
|
+
//#endregion
|
|
306
|
+
//#region src/package-dependency.d.ts
|
|
307
|
+
declare function updatePackagesDependencies(packages: Package[]): void;
|
|
308
|
+
//#endregion
|
|
309
|
+
export { BaseError, ChainTokenProvider, ConsolaLogger, EnvTokenProvider, ExecFn, HapicRegistryClient, IFileSystem, ILogger, IPackagePublisher, IRegistryClient, ITokenProvider, MemoryFileSystem, MemoryPublisher, MemoryRegistryClient, MemoryTokenProvider, NodeFileSystem, NoopLogger, NpmCliPublisher, NpmPublisher, OidcTokenProvider, Package, PackageJson, Packument, PackumentVersion, PublishError, PublishOptions, RegistryError, isPackagePublishable, isPackagePublished, isRegistryError, publish, publishPackage, resolvePublisher, updatePackagesDependencies };
|
|
310
|
+
//# sourceMappingURL=index.d.mts.map
|