@autobest-ui/scripts 3.0.0-alpha.2 → 3.0.0-alpha.3

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.
package/bin/api.js ADDED
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env node
2
+
3
+ process.on('unhandledRejection', err => {
4
+ // eslint-disable-next-line @typescript-eslint/no-throw-literal
5
+ throw err;
6
+ });
7
+
8
+ const spawn = require('cross-spawn');
9
+
10
+ const args = process.argv.slice(2);
11
+
12
+ const scriptIndex = args.findIndex(x => x === 'build' || x === 'start' || 'server');
13
+ const script = scriptIndex === -1 ? args[0] : args[scriptIndex];
14
+ const nodeArgs = scriptIndex > 0 ? args.slice(0, scriptIndex) : [];
15
+
16
+ if (['build', 'start'].includes(script)) {
17
+ const result = spawn.sync(
18
+ process.execPath,
19
+ nodeArgs.concat(require.resolve(`../apiConfig/${script}`)).concat(args.slice(scriptIndex + 1)),
20
+ { stdio: 'inherit' }
21
+ );
22
+ if (result.signal) {
23
+ if (result.signal === 'SIGKILL') {
24
+ // eslint-disable-next-line no-console
25
+ console.log(
26
+ 'The build failed because the process exited too early. ' +
27
+ 'This probably means the system ran out of memory or someone called ' +
28
+ '`kill -9` on the process.'
29
+ );
30
+ } else if (result.signal === 'SIGTERM') {
31
+ // eslint-disable-next-line no-console
32
+ console.log(
33
+ 'The build failed because the process exited too early. ' +
34
+ 'Someone might have called `kill` or `killall`, or the system could ' +
35
+ 'be shutting down.'
36
+ );
37
+ }
38
+ process.exit(1);
39
+ }
40
+ process.exit(result.status);
41
+ } else {
42
+ // eslint-disable-next-line no-console
43
+ console.log(`Unknown script "${script}".`);
44
+ }
@@ -58,7 +58,12 @@ const defaultConfig = {
58
58
  // 静态资源css基础文件夹
59
59
  baseStaticCssPath: 'css',
60
60
  // 静态资源js基础文件夹
61
- baseStaticJsPath: 'js'
61
+ baseStaticJsPath: 'js',
62
+
63
+ // API 配置
64
+ apiEntry: '/src/index.ts',
65
+ apiOutputPath: '/build',
66
+ hotApiWatch: ['src']
62
67
  };
63
68
 
64
69
  module.exports = {
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@autobest-ui/scripts",
3
- "version": "3.0.0-alpha.2",
3
+ "version": "3.0.0-alpha.3",
4
4
  "private": false,
5
5
  "description": "utils for project tools",
6
6
  "bin": {
7
7
  "react-spa": "./bin/spa.js",
8
- "react-ssr": "./bin/ssr.js"
8
+ "react-ssr": "./bin/ssr.js",
9
+ "node-api": "./bin/api.js"
9
10
  },
10
11
  "scripts": {
11
12
  "clean": "rimraf lib esm",