1
1
import { execa } from 'execa'
2
- import glob from 'fast-glob'
3
2
import { green } from 'kleur/colors'
4
3
import mri from 'mri'
5
4
import fs from 'node:fs/promises'
@@ -98,23 +97,11 @@ async function main() {
98
97
}
99
98
}
100
99
101
- /** This is the identifier used by URLs. */
102
- let newReleaseId = 'v' + String ( newReleaseMajor )
103
- if ( newReleaseParts . length > 3 ) {
104
- if ( newReleaseMajor === lastReleaseMajor ) {
105
- newReleaseId += '.' + newReleaseMinor
106
- if ( newReleaseMinor === lastReleaseMinor ) {
107
- newReleaseId += '.' + newReleaseParts [ 2 ]
108
- }
109
- }
110
- newReleaseId += '-' + newReleaseParts [ 3 ]
111
- }
112
-
113
100
if ( process . env . DOCS_DEPLOY_KEY ) {
114
101
await installDeployKey ( process . env . DOCS_DEPLOY_KEY )
115
102
}
116
103
117
- log ( 'Publishing docs for version:' , newReleaseId )
104
+ log ( 'Publishing docs for version:' , newVersion )
118
105
119
106
log ( 'Cloning main branch of radashi-org.github.io' )
120
107
await execa (
@@ -169,73 +156,8 @@ async function main() {
169
156
log ( 'Symlinking radashi to ./www/radashi' )
170
157
await fs . symlink ( '..' , './www/radashi' )
171
158
172
- const removedVersions = new Set < string > ( )
173
- const cleanVersions = ( oldVersions : string [ ] ) =>
174
- oldVersions . filter ( oldVersion => {
175
- if ( newVersion === oldVersion ) {
176
- return true
177
- }
178
- const oldRawVersion = toRawVersion ( oldVersion )
179
- if ( newVersion === oldRawVersion ) {
180
- // Avoid having a beta, RC, or stable with the same raw version.
181
- removedVersions . add ( oldVersion )
182
- return false
183
- }
184
- // Beta versions are reserved for non-breaking changes that have
185
- // been merged into the "main" branch and don't have a stable
186
- // version yet.
187
- if ( oldVersion . includes ( 'beta' ) ) {
188
- if ( newVersion . includes ( 'beta' ) ) {
189
- // Only one beta version is made available at a time.
190
- removedVersions . add ( oldVersion )
191
- return false
192
- }
193
- }
194
- // Alpha versions are reserved for breaking changes that have
195
- // been merged into the "next" branch.
196
- else if ( oldVersion . includes ( 'alpha' ) ) {
197
- if ( newVersion . includes ( 'alpha' ) ) {
198
- // Only one alpha version is made available at a time.
199
- removedVersions . add ( oldVersion )
200
- return false
201
- }
202
- }
203
- // Only a stable version should be left to handle.
204
- else {
205
- const oldMajorVersion = + oldRawVersion . split ( '.' ) [ 0 ]
206
- if ( newReleaseMajor - oldMajorVersion > 2 ) {
207
- // Only 3 major versions are made available at a time.
208
- removedVersions . add ( oldVersion )
209
- return false
210
- }
211
- }
212
- return true
213
- } )
214
-
215
- log ( 'Updating ./www/public/versions.json' )
216
- const versions = new Set (
217
- cleanVersions (
218
- JSON . parse ( await fs . readFile ( './www/public/versions.json' , 'utf8' ) ) ,
219
- ) ,
220
- )
221
- versions . add ( newReleaseId )
222
- await fs . writeFile (
223
- './www/public/versions.json' ,
224
- JSON . stringify ( [ ...versions ] ) ,
225
- )
226
-
227
- if ( removedVersions . size > 0 ) {
228
- log ( 'Removing docs for unmaintained versions' )
229
- for ( const removedVersion of removedVersions ) {
230
- await fs . rm ( `./www/dist/${ removedVersion } ` , { recursive : true } )
231
- }
232
- }
233
-
234
- log ( 'Removing docs that will be overwritten' )
235
- await fs . rm ( `./www/dist/${ newReleaseId } ` , { recursive : true } ) . catch ( ( ) => { } )
236
-
237
- log ( 'Building docs with version-specific --outDir' )
238
- await execa ( 'pnpm' , [ 'build' , '--outDir' , `./dist/${ newReleaseId } ` ] , {
159
+ log ( 'Building docs' )
160
+ await execa ( 'pnpm' , [ 'build' ] , {
239
161
cwd : './www' ,
240
162
stdio : 'inherit' ,
241
163
extendEnv : false ,
@@ -249,15 +171,6 @@ async function main() {
249
171
} ,
250
172
} ) . catch ( exit )
251
173
252
- if ( newReleaseParts . length === 3 ) {
253
- log ( 'Copying build into root folder' )
254
- const cwd = `www/dist/${ newReleaseId } `
255
- const files = await glob ( '**/*' , { cwd } )
256
- for ( const file of files ) {
257
- await fs . cp ( `${ cwd } /${ file } ` , `www/dist/${ file } ` )
258
- }
259
- }
260
-
261
174
// Set up git user in CI environment
262
175
if ( process . env . CI ) {
263
176
if ( process . env . GITHUB_ACTOR ) {
@@ -283,7 +196,7 @@ async function main() {
283
196
284
197
log ( 'Pushing to gh-pages branch' )
285
198
await execa ( 'git' , [ 'add' , '-A' ] , { cwd : './www/dist' } )
286
- await execa ( 'git' , [ 'commit' , '-m' , `chore: ${ newReleaseId } ` ] , {
199
+ await execa ( 'git' , [ 'commit' , '-m' , `chore: ${ newVersion } ` ] , {
287
200
cwd : './www/dist' ,
288
201
stdio : 'inherit' ,
289
202
} )
@@ -301,25 +214,6 @@ function exit() {
301
214
process . exit ( 1 )
302
215
}
303
216
304
- /**
305
- * Extracts the raw version from a version string that may not have
306
- * its minor or patch version set. It also removes any suffix like
307
- * "-rc" or "-beta".
308
- *
309
- * @example
310
- * ```ts
311
- * toRawVersion('1') // '1.0.0'
312
- * toRawVersion('1.1.0-rc') // '1.1.0'
313
- * ```
314
- */
315
- function toRawVersion ( version : string ) {
316
- let [ , rawVersion ] = version . match ( / ^ v ? ( \d + (?: \. \d + (?: \. \d + ) ? ) ? ) / ) !
317
- for ( let i = rawVersion . split ( '.' ) . length ; i < 3 ; i ++ ) {
318
- rawVersion += '.0'
319
- }
320
- return rawVersion
321
- }
322
-
323
217
async function coerceTagToVersion ( tag : string ) {
324
218
let version : string
325
219
let metaId : string
0 commit comments