Skip to content

Commit

Permalink
chore: update npm script
Browse files Browse the repository at this point in the history
  • Loading branch information
anncwb committed Oct 26, 2020
1 parent adffefd commit 2be166d
Show file tree
Hide file tree
Showing 9 changed files with 275 additions and 456 deletions.
3 changes: 3 additions & 0 deletions .browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
> 1%
last 2 versions
not ie <= 10
52 changes: 0 additions & 52 deletions build/jsc.ts

This file was deleted.

2 changes: 2 additions & 0 deletions build/script/changelog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ export const runChangeLog = async () => {
process.exit(1);
}
};

runChangeLog();
40 changes: 0 additions & 40 deletions build/script/cli.ts

This file was deleted.

3 changes: 2 additions & 1 deletion build/script/build.ts → build/script/postBuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const runBuild = async (preview = false) => {
try {
const argvList = argv._;
if (preview) {
let cmd = `cross-env NODE_ENV=production vite build`;
let cmd = `npm run build`;
await sh(cmd, {
async: true,
nopipe: true,
Expand All @@ -33,3 +33,4 @@ export const runBuild = async (preview = false) => {
process.exit(1);
}
};
runBuild();
23 changes: 10 additions & 13 deletions build/script/preserve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,26 @@ import path from 'path';
import fs from 'fs-extra';
import { isEqual } from 'lodash';
import { sh } from 'tasksfile';
import {
successConsole,
// errorConsole
} from '../utils';
import { successConsole, errorConsole } from '../utils';

const resolve = (dir: string) => {
return path.resolve(process.cwd(), dir);
};

// const reg = /[\u4E00-\u9FA5\uF900-\uFA2D]/;
const reg = /[\u4E00-\u9FA5\uF900-\uFA2D]/;

let NEED_INSTALL = false;

export async function runPreserve() {
// rc.6 fixed
// const cwdPath = process.cwd();
// if (reg.test(cwdPath)) {
// errorConsole(
// 'Do not include Chinese, Japanese or Korean in the full path of the project directory, please modify the directory name and run again!'
// );
// errorConsole('项目目录全路径请勿包含中文、日文、韩文,请修改目录名后再次重新运行!');
// process.exit(1);
// }
const cwdPath = process.cwd();
if (reg.test(cwdPath)) {
errorConsole(
'Do not include Chinese, Japanese or Korean in the full path of the project directory, please modify the directory name and run again!'
);
errorConsole('项目目录全路径请勿包含中文、日文、韩文,请修改目录名后再次重新运行!');
process.exit(1);
}

fs.mkdirp(resolve('build/.cache'));
function checkPkgUpdate() {
Expand Down
52 changes: 26 additions & 26 deletions build/script/preview.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import chalk from 'chalk';
import Koa from 'koa';
import inquirer from 'inquirer';
// import inquirer from 'inquirer';
import staticServer from 'koa-static';
import portfinder from 'portfinder';
import { resolve } from 'path';
import viteConfig from '../../vite.config';
import { getIPAddress } from '../utils';
import { runBuild } from './build';
// import { runBuild } from './postBuild';

const BUILD = 1;
const NO_BUILD = 2;
// const BUILD = 1;
// const NO_BUILD = 2;

// start server
const startApp = () => {
Expand All @@ -35,25 +35,25 @@ const startApp = () => {
});
};

export const runPreview = async () => {
const prompt = inquirer.prompt({
type: 'list',
message: 'Please select a preview method',
name: 'type',
choices: [
{
name: 'Preview after packaging',
value: BUILD,
},
{
name: `No packaging, preview directly (need to have dist file after packaging)`,
value: NO_BUILD,
},
],
});
const { type } = await prompt;
if (type === BUILD) {
await runBuild(true);
}
startApp();
};
// export const runPreview = async () => {
// // const prompt = inquirer.prompt({
// // type: 'list',
// // message: 'Please select a preview method',
// // name: 'type',
// // choices: [
// // {
// // name: 'Preview after packaging',
// // value: BUILD,
// // },
// // {
// // name: `No packaging, preview directly (need to have dist file after packaging)`,
// // value: NO_BUILD,
// // },
// // ],
// // });
// const { type } = await prompt;
// if (type === BUILD) {
// await runBuild(true);
// }
// };
startApp();
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,22 @@
"name": "vben-admin-2.0",
"version": "2.0.0-rc.5",
"scripts": {
"bootstrap": "yarn install || npm install",
"serve": "cross-env ts-node --files -P ./build/tsconfig.json ./build/script/preserve && cross-env NODE_ENV=development vite",
"build": "cross-env NODE_ENV=production vite build && node ./build/jsc.ts build",
"bootstrap": "yarn install",
"serve": "esno ./build/script/preserve.ts && cross-env NODE_ENV=development vite",
"build": "cross-env NODE_ENV=production vite build && esno ./build/script/postBuild.ts",
"build:site": "cross-env SITE=true npm run build ",
"build:no-cache": "yarn clean:cache && node ./build/jsc.ts build",
"build:no-cache": "yarn clean:cache && npm run build",
"report": "cross-env REPORT=true npm run build ",
"preview": "node ./build/jsc.ts preview",
"log": "node ./build/jsc.ts log",
"preview": "npm run build && esno ./build/script/preview.ts",
"preview:dist": "esno ./build/script/preview.ts",
"log": "esno ./build/script/changelog.ts",
"clean:cache": "rimraf node_modules/.cache/ && rimraf node_modules/.vite_opt_cache",
"clean:lib": "npx rimraf node_modules",
"ls-lint": "npx ls-lint",
"lint:eslint": "eslint --fix --ext \"src/**/*.{vue,less,css,scss}\"",
"lint:prettier": "prettier --write --loglevel warn \"src/**/*.{js,json,tsx,css,less,scss,vue,html,md}\"",
"lint:stylelint": "stylelint --fix \"**/*.{vue,less,postcss,css,scss}\" --cache --cache-location node_modules/.cache/stylelint/",
"reinstall": "rimraf node_modules && rimraf yarn.lock && rimraf package.lock.json && npm run bootstrap"
"reinstall": "rimraf yarn.lock && rimraf package.lock.json && rimraf node_modules && npm run bootstrap"
},
"dependencies": {
"@iconify/iconify": "^2.0.0-rc.1",
Expand All @@ -42,13 +43,12 @@
"devDependencies": {
"@commitlint/cli": "^11.0.0",
"@commitlint/config-conventional": "^11.0.0",
"@iconify/json": "^1.1.246",
"@iconify/json": "^1.1.247",
"@ls-lint/ls-lint": "^1.9.2",
"@purge-icons/generated": "^0.4.1",
"@types/echarts": "^4.8.3",
"@types/fs-extra": "^9.0.2",
"@types/html-minifier": "^4.0.0",
"@types/inquirer": "^7.3.1",
"@types/koa-static": "^4.0.1",
"@types/lodash-es": "^4.17.3",
"@types/mockjs": "^1.0.3",
Expand All @@ -70,10 +70,10 @@
"eslint-config-prettier": "^6.14.0",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-vue": "^7.1.0",
"esno": "^0.2.4",
"fs-extra": "^9.0.1",
"html-minifier": "^4.0.0",
"husky": "^4.3.0",
"inquirer": "^7.3.3",
"koa-static": "^5.0.0",
"less": "^3.12.2",
"lint-staged": "^10.4.2",
Expand Down
Loading

0 comments on commit 2be166d

Please sign in to comment.