extension-create 3.3.3-next.15 → 3.3.3-next.17
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/module.js +68 -15
- package/package.json +1 -1
package/dist/module.js
CHANGED
|
@@ -463,6 +463,61 @@ function getInstallArgs() {
|
|
|
463
463
|
'--silent'
|
|
464
464
|
];
|
|
465
465
|
}
|
|
466
|
+
function getTagFallback(version) {
|
|
467
|
+
if ('*' === version || 'latest' === version || 'next' === version) return null;
|
|
468
|
+
const cleaned = version.replace(/^[~^]/, '');
|
|
469
|
+
return cleaned.includes('-') ? 'next' : 'latest';
|
|
470
|
+
}
|
|
471
|
+
async function updateExtensionDependencyTag(projectPath, projectName) {
|
|
472
|
+
const packageJsonPath = external_path_namespaceObject.join(projectPath, 'package.json');
|
|
473
|
+
try {
|
|
474
|
+
const raw = await external_fs_namespaceObject.promises.readFile(packageJsonPath, 'utf8');
|
|
475
|
+
const packageJson = JSON.parse(raw);
|
|
476
|
+
const currentVersion = packageJson?.devDependencies?.extension;
|
|
477
|
+
if ('string' != typeof currentVersion) return false;
|
|
478
|
+
const tag = getTagFallback(currentVersion);
|
|
479
|
+
if (!tag || currentVersion === tag) return false;
|
|
480
|
+
packageJson.devDependencies = {
|
|
481
|
+
...packageJson.devDependencies || {},
|
|
482
|
+
extension: tag
|
|
483
|
+
};
|
|
484
|
+
await external_fs_namespaceObject.promises.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2) + '\n');
|
|
485
|
+
return true;
|
|
486
|
+
} catch (error) {
|
|
487
|
+
console.error(cantInstallDependencies(projectName, error));
|
|
488
|
+
return false;
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
function shouldRetryWithTagFallback(output) {
|
|
492
|
+
const text = output.toLowerCase();
|
|
493
|
+
return text.includes('no matching version found for extension@') || text.includes('notarget') || text.includes('etarget');
|
|
494
|
+
}
|
|
495
|
+
async function runInstall(command, args, cwd, stdio) {
|
|
496
|
+
const child = (0, external_cross_spawn_namespaceObject.spawn)(command, args, {
|
|
497
|
+
stdio,
|
|
498
|
+
cwd
|
|
499
|
+
});
|
|
500
|
+
let stdout = '';
|
|
501
|
+
let stderr = '';
|
|
502
|
+
if (child.stdout) child.stdout.on('data', (chunk)=>{
|
|
503
|
+
stdout += chunk.toString();
|
|
504
|
+
});
|
|
505
|
+
if (child.stderr) child.stderr.on('data', (chunk)=>{
|
|
506
|
+
stderr += chunk.toString();
|
|
507
|
+
});
|
|
508
|
+
return new Promise((resolve, reject)=>{
|
|
509
|
+
child.on('close', (code)=>{
|
|
510
|
+
resolve({
|
|
511
|
+
code,
|
|
512
|
+
stderr,
|
|
513
|
+
stdout
|
|
514
|
+
});
|
|
515
|
+
});
|
|
516
|
+
child.on('error', (error)=>{
|
|
517
|
+
reject(error);
|
|
518
|
+
});
|
|
519
|
+
});
|
|
520
|
+
}
|
|
466
521
|
async function installDependencies(projectPath, projectName) {
|
|
467
522
|
const nodeModulesPath = external_path_namespaceObject.join(projectPath, 'node_modules');
|
|
468
523
|
const command = await getInstallCommand();
|
|
@@ -472,22 +527,20 @@ async function installDependencies(projectPath, projectName) {
|
|
|
472
527
|
await external_fs_namespaceObject.promises.mkdir(nodeModulesPath, {
|
|
473
528
|
recursive: true
|
|
474
529
|
});
|
|
475
|
-
const stdio = 'development' === process.env.EXTENSION_ENV ? 'inherit' : '
|
|
476
|
-
const
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
reject(error);
|
|
488
|
-
});
|
|
489
|
-
});
|
|
530
|
+
const stdio = 'development' === process.env.EXTENSION_ENV ? 'inherit' : 'pipe';
|
|
531
|
+
const firstRun = await runInstall(command, dependenciesArgs, projectPath, stdio);
|
|
532
|
+
if (0 !== firstRun.code) {
|
|
533
|
+
const output = `${firstRun.stdout}\n${firstRun.stderr}`;
|
|
534
|
+
const shouldRetry = shouldRetryWithTagFallback(output);
|
|
535
|
+
const didUpdate = shouldRetry ? await updateExtensionDependencyTag(projectPath, projectName) : false;
|
|
536
|
+
if (didUpdate) {
|
|
537
|
+
const retryRun = await runInstall(command, dependenciesArgs, projectPath, stdio);
|
|
538
|
+
if (0 === retryRun.code) return;
|
|
539
|
+
}
|
|
540
|
+
throw new Error(installingDependenciesFailed(command, dependenciesArgs, firstRun.code));
|
|
541
|
+
}
|
|
490
542
|
} catch (error) {
|
|
543
|
+
console.error(installingDependenciesProcessError(projectName, error));
|
|
491
544
|
console.error(cantInstallDependencies(projectName, error));
|
|
492
545
|
throw error;
|
|
493
546
|
}
|