@zairakai/js-dev-tools 3.12.0 → 3.12.2
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zairakai/js-dev-tools",
|
|
3
|
-
"version": "3.12.
|
|
3
|
+
"version": "3.12.2",
|
|
4
4
|
"description": "The unified and centralized development toolkit for JavaScript/TypeScript projects - ESLint, Prettier, Stylelint, Knip, Vitest, Git Hooks, and GitLab CI pipeline templates",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dev-tools",
|
|
@@ -45,6 +45,7 @@ const POLICY_URL = 'https://gitlab.com/zairakai/dependency-policy/-/raw/main'
|
|
|
45
45
|
const POLICY_FILES = { npm: 'node.json', composer: 'php.json' }
|
|
46
46
|
const POLICY_BRANCH_PREFIX = 'chore/unblock'
|
|
47
47
|
const GROUP_SCOPE = '@zairakai/'
|
|
48
|
+
const TRUSTED_SCOPES = [GROUP_SCOPE, '@stanislas-poisson/']
|
|
48
49
|
|
|
49
50
|
const DEFAULTS = {
|
|
50
51
|
reject: [],
|
|
@@ -251,6 +252,19 @@ export function isLifted(entry, ranges) {
|
|
|
251
252
|
})
|
|
252
253
|
}
|
|
253
254
|
|
|
255
|
+
/**
|
|
256
|
+
* The packages of a lock file that the refresh may update: the ones of the group are left out, because they are trusted
|
|
257
|
+
* and not made to wait, and the cooling date would refuse a version that was just published.
|
|
258
|
+
*/
|
|
259
|
+
export function refreshableNames(lock, scopes = TRUSTED_SCOPES) {
|
|
260
|
+
const names = Object.keys(lock?.packages ?? {})
|
|
261
|
+
.filter((path) => '' !== path)
|
|
262
|
+
.map((path) => path.slice(path.lastIndexOf('node_modules/') + 'node_modules/'.length))
|
|
263
|
+
.filter((name) => !scopes.some((scope) => name.startsWith(scope)))
|
|
264
|
+
|
|
265
|
+
return [...new Set(names)].sort()
|
|
266
|
+
}
|
|
267
|
+
|
|
254
268
|
/** The age, as a date, from which a version is taken: now minus the cooling period ("3d", "12h"). */
|
|
255
269
|
export function cooldownDate(cooldown, now = new Date()) {
|
|
256
270
|
const match = /^(\d+)\s*([dhm])$/.exec(cooldown)
|
|
@@ -594,12 +608,19 @@ async function update(config) {
|
|
|
594
608
|
// The lock file is refreshed inside the ranges, so that a fix of a package that this project only inherits arrives
|
|
595
609
|
// (overrides of a dependency do not apply here). The new versions wait for the cooling period, except for a fix.
|
|
596
610
|
const before = cooldownDate(config.cooldown)
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
611
|
+
const names = refreshableNames(JSON.parse(readFileSync('package-lock.json', 'utf8')))
|
|
612
|
+
|
|
613
|
+
// The refresh is a bonus: when npm cannot respect the cooling date (a range that starts at a version younger than
|
|
614
|
+
// the period, after an urgent update), it waits for the next run and the update goes on.
|
|
615
|
+
try {
|
|
616
|
+
if (urgent || null === before) {
|
|
617
|
+
run('npm', ['update', '--no-audit', '--no-fund'])
|
|
618
|
+
} else if (0 < names.length) {
|
|
619
|
+
run('npm', ['update', '--no-audit', '--no-fund', `--before=${before.toISOString()}`, ...names])
|
|
620
|
+
}
|
|
621
|
+
} catch (error) {
|
|
622
|
+
log(`The lock file is not refreshed this time: ${secret(error.message).split('\n')[0]}`)
|
|
623
|
+
}
|
|
603
624
|
|
|
604
625
|
if (urgent) {
|
|
605
626
|
try {
|