@take-out/scripts 0.0.77 → 0.0.79
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 +1 -1
- package/src/up.ts +45 -7
package/package.json
CHANGED
package/src/up.ts
CHANGED
|
@@ -206,6 +206,12 @@ function updatePackageJsonVersions(
|
|
|
206
206
|
depsObject[pkg] = newVersion
|
|
207
207
|
} else {
|
|
208
208
|
const currentVersion = depsObject[pkg]
|
|
209
|
+
// wildcard "*" means newly added placeholder, use ^ prefix
|
|
210
|
+
if (currentVersion === '*') {
|
|
211
|
+
depsObject[pkg] = `^${newVersion}`
|
|
212
|
+
updatedCount++
|
|
213
|
+
continue
|
|
214
|
+
}
|
|
209
215
|
const prefixMatch = currentVersion.match(/^([^\d]*)/)
|
|
210
216
|
const prefix = prefixMatch?.[1] || ''
|
|
211
217
|
depsObject[pkg] = `${prefix}${newVersion}`
|
|
@@ -385,14 +391,46 @@ async function main() {
|
|
|
385
391
|
}
|
|
386
392
|
}
|
|
387
393
|
|
|
388
|
-
console.info(
|
|
389
|
-
`Found ${allMatchingDeps.size} dependencies matching patterns: ${packagePatterns.join(', ')}`
|
|
390
|
-
)
|
|
391
|
-
console.info(`Found matches in ${packagesByWorkspace.size} workspace(s)`)
|
|
392
|
-
|
|
393
394
|
if (allMatchingDeps.size === 0) {
|
|
394
|
-
|
|
395
|
-
|
|
395
|
+
// no existing deps matched, but exact patterns (no wildcards) can be added fresh
|
|
396
|
+
const exactPatterns = packagePatterns.filter((p) => !p.includes('*'))
|
|
397
|
+
if (exactPatterns.length === 0) {
|
|
398
|
+
console.info(
|
|
399
|
+
`Found 0 dependencies matching patterns: ${packagePatterns.join(', ')}`
|
|
400
|
+
)
|
|
401
|
+
console.info('No matching packages found to update.')
|
|
402
|
+
return
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
// add as new dependencies to the root package.json
|
|
406
|
+
console.info(`No existing deps found, adding to root: ${exactPatterns.join(', ')}`)
|
|
407
|
+
const rootPkgPath = join(rootDir, 'package.json')
|
|
408
|
+
|
|
409
|
+
for (const pkg of exactPatterns) {
|
|
410
|
+
allMatchingDeps.add(pkg)
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
packagesByWorkspace.set('root', {
|
|
414
|
+
dir: rootDir,
|
|
415
|
+
packages: exactPatterns,
|
|
416
|
+
})
|
|
417
|
+
|
|
418
|
+
// insert placeholder so updatePackageJsonVersions can set the real version
|
|
419
|
+
const rootPkg = JSON.parse(readFileSync(rootPkgPath, 'utf-8'))
|
|
420
|
+
if (!rootPkg.dependencies) {
|
|
421
|
+
rootPkg.dependencies = {}
|
|
422
|
+
}
|
|
423
|
+
for (const pkg of exactPatterns) {
|
|
424
|
+
if (!rootPkg.dependencies[pkg] && !rootPkg.devDependencies?.[pkg]) {
|
|
425
|
+
rootPkg.dependencies[pkg] = '*'
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
writeFileSync(rootPkgPath, JSON.stringify(rootPkg, null, 2) + '\n')
|
|
429
|
+
} else {
|
|
430
|
+
console.info(
|
|
431
|
+
`Found ${allMatchingDeps.size} dependencies matching patterns: ${packagePatterns.join(', ')}`
|
|
432
|
+
)
|
|
433
|
+
console.info(`Found matches in ${packagesByWorkspace.size} workspace(s)`)
|
|
396
434
|
}
|
|
397
435
|
|
|
398
436
|
if (globalTag) {
|