extension-create 3.6.2 → 3.7.0-canary.169.5b5db8b

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.
Files changed (2) hide show
  1. package/dist/module.cjs +66 -252
  2. package/package.json +4 -7
package/dist/module.cjs CHANGED
@@ -202,23 +202,6 @@ function cantSetupBuiltInTests(projectName, error) {
202
202
  return `${external_pintor_default().red('Error')} Couldn't set up built-in tests for ${external_pintor_default().yellow(projectName)}.\n${external_pintor_default().red(String(error))}\n${external_pintor_default().red('Next step: run the setup step again or skip tests.')}`;
203
203
  }
204
204
  const promises_namespaceObject = require("fs/promises");
205
- async function copyDirectoryWithSymlinks(source, destination) {
206
- const entries = await promises_namespaceObject.readdir(source, {
207
- withFileTypes: true
208
- });
209
- await promises_namespaceObject.mkdir(destination, {
210
- recursive: true
211
- });
212
- for (const entry of entries){
213
- const sourcePath = external_path_namespaceObject.join(source, entry.name);
214
- const destPath = external_path_namespaceObject.join(destination, entry.name);
215
- if (entry.isDirectory()) await copyDirectoryWithSymlinks(sourcePath, destPath);
216
- else if (entry.isSymbolicLink()) {
217
- const target = await promises_namespaceObject.readlink(sourcePath);
218
- await promises_namespaceObject.symlink(target, destPath);
219
- } else await promises_namespaceObject.copyFile(sourcePath, destPath);
220
- }
221
- }
222
205
  async function moveDirectoryContents(source, destination) {
223
206
  await promises_namespaceObject.mkdir(destination, {
224
207
  recursive: true
@@ -230,10 +213,18 @@ async function moveDirectoryContents(source, destination) {
230
213
  const sourcePath = external_path_namespaceObject.join(source, entry.name);
231
214
  const destPath = external_path_namespaceObject.join(destination, entry.name);
232
215
  if (entry.isDirectory()) await moveDirectoryContents(sourcePath, destPath);
233
- else if (entry.isSymbolicLink()) {
216
+ else if (entry.isSymbolicLink()) try {
234
217
  const target = await promises_namespaceObject.readlink(sourcePath);
235
218
  await promises_namespaceObject.symlink(target, destPath);
236
- } else try {
219
+ } catch (err) {
220
+ if (err?.code === 'EPERM' || err?.code === 'ENOTSUP') {
221
+ const real = await promises_namespaceObject.realpath(sourcePath);
222
+ await promises_namespaceObject.cp(real, destPath, {
223
+ recursive: true
224
+ });
225
+ } else throw err;
226
+ }
227
+ else try {
237
228
  await promises_namespaceObject.rename(sourcePath, destPath);
238
229
  } catch (err) {
239
230
  if (err && ('EXDEV' === err.code || 'EINVAL' === err.code)) {
@@ -303,148 +294,55 @@ var external_adm_zip_default = /*#__PURE__*/ __webpack_require__.n(external_adm_
303
294
  const external_go_git_it_namespaceObject = require("go-git-it");
304
295
  var external_go_git_it_default = /*#__PURE__*/ __webpack_require__.n(external_go_git_it_namespaceObject);
305
296
  const import_external_template_filename = (0, external_url_namespaceObject.fileURLToPath)(__rslib_import_meta_url__);
306
- const import_external_template_dirname = external_path_namespaceObject.dirname(import_external_template_filename);
297
+ external_path_namespaceObject.dirname(import_external_template_filename);
307
298
  async function importExternalTemplate(projectPath, projectName, template) {
308
299
  const templateName = external_path_namespaceObject.basename(template);
309
300
  const examplesUrl = 'https://github.com/extension-js/examples/tree/main/examples';
310
301
  const resolvedTemplate = 'init' === templateName ? "javascript" : template;
311
302
  const resolvedTemplateName = 'init' === templateName ? "javascript" : templateName;
312
303
  const templateUrl = `${examplesUrl}/${resolvedTemplate}`;
313
- const examplesZipUrl = 'https://codeload.github.com/extension-js/examples/zip/refs/heads/main';
314
304
  try {
315
305
  await promises_namespaceObject.mkdir(projectPath, {
316
306
  recursive: true
317
307
  });
318
- if ('development' === process.env.EXTENSION_ENV) {
319
- console.log(installingFromTemplate(projectName, template));
320
- async function findTemplatesRoot(startDir) {
321
- let current = startDir;
322
- const maxDepth = 6;
323
- for(let i = 0; i < maxDepth; i++){
324
- const candidate = external_path_namespaceObject.join(current, 'templates');
325
- try {
326
- const stats = await promises_namespaceObject.stat(candidate);
327
- if (stats.isDirectory()) return candidate;
328
- } catch {}
329
- const parent = external_path_namespaceObject.dirname(current);
330
- if (parent === current) break;
331
- current = parent;
332
- }
333
- }
334
- const localTemplatesRoot = await findTemplatesRoot(import_external_template_dirname);
335
- if (!localTemplatesRoot) throw new Error('Local templates directory not found');
336
- const localTemplatePath = external_path_namespaceObject.join(localTemplatesRoot, resolvedTemplateName);
337
- await copyDirectoryWithSymlinks(localTemplatePath, projectPath);
338
- } else {
339
- const tempRoot = await promises_namespaceObject.mkdtemp(external_path_namespaceObject.join(external_os_namespaceObject.tmpdir(), 'extension-js-create-'));
340
- const tempPath = external_path_namespaceObject.join(tempRoot, projectName + '-temp');
341
- await promises_namespaceObject.mkdir(tempPath, {
342
- recursive: true
308
+ const tempRoot = await promises_namespaceObject.mkdtemp(external_path_namespaceObject.join(external_os_namespaceObject.tmpdir(), 'extension-js-create-'));
309
+ const tempPath = external_path_namespaceObject.join(tempRoot, projectName + '-temp');
310
+ await promises_namespaceObject.mkdir(tempPath, {
311
+ recursive: true
312
+ });
313
+ const isHttp = /^https?:\/\//i.test(template);
314
+ const isGithub = /^https?:\/\/github.com\//i.test(template);
315
+ const runGoGitIt = async (templatePath, destination)=>{
316
+ await external_go_git_it_default()(templatePath, destination, installingFromTemplate(projectName, templateName));
317
+ };
318
+ if (isGithub) {
319
+ await runGoGitIt(template, tempPath);
320
+ const candidates = await promises_namespaceObject.readdir(tempPath, {
321
+ withFileTypes: true
343
322
  });
344
- const isHttp = /^https?:\/\//i.test(template);
345
- const isGithub = /^https?:\/\/github.com\//i.test(template);
346
- async function withFilteredOutput(fn) {
347
- const originalStdoutWrite = process.stdout.write.bind(process.stdout);
348
- const originalStderrWrite = process.stderr.write.bind(process.stderr);
349
- const stdoutBuffer = {
350
- value: ''
351
- };
352
- const stderrBuffer = {
353
- value: ''
354
- };
355
- let suppressGoGitItStack = false;
356
- const toText = (chunk)=>'string' == typeof chunk ? chunk : chunk?.toString?.() ?? '';
357
- const shouldFilterLine = (line)=>{
358
- if (!line) return false;
359
- const trimmed = line.trim();
360
- if (!trimmed) return false;
361
- if (/Using git version/i.test(line) || /GitHub API rate limit reached, continuing without connectivity check/i.test(line) || /^Downloading extension\b/i.test(trimmed) || /^URL https?:\/\/codeload\.github\.com\/extension-js\/examples\/zip\/refs\/heads\/main\b/i.test(trimmed) || /^\[[=\s]+\]\s*\d+%/i.test(trimmed)) {
362
- suppressGoGitItStack = true;
363
- return true;
364
- }
365
- if (suppressGoGitItStack && /^\s+at\b/.test(line)) return true;
366
- if (suppressGoGitItStack && !/^\s+at\b/.test(line)) suppressGoGitItStack = false;
367
- return false;
368
- };
369
- const writeWithFilter = (originalWrite, buffer)=>(chunk, ...args)=>{
370
- const text = buffer.value + toText(chunk);
371
- if (!text) return true;
372
- const parts = text.split(/\r?\n|\r/);
373
- buffer.value = parts.pop() ?? '';
374
- if (0 === parts.length) return true;
375
- const kept = [];
376
- for (const line of parts)if (!shouldFilterLine(line)) kept.push(line);
377
- if (0 === kept.length) return true;
378
- return originalWrite(kept.join('\n') + '\n', ...args);
379
- };
380
- process.stdout.write = writeWithFilter(originalStdoutWrite, stdoutBuffer);
381
- process.stderr.write = writeWithFilter(originalStderrWrite, stderrBuffer);
382
- try {
383
- return await fn();
384
- } finally{
385
- process.stdout.write = originalStdoutWrite;
386
- process.stderr.write = originalStderrWrite;
387
- }
388
- }
389
- if (isGithub) {
390
- await withFilteredOutput(()=>external_go_git_it_default()(template, tempPath, installingFromTemplate(projectName, templateName)));
391
- const candidates = await promises_namespaceObject.readdir(tempPath, {
392
- withFileTypes: true
393
- });
394
- const preferred = candidates.find((d)=>d.isDirectory() && d.name === templateName);
395
- const srcPath = preferred ? external_path_namespaceObject.join(tempPath, templateName) : tempPath;
396
- await moveDirectoryContents(srcPath, projectPath);
397
- } else if (isHttp) {
398
- const { data, headers } = await external_axios_default().get(template, {
399
- responseType: 'arraybuffer',
400
- maxRedirects: 5
401
- });
402
- const contentType = String(headers?.['content-type'] || '');
403
- const looksZip = /zip|octet-stream/i.test(contentType) || template.toLowerCase().endsWith('.zip');
404
- if (!looksZip) throw new Error(`Remote template does not appear to be a ZIP archive: ${template}`);
405
- const zip = new (external_adm_zip_default())(Buffer.from(data));
406
- zip.extractAllTo(tempPath, true);
407
- await moveDirectoryContents(tempPath, projectPath);
408
- } else {
409
- const ok = await (async ()=>{
410
- const zipExtractRoot = external_path_namespaceObject.join(tempPath, 'zip-extract');
411
- try {
412
- const { data } = await external_axios_default().get(examplesZipUrl, {
413
- responseType: 'arraybuffer',
414
- maxRedirects: 5
415
- });
416
- const zip = new (external_adm_zip_default())(Buffer.from(data));
417
- zip.extractAllTo(zipExtractRoot, true);
418
- const entries = await promises_namespaceObject.readdir(zipExtractRoot, {
419
- withFileTypes: true
420
- });
421
- const rootDir = entries.find((e)=>e.isDirectory())?.name;
422
- if (!rootDir) return false;
423
- const srcPath = external_path_namespaceObject.join(zipExtractRoot, rootDir, 'examples', resolvedTemplateName);
424
- await moveDirectoryContents(srcPath, projectPath);
425
- return true;
426
- } catch {
427
- return false;
428
- } finally{
429
- try {
430
- await promises_namespaceObject.rm(zipExtractRoot, {
431
- recursive: true,
432
- force: true
433
- });
434
- } catch {}
435
- }
436
- })();
437
- if (!ok) {
438
- await withFilteredOutput(()=>external_go_git_it_default()(templateUrl, tempPath, installingFromTemplate(projectName, templateName)));
439
- const srcPath = external_path_namespaceObject.join(tempPath, resolvedTemplateName);
440
- await moveDirectoryContents(srcPath, projectPath);
441
- }
442
- }
443
- await promises_namespaceObject.rm(tempRoot, {
444
- recursive: true,
445
- force: true
323
+ const preferred = candidates.find((d)=>d.isDirectory() && d.name === templateName);
324
+ const srcPath = preferred ? external_path_namespaceObject.join(tempPath, templateName) : tempPath;
325
+ await moveDirectoryContents(srcPath, projectPath);
326
+ } else if (isHttp) {
327
+ const { data, headers } = await external_axios_default().get(template, {
328
+ responseType: 'arraybuffer',
329
+ maxRedirects: 5
446
330
  });
331
+ const contentType = String(headers?.['content-type'] || '');
332
+ const looksZip = /zip|octet-stream/i.test(contentType) || template.toLowerCase().endsWith('.zip');
333
+ if (!looksZip) throw new Error(`Remote template does not appear to be a ZIP archive: ${template}`);
334
+ const zip = new (external_adm_zip_default())(Buffer.from(data));
335
+ zip.extractAllTo(tempPath, true);
336
+ await moveDirectoryContents(tempPath, projectPath);
337
+ } else {
338
+ await runGoGitIt(templateUrl, tempPath);
339
+ const srcPath = external_path_namespaceObject.join(tempPath, resolvedTemplateName);
340
+ await moveDirectoryContents(srcPath, projectPath);
447
341
  }
342
+ await promises_namespaceObject.rm(tempRoot, {
343
+ recursive: true,
344
+ force: true
345
+ });
448
346
  } catch (error) {
449
347
  console.error(installingFromTemplateError(projectName, templateName, error));
450
348
  throw error;
@@ -506,52 +404,6 @@ async function overridePackageJson(projectPath, projectName, { template: _templa
506
404
  throw error;
507
405
  }
508
406
  }
509
- function clearLine() {
510
- if (!process.stdout.isTTY) return;
511
- process.stdout.write('\r');
512
- process.stdout.write('\x1b[2K');
513
- }
514
- function stripAnsi(input) {
515
- return input.replace(/\x1b\[[0-9;]*m/g, '');
516
- }
517
- function shouldShowProgress() {
518
- return Boolean(process.stdout.isTTY) && !process.env.CI;
519
- }
520
- function startProgressBar(label, options) {
521
- const enabled = (options?.enabled ?? true) && shouldShowProgress();
522
- if (!enabled) return {
523
- stop: ()=>void 0
524
- };
525
- const width = Math.max(10, options?.width ?? 24);
526
- const intervalMs = Math.max(50, options?.intervalMs ?? 90);
527
- let tick = 0;
528
- let lastVisibleLength = 0;
529
- const render = ()=>{
530
- const filled = tick % (width + 1);
531
- const empty = width - filled;
532
- const bar = `[${'='.repeat(filled)}${' '.repeat(empty)}]`;
533
- const line = `${label} ${bar}`;
534
- lastVisibleLength = stripAnsi(line).length;
535
- clearLine();
536
- process.stdout.write(line);
537
- tick = (tick + 1) % (width + 1);
538
- };
539
- render();
540
- const timer = setInterval(render, intervalMs);
541
- return {
542
- stop: ()=>{
543
- clearInterval(timer);
544
- if (process.stdout.isTTY) {
545
- clearLine();
546
- if (lastVisibleLength > 0) {
547
- process.stdout.write(' '.repeat(lastVisibleLength));
548
- process.stdout.write('\r');
549
- }
550
- if (options?.persistLabel) process.stdout.write(`${label}\n`);
551
- }
552
- }
553
- };
554
- }
555
407
  const external_cross_spawn_namespaceObject = require("cross-spawn");
556
408
  function buildExecEnv() {
557
409
  if ('win32' !== process.platform) return;
@@ -652,38 +504,19 @@ async function installDependencies(projectPath, projectName) {
652
504
  const command = await getInstallCommand();
653
505
  const dependenciesArgs = getInstallArgs();
654
506
  const installMessage = installingDependencies();
655
- const progressEnabled = shouldShowProgress();
656
- const progress = startProgressBar(installMessage, {
657
- enabled: progressEnabled,
658
- persistLabel: true
659
- });
660
- if (!progressEnabled) console.log(installMessage);
507
+ console.log(installMessage);
661
508
  try {
662
509
  await external_fs_namespaceObject.promises.mkdir(nodeModulesPath, {
663
510
  recursive: true
664
511
  });
665
512
  const stdio = 'development' === process.env.EXTENSION_ENV ? 'inherit' : 'pipe';
666
- let firstRun;
667
- try {
668
- firstRun = await install_dependencies_runInstall(command, dependenciesArgs, projectPath, stdio);
669
- } finally{
670
- progress.stop();
671
- }
513
+ const firstRun = await install_dependencies_runInstall(command, dependenciesArgs, projectPath, stdio);
672
514
  if (0 !== firstRun.code) {
673
515
  const output = `${firstRun.stdout}\n${firstRun.stderr}`;
674
516
  const shouldRetry = shouldRetryWithTagFallback(output);
675
517
  const didUpdate = shouldRetry ? await updateExtensionDependencyTag(projectPath, projectName) : false;
676
518
  if (didUpdate) {
677
- const retryProgress = startProgressBar(installMessage, {
678
- enabled: progressEnabled,
679
- persistLabel: true
680
- });
681
- let retryRun;
682
- try {
683
- retryRun = await install_dependencies_runInstall(command, dependenciesArgs, projectPath, stdio);
684
- } finally{
685
- retryProgress.stop();
686
- }
519
+ const retryRun = await install_dependencies_runInstall(command, dependenciesArgs, projectPath, stdio);
687
520
  if (0 === retryRun.code) return;
688
521
  }
689
522
  throw new Error(installingDependenciesFailed(command, dependenciesArgs, firstRun.code));
@@ -1183,29 +1016,19 @@ async function installBuildDependencies(developRoot, plan) {
1183
1016
  if (0 === plan.dependencies.length) return;
1184
1017
  const pm = detectPackageManagerFromEnv();
1185
1018
  const installMessage = installingBuildDependencies(plan.dependencies);
1186
- const progressEnabled = shouldShowProgress();
1187
- const progress = startProgressBar(installMessage, {
1188
- enabled: progressEnabled,
1189
- persistLabel: true
1019
+ console.log(installMessage);
1020
+ const args = buildBuildInstallArgs(pm, plan.dependencies, plan.dependencyMap);
1021
+ const stdio = 'development' === process.env.EXTENSION_ENV ? 'inherit' : 'ignore';
1022
+ const result = await runInstall(pm, args, {
1023
+ cwd: developRoot,
1024
+ stdio
1190
1025
  });
1191
- if (!progressEnabled) console.log(installMessage);
1192
- try {
1193
- const args = buildBuildInstallArgs(pm, plan.dependencies, plan.dependencyMap);
1194
- const stdio = 'development' === process.env.EXTENSION_ENV ? 'inherit' : 'ignore';
1195
- const result = await runInstall(pm, args, {
1196
- cwd: developRoot,
1197
- stdio
1198
- });
1199
- if (0 !== result.code) throw new Error(installingDependenciesFailed(pm, args, result.code));
1200
- } finally{
1201
- progress.stop();
1202
- }
1026
+ if (0 !== result.code) throw new Error(installingDependenciesFailed(pm, args, result.code));
1203
1027
  }
1204
1028
  async function installOptionalDependencies(developRoot, projectPath, plan) {
1205
1029
  if (0 === plan.dependencies.length) return;
1206
1030
  const pm = detectPackageManagerFromEnv();
1207
1031
  const stdio = 'development' === process.env.EXTENSION_ENV ? 'inherit' : 'ignore';
1208
- const progressEnabled = shouldShowProgress();
1209
1032
  console.log(foundSpecializedDependencies(plan.integrations.length));
1210
1033
  for (const [index, integration] of plan.integrations.entries()){
1211
1034
  const missingDeps = plan.dependenciesByIntegration[integration] || [];
@@ -1213,25 +1036,16 @@ async function installOptionalDependencies(developRoot, projectPath, plan) {
1213
1036
  integration
1214
1037
  ]);
1215
1038
  const installMessage = baseMessage.replace('►►► ', `►►► [${index + 1}/${plan.integrations.length}] `);
1216
- const progress = startProgressBar(installMessage, {
1217
- enabled: progressEnabled,
1218
- persistLabel: true
1219
- });
1220
- if (!progressEnabled) console.log(installMessage);
1221
- try {
1222
- if (0 === missingDeps.length) continue;
1223
- for (const dep of missingDeps){
1224
- const args = buildOptionalInstallArgs(pm, [
1225
- dep
1226
- ], developRoot);
1227
- const result = await runInstall(pm, args, {
1228
- cwd: developRoot,
1229
- stdio
1230
- });
1231
- if (0 !== result.code) throw new Error(installingDependenciesFailed(pm, args, result.code));
1232
- }
1233
- } finally{
1234
- progress.stop();
1039
+ console.log(installMessage);
1040
+ if (0 !== missingDeps.length) for (const dep of missingDeps){
1041
+ const args = buildOptionalInstallArgs(pm, [
1042
+ dep
1043
+ ], developRoot);
1044
+ const result = await runInstall(pm, args, {
1045
+ cwd: developRoot,
1046
+ stdio
1047
+ });
1048
+ if (0 !== result.code) throw new Error(installingDependenciesFailed(pm, args, result.code));
1235
1049
  }
1236
1050
  }
1237
1051
  }
package/package.json CHANGED
@@ -23,7 +23,7 @@
23
23
  "dist"
24
24
  ],
25
25
  "name": "extension-create",
26
- "version": "3.6.2",
26
+ "version": "3.7.0-canary.169.5b5db8b",
27
27
  "description": "The standalone extension creation engine for Extension.js",
28
28
  "author": {
29
29
  "name": "Cezar Augusto",
@@ -42,8 +42,8 @@
42
42
  "clean": "rm -rf dist",
43
43
  "watch": "rslib build --watch",
44
44
  "compile": "rslib build",
45
- "format": "prettier --write \"**/*.{ts,tsx,md,js,json}\"",
46
- "lint": "eslint .",
45
+ "format": "biome format --write .",
46
+ "lint": "biome lint .",
47
47
  "pretest:create": "pnpm compile",
48
48
  "test:create": "vitest run",
49
49
  "test:coverage": "vitest run --coverage"
@@ -79,8 +79,8 @@
79
79
  "tiny-glob": "^0.2.9"
80
80
  },
81
81
  "devDependencies": {
82
+ "@biomejs/biome": "^2.2.4",
82
83
  "@changesets/cli": "^2.29.8",
83
- "@eslint/js": "^9.39.2",
84
84
  "@rslib/core": "^0.19.4",
85
85
  "@types/adm-zip": "^0.5.7",
86
86
  "@types/chrome": "^0.1.33",
@@ -88,9 +88,6 @@
88
88
  "@types/node": "^25.2.0",
89
89
  "@types/webextension-polyfill": "0.12.4",
90
90
  "@vitest/coverage-v8": "^4.0.17",
91
- "eslint": "^9.39.2",
92
- "globals": "^17.3.0",
93
- "prettier": "^3.8.0",
94
91
  "tsconfig": "*",
95
92
  "typescript": "5.9.3",
96
93
  "vitest": "^4.0.17",