extension-create 4.0.0 → 4.0.1-canary.local-3d783a65
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
CHANGED
|
@@ -47,6 +47,9 @@ const external_fs_namespaceObject = require("fs");
|
|
|
47
47
|
const external_pintor_namespaceObject = require("pintor");
|
|
48
48
|
var external_pintor_default = /*#__PURE__*/ __webpack_require__.n(external_pintor_namespaceObject);
|
|
49
49
|
const external_prefers_yarn_namespaceObject = require("prefers-yarn");
|
|
50
|
+
function isDenoRuntime() {
|
|
51
|
+
return void 0 !== globalThis.Deno || Boolean(process.versions?.deno);
|
|
52
|
+
}
|
|
50
53
|
const statusPrefix = external_pintor_default().brightBlue('⏵⏵⏵');
|
|
51
54
|
function destinationNotWriteable(workingDir) {
|
|
52
55
|
const workingDirFolder = external_path_namespaceObject.basename(workingDir);
|
|
@@ -73,7 +76,10 @@ async function successfullInstall(projectPath, projectName, depsInstalled) {
|
|
|
73
76
|
const pm = (0, external_prefers_yarn_namespaceObject.detectPackageManagerFromEnv)();
|
|
74
77
|
let command = 'npm run';
|
|
75
78
|
let installCmd = 'npm install';
|
|
76
|
-
|
|
79
|
+
if (isDenoRuntime()) {
|
|
80
|
+
command = 'deno task dev';
|
|
81
|
+
installCmd = 'deno install';
|
|
82
|
+
} else switch(pm){
|
|
77
83
|
case 'yarn':
|
|
78
84
|
command = 'yarn dev';
|
|
79
85
|
installCmd = 'yarn';
|
|
@@ -82,6 +88,10 @@ async function successfullInstall(projectPath, projectName, depsInstalled) {
|
|
|
82
88
|
command = 'pnpm dev';
|
|
83
89
|
installCmd = 'pnpm install';
|
|
84
90
|
break;
|
|
91
|
+
case 'bun':
|
|
92
|
+
command = 'bun dev';
|
|
93
|
+
installCmd = 'bun install';
|
|
94
|
+
break;
|
|
85
95
|
default:
|
|
86
96
|
command = 'npm run dev';
|
|
87
97
|
installCmd = 'npm install';
|
|
@@ -332,6 +342,16 @@ async function withSuppressedOutput(task) {
|
|
|
332
342
|
function bundledTemplateDir(templateName) {
|
|
333
343
|
return external_path_namespaceObject.join(__dirname, '..', 'templates', templateName);
|
|
334
344
|
}
|
|
345
|
+
const TEMPLATE_SCAFFOLDING_FILES = [
|
|
346
|
+
'template.meta.json',
|
|
347
|
+
'template.spec.ts',
|
|
348
|
+
'screenshot.png'
|
|
349
|
+
];
|
|
350
|
+
async function removeTemplateScaffoldingFiles(projectPath) {
|
|
351
|
+
await Promise.all(TEMPLATE_SCAFFOLDING_FILES.map((name)=>promises_namespaceObject.rm(external_path_namespaceObject.join(projectPath, name), {
|
|
352
|
+
force: true
|
|
353
|
+
})));
|
|
354
|
+
}
|
|
335
355
|
function getArchiveBaseName(url) {
|
|
336
356
|
const withoutQuery = url.split('?')[0];
|
|
337
357
|
const fileName = external_path_namespaceObject.basename(withoutQuery);
|
|
@@ -368,7 +388,11 @@ async function importExternalTemplate(projectPath, projectName, template, logger
|
|
|
368
388
|
});
|
|
369
389
|
if (!isHttp && !isGithub && "javascript" === resolvedTemplate) {
|
|
370
390
|
const localTemplate = bundledTemplateDir("javascript");
|
|
371
|
-
if ((0, external_fs_namespaceObject.existsSync)(localTemplate))
|
|
391
|
+
if ((0, external_fs_namespaceObject.existsSync)(localTemplate)) {
|
|
392
|
+
await copyDirectoryWithSymlinks(localTemplate, projectPath);
|
|
393
|
+
await removeTemplateScaffoldingFiles(projectPath);
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
372
396
|
}
|
|
373
397
|
const tempRoot = await promises_namespaceObject.mkdtemp(external_path_namespaceObject.join(external_os_namespaceObject.tmpdir(), 'extension-js-create-'));
|
|
374
398
|
const tempPath = external_path_namespaceObject.join(tempRoot, projectName + '-temp');
|
|
@@ -404,6 +428,7 @@ async function importExternalTemplate(projectPath, projectName, template, logger
|
|
|
404
428
|
const srcPath = external_path_namespaceObject.join(tempPath, resolvedTemplateName);
|
|
405
429
|
await moveDirectoryContents(srcPath, projectPath);
|
|
406
430
|
}
|
|
431
|
+
await removeTemplateScaffoldingFiles(projectPath);
|
|
407
432
|
await promises_namespaceObject.rm(tempRoot, {
|
|
408
433
|
recursive: true,
|
|
409
434
|
force: true
|
|
@@ -451,6 +476,19 @@ function getTemplateAwareScripts(template, extensionBinary) {
|
|
|
451
476
|
}
|
|
452
477
|
return extensionJsPackageJsonScripts(extensionBinary);
|
|
453
478
|
}
|
|
479
|
+
const BUILD_NOOP_DEPENDENCIES = [
|
|
480
|
+
'less'
|
|
481
|
+
];
|
|
482
|
+
const ML_NATIVE_BUILD_DEPENDENCIES = [
|
|
483
|
+
'onnxruntime-node',
|
|
484
|
+
'sharp',
|
|
485
|
+
'protobufjs'
|
|
486
|
+
];
|
|
487
|
+
const ML_DEP_TRIGGERS = [
|
|
488
|
+
'@huggingface/transformers',
|
|
489
|
+
'@xenova/transformers'
|
|
490
|
+
];
|
|
491
|
+
const uniq = (values)=>Array.from(new Set(values.filter(Boolean)));
|
|
454
492
|
function resolveExtensionDevDependencyVersion(cliVersion) {
|
|
455
493
|
if (!cliVersion) return 'latest';
|
|
456
494
|
return cliVersion.includes('-') ? cliVersion : `^${cliVersion}`;
|
|
@@ -478,6 +516,25 @@ async function overridePackageJson(projectPath, projectName, { template = "javas
|
|
|
478
516
|
extension: 'development' === process.env.EXTENSION_ENV ? '*' : resolveExtensionDevDependencyVersion(cliVersion)
|
|
479
517
|
};
|
|
480
518
|
const packageManagerSpec = packageJson.packageManager || (0, external_prefers_yarn_namespaceObject.getPackageManagerSpec)();
|
|
519
|
+
const declaredDeps = {
|
|
520
|
+
...packageJson.dependencies || {},
|
|
521
|
+
...packageJson.devDependencies || {}
|
|
522
|
+
};
|
|
523
|
+
const usesMlNativeDeps = ML_DEP_TRIGGERS.some((dep)=>declaredDeps[dep]);
|
|
524
|
+
const nativeBuildDeps = usesMlNativeDeps ? ML_NATIVE_BUILD_DEPENDENCIES : [];
|
|
525
|
+
const existingPnpm = packageJson.pnpm && 'object' == typeof packageJson.pnpm ? packageJson.pnpm : {};
|
|
526
|
+
const ignoredBuilt = uniq([
|
|
527
|
+
...existingPnpm.ignoredBuiltDependencies || [],
|
|
528
|
+
...BUILD_NOOP_DEPENDENCIES
|
|
529
|
+
]);
|
|
530
|
+
const onlyBuilt = uniq([
|
|
531
|
+
...existingPnpm.onlyBuiltDependencies || [],
|
|
532
|
+
...nativeBuildDeps
|
|
533
|
+
]);
|
|
534
|
+
const trustedDeps = uniq([
|
|
535
|
+
...packageJson.trustedDependencies || [],
|
|
536
|
+
...nativeBuildDeps
|
|
537
|
+
]);
|
|
481
538
|
const packageMetadata = {
|
|
482
539
|
...packageJson,
|
|
483
540
|
name: external_path_namespaceObject.basename(projectPath),
|
|
@@ -491,6 +548,18 @@ async function overridePackageJson(projectPath, projectName, { template = "javas
|
|
|
491
548
|
},
|
|
492
549
|
dependencies: packageJson.dependencies,
|
|
493
550
|
devDependencies: packageJson.devDependencies,
|
|
551
|
+
pnpm: {
|
|
552
|
+
...existingPnpm,
|
|
553
|
+
...ignoredBuilt.length ? {
|
|
554
|
+
ignoredBuiltDependencies: ignoredBuilt
|
|
555
|
+
} : {},
|
|
556
|
+
...onlyBuilt.length ? {
|
|
557
|
+
onlyBuiltDependencies: onlyBuilt
|
|
558
|
+
} : {}
|
|
559
|
+
},
|
|
560
|
+
...trustedDeps.length ? {
|
|
561
|
+
trustedDependencies: trustedDeps
|
|
562
|
+
} : {},
|
|
494
563
|
author: {
|
|
495
564
|
name: 'Your Name',
|
|
496
565
|
email: 'your@email.com',
|
|
@@ -684,6 +753,9 @@ async function pathExists(target) {
|
|
|
684
753
|
}
|
|
685
754
|
async function writeReadmeFile(projectPath, projectName, logger) {
|
|
686
755
|
const installCommand = await getInstallCommand();
|
|
756
|
+
const deno = isDenoRuntime();
|
|
757
|
+
const runPrefix = deno ? 'deno task' : `${installCommand} run`;
|
|
758
|
+
const argSeparator = deno ? '' : ' --';
|
|
687
759
|
const manifestJsonPath = await findManifestJsonPath(projectPath);
|
|
688
760
|
const manifestJson = JSON.parse(await promises_namespaceObject.readFile(manifestJsonPath, 'utf-8'));
|
|
689
761
|
const description = String(manifestJson.description || '').trim();
|
|
@@ -691,7 +763,7 @@ async function writeReadmeFile(projectPath, projectName, logger) {
|
|
|
691
763
|
const hasScreenshot = await pathExists(screenshotPath);
|
|
692
764
|
const screenshotEmbed = hasScreenshot ? `\n\n` : '';
|
|
693
765
|
const blockquote = description ? `> ${description}\n\n` : '';
|
|
694
|
-
const readme = `<a href="https://extension.js.org" target="_blank" rel="noopener noreferrer"><img src="https://img.shields.io/badge/Powered%20by%20%7C%20Extension.js-0971fe" alt="Powered by Extension.js" align="right" /></a>\n\n# ${projectName}\n\n` + blockquote + `${screenshotEmbed}` + `## Commands\n` + `\n` + `### dev\n` + `\n` + "Run the extension in development mode. Target a browser with `--browser`:\n" + `\n` + "```bash\n" + `${
|
|
766
|
+
const readme = `<a href="https://extension.js.org" target="_blank" rel="noopener noreferrer"><img src="https://img.shields.io/badge/Powered%20by%20%7C%20Extension.js-0971fe" alt="Powered by Extension.js" align="right" /></a>\n\n# ${projectName}\n\n` + blockquote + `${screenshotEmbed}` + `## Commands\n` + `\n` + `### dev\n` + `\n` + "Run the extension in development mode. Target a browser with `--browser`:\n" + `\n` + "```bash\n" + `${runPrefix} dev\n` + `${runPrefix} dev${argSeparator} --browser=firefox\n` + `${runPrefix} dev${argSeparator} --browser=edge\n` + "```\n" + `\n` + `### build\n` + `\n` + `Build for production. Convenience scripts target each browser:\n` + `\n` + "```bash\n" + `${runPrefix} build # Chrome (default)\n` + `${runPrefix} build:firefox\n` + `${runPrefix} build:edge\n` + "```\n" + `\n` + `### preview\n` + `\n` + `Preview the production build in the browser:\n` + `\n` + "```bash\n" + `${runPrefix} preview\n` + "```\n" + `\n` + `## Learn more\n` + `\n` + `[Extension.js docs](https://extension.js.org).\n`;
|
|
695
767
|
try {
|
|
696
768
|
logger.log(writingReadmeMetaData());
|
|
697
769
|
await promises_namespaceObject.mkdir(projectPath, {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export declare const TEMPLATE_SCAFFOLDING_FILES: string[];
|
|
2
|
+
export declare function removeTemplateScaffoldingFiles(projectPath: string): Promise<void>;
|
|
1
3
|
export declare function importExternalTemplate(projectPath: string, projectName: string, template: string, logger: {
|
|
2
4
|
log(...args: any[]): void;
|
|
3
5
|
error(...args: any[]): void;
|
package/package.json
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"templates"
|
|
26
26
|
],
|
|
27
27
|
"name": "extension-create",
|
|
28
|
-
"version": "4.0.
|
|
28
|
+
"version": "4.0.1-canary.local-3d783a65",
|
|
29
29
|
"description": "The standalone extension creation engine for Extension.js",
|
|
30
30
|
"author": {
|
|
31
31
|
"name": "Cezar Augusto",
|
|
@@ -47,6 +47,8 @@
|
|
|
47
47
|
"format": "biome format --write .",
|
|
48
48
|
"lint": "biome lint .",
|
|
49
49
|
"pretest:create": "pnpm compile",
|
|
50
|
+
"pretest": "pnpm compile",
|
|
51
|
+
"test": "vitest run",
|
|
50
52
|
"test:create": "vitest run",
|
|
51
53
|
"test:coverage": "vitest run --coverage"
|
|
52
54
|
},
|
|
@@ -87,7 +89,7 @@
|
|
|
87
89
|
"@types/adm-zip": "^0.5.7",
|
|
88
90
|
"@types/chrome": "^0.1.33",
|
|
89
91
|
"@types/cross-spawn": "^6.0.6",
|
|
90
|
-
"@types/node": "^
|
|
92
|
+
"@types/node": "^26",
|
|
91
93
|
"@types/webextension-polyfill": "0.12.4",
|
|
92
94
|
"@vitest/coverage-v8": "^4.1.9",
|
|
93
95
|
"tsconfig": "*",
|