@take-out/scripts 0.0.72 → 0.0.74

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": "@take-out/scripts",
3
- "version": "0.0.72",
3
+ "version": "0.0.74",
4
4
  "type": "module",
5
5
  "main": "./src/run.ts",
6
6
  "sideEffects": false,
@@ -28,7 +28,7 @@
28
28
  "access": "public"
29
29
  },
30
30
  "dependencies": {
31
- "@take-out/helpers": "0.0.69"
31
+ "@take-out/helpers": "0.0.73"
32
32
  },
33
33
  "devDependencies": {
34
34
  "vxrn": "1.4.10-1770207233041"
package/src/env-update.ts CHANGED
@@ -137,9 +137,21 @@ function updateDockerCompose() {
137
137
  return
138
138
  }
139
139
 
140
- const indent = ' '
140
+ // detect indent from the marker line
141
+ const markerMatch = dockerCompose.match(new RegExp(`^(\\s*)${yamlStartMarker}`, 'm'))
142
+ const indent = markerMatch?.[1] || ' '
143
+
144
+ // detect format: if markers are under an x- anchor block, use map syntax (KEY: val)
145
+ // otherwise use list syntax (- KEY=val)
146
+ const beforeMarker = dockerCompose.slice(0, dockerCompose.indexOf(yamlStartMarker))
147
+ const isMap = /x-[\w-]+:.*&[\w-]+/s.test(beforeMarker)
148
+
141
149
  const envLines = Object.keys(envVars)
142
- .map((key) => `${indent}- ${key}=\${${key}:-}`)
150
+ .map((key) =>
151
+ isMap
152
+ ? `${indent}${key}: \${${key}:-}`
153
+ : `${indent}- ${key}=\${${key}:-}`
154
+ )
143
155
  .join('\n')
144
156
 
145
157
  const newDockerCompose = replaceYamlSection(dockerCompose, envLines, { indent })
package/src/release.ts CHANGED
@@ -317,7 +317,9 @@ async function syncOnZeroIn() {
317
317
  return
318
318
  }
319
319
 
320
- const newCommits = commits.slice(0, lastSyncIdx).filter((c) => !c.match(/^v\d+\.\d+\.\d+/))
320
+ const newCommits = commits
321
+ .slice(0, lastSyncIdx)
322
+ .filter((c) => !c.match(/^v\d+\.\d+\.\d+/))
321
323
  if (!newCommits.length) {
322
324
  console.info(' ← on-zero: no new github commits to sync in')
323
325
  return
@@ -331,7 +333,9 @@ async function syncOnZeroIn() {
331
333
  return
332
334
  }
333
335
 
334
- await fs.copy(join(onZeroGithub, 'src'), join(onZeroTakeout, 'src'), { overwrite: true })
336
+ await fs.copy(join(onZeroGithub, 'src'), join(onZeroTakeout, 'src'), {
337
+ overwrite: true,
338
+ })
335
339
 
336
340
  const status = (await $`git status --porcelain`.text()).trim()
337
341
  if (status) {
@@ -342,7 +346,6 @@ async function syncOnZeroIn() {
342
346
 
343
347
  async function syncOnZeroOut(version: string) {
344
348
  if (!(await fs.pathExists(onZeroGithub))) return
345
- console.info(' → on-zero: syncing out to github')
346
349
 
347
350
  // copy src files from takeout to github
348
351
  await fs.copy(join(onZeroTakeout, 'src'), join(onZeroGithub, 'src'), {
@@ -375,10 +378,12 @@ async function syncOnZeroOut(version: string) {
375
378
  { spaces: 2 }
376
379
  )
377
380
 
378
- // commit and push
381
+ // only commit if there are actual changes
379
382
  const status = (await $`git -C ${onZeroGithub} status --porcelain`.text()).trim()
380
383
  if (!status) return
381
384
 
385
+ console.info(' → on-zero: syncing out to github')
386
+
382
387
  if (dryRun) {
383
388
  console.info(` [dry-run] would push: sync: from takeout v${version}`)
384
389
  await $`git -C ${onZeroGithub} checkout -- .`