extension-create 3.8.7 → 3.8.8
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.cjs +47 -11
- package/dist/steps/write-package-json.d.ts +1 -1
- package/package.json +1 -1
package/dist/module.cjs
CHANGED
|
@@ -380,14 +380,50 @@ async function importExternalTemplate(projectPath, projectName, template) {
|
|
|
380
380
|
throw error;
|
|
381
381
|
}
|
|
382
382
|
}
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
}
|
|
390
|
-
|
|
383
|
+
async function resolveExtensionBinary() {
|
|
384
|
+
const developRoot = process.env.EXTENSION_CREATE_DEVELOP_ROOT;
|
|
385
|
+
if (developRoot) {
|
|
386
|
+
const localCliPath = external_path_namespaceObject.resolve(developRoot, '..', 'cli', 'dist', 'cli.cjs');
|
|
387
|
+
try {
|
|
388
|
+
await promises_namespaceObject.access(localCliPath);
|
|
389
|
+
return `node "${localCliPath}"`;
|
|
390
|
+
} catch {}
|
|
391
|
+
}
|
|
392
|
+
if ('development' === process.env.EXTENSION_ENV) return 'node node_modules/extension';
|
|
393
|
+
return 'extension';
|
|
394
|
+
}
|
|
395
|
+
function extensionJsPackageJsonScripts(extensionBinary) {
|
|
396
|
+
return {
|
|
397
|
+
dev: `${extensionBinary} dev`,
|
|
398
|
+
start: `${extensionBinary} start`,
|
|
399
|
+
build: `${extensionBinary} build`,
|
|
400
|
+
preview: `${extensionBinary} preview`,
|
|
401
|
+
'build:chrome': `${extensionBinary} build --browser chrome`,
|
|
402
|
+
'build:firefox': `${extensionBinary} build --browser firefox`,
|
|
403
|
+
'build:edge': `${extensionBinary} build --browser edge`
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
function getTemplateAwareScripts(template, extensionBinary) {
|
|
407
|
+
if (String(template).toLowerCase().includes('monorepo')) {
|
|
408
|
+
const target = 'packages/extension';
|
|
409
|
+
return {
|
|
410
|
+
dev: `${extensionBinary} dev ${target}`,
|
|
411
|
+
start: `${extensionBinary} start ${target}`,
|
|
412
|
+
build: `${extensionBinary} build ${target}`,
|
|
413
|
+
preview: `${extensionBinary} preview ${target}`,
|
|
414
|
+
'build:chrome': `${extensionBinary} build ${target} --browser chrome`,
|
|
415
|
+
'build:firefox': `${extensionBinary} build ${target} --browser firefox`,
|
|
416
|
+
'build:edge': `${extensionBinary} build ${target} --browser edge`
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
return extensionJsPackageJsonScripts(extensionBinary);
|
|
420
|
+
}
|
|
421
|
+
function resolveExtensionDevDependencyVersion(cliVersion) {
|
|
422
|
+
if (!cliVersion) return 'latest';
|
|
423
|
+
return cliVersion.includes('-') ? cliVersion : `^${cliVersion}`;
|
|
424
|
+
}
|
|
425
|
+
async function overridePackageJson(projectPath, projectName, { template, cliVersion }) {
|
|
426
|
+
const extensionBinary = await resolveExtensionBinary();
|
|
391
427
|
const candidatePath = external_path_namespaceObject.join(projectPath, 'package.json');
|
|
392
428
|
let packageJson = {};
|
|
393
429
|
try {
|
|
@@ -406,7 +442,7 @@ async function overridePackageJson(projectPath, projectName, { template: _templa
|
|
|
406
442
|
packageJson.dependencies = packageJson.dependencies || {};
|
|
407
443
|
packageJson.devDependencies = {
|
|
408
444
|
...packageJson.devDependencies || {},
|
|
409
|
-
extension: 'development' === process.env.EXTENSION_ENV ? '*' :
|
|
445
|
+
extension: 'development' === process.env.EXTENSION_ENV ? '*' : resolveExtensionDevDependencyVersion(cliVersion)
|
|
410
446
|
};
|
|
411
447
|
const packageManagerSpec = packageJson.packageManager || getPackageManagerSpecFromEnv();
|
|
412
448
|
const packageMetadata = {
|
|
@@ -417,8 +453,8 @@ async function overridePackageJson(projectPath, projectName, { template: _templa
|
|
|
417
453
|
packageManager: packageManagerSpec
|
|
418
454
|
} : {},
|
|
419
455
|
scripts: {
|
|
420
|
-
...
|
|
421
|
-
...
|
|
456
|
+
...getTemplateAwareScripts(template, extensionBinary),
|
|
457
|
+
...packageJson.scripts
|
|
422
458
|
},
|
|
423
459
|
dependencies: packageJson.dependencies,
|
|
424
460
|
devDependencies: packageJson.devDependencies,
|
|
@@ -2,5 +2,5 @@ interface OverridePackageJsonOptions {
|
|
|
2
2
|
template: string;
|
|
3
3
|
cliVersion?: string;
|
|
4
4
|
}
|
|
5
|
-
export declare function overridePackageJson(projectPath: string, projectName: string, { template
|
|
5
|
+
export declare function overridePackageJson(projectPath: string, projectName: string, { template, cliVersion }: OverridePackageJsonOptions): Promise<void>;
|
|
6
6
|
export {};
|