extension 1.2.0 → 1.2.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 (3) hide show
  1. package/README.md +109 -3
  2. package/dist/cli.js +43 -4
  3. package/package.json +4 -3
package/README.md CHANGED
@@ -1,5 +1,111 @@
1
- # @extension-create/cli
1
+ [action-image]: https://github.com/cezaraugusto/extension-create/actions/workflows/ci.yml/badge.svg?branch=main
2
+ [action-url]: https://github.com/cezaraugusto/extension-create/actions
3
+ [npm-image]: https://img.shields.io/npm/v/extension-create.svg
4
+ [npm-url]: https://npmjs.org/package/extension-create
5
+ [downloads-image]: https://img.shields.io/npm/dm/extension-create.svg
6
+ [downloads-url]: https://npmjs.org/package/extension-create
7
+ [node]: https://img.shields.io/node/v/extension-create.svg
8
+ [node-url]: https://nodejs.org
9
+ [prs]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg
10
+ [prs-url]: https://github.com/cezaraugusto/extension-create/blob/main/CONTRIBUTING.md
11
+ [vunlerabilities]: https://snyk.io/test/github/cezaraugusto/extension-create/badge.svg
12
+ [fossa-image]: https://app.fossa.com/api/projects/git%2Bgithub.com%2Fcezaraugusto%2Fextension-create.svg?type=shield
13
+ [fossa-url]: https://app.fossa.com/projects/git%2Bgithub.com%2Fcezaraugusto%2Fextension-create?ref=badge_large
2
14
 
