@npmcli/template-oss 4.21.4 → 4.23.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.
- package/bin/apply.js +2 -5
- package/bin/check.js +2 -4
- package/bin/release-manager.js +1 -1
- package/bin/release-please.js +22 -18
- package/lib/apply/apply-files.js +14 -19
- package/lib/apply/apply-version.js +1 -5
- package/lib/apply/index.js +1 -4
- package/lib/check/check-apply.js +38 -39
- package/lib/check/check-changelog.js +1 -4
- package/lib/check/check-engines.js +5 -6
- package/lib/check/check-gitignore.js +14 -14
- package/lib/check/check-required.js +13 -15
- package/lib/check/check-unwanted.js +2 -3
- package/lib/check/index.js +9 -8
- package/lib/config.js +86 -35
- package/lib/content/LICENSE-md.hbs +2 -2
- package/lib/content/_job-matrix-yml.hbs +10 -0
- package/lib/content/_job-release-integration-yml.hbs +5 -10
- package/lib/content/_step-git-yml.hbs +1 -1
- package/lib/content/_step-node-yml.hbs +1 -1
- package/lib/content/action-create-check-yml.hbs +1 -1
- package/lib/content/ci-release-yml.hbs +2 -2
- package/lib/content/eslintrc-js.hbs +4 -5
- package/lib/content/gitignore.hbs +0 -3
- package/lib/content/index.js +39 -38
- package/lib/content/package-json.hbs +12 -2
- package/lib/content/prettier-js.hbs +6 -0
- package/lib/content/prettierignore.hbs +3 -0
- package/lib/content/release-yml.hbs +3 -3
- package/lib/index.js +3 -3
- package/lib/release/changelog.js +41 -44
- package/lib/release/node-workspace-format.js +29 -16
- package/lib/release/release-manager.js +61 -76
- package/lib/release/release-please.js +50 -61
- package/lib/release/util.js +11 -8
- package/lib/util/ci-versions.js +3 -3
- package/lib/util/dependabot.js +2 -2
- package/lib/util/files.js +34 -32
- package/lib/util/git.js +8 -5
- package/lib/util/gitignore.js +13 -11
- package/lib/util/has-package.js +7 -12
- package/lib/util/import-or-require.js +1 -1
- package/lib/util/json-diff.js +22 -21
- package/lib/util/merge.js +19 -16
- package/lib/util/output.js +8 -5
- package/lib/util/parser.js +86 -70
- package/lib/util/path.js +4 -4
- package/lib/util/template.js +13 -9
- package/package.json +13 -8
- package/lib/release/node-workspace.js +0 -103
package/bin/apply.js
CHANGED
|
@@ -3,10 +3,7 @@
|
|
|
3
3
|
const apply = require('../lib/apply/index.js')
|
|
4
4
|
|
|
5
5
|
const main = async () => {
|
|
6
|
-
const {
|
|
7
|
-
npm_config_global: globalMode,
|
|
8
|
-
npm_config_local_prefix: root,
|
|
9
|
-
} = process.env
|
|
6
|
+
const { npm_config_global: globalMode, npm_config_local_prefix: root } = process.env
|
|
10
7
|
|
|
11
8
|
// do nothing in global mode or when the local prefix isn't set
|
|
12
9
|
if (globalMode === 'true' || !root) {
|
|
@@ -16,7 +13,7 @@ const main = async () => {
|
|
|
16
13
|
await apply(root)
|
|
17
14
|
}
|
|
18
15
|
|
|
19
|
-
module.exports = main().catch(
|
|
16
|
+
module.exports = main().catch(err => {
|
|
20
17
|
console.error(err.stack)
|
|
21
18
|
process.exitCode = 1
|
|
22
19
|
})
|
package/bin/check.js
CHANGED
|
@@ -4,9 +4,7 @@ const check = require('../lib/check/index.js')
|
|
|
4
4
|
const output = require('../lib/util/output.js')
|
|
5
5
|
|
|
6
6
|
const main = async () => {
|
|
7
|
-
const {
|
|
8
|
-
npm_config_local_prefix: root,
|
|
9
|
-
} = process.env
|
|
7
|
+
const { npm_config_local_prefix: root } = process.env
|
|
10
8
|
|
|
11
9
|
if (!root) {
|
|
12
10
|
throw new Error('This package requires npm >7.21.1')
|
|
@@ -20,7 +18,7 @@ const main = async () => {
|
|
|
20
18
|
}
|
|
21
19
|
}
|
|
22
20
|
|
|
23
|
-
module.exports = main().catch(
|
|
21
|
+
module.exports = main().catch(err => {
|
|
24
22
|
console.error(err.stack)
|
|
25
23
|
process.exitCode = 1
|
|
26
24
|
})
|
package/bin/release-manager.js
CHANGED
package/bin/release-please.js
CHANGED
|
@@ -18,23 +18,27 @@ ReleasePlease.run({
|
|
|
18
18
|
// `RELEASE_PLEASE_<manfiestOverrideConfigName>`
|
|
19
19
|
// (eg`RELEASE_PLEASE_lastReleaseSha=<SHA>`) to set one-off config items for
|
|
20
20
|
// the release please run without needing to commit and push the config.
|
|
21
|
-
overrides: Object.fromEntries(
|
|
22
|
-
.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
21
|
+
overrides: Object.fromEntries(
|
|
22
|
+
Object.entries(process.env)
|
|
23
|
+
.filter(([k, v]) => k.startsWith('RELEASE_PLEASE_') && v != null)
|
|
24
|
+
.map(([k, v]) => [k.replace('RELEASE_PLEASE_', ''), v]),
|
|
25
|
+
),
|
|
26
|
+
})
|
|
27
|
+
.then(({ pr, releases }) => {
|
|
28
|
+
if (pr) {
|
|
29
|
+
core.setOutput('pr', JSON.stringify(pr))
|
|
30
|
+
core.setOutput('pr-branch', pr.headBranchName)
|
|
31
|
+
core.setOutput('pr-number', pr.number)
|
|
32
|
+
core.setOutput('pr-sha', pr.sha)
|
|
33
|
+
}
|
|
31
34
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
if (releases) {
|
|
36
|
+
core.setOutput('releases', JSON.stringify(releases))
|
|
37
|
+
}
|
|
35
38
|
|
|
36
|
-
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
return null
|
|
40
|
+
})
|
|
41
|
+
.catch(err => {
|
|
42
|
+
core.setFailed('Release Please failed')
|
|
43
|
+
core.error(err)
|
|
44
|
+
})
|
package/lib/apply/apply-files.js
CHANGED
|
@@ -6,26 +6,21 @@ const run = async (dir, files, options) => {
|
|
|
6
6
|
const { rm, add } = files
|
|
7
7
|
|
|
8
8
|
log.verbose('apply-files', 'rm', rm)
|
|
9
|
-
await rmEach(dir, rm, options,
|
|
9
|
+
await rmEach(dir, rm, options, f => fs.rm(f))
|
|
10
10
|
|
|
11
11
|
log.verbose('apply-files', 'add', add)
|
|
12
|
-
await parseEach(dir, add, options, {},
|
|
12
|
+
await parseEach(dir, add, options, {}, p => p.applyWrite())
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
module.exports = [
|
|
16
|
-
|
|
17
|
-
options.config.repoDir,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
},
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
options
|
|
28
|
-
),
|
|
29
|
-
when: ({ config: c }) => c.applyModule && c.needsUpdate,
|
|
30
|
-
name: 'apply-module',
|
|
31
|
-
}]
|
|
15
|
+
module.exports = [
|
|
16
|
+
{
|
|
17
|
+
run: options => run(options.config.repoDir, options.config.repoFiles, options),
|
|
18
|
+
when: ({ config: c }) => c.applyRepo && c.needsUpdate,
|
|
19
|
+
name: 'apply-repo',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
run: options => run(options.config.moduleDir, options.config.moduleFiles, options),
|
|
23
|
+
when: ({ config: c }) => c.applyModule && c.needsUpdate,
|
|
24
|
+
name: 'apply-module',
|
|
25
|
+
},
|
|
26
|
+
]
|
|
@@ -2,11 +2,7 @@ const { log } = require('proc-log')
|
|
|
2
2
|
const PackageJson = require('@npmcli/package-json')
|
|
3
3
|
|
|
4
4
|
const run = async ({ config: c }) => {
|
|
5
|
-
const {
|
|
6
|
-
moduleDir: dir,
|
|
7
|
-
__CONFIG_KEY__: key,
|
|
8
|
-
__VERSION__: version,
|
|
9
|
-
} = c
|
|
5
|
+
const { moduleDir: dir, __CONFIG_KEY__: key, __VERSION__: version } = c
|
|
10
6
|
|
|
11
7
|
log.verbose('apply-version', dir)
|
|
12
8
|
|
package/lib/apply/index.js
CHANGED
package/lib/check/check-apply.js
CHANGED
|
@@ -8,23 +8,25 @@ const solution = 'npx template-oss-apply --force'
|
|
|
8
8
|
|
|
9
9
|
const run = async (type, dir, files, options) => {
|
|
10
10
|
const res = []
|
|
11
|
-
const rel =
|
|
11
|
+
const rel = f => relative(options.root, f)
|
|
12
12
|
const { add: addFiles, rm: rmFiles } = files
|
|
13
13
|
|
|
14
|
-
const rm = await rmEach(dir, rmFiles, options,
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
14
|
+
const rm = await rmEach(dir, rmFiles, options, f => rel(f))
|
|
15
|
+
const [add, update] = partition(
|
|
16
|
+
await parseEach(dir, addFiles, options, {}, async p => {
|
|
17
|
+
const diff = await p.applyDiff()
|
|
18
|
+
const target = rel(p.target)
|
|
19
|
+
if (diff === null) {
|
|
20
|
+
// needs to be added
|
|
21
|
+
return target
|
|
22
|
+
} else if (diff === true) {
|
|
23
|
+
// its ok, no diff, this is filtered out
|
|
24
|
+
return null
|
|
25
|
+
}
|
|
26
|
+
return { file: target, diff }
|
|
27
|
+
}),
|
|
28
|
+
d => typeof d === 'string',
|
|
29
|
+
)
|
|
28
30
|
|
|
29
31
|
log.verbose('check-apply', 'rm', rm)
|
|
30
32
|
if (rm.length) {
|
|
@@ -45,31 +47,28 @@ const run = async (type, dir, files, options) => {
|
|
|
45
47
|
}
|
|
46
48
|
|
|
47
49
|
log.verbose('check-apply', 'update', update)
|
|
48
|
-
res.push(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
res.push(
|
|
51
|
+
...update
|
|
52
|
+
.sort((a, b) => localeCompare(a.file, b.file))
|
|
53
|
+
.map(({ file, diff }) => ({
|
|
54
|
+
title: `The ${type} file ${basename(file)} needs to be updated:`,
|
|
55
|
+
body: [`${file}\n${'='.repeat(40)}\n${diff}`],
|
|
56
|
+
solution,
|
|
57
|
+
})),
|
|
58
|
+
)
|
|
53
59
|
|
|
54
60
|
return res
|
|
55
61
|
}
|
|
56
62
|
|
|
57
|
-
module.exports = [
|
|
58
|
-
|
|
59
|
-
'repo',
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
options.config.moduleDir,
|
|
70
|
-
options.config.moduleFiles,
|
|
71
|
-
options
|
|
72
|
-
),
|
|
73
|
-
when: ({ config: c }) => c.applyModule,
|
|
74
|
-
name: 'check-module',
|
|
75
|
-
}]
|
|
63
|
+
module.exports = [
|
|
64
|
+
{
|
|
65
|
+
run: options => run('repo', options.config.repoDir, options.config.repoFiles, options),
|
|
66
|
+
when: ({ config: c }) => c.applyRepo,
|
|
67
|
+
name: 'check-repo',
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
run: options => run('module', options.config.moduleDir, options.config.moduleFiles, options),
|
|
71
|
+
when: ({ config: c }) => c.applyModule,
|
|
72
|
+
name: 'check-module',
|
|
73
|
+
},
|
|
74
|
+
]
|
|
@@ -14,10 +14,7 @@ const run = async ({ root, path }) => {
|
|
|
14
14
|
if (!mustStart.test(content)) {
|
|
15
15
|
return {
|
|
16
16
|
title: `The ${relative(root, changelog)} is incorrect:`,
|
|
17
|
-
body: [
|
|
18
|
-
'The changelog should start with',
|
|
19
|
-
`"# Changelog\n\n#"`,
|
|
20
|
-
],
|
|
17
|
+
body: ['The changelog should start with', `"# Changelog\n\n#"`],
|
|
21
18
|
solution: 'reformat the changelog to have the correct heading',
|
|
22
19
|
}
|
|
23
20
|
}
|
|
@@ -27,15 +27,14 @@ const run = async ({ root, path, pkg, config: { omitEngines = [] } }) => {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
if (invalid.length) {
|
|
30
|
-
const title =
|
|
30
|
+
const title =
|
|
31
|
+
`The following production dependencies are not compatible with ` +
|
|
31
32
|
`\`engines.node: ${engines}\` found in \`${pkgPath}\`:`
|
|
32
33
|
return {
|
|
33
34
|
title,
|
|
34
|
-
body: invalid
|
|
35
|
-
`${dep.name}:`,
|
|
36
|
-
|
|
37
|
-
` location: ${dep.location}`,
|
|
38
|
-
].join('\n')).join('\n'),
|
|
35
|
+
body: invalid
|
|
36
|
+
.map(dep => [`${dep.name}:`, ` engines.node: ${dep.engines}`, ` location: ${dep.location}`].join('\n'))
|
|
37
|
+
.join('\n'),
|
|
39
38
|
solution: 'Remove them or move them to devDependencies.',
|
|
40
39
|
}
|
|
41
40
|
}
|
|
@@ -13,34 +13,34 @@ const NAME = 'check-gitignore'
|
|
|
13
13
|
const run = async ({ root, path, config }) => {
|
|
14
14
|
log.verbose(NAME, { root, path })
|
|
15
15
|
|
|
16
|
-
const relativeToRoot =
|
|
16
|
+
const relativeToRoot = f => relative(root, resolve(path, f))
|
|
17
17
|
|
|
18
18
|
// use the root to detect a git repo but the project directory (path) for the
|
|
19
19
|
// ignore check
|
|
20
20
|
const ignoreFile = resolve(path, '.gitignore')
|
|
21
|
-
if (!await git.is({ cwd: root }) || !existsSync(ignoreFile)) {
|
|
21
|
+
if (!(await git.is({ cwd: root })) || !existsSync(ignoreFile)) {
|
|
22
22
|
log.verbose(NAME, 'no git or no gitignore')
|
|
23
23
|
return null
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
log.verbose(NAME, `using ignore file ${ignoreFile}`)
|
|
27
27
|
|
|
28
|
-
const res = await git.spawn(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
const res = await git.spawn(
|
|
29
|
+
[
|
|
30
|
+
'ls-files',
|
|
31
|
+
'--cached',
|
|
32
|
+
'--ignored',
|
|
33
|
+
// https://git-scm.com/docs/git-ls-files#_exclude_patterns
|
|
34
|
+
`--${config.isRoot ? 'exclude-from' : 'exclude-per-directory'}=${basename(ignoreFile)}`,
|
|
35
|
+
],
|
|
36
|
+
{ cwd: path },
|
|
37
|
+
)
|
|
35
38
|
|
|
36
39
|
log.verbose(NAME, 'ls-files', res)
|
|
37
40
|
|
|
38
41
|
// TODO: files should be filtered if they have already been moved/deleted
|
|
39
42
|
// but not committed. Currently you must commit for this check to pass.
|
|
40
|
-
const files = res.stdout
|
|
41
|
-
.trim()
|
|
42
|
-
.split('\n')
|
|
43
|
-
.filter(Boolean)
|
|
43
|
+
const files = res.stdout.trim().split('\n').filter(Boolean)
|
|
44
44
|
|
|
45
45
|
if (!files.length) {
|
|
46
46
|
return null
|
|
@@ -49,7 +49,7 @@ const run = async ({ root, path, config }) => {
|
|
|
49
49
|
const ignores = (await fs.readFile(ignoreFile))
|
|
50
50
|
.toString()
|
|
51
51
|
.split(/\r?\n/)
|
|
52
|
-
.filter(
|
|
52
|
+
.filter(l => l && !l.trim().startsWith('#'))
|
|
53
53
|
|
|
54
54
|
const relIgnore = relativeToRoot(ignoreFile)
|
|
55
55
|
|
|
@@ -3,25 +3,21 @@ const npa = require('npm-package-arg')
|
|
|
3
3
|
const { partition } = require('lodash')
|
|
4
4
|
const hasPackage = require('../util/has-package.js')
|
|
5
5
|
|
|
6
|
-
const rmCommand = (
|
|
7
|
-
`npm rm ${specs.map((s) => s.name).join(' ')}`.trim()
|
|
6
|
+
const rmCommand = specs => `npm rm ${specs.map(s => s.name).join(' ')}`.trim()
|
|
8
7
|
|
|
9
|
-
const installCommand = (specs, flags) =>
|
|
10
|
-
`npm i ${specs.map(
|
|
8
|
+
const installCommand = (specs, flags) =>
|
|
9
|
+
specs.length ? `npm i ${specs.map(s => `${s.name}@${s.fetchSpec}`).join(' ')} ${flags.join(' ')}`.trim() : ''
|
|
11
10
|
|
|
12
11
|
// ensure required packages are present in the correct place
|
|
13
12
|
const run = ({ pkg, path, config: { requiredPackages = {} } }) => {
|
|
14
13
|
// keys are the dependency location in package.json
|
|
15
14
|
// values are a filtered list of parsed specs that dont exist in the current package
|
|
16
15
|
// { [location]: [spec1, spec2] }
|
|
17
|
-
const requiredByLocation = Object.entries(requiredPackages)
|
|
18
|
-
.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
log.verbose(location, pkg, pkgs)
|
|
23
|
-
return acc
|
|
24
|
-
}, {})
|
|
16
|
+
const requiredByLocation = Object.entries(requiredPackages).reduce((acc, [location, pkgs]) => {
|
|
17
|
+
acc[location] = pkgs.filter(spec => !hasPackage(pkg, spec, [location], path)).map(spec => npa(spec))
|
|
18
|
+
log.verbose(location, pkg, pkgs)
|
|
19
|
+
return acc
|
|
20
|
+
}, {})
|
|
25
21
|
|
|
26
22
|
const requiredEntries = Object.entries(requiredByLocation)
|
|
27
23
|
|
|
@@ -30,19 +26,21 @@ const run = ({ pkg, path, config: { requiredPackages = {} } }) => {
|
|
|
30
26
|
if (requiredEntries.flatMap(([, specs]) => specs).length) {
|
|
31
27
|
return requiredEntries.map(([location, specs]) => {
|
|
32
28
|
const locationFlag = hasPackage.flags[location]
|
|
33
|
-
const [exactSpecs, saveSpecs] = partition(specs,
|
|
29
|
+
const [exactSpecs, saveSpecs] = partition(specs, s => s.type === 'version')
|
|
34
30
|
|
|
35
31
|
log.verbose('check-required', location, specs)
|
|
36
32
|
|
|
37
33
|
return {
|
|
38
34
|
title: `The following required ${location} were not found:`,
|
|
39
|
-
body: specs.map(
|
|
35
|
+
body: specs.map(s => (s.rawSpec === '*' ? s.name : `${s.name}@${s.rawSpec}`)),
|
|
40
36
|
// solution is to remove any existing all at once but add back in by --save-<location>
|
|
41
37
|
solution: [
|
|
42
38
|
rmCommand(specs),
|
|
43
39
|
installCommand(saveSpecs, [locationFlag]),
|
|
44
40
|
installCommand(exactSpecs, [locationFlag, '--save-exact']),
|
|
45
|
-
]
|
|
41
|
+
]
|
|
42
|
+
.filter(Boolean)
|
|
43
|
+
.join(' && '),
|
|
46
44
|
}
|
|
47
45
|
})
|
|
48
46
|
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
|
|
2
1
|
const hasPackage = require('../util/has-package.js')
|
|
3
2
|
|
|
4
3
|
const run = ({ pkg, config: { allowedPackages = [], unwantedPackages = [] } }) => {
|
|
5
4
|
// ensure packages that should not be present are removed
|
|
6
5
|
const hasUnwanted = unwantedPackages
|
|
7
|
-
.filter(
|
|
8
|
-
.filter(
|
|
6
|
+
.filter(name => !allowedPackages.includes(name))
|
|
7
|
+
.filter(name => hasPackage(pkg, name))
|
|
9
8
|
|
|
10
9
|
if (hasUnwanted.length) {
|
|
11
10
|
return {
|
package/lib/check/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
const run = require('../index.js')
|
|
2
2
|
|
|
3
|
-
module.exports =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
module.exports = root =>
|
|
4
|
+
run(root, [
|
|
5
|
+
require('./check-apply.js'),
|
|
6
|
+
require('./check-required.js'),
|
|
7
|
+
require('./check-unwanted.js'),
|
|
8
|
+
require('./check-gitignore.js'),
|
|
9
|
+
require('./check-changelog.js'),
|
|
10
|
+
require('./check-engines.js'),
|
|
11
|
+
])
|
package/lib/config.js
CHANGED
|
@@ -16,15 +16,24 @@ const { name: NAME, version: LATEST_VERSION } = require('../package.json')
|
|
|
16
16
|
const CONFIG_KEY = 'templateOSS'
|
|
17
17
|
const MERGE_KEYS = [...FILE_KEYS, 'defaultContent', 'content']
|
|
18
18
|
const DEFAULT_CONTENT = require.resolve(NAME)
|
|
19
|
-
const getPkgConfig =
|
|
19
|
+
const getPkgConfig = pkg => pkg[CONFIG_KEY] || {}
|
|
20
20
|
|
|
21
21
|
const merge = mergeWithCustomizers(
|
|
22
|
-
customizers.mergeArrays(
|
|
22
|
+
customizers.mergeArrays(
|
|
23
|
+
'branches',
|
|
24
|
+
'distPaths',
|
|
25
|
+
'allowPaths',
|
|
26
|
+
'ignorePaths',
|
|
27
|
+
'lintIgnorePaths',
|
|
28
|
+
'lintExtensions',
|
|
29
|
+
'formatIgnorePaths',
|
|
30
|
+
'formatExtensions',
|
|
31
|
+
),
|
|
23
32
|
(value, srcValue, key) => {
|
|
24
33
|
if (key === 'ciVersions' && (Array.isArray(srcValue) || isPlainObject(srcValue))) {
|
|
25
34
|
return { ...ciVersions.parse(value), ...ciVersions.parse(srcValue) }
|
|
26
35
|
}
|
|
27
|
-
}
|
|
36
|
+
},
|
|
28
37
|
)
|
|
29
38
|
|
|
30
39
|
const mergeConfigs = (...configs) => {
|
|
@@ -39,7 +48,7 @@ const mergeConfigs = (...configs) => {
|
|
|
39
48
|
})
|
|
40
49
|
}
|
|
41
50
|
|
|
42
|
-
const readContentPath = async
|
|
51
|
+
const readContentPath = async path => {
|
|
43
52
|
if (!path) {
|
|
44
53
|
return {}
|
|
45
54
|
}
|
|
@@ -62,10 +71,7 @@ const getFiles = async (path, rawConfig, templateSettings) => {
|
|
|
62
71
|
if (!dir) {
|
|
63
72
|
return []
|
|
64
73
|
}
|
|
65
|
-
return [
|
|
66
|
-
parseFiles(pick(content, FILE_KEYS), dir, pick(rawConfig, FILE_KEYS), templateSettings),
|
|
67
|
-
dir,
|
|
68
|
-
]
|
|
74
|
+
return [parseFiles(pick(content, FILE_KEYS), dir, pick(rawConfig, FILE_KEYS), templateSettings), dir]
|
|
69
75
|
}
|
|
70
76
|
|
|
71
77
|
const getFullConfig = async ({
|
|
@@ -115,13 +121,11 @@ const getFullConfig = async ({
|
|
|
115
121
|
const publicPkgs = pkgs.filter(p => !p.pkgJson.private)
|
|
116
122
|
const allPrivate = pkgs.every(p => p.pkgJson.private)
|
|
117
123
|
|
|
118
|
-
const branches = uniq([...pkgConfig.branches ?? [], pkgConfig.releaseBranch]).filter(Boolean)
|
|
124
|
+
const branches = uniq([...(pkgConfig.branches ?? []), pkgConfig.releaseBranch]).filter(Boolean)
|
|
119
125
|
const gitBranches = await git.getBranches(rootPkg.path, branches)
|
|
120
|
-
const defaultBranch = await git.defaultBranch(rootPkg.path) ?? 'main'
|
|
126
|
+
const defaultBranch = (await git.defaultBranch(rootPkg.path)) ?? 'main'
|
|
121
127
|
const isReleaseBranch = !!pkgConfig.backport
|
|
122
|
-
const releaseBranch = isReleaseBranch
|
|
123
|
-
? pkgConfig.releaseBranch.replace(/\*/g, pkgConfig.backport)
|
|
124
|
-
: defaultBranch
|
|
128
|
+
const releaseBranch = isReleaseBranch ? pkgConfig.releaseBranch.replace(/\*/g, pkgConfig.backport) : defaultBranch
|
|
125
129
|
|
|
126
130
|
const esm = pkg.pkgJson?.type === 'module' || !!pkgConfig.typescript || !!pkgConfig.esm
|
|
127
131
|
|
|
@@ -192,21 +196,47 @@ const getFullConfig = async ({
|
|
|
192
196
|
}
|
|
193
197
|
|
|
194
198
|
if (!pkgConfig.eslint && Array.isArray(pkgConfig.requiredPackages?.devDependencies)) {
|
|
195
|
-
pkgConfig.requiredPackages.devDependencies =
|
|
196
|
-
|
|
199
|
+
pkgConfig.requiredPackages.devDependencies = pkgConfig.requiredPackages.devDependencies.filter(
|
|
200
|
+
p => !p.includes('eslint'),
|
|
201
|
+
)
|
|
197
202
|
}
|
|
198
203
|
|
|
204
|
+
pkgConfig.lintIgnorePaths = [
|
|
205
|
+
...(pkgConfig.ignorePaths || []),
|
|
206
|
+
...(pkgConfig.lintIgnorePaths || []),
|
|
207
|
+
...derived.workspaceGlobs,
|
|
208
|
+
]
|
|
209
|
+
|
|
210
|
+
pkgConfig.formatIgnorePaths = [
|
|
211
|
+
...(pkgConfig.ignorePaths || []),
|
|
212
|
+
...(pkgConfig.formatIgnorePaths || []),
|
|
213
|
+
...derived.workspaceGlobs,
|
|
214
|
+
]
|
|
215
|
+
|
|
199
216
|
if (pkgConfig.typescript) {
|
|
200
217
|
defaultsDeep(pkgConfig, { allowPaths: [], requiredPackages: { devDependencies: [] } })
|
|
201
218
|
pkgConfig.distPaths = ['dist/']
|
|
219
|
+
pkgConfig.lintIgnorePaths = uniq([...pkgConfig.lintIgnorePaths, 'dist/'])
|
|
220
|
+
pkgConfig.formatIgnorePaths = uniq([...pkgConfig.formatIgnorePaths, 'dist/'])
|
|
202
221
|
pkgConfig.allowDistPaths = false
|
|
203
|
-
pkgConfig.allowPaths.
|
|
204
|
-
pkgConfig.requiredPackages.devDependencies
|
|
222
|
+
pkgConfig.allowPaths = uniq([...pkgConfig.allowPaths, '/src/'])
|
|
223
|
+
pkgConfig.requiredPackages.devDependencies = uniq([
|
|
224
|
+
...pkgConfig.requiredPackages.devDependencies,
|
|
205
225
|
'typescript',
|
|
206
226
|
'tshy',
|
|
207
227
|
'@typescript-eslint/parser',
|
|
208
|
-
...derived.tap16 ? ['c8', 'ts-node'] : []
|
|
209
|
-
)
|
|
228
|
+
...(derived.tap16 ? ['c8', 'ts-node'] : []),
|
|
229
|
+
])
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
if (pkgConfig.prettier) {
|
|
233
|
+
defaultsDeep(pkgConfig, { requiredPackages: { devDependencies: [] } })
|
|
234
|
+
pkgConfig.requiredPackages.devDependencies = uniq([
|
|
235
|
+
...pkgConfig.requiredPackages.devDependencies,
|
|
236
|
+
'prettier',
|
|
237
|
+
'eslint-config-prettier',
|
|
238
|
+
'@github/prettier-config',
|
|
239
|
+
])
|
|
210
240
|
}
|
|
211
241
|
|
|
212
242
|
const gitUrl = await git.getUrl(rootPkg.path)
|
|
@@ -238,32 +268,53 @@ const getFullConfig = async ({
|
|
|
238
268
|
applyRepo: !!repoFiles,
|
|
239
269
|
applyModule: !!moduleFiles,
|
|
240
270
|
__PARTIAL_DIRS__: fileDirs,
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
271
|
+
})
|
|
272
|
+
|
|
273
|
+
const ignoreAddedPaths = gitignore.sort([
|
|
274
|
+
...gitignore.allowRootDir([
|
|
275
|
+
// Allways allow module files in root or workspaces
|
|
276
|
+
...getAddedFiles(moduleFiles).map(s => template(s, fullConfig)),
|
|
277
|
+
...(isRoot
|
|
278
|
+
? [
|
|
248
279
|
// in the root allow all repo files
|
|
249
280
|
...getAddedFiles(repoFiles).map(s => template(s, fullConfig)),
|
|
250
281
|
// and allow all workspace repo level files in the root
|
|
251
282
|
...pkgs
|
|
252
283
|
.filter(p => p.path !== rootPkg.path && p.config.workspaceRepo !== false)
|
|
253
284
|
.flatMap(() => getAddedFiles(files.workspaceRepo)),
|
|
254
|
-
]
|
|
255
|
-
]),
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
285
|
+
]
|
|
286
|
+
: []),
|
|
287
|
+
]),
|
|
288
|
+
...(isRoot && pkgConfig.lockfile ? ['!/package-lock.json'] : []),
|
|
289
|
+
])
|
|
290
|
+
|
|
291
|
+
Object.assign(fullConfig, {
|
|
292
|
+
// Make sure we don't format any files that are being generated since they will cause template-oss-check to fail
|
|
293
|
+
// This could be changed if those files were also formatted before save but then we would need to read generated
|
|
294
|
+
// the prettier config first and use that as the formatting rules which would get weird
|
|
295
|
+
formatIgnorePaths: [
|
|
296
|
+
...fullConfig.formatIgnorePaths,
|
|
297
|
+
...ignoreAddedPaths
|
|
298
|
+
.filter(f => f.startsWith('!'))
|
|
299
|
+
.map(f => f.replace(/^!/, ''))
|
|
300
|
+
.filter(f => {
|
|
301
|
+
const ext = extname(f).slice(1)
|
|
302
|
+
// ignore it if the specified format extensions match or if its a directory
|
|
303
|
+
return (fullConfig.formatExtensions || []).includes(ext) || (!ext && f.endsWith('/'))
|
|
304
|
+
}),
|
|
305
|
+
],
|
|
306
|
+
// gitignore, these use the full config so need to come at the very end
|
|
307
|
+
ignorePaths: [
|
|
308
|
+
...gitignore.sort([
|
|
309
|
+
...ignoreAddedPaths,
|
|
310
|
+
...(pkgConfig.allowPaths || []).map(p => `!${p}`),
|
|
311
|
+
...(pkgConfig.allowDistPaths ? pkgConfig.distPaths : []).map(p => `!/${p}`),
|
|
259
312
|
...(pkgConfig.ignorePaths || []),
|
|
260
313
|
]),
|
|
261
314
|
// these cant be sorted since they rely on order
|
|
262
315
|
// to allow a previously ignored directoy
|
|
263
|
-
...isRoot
|
|
264
|
-
|
|
265
|
-
: [],
|
|
266
|
-
].filter(p => !pkgConfig.eslint ? !p.includes('eslint') : true),
|
|
316
|
+
...(isRoot ? gitignore.allowDir(wsPkgs.map(p => makePosix(relative(rootPkg.path, p.path)))) : []),
|
|
317
|
+
].filter(p => (!pkgConfig.eslint ? !p.includes('eslint') : true)),
|
|
267
318
|
})
|
|
268
319
|
|
|
269
320
|
return fullConfig
|
|
@@ -7,10 +7,10 @@ software for any purpose with or without fee is hereby
|
|
|
7
7
|
granted, provided that the above copyright notice and this
|
|
8
8
|
permission notice appear in all copies.
|
|
9
9
|
|
|
10
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND
|
|
10
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
|
|
11
11
|
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
|
12
12
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
|
|
13
|
-
EVENT SHALL
|
|
13
|
+
EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
14
14
|
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
15
15
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
|
16
16
|
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|