extension-create 0.5.1 → 1.0.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 +29 -30
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +252 -0
- package/package.json +51 -36
- package/LICENSE +0 -21
- package/cli.js +0 -40
- package/create/CONTRIBUTING.md +0 -47
- package/create/README.md +0 -55
- package/create/cli.js +0 -58
- package/create/cli.test.js +0 -37
- package/create/createExtension.js +0 -35
- package/create/messages/directoryHasConflicts.js +0 -38
- package/create/messages/index.js +0 -16
- package/create/messages/programHelp.js +0 -26
- package/create/messages/successfullInstall.js +0 -24
- package/create/package.json +0 -38
- package/create/steps/abortProjectAndClean.js +0 -40
- package/create/steps/cleanTemplateFolder.js +0 -26
- package/create/steps/createDirectory.js +0 -45
- package/create/steps/getTemplatePath.js +0 -23
- package/create/steps/importExternalTemplate.js +0 -41
- package/create/steps/importLocalTemplate.js +0 -33
- package/create/steps/installDependencies.js +0 -61
- package/create/steps/writePackageJson.js +0 -64
- package/create/templates/standard/.gitignore +0 -21
- package/create/templates/standard/README.md +0 -14
- package/create/templates/standard/package.json +0 -26
- package/create/templates/standard/template/.gitignore +0 -21
- package/create/templates/standard/template/README.md +0 -0
- package/create/templates/standard/template/manifest.json +0 -31
- package/create/templates/standard/template/newtab/newtab.html +0 -24
- package/create/templates/standard/template/newtab/newtab.js +0 -1
- package/create/templates/standard/template/newtab/styles.css +0 -43
- package/create/templates/standard/template/popup/popup.css +0 -26
- package/create/templates/standard/template/popup/popup.html +0 -15
- package/create/templates/standard/template/popup/popup.js +0 -1
- package/create/templates/standard/template/public/icon/test_16.png +0 -0
- package/create/templates/standard/template/public/icon/test_32.png +0 -0
- package/create/templates/standard/template/public/icon/test_48.png +0 -0
- package/create/templates/standard/template/public/icon/test_64.png +0 -0
- package/create/templates/standard/template/public/puzzle.png +0 -0
- package/create/templates/standard/template.json +0 -6
- package/create/yarn.lock +0 -4462
- package/develop/CONTRIBUTING.md +0 -47
- package/develop/README.md +0 -55
- package/develop/module.js +0 -16
- package/develop/package.json +0 -44
- package/develop/start/cli.js +0 -47
- package/develop/start/cli.test.js +0 -45
- package/develop/start/config/browserSwitch.js +0 -31
- package/develop/start/config/compiler.js +0 -47
- package/develop/start/config/server.js +0 -17
- package/develop/start/messages/index.js +0 -14
- package/develop/start/messages/manifestNotFound.js +0 -22
- package/develop/start/messages/programHelp.js +0 -49
- package/develop/start/resolve/resolveExtensionPath.js +0 -45
- package/develop/start/startExtension.js +0 -69
- package/develop/start/steps/resolveManifest.js +0 -44
- package/develop/start/steps/startWebpack.js +0 -46
- package/develop/yarn.lock +0 -7165
- package/messages.js +0 -57
- package/preinstall.sh +0 -2
- package/reservedKeywords.js +0 -17
package/README.md
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
> ### This project is under active development.
|
|
2
|
-
|
|
3
1
|
[action-image]: https://github.com/cezaraugusto/extension-create/workflows/CI/badge.svg
|
|
4
2
|
[action-url]: https://github.com/cezaraugusto/extension-create/actions
|
|
5
3
|
[npm-image]: https://img.shields.io/npm/v/extension-create.svg
|
|
@@ -11,23 +9,23 @@
|
|
|
11
9
|
|
|
12
10
|
<img alt="Logo" align="right" src="https://user-images.githubusercontent.com/4672033/102850460-4d22aa80-43f8-11eb-82db-9efce586f73e.png" width="25%" />
|
|
13
11
|
|
|
14
|
-
Create
|
|
12
|
+
Create cross-browser extensions with no build configuration.
|
|
15
13
|
|
|
16
14
|
- [Creating an extension](#creating-an-extension) — How to create a new extension.
|
|
17
15
|
- [Getting started immediately](#getting-started-immediately) — Get work done in no time.
|
|
18
|
-
- [I have an extension](#i-have-an-extension) - Use only specific parts of `extension-create
|
|
16
|
+
- [I have an extension](#i-have-an-extension) - Use only specific parts of `extension-create`.
|
|
19
17
|
|
|
20
|
-
`extension-create` helps you develop cross-browser extensions with built-in support for module imports/exports, auto-reload, and more.
|
|
18
|
+
`extension-create` helps you develop cross-browser extensions with built-in support for module imports/exports, auto-reload, and more.
|
|
21
19
|
|
|
22
20
|
## Creating an Extension
|
|
23
21
|
|
|
24
22
|
```sh
|
|
25
|
-
npx extension-create my-extension-hello
|
|
23
|
+
npx extension-create create my-extension-hello
|
|
26
24
|
cd my-extension-hello
|
|
27
|
-
npm
|
|
25
|
+
npm run dev
|
|
28
26
|
```
|
|
29
27
|
|
|
30
|
-
A new browser instance
|
|
28
|
+
A new browser instance will open up with your extension ready for development.
|
|
31
29
|
|
|
32
30
|
You are done. Time to hack on your extension!
|
|
33
31
|
|
|
@@ -39,14 +37,18 @@ You are done. Time to hack on your extension!
|
|
|
39
37
|
|
|
40
38
|
### Kickstart any sample from Chrome Extension Samples
|
|
41
39
|
|
|
42
|
-
The [chrome-
|
|
40
|
+
The [chrome-extensions-sample](https://github.com/GoogleChrome/chrome-extensions-samples/) project is a great way to kickstart developing your extension.
|
|
43
41
|
|
|
44
|
-
If we go to the samples repository and look for an extension sample to work, let's say the [
|
|
42
|
+
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:
|
|
45
43
|
|
|
46
|
-
|
|
44
|
+
#### Command
|
|
47
45
|
|
|
48
46
|
```sh
|
|
49
|
-
|
|
47
|
+
# This command will:
|
|
48
|
+
# 1. Download the Chrome extension sample URL to the current working directory
|
|
49
|
+
# 2. Bundle the downloaded extension using extension-create
|
|
50
|
+
# 3. Enable the extension in Chrome using a fresh user profile
|
|
51
|
+
npx extension-create dev https://github.com/GoogleChrome/chrome-extensions-samples/tree/main/functional-samples/sample.page-redder
|
|
50
52
|
```
|
|
51
53
|
|
|
52
54
|
<p align="center">
|
|
@@ -57,47 +59,44 @@ Will not only download the extension but also kickstart a Chrome instance in a f
|
|
|
57
59
|
|
|
58
60
|
### Use `Microsoft Edge` to kickstart any sample from [chrome-extesions-sample](https://github.com/GoogleChrome/chrome-extensions-samples/)
|
|
59
61
|
|
|
60
|
-
You read it
|
|
62
|
+
**You read it!** Just run the command above with the `--browser=edge` flag:
|
|
61
63
|
|
|
62
|
-
```
|
|
63
|
-
npx extension-create
|
|
64
|
+
```sh
|
|
65
|
+
npx extension-create dev --browser=edge https://github.com/GoogleChrome/chrome-extensions-samples/tree/main/functional-samples/sample.page-redder
|
|
64
66
|
```
|
|
65
67
|
|
|
66
|
-
And see a
|
|
68
|
+
And see a Chrome Extension sample running automatically. On Edge!
|
|
67
69
|
|
|
68
70
|
## I have an extension
|
|
69
71
|
|
|
70
|
-
`extension-create`
|
|
71
|
-
|
|
72
|
-
### Integrate `extension-create` via command line or npm scripts
|
|
73
|
-
|
|
74
|
-
The first option is to just use the command line interface `extension-create` provides and add it to your npm scripts. Assuming you want your extension to run the `start` command (path argument can be omitted if the manifest file is on your extension root folder), here's how it should look in your `package.json`:
|
|
72
|
+
Just add `extension-create` to your npm scripts. Here's how it should look in your `package.json`:
|
|
75
73
|
|
|
76
74
|
```js
|
|
77
75
|
{
|
|
78
76
|
// ...npm stuff,
|
|
79
77
|
"scripts": {
|
|
80
|
-
"start": "npx extension-create start"
|
|
78
|
+
"start": "npx extension-create start",
|
|
79
|
+
"dev": "npx extension-create dev",
|
|
80
|
+
"build": "npx extension-create build"
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
```
|
|
84
84
|
|
|
85
|
-
Will load your extension the same way the screenshot above demonstrates. This method is, in fact, what the [standard template does](https://github.com/cezaraugusto/extension-create/blob/main/create/steps/writePackageJson.js#L19-L21) when you run the create command `npx extension-create <extension-name>`.
|
|
86
|
-
|
|
87
85
|
#### Using a specific browser for development
|
|
88
86
|
|
|
89
|
-
| <img width=120 src="https://raw.githubusercontent.com/alrra/browser-logos/
|
|
90
|
-
|
|
91
|
-
| Google Chrome ✅
|
|
87
|
+
| <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"> |
|
|
88
|
+
| -------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
|
|
89
|
+
| Google Chrome ✅ | Microsoft Edge ✅ | Mozilla Firefox ⛔️ | Apple Safari ⛔️ | Opera browser ⛔️ | Chromium (forks) 🤔 |
|
|
92
90
|
|
|
93
|
-
If you want to target a specific browser, just pass the `--browser` flag to the start command (Chrome or Edge, soon others), like `npx extension-create
|
|
91
|
+
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`.
|
|
94
92
|
|
|
95
93
|
That's it!
|
|
96
94
|
|
|
97
95
|
> _Hint: pass `all` instead of `edge` as an argument to load both Edge and Chrome at the same time!_
|
|
98
|
-
## What's next?
|
|
99
96
|
|
|
100
|
-
|
|
97
|
+
## Program Options Table
|
|
98
|
+
|
|
99
|
+
For a list of all commands available, see [OPTIONS_TABLE.md](OPTIONS_TABLE.md).
|
|
101
100
|
|
|
102
101
|
## License
|
|
103
102
|
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
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
|
+
));
|
|
29
|
+
|
|
30
|
+
// cli.ts
|
|
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
|
+
},
|
|
115
|
+
engines: {
|
|
116
|
+
node: ">=18"
|
|
117
|
+
},
|
|
118
|
+
name: "extension-create",
|
|
119
|
+
version: "1.0.0",
|
|
120
|
+
description: "Create cross-browser extensions with no build configuration.",
|
|
121
|
+
main: "./dist/cli.js",
|
|
122
|
+
types: "./dist/cli.d.ts",
|
|
123
|
+
files: [
|
|
124
|
+
"dist"
|
|
125
|
+
],
|
|
126
|
+
bin: {
|
|
127
|
+
"extension-create": "./dist/cli.js"
|
|
128
|
+
},
|
|
129
|
+
author: {
|
|
130
|
+
name: "Cezar Augusto",
|
|
131
|
+
email: "boss@cezaraugusto.net",
|
|
132
|
+
url: "https://cezaraugusto.com"
|
|
133
|
+
},
|
|
134
|
+
scripts: {
|
|
135
|
+
postinstall: "node ./scripts/copyMarkdownFilesToCli.js",
|
|
136
|
+
clean: "rm -rf dist",
|
|
137
|
+
compile: "tsup-node ./cli.ts --format cjs --dts --target=node18",
|
|
138
|
+
test: "jest"
|
|
139
|
+
},
|
|
140
|
+
keywords: [
|
|
141
|
+
"zero-config",
|
|
142
|
+
"build",
|
|
143
|
+
"develop",
|
|
144
|
+
"browser",
|
|
145
|
+
"extension",
|
|
146
|
+
"chrome extension",
|
|
147
|
+
"edge extension",
|
|
148
|
+
"firefox extension",
|
|
149
|
+
"web",
|
|
150
|
+
"react",
|
|
151
|
+
"typescript"
|
|
152
|
+
],
|
|
153
|
+
dependencies: {
|
|
154
|
+
"@extension-create/create": "*",
|
|
155
|
+
"@extension-create/develop": "*",
|
|
156
|
+
"@types/jest": "^29.5.11",
|
|
157
|
+
commander: "^11.1.0",
|
|
158
|
+
inquirer: "^9.2.12",
|
|
159
|
+
semver: "^7.5.4",
|
|
160
|
+
tsconfig: "*"
|
|
161
|
+
},
|
|
162
|
+
devDependencies: {
|
|
163
|
+
"@types/inquirer": "^9.0.7",
|
|
164
|
+
"@types/jest": "^29.5.11",
|
|
165
|
+
"@types/mock-fs": "^4.13.4",
|
|
166
|
+
"@types/node": "^20.11.5",
|
|
167
|
+
"@types/pacote": "^11.1.8",
|
|
168
|
+
"@types/semver": "^7.5.6",
|
|
169
|
+
jest: "^29.7.0",
|
|
170
|
+
"mock-fs": "^5.2.0",
|
|
171
|
+
"ts-jest": "^29.1.2",
|
|
172
|
+
tsup: "^8.0.1",
|
|
173
|
+
typescript: "^5.3.3"
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
// cli.ts
|
|
178
|
+
var import_create = __toESM(require("@extension-create/create"));
|
|
179
|
+
var import_develop = require("@extension-create/develop");
|
|
180
|
+
if (import_semver.default.lte(process.version, "18.0.0")) {
|
|
181
|
+
messages_default.unsupportedNodeVersion();
|
|
182
|
+
process.exit(1);
|
|
183
|
+
}
|
|
184
|
+
var extensionCreate = import_commander.program;
|
|
185
|
+
var isExtensionCreateNamespace = package_default.name === "extension-create";
|
|
186
|
+
extensionCreate.name(package_default.name).description(package_default.description).version(package_default.version).addHelpText("after", messages_default.programHelp());
|
|
187
|
+
extensionCreate.command("create", { isDefault: isExtensionCreateNamespace }).arguments("<project-name|project-path>").usage("create <project-name|project-path> [options]").description("Creates a new extension.").option(
|
|
188
|
+
"-t, --template <template-name>",
|
|
189
|
+
"specify a template for the created project"
|
|
190
|
+
).action(async function(projectName, { template, targetDir }) {
|
|
191
|
+
await (0, import_create.default)(projectName, { targetDir, template });
|
|
192
|
+
});
|
|
193
|
+
extensionCreate.command("dev").arguments("[project-path|remote-url]").usage("dev [project-path|remote-url] [options]").description("Starts the development server (development mode)").option(
|
|
194
|
+
"-u, --user-data-dir <path-to-file | boolean>",
|
|
195
|
+
"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"
|
|
196
|
+
).option(
|
|
197
|
+
"-b, --browser <chrome | edge>",
|
|
198
|
+
"specify a browser to run your extension in development mode"
|
|
199
|
+
).option(
|
|
200
|
+
"--polyfill <boolean>",
|
|
201
|
+
"whether or not to apply the cross-browser polyfill. Defaults to `true`"
|
|
202
|
+
).option(
|
|
203
|
+
"-p, --port <number>",
|
|
204
|
+
"what port should extension-create/develop run. Defaults to `3000`"
|
|
205
|
+
).action(async function(pathOrRemoteUrl, { browser = "chrome", ...devOptions }) {
|
|
206
|
+
const vendors = browser.split(",");
|
|
207
|
+
for (const vendor of vendors) {
|
|
208
|
+
await (0, import_develop.extensionDev)(pathOrRemoteUrl, {
|
|
209
|
+
mode: "development",
|
|
210
|
+
browser: vendor,
|
|
211
|
+
...devOptions
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
extensionCreate.command("start").arguments("[project-path|remote-url]").usage("start [project-path|remote-url] [options]").description("Starts the development server (production mode)").option(
|
|
216
|
+
"-u, --user-data-dir <path-to-file | boolean>",
|
|
217
|
+
"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"
|
|
218
|
+
).option(
|
|
219
|
+
"-b, --browser <chrome | edge>",
|
|
220
|
+
"specify a browser to run your extension in development mode"
|
|
221
|
+
).option(
|
|
222
|
+
"--polyfill <boolean>",
|
|
223
|
+
"whether or not to apply the cross-browser polyfill. Defaults to `true`"
|
|
224
|
+
).option(
|
|
225
|
+
"-p, --port <number>",
|
|
226
|
+
"what port should extension-create/develop run. Defaults to `3000`"
|
|
227
|
+
).action(async function(pathOrRemoteUrl, { browser = "chrome", ...startOptions }) {
|
|
228
|
+
const vendors = browser.split(",");
|
|
229
|
+
for (const vendor of vendors) {
|
|
230
|
+
await (0, import_develop.extensionStart)(pathOrRemoteUrl, {
|
|
231
|
+
mode: "production",
|
|
232
|
+
browser: vendor,
|
|
233
|
+
...startOptions
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
extensionCreate.command("build").arguments("[project-name]").usage("build [path-to-remote-extension] [options]").description("Builds the extension for production").option(
|
|
238
|
+
"-b, --browser <chrome | edge>",
|
|
239
|
+
"specify a browser to run your extension in development mode"
|
|
240
|
+
).option(
|
|
241
|
+
"--polyfill <boolean>",
|
|
242
|
+
"whether or not to apply the cross-browser polyfill. Defaults to `false`"
|
|
243
|
+
).action(async function(pathOrRemoteUrl, { browser = "chrome", ...buildOptions }) {
|
|
244
|
+
const vendors = browser.split(",");
|
|
245
|
+
for (const vendor of vendors) {
|
|
246
|
+
await (0, import_develop.extensionBuild)(pathOrRemoteUrl, {
|
|
247
|
+
browser: vendor,
|
|
248
|
+
...buildOptions
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
extensionCreate.parse();
|
package/package.json
CHANGED
|
@@ -1,52 +1,67 @@
|
|
|
1
1
|
{
|
|
2
|
+
"license": "MIT",
|
|
3
|
+
"repository": {
|
|
4
|
+
"type": "git",
|
|
5
|
+
"url": "https://github.com/cezaraugusto/extension-create.git"
|
|
6
|
+
},
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">=18"
|
|
9
|
+
},
|
|
2
10
|
"name": "extension-create",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Create
|
|
5
|
-
"main": "./cli.js",
|
|
11
|
+
"version": "1.0.0",
|
|
12
|
+
"description": "Create cross-browser extensions with no build configuration.",
|
|
13
|
+
"main": "./dist/cli.js",
|
|
14
|
+
"types": "./dist/cli.d.ts",
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
6
18
|
"bin": {
|
|
7
|
-
"extension-create": "./cli.js"
|
|
19
|
+
"extension-create": "./dist/cli.js"
|
|
20
|
+
},
|
|
21
|
+
"author": {
|
|
22
|
+
"name": "Cezar Augusto",
|
|
23
|
+
"email": "boss@cezaraugusto.net",
|
|
24
|
+
"url": "https://cezaraugusto.com"
|
|
8
25
|
},
|
|
9
26
|
"scripts": {
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"deploy": "np",
|
|
27
|
+
"postinstall": "node ./scripts/copyMarkdownFilesToCli.js",
|
|
28
|
+
"clean": "rm -rf dist",
|
|
29
|
+
"compile": "tsup-node ./cli.ts --format cjs --dts --target=node18",
|
|
14
30
|
"test": "jest"
|
|
15
31
|
},
|
|
16
32
|
"keywords": [
|
|
17
|
-
"
|
|
18
|
-
"
|
|
33
|
+
"zero-config",
|
|
34
|
+
"build",
|
|
35
|
+
"develop",
|
|
36
|
+
"browser",
|
|
37
|
+
"extension",
|
|
19
38
|
"chrome extension",
|
|
39
|
+
"edge extension",
|
|
20
40
|
"firefox extension",
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
],
|
|
25
|
-
"author": "Cezar Augusto <boss@cezaraugusto.net> (https://twitter.com/cezaraugusto)",
|
|
26
|
-
"license": "MIT",
|
|
27
|
-
"files": [
|
|
28
|
-
"create",
|
|
29
|
-
"develop",
|
|
30
|
-
"cli.js",
|
|
31
|
-
"messages.js",
|
|
32
|
-
"preinstall.sh",
|
|
33
|
-
"reservedKeywords.js"
|
|
41
|
+
"web",
|
|
42
|
+
"react",
|
|
43
|
+
"typescript"
|
|
34
44
|
],
|
|
35
45
|
"dependencies": {
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
46
|
+
"@extension-create/create": "*",
|
|
47
|
+
"@extension-create/develop": "*",
|
|
48
|
+
"@types/jest": "^29.5.11",
|
|
49
|
+
"commander": "^11.1.0",
|
|
50
|
+
"inquirer": "^9.2.12",
|
|
51
|
+
"semver": "^7.5.4",
|
|
52
|
+
"tsconfig": "*"
|
|
40
53
|
},
|
|
41
54
|
"devDependencies": {
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"fs
|
|
50
|
-
"jest": "^
|
|
55
|
+
"@types/inquirer": "^9.0.7",
|
|
56
|
+
"@types/jest": "^29.5.11",
|
|
57
|
+
"@types/mock-fs": "^4.13.4",
|
|
58
|
+
"@types/node": "^20.11.5",
|
|
59
|
+
"@types/pacote": "^11.1.8",
|
|
60
|
+
"@types/semver": "^7.5.6",
|
|
61
|
+
"jest": "^29.7.0",
|
|
62
|
+
"mock-fs": "^5.2.0",
|
|
63
|
+
"ts-jest": "^29.1.2",
|
|
64
|
+
"tsup": "^8.0.1",
|
|
65
|
+
"typescript": "^5.3.3"
|
|
51
66
|
}
|
|
52
67
|
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2020 Cezar Augusto
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
package/cli.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const {program} = require('commander')
|
|
4
|
-
const semver = require('semver')
|
|
5
|
-
|
|
6
|
-
const isKeyword = require('./reservedKeywords')
|
|
7
|
-
const packageJson = require('./package.json')
|
|
8
|
-
const createExtensionCLI = require('./create')
|
|
9
|
-
const developExtensionCLI = require('./develop')
|
|
10
|
-
const messages = require('./messages')
|
|
11
|
-
|
|
12
|
-
if (semver.lte(process.version, '10.3.0')) {
|
|
13
|
-
messages.nodeVersionNotSupported()
|
|
14
|
-
process.exit(1)
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const extensionCreate = program
|
|
18
|
-
|
|
19
|
-
extensionCreate
|
|
20
|
-
.version(packageJson.version)
|
|
21
|
-
.on('--help', () => messages.help())
|
|
22
|
-
|
|
23
|
-
// We support creating new extensions without
|
|
24
|
-
// an explicit `create` command but this convenience
|
|
25
|
-
// allows user to add projects using command names.
|
|
26
|
-
// In this case we check first if command is a keyword
|
|
27
|
-
// and only run create if it's not.
|
|
28
|
-
if (!isKeyword()) {
|
|
29
|
-
const argument = process.argv[process.argv.length - 1]
|
|
30
|
-
|
|
31
|
-
// This operation is a mistake, warn user.
|
|
32
|
-
if (argument.startsWith('http')) {
|
|
33
|
-
messages.noURLWithoutStart(argument)
|
|
34
|
-
process.exit()
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
createExtensionCLI(extensionCreate)
|
|
38
|
-
} else {
|
|
39
|
-
developExtensionCLI(extensionCreate)
|
|
40
|
-
}
|
package/create/CONTRIBUTING.md
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
# Contributing to @webextension/create
|
|
2
|
-
|
|
3
|
-
## Getting started
|
|
4
|
-
|
|
5
|
-
```
|
|
6
|
-
git clone git@github.com:cezaraugusto/extension-create.git
|
|
7
|
-
cd extension-create/create
|
|
8
|
-
yarn install
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Creating an extension
|
|
12
|
-
|
|
13
|
-
`yarn dev:create` is equivalent of running `npx @webextension/create my-hello-extension`
|
|
14
|
-
|
|
15
|
-
## Running tests
|
|
16
|
-
|
|
17
|
-
`cli.test.js` is an evergrowing list of tests covering functionalities exposed to the client. For file testing, see **unit testing**.
|
|
18
|
-
|
|
19
|
-
```
|
|
20
|
-
yarn test
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
### Unit testing
|
|
24
|
-
|
|
25
|
-
Unit tests are welcome and should live in the same folder as the file it is testing, having one created in case of no tests, suffixed with `.test.js`.
|
|
26
|
-
|
|
27
|
-
For example:
|
|
28
|
-
|
|
29
|
-
**Before**
|
|
30
|
-
|
|
31
|
-
```
|
|
32
|
-
folder/
|
|
33
|
-
method1.js
|
|
34
|
-
method2.js
|
|
35
|
-
method3.js
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
**After**
|
|
39
|
-
|
|
40
|
-
```
|
|
41
|
-
folder/
|
|
42
|
-
method1/
|
|
43
|
-
method1.js
|
|
44
|
-
method1.spec.js
|
|
45
|
-
method2.js
|
|
46
|
-
method3.js
|
|
47
|
-
```
|
package/create/README.md
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
# @extension-create/create
|
|
2
|
-
|
|
3
|
-
> The `create` part of `extension-create` available as a standalone package.
|
|
4
|
-
|
|
5
|
-
This package stores all logic needed by `extension-create` to create new projects.
|
|
6
|
-
|
|
7
|
-
## Installation
|
|
8
|
-
|
|
9
|
-
```
|
|
10
|
-
npm i @extension-create/create
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
## Usage
|
|
14
|
-
|
|
15
|
-
There are two ways of using it:
|
|
16
|
-
|
|
17
|
-
### Standalone Executable
|
|
18
|
-
|
|
19
|
-
```
|
|
20
|
-
# Will create a new directory named `my-extension-hello`.
|
|
21
|
-
npx @extension-create/create my-extension-hello
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
### Imported CLI
|
|
25
|
-
|
|
26
|
-
Alternatively, if you're using [commander](https://github.com/tj/commander.js), you can use `@extension-create/create` to extend you CLI. This is what `extension-create` does.
|
|
27
|
-
|
|
28
|
-
```js
|
|
29
|
-
const {program} = require('commander')
|
|
30
|
-
const createExtensionCLI = require('@extension-create/create')
|
|
31
|
-
|
|
32
|
-
const yourCreateProgram = program
|
|
33
|
-
|
|
34
|
-
yourCreateProgram
|
|
35
|
-
.version(packageJson.version)
|
|
36
|
-
|
|
37
|
-
createExtensionCLI(yourCreateProgram)
|
|
38
|
-
|
|
39
|
-
yourCreateProgram
|
|
40
|
-
.parse(process.argv)
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
## Program options table
|
|
44
|
-
|
|
45
|
-
| Flag | Argument | What it does |
|
|
46
|
-
|------------------|----------------------------------------------------------|--------------|
|
|
47
|
-
| -t, --template | Path to the template used to bootstrap your extension | Bootstrap your extension using a template |
|
|
48
|
-
|
|
49
|
-
## Contributing
|
|
50
|
-
|
|
51
|
-
See [CONTRIBUTING.md](CONTRIBUTING.md)
|
|
52
|
-
|
|
53
|
-
## License
|
|
54
|
-
|
|
55
|
-
MIT (c) Cezar Augusto.
|