slicejs-cli 2.9.2 → 2.9.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/client.js CHANGED
@@ -137,9 +137,15 @@ sliceClient
137
137
  const buildCommand = sliceClient.command("build")
138
138
  .description("Build Slice.js project for production")
139
139
  .action(async (options) => {
140
- await runWithVersionCheck(async () => {
141
- await build(options);
142
- });
140
+ const prevEnv = process.env.NODE_ENV;
141
+ process.env.NODE_ENV = 'production';
142
+ try {
143
+ await runWithVersionCheck(async () => {
144
+ await build(options);
145
+ });
146
+ } finally {
147
+ process.env.NODE_ENV = prevEnv;
148
+ }
143
149
  });
144
150
 
145
151
  buildCommand
@@ -172,14 +178,22 @@ sliceClient
172
178
  .option("-p, --port <port>", "Port for development server", 3000)
173
179
  .option("-w, --watch", "Enable watch mode for file changes")
174
180
  .action(async (options) => {
175
- await runWithVersionCheck(async () => {
176
- await startServer({
177
- mode: 'development',
178
- port: parseInt(options.port),
179
- watch: options.watch,
180
- bundled: false
181
+ // Ensure the process.env.NODE_ENV reflects the requested mode for any
182
+ // code (builds, spawned processes, libraries) that reads it.
183
+ const prevEnv = process.env.NODE_ENV;
184
+ process.env.NODE_ENV = 'development';
185
+ try {
186
+ await runWithVersionCheck(async () => {
187
+ await startServer({
188
+ mode: 'development',
189
+ port: parseInt(options.port),
190
+ watch: options.watch,
191
+ bundled: false
192
+ });
181
193
  });
182
- });
194
+ } finally {
195
+ process.env.NODE_ENV = prevEnv;
196
+ }
183
197
  });
184
198
 
185
199
  // START COMMAND - PRODUCTION MODE
@@ -189,14 +203,20 @@ sliceClient
189
203
  .option("-p, --port <port>", "Port for server", 3000)
190
204
  .option("-w, --watch", "Enable watch mode for file changes")
191
205
  .action(async (options) => {
192
- await runWithVersionCheck(async () => {
193
- await startServer({
194
- mode: 'production',
195
- port: parseInt(options.port),
196
- watch: options.watch,
197
- bundled: false
206
+ const prevEnv = process.env.NODE_ENV;
207
+ process.env.NODE_ENV = 'production';
208
+ try {
209
+ await runWithVersionCheck(async () => {
210
+ await startServer({
211
+ mode: 'production',
212
+ port: parseInt(options.port),
213
+ watch: options.watch,
214
+ bundled: false
215
+ });
198
216
  });
199
- });
217
+ } finally {
218
+ process.env.NODE_ENV = prevEnv;
219
+ }
200
220
  });
201
221
 
202
222
  // COMPONENT COMMAND GROUP - For local component management
@@ -94,12 +94,18 @@ function startNodeServer(port, mode) {
94
94
  args.push('--development');
95
95
  }
96
96
 
97
+ // Ensure the spawned server process receives NODE_ENV consistent with the
98
+ // requested mode. This guarantees code that only checks process.env.NODE_ENV
99
+ // (instead of CLI flags) will behave as expected.
100
+ const serverEnv = {
101
+ ...process.env,
102
+ PORT: port,
103
+ NODE_ENV: mode === 'production' ? 'production' : (process.env.NODE_ENV || 'development')
104
+ };
105
+
97
106
  const serverProcess = spawn('node', args, {
98
107
  stdio: ['inherit', 'pipe', 'pipe'],
99
- env: {
100
- ...process.env,
101
- PORT: port
102
- }
108
+ env: serverEnv
103
109
  });
104
110
 
105
111
  let serverStarted = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "slicejs-cli",
3
- "version": "2.9.2",
3
+ "version": "2.9.3",
4
4
  "description": "Command client for developing web applications with Slice.js framework",
5
5
  "main": "client.js",
6
6
  "bin": {
@@ -29,6 +29,8 @@
29
29
  "preferGlobal": false,
30
30
  "license": "ISC",
31
31
  "dependencies": {
32
+ "@babel/parser": "^7.28.5",
33
+ "@babel/traverse": "^7.28.5",
32
34
  "chalk": "^5.6.2",
33
35
  "chokidar": "^3.6.0",
34
36
  "clean-css": "^5.3.3",
@@ -39,8 +41,6 @@
39
41
  "inquirer": "^12.4.2",
40
42
  "ora": "^8.2.0",
41
43
  "slicejs-web-framework": "latest",
42
- "terser": "^5.43.1",
43
- "@babel/parser": "^7.28.5",
44
- "@babel/traverse": "^7.28.5"
44
+ "terser": "^5.43.1"
45
45
  }
46
46
  }