@qse/edu-scripts 1.13.6 → 1.13.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,46 +1,42 @@
1
- "use strict";
2
-
3
- const WebpackDevServer = require('webpack-dev-server');
4
-
5
- /**
6
- * @param {*} args
7
- * @param {import('../utils/defineConfig').Config} override
8
- */
1
+ // src/config/webpackDevServerConfig.js
2
+ var WebpackDevServer = require("webpack-dev-server");
9
3
  module.exports = function getWebpackDevServerConfig(args, override) {
10
- const host = process.env.HOST || '0.0.0.0';
4
+ const host = process.env.HOST || "0.0.0.0";
11
5
  const sockHost = process.env.WDS_SOCKET_HOST;
12
6
  const sockPort = process.env.WDS_SOCKET_PORT;
13
-
14
- /** @type {WebpackDevServer.Configuration} */
15
7
  const devServer = {
16
8
  hot: true,
17
- allowedHosts: 'all',
9
+ allowedHosts: "all",
18
10
  historyApiFallback: true,
19
11
  port: args.port,
20
12
  open: args.open,
21
13
  host,
22
14
  client: {
23
- webSocketURL: {
24
- protocol: 'auto:',
25
- hostname: sockHost,
26
- port: sockPort
15
+ webSocketURL: { protocol: "auto:", hostname: sockHost, port: sockPort },
16
+ overlay: {
17
+ runtimeErrors: false,
18
+ errors: true,
19
+ warnings: false
27
20
  }
28
21
  },
29
22
  headers: {
30
- 'Access-Control-Allow-Origin': '*',
31
- 'Access-Control-Allow-Methods': '*',
32
- 'Access-Control-Allow-Headers': '*'
23
+ "Access-Control-Allow-Origin": "*",
24
+ "Access-Control-Allow-Methods": "*",
25
+ "Access-Control-Allow-Headers": "*"
33
26
  },
34
- proxy: [...override.proxy, {
35
- context: ['/api'],
36
- target: 'http://192.168.10.19:3339/qsxxwapdev',
37
- changeOrigin: true,
38
- headers: {
39
- host: 'www.zhidianbao.cn',
40
- origin: 'http://www.zhidianbao.cn'
27
+ proxy: [
28
+ ...override.proxy,
29
+ {
30
+ context: ["/api"],
31
+ target: "http://192.168.10.19:3339/qsxxwapdev",
32
+ changeOrigin: true,
33
+ headers: {
34
+ host: "www.zhidianbao.cn",
35
+ origin: "http://www.zhidianbao.cn"
36
+ }
41
37
  }
42
- }],
38
+ ],
43
39
  compress: true
44
40
  };
45
41
  return devServer;
46
- };
42
+ };
package/lib/deploy.js CHANGED
@@ -1,18 +1,15 @@
1
- "use strict";
2
-
3
- const {
4
- sshSftp
5
- } = require('@qse/ssh-sftp');
6
- const path = require('path');
7
- const paths = require('./config/paths');
8
- const pkg = require(paths.package);
9
- const chalk = require('chalk');
10
- const fs = require('fs-extra');
11
- const changeDeployVersion = require('./utils/changeDeployVersion');
12
- const ora = require('ora');
13
- const appConfig = require('./utils/appConfig');
14
- const baseConfig = {
15
- localPath: 'dist',
1
+ // src/deploy.js
2
+ var { sshSftp } = require("@qse/ssh-sftp");
3
+ var path = require("path");
4
+ var paths = require("./config/paths");
5
+ var pkg = require(paths.package);
6
+ var chalk = require("chalk");
7
+ var fs = require("fs-extra");
8
+ var changeDeployVersion = require("./utils/changeDeployVersion");
9
+ var ora = require("ora");
10
+ var appConfig = require("./utils/appConfig");
11
+ var baseConfig = {
12
+ localPath: "dist",
16
13
  ignore: [],
17
14
  cleanRemoteFiles: false,
18
15
  securityLock: false,
@@ -22,111 +19,78 @@ const baseConfig = {
22
19
  async function normalDeploy(args) {
23
20
  const presetConfig = {
24
21
  s: {
25
- context: 'eduwebngv1',
26
- folder: 'userportal'
22
+ context: "eduwebngv1",
23
+ folder: "userportal"
27
24
  },
28
25
  b: {
29
- context: 'eduwebngv1',
30
- folder: 'bureaupc'
26
+ context: "eduwebngv1",
27
+ folder: "bureaupc"
31
28
  },
32
29
  d: {
33
- context: 'eduwebngv1',
34
- folder: 'documentshelves'
30
+ context: "eduwebngv1",
31
+ folder: "documentshelves"
35
32
  }
36
33
  };
37
34
  const resolve = (...pathSegments) => path.resolve(process.cwd(), ...pathSegments);
38
-
39
- /**
40
- * 生成路径
41
- * @name remoteFile 远程文件
42
- * @name tmpFile 本地文件
43
- * @name tmpDir 本地临时文件夹 `tmpFile`存在的文件夹
44
- * @name tmpBase 本地临时文件夹 到`__tmp__`层
45
- * @param {string} remoteFilePath 远程文件相对`opts.remotePath`地址
46
- */
47
35
  function getLocalAndRemoteFilePath(remoteFilePath, opts) {
48
- const splited = remoteFilePath.split('/');
36
+ const splited = remoteFilePath.split("/");
49
37
  const fileName = splited[splited.length - 1];
50
- const tmpBase = resolve(opts.localPath, '__tmp__');
51
- const tmpDir = resolve(opts.localPath, '__tmp__', ...splited.slice(0, -1));
38
+ const tmpBase = resolve(opts.localPath, "__tmp__");
39
+ const tmpDir = resolve(opts.localPath, "__tmp__", ...splited.slice(0, -1));
52
40
  const tmpFile = resolve(tmpDir, fileName);
53
- const remoteFile = [opts.remotePath, remoteFilePath].join('/');
54
- return {
55
- tmpDir,
56
- tmpFile,
57
- remoteFile,
58
- tmpBase
59
- };
41
+ const remoteFile = [opts.remotePath, remoteFilePath].join("/");
42
+ return { tmpDir, tmpFile, remoteFile, tmpBase };
60
43
  }
61
44
  function dateTime() {
62
- let date = new Date();
63
- date = new Date(date.getTime() - date.getTimezoneOffset() * 60000);
64
- return date.toISOString().replace(/T/, ' ').replace(/\..+/, '');
45
+ let date = /* @__PURE__ */ new Date();
46
+ date = new Date(date.getTime() - date.getTimezoneOffset() * 6e4);
47
+ return date.toISOString().replace(/T/, " ").replace(/\..+/, "");
65
48
  }
66
49
  function updateLogContent(content, info) {
67
- const lines = content.trim().split('\n');
68
- lines.push(`[${dateTime()}] ${JSON.stringify(info)}\n`);
69
- return lines.slice(-50).join('\n');
50
+ const lines = content.trim().split("\n");
51
+ lines.push(`[${dateTime()}] ${JSON.stringify(info)}
52
+ `);
53
+ return lines.slice(-50).join("\n");
70
54
  }
71
55
  async function upload(opts) {
72
- // 上传dist文件
73
- const {
74
- sftp,
75
- opts: fullOpts
76
- } = await sshSftp(opts);
77
- const spinner = ora('自动更新 ver.js 版本配置').start();
78
- // 指定远程需要修改的文件
79
- const fileName = 'js/ver.js';
80
- // 生成各种路径
81
- const {
82
- remoteFile,
83
- tmpDir,
84
- tmpFile,
85
- tmpBase
86
- } = getLocalAndRemoteFilePath(fileName, fullOpts);
56
+ const { sftp, opts: fullOpts } = await sshSftp(opts);
57
+ const spinner = ora("自动更新 ver.js 版本配置").start();
58
+ const fileName = "js/ver.js";
59
+ const { remoteFile, tmpDir, tmpFile, tmpBase } = getLocalAndRemoteFilePath(fileName, fullOpts);
87
60
  try {
88
- // 创建本地临时文件夹,位置在 `opts.localPath` 下的 `__tmp__` 文件夹
89
- fs.mkdirSync(tmpDir, {
90
- recursive: true
91
- });
61
+ fs.mkdirSync(tmpDir, { recursive: true });
92
62
  const info = {
93
63
  name: pkg.name,
94
64
  version: pkg.version,
95
65
  grayscale: appConfig.grayscale
96
66
  };
97
67
  {
98
- // 拉取远程文件到本地
99
68
  await sftp.fastGet(remoteFile, tmpFile);
100
-
101
- // 读取本地文件内容
102
- let code = await fs.readFile(tmpFile, {
103
- encoding: 'utf-8'
104
- });
69
+ let code = await fs.readFile(tmpFile, { encoding: "utf-8" });
105
70
  code = changeDeployVersion(code, info);
106
- await sftp.fastPut(tmpFile, remoteFile + '.bak');
71
+ await sftp.fastPut(tmpFile, remoteFile + ".bak");
107
72
  await fs.writeFile(tmpFile, code);
108
- // 将修改完的内容传回服务器
109
73
  await sftp.fastPut(tmpFile, remoteFile);
110
74
  }
111
75
  {
112
- const remoteLogFile = remoteFile + '.log';
113
- const tmpLogFile = tmpFile + '.log';
114
- let content = '';
76
+ const remoteLogFile = remoteFile + ".log";
77
+ const tmpLogFile = tmpFile + ".log";
78
+ let content = "";
115
79
  try {
116
80
  await sftp.fastGet(remoteLogFile, tmpLogFile);
117
- content = await fs.readFile(tmpLogFile, 'utf-8');
118
- } catch (error) {}
81
+ content = await fs.readFile(tmpLogFile, "utf-8");
82
+ } catch (error) {
83
+ }
119
84
  content = updateLogContent(content, info);
120
85
  await fs.writeFile(tmpLogFile, content);
121
86
  await sftp.fastPut(tmpLogFile, remoteLogFile);
122
87
  }
123
- spinner.succeed('已更新 ver.js 版本配置');
88
+ spinner.succeed("已更新 ver.js 版本配置");
124
89
  } catch (e) {
125
90
  spinner.fail(`自动修改 ver.js 失败,请手动修改`);
126
91
  console.log(chalk.bgRed(e.message));
127
92
  } finally {
128
93
  await sftp.end();
129
- // 清除临时文件夹
130
94
  fs.removeSync(tmpBase);
131
95
  }
132
96
  }
@@ -141,40 +105,34 @@ async function normalDeploy(args) {
141
105
  presets.push(presetConfig.d);
142
106
  }
143
107
  if (presets.length === 0) {
144
- console.log(`
145
- ${chalk.red('指定 deploy 部署范围')}
108
+ console.log(
109
+ `
110
+ ${chalk.red("指定 deploy 部署范围")}
146
111
 
147
112
  # 部署代码 校端
148
- ${chalk.green('edu-scripts deploy -s')}
113
+ ${chalk.green("edu-scripts deploy -s")}
149
114
  # 部署代码 局端
150
- ${chalk.green('edu-scripts deploy -b')}
115
+ ${chalk.green("edu-scripts deploy -b")}
151
116
  # 部署代码 公文
152
- ${chalk.green('edu-scripts deploy -d')}
117
+ ${chalk.green("edu-scripts deploy -d")}
153
118
  # 部署代码 校端 + 局端
154
- ${chalk.green('edu-scripts deploy -s -b')}
155
- `);
119
+ ${chalk.green("edu-scripts deploy -s -b")}
120
+ `
121
+ );
156
122
  process.exit();
157
123
  }
158
- const uploadConfig = {
159
- ...baseConfig,
160
- ignore: [...baseConfig.ignore, 'js/ver.js']
161
- };
124
+ const uploadConfig = { ...baseConfig, ignore: [...baseConfig.ignore, "js/ver.js"] };
162
125
  if (!appConfig.mainProject) {
163
- uploadConfig.ignore = [...uploadConfig.ignore, '!(js|images)'];
126
+ uploadConfig.ignore = [...uploadConfig.ignore, "!(js|images)"];
164
127
  }
165
128
  for (const preset of presets) {
166
- await upload({
167
- ...uploadConfig,
168
- preset
169
- });
129
+ await upload({ ...uploadConfig, preset });
170
130
  }
171
131
  }
172
132
  async function singleDeploy() {
173
133
  const config = fs.existsSync(paths.sshSftp) ? fs.readJsonSync(paths.sshSftp) : {
174
134
  ...baseConfig,
175
- preset: {
176
- context: 'qsxxwapdev'
177
- },
135
+ preset: { context: "qsxxwapdev" },
178
136
  cleanRemoteFiles: true,
179
137
  securityLock: true,
180
138
  keepAlive: false,
@@ -188,4 +146,4 @@ module.exports = function deploy(args) {
188
146
  } else {
189
147
  normalDeploy(args);
190
148
  }
191
- };
149
+ };
package/lib/generator.js CHANGED
@@ -1,77 +1,37 @@
1
- "use strict";
2
-
3
- const path = require('path');
4
- const fs = require('fs-extra');
5
- const {
6
- upperFirst,
7
- camelCase,
8
- has
9
- } = require('lodash');
10
- const paths = require('./config/paths');
11
- const chalk = require('chalk');
12
-
13
- /**
14
- * @param {string[]} args
15
- * @returns {string}
16
- */
17
- const getTmpPath = (...args) => path.resolve(__dirname, 'asset', 'template', ...args);
18
- function genFile({
19
- source,
20
- target,
21
- modulePath,
22
- replace
23
- }) {
24
- let content = fs.readFileSync(source, 'utf-8');
25
- if (typeof replace === 'object') {
1
+ // src/generator.js
2
+ var path = require("path");
3
+ var fs = require("fs-extra");
4
+ var { upperFirst, camelCase, has } = require("lodash");
5
+ var paths = require("./config/paths");
6
+ var chalk = require("chalk");
7
+ var getTmpPath = (...args) => path.resolve(__dirname, "asset", "template", ...args);
8
+ function genFile({ source, target, modulePath, replace }) {
9
+ let content = fs.readFileSync(source, "utf-8");
10
+ if (typeof replace === "object") {
26
11
  Object.entries(replace).forEach(([searchValue, replaceValue]) => {
27
12
  content = content.replaceAll(searchValue, replaceValue);
28
13
  });
29
14
  }
30
15
  fs.writeFileSync(path.resolve(modulePath, target), content);
31
16
  }
32
-
33
- /**
34
- * @typedef {Object} PageArgs
35
- * @property {string} name
36
- * @property {boolean} [fc=false]
37
- * @property {boolean} [ts=true]
38
- * @property {boolean} [route=true]
39
- *
40
- * @param {PageArgs} args
41
- */
42
17
  async function generatorPage(args) {
43
- const tmpPath = getTmpPath('page', 'index.[type].[ext].tpl');
44
- const lessPath = tmpPath.replace('[type].[ext]', 'less');
18
+ const tmpPath = getTmpPath("page", "index.[type].[ext].tpl");
19
+ const lessPath = tmpPath.replace("[type].[ext]", "less");
45
20
  const moduleName = camelCase(args.name);
46
21
  const ModuleName = upperFirst(moduleName);
47
- const type = args.fc ? 'fc' : 'class';
48
- const ext = fs.existsSync(paths.tsconfig) ? args.ts ? 'tsx' : 'js' : 'js';
49
- const jsPath = tmpPath.replace('[type]', type).replace('[ext]', ext);
50
- const routePath = tmpPath.replace('index.[type].[ext]', 'route.js');
51
- const logicPath = tmpPath.replace('index.[type].[ext]', 'logic.js');
22
+ const type = args.fc ? "fc" : "class";
23
+ const ext = fs.existsSync(paths.tsconfig) ? args.ts ? "tsx" : "js" : "js";
24
+ const jsPath = tmpPath.replace("[type]", type).replace("[ext]", ext);
25
+ const routePath = tmpPath.replace("index.[type].[ext]", "route.js");
26
+ const logicPath = tmpPath.replace("index.[type].[ext]", "logic.js");
52
27
  const modulePath = path.resolve(paths.pages, moduleName);
53
- const ModuleFileName = args.route ? ModuleName : 'index';
54
- const ModuleLogicName = args.route ? ModuleName + 'Logic' : 'logic';
55
- const replace = {
56
- ModuleName,
57
- moduleName,
58
- ModuleFileName,
59
- ModuleLogicName
60
- };
28
+ const ModuleFileName = args.route ? ModuleName : "index";
29
+ const ModuleLogicName = args.route ? ModuleName + "Logic" : "logic";
30
+ const replace = { ModuleName, moduleName, ModuleFileName, ModuleLogicName };
61
31
  fs.ensureDirSync(modulePath);
62
- genFile({
63
- source: jsPath,
64
- target: `${ModuleFileName}.${ext}`,
65
- modulePath,
66
- replace
67
- });
68
- genFile({
69
- source: lessPath,
70
- target: `${ModuleFileName}.less`,
71
- modulePath,
72
- replace
73
- });
74
- if (type === 'class' && ext === 'js') {
32
+ genFile({ source: jsPath, target: `${ModuleFileName}.${ext}`, modulePath, replace });
33
+ genFile({ source: lessPath, target: `${ModuleFileName}.less`, modulePath, replace });
34
+ if (type === "class" && ext === "js") {
75
35
  genFile({
76
36
  source: logicPath,
77
37
  target: `${ModuleLogicName}.${ext.slice(0, 2)}`,
@@ -80,21 +40,25 @@ async function generatorPage(args) {
80
40
  });
81
41
  }
82
42
  if (args.route) {
83
- genFile({
84
- source: routePath,
85
- target: `index.${ext.slice(0, 2)}`,
86
- modulePath,
87
- replace
88
- });
43
+ genFile({ source: routePath, target: `index.${ext.slice(0, 2)}`, modulePath, replace });
89
44
  }
90
- console.log(chalk.green([`生成完毕:`, `import ${ModuleName} from '@/pages/${moduleName}'`, `const ${ModuleName} = lazy(() => import(/* webpackChunkName: '${moduleName}' */ '@/pages/${moduleName}'))`, `{ path: '/${moduleName}', element: <${ModuleName} /> },`].join('\n')));
45
+ console.log(
46
+ chalk.green(
47
+ [
48
+ `生成完毕:`,
49
+ `import ${ModuleName} from '@/pages/${moduleName}'`,
50
+ `const ${ModuleName} = lazy(() => import(/* webpackChunkName: '${moduleName}' */ '@/pages/${moduleName}'))`,
51
+ `{ path: '/${moduleName}', element: <${ModuleName} /> },`
52
+ ].join("\n")
53
+ )
54
+ );
91
55
  }
92
56
  async function generatorOverride() {
93
57
  if (fs.existsSync(paths.override)) {
94
58
  console.log(chalk.red(`文件已存在 ${paths.override}`));
95
59
  process.exit(0);
96
60
  }
97
- fs.copySync(getTmpPath('edu-scripts.override.js.tpl'), paths.override);
61
+ fs.copySync(getTmpPath("edu-scripts.override.js.tpl"), paths.override);
98
62
  console.log(chalk.green(`成功生成 ${paths.override}`));
99
63
  }
100
64
  async function generatorTsconfig() {
@@ -102,8 +66,8 @@ async function generatorTsconfig() {
102
66
  console.log(chalk.red(`文件已存在 ${paths.tsconfig}`));
103
67
  process.exit(0);
104
68
  }
105
- fs.copySync(getTmpPath('tsconfig.json.tpl'), paths.tsconfig);
106
- fs.copySync(getTmpPath('edu-app-env.d.ts.tpl'), paths.eduAppEnv);
69
+ fs.copySync(getTmpPath("tsconfig.json.tpl"), paths.tsconfig);
70
+ fs.copySync(getTmpPath("edu-app-env.d.ts.tpl"), paths.eduAppEnv);
107
71
  console.log(chalk.green(`成功生成 ${paths.tsconfig}`));
108
72
  }
109
73
  async function generatorTailwind() {
@@ -111,22 +75,26 @@ async function generatorTailwind() {
111
75
  console.log(chalk.red(`文件已存在 ${paths.tailwind}`));
112
76
  process.exit(0);
113
77
  }
114
- fs.copySync(getTmpPath('tailwind.config.js.tpl'), paths.tailwind);
115
- const code = ['@tailwind base;', '@tailwind components;', '@tailwind utilities;'].join('\n');
116
- const globalLessFile = paths.resolveApp('src', 'index.less');
78
+ fs.copySync(getTmpPath("tailwind.config.js.tpl"), paths.tailwind);
79
+ const code = ["@tailwind base;", "@tailwind components;", "@tailwind utilities;"].join("\n");
80
+ const globalLessFile = paths.resolveApp("src", "index.less");
117
81
  if (fs.existsSync(globalLessFile)) {
118
- const content = fs.readFileSync(globalLessFile, 'utf-8');
119
- if (!content.includes('@tailwind base')) {
120
- fs.writeFileSync(globalLessFile, [code, content].join('\n'));
82
+ const content = fs.readFileSync(globalLessFile, "utf-8");
83
+ if (!content.includes("@tailwind base")) {
84
+ fs.writeFileSync(globalLessFile, [code, content].join("\n"));
121
85
  }
122
86
  console.log(chalk.green(`成功生成 ${paths.tailwind}`));
123
87
  return;
124
88
  }
125
- console.log(chalk.green([`成功生成 ${paths.tailwind}`, '', '添加以下代码到入口处的 index.less 中', code].join('\n')));
89
+ console.log(
90
+ chalk.green(
91
+ [`成功生成 ${paths.tailwind}`, "", "添加以下代码到入口处的 index.less 中", code].join("\n")
92
+ )
93
+ );
126
94
  }
127
95
  module.exports = {
128
96
  page: generatorPage,
129
97
  override: generatorOverride,
130
98
  ts: generatorTsconfig,
131
99
  tailwind: generatorTailwind
132
- };
100
+ };
package/lib/index.js CHANGED
@@ -1,12 +1,29 @@
1
- "use strict";
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
2
18
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
19
+ // src/index.ts
20
+ var src_exports = {};
21
+ __export(src_exports, {
22
+ defineConfig: () => import_defineConfig.defineConfig
5
23
  });
6
- Object.defineProperty(exports, "defineConfig", {
7
- enumerable: true,
8
- get: function () {
9
- return _defineConfig.defineConfig;
10
- }
24
+ module.exports = __toCommonJS(src_exports);
25
+ var import_defineConfig = require("./utils/defineConfig");
26
+ // Annotate the CommonJS export names for ESM import in node:
27
+ 0 && (module.exports = {
28
+ defineConfig
11
29
  });
12
- var _defineConfig = require("./utils/defineConfig");
package/lib/start.js CHANGED
@@ -1,21 +1,16 @@
1
- "use strict";
2
-
3
- process.env.NODE_ENV = 'development';
4
- process.env.BABEL_ENV = 'development';
5
- process.env.BROWSERSLIST = 'chrome >= 70';
6
- process.env.WEBPACK_DEV_SERVER_BASE_PORT = '3000';
7
-
8
- // Makes the script crash on unhandled rejections instead of silently
9
- // ignoring them. In the future, promise rejections that are not handled will
10
- // terminate the Node.js process with a non-zero exit code.
11
- process.on('unhandledRejection', err => {
1
+ // src/start.js
2
+ process.env.NODE_ENV = "development";
3
+ process.env.BABEL_ENV = "development";
4
+ process.env.BROWSERSLIST = "chrome >= 70";
5
+ process.env.WEBPACK_DEV_SERVER_BASE_PORT = "3000";
6
+ process.on("unhandledRejection", (err) => {
12
7
  throw err;
13
8
  });
14
- const WebpackDevServer = require('webpack-dev-server');
15
- const webpack = require('webpack');
16
- const getConfig = require('./utils/getConfig');
17
- const chalk = require('chalk');
18
- process.env.WDS_SOCKET_HOST = WebpackDevServer.internalIPSync('v4') || '127.0.0.1';
9
+ var WebpackDevServer = require("webpack-dev-server");
10
+ var webpack = require("webpack");
11
+ var getConfig = require("./utils/getConfig");
12
+ var chalk = require("chalk");
13
+ process.env.WDS_SOCKET_HOST = WebpackDevServer.internalIPSync("v4") || "127.0.0.1";
19
14
  module.exports = async function start(args) {
20
15
  const basePort = process.env.WEBPACK_DEV_SERVER_BASE_PORT;
21
16
  const port = await WebpackDevServer.getFreePort(args.port || process.env.PORT);
@@ -27,17 +22,16 @@ module.exports = async function start(args) {
27
22
  const compiler = webpack(getConfig(args));
28
23
  const devServer = new WebpackDevServer(compiler.options.devServer, compiler);
29
24
  devServer.start();
30
- [('SIGINT', 'SIGTERM')].forEach(function (sig) {
31
- process.on(sig, function () {
25
+ [("SIGINT", "SIGTERM")].forEach(function(sig) {
26
+ process.on(sig, function() {
32
27
  devServer.stop();
33
28
  process.exit();
34
29
  });
35
30
  });
36
- if (process.env.CI !== 'true') {
37
- // Gracefully exit when stdin ends
38
- process.stdin.on('end', function () {
31
+ if (process.env.CI !== "true") {
32
+ process.stdin.on("end", function() {
39
33
  devServer.stop();
40
34
  process.exit();
41
35
  });
42
36
  }
43
- };
37
+ };