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.
Files changed (63) hide show
  1. package/README.md +29 -30
  2. package/dist/cli.d.ts +1 -0
  3. package/dist/cli.js +252 -0
  4. package/package.json +51 -36
  5. package/LICENSE +0 -21
  6. package/cli.js +0 -40
  7. package/create/CONTRIBUTING.md +0 -47
  8. package/create/README.md +0 -55
  9. package/create/cli.js +0 -58
  10. package/create/cli.test.js +0 -37
  11. package/create/createExtension.js +0 -35
  12. package/create/messages/directoryHasConflicts.js +0 -38
  13. package/create/messages/index.js +0 -16
  14. package/create/messages/programHelp.js +0 -26
  15. package/create/messages/successfullInstall.js +0 -24
  16. package/create/package.json +0 -38
  17. package/create/steps/abortProjectAndClean.js +0 -40
  18. package/create/steps/cleanTemplateFolder.js +0 -26
  19. package/create/steps/createDirectory.js +0 -45
  20. package/create/steps/getTemplatePath.js +0 -23
  21. package/create/steps/importExternalTemplate.js +0 -41
  22. package/create/steps/importLocalTemplate.js +0 -33
  23. package/create/steps/installDependencies.js +0 -61
  24. package/create/steps/writePackageJson.js +0 -64
  25. package/create/templates/standard/.gitignore +0 -21
  26. package/create/templates/standard/README.md +0 -14
  27. package/create/templates/standard/package.json +0 -26
  28. package/create/templates/standard/template/.gitignore +0 -21
  29. package/create/templates/standard/template/README.md +0 -0
  30. package/create/templates/standard/template/manifest.json +0 -31
  31. package/create/templates/standard/template/newtab/newtab.html +0 -24
  32. package/create/templates/standard/template/newtab/newtab.js +0 -1
  33. package/create/templates/standard/template/newtab/styles.css +0 -43
  34. package/create/templates/standard/template/popup/popup.css +0 -26
  35. package/create/templates/standard/template/popup/popup.html +0 -15
  36. package/create/templates/standard/template/popup/popup.js +0 -1
  37. package/create/templates/standard/template/public/icon/test_16.png +0 -0
  38. package/create/templates/standard/template/public/icon/test_32.png +0 -0
  39. package/create/templates/standard/template/public/icon/test_48.png +0 -0
  40. package/create/templates/standard/template/public/icon/test_64.png +0 -0
  41. package/create/templates/standard/template/public/puzzle.png +0 -0
  42. package/create/templates/standard/template.json +0 -6
  43. package/create/yarn.lock +0 -4462
  44. package/develop/CONTRIBUTING.md +0 -47
  45. package/develop/README.md +0 -55
  46. package/develop/module.js +0 -16
  47. package/develop/package.json +0 -44
  48. package/develop/start/cli.js +0 -47
  49. package/develop/start/cli.test.js +0 -45
  50. package/develop/start/config/browserSwitch.js +0 -31
  51. package/develop/start/config/compiler.js +0 -47
  52. package/develop/start/config/server.js +0 -17
  53. package/develop/start/messages/index.js +0 -14
  54. package/develop/start/messages/manifestNotFound.js +0 -22
  55. package/develop/start/messages/programHelp.js +0 -49
  56. package/develop/start/resolve/resolveExtensionPath.js +0 -45
  57. package/develop/start/startExtension.js +0 -69
  58. package/develop/start/steps/resolveManifest.js +0 -44
  59. package/develop/start/steps/startWebpack.js +0 -46
  60. package/develop/yarn.lock +0 -7165
  61. package/messages.js +0 -57
  62. package/preinstall.sh +0 -2
  63. package/reservedKeywords.js +0 -17
