@take-out/scripts 0.0.50 ā 0.0.52
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 +2 -2
- package/src/update-changelog.ts +6 -1
- package/src/update-deps.ts +88 -86
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@take-out/scripts",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.52",
|
|
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.
|
|
27
|
+
"@take-out/helpers": "0.0.52",
|
|
28
28
|
"glob": "^11.0.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
package/src/update-changelog.ts
CHANGED
|
@@ -66,9 +66,14 @@ Instructions:
|
|
|
66
66
|
- update the "last updated" comment to: ${latestSha}
|
|
67
67
|
- create new week sections if needed (weeks start monday)
|
|
68
68
|
- format: "## Week of January 20, 2026" with sha in backticks below
|
|
69
|
-
-
|
|
69
|
+
- no emoji, plain text only
|
|
70
70
|
- group small fixes/chores into "Bug fixes and chores (N)"
|
|
71
71
|
- for tamagui/one upgrades, check ~/tamagui or ~/one repos or github for what actually changed
|
|
72
72
|
- write useful descriptions - explain WHY and WHAT improved, not just "fixed X"
|
|
73
73
|
- stop when you reach commits already in the changelog
|
|
74
|
+
|
|
75
|
+
Archiving old entries:
|
|
76
|
+
- keep only 10 weeks in changelog.mdx
|
|
77
|
+
- when over 10 weeks, move oldest entries to changelog-YYYY.mdx (by year, e.g. changelog-2025.mdx)
|
|
78
|
+
- add a link at the bottom of changelog.mdx: "See [2025 changes](/docs/changelog-2025)" etc (use absolute path)
|
|
74
79
|
`)
|
package/src/update-deps.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @description Update dependencies across workspace packages
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { existsSync, readdirSync, readFileSync, rmSync } from 'node:fs'
|
|
7
|
+
import { existsSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
|
|
8
8
|
import { join } from 'node:path'
|
|
9
9
|
|
|
10
10
|
import { $ } from 'bun'
|
|
@@ -129,61 +129,48 @@ function doesPackageMatchPattern(packageName: string, pattern: string): boolean
|
|
|
129
129
|
return packageName === pattern
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
|
|
132
|
+
function updatePackageJsonVersions(
|
|
133
|
+
packageJsonPath: string,
|
|
133
134
|
packagesToUpdate: string[],
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
)
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
})
|
|
155
|
-
)
|
|
156
|
-
).filter((pkg): pkg is string => pkg !== null)
|
|
157
|
-
|
|
158
|
-
if (packagesWithTag.length === 0) {
|
|
159
|
-
return
|
|
135
|
+
versionMap: Map<string, string>
|
|
136
|
+
): number {
|
|
137
|
+
const content = readFileSync(packageJsonPath, 'utf-8')
|
|
138
|
+
const packageJson = JSON.parse(content) as PackageJson
|
|
139
|
+
let updatedCount = 0
|
|
140
|
+
|
|
141
|
+
const updateDeps = (depsObject: Record<string, string> | undefined) => {
|
|
142
|
+
if (!depsObject) return
|
|
143
|
+
for (const pkg of packagesToUpdate) {
|
|
144
|
+
if (pkg in depsObject && !depsObject[pkg].startsWith('workspace:')) {
|
|
145
|
+
const newVersion = versionMap.get(pkg)
|
|
146
|
+
if (newVersion) {
|
|
147
|
+
const currentVersion = depsObject[pkg]
|
|
148
|
+
// preserve version prefix (^, ~, >=, etc) or use exact if none
|
|
149
|
+
const prefixMatch = currentVersion.match(/^([^\d]*)/)
|
|
150
|
+
const prefix = prefixMatch?.[1] || ''
|
|
151
|
+
depsObject[pkg] = `${prefix}${newVersion}`
|
|
152
|
+
updatedCount++
|
|
153
|
+
}
|
|
154
|
+
}
|
|
160
155
|
}
|
|
156
|
+
}
|
|
161
157
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
try {
|
|
167
|
-
await $`bun add ${packageNamesWithTags} --ignore-scripts`.quiet()
|
|
168
|
-
} catch (error: any) {
|
|
169
|
-
const errorMessage = error.message?.split('\n')[0]
|
|
170
|
-
console.warn(` ā ļø ${workspaceName}: ${errorMessage}`)
|
|
171
|
-
}
|
|
172
|
-
} else {
|
|
173
|
-
console.info(` š¦ ${workspaceName}: updating ${packagesToUpdate.length} package(s)`)
|
|
158
|
+
updateDeps(packageJson.dependencies)
|
|
159
|
+
updateDeps(packageJson.devDependencies)
|
|
160
|
+
updateDeps(packageJson.peerDependencies)
|
|
161
|
+
updateDeps(packageJson.optionalDependencies)
|
|
174
162
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
} catch (error: any) {
|
|
178
|
-
const errorMessage = error.message?.split('\n')[0]
|
|
179
|
-
console.warn(` ā ļø ${workspaceName}: ${errorMessage}`)
|
|
180
|
-
}
|
|
163
|
+
if (updatedCount > 0) {
|
|
164
|
+
writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2) + '\n')
|
|
181
165
|
}
|
|
166
|
+
|
|
167
|
+
return updatedCount
|
|
182
168
|
}
|
|
183
169
|
|
|
184
170
|
async function updatePackages(
|
|
185
171
|
packagesByWorkspace: Map<string, { dir: string; packages: string[] }>,
|
|
186
|
-
rootDir: string
|
|
172
|
+
rootDir: string,
|
|
173
|
+
packageJsonFiles: string[]
|
|
187
174
|
) {
|
|
188
175
|
try {
|
|
189
176
|
rmSync(`node_modules/vite`, {
|
|
@@ -194,58 +181,73 @@ async function updatePackages(
|
|
|
194
181
|
// ignore if vite is not there
|
|
195
182
|
}
|
|
196
183
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
}
|
|
184
|
+
// collect all unique packages to update
|
|
185
|
+
const allPackages = new Set<string>()
|
|
186
|
+
for (const { packages } of packagesByWorkspace.values()) {
|
|
187
|
+
packages.forEach((pkg) => allPackages.add(pkg))
|
|
188
|
+
}
|
|
203
189
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
190
|
+
// fetch versions for all packages (with tag if specified)
|
|
191
|
+
const versionMap = new Map<string, string>()
|
|
192
|
+
console.info(`\nš Fetching versions for ${allPackages.size} package(s)...`)
|
|
193
|
+
|
|
194
|
+
await Promise.all(
|
|
195
|
+
[...allPackages].map(async (pkg) => {
|
|
196
|
+
try {
|
|
197
|
+
const tag = globalTag || 'latest'
|
|
198
|
+
const result = await $`npm view ${pkg}@${tag} version`.quiet()
|
|
199
|
+
const version = result.text().trim()
|
|
200
|
+
if (version) {
|
|
201
|
+
versionMap.set(pkg, version)
|
|
202
|
+
console.info(` ā ${pkg}@${tag} ā ${version}`)
|
|
203
|
+
}
|
|
204
|
+
} catch {
|
|
205
|
+
if (globalTag) {
|
|
212
206
|
console.info(` ā ${pkg}@${globalTag} not found, skipping`)
|
|
207
|
+
} else {
|
|
208
|
+
console.info(` ā ${pkg} not found, skipping`)
|
|
213
209
|
}
|
|
214
|
-
}
|
|
215
|
-
)
|
|
216
|
-
|
|
217
|
-
if (packagesWithTag.size === 0) {
|
|
218
|
-
console.info(`\nā ļø No packages found with tag '${globalTag}'`)
|
|
219
|
-
return
|
|
220
|
-
}
|
|
210
|
+
}
|
|
211
|
+
})
|
|
212
|
+
)
|
|
221
213
|
|
|
222
|
-
|
|
214
|
+
if (versionMap.size === 0) {
|
|
215
|
+
console.info(`\nā ļø No packages found to update`)
|
|
216
|
+
return
|
|
217
|
+
}
|
|
223
218
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
}
|
|
228
|
-
} else {
|
|
229
|
-
console.info(`\nš¦ Updating packages across workspaces...`)
|
|
219
|
+
// update all package.json files directly
|
|
220
|
+
console.info(`\nš¦ Updating ${packageJsonFiles.length} package.json file(s)...`)
|
|
221
|
+
let totalUpdates = 0
|
|
230
222
|
|
|
231
|
-
|
|
232
|
-
|
|
223
|
+
for (const packageJsonPath of packageJsonFiles) {
|
|
224
|
+
const packagesInWorkspace =
|
|
225
|
+
packagesByWorkspace.get(getWorkspaceName(packageJsonPath, rootDir))?.packages || []
|
|
226
|
+
|
|
227
|
+
if (packagesInWorkspace.length > 0) {
|
|
228
|
+
const updates = updatePackageJsonVersions(
|
|
229
|
+
packageJsonPath,
|
|
230
|
+
packagesInWorkspace,
|
|
231
|
+
versionMap
|
|
232
|
+
)
|
|
233
|
+
if (updates > 0) {
|
|
234
|
+
const name = getWorkspaceName(packageJsonPath, rootDir)
|
|
235
|
+
console.info(` ā ${name}: ${updates} package(s)`)
|
|
236
|
+
totalUpdates += updates
|
|
237
|
+
}
|
|
233
238
|
}
|
|
234
239
|
}
|
|
235
240
|
|
|
236
|
-
console.info(
|
|
237
|
-
|
|
238
|
-
)
|
|
241
|
+
console.info(`\nš Updated ${totalUpdates} dependency version(s)`)
|
|
242
|
+
|
|
243
|
+
console.info(`\nāļø Running 'bun install'...`)
|
|
239
244
|
$.cwd(rootDir)
|
|
240
245
|
try {
|
|
241
246
|
await $`bun install`
|
|
242
|
-
console.info(
|
|
247
|
+
console.info('ā
Done!')
|
|
243
248
|
} catch (error: any) {
|
|
244
249
|
const errorMessage = error.message?.split('\n')[0]
|
|
245
|
-
console.error(`šØ
|
|
246
|
-
console.error(
|
|
247
|
-
'Your dependencies might be in an inconsistent state. Please check manually.'
|
|
248
|
-
)
|
|
250
|
+
console.error(`šØ 'bun install' failed: ${errorMessage}`)
|
|
249
251
|
}
|
|
250
252
|
}
|
|
251
253
|
|
|
@@ -322,7 +324,7 @@ async function main() {
|
|
|
322
324
|
console.info(`š·ļø Using tag '${globalTag}'`)
|
|
323
325
|
}
|
|
324
326
|
|
|
325
|
-
await updatePackages(packagesByWorkspace, rootDir)
|
|
327
|
+
await updatePackages(packagesByWorkspace, rootDir, packageJsonFiles)
|
|
326
328
|
|
|
327
329
|
console.info('\nš Dependency update complete!')
|
|
328
330
|
}
|