Skip to content

Commit

Permalink
chore: fix docs build
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed May 8, 2021
1 parent 6e7e735 commit d5aad3c
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 49 deletions.
20 changes: 4 additions & 16 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 4 additions & 6 deletions scripts/docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ import { run } from './run'
;(async() => {
await installBrowsersWithProgressBar()

run('npm run build')
run('npx vitepress build', path.resolve(__dirname, '../docs'))
await run('npm run build')
await run('npx vitepress build', path.resolve(__dirname, '../docs'))

run('npx slidev build slides.md -d --base /demo/composable-vue/ --out ../docs/.vitepress/dist/demo/composable-vue', path.resolve(__dirname, '../demo'))

run('cp packages/create-app/template/slides.md demo/build.md')
run('npx slidev build build.md -d --base /demo/starter/ --out ../docs/.vitepress/dist/demo/starter', path.resolve(__dirname, '../demo'))
await run('npx slidev build -d --base /demo/composable-vue/ --out ../../docs/.vitepress/dist/demo/composable-vue', path.resolve(__dirname, '../demo/composable-vue'))
await run('npx slidev build -d --base /demo/starter/ --out ../../docs/.vitepress/dist/demo/starter', path.resolve(__dirname, '../demo/starter'))
})()
.catch((e) => {
console.error(e)
Expand Down
11 changes: 8 additions & 3 deletions scripts/publish.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import fs from 'fs-extra'
import { run } from './run'

fs.copyFileSync('README.md', 'packages/slidev/README.md')

run('npx pnpm -r publish --access public --no-git-checks')
;(async() => {
await fs.copyFile('README.md', 'packages/slidev/README.md')
await run('npx pnpm -r publish --access public --no-git-checks')
})()
.catch((e) => {
console.error(e)
process.exit(1)
})
50 changes: 28 additions & 22 deletions scripts/release.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,37 @@
/* eslint-disable @typescript-eslint/no-var-requires */
import { readFileSync, writeFileSync } from 'fs'
import { join } from 'path'
import fs from 'fs-extra'
import { objectMap } from '@antfu/utils'
import { run, runArgs } from './run'

run('npx bumpp package.json packages/*/package.json')
;(async() => {
await run('npx bumpp package.json packages/*/package.json')

const templates = [
'packages/create-app/template',
'packages/create-theme/template',
]
const templates = [
'packages/create-app/template',
'packages/create-theme/template',
]

const { version } = require('../package.json')
const { version } = require('../package.json')

for (const template of templates) {
const path = join(template, 'package.json')
const pkg = JSON.parse(readFileSync(path, 'utf-8'))
pkg.dependencies = objectMap(pkg.dependencies, (k, v) => {
if (k.startsWith('@slidev/'))
return [k, `^${version}`]
return [k, v]
})
writeFileSync(path, `${JSON.stringify(pkg, null, 2)}\n`, 'utf-8')
}
for (const template of templates) {
const path = join(template, 'package.json')
const pkg = await fs.readJSON(path)
pkg.dependencies = objectMap(pkg.dependencies, (k, v) => {
if (k.startsWith('@slidev/'))
return [k, `^${version}`]
return [k, v]
})
await fs.writeJSON(path, pkg, { spaces: 2 })
}

run('git add .')
runArgs('git', ['commit', '-m', `chore: release v${version}`])
run(`git tag v${version}`)
run('git push')
run('git push origin --tags')
await run('git add .')
await runArgs('git', ['commit', '-m', `chore: release v${version}`])
await run(`git tag v${version}`)
await run('git push')
await run('git push origin --tags')
})()
.catch((e) => {
console.error(e)
process.exit(1)
})
4 changes: 2 additions & 2 deletions scripts/run.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import execa from 'execa'

export function run(command: string, cwd?: string) {
execa.commandSync(command, { stdio: 'inherit', cwd })
return execa.command(command, { stdio: 'inherit', cwd })
}

export function runArgs(command: string, args: string[], cwd?: string) {
execa.sync(command, args, { stdio: 'inherit', cwd })
return execa(command, args, { stdio: 'inherit', cwd })
}

0 comments on commit d5aad3c

Please sign in to comment.