@virmator/publish 14.34.0 → 14.35.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/dist/publish.d.ts CHANGED
@@ -40,6 +40,16 @@ export declare const virmatorPublishPlugin: Readonly<Readonly<{
40
40
  };
41
41
  }>>;
42
42
  }>;
43
+ /**
44
+ * Rewrites TypeScript bin entry points to their compiled JavaScript paths.
45
+ *
46
+ * @category Internal
47
+ */
48
+ export declare function updatePackageJsonBinPaths({ packageJsonContents, bin, outDir, }: Readonly<{
49
+ packageJsonContents: string;
50
+ bin: PackageJson['bin'];
51
+ outDir: string;
52
+ }>): string;
43
53
  /**
44
54
  * Creates the error that prevents publishing an unhealthy package.json.
45
55
  *
package/dist/publish.js CHANGED
@@ -167,6 +167,11 @@ export const virmatorPublishPlugin = defineVirmatorPlugin(import.meta.dirname, {
167
167
  if (packageJson.types?.startsWith('src')) {
168
168
  packageJsonContents = packageJsonContents.replace(`"types": "${packageJson.types}"`, `"types": "${packageJson.types.replace('src', outDir).replace('.ts', '.d.ts')}"`);
169
169
  }
170
+ packageJsonContents = updatePackageJsonBinPaths({
171
+ packageJsonContents,
172
+ bin: packageJson.bin,
173
+ outDir,
174
+ });
170
175
  if (packageJsonContents !== alteredJsonFile.original) {
171
176
  alteredPackageJsonFiles.push(alteredJsonFile);
172
177
  await writeFile(alteredJsonFile.path, packageJsonContents);
@@ -184,6 +189,14 @@ export const virmatorPublishPlugin = defineVirmatorPlugin(import.meta.dirname, {
184
189
  !existsSync(join(packagePath, updatedPackageJson.types))) {
185
190
  throw new Error(`Missing 'types' file '${updatedPackageJson.types}' from '${relative(monoRepoRootPath, packageJsonPath)}'.`);
186
191
  }
192
+ else {
193
+ const missingBinPath = getPackageBinPaths(updatedPackageJson.bin).find((binPath) => {
194
+ return !existsSync(join(packagePath, binPath));
195
+ });
196
+ if (missingBinPath) {
197
+ throw new Error(`Missing 'bin' file '${missingBinPath}' from '${relative(monoRepoRootPath, packageJsonPath)}'.`);
198
+ }
199
+ }
187
200
  }
188
201
  try {
189
202
  if (monoRepoPackages.length) {
@@ -235,6 +248,32 @@ export const virmatorPublishPlugin = defineVirmatorPlugin(import.meta.dirname, {
235
248
  }));
236
249
  }
237
250
  });
251
+ /**
252
+ * Rewrites TypeScript bin entry points to their compiled JavaScript paths.
253
+ *
254
+ * @category Internal
255
+ */
256
+ export function updatePackageJsonBinPaths({ packageJsonContents, bin, outDir, }) {
257
+ const binScriptPaths = getPackageBinPaths(bin).filter((binPath) => binPath.endsWith('.ts'));
258
+ if (!binScriptPaths.length) {
259
+ return packageJsonContents;
260
+ }
261
+ else if (check.isString(bin)) {
262
+ return packageJsonContents.replace(new RegExp(String.raw `("bin"\s*:\s*)"${escapeRegExp(bin)}"`), (binProperty) => {
263
+ return binProperty.replace(bin, bin.replace('src', outDir).replace('.ts', '.js'));
264
+ });
265
+ }
266
+ else {
267
+ return packageJsonContents.replace(/"bin"\s*:\s*\{[^{}]*}/, (binProperty) => {
268
+ return binScriptPaths.reduce((updatedBinProperty, binScriptPath) => {
269
+ return updatedBinProperty.replaceAll(`"${binScriptPath}"`, `"${binScriptPath.replace('src', outDir).replace('.ts', '.js')}"`);
270
+ }, binProperty);
271
+ });
272
+ }
273
+ }
274
+ function getPackageBinPaths(bin) {
275
+ return check.isString(bin) ? [bin] : getObjectTypedValues(bin || {}).filter(check.isString);
276
+ }
238
277
  async function assertPackageJsonHealth(packageDirPath) {
239
278
  const packageJsonHealth = await checkPackageJsonHealth({
240
279
  packageDirPath,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@virmator/publish",
3
- "version": "14.34.0",
3
+ "version": "14.35.1",
4
4
  "description": "Default publish plugin for virmator.",
5
5
  "keywords": [
6
6
  "virmator",
@@ -38,7 +38,7 @@
38
38
  "@augment-vir/common": "^32.2.4",
39
39
  "@augment-vir/node": "^32.2.4",
40
40
  "@npmcli/package-json": "^8.0.0",
41
- "@virmator/core": "^14.34.0",
41
+ "@virmator/core": "^14.35.1",
42
42
  "mri": "^1.2.0",
43
43
  "semver": "^7.8.5",
44
44
  "simple-git": "^3.36.0",