@jcoreio/toolchain 1.0.0-beta.1

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 (87) hide show
  1. package/.eslintrc.js +6 -0
  2. package/bin/commitizen +5 -0
  3. package/bin/commitlint +5 -0
  4. package/bin/cz +5 -0
  5. package/bin/eslint +5 -0
  6. package/bin/git-cz +5 -0
  7. package/bin/lint-fix.cjs +8 -0
  8. package/bin/lint-staged +5 -0
  9. package/bin/prettier +5 -0
  10. package/bin/resolveBin.cjs +8 -0
  11. package/bin/semantic-release +5 -0
  12. package/commitizen.cjs +1 -0
  13. package/commitlint.config.cjs +11 -0
  14. package/eslint.config.cjs +8 -0
  15. package/eslint.extends.cjs +54 -0
  16. package/githooks/applypatch-msg +3 -0
  17. package/githooks/commit-msg +3 -0
  18. package/githooks/post-applypatch +3 -0
  19. package/githooks/post-checkout +3 -0
  20. package/githooks/post-commit +3 -0
  21. package/githooks/post-merge +3 -0
  22. package/githooks/post-receive +3 -0
  23. package/githooks/post-rewrite +3 -0
  24. package/githooks/post-update +3 -0
  25. package/githooks/pre-applypatch +3 -0
  26. package/githooks/pre-auto-gc +3 -0
  27. package/githooks/pre-commit +3 -0
  28. package/githooks/pre-merge-commit +3 -0
  29. package/githooks/pre-push +3 -0
  30. package/githooks/pre-rebase +3 -0
  31. package/githooks/pre-receive +3 -0
  32. package/githooks/prepare-commit-msg +3 -0
  33. package/githooks/push-to-checkout +3 -0
  34. package/githooks/runHook.cjs +32 -0
  35. package/githooks.cjs +5 -0
  36. package/lint-staged.config.cjs +20 -0
  37. package/package.json +60 -0
  38. package/plugins/buildDistPackageJson.cjs +7 -0
  39. package/plugins/compile.cjs +21 -0
  40. package/plugins/formatExtensions.cjs +12 -0
  41. package/plugins/getConfigFiles.cjs +57 -0
  42. package/plugins/getEslintExtends.cjs +1 -0
  43. package/plugins/lintExtensions.cjs +1 -0
  44. package/plugins/sourceExtensions.cjs +1 -0
  45. package/prettier.config.cjs +5 -0
  46. package/release.config.cjs +16 -0
  47. package/scripts/bootstrap/bootstrapConfigFiles.cjs +18 -0
  48. package/scripts/bootstrap/bootstrapEslintConfigs.cjs +30 -0
  49. package/scripts/bootstrap/bootstrapGitignore.cjs +37 -0
  50. package/scripts/bootstrap/bootstrapMoveTypeDefs.cjs +14 -0
  51. package/scripts/bootstrap/bootstrapProjectPackageJson.cjs +76 -0
  52. package/scripts/bootstrap/bootstrapRemoveDevDeps.cjs +110 -0
  53. package/scripts/bootstrap/bootstrapRemoveFiles.cjs +50 -0
  54. package/scripts/bootstrap/installGitHooks.cjs +31 -0
  55. package/scripts/bootstrap.cjs +48 -0
  56. package/scripts/build.cjs +66 -0
  57. package/scripts/check.cjs +19 -0
  58. package/scripts/clean.cjs +6 -0
  59. package/scripts/coverage.cjs +12 -0
  60. package/scripts/format.cjs +4 -0
  61. package/scripts/init.cjs +55 -0
  62. package/scripts/lint-fix.cjs +4 -0
  63. package/scripts/lint.cjs +4 -0
  64. package/scripts/open-coverage.cjs +7 -0
  65. package/scripts/preinstall/preinstallRemoveDevDeps.cjs +65 -0
  66. package/scripts/preinstall/preinstallRemoveFiles.cjs +50 -0
  67. package/scripts/preinstall/preinstallUpdateProjectPackageJson.cjs +39 -0
  68. package/scripts/preinstall.cjs +35 -0
  69. package/scripts/prepublish.cjs +11 -0
  70. package/scripts/runEslint.cjs +34 -0
  71. package/scripts/runPrettier.cjs +27 -0
  72. package/scripts/test.cjs +12 -0
  73. package/scripts/toolchain.cjs +82 -0
  74. package/util/ChdirFs.cjs +50 -0
  75. package/util/execa.cjs +72 -0
  76. package/util/findUps.cjs +44 -0
  77. package/util/getPlugins.cjs +21 -0
  78. package/util/getPluginsArraySync.cjs +14 -0
  79. package/util/getPluginsAsyncFunction.cjs +12 -0
  80. package/util/getPluginsObject.cjs +12 -0
  81. package/util/glob.cjs +6 -0
  82. package/util/hasTSSourcesSync.cjs +7 -0
  83. package/util/ini.cjs +36 -0
  84. package/util/once.cjs +6 -0
  85. package/util/projectFs.cjs +4 -0
  86. package/util/sortDeps.cjs +21 -0
  87. package/util/sortPlugins.cjs +67 -0