@@ -1,47 +0,0 @@
1
- # Contributing to @webextension/start
2
-
3
- ## Getting started
4
-
5
- ```
6
- git clone git@github.com:cezaraugusto/extension-create.git
7
- cd extension-create/develop/start
8
- yarn install
9
- ```
10
-
11
- ## Creating an extension
12
-
13
- `yarn dev:start my-hello-extension` is equivalent of running `npx @webextension/start 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/develop/README.md DELETED
@@ -1,55 +0,0 @@
1
- # @extension-create/develop
2
-
3
- > The `start` part of `extension-create` available as a standalone package.
4
-
5
- This package stores all logic needed by `extension-create` to start new projects.
6
-
7
- ## Installation
8
-
9
- ```
10
- npm i @extension-create/develop
11
- ```
12
-
13
- ## Usage
14
-
15
- There are two ways of using it:
16
-
17
- ### Standalone Executable
18
-
19
- ```
20
- # Will start a new browser instance with my-extension-hello loaded.
21
- npx @extension-create/start 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/start` to extend you CLI. This is what `extension-create` does.
27
-
28
- ```js
29
- const {program} = require('commander')
30
- const startExtensionCLI = require('@extension-create/start')
31
-
32
- const yourCreateProgram = program
33
-
34
- yourCreateProgram
35
- .version(packageJson.version)
36
-
37
- startExtensionCLI(yourCreateProgram)
38
-
39
- yourCreateProgram
40
- .parse(process.argv)
41
- ```
42
-
43
- ## Program options table
44
-
45
- | Flag | Argument | What it does |
46
- |------------------|----------------------------------------------------------|--------------|
47
- | -m, --manifest | file path | Specify a custom path for your extensions's manifest file |
48
-
49
- ## Contributing
50
-
51
- See [CONTRIBUTING.md](CONTRIBUTING.md)
52
-
53
- ## License
54
-
55
- MIT (c) Cezar Augusto.
package/develop/module.js DELETED
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // ██████╗ ███████╗██╗ ██╗███████╗██╗ ██████╗ ██████╗
4
- // ██╔══██╗██╔════╝██║ ██║██╔════╝██║ ██╔═══██╗██╔══██╗
5
- // ██║ ██║█████╗ ██║ ██║█████╗ ██║ ██║ ██║██████╔╝
6
- // ██║ ██║██╔══╝ ╚██╗ ██╔╝██╔══╝ ██║ ██║ ██║██╔═══╝
7
- // ██████╔╝███████╗ ╚████╔╝ ███████╗███████╗╚██████╔╝██║
8
- // ╚═════╝ ╚══════╝ ╚═══╝ ╚══════╝╚══════╝ ╚═════╝ ╚═╝
9
-
10
- const {program} = require('commander')
11
-
12
- const startCLI = require('./start/cli')
13
-
14
- module.exports = function (clientProgram = program) {
15
- startCLI(clientProgram)
16
- }
@@ -1,44 +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
- "@rbarilani/remove-source-map-url-webpack-plugin": "^0.1.0",
23
- "chrome-launcher": "^0.13.4",
24
- "commander": "^6.2.0",
25
- "copy-webpack-plugin": "^6.2.1",
26
- "fs-extra": "^9.0.1",
27
- "go-git-it": "github:cezaraugusto/go-git-it#174168d12a31791a08c777b92650f98470d45674",
28
- "log-md": "^0.2.0",
29
- "semver": "^7.3.2",
30
- "string-replace-loader": "^2.3.0",
31
- "symlink-dir": "^4.1.0",
32
- "webextension-polyfill": "^0.6.0",
33
- "webpack": "^5.6.0",
34
- "webpack-cli": "^4.1.0",
35
- "webpack-dev-server": "^3.11.0",
36
- "webpack-resolve-background-script": "^1.0.0",
37
- "webpack-run-chrome-extension": "^0.3.0",
38
- "webpack-run-edge-extension": "^0.3.0"
39
- },
40
- "devDependencies": {
41
- "cross-spawn": "^7.0.3",
42
- "jest": "^26.6.1"
43
- }
44
- }
@@ -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,45 +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: [
12
- './background.js'
13
- ]
14
- }
15
- }
16
-
17
- /* eslint-disable no-unused-vars */
18
- async function createTmpExtension () {
19
- // Write a fake bg script
20
- await fs.writeFile(
21
- path.join(process.cwd(), 'background.js'),
22
- 'console.log("hello")'
23
- )
24
- // Write a fake manifest file
25
- await fs.writeFile(
26
- path.join(process.cwd(), 'manifest.json'),
27
- JSON.stringify(boringManifestFile)
28
- )
29
- }
30
-
31
- describe('`start` command line interface', () => {
32
- it.todo('starts extension from local path with arguments')
33
- it.todo('starts extension from local path without arguments')
34
- it.todo('starts extension from local path - manifest in src/')
35
- it.todo('starts extension from local path - manifest in public/')
36
- it.todo('starts extension from remote (URL) path')
37
- it.todo('starts extension from remote (URL) path - manifest in src/')
38
- it.todo('starts extension from remote (URL) path - manifest in public/')
39
- describe('--browser flag', () => {
40
- it.todo('accepts and starts `chrome` as flag')
41
- it.todo('accepts and starts `edge` as flag')
42
- it.todo('accepts and `all` browsers as flag')
43
- it.todo('accepts and starts chrome as default')
44
- })
45
- })
@@ -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 (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,47 +0,0 @@
1
- // ███████╗████████╗ █████╗ ██████╗ ████████╗
2
- // ██╔════╝╚══██╔══╝██╔══██╗██╔══██╗╚══██╔══╝
3
- // ███████╗ ██║ ███████║██████╔╝ ██║
4
- // ╚════██║ ██║ ██╔══██║██╔══██╗ ██║
5
- // ███████║ ██║ ██║ ██║██║ ██║ ██║
6
- // ╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝
7
-
8
- const webpack = require('webpack')
9
-
10
- const browserSwitch = require('./browserSwitch')
11
-
12
- process.on('unhandledRejection', (error) => { throw error })
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
- // Polyfill `browser` namespace for unspported browsers (FF).
21
- // TODO: Do not add this plugin when developing for those vendors
22
- new webpack.ProvidePlugin({browser: require.resolve('webextension-polyfill')}),
23
- // Browser lists loaded conditionally based on user choice
24
- browserSwitch(projectDir, browserVendor)
25
- ],
26
- resolve: {
27
- extensions: ['js', '.json']
28
- },
29
- module: {
30
- // Adapted from
31
- // https://github.com/webextension-toolbox/webextension-toolbox
32
- // Relased under MIT license. Copyright 2018 Henrik Wenz
33
- rules: [{
34
- test: /webextension-polyfill[\\/]+dist[\\/]+browser-polyfill\.js$/,
35
- loader: require.resolve('string-replace-loader'),
36
- options: {
37
- search: 'typeof browser === "undefined"',
38
- replace: 'typeof window.browser === "undefined" || Object.getPrototypeOf(window.browser) !== Object.prototype'
39
- }
40
- }]
41
- }
42
- }
43
-
44
- return {
45
- ...config
46
- }
47
- }
@@ -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 () {
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 () {
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 (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,69 +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 (workingDir, {customPath, browserVendor}) {
45
- let currentworkingDir
46
-
47
- try {
48
- if (!customPath) {
49
- // No user arguments, default to cwd
50
- currentworkingDir = workingDir
51
- } else if (customPath.startsWith('http')) {
52
- currentworkingDir = setWorkingDirFromRemote(workingDir, customPath)
53
- } else {
54
- currentworkingDir = await setWorkingDirFromLocal(workingDir, customPath)
55
- }
56
-
57
- const resolvedManifest = await resoleManifest(currentworkingDir)
58
-
59
- startWebpack(currentworkingDir, {
60
- manifestPath: resolvedManifest,
61
- browserVendor
62
- })
63
- } catch (error) {
64
- log(`
65
- Error while starting the extension: ${error}
66
- `)
67
- process.exit(1)
68
- }
69
- }
@@ -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 (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,46 +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.js')
15
- const serverConfig = require('../config/server.js')
16
-
17
- function closeAll (devServer) {
18
- devServer.close()
19
- process.exit()
20
- }
21
-
22
- module.exports = function (projectDir, {manifestPath, browserVendor}) {
23
- const serverOptions = {
24
- // Tell the server where to serve content from
25
- contentBase: path.dirname(manifestPath)
26
- }
27
-
28
- const webpackConfig = compilerConfig(projectDir, {
29
- manifestPath,
30
- browserVendor
31
- })
32
-
33
- const compiler = webpack(webpackConfig)
34
- const server = {...serverConfig, ...serverOptions}
35
- const devServer = new WebpackDevServer(compiler, server)
36
-
37
- const PORT = 3001
38
- const HOST = '127.0.0.1'
39
-
40
- devServer.listen(PORT, HOST, (error) => {
41
- if (error) return log(`Error in the extension runner: ${error}`)
42
- })
43
-
44
- process.on('SIGINT', () => closeAll(devServer))
45
- process.on('SIGTERM', () => closeAll(devServer))
46
- }