@npmcli/template-oss 4.22.0 → 4.23.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 (47) hide show
  1. package/bin/apply.js +2 -5
  2. package/bin/check.js +2 -4
  3. package/bin/release-manager.js +1 -1
  4. package/bin/release-please.js +22 -18
  5. package/lib/apply/apply-files.js +14 -19
  6. package/lib/apply/apply-version.js +1 -5
  7. package/lib/apply/index.js +1 -4
  8. package/lib/check/check-apply.js +38 -38
  9. package/lib/check/check-changelog.js +1 -4
  10. package/lib/check/check-engines.js +5 -6
  11. package/lib/check/check-gitignore.js +14 -14
  12. package/lib/check/check-required.js +13 -15
  13. package/lib/check/check-unwanted.js +2 -3
  14. package/lib/check/index.js +9 -8
  15. package/lib/config.js +86 -35
  16. package/lib/content/SECURITY-md.hbs +1 -1
  17. package/lib/content/_job-release-integration-yml.hbs +2 -0
  18. package/lib/content/action-create-check-yml.hbs +1 -1
  19. package/lib/content/action-install-latest-npm-yml.hbs +1 -1
  20. package/lib/content/ci-release-yml.hbs +2 -2
  21. package/lib/content/eslintrc-js.hbs +4 -5
  22. package/lib/content/gitignore.hbs +0 -3
  23. package/lib/content/index.js +33 -32
  24. package/lib/content/package-json.hbs +12 -2
  25. package/lib/content/post-dependabot-yml.hbs +2 -3
  26. package/lib/content/prettier-js.hbs +6 -0
  27. package/lib/content/prettierignore.hbs +3 -0
  28. package/lib/index.js +3 -3
  29. package/lib/release/changelog.js +28 -31
  30. package/lib/release/node-workspace-format.js +12 -12
  31. package/lib/release/release-manager.js +61 -76
  32. package/lib/release/release-please.js +50 -58
  33. package/lib/release/util.js +11 -8
  34. package/lib/util/ci-versions.js +3 -3
  35. package/lib/util/dependabot.js +2 -2
  36. package/lib/util/files.js +25 -22
  37. package/lib/util/git.js +7 -4
  38. package/lib/util/gitignore.js +13 -11
  39. package/lib/util/has-package.js +7 -12
  40. package/lib/util/import-or-require.js +1 -1
  41. package/lib/util/json-diff.js +22 -21
  42. package/lib/util/merge.js +19 -16
  43. package/lib/util/output.js +8 -5
  44. package/lib/util/parser.js +77 -70
  45. package/lib/util/path.js +4 -4
  46. package/lib/util/template.js +11 -10
  47. package/package.json +12 -7
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((err) => {
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((err) => {
21
+ module.exports = main().catch(err => {
24
22
  console.error(err.stack)
25
23
  process.exitCode = 1
26
24
  })
@@ -19,7 +19,7 @@ ReleaseManager.run({
19
19
  },
20
20
  }).values,
21
21
  })
22
- .then((result) => {
22
+ .then(result => {
23
23
  core.setOutput('result', result)
24
24
  return null
25
25
  })
@@ -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(Object.entries(process.env)
22
- .filter(([k, v]) => k.startsWith('RELEASE_PLEASE_') && v != null)
23
- .map(([k, v]) => [k.replace('RELEASE_PLEASE_', ''), v])),
24
- }).then(({ pr, releases }) => {
25
- if (pr) {
26
- core.setOutput('pr', JSON.stringify(pr))
27
- core.setOutput('pr-branch', pr.headBranchName)
28
- core.setOutput('pr-number', pr.number)
29
- core.setOutput('pr-sha', pr.sha)
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
- if (releases) {
33
- core.setOutput('releases', JSON.stringify(releases))
34
- }
35
+ if (releases) {
36
+ core.setOutput('releases', JSON.stringify(releases))
37
+ }
35
38
 
36
- return null
37
- }).catch(err => {
38
- core.setFailed('Release Please failed')
39
- core.error(err)
40
- })
39
+ return null
40
+ })
41
+ .catch(err => {
42
+ core.setFailed('Release Please failed')
43
+ core.error(err)
44
+ })
@@ -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, (f) => fs.rm(f))
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, {}, (p) => p.applyWrite())
12
+ await parseEach(dir, add, options, {}, p => p.applyWrite())
13
13
  }
14
14
 
15
- module.exports = [{
16
- run: (options) => run(
17
- options.config.repoDir,
18
- options.config.repoFiles,
19
- options
20
- ),
21
- when: ({ config: c }) => c.applyRepo && c.needsUpdate,
22
- name: 'apply-repo',
23
- }, {
24
- run: (options) => run(
25
- options.config.moduleDir,
26
- options.config.moduleFiles,
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
 
@@ -1,6 +1,3 @@
1
1
  const run = require('../index.js')
2
2
 
3
- module.exports = (root) => run(root, [
4
- require('./apply-files.js'),
5
- require('./apply-version.js'),
6
- ])
3
+ module.exports = root => run(root, [require('./apply-files.js'), require('./apply-version.js')])
@@ -8,22 +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 = (f) => relative(options.root, f)
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, (f) => rel(f))
15
- const [add, update] = partition(await parseEach(dir, addFiles, options, {}, async (p) => {
16
- const diff = await p.applyDiff()
17
- const target = rel(p.target)
18
- if (diff === null) {
19
- // needs to be added
20
- return target
21
- } else if (diff === true) {
22
- // its ok, no diff, this is filtered out
23
- return null
24
- }
25
- return { file: target, diff }
26
- }), (d) => typeof d === 'string')
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
+ )
27
30
 
28
31
  log.verbose('check-apply', 'rm', rm)
29
32
  if (rm.length) {
@@ -44,31 +47,28 @@ const run = async (type, dir, files, options) => {
44
47
  }
45
48
 
46
49
  log.verbose('check-apply', 'update', update)
47
- res.push(...update.sort((a, b) => localeCompare(a.file, b.file)).map(({ file, diff }) => ({
48
- title: `The ${type} file ${basename(file)} needs to be updated:`,
49
- body: [`${file}\n${'='.repeat(40)}\n${diff}`],
50
- solution,
51
- })))
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
+ )
52
59
 
53
60
  return res
54
61
  }