@@ -0,0 +1,76 @@
1
+ const { name, peerDependencies: basePeerDeps } = require('../../package.json')
2
+ const { projectDir, toolchainPackages } = require('../../util/findUps.cjs')
3
+ const getPluginsAsyncFunction = require('../../util/getPluginsAsyncFunction.cjs')
4
+ const fs = require('../../util/projectFs.cjs')
5
+ const sortDeps = require('../../util/sortDeps.cjs')
6
+
7
+ async function bootstrapProjectPackageJson() {
8
+ const { merge, unset } = require('lodash')
9
+
10
+ const packageJson = await fs.readJson('package.json')
11
+ const devDependencies =
12
+ packageJson.devDependencies || (packageJson.devDependencies = {})
13
+
14
+ const peerDependencies = { ...basePeerDeps }
15
+ for (const pkg of toolchainPackages) {
16
+ Object.assign(
17
+ peerDependencies,
18
+ require(require.resolve(`${pkg}/package.json`, { paths: [projectDir] }))
19
+ .peerDependencies
20
+ )
21
+ }
22
+
23
+ for (const path of [
24
+ 'exports',
25
+ 'eslintConfig',
26
+ 'files',
27
+ 'husky',
28
+ 'main',
29
+ 'module',
30
+ 'renovate',
31
+ 'prettier',
32
+ 'commitlint',
33
+ 'lint-staged',
34
+ 'nyc',
35
+ 'husky',
36
+ 'config.mocha',
37
+ ]) {
38
+ unset(packageJson, path)
39
+ }
40
+ for (const dep of require('./bootstrapRemoveDevDeps.cjs')) {
41
+ delete devDependencies[dep]
42
+ }
43
+
44
+ merge(packageJson, {
45
+ version: '0.0.0-development',
46
+ sideEffects: false,
47
+ scripts: {
48
+ tc: 'toolchain',
49
+ toolchain: 'toolchain',
50
+ test: 'toolchain test',
51
+ prepublishOnly:
52
+ 'echo This package is meant to be published by semantic-release from the dist build directory. && exit 1',
53
+ },
54
+ config: {
55
+ commitizen: { path: `${name}/commitizen.cjs` },
56
+ },
57
+ })
58
+
59
+ if (peerDependencies) {
60
+ for (const dep in peerDependencies) {
61
+ const version = peerDependencies[dep]
62
+ if (version.startsWith('workspace') || version === '*') continue
63
+ packageJson.devDependencies[dep] = version
64
+ }
65
+ }
66
+
67
+ await getPluginsAsyncFunction('bootstrapProjectPackageJson')(packageJson)
68
+
69
+ sortDeps(packageJson)
70
+
71
+ await fs.writeJson('package.json', packageJson, { spaces: 2 })
72
+ // eslint-disable-next-line no-console
73
+ console.error('updated package.json')
74
+ }
75
+
76
+ module.exports = bootstrapProjectPackageJson
@@ -0,0 +1,110 @@
1
+ module.exports = [
2
+ '@babel/cli',
3
+ '@babel/core',
4
+ '@babel/plugin-dynamic-import-node',
5
+ '@babel/plugin-external-helpers',
6
+ '@babel/plugin-proposal-class-properties',
7
+ '@babel/plugin-proposal-export-default-from',
8
+ '@babel/plugin-proposal-export-namespace-from',
9
+ '@babel/plugin-proposal-object-rest-spread',
10
+ '@babel/plugin-syntax-async-functions',
11
+ '@babel/plugin-syntax-dynamic-import',
12
+ '@babel/plugin-syntax-flow',
13
+ '@babel/plugin-tester',
14
+ '@babel/plugin-transform-async-generator-functions',
15
+ '@babel/plugin-transform-async-to-module-method',
16
+ '@babel/plugin-transform-charcodes',
17
+ '@babel/plugin-transform-class-properties',
18
+ '@babel/plugin-transform-decorators-legacy',
19
+ '@babel/plugin-transform-es2015-modules-commonjs',
20
+ '@babel/plugin-transform-es2015-modules-simple-commonjs',
21
+ '@babel/plugin-transform-export-extensions',
22
+ '@babel/plugin-transform-flow-comments',
23
+ '@babel/plugin-transform-object-rest-spread',
24
+ '@babel/plugin-transform-regenerator',
25
+ '@babel/plugin-transform-runtime',
26
+ '@babel/polyfill',
27
+ '@babel/preset-async-to-bluebird',
28
+ '@babel/preset-babili',
29
+ '@babel/preset-env',
30
+ '@babel/preset-es2015-no-commonjs',
31
+ '@babel/preset-es2015-node',
32
+ '@babel/preset-es2015-node4',
33
+ '@babel/preset-es2015-without-strict',
34
+ '@babel/preset-es2015',
35
+ '@babel/preset-flow',
36
+ '@babel/preset-react',
37
+ '@babel/preset-stage-1',
38
+ '@babel/preset-stage-2',
39
+ '@babel/preset-typescript',
40
+ '@babel/register',
41
+ '@commitlint/cli',
42
+ '@commitlint/config-conventional',
43
+ '@jcoreio/commitlint-config',
44
+ '@jedwards1211/commitlint-config',
45
+ '@jedwards1211/eslint-config-flow',
46
+ '@jedwards1211/eslint-config-react',
47
+ '@jedwards1211/eslint-config-typescript',
48
+ '@jedwards1211/eslint-config',
49
+ '@typescript-eslint/eslint-plugin',
50
+ '@typescript-eslint/parser',
51
+ 'babel-cli',
52
+ 'babel-core',
53
+ 'babel-eslint',
54
+ 'babel-plugin-dynamic-import-node',
55
+ 'babel-plugin-external-helpers',
56
+ 'babel-plugin-flow-react-proptypes',
57
+ 'babel-plugin-istanbul',
58
+ 'babel-plugin-syntax-async-functions',
59
+ 'babel-plugin-syntax-dynamic-import',
60
+ 'babel-plugin-syntax-flow',
61
+ 'babel-plugin-tester',
62
+ 'babel-plugin-transform-async-generator-functions',
63
+ 'babel-plugin-transform-async-to-module-method',
64
+ 'babel-plugin-transform-charcodes',
65
+ 'babel-plugin-transform-class-properties',
66
+ 'babel-plugin-transform-decorators-legacy',
67
+ 'babel-plugin-transform-es2015-modules-commonjs',
68
+ 'babel-plugin-transform-es2015-modules-simple-commonjs',
69
+ 'babel-plugin-transform-export-extensions',
70
+ 'babel-plugin-transform-flow-comments',
71
+ 'babel-plugin-transform-object-rest-spread',
72
+ 'babel-plugin-transform-regenerator',
73
+ 'babel-plugin-transform-runtime',
74
+ 'babel-polyfill',
75
+ 'babel-preset-async-to-bluebird',
76
+ 'babel-preset-babili',
77
+ 'babel-preset-env',
78
+ 'babel-preset-es2015-no-commonjs',
79
+ 'babel-preset-es2015-node',
80
+ 'babel-preset-es2015-node4',
81
+ 'babel-preset-es2015-without-strict',
82
+ 'babel-preset-es2015',
83
+ 'babel-preset-flow',
84
+ 'babel-preset-react',
85
+ 'babel-preset-stage-1',
86
+ 'babel-preset-stage-2',
87
+ 'babel-register',
88
+ 'babel-runtime',
89
+ 'babel-types',
90
+ 'babylon',
91
+ 'codecov',
92
+ 'coveralls',
93
+ 'eslint-plugin-flowtype',
94
+ 'eslint-plugin-prettier',
95
+ 'eslint-plugin-react',
96
+ 'eslint-watch',
97
+ 'eslint',
98
+ 'flow-copy-source',
99
+ 'flow-watch',
100
+ 'husky',
101
+ 'isparta',
102
+ 'istanbul',
103
+ 'lint-staged',
104
+ 'mocha',
105
+ 'nyc',
106
+ 'prettier-eslint',
107
+ 'prettier',
108
+ 'semantic-release',
109
+ 'travis-deploy-once',
110
+ ]
@@ -0,0 +1,50 @@
1
+ module.exports = [
2
+ '.babelrc.cjs',
3
+ '.babelrc.js',
4
+ '.babelrc.json',
5
+ '.babelrc.mjs',
6
+ '.babelrc',
7
+ '.commitlintrc.js',
8
+ '.commitlintrc.json',
9
+ '.commitlintrc.yml',
10
+ '.eslintignore',
11
+ '.github/renovate.json',
12
+ '.github/renovate.json5',
13
+ '.gitignore',
14
+ '.gitlab/renovate.json',
15
+ '.gitlab/renovate.json5',
16
+ '.lintstagedrc',
17
+ '.npmignore',
18
+ '.nycrc.json',
19
+ '.nycrc.yaml',
20
+ '.nycrc.yml',
21
+ '.nycrc',
22
+ '.prettierrc.cjs',
23
+ '.prettierrc.js',
24
+ '.prettierrc.json',
25
+ '.prettierrc.json5',
26
+ '.prettierrc.toml',
27
+ '.prettierrc.yaml',
28
+ '.prettierrc.yml',
29
+ '.prettierrc',
30
+ '.renovaterc.json',
31
+ '.renovaterc',
32
+ '.travis.yml',
33
+ 'babel.config.cjs',
34
+ 'babel.config.js',
35
+ 'babel.config.json',
36
+ 'babel.config.mjs',
37
+ 'commitlint.config.cjs',
38
+ 'commitlint.config.js',
39
+ 'lint-staged.config.cjs',
40
+ 'lint-staged.config.js',
41
+ 'nyc.config.cjs',
42
+ 'nyc.config.js',
43
+ 'package-lock.json',
44
+ 'prettier.config.cjs',
45
+ 'prettier.config.js',
46
+ 'renovate.json',
47
+ 'renovate.json5',
48
+ 'solano.yml',
49
+ 'yarn.lock',
50
+ ]
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env node
2
+
3
+ const execa = require('../../util/execa.cjs')
4
+ const Path = require('path')
5
+ const dedent = require('dedent-js')
6
+ const { findGitDir } = require('../../util/findUps.cjs')
7
+
8
+ async function installGitHooks() {
9
+ const gitDir = findGitDir()
10
+ if (!gitDir) {
11
+ // eslint-disable-next-line no-console
12
+ console.warn(dedent`
13
+ .git directory not found!
14
+ git hooks could not be installed.
15
+ after you run \`git init\`, try \`pnpm exec install-git-hooks\`.
16
+ `)
17
+ } else {
18
+ await execa('git', [
19
+ 'config',
20
+ 'core.hooksPath',
21
+ Path.relative(
22
+ Path.dirname(gitDir),
23
+ Path.resolve(__dirname, '..', '..', 'githooks')
24
+ ),
25
+ ])
26
+ // eslint-disable-next-line no-console
27
+ console.log('successfully installed git hooks!')
28
+ }
29
+ }
30
+
31
+ module.exports = installGitHooks
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require('../util/projectFs.cjs')
4
+ const getPluginsAsyncFunction = require('../util/getPluginsAsyncFunction.cjs')
5
+
6
+ async function bootstrap(args = []) {
7
+ const execa = require('../util/execa.cjs')
8
+ const installGitHooks = require('./bootstrap/installGitHooks.cjs')
9
+ const bootstrapProjectPackageJson = require('./bootstrap/bootstrapProjectPackageJson.cjs')
10
+ const bootstrapEslintConfigs = require('./bootstrap/bootstrapEslintConfigs.cjs')
11
+ const bootstrapConfigFiles = require('./bootstrap/bootstrapConfigFiles.cjs')
12
+ const bootstrapMoveTypeDefs = require('./bootstrap/bootstrapMoveTypeDefs.cjs')
13
+ const bootstrapGitignore = require('./bootstrap/bootstrapGitignore.cjs')
14
+ const bootstrapRemoveFiles = require('./bootstrap/bootstrapRemoveFiles.cjs')
15
+
16
+ await execa('git', ['init'])
17
+ await installGitHooks()
18
+ await bootstrapProjectPackageJson()
19
+ await Promise.all(
20
+ bootstrapRemoveFiles.map(async (file) => {
21
+ const exists = await fs.pathExists(file)
22
+ if (exists) {
23
+ await fs.remove(file)
24
+ // eslint-disable-next-line no-console
25
+ console.error('removed', file)
26
+ }
27
+ })
28
+ )
29
+ await bootstrapConfigFiles()
30
+ await bootstrapEslintConfigs()
31
+ await bootstrapMoveTypeDefs()
32
+ await bootstrapGitignore()
33
+ await getPluginsAsyncFunction('bootstrap')(args)
34
+ }
35
+
36
+ exports.description = 'set up project'
37
+ exports.run = bootstrap
38
+
39
+ if (require.main === module) {
40
+ bootstrap().then(
41
+ () => process.exit(0),
42
+ (error) => {
43
+ // eslint-disable-next-line no-console
44
+ console.error(error.stack)
45
+ process.exit(error.exitCode != null ? error.exitCode : 1)
46
+ }
47
+ )
48
+ }
@@ -0,0 +1,66 @@
1
+ const getPluginsAsyncFunction = require('../util/getPluginsAsyncFunction.cjs')
2
+ const Path = require('path')
3
+ const { projectDir } = require('../util/findUps.cjs')
4
+ const fs = require('../util/projectFs.cjs')
5
+ const clean = require('./clean.cjs')
6
+ const glob = require('../util/glob.cjs')
7
+
8
+ exports.run = async function build(args = []) {
9
+ await clean.run()
10
+ await fs.mkdirs('dist')
11
+
12
+ const ignoreEnoent = (err) => {
13
+ if (err.code !== 'ENOENT') throw err
14
+ }
15
+ const filter = (src, dest) => {
16
+ // eslint-disable-next-line no-console
17
+ console.error(
18
+ Path.relative(projectDir, src),
19
+ '->',
20
+ Path.relative(projectDir, dest)
21
+ )
22
+ return true
23
+ }
24
+ await Promise.all(
25
+ ['pnpm-lock.yaml', 'README.md', 'LICENSE.md'].map((file) =>
26
+ fs.copy(file, `dist/${file}`, { filter })
27
+ )
28
+ ).catch(ignoreEnoent)
29
+
30
+ const flowFiles = await glob(Path.join('src', '**', '*.{js,mjs,cjs}.flow'))
31
+ await Promise.all(
32
+ flowFiles.map(async (src) => {
33
+ for (const ext of src.endsWith('.js.flow')
34
+ ? ['.js.flow', '.cjs.flow', '.mjs.flow']
35
+ : /\.(js|mjs|cjs)\.flow$/.exec(ext)[0]) {
36
+ const dest = Path.join(
37
+ 'dist',
38
+ Path.relative('src', src.replace(/\.(js|mjs|cjs)\.flow$/, ext))
39
+ )
40
+ // eslint-disable-next-line no-console
41
+ console.error(src, '->', dest)
42
+ await fs.copy(src, dest)
43
+ }
44
+ })
45
+ )
46
+
47
+ const dtsFiles = await glob(Path.join('src', '**', '*.d.ts'))
48
+ await Promise.all(
49
+ dtsFiles.map(async (src) => {
50
+ const dest = Path.join('dist', Path.relative('src', src))
51
+ // eslint-disable-next-line no-console
52
+ console.error(src, '->', dest)
53
+ await fs.copy(src, dest)
54
+ })
55
+ )
56
+
57
+ await getPluginsAsyncFunction('compile')(args)
58
+ await getPluginsAsyncFunction('build')(args)
59
+
60
+ const packageJson = await fs.readJson('package.json')
61
+ await getPluginsAsyncFunction('buildDistPackageJson')(packageJson)
62
+ // eslint-disable-next-line no-console
63
+ console.error('package.json -> dist/package.json')
64
+ await fs.writeJson('dist/package.json', packageJson, { spaces: 2 })
65
+ }
66
+ exports.description = 'build dist directory'
@@ -0,0 +1,19 @@
1
+ const getPluginsAsyncFunction = require('../util/getPluginsAsyncFunction.cjs')
2
+ const {
3
+ packageJson: { devDependencies = {} },
4
+ } = require('../util/findUps.cjs')
5
+ const execa = require('../util/execa.cjs')
6
+ const fs = require('../util/projectFs.cjs')
7
+
8
+ exports.run = async function check(args = []) {
9
+ await require('../scripts/runPrettier.cjs').prettierCheck(args)
10
+ await require('../scripts/runEslint.cjs').eslintCheck(args)
11
+ if (devDependencies['flow-bin'] && (await fs.pathExists('.flowconfig'))) {
12
+ await execa('flow')
13
+ }
14
+ if (devDependencies['typescript'] && (await fs.pathExists('tsconfig.json'))) {
15
+ await execa('tsc', ['--noEmit'])
16
+ }
17
+ await getPluginsAsyncFunction('check')(args)
18
+ }
19
+ exports.description = 'check format, types (if applicable), and lint'
@@ -0,0 +1,6 @@
1
+ const fs = require('../util/projectFs.cjs')
2
+
3
+ exports.run = async function clean() {
4
+ await fs.remove('dist')
5
+ }
6
+ exports.description = 'remove build output'
@@ -0,0 +1,12 @@
1
+ const getPlugins = require('../util/getPlugins.cjs')
2
+ const getPluginsAsyncFunction = require('../util/getPluginsAsyncFunction.cjs')
3
+
4
+ exports.run = async function (args = []) {
5
+ if (!getPlugins('coverage').length) {
6
+ throw new Error(
7
+ 'missing test toolchain, install @jcoreio/toolchain-mocha (there may be alternatives in the future)'
8
+ )
9
+ }
10
+ await getPluginsAsyncFunction('coverage')(args)
11
+ }
12
+ exports.description = 'run tests with code coverage'
@@ -0,0 +1,4 @@
1
+ exports.run = async function (args = []) {
2
+ await require('./runPrettier.cjs').prettierFormat(args)
3
+ }
4
+ exports.description = 'format files with prettier'
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { packageJson } = require('../util/findUps.cjs')
4
+ const preinstall = require('./preinstall.cjs')
5
+ const execa = require('../util/execa.cjs')
6
+
7
+ async function init(args = []) {
8
+ const { dependencies = {}, devDependencies = {} } = packageJson
9
+ const toolchains = []
10
+ const isBabel =
11
+ devDependencies['@babel/core'] != null ||
12
+ devDependencies['babel-core'] != null
13
+ const isTS = isBabel && devDependencies.typescript != null
14
+ const isFlow = isBabel && devDependencies['flow-bin'] != null
15
+ const isReact = dependencies.react != null || devDependencies.react != null
16
+ const isMocha = devDependencies['mocha'] != null
17
+
18
+ if (isMocha) toolchains.push('@jcoreio/toolchain-mocha')
19
+ if (isBabel) toolchains.push('@jcoreio/toolchain-esnext')
20
+ if (isFlow) toolchains.push('@jcoreio/toolchain-flow')
21
+ if (isTS) toolchains.push('@jcoreio/toolchain-typescript')
22
+ if (isReact) toolchains.push('@jcoreio/toolchain-react')
23
+
24
+ const isTest = Boolean(process.env.JCOREIO_TOOLCHAIN_TEST)
25
+
26
+ await preinstall.run()
27
+ await execa('pnpm', [
28
+ 'add',
29
+ '-D',
30
+ isTest ? '../packages/base' : '@jcoreio/toolchain',
31
+ ...(isTest
32
+ ? toolchains.map((t) => t.replace(/@jcoreio\/toolchain-/, '../packages/'))
33
+ : toolchains),
34
+ ])
35
+ await execa('tc', ['bootstrap'])
36
+ await execa('pnpm', ['i', '--no-frozen-lockfile'])
37
+ await execa('tc', ['format'])
38
+ await execa('tc', ['lint:fix'])
39
+ await execa('tc', ['prepublish'])
40
+ }
41
+
42
+ exports.description =
43
+ 'install toolchains, bootstrap, format, lint:fix and prepublish'
44
+ exports.run = init
45
+
46
+ if (require.main === module) {
47
+ init().then(
48
+ () => process.exit(0),
49
+ (error) => {
50
+ // eslint-disable-next-line no-console
51
+ console.error(error.stack)
52
+ process.exit(error.exitCode != null ? error.exitCode : 1)
53
+ }
54
+ )
55
+ }
@@ -0,0 +1,4 @@
1
+ exports.run = async function (args = []) {
2
+ await require('./runEslint.cjs').eslintFix(args)
3
+ }
4
+ exports.description = 'autofix eslint errors'
@@ -0,0 +1,4 @@
1
+ exports.run = async function (args = []) {
2
+ await require('./runEslint.cjs').eslintCheck(args)
3
+ }
4
+ exports.description = 'check files with eslint'
@@ -0,0 +1,7 @@
1
+ const execa = require('../util/execa.cjs')
2
+ const Path = require('path')
3
+
4
+ exports.run = async () => {
5
+ await execa('open', [Path.join('coverage', 'lcov-report', 'index.html')])
6
+ }
7
+ exports.description = 'open code coverage report'
@@ -0,0 +1,65 @@
1
+ module.exports = [
2
+ '@commitlint/cli',
3
+ '@commitlint/config-conventional',
4
+ '@jedwards1211/commitlint-config',
5
+ '@jcoreio/commitlint-config',
6
+ 'babel-cli',
7
+ 'babel-core',
8
+ 'babel-eslint',
9
+ 'babel-plugin-dynamic-import-node',
10
+ 'babel-plugin-external-helpers',
11
+ 'babel-plugin-flow-react-proptypes',
12
+ 'babel-plugin-istanbul',
13
+ 'babel-plugin-syntax-async-functions',
14
+ 'babel-plugin-syntax-dynamic-import',
15
+ 'babel-plugin-syntax-flow',
16
+ 'babel-plugin-tester',
17
+ 'babel-plugin-transform-async-generator-functions',
18
+ 'babel-plugin-transform-async-to-module-method',
19
+ 'babel-plugin-transform-charcodes',
20
+ 'babel-plugin-transform-class-properties',
21
+ 'babel-plugin-transform-decorators-legacy',
22
+ 'babel-plugin-transform-es2015-modules-commonjs',
23
+ 'babel-plugin-transform-es2015-modules-simple-commonjs',
24
+ 'babel-plugin-transform-export-extensions',
25
+ 'babel-plugin-transform-flow-comments',
26
+ 'babel-plugin-transform-object-rest-spread',
27
+ 'babel-plugin-transform-regenerator',
28
+ 'babel-plugin-transform-runtime',
29
+ 'babel-polyfill',
30
+ 'babel-preset-async-to-bluebird',
31
+ 'babel-preset-babili',
32
+ 'babel-preset-env',
33
+ 'babel-preset-es2015',
34
+ 'babel-preset-es2015-no-commonjs',
35
+ 'babel-preset-es2015-node',
36
+ 'babel-preset-es2015-node4',
37
+ 'babel-preset-es2015-without-strict',
38
+ 'babel-preset-flow',
39
+ 'babel-preset-react',
40
+ 'babel-preset-stage-1',
41
+ 'babel-preset-stage-2',
42
+ 'babel-register',
43
+ 'babel-runtime',
44
+ 'babel-types',
45
+ 'babylon',
46
+ 'codecov',
47
+ 'coveralls',
48
+ 'eslint-plugin-flowtype',
49
+ 'eslint-plugin-prettier',
50
+ 'eslint-plugin-react',
51
+ 'eslint-watch',
52
+ 'eslint',
53
+ 'flow-copy-source',
54
+ 'flow-watch',
55
+ 'husky',
56
+ 'isparta',
57
+ 'istanbul',
58
+ 'lint-staged',
59
+ 'mocha',
60
+ 'nyc',
61
+ 'prettier',
62
+ 'prettier-eslint',
63
+ 'semantic-release',
64
+ 'travis-deploy-once',
65
+ ]
@@ -0,0 +1,50 @@
1
+ module.exports = [
2
+ '.babelrc',
3
+ '.babelrc.json',
4
+ '.babelrc.js',
5
+ '.babelrc.cjs',
6
+ '.babelrc.mjs',
7
+ 'babel.config.json',
8
+ 'babel.config.js',
9
+ 'babel.config.cjs',
10
+ 'babel.config.mjs',
11
+ '.prettierrc',
12
+ '.prettierrc.json',
13
+ '.prettierrc.json5',
14
+ '.prettierrc.yml',
15
+ '.prettierrc.yaml',
16
+ '.prettierrc.toml',
17
+ '.prettierrc.js',
18
+ '.prettierrc.cjs',
19
+ 'prettier.config.js',
20
+ 'prettier.config.cjs',
21
+ 'package-lock.json',
22
+ '.npmignore',
23
+ '.gitignore',
24
+ '.eslintignore',
25
+ 'commitlint.config.js',
26
+ 'commitlint.config.cjs',
27
+ '.commitlintrc.js',
28
+ '.commitlintrc.json',
29
+ '.commitlintrc.yml',
30
+ '.lintstagedrc',
31
+ 'lint-staged.config.js',
32
+ 'lint-staged.config.cjs',
33
+ '.nycrc',
34
+ '.nycrc.json',
35
+ '.nycrc.yaml',
36
+ '.nycrc.yml',
37
+ 'nyc.config.js',
38
+ 'nyc.config.cjs',
39
+ '.github/renovate.json',
40
+ '.github/renovate.json5',
41
+ '.gitlab/renovate.json',
42
+ '.gitlab/renovate.json5',
43
+ '.renovaterc.json',
44
+ 'renovate.json',
45
+ 'renovate.json5',
46
+ '.renovaterc',
47
+ '.travis.yml',
48
+ 'solano.yml',
49
+ 'yarn.lock',
50
+ ].sort()
@@ -0,0 +1,39 @@
1
+ const fs = require('../../util/projectFs.cjs')
2
+
3
+ async function preinstallUpdateProjectPackageJson() {
4
+ const { unset } = require('lodash')
5
+
6
+ const packageJson = await fs.readJson('package.json')
7
+ const { devDependencies } = packageJson
8
+
9
+ for (const path of [
10
+ 'exports',
11
+ 'files',
12
+ 'husky',
13
+ 'main',
14
+ 'module',
15
+ 'renovate',
16
+ 'prettier',
17
+ 'commitlint',
18
+ 'lint-staged',
19
+ 'nyc',
20
+ 'husky',
21
+ 'config.mocha',
22
+ ]) {
23
+ unset(packageJson, path)
24
+ }
25
+ if (devDependencies) {
26
+ for (const dep in Object.keys(devDependencies)) {
27
+ if (dep.startsWith('@babel/')) delete devDependencies[dep]
28
+ }
29
+ for (const dep of require('./preinstallRemoveDevDeps.cjs')) {
30
+ delete devDependencies[dep]
31
+ }
32
+ }
33
+
34
+ await fs.writeJson('package.json', packageJson, { spaces: 2 })
35
+ // eslint-disable-next-line no-console
36
+ console.error('updated package.json')
37
+ }
38
+
39
+ module.exports = preinstallUpdateProjectPackageJson