@take-out/scripts 0.0.45 → 0.0.46

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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/src/release.ts +58 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@take-out/scripts",
3
- "version": "0.0.45",
3
+ "version": "0.0.46",
4
4
  "type": "module",
5
5
  "main": "./src/run.ts",
6
6
  "sideEffects": false,
@@ -24,7 +24,7 @@
24
24
  "access": "public"
25
25
  },
26
26
  "dependencies": {
27
- "@take-out/helpers": "0.0.45",
27
+ "@take-out/helpers": "0.0.46",
28
28
  "glob": "^11.0.0"
29
29
  },
30
30
  "devDependencies": {
package/src/release.ts CHANGED
@@ -279,12 +279,70 @@ async function main() {
279
279
  }
280
280
 
281
281
  console.info(`✅ Done\n`)
282
+
283
+ // update downstream repos if they exist
284
+ if (!canary) {
285
+ await updateDownstreamRepos()
286
+ }
282
287
  } catch (err) {
283
288
  console.info('\nError:\n', err)
284
289
  process.exit(1)
285
290
  }
286
291
  }
287
292
 
293
+ async function updateDownstreamRepos() {
294
+ const homeDir = process.env.HOME || process.env.USERPROFILE || ''
295
+ const downstreamRepos = [join(homeDir, 'takeout-free'), join(homeDir, 'takeout-static')]
296
+
297
+ for (const repoPath of downstreamRepos) {
298
+ if (!(await fs.pathExists(repoPath))) {
299
+ continue
300
+ }
301
+
302
+ console.info(`\n📦 Found downstream repo: ${repoPath}`)
303
+
304
+ try {
305
+ // check for uncommitted changes
306
+ const statusOut = await run(`git status --porcelain`, {
307
+ cwd: repoPath,
308
+ silent: true,
309
+ })
310
+ if (statusOut.stdout.trim()) {
311
+ console.warn(` ⚠️ Skipping ${repoPath}: has uncommitted changes`)
312
+ continue
313
+ }
314
+
315
+ // pull latest
316
+ console.info(` Pulling latest...`)
317
+ try {
318
+ await run(`git pull --rebase origin HEAD`, { cwd: repoPath, silent: true })
319
+ } catch (err) {
320
+ console.warn(` ⚠️ Skipping ${repoPath}: failed to pull from origin`)
321
+ continue
322
+ }
323
+
324
+ // run upgrade
325
+ console.info(` Running upgrade/takeout...`)
326
+ await run(`bun tko upgrade/takeout`, { cwd: repoPath })
327
+
328
+ // run check:all
329
+ console.info(` Running check:all...`)
330
+ try {
331
+ await run(`bun check:all`, { cwd: repoPath })
332
+ console.info(` ✅ ${repoPath} upgraded successfully`)
333
+ } catch (err) {
334
+ console.warn(
335
+ ` ⚠️ ${repoPath}: check:all failed after upgrade, please review manually`
336
+ )
337
+ // reset the changes since check failed
338
+ await run(`git checkout .`, { cwd: repoPath, silent: true })
339
+ }
340
+ } catch (err) {
341
+ console.warn(` ⚠️ Error updating ${repoPath}:`, err)
342
+ }
343
+ }
344
+ }
345
+
288
346
  async function getWorkspacePackages() {
289
347
  // read workspaces from root package.json
290
348
  const rootPackageJson = await fs.readJSON(join(process.cwd(), 'package.json'))