Skip to content

Commit c311825

Browse files
committed
Chore: add deploy script
1 parent 4d16a9c commit c311825

File tree

3 files changed

+77
-1
lines changed

3 files changed

+77
-1
lines changed

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-eslint-demo",
3-
"version": "1.0.0",
3+
"version": "0.1.0",
44
"description": "The online demo to check `eslint-plugin-vue`.",
55
"engines": {
66
"node": ">=8"
@@ -26,6 +26,7 @@
2626
"monaco-editor": "^0.10.1",
2727
"npm-run-all": "^4.1.2",
2828
"rimraf": "^2.6.2",
29+
"shelljs": "^0.7.8",
2930
"string-replace-loader": "^1.3.0",
3031
"vue": "^2.5.9",
3132
"vue-eslint-parser": "^2.0.1-beta.2",
@@ -40,7 +41,11 @@
4041
"build:js": "webpack --progress --hide-modules",
4142
"build:monaco": "cpx node_modules/monaco-editor/min/vs/**/* dist/vs",
4243
"build:manifest": "appcache-manifest \"dist/**/*.{css,html,js,svg}\" --prefix /vue-eslint-demo --network-star -o dist/index.appcache",
44+
"build:versions": "node scripts/make-versions",
4345
"clean": "rimraf dist",
46+
"deploy": "node scripts/deploy",
47+
"preversion": "npm run build",
48+
"postversion": "git push && git push --tags && npm run deploy",
4449
"watch": "cross-env NODE_ENV=development run-p watch:*",
4550
"watch:html": "cpx src/*.html dist --watch",
4651
"watch:js": "webpack-dev-server --open --hot",

scripts/deploy.js

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*eslint-env node */
2+
3+
const sh = require("shelljs")
4+
5+
main()
6+
7+
/**
8+
* Main.
9+
* @returns {void}
10+
*/
11+
function main() {
12+
exec("npm run build")
13+
exec("git checkout gh-pages")
14+
15+
if (String(sh.cat("dist/versions.json")) === String(sh.cat("versions.json"))) {
16+
sh.echo("No update.")
17+
exec("git checkout -")
18+
return
19+
}
20+
21+
rm("-rf", "vs", "index.*")
22+
cp("dist/*", ".")
23+
exec("git add -A")
24+
exec("git commit -m \"Update: website\"")
25+
exec("git push")
26+
exec("git checkout -")
27+
}
28+
29+
/**
30+
* Execute `cp` command.
31+
* @returns {void}
32+
*/
33+
function cp(...args) {
34+
sh.echo(`> cp ${args.join(" ")}`)
35+
sh.cp(...args)
36+
}
37+
38+
/**
39+
* Execute a command.
40+
* @param {string} command The command to execute.
41+
* @returns {void}
42+
*/
43+
function exec(command) {
44+
sh.echo(`> ${command}`)
45+
const code = sh.exec(command, { stdio: "inherit" }).code
46+
if (code) {
47+
throw new Error(`Exited with ${code}.`)
48+
}
49+
}
50+
51+
/**
52+
* Execute `rm` command.
53+
* @returns {void}
54+
*/
55+
function rm(...args) {
56+
sh.echo(`> rm ${args.join(" ")}`)
57+
sh.rm(...args)
58+
}

scripts/make-versions.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*eslint-env node */
2+
3+
const fs = require("fs")
4+
5+
fs.writeFileSync(
6+
"dist/versions.json",
7+
JSON.stringify({
8+
"eslint": require("eslint/package.json").version,
9+
"eslint-plugin-vue": require("eslint-plugin-vue/package.json").version,
10+
"vue-eslint-demo": require("../package.json").version,
11+
"vue-eslint-parser": require("vue-eslint-parser/package.json").version,
12+
})
13+
)

0 commit comments

Comments
 (0)