@jcoreio/toolchain 1.0.0-beta.7 → 1.0.0-beta.9

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.
File without changes
@@ -2,7 +2,7 @@ const Path = require('path')
2
2
  const { findGitDir } = require('../util/findUps.cjs')
3
3
  const execa = require('../util/execa.cjs')
4
4
 
5
- module.exports = async function runHook(hook) {
5
+ module.exports = async function runHook(hookName) {
6
6
  try {
7
7
  const gitDir = findGitDir()
8
8
  if (!gitDir) {
@@ -16,9 +16,13 @@ module.exports = async function runHook(hook) {
16
16
  } catch (error) {
17
17
  hooks = require('../githooks.cjs')
18
18
  }
19
+ const hook = hooks[hookName]
20
+ if (!hook) return
19
21
 
20
- if (hooks[hook]) {
21
- await execa(hooks[hook], {
22
+ if (typeof hook === 'function') {
23
+ await hook()
24
+ } else if (hook) {
25
+ await execa(hook, {
22
26
  cwd: projDir,
23
27
  shell: true,
24
28
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jcoreio/toolchain",
3
- "version": "1.0.0-beta.7",
3
+ "version": "1.0.0-beta.9",
4
4
  "description": "base JS build toolchain",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,14 +14,10 @@
14
14
  },
15
15
  "homepage": "https://github.com/jcoreio/toolchains/tree/beta/packages/base",
16
16
  "dependencies": {
17
- "@semantic-release/commit-analyzer": "^9.0.2",
18
- "@semantic-release/github": "^8.0.4",
19
- "@semantic-release/npm": "^10.0.4",
20
- "@semantic-release/release-notes-generator": "^10.0.3",
21
17
  "chalk": "^4.0.0",
22
18
  "dedent-js": "^1.0.1",
23
- "eslint": "^8.5.0",
24
- "eslint-config-prettier": "^8.3.0",
19
+ "eslint": "^8.43.0",
20
+ "eslint-config-prettier": "^8.8.0",
25
21
  "execa": "^5.0.0",
26
22
  "find-up": "^5.0.0",
27
23
  "fs-extra": "^10.0.0",
@@ -31,23 +27,23 @@
31
27
  "open": "^8.4.0",
32
28
  "prettier": "^2.5.1",
33
29
  "resolve-bin": "^1.0.0",
34
- "semantic-release": "^21.0.5",
35
30
  "semver": "^7.5.3",
36
31
  "toposort": "^2.0.2",
37
32
  "zod": "^3.21.4"
38
33
  },
39
34
  "toolchainManaged": {
35
+ "engines": {
36
+ "node": ">=16"
37
+ },
38
+ "packageManager": "pnpm@8.3.1",
40
39
  "devDependencies": {
41
40
  "eslint": "*"
42
41
  }
43
42
  },
44
43
  "bin": {
45
- "cz": "./bin/cz",
46
44
  "eslint": "./bin/eslint",
47
- "git-cz": "./bin/git-cz",
48
45
  "lint-staged": "./bin/lint-staged",
49
46
  "prettier": "./bin/prettier",
50
- "semantic-release": "./bin/semantic-release",
51
47
  "tc": "./scripts/toolchain.cjs",
52
48
  "toolchain": "./scripts/toolchain.cjs"
53
49
  },
@@ -30,12 +30,6 @@ module.exports = [
30
30
  }
31
31
  }
32
32
  `,
33
- 'release.config.js': dedent`
34
- /* eslint-env node, es2018 */
35
- module.exports = {
36
- extends: [require.resolve('${name}/release.config.cjs')],
37
- }
38
- `,
39
33
  }
40
34
  for (const file of [
41
35
  'githooks.cjs',
@@ -1,19 +1,28 @@
1
1
  const fs = require('../../util/projectFs.cjs')
2
- const getPluginsObject = require('../../util/getPluginsObject.cjs')
2
+ const path = require('path')
3
+ const getPluginsObjectAsync = require('../../util/getPluginsObjectAsync.cjs')
3
4
  const { name } = require('../../package.json')
4
5
 
5
6
  async function bootstrapConfigFiles() {
6
- const files = await getPluginsObject('getConfigFiles')
7
+ const files = await getPluginsObjectAsync('getConfigFiles')
7
8
  for (const file in files) {
8
9
  const value = files[file]
9
- const content = typeof value === 'string' ? value : value.content
10
- const overwrite = typeof value === 'string' ? false : value.overwrite
10
+ let content, overwrite
11
+ if (typeof value === 'function') {
12
+ const prev = await fs.readFile(file, 'utf8').catch(() => undefined)
13
+ content = await value(prev)
14
+ overwrite = content !== prev
15
+ } else {
16
+ content = typeof value === 'string' ? value : value.content
17
+ overwrite = typeof value === 'string' ? false : value.overwrite
18
+ }
11
19
  if (
12
20
  overwrite === true ||
13
21
  !(await fs.pathExists(file)) ||
14
22
  (content.includes(name) &&
15
23
  !(await fs.readFile(file, 'utf8')).includes(name))
16
24
  ) {
25
+ await fs.mkdirs(path.dirname(file))
17
26
  await fs.writeFile(file, content, 'utf8')
18
27
  // eslint-disable-next-line no-console
19
28
  console.error(`wrote ${file}`)
@@ -1,9 +1,10 @@
1
- const { name } = require('../../package.json')
2
- const { projectDir, toolchainPackages } = require('../../util/findUps.cjs')
1
+ const { toolchainManaged } = require('../../util/findUps.cjs')
3
2
  const getPluginsAsyncFunction = require('../../util/getPluginsAsyncFunction.cjs')
4
3
  const fs = require('../../util/projectFs.cjs')
5
4
  const sortDeps = require('../../util/sortDeps.cjs')
6
5
  const semver = require('semver')
6
+ const isEmpty = require('lodash/isEmpty')
7
+ const pick = require('lodash/pick')
7
8
 
8
9
  async function bootstrapProjectPackageJson() {
9
10
  const { merge, unset } = require('lodash')
@@ -12,41 +13,52 @@ async function bootstrapProjectPackageJson() {
12
13
  const devDependencies =
13
14
  packageJson.devDependencies || (packageJson.devDependencies = {})
14
15
 
15
- const toolchainManaged = {}
16
- for (const pkg of toolchainPackages) {
17
- const toolchainPkgJson = require(require.resolve(`${pkg}/package.json`, {
18
- paths: [projectDir],
19
- }))
20
- const toolchainPkgDeps = toolchainPkgJson.dependencies || {}
21
- const toolchainPkgDevDeps = toolchainPkgJson.devDependencies || {}
22
- if (toolchainPkgJson.toolchainManaged) {
23
- for (const section in toolchainPkgJson.toolchainManaged) {
24
- const sectionDeps = toolchainPkgJson.toolchainManaged[section]
25
- if (!toolchainManaged[section]) toolchainManaged[section] = {}
26
- for (const dep in sectionDeps) {
27
- let version = sectionDeps[dep]
28
- if (version === '*')
29
- version = toolchainPkgDevDeps[dep] || toolchainPkgDeps[dep]
30
- if (version !== '*') toolchainManaged[section][dep] = version
31
- }
32
- }
33
- }
34
- }
35
-
36
16
  for (const path of [
37
- 'exports',
17
+ 'commitlint',
18
+ 'config.commitizen',
19
+ 'config.eslint',
20
+ 'config.lint',
21
+ 'config.mocha',
22
+ 'config.prettier',
38
23
  'eslintConfig',
24
+ 'exports',
39
25
  'files',
40
26
  'husky',
27
+ 'husky',
28
+ 'lint-staged',
41
29
  'main',
42
30
  'module',
43
- 'renovate',
44
- 'prettier',
45
- 'commitlint',
46
- 'lint-staged',
47
31
  'nyc',
48
- 'husky',
49
- 'config.mocha',
32
+ 'prettier',
33
+ 'renovate',
34
+ 'scripts.build:cjs',
35
+ 'scripts.build:js',
36
+ 'scripts.build:mjs',
37
+ 'scripts.build:types',
38
+ 'scripts.build',
39
+ 'scripts.clean',
40
+ 'scripts.codecov',
41
+ 'scripts.coverage',
42
+ 'scripts.commitmsg',
43
+ 'scripts.flow:coverage',
44
+ 'scripts.flow:watch',
45
+ 'scripts.flow',
46
+ 'scripts.lint:fix',
47
+ 'scripts.lint:watch',
48
+ 'scripts.lint',
49
+ 'scripts.open:coverage',
50
+ 'scripts.precommit',
51
+ 'scripts.prepublishOnly',
52
+ 'scripts.prepush',
53
+ 'scripts.prettier:check',
54
+ 'scripts.prettier',
55
+ 'scripts.semantic-release',
56
+ 'scripts.test:debug',
57
+ 'scripts.test:watch',
58
+ 'scripts.test',
59
+ 'scripts.travis-deploy-once',
60
+ 'scripts.tsc:wath',
61
+ 'scripts.tsc',
50
62
  ]) {
51
63
  unset(packageJson, path)
52
64
  }
@@ -54,22 +66,26 @@ async function bootstrapProjectPackageJson() {
54
66
  delete devDependencies[dep]
55
67
  }
56
68
 
57
- merge(packageJson, {
58
- version: '0.0.0-development',
59
- sideEffects: false,
60
- scripts: {
61
- tc: 'toolchain',
62
- toolchain: 'toolchain',
63
- test: 'toolchain test',
64
- prepublishOnly:
65
- 'echo This package is meant to be published by semantic-release from the dist build directory. && exit 1',
66
- },
67
- config: {
68
- commitizen: { path: `${name}/commitizen.cjs` },
69
+ merge(
70
+ packageJson,
71
+ {
72
+ version: '0.0.0-development',
73
+ sideEffects: false,
74
+ scripts: {
75
+ tc: 'toolchain',
76
+ toolchain: 'toolchain',
77
+ test: 'toolchain test',
78
+ prepublishOnly:
79
+ 'echo This package is meant to be published by semantic-release from the dist build directory. && exit 1',
80
+ },
69
81
  },
70
- })
82
+ pick(toolchainManaged, 'engines', 'packageManager'),
83
+ pick(packageJson, 'engines')
84
+ )
85
+ if (isEmpty(packageJson.config)) delete packageJson.config
71
86
 
72
87
  for (const section in toolchainManaged) {
88
+ if (!section.endsWith('ependencies')) continue
73
89
  const managedSection = toolchainManaged[section]
74
90
  const pkgSectionName = section.replace(/^optionalD/, 'd')
75
91
  let pkgSection = packageJson[pkgSectionName]
@@ -82,10 +98,7 @@ async function bootstrapProjectPackageJson() {
82
98
  const versionRange = managedSection[dep]
83
99
  if (
84
100
  !pkgSection[dep] ||
85
- semver.gt(
86
- versionRange.replace(/^\D+/, ''),
87
- pkgSection[dep].replace(/^\D+/, '')
88
- )
101
+ !semver.satisfies(semver.minVersion(pkgSection[dep]), versionRange)
89
102
  ) {
90
103
  pkgSection[dep] = versionRange
91
104
  }
@@ -89,6 +89,8 @@ module.exports = [
89
89
  'babel-types',
90
90
  'babylon',
91
91
  'codecov',
92
+ 'commitizen',
93
+ 'cz-conventional-changelog',
92
94
  'coveralls',
93
95
  'eslint-watch',
94
96
  'flow-copy-source',
@@ -5,7 +5,7 @@ const getPluginsAsyncFunction = require('../util/getPluginsAsyncFunction.cjs')
5
5
 
6
6
  async function bootstrap(args = []) {
7
7
  const execa = require('../util/execa.cjs')
8
- const installGitHooks = require('./bootstrap/installGitHooks.cjs')
8
+ const installGitHooks = require('./install-git-hooks.cjs')
9
9
  const bootstrapProjectPackageJson = require('./bootstrap/bootstrapProjectPackageJson.cjs')
10
10
  const bootstrapEslintConfigs = require('./bootstrap/bootstrapEslintConfigs.cjs')
11
11
  const bootstrapConfigFiles = require('./bootstrap/bootstrapConfigFiles.cjs')
@@ -15,7 +15,7 @@ async function bootstrap(args = []) {
15
15
  const hasYarnOrNpmLockfile = require('../util/hasYarnOrNpmLockfile.cjs')
16
16
 
17
17
  await execa('git', ['init'])
18
- await installGitHooks()
18
+ await installGitHooks.run()
19
19
  await bootstrapProjectPackageJson()
20
20
  if (await hasYarnOrNpmLockfile()) {
21
21
  await execa('pnpm', ['import'])
package/scripts/check.cjs CHANGED
@@ -8,8 +8,9 @@ const fs = require('../util/projectFs.cjs')
8
8
  exports.run = async function check(args = []) {
9
9
  await require('../scripts/runPrettier.cjs').prettierCheck(args)
10
10
  await require('../scripts/runEslint.cjs').eslintCheck(args)
11
+ const isTest = Boolean(process.env.JCOREIO_TOOLCHAIN_TEST)
11
12
  if (devDependencies['flow-bin'] && (await fs.pathExists('.flowconfig'))) {
12
- await execa('flow')
13
+ await execa('flow', isTest ? ['check'] : [])
13
14
  }
14
15
  if (devDependencies['typescript'] && (await fs.pathExists('tsconfig.json'))) {
15
16
  await execa('tsc', ['--noEmit'])
package/scripts/init.cjs CHANGED
@@ -3,23 +3,29 @@
3
3
  const { packageJson } = require('../util/findUps.cjs')
4
4
  const preinstall = require('./preinstall.cjs')
5
5
  const execa = require('../util/execa.cjs')
6
+ const hasTSFiles = require('../util/hasTSFiles.cjs')
6
7
 
7
8
  async function init(args = []) {
8
9
  const { dependencies = {}, devDependencies = {} } = packageJson
9
10
  const toolchains = []
10
11
  const isBabel =
11
12
  devDependencies['@babel/core'] != null ||
12
- devDependencies['babel-core'] != null
13
- const isTS = isBabel && devDependencies.typescript != null
13
+ devDependencies['babel-core'] != null ||
14
+ devDependencies['@jcoreio/toolchain-esnext'] != null
15
+ const isTS = await hasTSFiles()
14
16
  const isFlow = isBabel && devDependencies['flow-bin'] != null
15
17
  const isReact = dependencies.react != null || devDependencies.react != null
16
18
  const isMocha = devDependencies['mocha'] != null
19
+ const isCircle = true // might be false someday
20
+ const isSemanticRelease = devDependencies['semantic-release'] != null
17
21
 
18
22
  if (isMocha) toolchains.push('@jcoreio/toolchain-mocha')
19
23
  if (isBabel) toolchains.push('@jcoreio/toolchain-esnext')
20
24
  if (isFlow) toolchains.push('@jcoreio/toolchain-flow')
21
25
  if (isTS) toolchains.push('@jcoreio/toolchain-typescript')
22
26
  if (isReact) toolchains.push('@jcoreio/toolchain-react')
27
+ if (isCircle) toolchains.push('@jcoreio/toolchain-circle')
28
+ if (isSemanticRelease) toolchains.push('@jcoreio/toolchain-semantic-release')
23
29
 
24
30
  const isTest = Boolean(process.env.JCOREIO_TOOLCHAIN_TEST)
25
31
 
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- const execa = require('../../util/execa.cjs')
3
+ const execa = require('../util/execa.cjs')
4
4
  const Path = require('path')
5
5
  const dedent = require('dedent-js')
6
- const { findGitDir } = require('../../util/findUps.cjs')
6
+ const { findGitDir } = require('../util/findUps.cjs')
7
7
  const fs = require('fs-extra')
8
8
 
9
- const githooksDir = Path.resolve(__dirname, '..', '..', 'githooks')
9
+ const githooksDir = Path.resolve(__dirname, '..', 'githooks')
10
10
 
11
11
  async function installGitHooks() {
12
12
  const gitDir = findGitDir()
@@ -15,7 +15,7 @@ async function installGitHooks() {
15
15
  console.warn(dedent`
16
16
  .git directory not found!
17
17
  git hooks could not be installed.
18
- after you run \`git init\`, try \`pnpm exec install-git-hooks\`.
18
+ after you run \`git init\`, try \`pnpm tc install-git-hooks\`.
19
19
  `)
20
20
  } else {
21
21
  // chmod in case pnpm doesn't preserve mode of hooks scripts
@@ -34,4 +34,6 @@ async function installGitHooks() {
34
34
  }
35
35
  }
36
36
 
37
- module.exports = installGitHooks
37
+ exports.description = 'install git hooks'
38
+
39
+ exports.run = installGitHooks
@@ -1,10 +1,10 @@
1
1
  const check = require('./check.cjs')
2
- const coverage = require('./coverage.cjs')
3
2
  const build = require('./build.cjs')
3
+ const scripts = require('./toolchain.cjs')
4
4
 
5
5
  exports.run = async function (args = []) {
6
6
  await check.run()
7
- await coverage.run()
7
+ if (scripts.coverage) await scripts.coverage.run()
8
8
  await build.run()
9
9
  }
10
10
 
@@ -2,13 +2,13 @@
2
2
 
3
3
  const { name, version } = require('../package.json')
4
4
  const chalk = require('chalk')
5
+ const getPluginsObjectSync = require('../util/getPluginsObjectSync.cjs')
5
6
 
6
7
  const scripts = {
7
8
  bootstrap: require('./bootstrap.cjs'),
8
9
  build: require('./build.cjs'),
9
10
  check: require('./check.cjs'),
10
11
  clean: require('./clean.cjs'),
11
- coverage: require('./coverage.cjs'),
12
12
  format: require('./format.cjs'),
13
13
  init: require('./init.cjs'),
14
14
  preinstall: require('./preinstall.cjs'),
@@ -16,7 +16,6 @@ const scripts = {
16
16
  'lint:fix': require('./lint-fix.cjs'),
17
17
  'open:coverage': require('./open-coverage.cjs'),
18
18
  prepublish: require('./prepublish.cjs'),
19
- test: require('./test.cjs'),
20
19
  version: {
21
20
  description: `print version of ${name}`,
22
21
  run: () => {
@@ -24,6 +23,8 @@ const scripts = {
24
23
  console.log(`${name}@${version}`)
25
24
  },
26
25
  },
26
+ 'install-git-hooks': require('./install-git-hooks.cjs'),
27
+ ...getPluginsObjectSync('scripts'),
27
28
  }
28
29
 
29
30
  exports.scripts = scripts
package/util/findUps.cjs CHANGED
@@ -1,6 +1,7 @@
1
1
  const findUp = require('find-up')
2
2
  const Path = require('path')
3
3
  const fs = require('fs-extra')
4
+ const merge = require('lodash/merge')
4
5
  const once = require('./once.cjs')
5
6
  const { name } = require('../package.json')
6
7
  const configSchema = require('./configSchema.cjs')
@@ -25,12 +26,19 @@ if (!packageJsonFile) {
25
26
  }
26
27
  exports.packageJsonFile = packageJsonFile
27
28
  const packageJson = (exports.packageJson = fs.readJsonSync(packageJsonFile))
28
- exports.projectDir = Path.dirname(packageJsonFile)
29
+ const projectDir = (exports.projectDir = Path.dirname(packageJsonFile))
29
30
 
30
- exports.toolchainPackages = [
31
+ const toolchainPackages = (exports.toolchainPackages = [
31
32
  ...Object.keys(packageJson.dependencies || {}),
32
33
  ...Object.keys(packageJson.devDependencies || {}),
33
- ].filter((dep) => dep.startsWith(name))
34
+ ].filter((dep) => dep.startsWith(name)))
35
+
36
+ const toolchainPackageJsons = (exports.toolchainPackageJsons = {})
37
+ for (const pkg of toolchainPackages) {
38
+ toolchainPackageJsons[pkg] = require(require.resolve(`${pkg}/package.json`, {
39
+ paths: [projectDir],
40
+ }))
41
+ }
34
42
 
35
43
  let toolchainConfigFile
36
44
  try {
@@ -59,3 +67,29 @@ try {
59
67
  }
60
68
 
61
69
  exports.toolchainConfig = toolchainConfig
70
+
71
+ const toolchainManaged = (exports.toolchainManaged = {})
72
+ for (const toolchainPkgJson of Object.values(toolchainPackageJsons)) {
73
+ const toolchainPkgDeps = toolchainPkgJson.dependencies || {}
74
+ const toolchainPkgDevDeps = toolchainPkgJson.devDependencies || {}
75
+ if (toolchainPkgJson.toolchainManaged) {
76
+ for (const section in toolchainPkgJson.toolchainManaged) {
77
+ if (!toolchainManaged[section]) toolchainManaged[section] = {}
78
+ const sectionCfg = toolchainPkgJson.toolchainManaged[section]
79
+ if (section.endsWith('ependencies')) {
80
+ for (const dep in sectionCfg) {
81
+ let version = sectionCfg[dep]
82
+ if (version === '*')
83
+ version = toolchainPkgDevDeps[dep] || toolchainPkgDeps[dep]
84
+ if (version !== '*') toolchainManaged[section][dep] = version
85
+ }
86
+ continue
87
+ }
88
+ if (sectionCfg && typeof sectionCfg === 'object') {
89
+ toolchainManaged[section] = merge(toolchainManaged[section], sectionCfg)
90
+ continue
91
+ }
92
+ toolchainManaged[section] = sectionCfg
93
+ }
94
+ }
95
+ }
@@ -0,0 +1,15 @@
1
+ const getPlugins = require('./getPlugins.cjs')
2
+
3
+ async function getPluginsObjectAsync(name, ...args) {
4
+ const plugins = getPlugins(name)
5
+ const result = {}
6
+ for (const plugin of plugins) {
7
+ Object.assign(
8
+ result,
9
+ typeof plugin === 'function' ? await plugin(...args) : plugin
10
+ )
11
+ }
12
+ return result
13
+ }
14
+
15
+ module.exports = getPluginsObjectAsync
@@ -0,0 +1,15 @@
1
+ const getPlugins = require('./getPlugins.cjs')
2
+
3
+ function getPluginsObjectSync(name, ...args) {
4
+ const plugins = getPlugins(name)
5
+ const result = {}
6
+ for (const plugin of plugins) {
7
+ Object.assign(
8
+ result,
9
+ typeof plugin === 'function' ? plugin(...args) : plugin
10
+ )
11
+ }
12
+ return result
13
+ }
14
+
15
+ module.exports = getPluginsObjectSync
@@ -0,0 +1,7 @@
1
+ const fs = require('./projectFs.cjs')
2
+ const once = require('./once.cjs')
3
+
4
+ module.exports = once(async function hasFlowFiles() {
5
+ const files = await fs.readdir('src')
6
+ return files.some((f) => /\.flow$/.test(f))
7
+ })
@@ -0,0 +1,7 @@
1
+ const fs = require('./projectFs.cjs')
2
+ const once = require('./once.cjs')
3
+
4
+ module.exports = once(async function hasTSFiles() {
5
+ const files = await fs.readdir('src')
6
+ return files.some((f) => /\.[cm]?tsx?$/.test(f))
7
+ })
@@ -3,5 +3,5 @@ const once = require('./once.cjs')
3
3
 
4
4
  module.exports = once(function hasTSSourcesSync() {
5
5
  const files = fs.readdirSync('src')
6
- return files.find((f) => /\.tsx?$/.test(f) && !/\.d\.tsx?$/.test(f)) != null
6
+ return files.some((f) => /\.[cm]?tsx?$/.test(f) && !/\.d\.[cm]?tsx?$/.test(f))
7
7
  })
@@ -1,16 +0,0 @@
1
- const { projectDir } = require('./util/findUps.cjs')
2
- const path = require('path')
3
-
4
- module.exports = {
5
- plugins: [
6
- require.resolve('@semantic-release/commit-analyzer'),
7
- require.resolve('@semantic-release/release-notes-generator'),
8
- [
9
- require.resolve('@semantic-release/npm'),
10
- {
11
- pkgRoot: path.join(projectDir, 'dist'),
12
- },
13
- ],
14
- require.resolve('@semantic-release/github'),
15
- ],
16
- }
@@ -1,12 +0,0 @@
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'
package/scripts/test.cjs DELETED
@@ -1,12 +0,0 @@
1
- const getPlugins = require('../util/getPlugins.cjs')
2
- const getPluginsAsyncFunction = require('../util/getPluginsAsyncFunction.cjs')
3
-
4
- exports.run = async function (args = []) {
5
- if (!getPlugins('test').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('test')(args)
11
- }
12
- exports.description = 'run tests'
@@ -1,12 +0,0 @@
1
- const getPlugins = require('./getPlugins.cjs')
2
-
3
- async function getPluginsObject(name, ...args) {
4
- const plugins = getPlugins(name)
5
- const result = {}
6
- for (const plugin of plugins) {
7
- Object.assign(result, await plugin(...args))
8
- }
9
- return result
10
- }
11
-
12
- module.exports = getPluginsObject