55
62
 
56
- module.exports = [{
57
- run: (options) => run(
58
- 'repo',
59
- options.config.repoDir,
60
- options.config.repoFiles,
61
- options
62
- ),
63
- when: ({ config: c }) => c.applyRepo,
64
- name: 'check-repo',
65
- }, {
66
- run: (options) => run(
67
- 'module',
68
- options.config.moduleDir,
69
- options.config.moduleFiles,
70
- options
71
- ),
72
- when: ({ config: c }) => c.applyModule,
73
- name: 'check-module',
74
- }]
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 = `The following production dependencies are not compatible with ` +
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.map((dep) => [
35
- `${dep.name}:`,
36
- ` engines.node: ${dep.engines}`,
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 = (f) => relative(root, resolve(path, f))
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
- 'ls-files',
30
- '--cached',
31
- '--ignored',
32
- // https://git-scm.com/docs/git-ls-files#_exclude_patterns
33
- `--${config.isRoot ? 'exclude-from' : 'exclude-per-directory'}=${basename(ignoreFile)}`,
34
- ], { cwd: path })
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((l) => l && !l.trim().startsWith('#'))
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 = (specs) =>
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) => specs.length ?
10
- `npm i ${specs.map((s) => `${s.name}@${s.fetchSpec}`).join(' ')} ${flags.join(' ')}`.trim() : ''
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
- .reduce((acc, [location, pkgs]) => {
19
- acc[location] = pkgs
20
- .filter((spec) => !hasPackage(pkg, spec, [location], path))
21
- .map((spec) => npa(spec))
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, (s) => s.type === 'version')
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((s) => s.rawSpec === '*' ? s.name : `${s.name}@${s.rawSpec}`),
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
- ].filter(Boolean).join(' && '),
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((name) => !allowedPackages.includes(name))
8
- .filter((name) => hasPackage(pkg, name))
6
+ .filter(name => !allowedPackages.includes(name))
7
+ .filter(name => hasPackage(pkg, name))
9
8
 
10
9
  if (hasUnwanted.length) {
11
10
  return {
@@ -1,10 +1,11 @@
1
1
  const run = require('../index.js')
2
2
 
3
- module.exports = (root) => run(root, [
4
- require('./check-apply.js'),
5
- require('./check-required.js'),
6
- require('./check-unwanted.js'),
7
- require('./check-gitignore.js'),
8
- require('./check-changelog.js'),
9
- require('./check-engines.js'),
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 = (pkg) => pkg[CONFIG_KEY] || {}
19
+ const getPkgConfig = pkg => pkg[CONFIG_KEY] || {}
20
20
 
21
21
  const merge = mergeWithCustomizers(
22
- customizers.mergeArrays('branches', 'distPaths', 'allowPaths', 'ignorePaths'),
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 (path) => {
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
- pkgConfig.requiredPackages.devDependencies.filter(p => !p.includes('eslint'))
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.push('/src/')
204
- pkgConfig.requiredPackages.devDependencies.push(
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
- // gitignore, these use the full config so need to come at the very end
242
- ignorePaths: [
243
- ...gitignore.sort([
244
- ...gitignore.allowRootDir([
245
- // Allways allow module files in root or workspaces
246
- ...getAddedFiles(moduleFiles).map(s => template(s, fullConfig)),
247
- ...isRoot ? [
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
- ...isRoot && pkgConfig.lockfile ? ['!/package-lock.json'] : [],
257
- ...(pkgConfig.allowPaths || []).map((p) => `!${p}`),
258
- ...(pkgConfig.allowDistPaths ? pkgConfig.distPaths : []).map((p) => `!/${p}`),
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
- ? gitignore.allowDir(wsPkgs.map((p) => makePosix(relative(rootPkg.path, p.path))))
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
@@ -1,6 +1,6 @@
1
1
  GitHub takes the security of our software products and services seriously, including the open source code repositories managed through our GitHub organizations, such as [GitHub](https://github.com/GitHub).
2
2
 
3
- If you believe you have found a security vulnerability in this GitHub-owned open source repository, you can report it to us in one of two ways.
3
+ If you believe you have found a security vulnerability in this GitHub-owned open source repository, you can report it to us in one of two ways.
4
4
 
5
5
  If the vulnerability you have found is *not* [in scope for the GitHub Bug Bounty Program](https://bounty.github.com/#scope) or if you do not wish to be considered for a bounty reward, please report the issue to us directly through [opensource-security@github.com](mailto:opensource-security@github.com).
6
6
 
@@ -19,6 +19,8 @@ steps:
19
19
  {{else}}
20
20
  {{> stepsSetupYml }}
21
21
  - name: Check If Published
22
+ env:
23
+ RELEASES: $\{{ inputs.releases }}
22
24
  {{/if}}
23
25
  run: |
24
26
  EXIT_CODE=0