@take-out/scripts 0.0.81 → 0.0.83
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/helpers/process-compose-env.ts +18 -5
- package/src/helpers/uncloud.ts +2 -1
- package/src/up.ts +7 -7
package/package.json
CHANGED
|
@@ -1,11 +1,24 @@
|
|
|
1
1
|
import { readFileSync, writeFileSync } from 'node:fs'
|
|
2
2
|
|
|
3
|
-
//
|
|
3
|
+
// make values safe for yaml map syntax (KEY: value)
|
|
4
|
+
// handles multi-line values, special chars that break yaml parsing
|
|
4
5
|
function yamlSafe(value: string): string {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
const needsQuoting =
|
|
7
|
+
value.includes('\n') ||
|
|
8
|
+
value.includes(':') ||
|
|
9
|
+
value.includes('#') ||
|
|
10
|
+
value.startsWith('-') ||
|
|
11
|
+
value.startsWith('{') ||
|
|
12
|
+
value.startsWith('[') ||
|
|
13
|
+
value.startsWith('"') ||
|
|
14
|
+
value.startsWith("'")
|
|
15
|
+
|
|
16
|
+
if (!needsQuoting) return value
|
|
17
|
+
|
|
18
|
+
// escape backslashes and double quotes, collapse newlines
|
|
19
|
+
const escaped = value.replace(/\\/g, '\\\\').replace(/"/g, '\\"').replace(/\n/g, '\\n')
|
|
20
|
+
|
|
21
|
+
return `"${escaped}"`
|
|
9
22
|
}
|
|
10
23
|
|
|
11
24
|
/**
|
package/src/helpers/uncloud.ts
CHANGED
|
@@ -34,7 +34,8 @@ function ensureUncloudContext(host: string, sshKey: string, contextName: string)
|
|
|
34
34
|
// check if config already has context pointing to correct host
|
|
35
35
|
if (existsSync(configPath)) {
|
|
36
36
|
const existing = readFileSync(configPath, 'utf-8')
|
|
37
|
-
|
|
37
|
+
const hostname = host.split('@')[1]
|
|
38
|
+
if (hostname && existing.includes(`${contextName}:`) && existing.includes(hostname)) {
|
|
38
39
|
console.info(`✅ uncloud config already has ${contextName} context for ${host}`)
|
|
39
40
|
return
|
|
40
41
|
}
|
package/src/up.ts
CHANGED
|
@@ -20,7 +20,7 @@ const rootPackageJson = JSON.parse(readFileSync(join(rootDir, 'package.json'), '
|
|
|
20
20
|
const upgradeSets: Record<string, string[]> = rootPackageJson.upgradeSets || {}
|
|
21
21
|
|
|
22
22
|
for (let i = 0; i < args.length; i++) {
|
|
23
|
-
const arg = args[i]
|
|
23
|
+
const arg = args[i]!
|
|
24
24
|
if (arg.startsWith('--tag=')) {
|
|
25
25
|
const tagValue = arg.split('=')[1]
|
|
26
26
|
if (tagValue) {
|
|
@@ -40,7 +40,7 @@ for (let i = 0; i < args.length; i++) {
|
|
|
40
40
|
globalTag = 'rc'
|
|
41
41
|
} else if (arg in upgradeSets) {
|
|
42
42
|
// expand named upgrade set to its patterns
|
|
43
|
-
packagePatterns.push(...upgradeSets[arg])
|
|
43
|
+
packagePatterns.push(...upgradeSets[arg]!)
|
|
44
44
|
} else {
|
|
45
45
|
packagePatterns.push(arg)
|
|
46
46
|
}
|
|
@@ -94,7 +94,7 @@ function findPackageJsonFiles(dir: string): string[] {
|
|
|
94
94
|
|
|
95
95
|
if (normalizedWorkspace.includes('**')) {
|
|
96
96
|
// nested glob pattern - use glob to find all package.json files
|
|
97
|
-
const baseDir = normalizedWorkspace.split('**')[0]
|
|
97
|
+
const baseDir = normalizedWorkspace.split('**')[0]!.replace(/\/$/, '')
|
|
98
98
|
const basePath = join(dir, baseDir)
|
|
99
99
|
|
|
100
100
|
if (existsSync(basePath)) {
|
|
@@ -197,7 +197,8 @@ function updatePackageJsonVersions(
|
|
|
197
197
|
const updateDeps = (depsObject: Record<string, string> | undefined) => {
|
|
198
198
|
if (!depsObject) return
|
|
199
199
|
for (const pkg of packagesToUpdate) {
|
|
200
|
-
|
|
200
|
+
const current = depsObject[pkg]
|
|
201
|
+
if (current && !current.startsWith('workspace:')) {
|
|
201
202
|
const newVersion = versionMap.get(pkg)
|
|
202
203
|
if (newVersion) {
|
|
203
204
|
// for tagged versions (canary, rc, etc), use exact version (no prefix)
|
|
@@ -205,14 +206,13 @@ function updatePackageJsonVersions(
|
|
|
205
206
|
if (globalTag) {
|
|
206
207
|
depsObject[pkg] = newVersion
|
|
207
208
|
} else {
|
|
208
|
-
const currentVersion = depsObject[pkg]
|
|
209
209
|
// wildcard "*" means newly added placeholder, use ^ prefix
|
|
210
|
-
if (
|
|
210
|
+
if (current === '*') {
|
|
211
211
|
depsObject[pkg] = `^${newVersion}`
|
|
212
212
|
updatedCount++
|
|
213
213
|
continue
|
|
214
214
|
}
|
|
215
|
-
const prefixMatch =
|
|
215
|
+
const prefixMatch = current.match(/^([^\d]*)/)
|
|
216
216
|
const prefix = prefixMatch?.[1] || ''
|
|
217
217
|
depsObject[pkg] = `${prefix}${newVersion}`
|
|
218
218
|
}
|