Skip to content

Commit af14cc8

Browse files
committed
chore: add new binary paths for nightly release
1 parent 33101d9 commit af14cc8

1 file changed

Lines changed: 37 additions & 4 deletions

File tree

‎scripts/release-nightly.mjs‎

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,44 @@
1+
import{readFile,writeFile}from'node:fs/promises'
12
import{resolve}from'node:path'
23
import{x}from'tinyexec'
34

45
constdirs=['create-nuxt','nuxi','nuxt-cli']
56

67
for(constdirofdirs){
7-
awaitx('changelogen',['--canary','nightly','--publish'],{
8-
nodeOptions: {stdio: 'inherit',cwd: resolve('packages',dir)},
9-
throwOnError: true,
10-
})
8+
constcwd=resolve('packages',dir)
9+
constpkgPath=resolve(cwd,'package.json')
10+
constoriginal=awaitreadFile(pkgPath,'utf8')
11+
12+
awaitaddNightlyBins(pkgPath,original)
13+
14+
try{
15+
awaitx('changelogen',['--canary','nightly','--publish'],{
16+
nodeOptions: {stdio: 'inherit', cwd },
17+
throwOnError: true,
18+
})
19+
}
20+
finally{
21+
awaitwriteFile(pkgPath,original)
22+
}
23+
}
24+
25+
/**
26+
* `npx <pkg>` only resolves a bin whose name matches the (unscoped) package
27+
* name when a package ships more than one bin, so the `-nightly` packages need
28+
* `-nightly` aliases for each of their bins.
29+
*/
30+
asyncfunctionaddNightlyBins(pkgPath,original){
31+
constpkg=JSON.parse(original)
32+
if(!pkg.bin){
33+
return
34+
}
35+
36+
constbin={ ...pkg.bin}
37+
constentrypoint=Object.values(pkg.bin)[0]
38+
bin[`${pkg.name.split('/').pop()}-nightly`]=entrypoint
39+
for(const[name,path]ofObject.entries(pkg.bin)){
40+
bin[`${name}-nightly`]=path
41+
}
42+
43+
awaitwriteFile(pkgPath,`${JSON.stringify({ ...pkg, bin },null,2)}\n`)
1144
}

0 commit comments

Comments
 (0)