@virmator/publish 14.19.2 → 14.21.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.
package/dist/publish.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { type PackageJson } from 'type-fest';
1
2
  /** A virmator plugin for publishing a package to npm. */
2
3
  export declare const virmatorPublishPlugin: Readonly<Readonly<{
3
4
  name: string;
@@ -32,3 +33,13 @@ export declare const virmatorPublishPlugin: Readonly<Readonly<{
32
33
  };
33
34
  }>>;
34
35
  }>;
36
+ /**
37
+ * Asserts that a package's license field is valid if the package is going to be published.
38
+ *
39
+ * @category Internal
40
+ */
41
+ export declare function assertValidLicense({ license, isPrivate, displayName, }: {
42
+ license: PackageJson['license'];
43
+ isPrivate: PackageJson['private'];
44
+ displayName: string;
45
+ }): void;
package/dist/publish.js CHANGED
@@ -8,6 +8,7 @@ import { readFile, writeFile } from 'node:fs/promises';
8
8
  import { join, relative, resolve } from 'node:path';
9
9
  import semver from 'semver';
10
10
  import { simpleGit } from 'simple-git';
11
+ import { isValidSpdxExpression } from 'spdx-vir';
11
12
  const inVirmatorEnvKey = 'IN_VIRMATOR';
12
13
  /** A virmator plugin for publishing a package to npm. */
13
14
  export const virmatorPublishPlugin = defineVirmatorPlugin(import.meta.dirname, {
@@ -42,6 +43,11 @@ export const virmatorPublishPlugin = defineVirmatorPlugin(import.meta.dirname, {
42
43
  else if (!cwdValidPackageJson) {
43
44
  throw new VirmatorNoTraceError('Missing "name" / "version" package.json fields.');
44
45
  }
46
+ assertValidLicense({
47
+ license: cwdValidPackageJson.license,
48
+ isPrivate: cwdValidPackageJson.private,
49
+ displayName: cwdValidPackageJson.name,
50
+ });
45
51
  const monoRepoPackageJson = await readPackageJson(monoRepoRootPath);
46
52
  const version = monoRepoPackageJson.version;
47
53
  if (!version) {
@@ -66,6 +72,11 @@ export const virmatorPublishPlugin = defineVirmatorPlugin(import.meta.dirname, {
66
72
  else if (!packageJson.version) {
67
73
  throw new VirmatorNoTraceError(`No package.json version in '${packageJson.name}'`);
68
74
  }
75
+ assertValidLicense({
76
+ license: packageJson.license,
77
+ isPrivate: packageJson.private,
78
+ displayName: packageJson.name,
79
+ });
69
80
  return packageJson;
70
81
  }));
71
82
  const git = simpleGit(monoRepoRootPath);
@@ -197,6 +208,22 @@ async function updateGit(packageDirPath) {
197
208
  rejectOnError: true,
198
209
  });
199
210
  }
211
+ /**
212
+ * Asserts that a package's license field is valid if the package is going to be published.
213
+ *
214
+ * @category Internal
215
+ */
216
+ export function assertValidLicense({ license, isPrivate, displayName, }) {
217
+ if (isPrivate) {
218
+ return;
219
+ }
220
+ else if (!check.isString(license) || !license) {
221
+ throw new VirmatorNoTraceError(`Missing 'license' field in '${displayName}'.`);
222
+ }
223
+ else if (!isValidSpdxExpression(license)) {
224
+ throw new VirmatorNoTraceError(`Invalid SPDX license expression '${license}' in '${displayName}'.`);
225
+ }
226
+ }
200
227
  async function doChangesExist(repoDirPath) {
201
228
  const getChangesOutput = await runHiddenShellCommand('git status --porcelain=v1 2>/dev/null', {
202
229
  cwd: repoDirPath,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@virmator/publish",
3
- "version": "14.19.2",
3
+ "version": "14.21.0",
4
4
  "description": "Default publish plugin for virmator.",
5
5
  "keywords": [
6
6
  "virmator",
@@ -29,22 +29,24 @@
29
29
  "types": "dist/publish.d.ts",
30
30
  "scripts": {
31
31
  "compile": "virmator compile",
32
- "test": "exit 0",
32
+ "test": "virmator test node",
33
33
  "test:coverage": "npm test",
34
34
  "test:update": "npm test"
35
35
  },
36
36
  "dependencies": {
37
- "@augment-vir/assert": "^31.69.0",
38
- "@augment-vir/common": "^31.69.0",
39
- "@augment-vir/node": "^31.69.0",
40
- "@virmator/core": "^14.19.2",
37
+ "@augment-vir/assert": "^31.71.3",
38
+ "@augment-vir/common": "^31.71.3",
39
+ "@augment-vir/node": "^31.71.3",
40
+ "@virmator/core": "^14.21.0",
41
41
  "mri": "^1.2.0",
42
- "semver": "^7.7.4",
42
+ "semver": "^7.8.1",
43
43
  "simple-git": "^3.36.0",
44
+ "spdx-vir": "^0.0.1",
44
45
  "url-vir": "^2.1.9"
45
46
  },
46
47
  "devDependencies": {
47
- "@types/node": "^25.6.0",
48
+ "@augment-vir/test": "^31.71.3",
49
+ "@types/node": "^25.9.1",
48
50
  "@types/semver": "^7.7.1",
49
51
  "markdown-code-example-inserter": "^3.0.5",
50
52
  "type-fest": "^5.6.0",