3
- > The **CLI** part of [extension-create](https://github.com/cezaraugusto/extension-create). Available as a standalone package.
15
+ # extension-create [![npm][npm-image]][npm-url] [![fossa][fossa-image]][fossa-url] [![workflow][action-image]][action-url] [![downloads][downloads-image]][downloads-url] [![PR's welcome][prs]][prs-url]
4
16
 
5
- This package stores the interface of `extension-create`, used by `[extension](aliases/extension)` and `[extension-create](aliases/extension-create)` aliases.
17
+ <img alt="Logo" align="right" src="https://user-images.githubusercontent.com/4672033/102850460-4d22aa80-43f8-11eb-82db-9efce586f73e.png" width="25%" />
18
+
19
+ Create cross-browser extensions with no build configuration.
20
+
21
+ - [Creating an extension](#creating-an-extension) — How to create a new extension.
22
+ - [Getting started immediately](#getting-started-immediately) — Get work done in no time.
23
+ - [I have an extension](#i-have-an-extension) - Use only specific parts of `extension-create`.
24
+
25
+ `extension-create` helps you develop cross-browser extensions with built-in support for module imports/exports, auto-reload, and more.
26
+
27
+ ## Creating an Extension
28
+
29
+ ```sh
30
+ npx extension-create@latest create my-extension-hello
31
+ cd my-extension-hello
32
+ npm run dev
33
+ ```
34
+
35
+ A new browser instance will open up with your extension ready for development.
36
+
37
+ You are done. Time to hack on your extension!
38
+
39
+ <p align="center">
40
+ <img src="https://user-images.githubusercontent.com/4672033/106184765-ba0c2b80-6180-11eb-9d0f-d9d00d168290.gif" width="720" alt="npm start">
41
+ </p>
42
+
43
+ ## Getting Started Immediately
44
+
45
+ ### Kickstart any sample from Chrome Extension Samples
46
+
47
+ The [chrome-extensions-sample](https://github.com/GoogleChrome/chrome-extensions-samples/) project is a great way to kickstart developing your extension.
48
+
49
+ If we go to the samples repository and look for an extension sample to work, let's say the [page-redder](https://github.com/GoogleChrome/chrome-extensions-samples/tree/main/functional-samples/sample.page-redder) sample, all we need is to copy and paste it's URL as an argument for the start command:
50
+
51
+ #### Command
52
+
53
+ ```sh
54
+ # This command will:
55
+ # 1. Download the Chrome extension sample URL to the current working directory
56
+ # 2. Bundle the downloaded extension using extension-create
57
+ # 3. Enable the extension in Chrome using a fresh user profile
58
+ npx extension-create dev https://github.com/GoogleChrome/chrome-extensions-samples/tree/main/functional-samples/sample.page-redder
59
+ ```
60
+
61
+ <p align="center">
62
+ <img src="https://user-images.githubusercontent.com/4672033/106188671-04dc7200-6186-11eb-940a-52aebab46f31.gif" width="720" alt="npm start">
63
+ </p>
64
+
65
+ Will not only download the extension but also kickstart a Chrome instance in a fresh profile with your sample extension loaded and default auto-reload support. Try it yourself!
66
+
67
+ ### Use `Microsoft Edge` to kickstart any sample from [chrome-extesions-sample](https://github.com/GoogleChrome/chrome-extensions-samples/)
68
+
69
+ **You read it!** Just run the command above with the `--browser=edge` flag:
70
+
71
+ ```sh
72
+ npx extension-create dev --browser=edge https://github.com/GoogleChrome/chrome-extensions-samples/tree/main/functional-samples/sample.page-redder
73
+ ```
74
+
75
+ And see a Chrome Extension sample running automatically. On Edge!
76
+
77
+ ## I have an extension
78
+
79
+ Just add `extension-create` to your npm scripts. Here's how it should look in your `package.json`:
80
+
81
+ ```js
82
+ {
83
+ // ...npm stuff,
84
+ "scripts": {
85
+ "start": "npx extension-create start",
86
+ "dev": "npx extension-create dev",
87
+ "build": "npx extension-create build"
88
+ },
89
+ "devDependencies": {
90
+ "extension-create": "latest"
91
+ }
92
+ }
93
+ ```
94
+
95
+ #### Using a specific browser for development
96
+
97
+ | <img width=120 src="https://raw.githubusercontent.com/alrra/browser-logos/main/src/chrome/chrome.svg" alt="Chrome browser logo"> | <img width=120 src="https://raw.githubusercontent.com/alrra/browser-logos/main/src/edge/edge.svg" alt="Microsoft Edge browser logo"> | <img width=120 src="https://raw.githubusercontent.com/alrra/browser-logos/main/src/firefox/firefox.svg" alt="Mozilla Firefox browser logo"> | <img width=120 src="https://raw.githubusercontent.com/alrra/browser-logos/main/src/safari/safari.svg" alt="Apple Safari browser logo"> | <img width=120 src="https://raw.githubusercontent.com/alrra/browser-logos/main/src/opera/opera.svg" alt="Opera browser logo"> | <img width=120 src="https://raw.githubusercontent.com/alrra/browser-logos/main/src/chromium/chromium.svg" alt="Chromium browser logo"> |
98
+ | -------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
99
+ | Google Chrome ✅ | Microsoft Edge ✅ | Mozilla Firefox ⛔️ | Apple Safari ⛔️ | Opera browser ⛔️ | Chromium (forks) 🤔 |
100
+
101
+ If you want to target a specific browser, just pass the `--browser` flag to the dev/start command (Chrome or Edge, soon others), like `npx extension-create dev --browser=edge`.
102
+
103
+ That's it!
104
+
105
+ ## Program Options Table
106
+
107
+ For a list of all commands available, see [OPTIONS_TABLE.md](OPTIONS_TABLE.md).
108
+
109
+ ## License
110
+
111
+ MIT (c) Cezar Augusto.
package/dist/cli.js CHANGED
@@ -117,7 +117,7 @@ var package_default = {
117
117
  node: ">=18"
118
118
  },
119
119
  name: "extension",
120
- version: "1.2.0",
120
+ version: "1.2.1",
121
121
  description: "Create cross-browser extensions with no build configuration.",
122
122
  main: "./dist/cli.js",
123
123
  types: "./dist/cli.d.ts",
@@ -133,10 +133,11 @@ var package_default = {
133
133
  url: "https://cezaraugusto.com"
134
134
  },
135
135
  scripts: {
136
+ "compile:readme-files": "node ./scripts/copyMarkdownFilesToCli.js",
136
137
  "compile:tailwind-config": "node ./scripts/copyTailwindConfig.js",
137
138
  "compile:stylelint-config": "node ./scripts/copyStylelintConfig.js",
138
139
  "compile:cli": "tsup-node ./cli.ts --format cjs --dts --target=node18",
139
- compile: "yarn compile:tailwind-config && yarn compile:stylelint-config && yarn compile:cli",
140
+ compile: "yarn compile:readme-files && yarn compile:tailwind-config && yarn compile:stylelint-config &&yarn compile:cli",
140
141
  clean: "rm -rf dist",
141
142
  test: "jest"
142
143
  },
@@ -182,12 +183,50 @@ if (import_semver.default.lte(process.version, "18.0.0")) {
182
183
  }
183
184
  var extensionCreate = import_commander.program;
184
185
  var isExtensionCreateNamespace = package_default.name === "extension-create";
186
+ if (process.env.EXTENSION_ENV === "development") {
187
+ console.log(`Running extension-create via ${package_default.name}...`);
188
+ }
185
189
  extensionCreate.name(package_default.name).description(package_default.description).version(package_default.version).addHelpText("after", messages_default.programHelp());
186
190
  extensionCreate.command("create", { isDefault: isExtensionCreateNamespace }).arguments("<project-name|project-path>").usage("create <project-name|project-path> [options]").description("Creates a new extension.").option(
187
191
  "-t, --template <template-name>",
188
192
  "specify a template for the created project"
189
- ).action(async function(projectName, { template, targetDir }) {
190
- await (0, import_create.default)(projectName, { targetDir, template });
193
+ ).action(async function(pathOrRemoteUrl, {
194
+ browser = "chrome",
195
+ template,
196
+ ...otherCommandOptions
197
+ }) {
198
+ const vendors = browser.split(",");
199
+ switch (pathOrRemoteUrl) {
200
+ case "dev":
201
+ for (const vendor of vendors) {
202
+ await (0, import_develop.extensionDev)(pathOrRemoteUrl, {
203
+ mode: "development",
204
+ browser: vendor,
205
+ ...otherCommandOptions
206
+ });
207
+ }
208
+ break;
209
+ case "start":
210
+ for (const vendor of vendors) {
211
+ await (0, import_develop.extensionStart)(pathOrRemoteUrl, {
212
+ mode: "production",
213
+ browser: vendor,
214
+ ...otherCommandOptions
215
+ });
216
+ }
217
+ break;
218
+ case "build":
219
+ for (const vendor of vendors) {
220
+ await (0, import_develop.extensionBuild)(pathOrRemoteUrl, {
221
+ browser: vendor,
222
+ ...otherCommandOptions
223
+ });
224
+ }
225
+ break;
226
+ default:
227
+ await (0, import_create.default)(pathOrRemoteUrl, { template });
228
+ break;
229
+ }
191
230
  });
192
231
  extensionCreate.command("dev").arguments("[project-path|remote-url]").usage("dev [project-path|remote-url] [options]").description("Starts the development server (development mode)").option(
193
232
  "-u, --user-data-dir <path-to-file | boolean>",
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "node": ">=18"
10
10
  },
11
11
  "name": "extension",
12
- "version": "1.2.0",
12
+ "version": "1.2.1",
13
13
  "description": "Create cross-browser extensions with no build configuration.",
14
14
  "main": "./dist/cli.js",
15
15
  "types": "./dist/cli.d.ts",
@@ -25,10 +25,11 @@
25
25
  "url": "https://cezaraugusto.com"
26
26
  },
27
27
  "scripts": {
28
+ "compile:readme-files": "node ./scripts/copyMarkdownFilesToCli.js",
28
29
  "compile:tailwind-config": "node ./scripts/copyTailwindConfig.js",
29
30
  "compile:stylelint-config": "node ./scripts/copyStylelintConfig.js",
30
31
  "compile:cli": "tsup-node ./cli.ts --format cjs --dts --target=node18",
31
- "compile": "yarn compile:tailwind-config && yarn compile:stylelint-config && yarn compile:cli",
32
+ "compile": "yarn compile:readme-files && yarn compile:tailwind-config && yarn compile:stylelint-config &&yarn compile:cli",
32
33
  "clean": "rm -rf dist",
33
34
  "test": "jest"
34
35
  },
@@ -63,4 +64,4 @@
63
64
  "tsup": "^8.0.1",
64
65
  "typescript": "5.3.3"
65
66
  }
66
- }
67
+ }