@jcoreio/toolchain 1.0.0-beta.8 → 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.
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.8",
3
+ "version": "1.0.0",
4
4
  "description": "base JS build toolchain",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,10 +14,6 @@
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
19
  "eslint": "^8.43.0",
@@ -31,12 +27,15 @@
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
  }
@@ -45,7 +44,6 @@
45
44
  "eslint": "./bin/eslint",
46
45
  "lint-staged": "./bin/lint-staged",
47
46
  "prettier": "./bin/prettier",
48
- "semantic-release": "./bin/semantic-release",
49
47
  "tc": "./scripts/toolchain.cjs",
50
48
  "toolchain": "./scripts/toolchain.cjs"
51
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,54 @@ 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
- }
16
+ await getPluginsAsyncFunction('bootstrapProjectPackageJson')(packageJson)
35
17
 
36
18
  for (const path of [
37
- 'exports',
19
+ 'commitlint',
20
+ 'config.commitizen',
21
+ 'config.eslint',
22
+ 'config.lint',
23
+ 'config.mocha',
24
+ 'config.prettier',
38
25
  'eslintConfig',
26
+ 'exports',
39
27
  'files',
40
28
  'husky',
29
+ 'husky',
30
+ 'lint-staged',
41
31
  'main',
42
32
  'module',
43
- 'renovate',
44
- 'prettier',
45
- 'commitlint',
46
- 'lint-staged',
47
33
  'nyc',
48
- 'husky',
49
- 'config.mocha',
34
+ 'prettier',
35
+ 'renovate',
36
+ 'scripts.build:cjs',
37
+ 'scripts.build:js',
38
+ 'scripts.build:mjs',
39
+ 'scripts.build:types',
40
+ 'scripts.build',
41
+ 'scripts.clean',
42
+ 'scripts.codecov',
43
+ 'scripts.coverage',
44
+ 'scripts.commitmsg',
45
+ 'scripts.flow:coverage',
46
+ 'scripts.flow:watch',
47
+ 'scripts.flow',
48
+ 'scripts.lint:fix',
49
+ 'scripts.lint:watch',
50
+ 'scripts.lint',
51
+ 'scripts.open:coverage',
52
+ 'scripts.precommit',
53
+ 'scripts.prepublishOnly',
54
+ 'scripts.prepush',
55
+ 'scripts.prettier:check',
56
+ 'scripts.prettier',
57
+ 'scripts.semantic-release',
58
+ 'scripts.test:debug',
59
+ 'scripts.test:watch',
60
+ 'scripts.test',
61
+ 'scripts.travis-deploy-once',
62
+ 'scripts.tsc:wath',
63
+ 'scripts.tsc',
50
64
  ]) {
51
65
  unset(packageJson, path)
52
66
  }
@@ -54,22 +68,26 @@ async function bootstrapProjectPackageJson() {
54
68
  delete devDependencies[dep]
55
69
  }
