extension-create 0.4.3 → 0.5.2
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 +50 -5
- package/create/README.md +10 -12
- package/create/cli.js +2 -2
- package/create/cli.test.js +4 -5
- package/create/createExtension.js +8 -2
- package/create/messages/directoryHasConflicts.js +9 -11
- package/create/messages/programHelp.js +1 -1
- package/create/messages/successfullInstall.js +1 -1
- package/create/package.json +1 -2
- package/create/steps/abortProjectAndClean.js +8 -5
- package/create/steps/cleanTemplateFolder.js +1 -1
- package/create/steps/createDirectory.js +9 -13
- package/create/steps/getTemplatePath.js +1 -1
- package/create/steps/importExternalTemplate.js +11 -10
- package/create/steps/importLocalTemplate.js +5 -7
- package/create/steps/installDependencies.js +3 -6
- package/create/steps/writePackageJson.js +7 -7
- package/create/templates/standard/template/manifest.json +21 -25
- package/create/templates/standard/template/newtab/newtab.html +8 -5
- package/create/templates/standard/template/newtab/styles.css +2 -2
- package/create/templates/standard/template/popup/popup.css +2 -2
- package/create/templates/standard/template/popup/popup.html +2 -2
- package/create/templates/standard/template.json +1 -2
- package/develop/README.md +11 -13
- package/develop/module.js +1 -1
- package/develop/package-lock.json +7979 -0
- package/develop/package.json +3 -10
- package/develop/start/cli.js +14 -4
- package/develop/start/cli.test.js +8 -4
- package/develop/start/config/browserSwitch.js +31 -0
- package/develop/start/config/compiler.js +7 -23
- package/develop/start/messages/manifestNotFound.js +1 -1
- package/develop/start/messages/programHelp.js +10 -1
- package/develop/start/resolve/resolveExtensionPath.js +1 -1
- package/develop/start/startExtension.js +10 -4
- package/develop/start/steps/resolveManifest.js +1 -1
- package/develop/start/steps/startWebpack.js +11 -5
- package/develop/yarn.lock +45 -266
- package/package.json +14 -12
- package/preinstall.sh +10 -2
package/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
> ### This project is under active development.
|
|
2
|
+
|
|
1
3
|
[action-image]: https://github.com/cezaraugusto/extension-create/workflows/CI/badge.svg
|
|
2
4
|
[action-url]: https://github.com/cezaraugusto/extension-create/actions
|
|
3
5
|
[npm-image]: https://img.shields.io/npm/v/extension-create.svg
|
|
@@ -13,6 +15,7 @@ Create modern cross-browser extensions with no build configuration.
|
|
|
13
15
|
|
|
14
16
|
- [Creating an extension](#creating-an-extension) — How to create a new extension.
|
|
15
17
|
- [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
19
|
|
|
17
20
|
`extension-create` helps you develop cross-browser extensions with built-in support for module imports/exports, auto-reload, and more. Interested to know how it's being developed? [Every week I send emails about its progress](https://cezaraugusto.substack.com/). For goals, see the [wiki](https://github.com/cezaraugusto/extension-create/wiki/This-initiative).
|
|
18
21
|
|
|
@@ -34,14 +37,16 @@ You are done. Time to hack on your extension!
|
|
|
34
37
|
|
|
35
38
|
## Getting Started Immediately
|
|
36
39
|
|
|
37
|
-
### Kickstart any sample from
|
|
40
|
+
### Kickstart any sample from Chrome Extension Samples
|
|
41
|
+
|
|
42
|
+
The [chrome-extensions-sample](https://github.com/GoogleChrome/chrome-extensions-samples/) project is a great way to kickstart developing your extension.
|
|
38
43
|
|
|
39
|
-
|
|
44
|
+
If we go to the samples repository and look for an extension sample to work, let's say the [make_page_red](https://github.com/GoogleChrome/chrome-extensions-samples/blob/main/mv2-archive/api/browserAction/make_page_red/) sample, all we need is to copy and paste it's URL as an argument for the start command:
|
|
40
45
|
|
|
41
|
-
> Optimized for **git version 2.30.0**. Older versions are supported but download can take much longer.
|
|
46
|
+
> Optimized for **git version 2.30.0**. Older versions are supported, but download can take much longer.
|
|
42
47
|
|
|
43
48
|
```sh
|
|
44
|
-
npx extension-create start https://github.com/GoogleChrome/chrome-extensions-samples/
|
|
49
|
+
npx extension-create start https://github.com/GoogleChrome/chrome-extensions-samples/blob/main/mv2-archive/api/browserAction/make_page_red/
|
|
45
50
|
```
|
|
46
51
|
|
|
47
52
|
<p align="center">
|
|
@@ -50,9 +55,49 @@ npx extension-create start https://github.com/GoogleChrome/chrome-extensions-sam
|
|
|
50
55
|
|
|
51
56
|
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!
|
|
52
57
|
|
|
58
|
+
### Use `Microsoft Edge` to kickstart any sample from [chrome-extesions-sample](https://github.com/GoogleChrome/chrome-extensions-samples/)
|
|
59
|
+
|
|
60
|
+
You read it! Just run the command above with the `--browser=edge` flag:
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
npx extension-create start --browser=edge https://github.com/GoogleChrome/chrome-extensions-samples/blob/main/mv2-archive/api/browserAction/make_page_red/
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
And see a Crome Extension sample running automatically. On Edge!
|
|
67
|
+
|
|
68
|
+
## I have an extension
|
|
69
|
+
|
|
70
|
+
`extension-create` was designed to have each command/major feature working as a standalone module. This is useful if you have your extension setup but want to benefit from specific features, such as the browser launcher w/ default auto-reload support. You have two ways of doing it.
|
|
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`:
|
|
75
|
+
|
|
76
|
+
```js
|
|
77
|
+
{
|
|
78
|
+
// ...npm stuff,
|
|
79
|
+
"scripts": {
|
|
80
|
+
"start": "npx extension-create start"
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
```
|
|
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
|
+
#### Using a specific browser for development
|
|
88
|
+
|
|
89
|
+
| <img width=120 src="https://raw.githubusercontent.com/alrra/browser-logos/a94987f29719142668cdf960b3f624ce1a3c6aa8/src/chrome/chrome.svg?sanitize=true" alt="Chrome browser logo"> | <img width=120 src="https://raw.githubusercontent.com/alrra/browser-logos/a94987f29719142668cdf960b3f624ce1a3c6aa8/src/edge/edge.svg?sanitize=true" alt="Microsoft Edge browser logo"> |
|
|
90
|
+
|-----------|---------|
|
|
91
|
+
| Google Chrome ✅ | Microsoft Edge ✅ |
|
|
92
|
+
|
|
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 start --browser=edge`.
|
|
94
|
+
|
|
95
|
+
That's it!
|
|
96
|
+
|
|
97
|
+
> _Hint: pass `all` instead of `edge` as an argument to load both Edge and Chrome at the same time!_
|
|
53
98
|
## What's next?
|
|
54
99
|
|
|
55
|
-
See the [Wiki](https://github.com/cezaraugusto/extension-create/wiki) for stable updates and future project roadmap. If you're
|
|
100
|
+
See the [Wiki](https://github.com/cezaraugusto/extension-create/wiki) for stable updates and future project roadmap. If you're interested in the latest news, I write weekly about this project development at https://cezaraugusto.substack.com.
|
|
56
101
|
|
|
57
102
|
## License
|
|
58
103
|
|
package/create/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @
|
|
1
|
+
# @extension-create/create
|
|
2
2
|
|
|
3
3
|
> The `create` part of `extension-create` available as a standalone package.
|
|
4
4
|
|
|
@@ -7,7 +7,7 @@ This package stores all logic needed by `extension-create` to create new project
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
9
9
|
```
|
|
10
|
-
npm i @
|
|
10
|
+
npm i @extension-create/create
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
## Usage
|
|
@@ -18,33 +18,31 @@ There are two ways of using it:
|
|
|
18
18
|
|
|
19
19
|
```
|
|
20
20
|
# Will create a new directory named `my-extension-hello`.
|
|
21
|
-
npx @
|
|
21
|
+
npx @extension-create/create my-extension-hello
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
### Imported CLI
|
|
25
25
|
|
|
26
|
-
Alternatively, if you're using [commander](https://github.com/tj/commander.js), you can use `@
|
|
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
27
|
|
|
28
28
|
```js
|
|
29
29
|
const {program} = require('commander')
|
|
30
|
-
const createExtensionCLI = require('@
|
|
30
|
+
const createExtensionCLI = require('@extension-create/create')
|
|
31
31
|
|
|
32
32
|
const yourCreateProgram = program
|
|
33
33
|
|
|
34
|
-
yourCreateProgram
|
|
35
|
-
.version(packageJson.version)
|
|
34
|
+
yourCreateProgram.version(packageJson.version)
|
|
36
35
|
|
|
37
36
|
createExtensionCLI(yourCreateProgram)
|
|
38
37
|
|
|
39
|
-
yourCreateProgram
|
|
40
|
-
.parse(process.argv)
|
|
38
|
+
yourCreateProgram.parse(process.argv)
|
|
41
39
|
```
|
|
42
40
|
|
|
43
41
|
## Program options table
|
|
44
42
|
|
|
45
|
-
| Flag
|
|
46
|
-
|
|
47
|
-
| -t, --template
|
|
43
|
+
| Flag | Argument | What it does |
|
|
44
|
+
| -------------- | ----------------------------------------------------- | ----------------------------------------- |
|
|
45
|
+
| -t, --template | Path to the template used to bootstrap your extension | Bootstrap your extension using a template |
|
|
48
46
|
|
|
49
47
|
## Contributing
|
|
50
48
|
|
package/create/cli.js
CHANGED
|
@@ -17,12 +17,12 @@ const packageJson = require('./package.json')
|
|
|
17
17
|
let projectName
|
|
18
18
|
let templateName
|
|
19
19
|
|
|
20
|
-
function createExtensionCLI
|
|
20
|
+
function createExtensionCLI(clientProgram = program) {
|
|
21
21
|
clientProgram
|
|
22
22
|
.version(packageJson.version)
|
|
23
23
|
.command('create', {isDefault: true})
|
|
24
24
|
.usage('create <project-directory> [options]')
|
|
25
|
-
.action((cmd) => {
|
|
25
|
+
.action((_, cmd) => {
|
|
26
26
|
const {args, template} = cmd
|
|
27
27
|
|
|
28
28
|
projectName = args[0]
|
package/create/cli.test.js
CHANGED
|
@@ -15,11 +15,10 @@ describe('`create` command line interface', () => {
|
|
|
15
15
|
})
|
|
16
16
|
|
|
17
17
|
it('creates an extension with specified project name', async () => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
)
|
|
18
|
+
expect.assertions(1)
|
|
19
|
+
spawn.sync('node', [createExtensionCLI, 'my-extension-home'], {
|
|
20
|
+
stdio: 'inherit'
|
|
21
|
+
})
|
|
23
22
|
|
|
24
23
|
const pathStat = await fs.stat(outputpath)
|
|
25
24
|
const isDirectory = pathStat.isDirectory()
|
|
@@ -14,9 +14,15 @@ const messages = require('./messages')
|
|
|
14
14
|
const abortAndClean = require('./steps/abortProjectAndClean')
|
|
15
15
|
const cleanTemplateFolder = require('./steps/cleanTemplateFolder')
|
|
16
16
|
|
|
17
|
-
process.on('unhandledRejection', (error) => {
|
|
17
|
+
process.on('unhandledRejection', (error) => {
|
|
18
|
+
throw error
|
|
19
|
+
})
|
|
18
20
|
|
|
19
|
-
module.exports = async function (
|
|
21
|
+
module.exports = async function createExtension(
|
|
22
|
+
workingDir,
|
|
23
|
+
projectName,
|
|
24
|
+
template
|
|
25
|
+
) {
|
|
20
26
|
try {
|
|
21
27
|
await createDirectory(workingDir, projectName)
|
|
22
28
|
|
|
@@ -10,27 +10,25 @@ const path = require('path')
|
|
|
10
10
|
const fs = require('fs-extra')
|
|
11
11
|
const {log} = require('log-md')
|
|
12
12
|
|
|
13
|
-
module.exports = async function (
|
|
13
|
+
module.exports = async function directoryHasConflicts(
|
|
14
|
+
projectPath,
|
|
15
|
+
conflictingFiles
|
|
16
|
+
) {
|
|
14
17
|
const projectName = path.basename(projectPath)
|
|
15
18
|
|
|
16
|
-
log(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
)
|
|
19
|
+
log(`Conflict! Directory \`${projectName}/\` includes conflicting files:`, {
|
|
20
|
+
gutter: true
|
|
21
|
+
})
|
|
20
22
|
|
|
21
23
|
for (const file of conflictingFiles) {
|
|
22
24
|
const stats = await fs.lstat(path.join(projectPath, file))
|
|
23
25
|
|
|
24
|
-
log(
|
|
25
|
-
stats.isDirectory()
|
|
26
|
-
? ` 📁 - ${file}/`
|
|
27
|
-
: ` 📄 - ${file}`
|
|
28
|
-
)
|
|
26
|
+
log(stats.isDirectory() ? ` 📁 - ${file}/` : ` 📄 - ${file}`)
|
|
29
27
|
}
|
|
30
28
|
|
|
31
29
|
log(
|
|
32
30
|
'You need to either rename/remove the files listed above,\n' +
|
|
33
|
-
|
|
31
|
+
'or choose a new directory name for your extension.',
|
|
34
32
|
{gutter: true}
|
|
35
33
|
)
|
|
36
34
|
|
|
@@ -9,7 +9,7 @@ const path = require('path')
|
|
|
9
9
|
|
|
10
10
|
const {log} = require('log-md')
|
|
11
11
|
|
|
12
|
-
module.exports = function (workingDir, projectName) {
|
|
12
|
+
module.exports = function successfullInstall(workingDir, projectName) {
|
|
13
13
|
const projectPath = path.join(workingDir, projectName)
|
|
14
14
|
const relativePath = path.relative(workingDir, projectPath)
|
|
15
15
|
|
package/create/package.json
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"license": "MIT",
|
|
3
|
-
"private": true,
|
|
4
3
|
"repository": {
|
|
5
4
|
"type": "git",
|
|
6
5
|
"url": "https://github.com/cezaraugusto/extension-create.git",
|
|
@@ -9,7 +8,7 @@
|
|
|
9
8
|
"engines": {
|
|
10
9
|
"node": ">=10"
|
|
11
10
|
},
|
|
12
|
-
"name": "@
|
|
11
|
+
"name": "@extension-create/create",
|
|
13
12
|
"version": "0.0.0",
|
|
14
13
|
"description": "The create step of extension-create",
|
|
15
14
|
"main": "./cli.js",
|
|
@@ -10,7 +10,11 @@ const path = require('path')
|
|
|
10
10
|
const fs = require('fs-extra')
|
|
11
11
|
const {log} = require('log-md')
|
|
12
12
|
|
|
13
|
-
module.exports = async function (
|
|
13
|
+
module.exports = async function abortProjectAndClean(
|
|
14
|
+
error,
|
|
15
|
+
workingDir,
|
|
16
|
+
projectName
|
|
17
|
+
) {
|
|
14
18
|
const projectPath = path.resolve(workingDir, projectName)
|
|
15
19
|
|
|
16
20
|
log('😑👎 Aborting installation.')
|
|
@@ -24,10 +28,9 @@ module.exports = async function (error, workingDir, projectName) {
|
|
|
24
28
|
🚨 Unexpected creation error. This is a bug.
|
|
25
29
|
`)
|
|
26
30
|
log(`Please report: "${error}"`)
|
|
27
|
-
log(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
)
|
|
31
|
+
log('https://github.com/cezaraugusto/extension-create/issues/', {
|
|
32
|
+
gutter: true
|
|
33
|
+
})
|
|
31
34
|
}
|
|
32
35
|
|
|
33
36
|
log('🧹 - Removing files generated from project in:')
|
|
@@ -10,7 +10,7 @@ const {log} = require('log-md')
|
|
|
10
10
|
|
|
11
11
|
const getTemplatePath = require('./getTemplatePath')
|
|
12
12
|
|
|
13
|
-
module.exports = async function (template) {
|
|
13
|
+
module.exports = async function createTemplateFolder(template) {
|
|
14
14
|
// We don't want to delete local templates
|
|
15
15
|
if (!template) {
|
|
16
16
|
return
|
|
@@ -12,16 +12,12 @@ const {log} = require('log-md')
|
|
|
12
12
|
|
|
13
13
|
const messages = require('../messages')
|
|
14
14
|
|
|
15
|
-
const allowlist = [
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
log(
|
|
22
|
-
`👍 Starting a new browser extension named **${projectName}**`,
|
|
23
|
-
{gutter: true}
|
|
24
|
-
)
|
|
15
|
+
const allowlist = ['LICENSE', 'node_modules']
|
|
16
|
+
|
|
17
|
+
module.exports = async function createDirectory(workingDir, projectName) {
|
|
18
|
+
log(`👍 Starting a new browser extension named **${projectName}**`, {
|
|
19
|
+
gutter: true
|
|
20
|
+
})
|
|
25
21
|
const projectPath = path.resolve(workingDir, projectName)
|
|
26
22
|
|
|
27
23
|
log(`🤞 - Checking if \`${workingDir}\` exists...`)
|
|
@@ -31,11 +27,11 @@ module.exports = async function (workingDir, projectName) {
|
|
|
31
27
|
const currentDir = await fs.readdir(projectPath)
|
|
32
28
|
const conflictingFiles = currentDir
|
|
33
29
|
// .gitignore, .DS_Store, etc
|
|
34
|
-
.filter(file => !file.startsWith('.'))
|
|
30
|
+
.filter((file) => !file.startsWith('.'))
|
|
35
31
|
// Logs of yarn/npm
|
|
36
|
-
.filter(file => !file.endsWith('.log'))
|
|
32
|
+
.filter((file) => !file.endsWith('.log'))
|
|
37
33
|
// Whatever we think is appropriate
|
|
38
|
-
.filter(file => !allowlist.includes(file))
|
|
34
|
+
.filter((file) => !allowlist.includes(file))
|
|
39
35
|
|
|
40
36
|
// If directory has conflicting files, abort
|
|
41
37
|
if (conflictingFiles.length) {
|
|
@@ -10,7 +10,7 @@ const path = require('path')
|
|
|
10
10
|
const templatesDir = path.resolve(__dirname, '../templates')
|
|
11
11
|
const templateTempDir = (template) => `__temp__${template}`
|
|
12
12
|
|
|
13
|
-
module.exports = function (template) {
|
|
13
|
+
module.exports = function getTemplatePath(template) {
|
|
14
14
|
let thisTemplate
|
|
15
15
|
|
|
16
16
|
if (template) {
|
|
@@ -13,29 +13,30 @@ const {log} = require('log-md')
|
|
|
13
13
|
|
|
14
14
|
const templatesDir = path.resolve(__dirname, '../templates')
|
|
15
15
|
|
|
16
|
-
module.exports = async function (
|
|
16
|
+
module.exports = async function importExternalTemplate(
|
|
17
|
+
workingDir,
|
|
18
|
+
projectName,
|
|
19
|
+
template
|
|
20
|
+
) {
|
|
17
21
|
const projectPath = path.resolve(workingDir, projectName)
|
|
18
22
|
const templateName = template
|
|
19
23
|
|
|
20
24
|
try {
|
|
21
|
-
const tempTemplatePath = path
|
|
22
|
-
.join(templatesDir, `__temp__${templateName}`)
|
|
25
|
+
const tempTemplatePath = path.join(templatesDir, `__temp__${templateName}`)
|
|
23
26
|
|
|
24
27
|
log(`⚙️ - Importing template \`${template}\` as requested...`)
|
|
25
28
|
const {name, version} = await pacote.manifest(templateName)
|
|
26
29
|
|
|
27
|
-
await pacote
|
|
28
|
-
.extract(`${name}@${version}`, tempTemplatePath)
|
|
30
|
+
await pacote.extract(`${name}@${version}`, tempTemplatePath)
|
|
29
31
|
|
|
30
|
-
log(
|
|
32
|
+
log(`🧰 - Installing **${projectName}** from template \`${templateName}\``)
|
|
31
33
|
const templateDirPath = path.join(tempTemplatePath, 'template')
|
|
32
34
|
|
|
33
35
|
await fs.copy(templateDirPath, projectPath)
|
|
34
36
|
} catch (error) {
|
|
35
|
-
log(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
)
|
|
37
|
+
log(`😕❓ Can't find template __${templateName}__. ${error}`, {
|
|
38
|
+
gutter: true
|
|
39
|
+
})
|
|
39
40
|
process.exit(1)
|
|
40
41
|
}
|
|
41
42
|
}
|
|
@@ -13,10 +13,9 @@ const {log} = require('log-md')
|
|
|
13
13
|
const templatesDir = path.resolve(__dirname, '../templates')
|
|
14
14
|
const defaultTemplate = 'standard'
|
|
15
15
|
|
|
16
|
-
module.exports = async function (workingDir, projectName) {
|
|
16
|
+
module.exports = async function importLocalTemplate(workingDir, projectName) {
|
|
17
17
|
const projectPath = path.resolve(workingDir, projectName)
|
|
18
|
-
const templateDirPath = path
|
|
19
|
-
.join(templatesDir, defaultTemplate, 'template')
|
|
18
|
+
const templateDirPath = path.join(templatesDir, defaultTemplate, 'template')
|
|
20
19
|
|
|
21
20
|
const templateName = path.basename(templateDirPath)
|
|
22
21
|
|
|
@@ -24,10 +23,9 @@ module.exports = async function (workingDir, projectName) {
|
|
|
24
23
|
log(`🧰 - Installing **${projectName}** from standard template...`)
|
|
25
24
|
await fs.copy(templateDirPath, projectPath)
|
|
26
25
|
} catch (error) {
|
|
27
|
-
log(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
)
|
|
26
|
+
log(`😕❓ Can't copy template __${templateName}__: ${error}`, {
|
|
27
|
+
gutter: true
|
|
28
|
+
})
|
|
31
29
|
process.exit(1)
|
|
32
30
|
}
|
|
33
31
|
}
|
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
// ╚═════╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚═╝ ╚══════╝
|
|
7
7
|
|
|
8
8
|
const path = require('path')
|
|
9
|
-
const fs = require('fs-extra')
|
|
10
9
|
|
|
10
|
+
const fs = require('fs-extra')
|
|
11
11
|
const spawn = require('cross-spawn')
|
|
12
12
|
const {log} = require('log-md')
|
|
13
13
|
|
|
14
14
|
const abortProjectAndClean = require('./abortProjectAndClean')
|
|
15
15
|
|
|
16
|
-
module.exports = async function (workingDir, projectName) {
|
|
16
|
+
module.exports = async function installDependencies(workingDir, projectName) {
|
|
17
17
|
const projectPath = path.resolve(workingDir, projectName)
|
|
18
18
|
const projectPackageJson = path.join(projectPath, 'package.json')
|
|
19
19
|
const packageMetadata = require(projectPackageJson)
|
|
@@ -21,10 +21,7 @@ module.exports = async function (workingDir, projectName) {
|
|
|
21
21
|
const dependencies = packageMetadata.dependencies || []
|
|
22
22
|
const devDependencies = packageMetadata.devDependencies || []
|
|
23
23
|
|
|
24
|
-
if (
|
|
25
|
-
dependencies.length === 0 &&
|
|
26
|
-
devDependencies.length === 0
|
|
27
|
-
) {
|
|
24
|
+
if (dependencies.length === 0 && devDependencies.length === 0) {
|
|
28
25
|
log('⏭ - No dependencies. Skipping install step...')
|
|
29
26
|
|
|
30
27
|
return
|
|
@@ -20,16 +20,16 @@ const packageJsonScripts = {
|
|
|
20
20
|
start: 'extension-create start'
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
module.exports = async function (
|
|
23
|
+
module.exports = async function writePackageJson(
|
|
24
|
+
workingDir,
|
|
25
|
+
projectName,
|
|
26
|
+
template
|
|
27
|
+
) {
|
|
24
28
|
const projectPath = path.resolve(workingDir, projectName)
|
|
25
29
|
|
|
26
|
-
const templatePath = path.resolve(
|
|
27
|
-
templatesDir,
|
|
28
|
-
getTemplatePath(template)
|
|
29
|
-
)
|
|
30
|
+
const templatePath = path.resolve(templatesDir, getTemplatePath(template))
|
|
30
31
|
|
|
31
|
-
const templateJsonPath = path
|
|
32
|
-
.resolve(templatePath, 'template.json')
|
|
32
|
+
const templateJsonPath = path.resolve(templatePath, 'template.json')
|
|
33
33
|
|
|
34
34
|
const templateJson = require(templateJsonPath)
|
|
35
35
|
|
|
@@ -3,29 +3,25 @@
|
|
|
3
3
|
"version": "1.0",
|
|
4
4
|
"name": "Welcome Extension",
|
|
5
5
|
"description": "An extension to welcome you!",
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
},
|
|
28
|
-
"chrome_url_overrides": {
|
|
29
|
-
"newtab": "newtab/newtab.html"
|
|
30
|
-
}
|
|
6
|
+
"icons": {
|
|
7
|
+
"16": "public/icon/test_16.png",
|
|
8
|
+
"32": "public/icon/test_32.png",
|
|
9
|
+
"48": "public/icon/test_48.png",
|
|
10
|
+
"64": "public/icon/test_64.png"
|
|
11
|
+
},
|
|
12
|
+
"permissions": ["tabs"],
|
|
13
|
+
"web_accessible_resources": ["public/*"],
|
|
14
|
+
"browser_action": {
|
|
15
|
+
"default_icon": {
|
|
16
|
+
"16": "public/icon/test_16.png",
|
|
17
|
+
"32": "public/icon/test_32.png",
|
|
18
|
+
"48": "public/icon/test_48.png",
|
|
19
|
+
"64": "public/icon/test_64.png"
|
|
20
|
+
},
|
|
21
|
+
"default_popup": "popup/popup.html",
|
|
22
|
+
"default_title": "Welcome Extension"
|
|
23
|
+
},
|
|
24
|
+
"chrome_url_overrides": {
|
|
25
|
+
"newtab": "newtab/newtab.html"
|
|
26
|
+
}
|
|
31
27
|
}
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
<!DOCTYPE html>
|
|
2
2
|
<html lang="en">
|
|
3
3
|
<head>
|
|
4
|
-
<meta charset="UTF-8"
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
5
|
<title>New tab page</title>
|
|
6
|
-
<link rel="preconnect" href="https://fonts.gstatic.com"
|
|
7
|
-
<link
|
|
8
|
-
|
|
6
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" />
|
|
7
|
+
<link
|
|
8
|
+
href="https://fonts.googleapis.com/css2?family=Lato:ital,wght@1,900&display=swap"
|
|
9
|
+
rel="stylesheet"
|
|
10
|
+
/>
|
|
11
|
+
<link rel="stylesheet" href="./styles.css" />
|
|
9
12
|
</head>
|
|
10
13
|
<body>
|
|
11
14
|
<div class="hello-box">
|
|
12
15
|
<header>
|
|
13
|
-
<img src="../public/puzzle.png" alt="A puzzle icon"
|
|
16
|
+
<img src="../public/puzzle.png" alt="A puzzle icon" />
|
|
14
17
|
<h1>Welcome to your extension</h1>
|
|
15
18
|
<p class="description loading">Browser extensions are 🙌🙌🙌</p>
|
|
16
19
|
</header>
|
|
@@ -16,7 +16,8 @@ body {
|
|
|
16
16
|
max-width: 600px;
|
|
17
17
|
padding: 40px;
|
|
18
18
|
margin: auto;
|
|
19
|
-
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
|
|
19
|
+
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
|
|
20
|
+
0 2px 4px -1px rgba(0, 0, 0, 0.06);
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
img {
|
|
@@ -31,7 +32,6 @@ h1 {
|
|
|
31
32
|
color: #00214d;
|
|
32
33
|
}
|
|
33
34
|
|
|
34
|
-
|
|
35
35
|
p {
|
|
36
36
|
font-family: 'Courier New';
|
|
37
37
|
font-size: 1.25rem;
|