@bobfrankston/npmglobalize 1.0.83 → 1.0.85

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.
Files changed (2) hide show
  1. package/cli.js +16 -3
  2. package/package.json +1 -1
package/cli.js CHANGED
@@ -2,7 +2,7 @@
2
2
  /**
3
3
  * npmglobalize CLI - Transform file: dependencies to npm versions for publishing
4
4
  */
5
- import { globalize, globalizeWorkspace, readConfig, readPackageJson, writeConfig, writePackageJson } from './lib.js';
5
+ import { globalize, globalizeWorkspace, readConfig, readPackageJson, writeConfig, writePackageJson, confirm } from './lib.js';
6
6
  import fs from 'fs';
7
7
  import path from 'path';
8
8
  import { styleText } from 'util';
@@ -327,7 +327,7 @@ export async function main() {
327
327
  process.exit(1);
328
328
  }
329
329
  }
330
- // Build the target project if it has a build script and tsconfig (not noEmit)
330
+ // Build the target project if it has tsconfig (not noEmit)
331
331
  if (!cliOptions.cleanup) {
332
332
  let shouldBuild = false;
333
333
  try {
@@ -341,6 +341,18 @@ export async function main() {
341
341
  }
342
342
  if (shouldBuild) {
343
343
  const pkg = JSON.parse(fs.readFileSync(path.join(cwd, 'package.json'), 'utf-8'));
344
+ if (!pkg.scripts?.build) {
345
+ // TypeScript project without a build script — offer to add one
346
+ console.log(styleText('yellow', `TypeScript project has no "build" script in ${cwd}`));
347
+ const addIt = await confirm('Add "build": "tsc" to package.json?', true);
348
+ if (addIt) {
349
+ if (!pkg.scripts)
350
+ pkg.scripts = {};
351
+ pkg.scripts.build = 'tsc';
352
+ writePackageJson(cwd, pkg);
353
+ console.log(styleText('green', '✓ Added "build": "tsc" to package.json'));
354
+ }
355
+ }
344
356
  if (pkg.scripts?.build) {
345
357
  const { execSync } = await import('child_process');
346
358
  try {
@@ -365,7 +377,7 @@ export async function main() {
365
377
  pkg.scripts = {};
366
378
  const scripts = pkg.scripts;
367
379
  const changes = [];
368
- if (scripts.release) {
380
+ if (scripts.release && scripts.release !== 'npmglobalize') {
369
381
  scripts['old-release'] = scripts.release;
370
382
  changes.push(`renamed release → old-release`);
371
383
  }
@@ -403,6 +415,7 @@ export async function main() {
403
415
  }
404
416
  }
405
417
  }
418
+ options._fromCli = true;
406
419
  const success = await globalize(cwd, options, configOptions);
407
420
  process.exit(success ? 0 : 1);
408
421
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobfrankston/npmglobalize",
3
- "version": "1.0.83",
3
+ "version": "1.0.85",
4
4
  "description": "Transform file: dependencies to npm versions for publishing",
5
5
  "main": "index.js",
6
6
  "type": "module",