extension 1.1.1 → 1.2.0
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/README.md +3 -109
- package/dist/cli.js +246 -11
- package/dist/module.d.ts +3 -1
- package/dist/module.js +230 -3
- package/dist/stylelint.config.js +7 -0
- package/dist/tailwind.config.js +25 -0
- package/package.json +25 -6
package/README.md
CHANGED
|
@@ -1,111 +1,5 @@
|
|
|
1
|
-
|
|
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
|
|
1
|
+
# @extension-create/cli
|
|
14
2
|
|
|
15
|
-
|
|
3
|
+
> The **CLI** part of [extension-create](https://github.com/cezaraugusto/extension-create). Available as a standalone package.
|
|
16
4
|
|
|
17
|
-
|
|
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.
|
|
5
|
+
This package stores the interface of `extension-create`, used by `[extension](aliases/extension)` and `[extension-create](aliases/extension-create)` aliases.
|
package/dist/cli.js
CHANGED
|
@@ -1,16 +1,251 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
3
29
|
|
|
4
30
|
// cli.ts
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
31
|
+
var import_semver = __toESM(require("semver"));
|
|
32
|
+
var import_commander = require("commander");
|
|
33
|
+
|
|
34
|
+
// messages/blockingErrors.ts
|
|
35
|
+
var blockingErrors_exports = {};
|
|
36
|
+
__export(blockingErrors_exports, {
|
|
37
|
+
noURLWithoutStart: () => noURLWithoutStart,
|
|
38
|
+
notImplemented: () => notImplemented,
|
|
39
|
+
unsupportedNodeVersion: () => unsupportedNodeVersion
|
|
40
|
+
});
|
|
41
|
+
function unsupportedNodeVersion() {
|
|
42
|
+
return `
|
|
43
|
+
You are using an unsupported Node version (${process.version}).
|
|
44
|
+
|
|
45
|
+
Please update to a version higher than 18.
|
|
46
|
+
`;
|
|
47
|
+
}
|
|
48
|
+
function noURLWithoutStart(argument) {
|
|
49
|
+
return `
|
|
50
|
+
The default \`create\` command does not accept URLs.
|
|
51
|
+
Are you forgetting a \`start\` command? Maybe:
|
|
52
|
+
|
|
53
|
+
npx extension-create \`start\` ${argument}
|
|
54
|
+
`;
|
|
55
|
+
}
|
|
56
|
+
function notImplemented(argument) {
|
|
57
|
+
return `${argument} command not implemented yet.`;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// messages/programHelp.ts
|
|
61
|
+
function programHelp() {
|
|
62
|
+
return `
|
|
63
|
+
# Help center for the extension-create program
|
|
64
|
+
|
|
65
|
+
## Usage: \`extension-create [command] [options]\`
|
|
66
|
+
|
|
67
|
+
**Note:** If you are looking for a specific list of options,
|
|
68
|
+
all high-level commands offer their own \`--help\` file with
|
|
69
|
+
information about usage and a list of command flags available.
|
|
70
|
+
|
|
71
|
+
For example:
|
|
72
|
+
|
|
73
|
+
\`extension-create create --help\`
|
|
74
|
+
outputs information about the \`create\` command.
|
|
75
|
+
|
|
76
|
+
## Options available
|
|
77
|
+
|
|
78
|
+
\`extension-create create <extension-name>\`
|
|
79
|
+
Creates a new extension from template. The "create" command
|
|
80
|
+
is optional and can be ommitted.
|
|
81
|
+
|
|
82
|
+
\`extension-create dev <extension-path>\`
|
|
83
|
+
Starts a new browser instance in development mode, with the target
|
|
84
|
+
extension loaded and auto-reloaded based on file changes.
|
|
85
|
+
|
|
86
|
+
\`extension-create start <extension-path>\`
|
|
87
|
+
Starts a new browser instance in production mode, with the target
|
|
88
|
+
extension compiled based on the browser choice.
|
|
89
|
+
|
|
90
|
+
\`extension-create build <extension-path>\`
|
|
91
|
+
Builds the target extension with browser defaults, ready for packaging.
|
|
92
|
+
|
|
93
|
+
\`extension-create --help\`
|
|
94
|
+
This command ;) Outputs a help file with key command options.
|
|
95
|
+
|
|
96
|
+
Feels something is wrong? Help by reporting a bug:
|
|
97
|
+
https://github.com/cezaraugusto/extension-create/issues/new
|
|
98
|
+
`;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// messages/index.ts
|
|
102
|
+
var messages = {
|
|
103
|
+
...blockingErrors_exports,
|
|
104
|
+
programHelp
|
|
105
|
+
};
|
|
106
|
+
var messages_default = messages;
|
|
107
|
+
|
|
108
|
+
// package.json
|
|
109
|
+
var package_default = {
|
|
110
|
+
license: "MIT",
|
|
111
|
+
repository: {
|
|
112
|
+
type: "git",
|
|
113
|
+
url: "https://github.com/cezaraugusto/extension-create.git",
|
|
114
|
+
directory: "programs/cli"
|
|
115
|
+
},
|
|
116
|
+
engines: {
|
|
117
|
+
node: ">=18"
|
|
118
|
+
},
|
|
119
|
+
name: "extension",
|
|
120
|
+
version: "1.2.0",
|
|
121
|
+
description: "Create cross-browser extensions with no build configuration.",
|
|
122
|
+
main: "./dist/cli.js",
|
|
123
|
+
types: "./dist/cli.d.ts",
|
|
124
|
+
files: [
|
|
125
|
+
"dist"
|
|
126
|
+
],
|
|
127
|
+
bin: {
|
|
128
|
+
"extension-create": "./dist/cli.js"
|
|
129
|
+
},
|
|
130
|
+
author: {
|
|
131
|
+
name: "Cezar Augusto",
|
|
132
|
+
email: "boss@cezaraugusto.net",
|
|
133
|
+
url: "https://cezaraugusto.com"
|
|
134
|
+
},
|
|
135
|
+
scripts: {
|
|
136
|
+
"compile:tailwind-config": "node ./scripts/copyTailwindConfig.js",
|
|
137
|
+
"compile:stylelint-config": "node ./scripts/copyStylelintConfig.js",
|
|
138
|
+
"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
|
+
clean: "rm -rf dist",
|
|
141
|
+
test: "jest"
|
|
142
|
+
},
|
|
143
|
+
keywords: [
|
|
144
|
+
"zero-config",
|
|
145
|
+
"build",
|
|
146
|
+
"develop",
|
|
147
|
+
"browser",
|
|
148
|
+
"extension",
|
|
149
|
+
"chrome extension",
|
|
150
|
+
"edge extension",
|
|
151
|
+
"firefox extension",
|
|
152
|
+
"web",
|
|
153
|
+
"react",
|
|
154
|
+
"typescript"
|
|
155
|
+
],
|
|
156
|
+
dependencies: {
|
|
157
|
+
"@extension-create/create": "*",
|
|
158
|
+
"@extension-create/develop": "*",
|
|
159
|
+
commander: "^11.1.0",
|
|
160
|
+
semver: "^7.5.4"
|
|
161
|
+
},
|
|
162
|
+
devDependencies: {
|
|
163
|
+
"@types/jest": "^29.5.11",
|
|
164
|
+
"@types/mock-fs": "^4.13.4",
|
|
165
|
+
"@types/node": "^20.11.5",
|
|
166
|
+
"@types/semver": "^7.5.6",
|
|
167
|
+
jest: "^29.7.0",
|
|
168
|
+
"mock-fs": "^5.2.0",
|
|
169
|
+
"ts-jest": "^29.1.2",
|
|
170
|
+
tsconfig: "*",
|
|
171
|
+
tsup: "^8.0.1",
|
|
172
|
+
typescript: "5.3.3"
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
// cli.ts
|
|
177
|
+
var import_create = __toESM(require("@extension-create/create"));
|
|
178
|
+
var import_develop = require("@extension-create/develop");
|
|
179
|
+
if (import_semver.default.lte(process.version, "18.0.0")) {
|
|
180
|
+
messages_default.unsupportedNodeVersion();
|
|
181
|
+
process.exit(1);
|
|
15
182
|
}
|
|
16
|
-
|
|
183
|
+
var extensionCreate = import_commander.program;
|
|
184
|
+
var isExtensionCreateNamespace = package_default.name === "extension-create";
|
|
185
|
+
extensionCreate.name(package_default.name).description(package_default.description).version(package_default.version).addHelpText("after", messages_default.programHelp());
|
|
186
|
+
extensionCreate.command("create", { isDefault: isExtensionCreateNamespace }).arguments("<project-name|project-path>").usage("create <project-name|project-path> [options]").description("Creates a new extension.").option(
|
|
187
|
+
"-t, --template <template-name>",
|
|
188
|
+
"specify a template for the created project"
|
|
189
|
+
).action(async function(projectName, { template, targetDir }) {
|
|
190
|
+
await (0, import_create.default)(projectName, { targetDir, template });
|
|
191
|
+
});
|
|
192
|
+
extensionCreate.command("dev").arguments("[project-path|remote-url]").usage("dev [project-path|remote-url] [options]").description("Starts the development server (development mode)").option(
|
|
193
|
+
"-u, --user-data-dir <path-to-file | boolean>",
|
|
194
|
+
"what path to use for the browser profile. A boolean value of false sets the profile to the default user profile. Defaults to a fresh profile"
|
|
195
|
+
).option(
|
|
196
|
+
"-b, --browser <chrome | edge>",
|
|
197
|
+
"specify a browser to run your extension in development mode"
|
|
198
|
+
).option(
|
|
199
|
+
"--polyfill <boolean>",
|
|
200
|
+
"whether or not to apply the cross-browser polyfill. Defaults to `true`"
|
|
201
|
+
).option(
|
|
202
|
+
"-p, --port <number>",
|
|
203
|
+
"what port should extension-create/develop run. Defaults to `3000`"
|
|
204
|
+
).action(async function(pathOrRemoteUrl, { browser = "chrome", ...devOptions }) {
|
|
205
|
+
const vendors = browser.split(",");
|
|
206
|
+
for (const vendor of vendors) {
|
|
207
|
+
await (0, import_develop.extensionDev)(pathOrRemoteUrl, {
|
|
208
|
+
mode: "development",
|
|
209
|
+
browser: vendor,
|
|
210
|
+
...devOptions
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
extensionCreate.command("start").arguments("[project-path|remote-url]").usage("start [project-path|remote-url] [options]").description("Starts the development server (production mode)").option(
|
|
215
|
+
"-u, --user-data-dir <path-to-file | boolean>",
|
|
216
|
+
"what path to use for the browser profile. A boolean value of false sets the profile to the default user profile. Defaults to a fresh profile"
|
|
217
|
+
).option(
|
|
218
|
+
"-b, --browser <chrome | edge>",
|
|
219
|
+
"specify a browser to run your extension in development mode"
|
|
220
|
+
).option(
|
|
221
|
+
"--polyfill <boolean>",
|
|
222
|
+
"whether or not to apply the cross-browser polyfill. Defaults to `true`"
|
|
223
|
+
).option(
|
|
224
|
+
"-p, --port <number>",
|
|
225
|
+
"what port should extension-create/develop run. Defaults to `3000`"
|
|
226
|
+
).action(async function(pathOrRemoteUrl, { browser = "chrome", ...startOptions }) {
|
|
227
|
+
const vendors = browser.split(",");
|
|
228
|
+
for (const vendor of vendors) {
|
|
229
|
+
await (0, import_develop.extensionStart)(pathOrRemoteUrl, {
|
|
230
|
+
mode: "production",
|
|
231
|
+
browser: vendor,
|
|
232
|
+
...startOptions
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
extensionCreate.command("build").arguments("[project-name]").usage("build [path-to-remote-extension] [options]").description("Builds the extension for production").option(
|
|
237
|
+
"-b, --browser <chrome | edge>",
|
|
238
|
+
"specify a browser to run your extension in development mode"
|
|
239
|
+
).option(
|
|
240
|
+
"--polyfill <boolean>",
|
|
241
|
+
"whether or not to apply the cross-browser polyfill. Defaults to `false`"
|
|
242
|
+
).action(async function(pathOrRemoteUrl, { browser = "chrome", ...buildOptions }) {
|
|
243
|
+
const vendors = browser.split(",");
|
|
244
|
+
for (const vendor of vendors) {
|
|
245
|
+
await (0, import_develop.extensionBuild)(pathOrRemoteUrl, {
|
|
246
|
+
browser: vendor,
|
|
247
|
+
...buildOptions
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
extensionCreate.parse();
|
package/dist/module.d.ts
CHANGED
package/dist/module.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
1
|
"use strict";
|
|
3
2
|
var __create = Object.create;
|
|
4
3
|
var __defProp = Object.defineProperty;
|
|
@@ -6,6 +5,10 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
6
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
9
12
|
var __copyProps = (to, from, except, desc) => {
|
|
10
13
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
14
|
for (let key of __getOwnPropNames(from))
|
|
@@ -22,7 +25,231 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
22
25
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
23
26
|
mod
|
|
24
27
|
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// module.ts
|
|
31
|
+
var module_exports = {};
|
|
32
|
+
__export(module_exports, {
|
|
33
|
+
default: () => cli
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(module_exports);
|
|
36
|
+
var import_semver = __toESM(require("semver"));
|
|
37
|
+
var import_commander = require("commander");
|
|
38
|
+
|
|
39
|
+
// messages/blockingErrors.ts
|
|
40
|
+
var blockingErrors_exports = {};
|
|
41
|
+
__export(blockingErrors_exports, {
|
|
42
|
+
noURLWithoutStart: () => noURLWithoutStart,
|
|
43
|
+
notImplemented: () => notImplemented,
|
|
44
|
+
unsupportedNodeVersion: () => unsupportedNodeVersion
|
|
45
|
+
});
|
|
46
|
+
function unsupportedNodeVersion() {
|
|
47
|
+
return `
|
|
48
|
+
You are using an unsupported Node version (${process.version}).
|
|
49
|
+
|
|
50
|
+
Please update to a version higher than 18.
|
|
51
|
+
`;
|
|
52
|
+
}
|
|
53
|
+
function noURLWithoutStart(argument) {
|
|
54
|
+
return `
|
|
55
|
+
The default \`create\` command does not accept URLs.
|
|
56
|
+
Are you forgetting a \`start\` command? Maybe:
|
|
57
|
+
|
|
58
|
+
npx extension-create \`start\` ${argument}
|
|
59
|
+
`;
|
|
60
|
+
}
|
|
61
|
+
function notImplemented(argument) {
|
|
62
|
+
return `${argument} command not implemented yet.`;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// messages/programHelp.ts
|
|
66
|
+
function programHelp() {
|
|
67
|
+
return `
|
|
68
|
+
# Help center for the extension-create program
|
|
69
|
+
|
|
70
|
+
## Usage: \`extension-create [command] [options]\`
|
|
71
|
+
|
|
72
|
+
**Note:** If you are looking for a specific list of options,
|
|
73
|
+
all high-level commands offer their own \`--help\` file with
|
|
74
|
+
information about usage and a list of command flags available.
|
|
75
|
+
|
|
76
|
+
For example:
|
|
77
|
+
|
|
78
|
+
\`extension-create create --help\`
|
|
79
|
+
outputs information about the \`create\` command.
|
|
80
|
+
|
|
81
|
+
## Options available
|
|
82
|
+
|
|
83
|
+
\`extension-create create <extension-name>\`
|
|
84
|
+
Creates a new extension from template. The "create" command
|
|
85
|
+
is optional and can be ommitted.
|
|
86
|
+
|
|
87
|
+
\`extension-create dev <extension-path>\`
|
|
88
|
+
Starts a new browser instance in development mode, with the target
|
|
89
|
+
extension loaded and auto-reloaded based on file changes.
|
|
90
|
+
|
|
91
|
+
\`extension-create start <extension-path>\`
|
|
92
|
+
Starts a new browser instance in production mode, with the target
|
|
93
|
+
extension compiled based on the browser choice.
|
|
94
|
+
|
|
95
|
+
\`extension-create build <extension-path>\`
|
|
96
|
+
Builds the target extension with browser defaults, ready for packaging.
|
|
97
|
+
|
|
98
|
+
\`extension-create --help\`
|
|
99
|
+
This command ;) Outputs a help file with key command options.
|
|
100
|
+
|
|
101
|
+
Feels something is wrong? Help by reporting a bug:
|
|
102
|
+
https://github.com/cezaraugusto/extension-create/issues/new
|
|
103
|
+
`;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// messages/index.ts
|
|
107
|
+
var messages = {
|
|
108
|
+
...blockingErrors_exports,
|
|
109
|
+
programHelp
|
|
110
|
+
};
|
|
111
|
+
var messages_default = messages;
|
|
112
|
+
|
|
113
|
+
// package.json
|
|
114
|
+
var package_default = {
|
|
115
|
+
license: "MIT",
|
|
116
|
+
repository: {
|
|
117
|
+
type: "git",
|
|
118
|
+
url: "https://github.com/cezaraugusto/extension-create.git",
|
|
119
|
+
directory: "programs/cli"
|
|
120
|
+
},
|
|
121
|
+
engines: {
|
|
122
|
+
node: ">=18"
|
|
123
|
+
},
|
|
124
|
+
name: "@extension-create/cli",
|
|
125
|
+
version: "1.2.0",
|
|
126
|
+
description: "Create cross-browser extensions with no build configuration.",
|
|
127
|
+
main: "./dist/module.js",
|
|
128
|
+
types: "./dist/module.d.ts",
|
|
129
|
+
files: [
|
|
130
|
+
"dist"
|
|
131
|
+
],
|
|
132
|
+
author: {
|
|
133
|
+
name: "Cezar Augusto",
|
|
134
|
+
email: "boss@cezaraugusto.net",
|
|
135
|
+
url: "https://cezaraugusto.com"
|
|
136
|
+
},
|
|
137
|
+
scripts: {
|
|
138
|
+
"compile:tailwind-config": "node ./scripts/copyTailwindConfig.js",
|
|
139
|
+
"compile:stylelint-config": "node ./scripts/copyStylelintConfig.js",
|
|
140
|
+
"compile:module": "tsup-node ./module.ts --format cjs --dts --target=node18",
|
|
141
|
+
compile: "yarn compile:tailwind-config && yarn compile:stylelint-config && yarn compile:module",
|
|
142
|
+
clean: "rm -rf dist",
|
|
143
|
+
test: "jest"
|
|
144
|
+
},
|
|
145
|
+
keywords: [
|
|
146
|
+
"zero-config",
|
|
147
|
+
"build",
|
|
148
|
+
"develop",
|
|
149
|
+
"browser",
|
|
150
|
+
"extension",
|
|
151
|
+
"chrome extension",
|
|
152
|
+
"edge extension",
|
|
153
|
+
"firefox extension",
|
|
154
|
+
"web",
|
|
155
|
+
"react",
|
|
156
|
+
"typescript"
|
|
157
|
+
],
|
|
158
|
+
dependencies: {
|
|
159
|
+
"@extension-create/create": "*",
|
|
160
|
+
"@extension-create/develop": "*",
|
|
161
|
+
commander: "^11.1.0",
|
|
162
|
+
semver: "^7.5.4"
|
|
163
|
+
},
|
|
164
|
+
devDependencies: {
|
|
165
|
+
"@types/jest": "^29.5.11",
|
|
166
|
+
"@types/mock-fs": "^4.13.4",
|
|
167
|
+
"@types/node": "^20.11.5",
|
|
168
|
+
"@types/semver": "^7.5.6",
|
|
169
|
+
jest: "^29.7.0",
|
|
170
|
+
"mock-fs": "^5.2.0",
|
|
171
|
+
"ts-jest": "^29.1.2",
|
|
172
|
+
tsconfig: "*",
|
|
173
|
+
tsup: "^8.0.1",
|
|
174
|
+
typescript: "5.3.3"
|
|
175
|
+
}
|
|
176
|
+
};
|
|
25
177
|
|
|
26
178
|
// module.ts
|
|
27
|
-
var
|
|
28
|
-
|
|
179
|
+
var import_create = __toESM(require("@extension-create/create"));
|
|
180
|
+
var import_develop = require("@extension-create/develop");
|
|
181
|
+
if (import_semver.default.lte(process.version, "18.0.0")) {
|
|
182
|
+
messages_default.unsupportedNodeVersion();
|
|
183
|
+
process.exit(1);
|
|
184
|
+
}
|
|
185
|
+
var extensionCreate = import_commander.program;
|
|
186
|
+
var isExtensionCreateNamespace = package_default.name === "extension-create";
|
|
187
|
+
extensionCreate.name(package_default.name).description(package_default.description).version(package_default.version).addHelpText("after", messages_default.programHelp());
|
|
188
|
+
extensionCreate.command("create", { isDefault: isExtensionCreateNamespace }).arguments("<project-name|project-path>").usage("create <project-name|project-path> [options]").description("Creates a new extension.").option(
|
|
189
|
+
"-t, --template <template-name>",
|
|
190
|
+
"specify a template for the created project"
|
|
191
|
+
).action(async function(projectName, { template, targetDir }) {
|
|
192
|
+
await (0, import_create.default)(projectName, { targetDir, template });
|
|
193
|
+
});
|
|
194
|
+
extensionCreate.command("dev").arguments("[project-path|remote-url]").usage("dev [project-path|remote-url] [options]").description("Starts the development server (development mode)").option(
|
|
195
|
+
"-u, --user-data-dir <path-to-file | boolean>",
|
|
196
|
+
"what path to use for the browser profile. A boolean value of false sets the profile to the default user profile. Defaults to a fresh profile"
|
|
197
|
+
).option(
|
|
198
|
+
"-b, --browser <chrome | edge>",
|
|
199
|
+
"specify a browser to run your extension in development mode"
|
|
200
|
+
).option(
|
|
201
|
+
"--polyfill <boolean>",
|
|
202
|
+
"whether or not to apply the cross-browser polyfill. Defaults to `true`"
|
|
203
|
+
).option(
|
|
204
|
+
"-p, --port <number>",
|
|
205
|
+
"what port should extension-create/develop run. Defaults to `3000`"
|
|
206
|
+
).action(async function(pathOrRemoteUrl, { browser = "chrome", ...devOptions }) {
|
|
207
|
+
const vendors = browser.split(",");
|
|
208
|
+
for (const vendor of vendors) {
|
|
209
|
+
await (0, import_develop.extensionDev)(pathOrRemoteUrl, {
|
|
210
|
+
mode: "development",
|
|
211
|
+
browser: vendor,
|
|
212
|
+
...devOptions
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
extensionCreate.command("start").arguments("[project-path|remote-url]").usage("start [project-path|remote-url] [options]").description("Starts the development server (production mode)").option(
|
|
217
|
+
"-u, --user-data-dir <path-to-file | boolean>",
|
|
218
|
+
"what path to use for the browser profile. A boolean value of false sets the profile to the default user profile. Defaults to a fresh profile"
|
|
219
|
+
).option(
|
|
220
|
+
"-b, --browser <chrome | edge>",
|
|
221
|
+
"specify a browser to run your extension in development mode"
|
|
222
|
+
).option(
|
|
223
|
+
"--polyfill <boolean>",
|
|
224
|
+
"whether or not to apply the cross-browser polyfill. Defaults to `true`"
|
|
225
|
+
).option(
|
|
226
|
+
"-p, --port <number>",
|
|
227
|
+
"what port should extension-create/develop run. Defaults to `3000`"
|
|
228
|
+
).action(async function(pathOrRemoteUrl, { browser = "chrome", ...startOptions }) {
|
|
229
|
+
const vendors = browser.split(",");
|
|
230
|
+
for (const vendor of vendors) {
|
|
231
|
+
await (0, import_develop.extensionStart)(pathOrRemoteUrl, {
|
|
232
|
+
mode: "production",
|
|
233
|
+
browser: vendor,
|
|
234
|
+
...startOptions
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
extensionCreate.command("build").arguments("[project-name]").usage("build [path-to-remote-extension] [options]").description("Builds the extension for production").option(
|
|
239
|
+
"-b, --browser <chrome | edge>",
|
|
240
|
+
"specify a browser to run your extension in development mode"
|
|
241
|
+
).option(
|
|
242
|
+
"--polyfill <boolean>",
|
|
243
|
+
"whether or not to apply the cross-browser polyfill. Defaults to `false`"
|
|
244
|
+
).action(async function(pathOrRemoteUrl, { browser = "chrome", ...buildOptions }) {
|
|
245
|
+
const vendors = browser.split(",");
|
|
246
|
+
for (const vendor of vendors) {
|
|
247
|
+
await (0, import_develop.extensionBuild)(pathOrRemoteUrl, {
|
|
248
|
+
browser: vendor,
|
|
249
|
+
...buildOptions
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
function cli() {
|
|
254
|
+
extensionCreate.parse();
|
|
255
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const path = require('path')
|
|
2
|
+
const fs = require('fs')
|
|
3
|
+
|
|
4
|
+
const [, pathOrRemoteUrl] = process.argv.slice(2)
|
|
5
|
+
const projectDir = pathOrRemoteUrl.startsWith('http')
|
|
6
|
+
? process.cwd() + path.basename(pathOrRemoteUrl)
|
|
7
|
+
: path.resolve(__dirname, pathOrRemoteUrl)
|
|
8
|
+
|
|
9
|
+
const tailwindConfig = path.join(projectDir, 'tailwind.config.js')
|
|
10
|
+
|
|
11
|
+
/** @type {import('tailwindcss').Config} */
|
|
12
|
+
const tailwindConfigData = fs.existsSync(tailwindConfig)
|
|
13
|
+
? require(tailwindConfig)
|
|
14
|
+
: {content: []}
|
|
15
|
+
|
|
16
|
+
/** @type {import('tailwindcss').Config} */
|
|
17
|
+
const tailwindRootConfig = {
|
|
18
|
+
...tailwindConfigData,
|
|
19
|
+
content: [
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
21
|
+
...tailwindConfigData.content.map((file) => path.join(projectDir, file))
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
module.exports = tailwindRootConfig
|
package/package.json
CHANGED
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
"license": "MIT",
|
|
3
3
|
"repository": {
|
|
4
4
|
"type": "git",
|
|
5
|
-
"url": "https://github.com/cezaraugusto/extension-create.git"
|
|
5
|
+
"url": "https://github.com/cezaraugusto/extension-create.git",
|
|
6
|
+
"directory": "programs/cli"
|
|
6
7
|
},
|
|
7
8
|
"engines": {
|
|
8
9
|
"node": ">=18"
|
|
9
10
|
},
|
|
10
11
|
"name": "extension",
|
|
11
|
-
"version": "1.
|
|
12
|
+
"version": "1.2.0",
|
|
12
13
|
"description": "Create cross-browser extensions with no build configuration.",
|
|
13
14
|
"main": "./dist/cli.js",
|
|
14
15
|
"types": "./dist/cli.d.ts",
|
|
@@ -16,7 +17,7 @@
|
|
|
16
17
|
"dist"
|
|
17
18
|
],
|
|
18
19
|
"bin": {
|
|
19
|
-
"extension": "./dist/cli.js"
|
|
20
|
+
"extension-create": "./dist/cli.js"
|
|
20
21
|
},
|
|
21
22
|
"author": {
|
|
22
23
|
"name": "Cezar Augusto",
|
|
@@ -24,9 +25,12 @@
|
|
|
24
25
|
"url": "https://cezaraugusto.com"
|
|
25
26
|
},
|
|
26
27
|
"scripts": {
|
|
27
|
-
"compile:
|
|
28
|
+
"compile:tailwind-config": "node ./scripts/copyTailwindConfig.js",
|
|
29
|
+
"compile:stylelint-config": "node ./scripts/copyStylelintConfig.js",
|
|
28
30
|
"compile:cli": "tsup-node ./cli.ts --format cjs --dts --target=node18",
|
|
29
|
-
"compile": "yarn compile:
|
|
31
|
+
"compile": "yarn compile:tailwind-config && yarn compile:stylelint-config && yarn compile:cli",
|
|
32
|
+
"clean": "rm -rf dist",
|
|
33
|
+
"test": "jest"
|
|
30
34
|
},
|
|
31
35
|
"keywords": [
|
|
32
36
|
"zero-config",
|
|
@@ -42,6 +46,21 @@
|
|
|
42
46
|
"typescript"
|
|
43
47
|
],
|
|
44
48
|
"dependencies": {
|
|
45
|
-
"@extension-create/
|
|
49
|
+
"@extension-create/create": "*",
|
|
50
|
+
"@extension-create/develop": "*",
|
|
51
|
+
"commander": "^11.1.0",
|
|
52
|
+
"semver": "^7.5.4"
|
|
53
|
+
},
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"@types/jest": "^29.5.11",
|
|
56
|
+
"@types/mock-fs": "^4.13.4",
|
|
57
|
+
"@types/node": "^20.11.5",
|
|
58
|
+
"@types/semver": "^7.5.6",
|
|
59
|
+
"jest": "^29.7.0",
|
|
60
|
+
"mock-fs": "^5.2.0",
|
|
61
|
+
"ts-jest": "^29.1.2",
|
|
62
|
+
"tsconfig": "*",
|
|
63
|
+
"tsup": "^8.0.1",
|
|
64
|
+
"typescript": "5.3.3"
|
|
46
65
|
}
|
|
47
66
|
}
|