@mainset/cli 0.4.3 ā 0.4.4
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.
|
@@ -48,7 +48,11 @@ function registerWebAppCommand(program) {
|
|
|
48
48
|
execImmediatePurgeDist();
|
|
49
49
|
// Step 2: build:ssr-webapp source code
|
|
50
50
|
console.log('\nš¦ Compiling SSR WebApp with Webpack ...');
|
|
51
|
-
execImmediateCommand(
|
|
51
|
+
execImmediateCommand(`${webpackCLICommandPath} --config ${webpackSSRConfigPath}`, {
|
|
52
|
+
env: {
|
|
53
|
+
MS_CLI__WEBPACK_SERVE_MODE: 'ssr',
|
|
54
|
+
},
|
|
55
|
+
});
|
|
52
56
|
/*
|
|
53
57
|
// Step 3: build:ssr-server source code
|
|
54
58
|
console.log('\nš¦ Compiling SSR Server with Rslib ...');
|
|
@@ -65,7 +69,11 @@ function registerWebAppCommand(program) {
|
|
|
65
69
|
execImmediatePurgeDist();
|
|
66
70
|
// Step 2: build:csr-webapp source code
|
|
67
71
|
console.log('\nš¦ Compiling CSR WebApp with Webpack ...');
|
|
68
|
-
execImmediateCommand(
|
|
72
|
+
execImmediateCommand(`${webpackCLICommandPath} --config ${webpackCSRConfigPath}`, {
|
|
73
|
+
env: {
|
|
74
|
+
MS_CLI__WEBPACK_SERVE_MODE: 'csr',
|
|
75
|
+
},
|
|
76
|
+
});
|
|
69
77
|
console.log('\nā
CSR Build completed successfully\n');
|
|
70
78
|
}
|
|
71
79
|
}
|
|
@@ -93,7 +101,9 @@ function registerWebAppCommand(program) {
|
|
|
93
101
|
// Step 2: watch:ssr-webapp source code of web app
|
|
94
102
|
{
|
|
95
103
|
runCommand: () => runStreamingCommand(webpackCLICommandPath, ['--config', webpackSSRConfigPath, '--watch'], {
|
|
96
|
-
env:
|
|
104
|
+
env: {
|
|
105
|
+
MS_CLI__WEBPACK_SERVE_MODE: 'ssr',
|
|
106
|
+
},
|
|
97
107
|
}),
|
|
98
108
|
waitForOutput: 'compiled successfully',
|
|
99
109
|
},
|
|
@@ -115,7 +125,9 @@ function registerWebAppCommand(program) {
|
|
|
115
125
|
: path.resolve(runtimePathById.root, 'node_modules', '@mainset/bundler-webpack/dist/esm/webpack-config/dev-server.csr.config.mjs');
|
|
116
126
|
// Step 1: watch:csr-server / start:csr-server source code
|
|
117
127
|
runStreamingCommand(webpackCLICommandPath, ['serve', '--config', webpackDevServerConfigPath, '--open'], {
|
|
118
|
-
env:
|
|
128
|
+
env: {
|
|
129
|
+
MS_CLI__WEBPACK_SERVE_MODE: 'csr',
|
|
130
|
+
},
|
|
119
131
|
});
|
|
120
132
|
}
|
|
121
133
|
}
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
1
12
|
import { execSync, spawn } from 'child_process';
|
|
2
13
|
import { consoleColorize } from '../index.mjs';
|
|
3
14
|
import { processManager } from './process-manager.mjs';
|
|
@@ -22,9 +33,10 @@ function initProcessCatchErrorLogger(commandName, error, commandParam) {
|
|
|
22
33
|
*
|
|
23
34
|
* Example: execImmediateCommand('rspack --config ./config/rspack.config.ts');
|
|
24
35
|
*/
|
|
25
|
-
function execImmediateCommand(fullCommandString) {
|
|
36
|
+
function execImmediateCommand(fullCommandString, options = {}) {
|
|
26
37
|
try {
|
|
27
|
-
|
|
38
|
+
const { env } = options, restExecSyncOptions = __rest(options, ["env"]);
|
|
39
|
+
execSync(fullCommandString, Object.assign({ stdio: 'inherit', env: Object.assign(Object.assign({}, process.env), env) }, restExecSyncOptions));
|
|
28
40
|
}
|
|
29
41
|
catch (error) {
|
|
30
42
|
initProcessCatchErrorLogger('execImmediateCommand', error);
|
|
@@ -38,7 +50,8 @@ function execImmediateCommand(fullCommandString) {
|
|
|
38
50
|
*/
|
|
39
51
|
function runStreamingCommand(command, args, options = {}) {
|
|
40
52
|
try {
|
|
41
|
-
const
|
|
53
|
+
const { env } = options, restSpawnOptions = __rest(options, ["env"]);
|
|
54
|
+
const child = spawn(command, args, Object.assign({ stdio: 'inherit', shell: true, env: Object.assign(Object.assign({}, process.env), env) }, restSpawnOptions));
|
|
42
55
|
// Track the process using ProcessManager as it could live in the background after crashing
|
|
43
56
|
// Examples: server stacks when files removed while server is running
|
|
44
57
|
// 1. rm -rf ./dist
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SpawnOptions } from 'child_process';
|
|
1
|
+
import type { ExecSyncOptions, SpawnOptions } from 'child_process';
|
|
2
2
|
declare function initProcessCatchErrorLogger(commandName: string, error: Error | unknown, commandParam?: string): void;
|
|
3
3
|
/**
|
|
4
4
|
* Executes a short-lived command synchronously.
|
|
@@ -6,7 +6,7 @@ declare function initProcessCatchErrorLogger(commandName: string, error: Error |
|
|
|
6
6
|
*
|
|
7
7
|
* Example: execImmediateCommand('rspack --config ./config/rspack.config.ts');
|
|
8
8
|
*/
|
|
9
|
-
declare function execImmediateCommand(fullCommandString: string): void;
|
|
9
|
+
declare function execImmediateCommand(fullCommandString: string, options?: ExecSyncOptions): void;
|
|
10
10
|
/**
|
|
11
11
|
* Runs a long-lived streaming command asynchronously.
|
|
12
12
|
* The command and its arguments must be passed separately.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mainset/cli",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.4",
|
|
4
4
|
"description": "A unified CLI tool for accelerating development, based on mainset vision of front-end infrastructure",
|
|
5
5
|
"homepage": "https://github.com/mainset/dev-stack-fe/tree/main/packages/cli",
|
|
6
6
|
"bugs": {
|