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/create/cli.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
// ██████╗██████╗ ███████╗ █████╗ ████████╗███████╗
|
|
4
|
-
// ██╔════╝██╔══██╗██╔════╝██╔══██╗╚══██╔══╝██╔════╝
|
|
5
|
-
// ██║ ██████╔╝█████╗ ███████║ ██║ █████╗
|
|
6
|
-
// ██║ ██╔══██╗██╔══╝ ██╔══██║ ██║ ██╔══╝
|
|
7
|
-
// ╚██████╗██║ ██║███████╗██║ ██║ ██║ ███████╗
|
|
8
|
-
// ╚═════╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚═╝ ╚══════╝
|
|
9
|
-
|
|
10
|
-
const {program} = require('commander')
|
|
11
|
-
const {log} = require('log-md')
|
|
12
|
-
|
|
13
|
-
const createExtension = require('./createExtension')
|
|
14
|
-
const messages = require('./messages')
|
|
15
|
-
const packageJson = require('./package.json')
|
|
16
|
-
|
|
17
|
-
let projectName
|
|
18
|
-
let templateName
|
|
19
|
-
|
|
20
|
-
function createExtensionCLI(clientProgram = program) {
|
|
21
|
-
clientProgram
|
|
22
|
-
.version(packageJson.version)
|
|
23
|
-
.command('create', {isDefault: true})
|
|
24
|
-
.usage('create <project-directory> [options]')
|
|
25
|
-
.action((_, cmd) => {
|
|
26
|
-
const {args, template} = cmd
|
|
27
|
-
|
|
28
|
-
projectName = args[0]
|
|
29
|
-
templateName = template
|
|
30
|
-
})
|
|
31
|
-
.description('create a new cross-browser extension')
|
|
32
|
-
.option(
|
|
33
|
-
'-t, --template <template-name>',
|
|
34
|
-
'specify a template for the created project'
|
|
35
|
-
)
|
|
36
|
-
.on('--help', () => messages.programHelp())
|
|
37
|
-
.parse(process.argv)
|
|
38
|
-
|
|
39
|
-
if (!projectName) {
|
|
40
|
-
log(`
|
|
41
|
-
You need to provide an extension name to create one.
|
|
42
|
-
See \`--help\` for command info.
|
|
43
|
-
`)
|
|
44
|
-
process.exit(1)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const workingDir = process.cwd()
|
|
48
|
-
|
|
49
|
-
createExtension(workingDir, projectName, templateName)
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// If the module was called from the cmd line, execute it
|
|
53
|
-
if (require.main === module) {
|
|
54
|
-
createExtensionCLI()
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// Export as a module so it can be reused
|
|
58
|
-
module.exports = createExtensionCLI
|
package/create/cli.test.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/* global describe, afterEach, it, expect */
|
|
2
|
-
const path = require('path')
|
|
3
|
-
|
|
4
|
-
const spawn = require('cross-spawn')
|
|
5
|
-
const fs = require('fs-extra')
|
|
6
|
-
|
|
7
|
-
describe('`create` command line interface', () => {
|
|
8
|
-
const createExtensionCLI = path.resolve(__dirname, './cli.js')
|
|
9
|
-
const projectName = 'my-extension-home'
|
|
10
|
-
const outputpath = path.resolve(process.cwd(), projectName)
|
|
11
|
-
|
|
12
|
-
afterEach(async () => {
|
|
13
|
-
// Clear filesystem after running tests
|
|
14
|
-
await fs.remove(outputpath)
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
it('creates an extension with specified project name', async () => {
|
|
18
|
-
expect.assertions(1)
|
|
19
|
-
spawn.sync('node', [createExtensionCLI, 'my-extension-home'], {
|
|
20
|
-
stdio: 'inherit'
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
const pathStat = await fs.stat(outputpath)
|
|
24
|
-
const isDirectory = pathStat.isDirectory()
|
|
25
|
-
|
|
26
|
-
expect(isDirectory).toBe(true)
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
it.todo('warns users if destination folder is not empty')
|
|
30
|
-
|
|
31
|
-
describe('-t, --template', () => {
|
|
32
|
-
it.todo('creates an extension by consuming a template')
|
|
33
|
-
it.todo('warns users if template flag is empty')
|
|
34
|
-
})
|
|
35
|
-
})
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
// ██████╗██████╗ ███████╗ █████╗ ████████╗███████╗
|
|
2
|
-
// ██╔════╝██╔══██╗██╔════╝██╔══██╗╚══██╔══╝██╔════╝
|
|
3
|
-
// ██║ ██████╔╝█████╗ ███████║ ██║ █████╗
|
|
4
|
-
// ██║ ██╔══██╗██╔══╝ ██╔══██║ ██║ ██╔══╝
|
|
5
|
-
// ╚██████╗██║ ██║███████╗██║ ██║ ██║ ███████╗
|
|
6
|
-
// ╚═════╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚═╝ ╚══════╝
|
|
7
|
-
|
|
8
|
-
const createDirectory = require('./steps/createDirectory')
|
|
9
|
-
const importExternalTemplate = require('./steps/importExternalTemplate')
|
|
10
|
-
const importLocalTemplate = require('./steps/importLocalTemplate')
|
|
11
|
-
const writePackageJson = require('./steps/writePackageJson')
|
|
12
|
-
const installDependencies = require('./steps/installDependencies')
|
|
13
|
-
const messages = require('./messages')
|
|
14
|
-
const abortAndClean = require('./steps/abortProjectAndClean')
|
|
15
|
-
const cleanTemplateFolder = require('./steps/cleanTemplateFolder')
|
|
16
|
-
|
|
17
|
-
process.on('unhandledRejection', (error) => {
|
|
18
|
-
throw error
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
module.exports = async function createExtension(
|
|
22
|
-
workingDir,
|
|
23
|
-
projectName,
|
|
24
|
-
template
|
|
25
|
-
) {
|
|
26
|
-
try {
|
|
27
|
-
await createDirectory(workingDir, projectName)
|
|
28
|
-
|
|
29
|
-
template
|
|
30
|
-
? await importExternalTemplate(workingDir, projectName, template)
|
|
31
|
-
: await importLocalTemplate(workingDir, projectName)
|
|
32
|
-
|
|
33
|
-
await writePackageJson(workingDir, projectName, template)
|
|
34
|
-
await installDependencies(workingDir, projectName)
|
|
35
|
-
await cleanTemplateFolder(template)
|
|
36
|
-
messages.successfullInstall(workingDir, projectName)
|
|
37
|
-
} catch (error) {
|
|
38
|
-
await abortAndClean(error, workingDir, projectName)
|
|
39
|
-
await cleanTemplateFolder(template)
|
|
40
|
-
}
|
|
41
|
-
}
|
|
@@ -1,36 +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
|
-
|
|
13
|
-
module.exports = async function directoryHasConflicts(
|
|
14
|
-
projectPath,
|
|
15
|
-
conflictingFiles
|
|
16
|
-
) {
|
|
17
|
-
const projectName = path.basename(projectPath)
|
|
18
|
-
|
|
19
|
-
log(`Conflict! Directory \`${projectName}/\` includes conflicting files:`, {
|
|
20
|
-
gutter: true
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
for (const file of conflictingFiles) {
|
|
24
|
-
const stats = await fs.lstat(path.join(projectPath, file))
|
|
25
|
-
|
|
26
|
-
log(stats.isDirectory() ? ` 📁 - ${file}/` : ` 📄 - ${file}`)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
log(
|
|
30
|
-
'You need to either rename/remove the files listed above,\n' +
|
|
31
|
-
'or choose a new directory name for your extension.',
|
|
32
|
-
{gutter: true}
|
|
33
|
-
)
|
|
34
|
-
|
|
35
|
-
log(`Path to conflicting directory: \`${projectPath}\``)
|
|
36
|
-
}
|
package/create/messages/index.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
// ██████╗██████╗ ███████╗ █████╗ ████████╗███████╗
|
|
2
|
-
// ██╔════╝██╔══██╗██╔════╝██╔══██╗╚══██╔══╝██╔════╝
|
|
3
|
-
// ██║ ██████╔╝█████╗ ███████║ ██║ █████╗
|
|
4
|
-
// ██║ ██╔══██╗██╔══╝ ██╔══██║ ██║ ██╔══╝
|
|
5
|
-
// ╚██████╗██║ ██║███████╗██║ ██║ ██║ ███████╗
|
|
6
|
-
// ╚═════╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚═╝ ╚══════╝
|
|
7
|
-
|
|
8
|
-
const directoryHasConflicts = require('./directoryHasConflicts')
|
|
9
|
-
const programHelp = require('./programHelp')
|
|
10
|
-
const successfullInstall = require('./successfullInstall')
|
|
11
|
-
|
|
12
|
-
module.exports = {
|
|
13
|
-
successfullInstall,
|
|
14
|
-
programHelp,
|
|
15
|
-
directoryHasConflicts
|
|
16
|
-
}
|
|
@@ -1,26 +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 \`create\` command
|
|
13
|
-
|
|
14
|
-
## The \`<project-directory>\` argument (required).
|
|
15
|
-
|
|
16
|
-
The project's directory where your extension will be installed.
|
|
17
|
-
\`extension-create\` can't install files without this information.
|
|
18
|
-
|
|
19
|
-
## The \`--template\` _<template-name>_ flag
|
|
20
|
-
|
|
21
|
-
A template name can be provided if your project needs a special config.
|
|
22
|
-
|
|
23
|
-
Feels something is wrong? Help by reporting a bug:
|
|
24
|
-
https://github.com/cezaraugusto/extension-create/issues/new
|
|
25
|
-
`)
|
|
26
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
// ██████╗██████╗ ███████╗ █████╗ ████████╗███████╗
|
|
2
|
-
// ██╔════╝██╔══██╗██╔════╝██╔══██╗╚══██╔══╝██╔════╝
|
|
3
|
-
// ██║ ██████╔╝█████╗ ███████║ ██║ █████╗
|
|
4
|
-
// ██║ ██╔══██╗██╔══╝ ██╔══██║ ██║ ██╔══╝
|
|
5
|
-
// ╚██████╗██║ ██║███████╗██║ ██║ ██║ ███████╗
|
|
6
|
-
// ╚═════╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚═╝ ╚══════╝
|
|
7
|
-
|
|
8
|
-
const path = require('path')
|
|
9
|
-
|
|
10
|
-
const {log} = require('log-md')
|
|
11
|
-
|
|
12
|
-
module.exports = function successfullInstall(workingDir, projectName) {
|
|
13
|
-
const projectPath = path.join(workingDir, projectName)
|
|
14
|
-
const relativePath = path.relative(workingDir, projectPath)
|
|
15
|
-
|
|
16
|
-
log(` 🧩 Success! Extension ${projectName} created.`)
|
|
17
|
-
|
|
18
|
-
log(`
|
|
19
|
-
Now \`cd ${relativePath}\` and *npm start* to open a new browser instance
|
|
20
|
-
with your extension installed, loaded, and ready for development.
|
|
21
|
-
|
|
22
|
-
You are done. Time to hack on your extension!
|
|
23
|
-
`)
|
|
24
|
-
}
|
package/create/package.json
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"license": "MIT",
|
|
3
|
-
"repository": {
|
|
4
|
-
"type": "git",
|
|
5
|
-
"url": "https://github.com/cezaraugusto/extension-create.git",
|
|
6
|
-
"directory": "create"
|
|
7
|
-
},
|
|
8
|
-
"engines": {
|
|
9
|
-
"node": ">=10"
|
|
10
|
-
},
|
|
11
|
-
"name": "@extension-create/create",
|
|
12
|
-
"version": "0.0.0",
|
|
13
|
-
"description": "The create step of extension-create",
|
|
14
|
-
"main": "./cli.js",
|
|
15
|
-
"bin": "./cli.js",
|
|
16
|
-
"author": "Cezar Augusto <boss@cezaraugusto.net> (https://twitter.com/cezaraugusto)",
|
|
17
|
-
"scripts": {
|
|
18
|
-
"dev:create": "node ./cli.js",
|
|
19
|
-
"test": "jest"
|
|
20
|
-
},
|
|
21
|
-
"dependencies": {
|
|
22
|
-
"chalk": "^4.1.0",
|
|
23
|
-
"commander": "^6.2.0",
|
|
24
|
-
"cross-spawn": "^7.0.3",
|
|
25
|
-
"dedent": "^0.7.0",
|
|
26
|
-
"degit": "^2.8.0",
|
|
27
|
-
"fancy-json-stringify": "^1.0.0",
|
|
28
|
-
"fs-extra": "^9.0.1",
|
|
29
|
-
"jest": "^26.6.3",
|
|
30
|
-
"log-md": "^0.1.0",
|
|
31
|
-
"marked": "^1.2.3",
|
|
32
|
-
"marked-terminal": "^4.1.0",
|
|
33
|
-
"pacote": "^11.1.13",
|
|
34
|
-
"semver": "^7.3.2",
|
|
35
|
-
"symlink-dir": "^4.1.0",
|
|
36
|
-
"yarn": "^1.22.10"
|
|
37
|
-
}
|
|
38
|
-
}
|
|
@@ -1,43 +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
|
-
|
|
13
|
-
module.exports = async function abortProjectAndClean(
|
|
14
|
-
error,
|
|
15
|
-
workingDir,
|
|
16
|
-
projectName
|
|
17
|
-
) {
|
|
18
|
-
const projectPath = path.resolve(workingDir, projectName)
|
|
19
|
-
|
|
20
|
-
log('😑👎 Aborting installation.')
|
|
21
|
-
|
|
22
|
-
if (error.command) {
|
|
23
|
-
log(`
|
|
24
|
-
😕❓ ${error.command} has failed.
|
|
25
|
-
`)
|
|
26
|
-
} else {
|
|
27
|
-
log(`
|
|
28
|
-
🚨 Unexpected creation error. This is a bug.
|
|
29
|
-
`)
|
|
30
|
-
log(`Please report: "${error}"`)
|
|
31
|
-
log('https://github.com/cezaraugusto/extension-create/issues/', {
|
|
32
|
-
gutter: true
|
|
33
|
-
})
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
log('🧹 - Removing files generated from project in:')
|
|
37
|
-
log(`\`${projectPath}\``)
|
|
38
|
-
await fs.ensureDir(projectPath)
|
|
39
|
-
await fs.remove(projectPath)
|
|
40
|
-
|
|
41
|
-
log('Done.')
|
|
42
|
-
process.exit(1)
|
|
43
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
// ██████╗██████╗ ███████╗ █████╗ ████████╗███████╗
|
|
2
|
-
// ██╔════╝██╔══██╗██╔════╝██╔══██╗╚══██╔══╝██╔════╝
|
|
3
|
-
// ██║ ██████╔╝█████╗ ███████║ ██║ █████╗
|
|
4
|
-
// ██║ ██╔══██╗██╔══╝ ██╔══██║ ██║ ██╔══╝
|
|
5
|
-
// ╚██████╗██║ ██║███████╗██║ ██║ ██║ ███████╗
|
|
6
|
-
// ╚═════╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚═╝ ╚══════╝
|
|
7
|
-
|
|
8
|
-
const fs = require('fs-extra')
|
|
9
|
-
const {log} = require('log-md')
|
|
10
|
-
|
|
11
|
-
const getTemplatePath = require('./getTemplatePath')
|
|
12
|
-
|
|
13
|
-
module.exports = async function createTemplateFolder(template) {
|
|
14
|
-
// We don't want to delete local templates
|
|
15
|
-
if (!template) {
|
|
16
|
-
return
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
log('🧹 - Cleaning up everything...')
|
|
20
|
-
|
|
21
|
-
try {
|
|
22
|
-
await fs.remove(getTemplatePath(template))
|
|
23
|
-
} catch (error) {
|
|
24
|
-
log(`😕❓ Removing \`${template}\` failed: ${error}`)
|
|
25
|
-
}
|
|
26
|
-
}
|
|
@@ -1,41 +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
|
-
|
|
13
|
-
const messages = require('../messages')
|
|
14
|
-
|
|
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
|
-
})
|
|
21
|
-
const projectPath = path.resolve(workingDir, projectName)
|
|
22
|
-
|
|
23
|
-
log(`🤞 - Checking if \`${workingDir}\` exists...`)
|
|
24
|
-
await fs.ensureDir(projectName)
|
|
25
|
-
|
|
26
|
-
log('🔎 - Scanning for potential conflicting files...')
|
|
27
|
-
const currentDir = await fs.readdir(projectPath)
|
|
28
|
-
const conflictingFiles = currentDir
|
|
29
|
-
// .gitignore, .DS_Store, etc
|
|
30
|
-
.filter((file) => !file.startsWith('.'))
|
|
31
|
-
// Logs of yarn/npm
|
|
32
|
-
.filter((file) => !file.endsWith('.log'))
|
|
33
|
-
// Whatever we think is appropriate
|
|
34
|
-
.filter((file) => !allowlist.includes(file))
|
|
35
|
-
|
|
36
|
-
// If directory has conflicting files, abort
|
|
37
|
-
if (conflictingFiles.length) {
|
|
38
|
-
await messages.directoryHasConflicts(projectPath, conflictingFiles)
|
|
39
|
-
process.exit(1)
|
|
40
|
-
}
|
|
41
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
// ██████╗██████╗ ███████╗ █████╗ ████████╗███████╗
|
|
2
|
-
// ██╔════╝██╔══██╗██╔════╝██╔══██╗╚══██╔══╝██╔════╝
|
|
3
|
-
// ██║ ██████╔╝█████╗ ███████║ ██║ █████╗
|
|
4
|
-
// ██║ ██╔══██╗██╔══╝ ██╔══██║ ██║ ██╔══╝
|
|
5
|
-
// ╚██████╗██║ ██║███████╗██║ ██║ ██║ ███████╗
|
|
6
|
-
// ╚═════╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚═╝ ╚══════╝
|
|
7
|
-
|
|
8
|
-
const path = require('path')
|
|
9
|
-
|
|
10
|
-
const templatesDir = path.resolve(__dirname, '../templates')
|
|
11
|
-
const templateTempDir = (template) => `__temp__${template}`
|
|
12
|
-
|
|
13
|
-
module.exports = function getTemplatePath(template) {
|
|
14
|
-
let thisTemplate
|
|
15
|
-
|
|
16
|
-
if (template) {
|
|
17
|
-
thisTemplate = templateTempDir(template)
|
|
18
|
-
} else {
|
|
19
|
-
thisTemplate = 'standard'
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return path.resolve(templatesDir, thisTemplate)
|
|
23
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
// ██████╗██████╗ ███████╗ █████╗ ████████╗███████╗
|
|
2
|
-
// ██╔════╝██╔══██╗██╔════╝██╔══██╗╚══██╔══╝██╔════╝
|
|
3
|
-
// ██║ ██████╔╝█████╗ ███████║ ██║ █████╗
|
|
4
|
-
// ██║ ██╔══██╗██╔══╝ ██╔══██║ ██║ ██╔══╝
|
|
5
|
-
// ╚██████╗██║ ██║███████╗██║ ██║ ██║ ███████╗
|
|
6
|
-
// ╚═════╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚═╝ ╚══════╝
|
|
7
|
-
|
|
8
|
-
const path = require('path')
|
|
9
|
-
|
|
10
|
-
const fs = require('fs-extra')
|
|
11
|
-
const pacote = require('pacote')
|
|
12
|
-
const {log} = require('log-md')
|
|
13
|
-
|
|
14
|
-
const templatesDir = path.resolve(__dirname, '../templates')
|
|
15
|
-
|
|
16
|
-
module.exports = async function importExternalTemplate(
|
|
17
|
-
workingDir,
|
|
18
|
-
projectName,
|
|
19
|
-
template
|
|
20
|
-
) {
|
|
21
|
-
const projectPath = path.resolve(workingDir, projectName)
|
|
22
|
-
const templateName = template
|
|
23
|
-
|
|
24
|
-
try {
|
|
25
|
-
const tempTemplatePath = path.join(templatesDir, `__temp__${templateName}`)
|
|
26
|
-
|
|
27
|
-
log(`⚙️ - Importing template \`${template}\` as requested...`)
|
|
28
|
-
const {name, version} = await pacote.manifest(templateName)
|
|
29
|
-
|
|
30
|
-
await pacote.extract(`${name}@${version}`, tempTemplatePath)
|
|
31
|
-
|
|
32
|
-
log(`🧰 - Installing **${projectName}** from template \`${templateName}\``)
|
|
33
|
-
const templateDirPath = path.join(tempTemplatePath, 'template')
|
|
34
|
-
|
|
35
|
-
await fs.copy(templateDirPath, projectPath)
|
|
36
|
-
} catch (error) {
|
|
37
|
-
log(`😕❓ Can't find template __${templateName}__. ${error}`, {
|
|
38
|
-
gutter: true
|
|
39
|
-
})
|
|
40
|
-
process.exit(1)
|
|
41
|
-
}
|
|
42
|
-
}
|
|
@@ -1,31 +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
|
-
|
|
13
|
-
const templatesDir = path.resolve(__dirname, '../templates')
|
|
14
|
-
const defaultTemplate = 'standard'
|
|
15
|
-
|
|
16
|
-
module.exports = async function importLocalTemplate(workingDir, projectName) {
|
|
17
|
-
const projectPath = path.resolve(workingDir, projectName)
|
|
18
|
-
const templateDirPath = path.join(templatesDir, defaultTemplate, 'template')
|
|
19
|
-
|
|
20
|
-
const templateName = path.basename(templateDirPath)
|
|
21
|
-
|
|
22
|
-
try {
|
|
23
|
-
log(`🧰 - Installing **${projectName}** from standard template...`)
|
|
24
|
-
await fs.copy(templateDirPath, projectPath)
|
|
25
|
-
} catch (error) {
|
|
26
|
-
log(`😕❓ Can't copy template __${templateName}__: ${error}`, {
|
|
27
|
-
gutter: true
|
|
28
|
-
})
|
|
29
|
-
process.exit(1)
|
|
30
|
-
}
|
|
31
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
// ██████╗██████╗ ███████╗ █████╗ ████████╗███████╗
|
|
2
|
-
// ██╔════╝██╔══██╗██╔════╝██╔══██╗╚══██╔══╝██╔════╝
|
|
3
|
-
// ██║ ██████╔╝█████╗ ███████║ ██║ █████╗
|
|
4
|
-
// ██║ ██╔══██╗██╔══╝ ██╔══██║ ██║ ██╔══╝
|
|
5
|
-
// ╚██████╗██║ ██║███████╗██║ ██║ ██║ ███████╗
|
|
6
|
-
// ╚═════╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚═╝ ╚══════╝
|
|
7
|
-
|
|
8
|
-
const path = require('path')
|
|
9
|
-
|
|
10
|
-
const fs = require('fs-extra')
|
|
11
|
-
const spawn = require('cross-spawn')
|
|
12
|
-
const {log} = require('log-md')
|
|
13
|
-
|
|
14
|
-
const abortProjectAndClean = require('./abortProjectAndClean')
|
|
15
|
-
|
|
16
|
-
module.exports = async function installDependencies(workingDir, projectName) {
|
|
17
|
-
const projectPath = path.resolve(workingDir, projectName)
|
|
18
|
-
const projectPackageJson = path.join(projectPath, 'package.json')
|
|
19
|
-
const packageMetadata = require(projectPackageJson)
|
|
20
|
-
|
|
21
|
-
const dependencies = packageMetadata.dependencies || []
|
|
22
|
-
const devDependencies = packageMetadata.devDependencies || []
|
|
23
|
-
|
|
24
|
-
if (dependencies.length === 0 && devDependencies.length === 0) {
|
|
25
|
-
log('⏭ - No dependencies. Skipping install step...')
|
|
26
|
-
|
|
27
|
-
return
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const command = 'npm'
|
|
31
|
-
const commonArgs = ['--prefix', projectPath]
|
|
32
|
-
|
|
33
|
-
try {
|
|
34
|
-
log('🛠 - Installing extension-create as devDependency...')
|
|
35
|
-
// Link instead of download in local env
|
|
36
|
-
if (process.env.NODE_ENV === 'development') {
|
|
37
|
-
await fs.ensureSymlink(`${projectPath}/node_modules`, workingDir)
|
|
38
|
-
} else {
|
|
39
|
-
const installSelfArgs = [
|
|
40
|
-
...commonArgs,
|
|
41
|
-
'install',
|
|
42
|
-
'-D',
|
|
43
|
-
'extension-create',
|
|
44
|
-
'--silent'
|
|
45
|
-
]
|
|
46
|
-
|
|
47
|
-
spawn.sync(command, installSelfArgs, {stdio: 'inherit'})
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
log('⚙️ - Installing package dependencies...')
|
|
51
|
-
const installArgs = [...commonArgs, 'install', '--exact', '--silent']
|
|
52
|
-
|
|
53
|
-
spawn.sync(command, installArgs, {stdio: 'inherit'})
|
|
54
|
-
await Promise.resolve()
|
|
55
|
-
} catch (error) {
|
|
56
|
-
abortProjectAndClean(error, workingDir, projectName)
|
|
57
|
-
}
|
|
58
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
// ██████╗██████╗ ███████╗ █████╗ ████████╗███████╗
|
|
2
|
-
// ██╔════╝██╔══██╗██╔════╝██╔══██╗╚══██╔══╝██╔════╝
|
|
3
|
-
// ██║ ██████╔╝█████╗ ███████║ ██║ █████╗
|
|
4
|
-
// ██║ ██╔══██╗██╔══╝ ██╔══██║ ██║ ██╔══╝
|
|
5
|
-
// ╚██████╗██║ ██║███████╗██║ ██║ ██║ ███████╗
|
|
6
|
-
// ╚═════╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚═╝ ╚══════╝
|
|
7
|
-
|
|
8
|
-
const path = require('path')
|
|
9
|
-
|
|
10
|
-
const fs = require('fs-extra')
|
|
11
|
-
const fancyJsonStringify = require('fancy-json-stringify')
|
|
12
|
-
const {log} = require('log-md')
|
|
13
|
-
|
|
14
|
-
const getTemplatePath = require('./getTemplatePath')
|
|
15
|
-
const abortProjectAndClean = require('./abortProjectAndClean')
|
|
16
|
-
|
|
17
|
-
const templatesDir = path.resolve(__dirname, '../templates')
|
|
18
|
-
|
|
19
|
-
const packageJsonScripts = {
|
|
20
|
-
start: 'extension-create start'
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
module.exports = async function writePackageJson(
|
|
24
|
-
workingDir,
|
|
25
|
-
projectName,
|
|
26
|
-
template
|
|
27
|
-
) {
|
|
28
|
-
const projectPath = path.resolve(workingDir, projectName)
|
|
29
|
-
|
|
30
|
-
const templatePath = path.resolve(templatesDir, getTemplatePath(template))
|
|
31
|
-
|
|
32
|
-
const templateJsonPath = path.resolve(templatePath, 'template.json')
|
|
33
|
-
|
|
34
|
-
const templateJson = require(templateJsonPath)
|
|
35
|
-
|
|
36
|
-
const templateMetadata = templateJson.package || {}
|
|
37
|
-
|
|
38
|
-
templateMetadata.scripts = templateMetadata.scripts || {}
|
|
39
|
-
templateMetadata.dependencies = templateMetadata.dependencies || {}
|
|
40
|
-
templateMetadata.devDependencies = templateMetadata.devDependencies || {}
|
|
41
|
-
|
|
42
|
-
const packageMetadata = {
|
|
43
|
-
name: path.basename(projectPath),
|
|
44
|
-
private: true,
|
|
45
|
-
version: '0.0.0',
|
|
46
|
-
dependencies: templateMetadata.dependencies,
|
|
47
|
-
devDependencies: templateMetadata.devDependencies,
|
|
48
|
-
scripts: {
|
|
49
|
-
...templateMetadata.scripts,
|
|
50
|
-
...packageJsonScripts
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
try {
|
|
55
|
-
log('📝 - Writing `package.json` metadata...')
|
|
56
|
-
await fs.writeFile(
|
|
57
|
-
path.join(projectPath, 'package.json'),
|
|
58
|
-
fancyJsonStringify(packageMetadata)
|
|
59
|
-
)
|
|
60
|
-
} catch (error) {
|
|
61
|
-
await abortProjectAndClean(error, workingDir, projectName)
|
|
62
|
-
process.exit(1)
|
|
63
|
-
}
|
|
64
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
|
2
|
-
|
|
3
|
-
# dependencies
|
|
4
|
-
/node_modules
|
|
5
|
-
|
|
6
|
-
# testing
|
|
7
|
-
/coverage
|
|
8
|
-
|
|
9
|
-
# production
|
|
10
|
-
/dist
|
|
11
|
-
|
|
12
|
-
# misc
|
|
13
|
-
.DS_Store
|
|
14
|
-
.env.local
|
|
15
|
-
.env.development.local
|
|
16
|
-
.env.test.local
|
|
17
|
-
.env.production.local
|
|
18
|
-
|
|
19
|
-
npm-debug.log*
|
|
20
|
-
yarn-debug.log*
|
|
21
|
-
yarn-error.log*
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
# extension-create Standard Template
|
|
2
|
-
|
|
3
|
-
> Standard template for [extension-create](https://github.com/cezaraugusto/extension-create).
|
|
4
|
-
|
|
5
|
-
Directory Structure:
|
|
6
|
-
|
|
7
|
-
```
|
|
8
|
-
./template
|
|
9
|
-
├── manifest.json
|
|
10
|
-
├── src
|
|
11
|
-
│ ├── background.js
|
|
12
|
-
│ └── content.js (next)
|
|
13
|
-
├── .gitignore
|
|
14
|
-
```
|