@virmator/publish 14.30.7 → 14.31.0
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.
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** JSON-serializable results from npm's publish-time package.json checks. */
|
|
2
|
+
export type NpmPublishPackageJsonCheckResult = {
|
|
3
|
+
/** The corrections npm would report as publish warnings. */
|
|
4
|
+
warnings: string[];
|
|
5
|
+
/** Errors that prevent npm from checking the package.json. */
|
|
6
|
+
errors: string[];
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Runs npm's package.json normalization used during publishing without changing the source file.
|
|
10
|
+
*
|
|
11
|
+
* @category Internal
|
|
12
|
+
*/
|
|
13
|
+
export declare function checkPackageJsonHealth({ packageDirPath, }: Readonly<{
|
|
14
|
+
packageDirPath: string;
|
|
15
|
+
}>): Promise<NpmPublishPackageJsonCheckResult>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { check } from '@augment-vir/assert';
|
|
2
|
+
import NpmPackageJson from '@npmcli/package-json';
|
|
3
|
+
/**
|
|
4
|
+
* Runs npm's package.json normalization used during publishing without changing the source file.
|
|
5
|
+
*
|
|
6
|
+
* @category Internal
|
|
7
|
+
*/
|
|
8
|
+
export async function checkPackageJsonHealth({ packageDirPath, }) {
|
|
9
|
+
const warnings = [];
|
|
10
|
+
try {
|
|
11
|
+
const packageJson = await NpmPackageJson.fix(packageDirPath, {
|
|
12
|
+
changes: warnings,
|
|
13
|
+
});
|
|
14
|
+
await packageJson.prepare();
|
|
15
|
+
return {
|
|
16
|
+
warnings,
|
|
17
|
+
errors: [],
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
return {
|
|
22
|
+
warnings,
|
|
23
|
+
errors: [
|
|
24
|
+
check.isError(error) ? error.message : String(error),
|
|
25
|
+
],
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
}
|
package/dist/publish.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { type PackageJson } from '@augment-vir/common';
|
|
2
|
+
import { VirmatorNoTraceError } from '@virmator/core';
|
|
2
3
|
import { type SemVer } from 'semver';
|
|
4
|
+
export * from './npm-publish-package-json-check.js';
|
|
3
5
|
/** A virmator plugin for publishing a package to npm. */
|
|
4
6
|
export declare const virmatorPublishPlugin: Readonly<Readonly<{
|
|
5
7
|
name: string;
|
|
@@ -34,6 +36,12 @@ export declare const virmatorPublishPlugin: Readonly<Readonly<{
|
|
|
34
36
|
};
|
|
35
37
|
}>>;
|
|
36
38
|
}>;
|
|
39
|
+
/** Creates the error that prevents publishing an unhealthy package.json. */
|
|
40
|
+
export declare function createPackageJsonHealthError({ packageDirPath, warnings, errors, }: Readonly<{
|
|
41
|
+
packageDirPath: string;
|
|
42
|
+
warnings: ReadonlyArray<string>;
|
|
43
|
+
errors: ReadonlyArray<string>;
|
|
44
|
+
}>): VirmatorNoTraceError | undefined;
|
|
37
45
|
/**
|
|
38
46
|
* Asserts that a package's license field is valid if the package is going to be published.
|
|
39
47
|
*
|
package/dist/publish.js
CHANGED
|
@@ -10,6 +10,8 @@ import semver from 'semver';
|
|
|
10
10
|
import { simpleGit } from 'simple-git';
|
|
11
11
|
import { isValidSpdxExpression } from 'spdx-vir';
|
|
12
12
|
import { buildUrl } from 'url-vir';
|
|
13
|
+
import { checkPackageJsonHealth } from './npm-publish-package-json-check.js';
|
|
14
|
+
export * from './npm-publish-package-json-check.js';
|
|
13
15
|
const inVirmatorEnvKey = 'IN_VIRMATOR';
|
|
14
16
|
/**
|
|
15
17
|
* When true, publish through npm's staged publishing (`npm stage publish`), which requires later
|
|
@@ -188,6 +190,7 @@ export const virmatorPublishPlugin = defineVirmatorPlugin(import.meta.dirname, {
|
|
|
188
190
|
return undefined;
|
|
189
191
|
}
|
|
190
192
|
await alterPackageEntryPoints(packageCwd);
|
|
193
|
+
await assertPackageJsonHealth(packageCwd);
|
|
191
194
|
return publishCommand;
|
|
192
195
|
});
|
|
193
196
|
}
|
|
@@ -198,6 +201,7 @@ export const virmatorPublishPlugin = defineVirmatorPlugin(import.meta.dirname, {
|
|
|
198
201
|
return;
|
|
199
202
|
}
|
|
200
203
|
await alterPackageEntryPoints(monoRepoRootPath);
|
|
204
|
+
await assertPackageJsonHealth(monoRepoRootPath);
|
|
201
205
|
await runShellCommand(publishCommand);
|
|
202
206
|
}
|
|
203
207
|
await Promise.all(alteredPackageJsonFiles.map(async (alteredFile) => {
|
|
@@ -227,6 +231,31 @@ export const virmatorPublishPlugin = defineVirmatorPlugin(import.meta.dirname, {
|
|
|
227
231
|
}));
|
|
228
232
|
}
|
|
229
233
|
});
|
|
234
|
+
async function assertPackageJsonHealth(packageDirPath) {
|
|
235
|
+
const packageJsonHealth = await checkPackageJsonHealth({
|
|
236
|
+
packageDirPath,
|
|
237
|
+
});
|
|
238
|
+
const packageJsonHealthError = createPackageJsonHealthError({
|
|
239
|
+
packageDirPath,
|
|
240
|
+
...packageJsonHealth,
|
|
241
|
+
});
|
|
242
|
+
if (packageJsonHealthError) {
|
|
243
|
+
throw packageJsonHealthError;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
/** Creates the error that prevents publishing an unhealthy package.json. */
|
|
247
|
+
export function createPackageJsonHealthError({ packageDirPath, warnings, errors, }) {
|
|
248
|
+
const healthProblems = [
|
|
249
|
+
...errors.map((error) => `Error: ${error}`),
|
|
250
|
+
...warnings.map((warning) => `Warning: ${warning}`),
|
|
251
|
+
];
|
|
252
|
+
return healthProblems.length
|
|
253
|
+
? new VirmatorNoTraceError([
|
|
254
|
+
`npm publish package.json health check failed in '${packageDirPath}'.`,
|
|
255
|
+
...healthProblems,
|
|
256
|
+
].join('\n'))
|
|
257
|
+
: undefined;
|
|
258
|
+
}
|
|
230
259
|
async function updateGit(packageDirPath) {
|
|
231
260
|
const newVersion = (await readPackageJson(packageDirPath)).version;
|
|
232
261
|
assert.isDefined(newVersion);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@virmator/publish",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.31.0",
|
|
4
4
|
"description": "Default publish plugin for virmator.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"virmator",
|
|
@@ -34,19 +34,21 @@
|
|
|
34
34
|
"test:update": "npm test"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@augment-vir/assert": "^32.2.
|
|
38
|
-
"@augment-vir/common": "^32.2.
|
|
39
|
-
"@augment-vir/node": "^32.2.
|
|
40
|
-
"@
|
|
37
|
+
"@augment-vir/assert": "^32.2.2",
|
|
38
|
+
"@augment-vir/common": "^32.2.2",
|
|
39
|
+
"@augment-vir/node": "^32.2.2",
|
|
40
|
+
"@npmcli/package-json": "^8.0.0",
|
|
41
|
+
"@virmator/core": "^14.31.0",
|
|
41
42
|
"mri": "^1.2.0",
|
|
42
43
|
"semver": "^7.8.5",
|
|
43
44
|
"simple-git": "^3.36.0",
|
|
44
45
|
"spdx-vir": "^1.0.0",
|
|
45
|
-
"url-vir": "^2.1
|
|
46
|
+
"url-vir": "^2.2.1"
|
|
46
47
|
},
|
|
47
48
|
"devDependencies": {
|
|
48
|
-
"@augment-vir/test": "^32.2.
|
|
49
|
-
"@types/node": "^26.
|
|
49
|
+
"@augment-vir/test": "^32.2.2",
|
|
50
|
+
"@types/node": "^26.2.0",
|
|
51
|
+
"@types/npmcli__package-json": "^4.0.4",
|
|
50
52
|
"@types/semver": "^7.8.0",
|
|
51
53
|
"markdown-code-example-inserter": "^3.0.6",
|
|
52
54
|
"typedoc": "^0.28.20"
|