@bobfrankston/npmglobalize 1.0.122 → 1.0.123
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/lib.js +71 -62
- package/package.json +1 -1
package/lib.js
CHANGED
|
@@ -814,18 +814,6 @@ export function restoreDeps(pkg, verbose = false) {
|
|
|
814
814
|
}
|
|
815
815
|
}
|
|
816
816
|
}
|
|
817
|
-
// Remove bundledDependencies added for workspace hoisting
|
|
818
|
-
if (pkg['.bundledDependencies']) {
|
|
819
|
-
if (pkg['.bundledDependencies'].length === 0) {
|
|
820
|
-
delete pkg.bundledDependencies;
|
|
821
|
-
delete pkg.bundleDependencies;
|
|
822
|
-
}
|
|
823
|
-
else {
|
|
824
|
-
pkg.bundledDependencies = pkg['.bundledDependencies'];
|
|
825
|
-
}
|
|
826
|
-
delete pkg['.bundledDependencies'];
|
|
827
|
-
restored = true;
|
|
828
|
-
}
|
|
829
817
|
return restored;
|
|
830
818
|
}
|
|
831
819
|
/** Check if .dependencies exist (already transformed) */
|
|
@@ -3099,22 +3087,6 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
|
|
|
3099
3087
|
pkg.dependencies[m.dep] = version;
|
|
3100
3088
|
console.log(colors.green(` + hoisted ${m.dep}: ${version} (from ${m.from})`));
|
|
3101
3089
|
}
|
|
3102
|
-
// Add workspace sibling packages to dependencies + bundledDependencies
|
|
3103
|
-
// so npm includes them in the tarball's node_modules/
|
|
3104
|
-
// Save original bundledDependencies for restore
|
|
3105
|
-
const origBundled = pkg.bundledDependencies || pkg.bundleDependencies || [];
|
|
3106
|
-
pkg['.bundledDependencies'] = [...origBundled];
|
|
3107
|
-
const bundled = [...origBundled];
|
|
3108
|
-
for (const [name, relDir] of wsPackages) {
|
|
3109
|
-
if (!(name in pkg.dependencies)) {
|
|
3110
|
-
pkg.dependencies[name] = 'file:./' + relDir;
|
|
3111
|
-
}
|
|
3112
|
-
if (!bundled.includes(name)) {
|
|
3113
|
-
bundled.push(name);
|
|
3114
|
-
}
|
|
3115
|
-
console.log(colors.green(` + bundled workspace ${name} (./${relDir})`));
|
|
3116
|
-
}
|
|
3117
|
-
pkg.bundledDependencies = bundled;
|
|
3118
3090
|
if (!dryRun) {
|
|
3119
3091
|
writePackageJson(cwd, pkg);
|
|
3120
3092
|
}
|
|
@@ -3256,40 +3228,56 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
|
|
|
3256
3228
|
}
|
|
3257
3229
|
}
|
|
3258
3230
|
else if (install) {
|
|
3259
|
-
//
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
if (vOnNpm) {
|
|
3267
|
-
console.log(`Installing ${pkgName}@${pkgVersion} globally from registry...`);
|
|
3268
|
-
const registryInstallResult = installGlobalWithRetry(`${pkgName}@${pkgVersion}`, cwd);
|
|
3269
|
-
if (registryInstallResult.success) {
|
|
3231
|
+
// Workspace packages must install from local — npm install -g from
|
|
3232
|
+
// registry doesn't process workspaces, so sub-packages can't resolve
|
|
3233
|
+
// sibling imports. Local install handles workspace linking correctly.
|
|
3234
|
+
if (pkg.workspaces) {
|
|
3235
|
+
console.log(`Installing ${pkgName}@${pkgVersion} globally from local (workspace)...`);
|
|
3236
|
+
const localResult = runCommand('npm', ['install', '-g', '.'], { cwd, silent: false, showCommand: true });
|
|
3237
|
+
if (localResult.success) {
|
|
3270
3238
|
console.log(colors.green(`✓ Installed globally: ${pkgName}@${pkgVersion}`));
|
|
3271
3239
|
}
|
|
3272
3240
|
else {
|
|
3273
3241
|
console.error(colors.red(`✗ Global install failed`));
|
|
3274
|
-
console.error(colors.yellow(
|
|
3242
|
+
console.error(colors.yellow(' Try running manually: npm install -g .'));
|
|
3275
3243
|
}
|
|
3276
3244
|
}
|
|
3277
3245
|
else {
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3246
|
+
// Quick check: does this version actually exist on npm?
|
|
3247
|
+
const vCheck = spawnSafe('npm', ['view', `${pkgName}@${pkgVersion}`, 'version'], {
|
|
3248
|
+
shell: process.platform === 'win32',
|
|
3249
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
3250
|
+
encoding: 'utf-8'
|
|
3251
|
+
});
|
|
3252
|
+
const vOnNpm = vCheck.status === 0 && vCheck.stdout?.trim() === pkgVersion;
|
|
3253
|
+
if (vOnNpm) {
|
|
3254
|
+
console.log(`Installing ${pkgName}@${pkgVersion} globally from registry...`);
|
|
3255
|
+
const registryInstallResult = installGlobalWithRetry(`${pkgName}@${pkgVersion}`, cwd);
|
|
3256
|
+
if (registryInstallResult.success) {
|
|
3257
|
+
console.log(colors.green(`✓ Installed globally: ${pkgName}@${pkgVersion}`));
|
|
3258
|
+
}
|
|
3259
|
+
else {
|
|
3260
|
+
console.error(colors.red(`✗ Global install failed`));
|
|
3261
|
+
console.error(colors.yellow(` Try running manually: npm install -g ${pkgName}@${pkgVersion}`));
|
|
3262
|
+
}
|
|
3283
3263
|
}
|
|
3284
3264
|
else {
|
|
3285
|
-
console.
|
|
3286
|
-
console.
|
|
3265
|
+
console.log(colors.yellow(`${pkgName}@${pkgVersion} not found on npm — installing from local directory.`));
|
|
3266
|
+
console.log(colors.dim(' Use -m "message" to publish this version to npm.'));
|
|
3267
|
+
const localResult = runCommand('npm', ['install', '-g', '.'], { cwd, silent: false, showCommand: true });
|
|
3268
|
+
if (localResult.success) {
|
|
3269
|
+
console.log(colors.green(`✓ Installed globally from local: ${pkgName}@${pkgVersion}`));
|
|
3270
|
+
}
|
|
3271
|
+
else {
|
|
3272
|
+
console.error(colors.red(`✗ Local install failed`));
|
|
3273
|
+
console.error(colors.yellow(' Try running manually: npm install -g .'));
|
|
3274
|
+
}
|
|
3287
3275
|
}
|
|
3288
3276
|
}
|
|
3289
3277
|
}
|
|
3290
3278
|
if (wsl) {
|
|
3291
|
-
//
|
|
3292
|
-
const useLocal = link || (() => {
|
|
3279
|
+
// Workspace packages must install from local (see above)
|
|
3280
|
+
const useLocal = link || !!pkg.workspaces || (() => {
|
|
3293
3281
|
const vc = spawnSafe('npm', ['view', `${pkgName}@${pkgVersion}`, 'version'], {
|
|
3294
3282
|
shell: process.platform === 'win32',
|
|
3295
3283
|
stdio: ['pipe', 'pipe', 'pipe'],
|
|
@@ -3868,28 +3856,49 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
|
|
|
3868
3856
|
}
|
|
3869
3857
|
}
|
|
3870
3858
|
else if (install) {
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
3859
|
+
if (updatedPkg.workspaces) {
|
|
3860
|
+
// Workspace packages: install from local for proper workspace linking
|
|
3861
|
+
console.log(`Installing ${pkgName}@${pkgVersion} globally from local (workspace)...`);
|
|
3862
|
+
if (!dryRun) {
|
|
3863
|
+
const installResult = runCommand('npm', ['install', '-g', '.'], { cwd, silent: false, showCommand: true });
|
|
3864
|
+
if (installResult.success) {
|
|
3865
|
+
globalInstallOk = true;
|
|
3866
|
+
console.log(colors.green(`✓ Installed globally: ${pkgName}@${pkgVersion}`));
|
|
3867
|
+
}
|
|
3868
|
+
else {
|
|
3869
|
+
console.error(colors.red(`✗ Global install failed`));
|
|
3870
|
+
console.error(colors.yellow(' Try running manually: npm install -g .'));
|
|
3871
|
+
}
|
|
3878
3872
|
}
|
|
3879
3873
|
else {
|
|
3880
|
-
console.
|
|
3881
|
-
console.error(colors.yellow(` Try running manually: npm install -g ${pkgName}@${pkgVersion}`));
|
|
3874
|
+
console.log(` [dry-run] Would run: npm install -g .`);
|
|
3882
3875
|
}
|
|
3883
3876
|
}
|
|
3884
3877
|
else {
|
|
3885
|
-
console.log(`
|
|
3878
|
+
console.log(`Installing globally from registry: ${pkgName}@${pkgVersion}...`);
|
|
3879
|
+
if (!dryRun) {
|
|
3880
|
+
waitForNpmVersion(pkgName, pkgVersion);
|
|
3881
|
+
const installResult = installGlobalWithRetry(`${pkgName}@${pkgVersion}`, cwd);
|
|
3882
|
+
if (installResult.success) {
|
|
3883
|
+
globalInstallOk = true;
|
|
3884
|
+
console.log(colors.green(`✓ Installed globally: ${pkgName}@${pkgVersion}`));
|
|
3885
|
+
}
|
|
3886
|
+
else {
|
|
3887
|
+
console.error(colors.red(`✗ Global install failed`));
|
|
3888
|
+
console.error(colors.yellow(` Try running manually: npm install -g ${pkgName}@${pkgVersion}`));
|
|
3889
|
+
}
|
|
3890
|
+
}
|
|
3891
|
+
else {
|
|
3892
|
+
console.log(` [dry-run] Would run: npm install -g ${pkgName}@${pkgVersion}`);
|
|
3893
|
+
}
|
|
3886
3894
|
}
|
|
3887
3895
|
}
|
|
3888
3896
|
if (wsl) {
|
|
3889
|
-
const
|
|
3890
|
-
|
|
3897
|
+
const useLocalWsl = link || !!updatedPkg.workspaces;
|
|
3898
|
+
const wslArgs = useLocalWsl ? ['npm', 'install', '-g', '.'] : ['npm', 'install', '-g', `${pkgName}@${pkgVersion}`];
|
|
3899
|
+
if (!useLocalWsl)
|
|
3891
3900
|
waitForNpmVersion(pkgName, pkgVersion);
|
|
3892
|
-
console.log(`Installing in WSL${
|
|
3901
|
+
console.log(`Installing in WSL${useLocalWsl ? ' (local)' : ' from registry'}: ${pkgName}@${pkgVersion}...`);
|
|
3893
3902
|
if (!dryRun) {
|
|
3894
3903
|
const wslResult = runCommand('wsl', wslArgs, { cwd, silent: false, showCommand: true });
|
|
3895
3904
|
if (wslResult.success) {
|