extension-create 0.5.2 → 1.0.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 +27 -30
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +252 -0
- package/package.json +51 -38
- package/LICENSE +0 -21
- package/cli.js +0 -40
- package/create/CONTRIBUTING.md +0 -47
- package/create/README.md +0 -53
- package/create/cli.js +0 -58
- package/create/cli.test.js +0 -35
- package/create/createExtension.js +0 -41
- package/create/messages/directoryHasConflicts.js +0 -36
- 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 -43
- package/create/steps/cleanTemplateFolder.js +0 -26
- package/create/steps/createDirectory.js +0 -41
- package/create/steps/getTemplatePath.js +0 -23
- package/create/steps/importExternalTemplate.js +0 -42
- package/create/steps/importLocalTemplate.js +0 -31
- package/create/steps/installDependencies.js +0 -58
- 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 -27
- package/create/templates/standard/template/newtab/newtab.html +0 -27
- 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 -5
- package/create/yarn.lock +0 -4462
- package/develop/CONTRIBUTING.md +0 -47
- package/develop/README.md +0 -53
- package/develop/module.js +0 -16
- package/develop/package-lock.json +0 -7979
- package/develop/package.json +0 -37
- package/develop/start/cli.js +0 -47
- package/develop/start/cli.test.js +0 -43
- package/develop/start/config/browserSwitch.js +0 -31
- package/develop/start/config/compiler.js +0 -31
- 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 -72
- package/develop/start/steps/resolveManifest.js +0 -44
- package/develop/start/steps/startWebpack.js +0 -49
- package/develop/yarn.lock +0 -6908
- package/messages.js +0 -57
- package/preinstall.sh +0 -10
- package/reservedKeywords.js +0 -17
package/develop/package.json
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"license": "MIT",
|
|
3
|
-
"repository": {
|
|
4
|
-
"type": "git",
|
|
5
|
-
"url": "https://github.com/cezaraugusto/extension-create.git",
|
|
6
|
-
"directory": "develop"
|
|
7
|
-
},
|
|
8
|
-
"engines": {
|
|
9
|
-
"node": ">=10"
|
|
10
|
-
},
|
|
11
|
-
"name": "@extension-create/develop",
|
|
12
|
-
"version": "0.0.0",
|
|
13
|
-
"description": "The develop step of extension-create",
|
|
14
|
-
"main": "./module.js",
|
|
15
|
-
"bin": "./module.js",
|
|
16
|
-
"author": "Cezar Augusto <boss@cezaraugusto.net> (https://twitter.com/cezaraugusto)",
|
|
17
|
-
"scripts": {
|
|
18
|
-
"dev:start": "node ./module.js",
|
|
19
|
-
"test": "jest"
|
|
20
|
-
},
|
|
21
|
-
"dependencies": {
|
|
22
|
-
"commander": "^6.2.0",
|
|
23
|
-
"fs-extra": "^9.0.1",
|
|
24
|
-
"go-git-it": "github:cezaraugusto/go-git-it#174168d12a31791a08c777b92650f98470d45674",
|
|
25
|
-
"log-md": "^0.2.0",
|
|
26
|
-
"semver": "^7.3.2",
|
|
27
|
-
"webpack": "^5.6.0",
|
|
28
|
-
"webpack-cli": "^4.1.0",
|
|
29
|
-
"webpack-dev-server": "^3.11.0",
|
|
30
|
-
"webpack-run-chrome-extension": "^0.3.0",
|
|
31
|
-
"webpack-run-edge-extension": "^0.3.0"
|
|
32
|
-
},
|
|
33
|
-
"devDependencies": {
|
|
34
|
-
"cross-spawn": "^7.0.3",
|
|
35
|
-
"jest": "^26.6.1"
|
|
36
|
-
}
|
|
37
|
-
}
|
package/develop/start/cli.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
// ███████╗████████╗ █████╗ ██████╗ ████████╗
|
|
2
|
-
// ██╔════╝╚══██╔══╝██╔══██╗██╔══██╗╚══██╔══╝
|
|
3
|
-
// ███████╗ ██║ ███████║██████╔╝ ██║
|
|
4
|
-
// ╚════██║ ██║ ██╔══██║██╔══██╗ ██║
|
|
5
|
-
// ███████║ ██║ ██║ ██║██║ ██║ ██║
|
|
6
|
-
// ╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝
|
|
7
|
-
|
|
8
|
-
const {program} = require('commander')
|
|
9
|
-
|
|
10
|
-
const startExtension = require('./startExtension')
|
|
11
|
-
const messages = require('./messages')
|
|
12
|
-
const packageJson = require('../package.json')
|
|
13
|
-
|
|
14
|
-
let browserVendor
|
|
15
|
-
|
|
16
|
-
function startExtensionCLI(clientProgram = program) {
|
|
17
|
-
clientProgram
|
|
18
|
-
.version(packageJson.version)
|
|
19
|
-
.command('start')
|
|
20
|
-
.usage('start [path-to-extension-folder] [options]')
|
|
21
|
-
.action((cmd) => {
|
|
22
|
-
const {browser} = cmd
|
|
23
|
-
|
|
24
|
-
browserVendor = browser
|
|
25
|
-
})
|
|
26
|
-
.description('start the development server')
|
|
27
|
-
.option(
|
|
28
|
-
'-b, --browser <browser-vendor>',
|
|
29
|
-
'specify a browser to run your extension'
|
|
30
|
-
)
|
|
31
|
-
.on('--help', () => messages.programHelp())
|
|
32
|
-
.parse(process.argv)
|
|
33
|
-
|
|
34
|
-
const projectDir = process.cwd()
|
|
35
|
-
const commands = clientProgram.commands[0]
|
|
36
|
-
const customPath = commands.args[1] || ''
|
|
37
|
-
|
|
38
|
-
startExtension(projectDir, {customPath, browserVendor})
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// If the module was called from the cmd line, execute it
|
|
42
|
-
if (require.main === module) {
|
|
43
|
-
startExtensionCLI()
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// Export as a module so it can be reused
|
|
47
|
-
module.exports = startExtensionCLI
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/* global describe, it */
|
|
2
|
-
const path = require('path')
|
|
3
|
-
|
|
4
|
-
const fs = require('fs-extra')
|
|
5
|
-
|
|
6
|
-
const boringManifestFile = {
|
|
7
|
-
manifest_version: 2,
|
|
8
|
-
name: 'Your browser extension',
|
|
9
|
-
version: '1.0',
|
|
10
|
-
background: {
|
|
11
|
-
scripts: ['./background.js']
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/* eslint-disable no-unused-vars */
|
|
16
|
-
async function createTmpExtension() {
|
|
17
|
-
// Write a fake bg script
|
|
18
|
-
await fs.writeFile(
|
|
19
|
-
path.join(process.cwd(), 'background.js'),
|
|
20
|
-
'console.log("hello")'
|
|
21
|
-
)
|
|
22
|
-
// Write a fake manifest file
|
|
23
|
-
await fs.writeFile(
|
|
24
|
-
path.join(process.cwd(), 'manifest.json'),
|
|
25
|
-
JSON.stringify(boringManifestFile)
|
|
26
|
-
)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
describe('`start` command line interface', () => {
|
|
30
|
-
it.todo('starts extension from local path with arguments')
|
|
31
|
-
it.todo('starts extension from local path without arguments')
|
|
32
|
-
it.todo('starts extension from local path - manifest in src/')
|
|
33
|
-
it.todo('starts extension from local path - manifest in public/')
|
|
34
|
-
it.todo('starts extension from remote (URL) path')
|
|
35
|
-
it.todo('starts extension from remote (URL) path - manifest in src/')
|
|
36
|
-
it.todo('starts extension from remote (URL) path - manifest in public/')
|
|
37
|
-
describe('--browser flag', () => {
|
|
38
|
-
it.todo('accepts and starts `chrome` as flag')
|
|
39
|
-
it.todo('accepts and starts `edge` as flag')
|
|
40
|
-
it.todo('accepts and `all` browsers as flag')
|
|
41
|
-
it.todo('accepts and starts chrome as default')
|
|
42
|
-
})
|
|
43
|
-
})
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
const RunChromeExtension = require('webpack-run-chrome-extension')
|
|
2
|
-
const RunEdgeExtension = require('webpack-run-edge-extension')
|
|
3
|
-
|
|
4
|
-
module.exports = function browserSwitch(projectDir, browserVendor) {
|
|
5
|
-
switch (browserVendor) {
|
|
6
|
-
case 'chrome':
|
|
7
|
-
return new RunChromeExtension({extensionPath: projectDir})
|
|
8
|
-
|
|
9
|
-
case 'edge':
|
|
10
|
-
return new RunEdgeExtension({extensionPath: projectDir})
|
|
11
|
-
|
|
12
|
-
case 'all':
|
|
13
|
-
return {
|
|
14
|
-
apply: (compiler) => {
|
|
15
|
-
new RunChromeExtension({
|
|
16
|
-
extensionPath: projectDir,
|
|
17
|
-
port: 8081
|
|
18
|
-
}).apply(compiler)
|
|
19
|
-
|
|
20
|
-
new RunEdgeExtension({
|
|
21
|
-
extensionPath: projectDir,
|
|
22
|
-
port: 8082
|
|
23
|
-
}).apply(compiler)
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
default:
|
|
28
|
-
// TODO: Should be the user default browser, not Chrome
|
|
29
|
-
return new RunChromeExtension({extensionPath: projectDir})
|
|
30
|
-
}
|
|
31
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
// ███████╗████████╗ █████╗ ██████╗ ████████╗
|
|
2
|
-
// ██╔════╝╚══██╔══╝██╔══██╗██╔══██╗╚══██╔══╝
|
|
3
|
-
// ███████╗ ██║ ███████║██████╔╝ ██║
|
|
4
|
-
// ╚════██║ ██║ ██╔══██║██╔══██╗ ██║
|
|
5
|
-
// ███████║ ██║ ██║ ██║██║ ██║ ██║
|
|
6
|
-
// ╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝
|
|
7
|
-
|
|
8
|
-
const browserSwitch = require('./browserSwitch')
|
|
9
|
-
|
|
10
|
-
process.on('unhandledRejection', (error) => {
|
|
11
|
-
throw error
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
module.exports = (projectDir, {browserVendor}) => {
|
|
15
|
-
const config = {
|
|
16
|
-
mode: 'development',
|
|
17
|
-
// https://github.com/webpack/webpack/issues/2145
|
|
18
|
-
devtool: 'inline-cheap-module-source-map',
|
|
19
|
-
plugins: [
|
|
20
|
-
// Browser lists loaded conditionally based on user choice
|
|
21
|
-
browserSwitch(projectDir, browserVendor)
|
|
22
|
-
],
|
|
23
|
-
resolve: {
|
|
24
|
-
extensions: ['js', '.json']
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return {
|
|
29
|
-
...config
|
|
30
|
-
}
|
|
31
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
// ███████╗████████╗ █████╗ ██████╗ ████████╗
|
|
2
|
-
// ██╔════╝╚══██╔══╝██╔══██╗██╔══██╗╚══██╔══╝
|
|
3
|
-
// ███████╗ ██║ ███████║██████╔╝ ██║
|
|
4
|
-
// ╚════██║ ██║ ██╔══██║██╔══██╗ ██║
|
|
5
|
-
// ███████║ ██║ ██║ ██║██║ ██║ ██║
|
|
6
|
-
// ╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝
|
|
7
|
-
|
|
8
|
-
module.exports = {
|
|
9
|
-
clientLogLevel: 'none',
|
|
10
|
-
compress: true,
|
|
11
|
-
overlay: true,
|
|
12
|
-
quiet: true,
|
|
13
|
-
watchContentBase: true,
|
|
14
|
-
watchOptions: {
|
|
15
|
-
ignored: 'node_modules'
|
|
16
|
-
}
|
|
17
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
// ███████╗████████╗ █████╗ ██████╗ ████████╗
|
|
2
|
-
// ██╔════╝╚══██╔══╝██╔══██╗██╔══██╗╚══██╔══╝
|
|
3
|
-
// ███████╗ ██║ ███████║██████╔╝ ██║
|
|
4
|
-
// ╚════██║ ██║ ██╔══██║██╔══██╗ ██║
|
|
5
|
-
// ███████║ ██║ ██║ ██║██║ ██║ ██║
|
|
6
|
-
// ╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝
|
|
7
|
-
|
|
8
|
-
const manifestNotFound = require('./manifestNotFound')
|
|
9
|
-
const programHelp = require('./programHelp')
|
|
10
|
-
|
|
11
|
-
module.exports = {
|
|
12
|
-
manifestNotFound,
|
|
13
|
-
programHelp
|
|
14
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
// ███████╗████████╗ █████╗ ██████╗ ████████╗
|
|
2
|
-
// ██╔════╝╚══██╔══╝██╔══██╗██╔══██╗╚══██╔══╝
|
|
3
|
-
// ███████╗ ██║ ███████║██████╔╝ ██║
|
|
4
|
-
// ╚════██║ ██║ ██╔══██║██╔══██╗ ██║
|
|
5
|
-
// ███████║ ██║ ██║ ██║██║ ██║ ██║
|
|
6
|
-
// ╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝
|
|
7
|
-
|
|
8
|
-
const {log} = require('log-md')
|
|
9
|
-
|
|
10
|
-
module.exports = function manifestNotFound() {
|
|
11
|
-
log(`
|
|
12
|
-
# Error! Can't find the project's manifest file.
|
|
13
|
-
|
|
14
|
-
By default, extension-create scans the root folder and the paths to
|
|
15
|
-
\`src/\`, and \`public/\` looking for a manifest file, but none was found.
|
|
16
|
-
|
|
17
|
-
The argument after \`start\` needs to point to a folder where the
|
|
18
|
-
manifest is available within one of the paths above.
|
|
19
|
-
|
|
20
|
-
\`extension-create start\` <path-to-extension-folder>
|
|
21
|
-
`)
|
|
22
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
// ███████╗████████╗ █████╗ ██████╗ ████████╗
|
|
2
|
-
// ██╔════╝╚══██╔══╝██╔══██╗██╔══██╗╚══██╔══╝
|
|
3
|
-
// ███████╗ ██║ ███████║██████╔╝ ██║
|
|
4
|
-
// ╚════██║ ██║ ██╔══██║██╔══██╗ ██║
|
|
5
|
-
// ███████║ ██║ ██║ ██║██║ ██║ ██║
|
|
6
|
-
// ╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝
|
|
7
|
-
|
|
8
|
-
const {log} = require('log-md')
|
|
9
|
-
|
|
10
|
-
module.exports = function programHelp() {
|
|
11
|
-
log(`
|
|
12
|
-
# Help center for the \`start\` command
|
|
13
|
-
|
|
14
|
-
## The \`--remote\` _<github-url>_ flag
|
|
15
|
-
|
|
16
|
-
If you want to get up and running with an existing extension
|
|
17
|
-
available remotely on GitHub, you can specify its path as an
|
|
18
|
-
argument to the \`--remote\` flag.
|
|
19
|
-
|
|
20
|
-
The path can be any GitHub URL subdirectory. If a GitHub URL is provided,
|
|
21
|
-
the directory is downloaded to the current working directory.
|
|
22
|
-
|
|
23
|
-
For example:
|
|
24
|
-
|
|
25
|
-
\`extension-create start --remote https://github.com/user/repo/\`
|
|
26
|
-
will download \`repo\` in the current working directory and
|
|
27
|
-
kick off a new browser instance with \`repo\` loaded as an extension.
|
|
28
|
-
|
|
29
|
-
Works with subdirectories as well, like https://github.com/user/repo/subdirs
|
|
30
|
-
|
|
31
|
-
## The \`--manifest\` _<github-url>_ flag
|
|
32
|
-
|
|
33
|
-
You can specify a custom path to your manifest file. By default
|
|
34
|
-
\`extension-create\` will look for your project's root
|
|
35
|
-
path and **public/** directory, failing if no manifest is found.
|
|
36
|
-
|
|
37
|
-
## The \`--browser\` _<browser-vendor>_ flag
|
|
38
|
-
|
|
39
|
-
A browser vendor name can be provided to run your extension on a specific browser.
|
|
40
|
-
One of:
|
|
41
|
-
|
|
42
|
-
- \`--browser\`=chrome (default)
|
|
43
|
-
- \`--browser\`=edge
|
|
44
|
-
- \`--browser\`=all (runs all available browsers)
|
|
45
|
-
|
|
46
|
-
Feels something is wrong? Help by reporting a bug:
|
|
47
|
-
https://github.com/cezaraugusto/extension-create/issues/new
|
|
48
|
-
`)
|
|
49
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
// ███████╗████████╗ █████╗ ██████╗ ████████╗
|
|
2
|
-
// ██╔════╝╚══██╔══╝██╔══██╗██╔══██╗╚══██╔══╝
|
|
3
|
-
// ███████╗ ██║ ███████║██████╔╝ ██║
|
|
4
|
-
// ╚════██║ ██║ ██╔══██║██╔══██╗ ██║
|
|
5
|
-
// ███████║ ██║ ██║ ██║██║ ██║ ██║
|
|
6
|
-
// ╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝
|
|
7
|
-
|
|
8
|
-
const path = require('path')
|
|
9
|
-
|
|
10
|
-
const fs = require('fs-extra')
|
|
11
|
-
|
|
12
|
-
const message = require('../messages')
|
|
13
|
-
|
|
14
|
-
module.exports = async function resolveExtensionPath(workingDir, manifestFile) {
|
|
15
|
-
// Defaults to user-defined path
|
|
16
|
-
let manifestFilePath = manifestFile
|
|
17
|
-
|
|
18
|
-
try {
|
|
19
|
-
// Try manifest path provided by user
|
|
20
|
-
await fs.access(manifestFilePath)
|
|
21
|
-
|
|
22
|
-
return manifestFilePath
|
|
23
|
-
} catch (error) {
|
|
24
|
-
try {
|
|
25
|
-
// User didn't provide a manifest file, check in public/
|
|
26
|
-
manifestFilePath = path.join(workingDir, 'public', 'manifest.json')
|
|
27
|
-
await fs.access(manifestFilePath)
|
|
28
|
-
|
|
29
|
-
return manifestFilePath
|
|
30
|
-
} catch (error) {
|
|
31
|
-
try {
|
|
32
|
-
// Nothing found in public/, try the root directory
|
|
33
|
-
manifestFilePath = path.join(workingDir, 'manifest.json')
|
|
34
|
-
await fs.access(manifestFilePath)
|
|
35
|
-
|
|
36
|
-
return manifestFilePath
|
|
37
|
-
} catch (error) {
|
|
38
|
-
// Nothing found neither in public/ or path, and user did not
|
|
39
|
-
// provide a --manifest option. Manifests are required so we exit.
|
|
40
|
-
message.manifestNotFound()
|
|
41
|
-
process.exit(1)
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
// ███████╗████████╗ █████╗ ██████╗ ████████╗
|
|
2
|
-
// ██╔════╝╚══██╔══╝██╔══██╗██╔══██╗╚══██╔══╝
|
|
3
|
-
// ███████╗ ██║ ███████║██████╔╝ ██║
|
|
4
|
-
// ╚════██║ ██║ ██╔══██║██╔══██╗ ██║
|
|
5
|
-
// ███████║ ██║ ██║ ██║██║ ██║ ██║
|
|
6
|
-
// ╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝
|
|
7
|
-
|
|
8
|
-
const path = require('path')
|
|
9
|
-
|
|
10
|
-
const fs = require('fs-extra')
|
|
11
|
-
const {log} = require('log-md')
|
|
12
|
-
const goGitIt = require('go-git-it')
|
|
13
|
-
|
|
14
|
-
const resoleManifest = require('./steps/resolveManifest')
|
|
15
|
-
const startWebpack = require('./steps/startWebpack')
|
|
16
|
-
|
|
17
|
-
function setWorkingDirFromRemote(workingDir, customPath) {
|
|
18
|
-
if (new URL(customPath).hostname !== 'github.com') {
|
|
19
|
-
log(`
|
|
20
|
-
The remote extension URL must be stored on GitHub.
|
|
21
|
-
`)
|
|
22
|
-
process.exit(1)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
goGitIt(customPath)
|
|
26
|
-
|
|
27
|
-
return path.join(workingDir, path.basename(customPath))
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
async function setWorkingDirFromLocal(workingDir, customPath) {
|
|
31
|
-
const currentPath = path.resolve(workingDir, customPath)
|
|
32
|
-
const extensionPath = await fs.stat(currentPath)
|
|
33
|
-
|
|
34
|
-
if (!extensionPath.isDirectory()) {
|
|
35
|
-
log(`
|
|
36
|
-
The local extension path must be a directory.
|
|
37
|
-
`)
|
|
38
|
-
process.exit(1)
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return currentPath
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
module.exports = async function startExtension(
|
|
45
|
-
workingDir,
|
|
46
|
-
{customPath, browserVendor}
|
|
47
|
-
) {
|
|
48
|
-
let currentworkingDir
|
|
49
|
-
|
|
50
|
-
try {
|
|
51
|
-
if (!customPath) {
|
|
52
|
-
// No user arguments, default to cwd
|
|
53
|
-
currentworkingDir = workingDir
|
|
54
|
-
} else if (customPath.startsWith('http')) {
|
|
55
|
-
currentworkingDir = setWorkingDirFromRemote(workingDir, customPath)
|
|
56
|
-
} else {
|
|
57
|
-
currentworkingDir = await setWorkingDirFromLocal(workingDir, customPath)
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const resolvedManifest = await resoleManifest(currentworkingDir)
|
|
61
|
-
|
|
62
|
-
startWebpack(currentworkingDir, {
|
|
63
|
-
manifestPath: resolvedManifest,
|
|
64
|
-
browserVendor
|
|
65
|
-
})
|
|
66
|
-
} catch (error) {
|
|
67
|
-
log(`
|
|
68
|
-
Error while starting the extension: ${error}
|
|
69
|
-
`)
|
|
70
|
-
process.exit(1)
|
|
71
|
-
}
|
|
72
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
// ███████╗████████╗ █████╗ ██████╗ ████████╗
|
|
2
|
-
// ██╔════╝╚══██╔══╝██╔══██╗██╔══██╗╚══██╔══╝
|
|
3
|
-
// ███████╗ ██║ ███████║██████╔╝ ██║
|
|
4
|
-
// ╚════██║ ██║ ██╔══██║██╔══██╗ ██║
|
|
5
|
-
// ███████║ ██║ ██║ ██║██║ ██║ ██║
|
|
6
|
-
// ╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝
|
|
7
|
-
|
|
8
|
-
const path = require('path')
|
|
9
|
-
|
|
10
|
-
const fs = require('fs-extra')
|
|
11
|
-
|
|
12
|
-
const message = require('../messages')
|
|
13
|
-
|
|
14
|
-
module.exports = async function resolveManifest(workingDir) {
|
|
15
|
-
let manifestFilePath
|
|
16
|
-
|
|
17
|
-
// Iterate over common paths looking for the manifest file.
|
|
18
|
-
try {
|
|
19
|
-
// Start from usual suspects, check src/
|
|
20
|
-
await fs.access(path.join(workingDir, 'src', 'manifest.json'))
|
|
21
|
-
|
|
22
|
-
return manifestFilePath
|
|
23
|
-
} catch (error) {
|
|
24
|
-
try {
|
|
25
|
-
// Check in public/
|
|
26
|
-
manifestFilePath = path.join(workingDir, 'public', 'manifest.json')
|
|
27
|
-
await fs.access(manifestFilePath)
|
|
28
|
-
|
|
29
|
-
return manifestFilePath
|
|
30
|
-
} catch (error) {
|
|
31
|
-
try {
|
|
32
|
-
// Check the root directory
|
|
33
|
-
manifestFilePath = path.join(workingDir, 'manifest.json')
|
|
34
|
-
await fs.access(manifestFilePath)
|
|
35
|
-
|
|
36
|
-
return manifestFilePath
|
|
37
|
-
} catch (error) {
|
|
38
|
-
// Nothing found. Manifests are required so we exit.
|
|
39
|
-
message.manifestNotFound()
|
|
40
|
-
process.exit(1)
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
// ███████╗████████╗ █████╗ ██████╗ ████████╗
|
|
2
|
-
// ██╔════╝╚══██╔══╝██╔══██╗██╔══██╗╚══██╔══╝
|
|
3
|
-
// ███████╗ ██║ ███████║██████╔╝ ██║
|
|
4
|
-
// ╚════██║ ██║ ██╔══██║██╔══██╗ ██║
|
|
5
|
-
// ███████║ ██║ ██║ ██║██║ ██║ ██║
|
|
6
|
-
// ╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝
|
|
7
|
-
|
|
8
|
-
const path = require('path')
|
|
9
|
-
|
|
10
|
-
const webpack = require('webpack')
|
|
11
|
-
const {log} = require('log-md')
|
|
12
|
-
const WebpackDevServer = require('webpack-dev-server')
|
|
13
|
-
|
|
14
|
-
const compilerConfig = require('../config/compiler')
|
|
15
|
-
const serverConfig = require('../config/server')
|
|
16
|
-
|
|
17
|
-
function closeAll(devServer) {
|
|
18
|
-
devServer.close()
|
|
19
|
-
process.exit()
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
module.exports = function startWebpack(
|
|
23
|
-
projectDir,
|
|
24
|
-
{manifestPath, browserVendor}
|
|
25
|
-
) {
|
|
26
|
-
const serverOptions = {
|
|
27
|
-
// Tell the server where to serve content from
|
|
28
|
-
contentBase: path.dirname(manifestPath)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const webpackConfig = compilerConfig(projectDir, {
|
|
32
|
-
manifestPath,
|
|
33
|
-
browserVendor
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
const compiler = webpack(webpackConfig)
|
|
37
|
-
const server = {...serverConfig, ...serverOptions}
|
|
38
|
-
const devServer = new WebpackDevServer(compiler, server)
|
|
39
|
-
|
|
40
|
-
const PORT = 3001
|
|
41
|
-
const HOST = '127.0.0.1'
|
|
42
|
-
|
|
43
|
-
devServer.listen(PORT, HOST, (error) => {
|
|
44
|
-
if (error) return log(`Error in the extension runner: ${error}`)
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
process.on('SIGINT', () => closeAll(devServer))
|
|
48
|
-
process.on('SIGTERM', () => closeAll(devServer))
|
|
49
|
-
}
|