@bobfrankston/npmglobalize 1.0.83 → 1.0.84
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/cli.js +15 -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
|
|
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 {
|
|
@@ -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
|
}
|