extension-create 3.14.5 → 3.15.0-next.1

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 +15 -63
  2. package/package.json +2 -2
package/dist/module.cjs CHANGED
@@ -635,78 +635,30 @@ async function findManifestJsonPath(projectPath) {
635
635
  }
636
636
  throw new Error(`Could not locate manifest.json under ${projectPath}. Checked common paths and searched up to depth ${manifestSearchMaxDepth}.`);
637
637
  }
638
- async function writeReadmeFile(projectPath, projectName, logger) {
638
+ async function pathExists(target) {
639
639
  try {
640
- await promises_namespaceObject.access(external_path_namespaceObject.join(projectPath, 'README.md'));
641
- return;
642
- } catch {}
643
- const initTemplateReadme = `
644
- <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>
645
-
646
- # [projectName]
647
-
648
- > [templateDescription]
649
-
650
- This project was created with Extension.js. Use the commands below to run and build it.
651
-
652
- ## Installation
653
-
654
- \`\`\`bash
655
- [runCommand] create <project-name>
656
- cd <project-name>
657
- npm install
658
- \`\`\`
659
-
660
- For a different starter, add \`--template=<slug>\` (see the [templates](https://extension.js.org/docs/getting-started/templates) docs).
661
-
662
- ## Commands
663
-
664
- ### dev
665
-
666
- Run the extension in development mode. You can target a specific browser using the
667
- \`--browser <browser>\` flag. Supported values: \`chrome\`, \`firefox\`, \`edge\`.
668
-
669
- \`\`\`bash
670
- [runCommand] dev --browser chrome
671
- # or
672
- [runCommand] dev --browser firefox
673
- # or
674
- [runCommand] dev --browser edge
675
- \`\`\`
676
-
677
- ### build
678
-
679
- Build the extension for production. Use \`--browser <browser>\` to select a target.
680
-
681
- \`\`\`bash
682
- [runCommand] build (defaults to Chrome)
683
- # or use convenience scripts
684
- [runCommand] build:firefox (Firefox)
685
- [runCommand] build:edge (Edge)
686
- \`\`\`
687
-
688
- ### Preview
689
-
690
- Preview the extension in the browser.
691
-
692
- \`\`\`bash
693
- [runCommand] preview
694
- \`\`\`
695
-
696
- ## Learn more
697
-
698
- Learn more in the [Extension.js docs](https://extension.js.org).
699
- `;
640
+ await promises_namespaceObject.access(target);
641
+ return true;
642
+ } catch {
643
+ return false;
644
+ }
645
+ }
646
+ async function writeReadmeFile(projectPath, projectName, logger) {
700
647
  const installCommand = await getInstallCommand();
701
648
  const manifestJsonPath = await findManifestJsonPath(projectPath);
702
649
  const manifestJson = JSON.parse(await promises_namespaceObject.readFile(manifestJsonPath, 'utf-8'));
703
- const readmeFileEdited = initTemplateReadme.replaceAll('[projectName]', projectName).replaceAll("[templateDescription]", manifestJson.description).replaceAll('[runCommand]', installCommand);
650
+ const description = String(manifestJson.description || '').trim();
651
+ const screenshotPath = external_path_namespaceObject.join(projectPath, 'public', 'screenshot.png');
652
+ const hasScreenshot = await pathExists(screenshotPath);
653
+ const screenshotEmbed = hasScreenshot ? `\n![screenshot](./public/screenshot.png)\n` : '';
654
+ const blockquote = description ? `> ${description}\n\n` : '';
655
+ 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" + `${installCommand} run dev\n` + `${installCommand} run dev -- --browser=firefox\n` + `${installCommand} run dev -- --browser=edge\n` + "```\n" + `\n` + `### build\n` + `\n` + `Build for production. Convenience scripts target each browser:\n` + `\n` + "```bash\n" + `${installCommand} run build # Chrome (default)\n` + `${installCommand} run build:firefox\n` + `${installCommand} run build:edge\n` + "```\n" + `\n` + `### preview\n` + `\n` + `Preview the production build in the browser:\n` + `\n` + "```bash\n" + `${installCommand} run preview\n` + "```\n" + `\n` + `## Learn more\n` + `\n` + `[Extension.js docs](https://extension.js.org).\n`;
704
656
  try {
705
657
  logger.log(writingReadmeMetaData());
706
658
  await promises_namespaceObject.mkdir(projectPath, {
707
659
  recursive: true
708
660
  });
709
- await promises_namespaceObject.writeFile(external_path_namespaceObject.join(projectPath, 'README.md'), readmeFileEdited);
661
+ await promises_namespaceObject.writeFile(external_path_namespaceObject.join(projectPath, 'README.md'), readme);
710
662
  } catch (error) {
711
663
  logger.error(writingReadmeMetaDataEError(projectName, error));
712
664
  throw error;
package/package.json CHANGED
@@ -24,7 +24,7 @@
24
24
  "dist"
25
25
  ],
26
26
  "name": "extension-create",
27
- "version": "3.14.5",
27
+ "version": "3.15.0-next.1",
28
28
  "description": "The standalone extension creation engine for Extension.js",
29
29
  "author": {
30
30
  "name": "Cezar Augusto",
@@ -81,7 +81,7 @@
81
81
  "devDependencies": {
82
82
  "@biomejs/biome": "^2.2.4",
83
83
  "@changesets/cli": "^2.29.8",
84
- "@rslib/core": "^0.19.4",
84
+ "@rslib/core": "^0.21.3",
85
85
  "@types/adm-zip": "^0.5.7",
86
86
  "@types/chrome": "^0.1.33",
87
87
  "@types/cross-spawn": "^6.0.6",