mirror of
https://github.com/bs-community/blessing-skin-server.git
synced 2024-11-27 05:39:55 +08:00
Make some scripts cross-platform
This commit is contained in:
parent
776d1eee1e
commit
7dc59cf444
10
package.json
10
package.json
@ -11,9 +11,10 @@
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "webpack-dev-server",
|
||||
"build": "rimraf public/app && webpack --mode=production -p && node --experimental-modules scripts/commitish.mjs",
|
||||
"build": "rimraf public/app && webpack --mode=production -p && ts-node scripts/commitish.ts",
|
||||
"lint": "eslint --ext=.js,.vue,.ts -f=beauty .",
|
||||
"test": "tsc -p . && jest",
|
||||
"new-version": "ts-node scripts/version.ts",
|
||||
"codecov": "codecov -F js"
|
||||
},
|
||||
"dependencies": {
|
||||
@ -41,8 +42,11 @@
|
||||
"@babel/preset-typescript": "^7.3.3",
|
||||
"@gplane/tsconfig": "^1.0.0",
|
||||
"@types/echarts": "^4.1.9",
|
||||
"@types/execa": "^0.9.0",
|
||||
"@types/fs-extra": "^5.1.0",
|
||||
"@types/jest": "^24.0.12",
|
||||
"@types/jquery": "^3.3.29",
|
||||
"@types/semver": "^6.0.0",
|
||||
"@types/webpack": "^4.4.29",
|
||||
"@typescript-eslint/eslint-plugin": "^1.7.0",
|
||||
"@typescript-eslint/parser": "^1.7.0",
|
||||
@ -61,8 +65,10 @@
|
||||
"eslint-config-gplane": "^5.1.3",
|
||||
"eslint-formatter-beauty": "^3.0.0",
|
||||
"eslint-plugin-vue": "^5.2.2",
|
||||
"execa": "^1.0.0",
|
||||
"expose-loader": "^0.7.5",
|
||||
"file-loader": "^3.0.1",
|
||||
"fs-extra": "^7.0.1",
|
||||
"jest": "^24.7.1",
|
||||
"jest-extended": "^0.11.1",
|
||||
"json-loader": "^0.5.7",
|
||||
@ -75,6 +81,7 @@
|
||||
"style-loader": "^0.23.1",
|
||||
"stylus": "^0.54.5",
|
||||
"stylus-loader": "^3.0.2",
|
||||
"ts-node": "^8.1.0",
|
||||
"typescript": "^3.4.1",
|
||||
"url-loader": "^1.1.2",
|
||||
"vue-jest": "^4.0.0-beta.2",
|
||||
@ -136,6 +143,7 @@
|
||||
2,
|
||||
120
|
||||
],
|
||||
"prefer-destructuring": 0,
|
||||
"prefer-object-spread": 0,
|
||||
"import/no-unresolved": 0
|
||||
},
|
||||
|
@ -1,15 +0,0 @@
|
||||
import childProcess from 'child_process'
|
||||
import util from 'util'
|
||||
import fs from 'fs'
|
||||
|
||||
(async () => {
|
||||
const [manifest, commit] = await Promise.all([
|
||||
util
|
||||
.promisify(fs.readFile)('./public/app/manifest.json', 'utf8')
|
||||
.then(JSON.parse),
|
||||
util.promisify(childProcess.exec)('git log --pretty=%H -1').then(value => value.stdout.trim()),
|
||||
])
|
||||
|
||||
manifest.commit = commit
|
||||
await util.promisify(fs.writeFile)('./public/app/manifest.json', JSON.stringify(manifest, null, 2))
|
||||
})()
|
20
scripts/commitish.ts
Normal file
20
scripts/commitish.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import childProcess from 'child_process'
|
||||
import util from 'util'
|
||||
import fs from 'fs'
|
||||
|
||||
(async () => {
|
||||
const [manifest, commit]: [object & { commit: string }, string] = await Promise.all([
|
||||
util
|
||||
.promisify(fs.readFile)('./public/app/manifest.json', 'utf8')
|
||||
.then(JSON.parse),
|
||||
util
|
||||
.promisify(childProcess.exec)('git log --pretty=%H -1')
|
||||
.then(value => value.stdout.trim()),
|
||||
])
|
||||
|
||||
manifest.commit = commit
|
||||
await util.promisify(fs.writeFile)(
|
||||
'./public/app/manifest.json',
|
||||
JSON.stringify(manifest, null, 2)
|
||||
)
|
||||
})()
|
@ -1,12 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
CURRENT=$(cat package.json | grep -P '\d+\.\d+\.\d+' -o | head -n 1)
|
||||
NEW_VERSION=$(./node_modules/.bin/semver -i $1 $CURRENT)
|
||||
sed -i "0,/$CURRENT/s/$CURRENT/$NEW_VERSION/" package.json config/app.php
|
||||
git add package.json config/app.php
|
||||
git commit -m "Bump version to $NEW_VERSION"
|
||||
git tag -a $NEW_VERSION -m $NEW_VERSION
|
||||
git checkout master
|
||||
git merge dev
|
||||
git push --all --follow-tags
|
||||
git checkout dev
|
32
scripts/version.ts
Normal file
32
scripts/version.ts
Normal file
@ -0,0 +1,32 @@
|
||||
import fs from 'fs-extra'
|
||||
import semver from 'semver'
|
||||
import execa from 'execa'
|
||||
import { version } from '../package.json'
|
||||
|
||||
const action = process.argv[2] as semver.ReleaseType
|
||||
const increased = semver.inc(version, action)
|
||||
if (!increased) {
|
||||
throw new Error('Invalid semver action.')
|
||||
}
|
||||
const next = increased!
|
||||
|
||||
async function saveVersion(path: string): Promise<void> {
|
||||
const content = await fs.readFile(path, 'utf-8')
|
||||
await fs.writeFile(path, content.replace(version, next!))
|
||||
}
|
||||
|
||||
function git(args: readonly string[]) {
|
||||
return execa('git', args, { stdio: 'inherit' })
|
||||
}
|
||||
|
||||
(async () => {
|
||||
const files = ['./config/app.php', './package.json']
|
||||
await Promise.all(files.map(saveVersion))
|
||||
await git(['add'].concat(files))
|
||||
await git(['commit', '-m', `Bump version to ${next}`])
|
||||
await git(['tag', '-a', next, '-m', next])
|
||||
await git(['checkout', 'master'])
|
||||
await git(['merge', 'dev'])
|
||||
await git(['push', '--all', '--follow-tags'])
|
||||
await git(['checkout', 'dev'])
|
||||
})()
|
@ -4,8 +4,9 @@
|
||||
"declaration": false,
|
||||
"allowJs": true,
|
||||
"target": "es2015",
|
||||
"module": "esnext",
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"resolveJsonModule": true,
|
||||
"noEmit": true,
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
|
47
yarn.lock
47
yarn.lock
@ -1070,6 +1070,20 @@
|
||||
resolved "https://registry.npmjs.org/@types/events/-/events-3.0.0.tgz#2862f3f58a9a7f7c3e78d79f130dd4d71c25c2a7"
|
||||
integrity sha512-EaObqwIvayI5a8dCzhFrjKzVwKLxjoG9T6Ppd5CEo07LRKfQ8Yokw54r5+Wq7FaBQ+yXRvQAYPrHwya1/UFt9g==
|
||||
|
||||
"@types/execa@^0.9.0":
|
||||
version "0.9.0"
|
||||
resolved "https://registry.npmjs.org/@types/execa/-/execa-0.9.0.tgz#9b025d2755f17e80beaf9368c3f4f319d8b0fb93"
|
||||
integrity sha512-mgfd93RhzjYBUHHV532turHC2j4l/qxsF/PbfDmprHDEUHmNZGlDn1CEsulGK3AfsPdhkWzZQT/S/k0UGhLGsA==
|
||||
dependencies:
|
||||
"@types/node" "*"
|
||||
|
||||
"@types/fs-extra@^5.1.0":
|
||||
version "5.1.0"
|
||||
resolved "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-5.1.0.tgz#2a325ef97901504a3828718c390d34b8426a10a1"
|
||||
integrity sha512-AInn5+UBFIK9FK5xc9yP5e3TQSPNNgjHByqYcj9g5elVBnDQcQL7PlO1CIRy2gWlbwK7UPYqi7vRvFA44dCmYQ==
|
||||
dependencies:
|
||||
"@types/node" "*"
|
||||
|
||||
"@types/glob@^7.1.1":
|
||||
version "7.1.1"
|
||||
resolved "https://registry.npmjs.org/@types/glob/-/glob-7.1.1.tgz#aa59a1c6e3fbc421e07ccd31a944c30eba521575"
|
||||
@ -1118,6 +1132,11 @@
|
||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-11.11.3.tgz#7c6b0f8eaf16ae530795de2ad1b85d34bf2f5c58"
|
||||
integrity sha512-wp6IOGu1lxsfnrD+5mX6qwSwWuqsdkKKxTN4aQc4wByHAKZJf9/D4KXPQ1POUjEbnCP5LMggB0OEFNY9OTsMqg==
|
||||
|
||||
"@types/semver@^6.0.0":
|
||||
version "6.0.0"
|
||||
resolved "https://registry.npmjs.org/@types/semver/-/semver-6.0.0.tgz#86ba89f02a414e39c68d02b351872e4ed31bd773"
|
||||
integrity sha512-OO0srjOGH99a4LUN2its3+r6CBYcplhJ466yLqs+zvAWgphCpS8hYZEZ797tRDP/QKcqTdb/YCN6ifASoAWkrQ==
|
||||
|
||||
"@types/sizzle@*":
|
||||
version "2.3.2"
|
||||
resolved "https://registry.npmjs.org/@types/sizzle/-/sizzle-2.3.2.tgz#a811b8c18e2babab7d542b3365887ae2e4d9de47"
|
||||
@ -1572,6 +1591,11 @@ are-we-there-yet@~1.1.2:
|
||||
delegates "^1.0.0"
|
||||
readable-stream "^2.0.6"
|
||||
|
||||
arg@^4.1.0:
|
||||
version "4.1.0"
|
||||
resolved "https://registry.npmjs.org/arg/-/arg-4.1.0.tgz#583c518199419e0037abb74062c37f8519e575f0"
|
||||
integrity sha512-ZWc51jO3qegGkVh8Hwpv636EkbesNV5ZNQPCtRa+0qytRYPEs9IYT9qITY9buezqUH5uqyzlWLcufrzU2rffdg==
|
||||
|
||||
argparse@^1.0.7:
|
||||
version "1.0.10"
|
||||
resolved "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911"
|
||||
@ -3295,7 +3319,7 @@ diff-sequences@^24.3.0:
|
||||
resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-24.3.0.tgz#0f20e8a1df1abddaf4d9c226680952e64118b975"
|
||||
integrity sha512-xLqpez+Zj9GKSnPWS0WZw1igGocZ+uua8+y+5dDNTT934N3QuY1sp2LkHzwiaYQGz60hMq0pjAshdeXm5VUOEw==
|
||||
|
||||
diff@^3.2.0:
|
||||
diff@^3.1.0, diff@^3.2.0:
|
||||
version "3.5.0"
|
||||
resolved "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12"
|
||||
|
||||
@ -3791,6 +3815,7 @@ exec-sh@^0.3.2:
|
||||
execa@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.npmjs.org/execa/-/execa-1.0.0.tgz#c6236a5bb4df6d6f15e88e7f017798216749ddd8"
|
||||
integrity sha512-adbxcyWV46qiHyvSp50TKt05tB4tK3HcmF7/nxfAdhnox83seTDbwnaqKO4sXRy7roHAIFqJP/Rw/AuEbX61LA==
|
||||
dependencies:
|
||||
cross-spawn "^6.0.0"
|
||||
get-stream "^4.0.0"
|
||||
@ -4194,7 +4219,7 @@ from2@^2.1.0:
|
||||
inherits "^2.0.1"
|
||||
readable-stream "^2.0.0"
|
||||
|
||||
fs-extra@^7.0.0:
|
||||
fs-extra@^7.0.0, fs-extra@^7.0.1:
|
||||
version "7.0.1"
|
||||
resolved "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.1.tgz#4f189c44aa123b895f722804f55ea23eadc348e9"
|
||||
integrity sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==
|
||||
@ -6111,7 +6136,7 @@ make-dir@^1.0.0, make-dir@^1.3.0:
|
||||
dependencies:
|
||||
pify "^3.0.0"
|
||||
|
||||
make-error@1.x:
|
||||
make-error@1.x, make-error@^1.1.1:
|
||||
version "1.3.5"
|
||||
resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.5.tgz#efe4e81f6db28cadd605c70f29c831b58ef776c8"
|
||||
integrity sha512-c3sIjNUow0+8swNwVpqoH4YCShKNFkMaw6oH1mNS2haDZQqkeZFlHS3dhoeEbKKmJB4vXpJucU6oH75aDYeE9g==
|
||||
@ -9102,6 +9127,17 @@ ts-jest@^23.10.5:
|
||||
semver "^5.5"
|
||||
yargs-parser "10.x"
|
||||
|
||||
ts-node@^8.1.0:
|
||||
version "8.1.0"
|
||||
resolved "https://registry.npmjs.org/ts-node/-/ts-node-8.1.0.tgz#8c4b37036abd448577db22a061fd7a67d47e658e"
|
||||
integrity sha512-34jpuOrxDuf+O6iW1JpgTRDFynUZ1iEqtYruBqh35gICNjN8x+LpVcPAcwzLPi9VU6mdA3ym+x233nZmZp445A==
|
||||
dependencies:
|
||||
arg "^4.1.0"
|
||||
diff "^3.1.0"
|
||||
make-error "^1.1.1"
|
||||
source-map-support "^0.5.6"
|
||||
yn "^3.0.0"
|
||||
|
||||
tslib@^1.8.1, tslib@^1.9.0:
|
||||
version "1.9.3"
|
||||
resolved "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286"
|
||||
@ -9823,6 +9859,11 @@ yargs@^7.0.0:
|
||||
y18n "^3.2.1"
|
||||
yargs-parser "^5.0.0"
|
||||
|
||||
yn@^3.0.0:
|
||||
version "3.1.0"
|
||||
resolved "https://registry.npmjs.org/yn/-/yn-3.1.0.tgz#fcbe2db63610361afcc5eb9e0ac91e976d046114"
|
||||
integrity sha512-kKfnnYkbTfrAdd0xICNFw7Atm8nKpLcLv9AZGEt+kczL/WQVai4e2V6ZN8U/O+iI6WrNuJjNNOyu4zfhl9D3Hg==
|
||||
|
||||
zrender@4.0.7:
|
||||
version "4.0.7"
|
||||
resolved "https://registry.npmjs.org/zrender/-/zrender-4.0.7.tgz#15ae960822f5efed410995d37e5107fe3de10e6d"
|
||||
|
Loading…
Reference in New Issue
Block a user