-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: deployment to gh-pages, list of versions now published in versio…
…ns.json
- Loading branch information
Showing
4 changed files
with
54 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import type {Plugin} from 'vite'; | ||
import type {EmittedFile} from 'rollup'; | ||
|
||
export const emitFile = (emittedFile: EmittedFile): Plugin => { | ||
return { | ||
name: 'emit-file', | ||
apply: 'build', | ||
async buildStart(info) { | ||
this.emitFile(emittedFile); | ||
}, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const semver = require('semver'); | ||
|
||
const ghPagesFolder = process.cwd(); | ||
const availableVersions = fs | ||
.readdirSync(ghPagesFolder) | ||
.filter((folder) => folder.startsWith('v') && fs.statSync(path.join(ghPagesFolder, folder)).isDirectory()) | ||
.map((folder) => { | ||
const version = JSON.parse(fs.readFileSync(path.join(ghPagesFolder, folder, 'version.json'), 'utf8')); | ||
return { | ||
folder, | ||
version, | ||
}; | ||
}); | ||
|
||
availableVersions.sort((a, b) => -semver.compareBuild(a.version, b.version)); | ||
fs.writeFileSync('versions.json', JSON.stringify(availableVersions)); | ||
try { | ||
fs.unlinkSync('latest'); | ||
} catch (e) { | ||
if (e.code !== 'ENOENT') { | ||
throw e; | ||
} | ||
} | ||
fs.symlinkSync(availableVersions[0].folder, 'latest'); | ||
|
||
console.log('Ordered list of available versions:'); | ||
console.log(availableVersions); |