@npmcli/template-oss 3.2.0 → 3.2.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.
- package/lib/apply/apply-files.js +2 -2
- package/lib/apply/apply-version.js +26 -0
- package/lib/apply/index.js +1 -0
- package/lib/config.js +7 -5
- package/lib/content/eslintrc.js +1 -0
- package/lib/content/index.js +1 -0
- package/lib/content/pkg.json +1 -1
- package/package.json +1 -1
package/lib/apply/apply-files.js
CHANGED
|
@@ -18,7 +18,7 @@ module.exports = [{
|
|
|
18
18
|
options.config.repoFiles,
|
|
19
19
|
options
|
|
20
20
|
),
|
|
21
|
-
when: ({ config: c }) => c.
|
|
21
|
+
when: ({ config: c }) => c.applyRepo && c.needsUpdate,
|
|
22
22
|
name: 'apply-repo',
|
|
23
23
|
}, {
|
|
24
24
|
run: (options) => run(
|
|
@@ -26,6 +26,6 @@ module.exports = [{
|
|
|
26
26
|
options.config.moduleFiles,
|
|
27
27
|
options
|
|
28
28
|
),
|
|
29
|
-
when: ({ config: c }) => c.
|
|
29
|
+
when: ({ config: c }) => c.applyModule && c.needsUpdate,
|
|
30
30
|
name: 'apply-module',
|
|
31
31
|
}]
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const log = require('proc-log')
|
|
2
|
+
const PackageJson = require('@npmcli/package-json')
|
|
3
|
+
|
|
4
|
+
const run = async ({ config: c }) => {
|
|
5
|
+
const {
|
|
6
|
+
moduleDir: dir,
|
|
7
|
+
__CONFIG_KEY__: key,
|
|
8
|
+
__VERSION__: version,
|
|
9
|
+
} = c
|
|
10
|
+
|
|
11
|
+
log.verbose('apply-version', dir)
|
|
12
|
+
|
|
13
|
+
const pkg = await PackageJson.load(dir)
|
|
14
|
+
if (!pkg.content[key]) {
|
|
15
|
+
pkg.content[key] = { version }
|
|
16
|
+
} else {
|
|
17
|
+
pkg.content[key].version = version
|
|
18
|
+
}
|
|
19
|
+
await pkg.save()
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
module.exports = {
|
|
23
|
+
run,
|
|
24
|
+
when: ({ config: c }) => c.needsUpdate && !c.isDogFood,
|
|
25
|
+
name: 'apply-version',
|
|
26
|
+
}
|
package/lib/apply/index.js
CHANGED
package/lib/config.js
CHANGED
|
@@ -56,6 +56,7 @@ const getConfig = async ({
|
|
|
56
56
|
const isRoot = root === path
|
|
57
57
|
const isLatest = version === LATEST_VERSION
|
|
58
58
|
const isDogFood = pkg.name === NAME
|
|
59
|
+
const isForce = process.argv.includes('--force')
|
|
59
60
|
|
|
60
61
|
// this is written to ci yml files so it needs to always use posix
|
|
61
62
|
const pkgRelPath = makePosix(relative(root, path))
|
|
@@ -111,16 +112,17 @@ const getConfig = async ({
|
|
|
111
112
|
pkgName: pkg.name,
|
|
112
113
|
pkgNameFs: pkg.name.replace(/\//g, '-').replace(/@/g, ''),
|
|
113
114
|
pkgRelPath: pkgRelPath,
|
|
114
|
-
//
|
|
115
|
-
|
|
116
|
-
|
|
115
|
+
// booleans to control application of updates
|
|
116
|
+
isForce,
|
|
117
|
+
isDogFood,
|
|
117
118
|
isLatest,
|
|
118
|
-
|
|
119
|
+
// needs update if we are dogfooding this repo, with force argv, or its
|
|
120
|
+
// behind the current version
|
|
121
|
+
needsUpdate: isForce || isDogFood || !isLatest,
|
|
119
122
|
// templateoss specific values
|
|
120
123
|
__NAME__: NAME,
|
|
121
124
|
__CONFIG_KEY__: CONFIG_KEY,
|
|
122
125
|
__VERSION__: LATEST_VERSION,
|
|
123
|
-
__DOGFOOD__: isDogFood,
|
|
124
126
|
}
|
|
125
127
|
|
|
126
128
|
// merge the rest of base and pkg content to make the
|
package/lib/content/eslintrc.js
CHANGED
package/lib/content/index.js
CHANGED
package/lib/content/pkg.json
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"node": {{{json engines}}}
|
|
21
21
|
},
|
|
22
22
|
{{{json __CONFIG_KEY__}}}: {
|
|
23
|
-
"version": {{#if
|
|
23
|
+
"version": {{#if isDogFood}}{{{del}}}{{else}}{{{json __VERSION__}}}{{/if}}
|
|
24
24
|
},
|
|
25
25
|
"templateVersion": {{{del}}},
|
|
26
26
|
"standard": {{{del}}}
|