56
70
 
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` },
71
+ merge(
72
+ packageJson,
73
+ {
74
+ version: '0.0.0-development',
75
+ sideEffects: false,
76
+ scripts: {
77
+ tc: 'toolchain',
78
+ toolchain: 'toolchain',
79
+ test: 'toolchain test',
80
+ prepublishOnly:
81
+ 'echo This package is meant to be published by semantic-release from the dist build directory. && exit 1',
82
+ },
69
83
  },
70
- })
84
+ pick(toolchainManaged, 'engines', 'packageManager'),
85
+ pick(packageJson, 'engines')
86
+ )
87
+ if (isEmpty(packageJson.config)) delete packageJson.config
71
88
 
72
89
  for (const section in toolchainManaged) {
90
+ if (!section.endsWith('ependencies')) continue
73
91
  const managedSection = toolchainManaged[section]
74
92
  const pkgSectionName = section.replace(/^optionalD/, 'd')
75
93
  let pkgSection = packageJson[pkgSectionName]
@@ -82,18 +100,13 @@ async function bootstrapProjectPackageJson() {
82
100
  const versionRange = managedSection[dep]
83
101
  if (
84
102
  !pkgSection[dep] ||
85
- semver.gt(
86
- versionRange.replace(/^\D+/, ''),
87
- pkgSection[dep].replace(/^\D+/, '')
88
- )
103
+ !semver.satisfies(semver.minVersion(pkgSection[dep]), versionRange)
89
104
  ) {
90
105
  pkgSection[dep] = versionRange
91
106
  }
92
107
  }
93
108
  }
94
109
 
95
- await getPluginsAsyncFunction('bootstrapProjectPackageJson')(packageJson)
96
-
97
110
  sortDeps(packageJson)
98
111
 
99
112
  await fs.writeJson('package.json', packageJson, { spaces: 2 })
@@ -13,6 +13,7 @@ module.exports = [
13
13
  'commitlint.config.js',
14
14
  '.eslintignore',
15
15
  '.gitignore',
16
+ 'husky.config.js',
16
17
  '.lintstagedrc',
17
18
  'lint-staged.config.js',
18
19
  '.npmignore',
@@ -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
@@ -10,17 +10,22 @@ async function init(args = []) {
10
10
  const toolchains = []
11
11
  const isBabel =
12
12
  devDependencies['@babel/core'] != null ||
13
- devDependencies['babel-core'] != null
13
+ devDependencies['babel-core'] != null ||
14
+ devDependencies['@jcoreio/toolchain-esnext'] != null
14
15
  const isTS = await hasTSFiles()
15
16
  const isFlow = isBabel && devDependencies['flow-bin'] != null
16
17
  const isReact = dependencies.react != null || devDependencies.react != null
17
18
  const isMocha = devDependencies['mocha'] != null
19
+ const isCircle = true // might be false someday
20
+ const isSemanticRelease = devDependencies['semantic-release'] != null
18
21
 
19
22
  if (isMocha) toolchains.push('@jcoreio/toolchain-mocha')
20
23
  if (isBabel) toolchains.push('@jcoreio/toolchain-esnext')
21
24
  if (isFlow) toolchains.push('@jcoreio/toolchain-flow')
22
25
  if (isTS) toolchains.push('@jcoreio/toolchain-typescript')
23
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')
24
29
 
25
30
  const isTest = Boolean(process.env.JCOREIO_TOOLCHAIN_TEST)
26
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')
4
3
 
5
4
  exports.run = async function (args = []) {
6
5
  await check.run()
7
- await coverage.run()
6
+ const { scripts } = require('./toolchain.cjs')
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/execa.cjs CHANGED
@@ -14,7 +14,7 @@ function extractCommand(command) {
14
14
  return match ? match[0] : command
15
15
  }
16
16
 
17
- module.exports = async function defaultExeca(command, args, options, ...rest) {
17
+ function getExecaArgs(command, args, options, ...rest) {
18
18
  if (args instanceof Object && !Array.isArray(args)) {
19
19
  options = args
20
20
  args = []
@@ -46,27 +46,53 @@ module.exports = async function defaultExeca(command, args, options, ...rest) {
46
46
  },
47
47
  }
48
48
 
49
- const child = execa(command, args, opts, ...rest)
50
- child.then(
49
+ return [command, args, opts, ...rest]
50
+ }
51
+
52
+ function convertExecaError(command, error) {
53
+ const { code, signal } = error
54
+ if (code) {
55
+ error.message = chalk`{red ✖} {bold ${extractCommand(
56
+ command
57
+ )}} exited with code ${code}`
58
+ }
59
+ if (signal) {
60
+ error.message = chalk`{red ✖} {bold ${extractCommand(
61
+ command
62
+ )}} was killed with signal ${signal}`
63
+ }
64
+ return error
65
+ }
66
+
67
+ function logSuccess(command) {
68
+ // eslint-disable-next-line no-console
69
+ console.error(
70
+ chalk`{green ✔} {bold ${extractCommand(command)}} exited with code 0`
71
+ )
72
+ }
73
+
74
+ function defaultExeca(command, args, options, ...rest) {
75
+ return execa(...getExecaArgs(command, args, options, ...rest)).then(
51
76
  (result) => {
52
- // eslint-disable-next-line no-console
53
- console.error(
54
- chalk`{green ✔} {bold ${extractCommand(command)}} exited with code 0`
55
- )
77
+ logSuccess(command)
78
+ return result
56
79
  },
57
80
  (error) => {
58
- const { code, signal } = error
59
- if (code) {
60
- error.message = chalk`{red ✖} {bold ${extractCommand(
61
- command
62
- )}} exited with code ${code}`
63
- }
64
- if (signal) {
65
- error.message = chalk`{red ✖} {bold ${extractCommand(
66
- command
67
- )}} was killed with signal ${signal}`
68
- }
81
+ throw convertExecaError(command, error)
69
82
  }
70
83
  )
71
- return child
72
84
  }
85
+
86
+ function defaultExecaSync(command, args, options, ...rest) {
87
+ try {
88
+ const result = execa.sync(...getExecaArgs(command, args, options, ...rest))
89
+ logSuccess(command)
90
+ return result
91
+ } catch (error) {
92
+ throw convertExecaError(command, error)
93
+ }
94
+ }
95
+
96
+ defaultExeca.sync = defaultExecaSync
97
+
98
+ module.exports = defaultExeca
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
@@ -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