innetjs 3.1.0 → 3.2.0

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,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  ;(function () {
4
- const env = {"__INNETJS__PACKAGE_VERSION":"3.1.0"};
4
+ const env = {"__INNETJS__PACKAGE_VERSION":"3.2.0"};
5
5
  if (typeof process === 'undefined') {
6
6
  globalThis.process = { env: env };
7
7
  } else if (process.env) {
@@ -1,5 +1,5 @@
1
1
  ;(function () {
2
- const env = {"__INNETJS__PACKAGE_VERSION":"3.1.0"};
2
+ const env = {"__INNETJS__PACKAGE_VERSION":"3.2.0"};
3
3
  if (typeof process === 'undefined') {
4
4
  globalThis.process = { env: env };
5
5
  } else if (process.env) {
package/bin/innet CHANGED
@@ -3,6 +3,7 @@
3
3
 
4
4
  var commander = require('commander');
5
5
  var tslib = require('tslib');
6
+ var codeFrame = require('@babel/code-frame');
6
7
  var logger = require('@cantinc/logger');
7
8
  var commonjs = require('@rollup/plugin-commonjs');
8
9
  var eslint = require('@rollup/plugin-eslint');
@@ -167,6 +168,71 @@ function getNpmTag(version) {
167
168
  const match = version.match(NPM_TAG);
168
169
  return match ? match[1] : 'latest';
169
170
  }
171
+ function printErrorWithFrame(output, deep = 0, hide = false) {
172
+ var _a, _b, _c, _d, _e;
173
+ if (!output)
174
+ return '';
175
+ const input = output.split('\n');
176
+ const start = input.findIndex(line => line.trim().startsWith(deep ? '[cause]: Error:' : 'Error:'));
177
+ if (!~start)
178
+ return output;
179
+ const inputFrame = input.slice(0, start);
180
+ const end = input.slice(start + 1).findIndex(line => line.trim().startsWith('[cause]: Error:'));
181
+ const inputBody = input.slice(start, ~end ? start + end - 1 : undefined);
182
+ const inputCauses = ~end ? input.slice(start + end - 1) : [];
183
+ const bodyStackStart = inputBody.findIndex(line => line.trim().startsWith('at '));
184
+ const bodyText = ~bodyStackStart ? inputBody.slice(0, bodyStackStart).join('\n') : inputBody.join('\n');
185
+ const bodyStack = ~bodyStackStart ? inputBody.slice(bodyStackStart) : [];
186
+ const filePathWithNumber = bodyStack.length ? (_a = bodyStack[0].match(/\(([^(]+)\)$/)) === null || _a === void 0 ? void 0 : _a[1] : undefined;
187
+ const splitFilePath = (_b = filePathWithNumber === null || filePathWithNumber === void 0 ? void 0 : filePathWithNumber.split(':')) !== null && _b !== void 0 ? _b : [];
188
+ const filePath = (_c = splitFilePath[0]) === null || _c === void 0 ? void 0 : _c.trim();
189
+ const line = Number((_d = splitFilePath[1]) !== null && _d !== void 0 ? _d : 1);
190
+ const column = Number((_e = splitFilePath[2]) !== null && _e !== void 0 ? _e : 1);
191
+ let frame = '';
192
+ if (filePath && !filePath.includes('node_modules')) {
193
+ try {
194
+ const source = fs__default["default"].readFileSync(filePath, 'utf8');
195
+ frame = codeFrame.codeFrameColumns(source, { start: { line, column } }, { highlightCode: true });
196
+ }
197
+ catch (e) { }
198
+ }
199
+ else {
200
+ frame = inputFrame.join('\n');
201
+ }
202
+ const title = bodyText.trim();
203
+ const baseOffset = ' '.repeat(2);
204
+ const offset = baseOffset.repeat(deep);
205
+ const titleOffset = offset + baseOffset + baseOffset;
206
+ let hiddenCount = 0;
207
+ let collapse = titleOffset + 'at ... (0 more node_modules calls)';
208
+ const stack = hide
209
+ ? bodyStack.slice(1).reduce((cur, line) => {
210
+ if (line.includes('node_modules')) {
211
+ if (cur.at(-1) === collapse) {
212
+ collapse = collapse.replace(`${hiddenCount} more`, `${++hiddenCount} more`);
213
+ return [
214
+ ...cur.slice(0, -1),
215
+ collapse,
216
+ ];
217
+ }
218
+ collapse = collapse.replace(`${hiddenCount} more`, `${++hiddenCount} more`);
219
+ return [...cur, collapse];
220
+ }
221
+ hiddenCount = 0;
222
+ collapse = titleOffset + 'at ... (0 more node_modules calls)';
223
+ return [...cur, line];
224
+ }, [])
225
+ : bodyStack.slice(1);
226
+ return [
227
+ chalk__default["default"].red(`${titleOffset}${title}`),
228
+ bodyStack[0],
229
+ frame && `${offset}${frame.replaceAll('\n', `\n${offset}`)}`,
230
+ ...stack
231
+ .filter(line => line.trim() !== '}')
232
+ .map(line => line.includes('node_modules') ? chalk__default["default"].gray(line) : line),
233
+ printErrorWithFrame(inputCauses.join('\n'), deep + 1, hide),
234
+ ].filter(Boolean).join('\n');
235
+ }
170
236
  const scriptExtensions = ['ts', 'js', 'tsx', 'jsx'];
171
237
  const indexExt = scriptExtensions.join(',');
172
238
  class InnetJS {
@@ -359,7 +425,7 @@ class InnetJS {
359
425
  }
360
426
  });
361
427
  }
362
- start({ node = false, inject = false, error = false, index = 'index', } = {}) {
428
+ start({ node = false, inject = false, error = false, usualConsoleOutput = false, index = 'index', } = {}) {
363
429
  return tslib.__awaiter(this, void 0, void 0, function* () {
364
430
  const pkg = yield this.getPackage();
365
431
  const input = glob__default["default"].sync(`src/${index}.{${indexExt}}`);
@@ -389,8 +455,11 @@ class InnetJS {
389
455
  if (warning.code === 'THIS_IS_UNDEFINED' || warning.code === 'SOURCEMAP_ERROR')
390
456
  return;
391
457
  if (warning.plugin === 'typescript') {
392
- const { loc: { line, column, file }, frame, message } = warning;
393
- console.log(`ERROR in ${file}:${line}:${column}`);
458
+ const { loc, frame, message } = warning;
459
+ if (loc) {
460
+ const { line, column, file } = loc;
461
+ console.log(`ERROR in ${file}:${line}:${column}`);
462
+ }
394
463
  console.log(message);
395
464
  console.log(frame);
396
465
  return;
@@ -408,7 +477,7 @@ class InnetJS {
408
477
  options.plugins.push(pluginNodeResolve.nodeResolve(), string({
409
478
  include: '**/*.*',
410
479
  exclude: stringExcludeNode,
411
- }), this.createServer(input));
480
+ }), this.createServer(input, error, usualConsoleOutput));
412
481
  }
413
482
  else {
414
483
  const key = path__default["default"].basename(this.sslKey) !== this.sslKey
@@ -801,17 +870,34 @@ class InnetJS {
801
870
  }),
802
871
  };
803
872
  }
804
- createServer(input) {
873
+ createServer(input, error = false, usualConsoleOutput = false) {
805
874
  const apps = {};
806
875
  return {
807
876
  name: 'server',
808
877
  writeBundle: () => tslib.__awaiter(this, void 0, void 0, function* () {
809
878
  var _a;
810
879
  for (const file of input) {
880
+ let stderrBuffer = '';
811
881
  const { name } = path__default["default"].parse(file);
812
882
  (_a = apps[name]) === null || _a === void 0 ? void 0 : _a.kill();
813
883
  const filePath = path__default["default"].resolve(this.devBuildFolder, `${name}.js`);
814
- apps[name] = spawn('node', ['-r', 'source-map-support/register', filePath], { stdio: 'inherit' });
884
+ if (usualConsoleOutput) {
885
+ apps[name] = spawn('node', ['-r', 'source-map-support/register', filePath], { stdio: 'inherit' });
886
+ return;
887
+ }
888
+ const child = spawn('node', ['-r', 'source-map-support/register', filePath], {
889
+ stdio: ['inherit', 'pipe'],
890
+ });
891
+ apps[name] = child;
892
+ child.stderr.on('data', (chunk) => {
893
+ stderrBuffer += chunk.toString();
894
+ });
895
+ child.on('close', (code) => {
896
+ if (code !== 0 && stderrBuffer) {
897
+ console.error(printErrorWithFrame(stderrBuffer, 0, !error));
898
+ stderrBuffer = '';
899
+ }
900
+ });
815
901
  }
816
902
  }),
817
903
  };
@@ -819,7 +905,7 @@ class InnetJS {
819
905
  }
820
906
 
821
907
  (function () {
822
- const env = {"__INNETJS__PACKAGE_VERSION":"3.1.0"};
908
+ const env = {"__INNETJS__PACKAGE_VERSION":"3.2.0"};
823
909
  if (typeof process === 'undefined') {
824
910
  globalThis.process = { env: env };
825
911
  } else if (process.env) {
@@ -864,11 +950,12 @@ commander.program
864
950
  .command('start')
865
951
  .description('Start development with innet boilerplate')
866
952
  .option('-n, --node', 'Start development for Node.js')
953
+ .option('-uco, --usual-console-output', 'Removes custom error output (code-frame, colors...)')
867
954
  .option('-in, --inject', 'Injects script element into index.html')
868
955
  .option('-i, --index <index>', 'Root index file name', 'index')
869
956
  .addOption(errorOption)
870
- .action(({ error, node, index, inject }) => {
871
- innetJS.start({ node, error, index, inject }).catch(e => {
957
+ .action(({ error, node, index, inject, usualConsoleOutput }) => {
958
+ innetJS.start({ node, error, index, inject, usualConsoleOutput }).catch(e => {
872
959
  if (error) {
873
960
  console.error(e);
874
961
  process.exit(1);
package/index.d.ts CHANGED
@@ -62,10 +62,11 @@ export declare class InnetJS {
62
62
  inject?: boolean;
63
63
  index?: string;
64
64
  }): Promise<void>;
65
- start({ node, inject, error, index, }?: {
65
+ start({ node, inject, error, usualConsoleOutput, index, }?: {
66
66
  node?: boolean;
67
67
  inject?: boolean;
68
68
  error?: boolean;
69
+ usualConsoleOutput?: boolean;
69
70
  index?: string;
70
71
  }): Promise<void>;
71
72
  run(file: any, { config, exposeGc }?: {
@@ -79,5 +80,5 @@ export declare class InnetJS {
79
80
  increaseVersion(release: string): Promise<void>;
80
81
  getPackage(): Promise<Record<string, any>>;
81
82
  createClient(key: any, cert: any, pkg: any, index: string, inject: boolean): rollup.Plugin;
82
- createServer(input: string[]): rollup.Plugin;
83
+ createServer(input: string[], error?: boolean, usualConsoleOutput?: boolean): rollup.Plugin;
83
84
  }
package/index.js CHANGED
@@ -4,6 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  require('./_virtual/_rollup-plugin-process-env.js');
6
6
  var tslib = require('tslib');
7
+ var codeFrame = require('@babel/code-frame');
7
8
  var logger = require('@cantinc/logger');
8
9
  var commonjs = require('@rollup/plugin-commonjs');
9
10
  var eslint = require('@rollup/plugin-eslint');
@@ -95,6 +96,71 @@ function getNpmTag(version) {
95
96
  const match = version.match(NPM_TAG);
96
97
  return match ? match[1] : 'latest';
97
98
  }
99
+ function printErrorWithFrame(output, deep = 0, hide = false) {
100
+ var _a, _b, _c, _d, _e;
101
+ if (!output)
102
+ return '';
103
+ const input = output.split('\n');
104
+ const start = input.findIndex(line => line.trim().startsWith(deep ? '[cause]: Error:' : 'Error:'));
105
+ if (!~start)
106
+ return output;
107
+ const inputFrame = input.slice(0, start);
108
+ const end = input.slice(start + 1).findIndex(line => line.trim().startsWith('[cause]: Error:'));
109
+ const inputBody = input.slice(start, ~end ? start + end - 1 : undefined);
110
+ const inputCauses = ~end ? input.slice(start + end - 1) : [];
111
+ const bodyStackStart = inputBody.findIndex(line => line.trim().startsWith('at '));
112
+ const bodyText = ~bodyStackStart ? inputBody.slice(0, bodyStackStart).join('\n') : inputBody.join('\n');
113
+ const bodyStack = ~bodyStackStart ? inputBody.slice(bodyStackStart) : [];
114
+ const filePathWithNumber = bodyStack.length ? (_a = bodyStack[0].match(/\(([^(]+)\)$/)) === null || _a === void 0 ? void 0 : _a[1] : undefined;
115
+ const splitFilePath = (_b = filePathWithNumber === null || filePathWithNumber === void 0 ? void 0 : filePathWithNumber.split(':')) !== null && _b !== void 0 ? _b : [];
116
+ const filePath = (_c = splitFilePath[0]) === null || _c === void 0 ? void 0 : _c.trim();
117
+ const line = Number((_d = splitFilePath[1]) !== null && _d !== void 0 ? _d : 1);
118
+ const column = Number((_e = splitFilePath[2]) !== null && _e !== void 0 ? _e : 1);
119
+ let frame = '';
120
+ if (filePath && !filePath.includes('node_modules')) {
121
+ try {
122
+ const source = fs__default["default"].readFileSync(filePath, 'utf8');
123
+ frame = codeFrame.codeFrameColumns(source, { start: { line, column } }, { highlightCode: true });
124
+ }
125
+ catch (e) { }
126
+ }
127
+ else {
128
+ frame = inputFrame.join('\n');
129
+ }
130
+ const title = bodyText.trim();
131
+ const baseOffset = ' '.repeat(2);
132
+ const offset = baseOffset.repeat(deep);
133
+ const titleOffset = offset + baseOffset + baseOffset;
134
+ let hiddenCount = 0;
135
+ let collapse = titleOffset + 'at ... (0 more node_modules calls)';
136
+ const stack = hide
137
+ ? bodyStack.slice(1).reduce((cur, line) => {
138
+ if (line.includes('node_modules')) {
139
+ if (cur.at(-1) === collapse) {
140
+ collapse = collapse.replace(`${hiddenCount} more`, `${++hiddenCount} more`);
141
+ return [
142
+ ...cur.slice(0, -1),
143
+ collapse,
144
+ ];
145
+ }
146
+ collapse = collapse.replace(`${hiddenCount} more`, `${++hiddenCount} more`);
147
+ return [...cur, collapse];
148
+ }
149
+ hiddenCount = 0;
150
+ collapse = titleOffset + 'at ... (0 more node_modules calls)';
151
+ return [...cur, line];
152
+ }, [])
153
+ : bodyStack.slice(1);
154
+ return [
155
+ chalk__default["default"].red(`${titleOffset}${title}`),
156
+ bodyStack[0],
157
+ frame && `${offset}${frame.replaceAll('\n', `\n${offset}`)}`,
158
+ ...stack
159
+ .filter(line => line.trim() !== '}')
160
+ .map(line => line.includes('node_modules') ? chalk__default["default"].gray(line) : line),
161
+ printErrorWithFrame(inputCauses.join('\n'), deep + 1, hide),
162
+ ].filter(Boolean).join('\n');
163
+ }
98
164
  const scriptExtensions = ['ts', 'js', 'tsx', 'jsx'];
99
165
  const indexExt = scriptExtensions.join(',');
100
166
  class InnetJS {
@@ -287,7 +353,7 @@ class InnetJS {
287
353
  }
288
354
  });
289
355
  }
290
- start({ node = false, inject = false, error = false, index = 'index', } = {}) {
356
+ start({ node = false, inject = false, error = false, usualConsoleOutput = false, index = 'index', } = {}) {
291
357
  return tslib.__awaiter(this, void 0, void 0, function* () {
292
358
  const pkg = yield this.getPackage();
293
359
  const input = glob__default["default"].sync(`src/${index}.{${indexExt}}`);
@@ -317,8 +383,11 @@ class InnetJS {
317
383
  if (warning.code === 'THIS_IS_UNDEFINED' || warning.code === 'SOURCEMAP_ERROR')
318
384
  return;
319
385
  if (warning.plugin === 'typescript') {
320
- const { loc: { line, column, file }, frame, message } = warning;
321
- console.log(`ERROR in ${file}:${line}:${column}`);
386
+ const { loc, frame, message } = warning;
387
+ if (loc) {
388
+ const { line, column, file } = loc;
389
+ console.log(`ERROR in ${file}:${line}:${column}`);
390
+ }
322
391
  console.log(message);
323
392
  console.log(frame);
324
393
  return;
@@ -336,7 +405,7 @@ class InnetJS {
336
405
  options.plugins.push(pluginNodeResolve.nodeResolve(), string({
337
406
  include: '**/*.*',
338
407
  exclude: constants.stringExcludeNode,
339
- }), this.createServer(input));
408
+ }), this.createServer(input, error, usualConsoleOutput));
340
409
  }
341
410
  else {
342
411
  const key = path__default["default"].basename(this.sslKey) !== this.sslKey
@@ -729,17 +798,34 @@ class InnetJS {
729
798
  }),
730
799
  };
731
800
  }
732
- createServer(input) {
801
+ createServer(input, error = false, usualConsoleOutput = false) {
733
802
  const apps = {};
734
803
  return {
735
804
  name: 'server',
736
805
  writeBundle: () => tslib.__awaiter(this, void 0, void 0, function* () {
737
806
  var _a;
738
807
  for (const file of input) {
808
+ let stderrBuffer = '';
739
809
  const { name } = path__default["default"].parse(file);
740
810
  (_a = apps[name]) === null || _a === void 0 ? void 0 : _a.kill();
741
811
  const filePath = path__default["default"].resolve(this.devBuildFolder, `${name}.js`);
742
- apps[name] = spawn('node', ['-r', 'source-map-support/register', filePath], { stdio: 'inherit' });
812
+ if (usualConsoleOutput) {
813
+ apps[name] = spawn('node', ['-r', 'source-map-support/register', filePath], { stdio: 'inherit' });
814
+ return;
815
+ }
816
+ const child = spawn('node', ['-r', 'source-map-support/register', filePath], {
817
+ stdio: ['inherit', 'pipe'],
818
+ });
819
+ apps[name] = child;
820
+ child.stderr.on('data', (chunk) => {
821
+ stderrBuffer += chunk.toString();
822
+ });
823
+ child.on('close', (code) => {
824
+ if (code !== 0 && stderrBuffer) {
825
+ console.error(printErrorWithFrame(stderrBuffer, 0, !error));
826
+ stderrBuffer = '';
827
+ }
828
+ });
743
829
  }
744
830
  }),
745
831
  };
package/index.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  import './_virtual/_rollup-plugin-process-env.mjs';
2
2
  import { __awaiter } from 'tslib';
3
+ import { codeFrameColumns } from '@babel/code-frame';
3
4
  import logger from '@cantinc/logger';
4
5
  import commonjs from '@rollup/plugin-commonjs';
5
6
  import eslint from '@rollup/plugin-eslint';
@@ -58,6 +59,71 @@ function getNpmTag(version) {
58
59
  const match = version.match(NPM_TAG);
59
60
  return match ? match[1] : 'latest';
60
61
  }
62
+ function printErrorWithFrame(output, deep = 0, hide = false) {
63
+ var _a, _b, _c, _d, _e;
64
+ if (!output)
65
+ return '';
66
+ const input = output.split('\n');
67
+ const start = input.findIndex(line => line.trim().startsWith(deep ? '[cause]: Error:' : 'Error:'));
68
+ if (!~start)
69
+ return output;
70
+ const inputFrame = input.slice(0, start);
71
+ const end = input.slice(start + 1).findIndex(line => line.trim().startsWith('[cause]: Error:'));
72
+ const inputBody = input.slice(start, ~end ? start + end - 1 : undefined);
73
+ const inputCauses = ~end ? input.slice(start + end - 1) : [];
74
+ const bodyStackStart = inputBody.findIndex(line => line.trim().startsWith('at '));
75
+ const bodyText = ~bodyStackStart ? inputBody.slice(0, bodyStackStart).join('\n') : inputBody.join('\n');
76
+ const bodyStack = ~bodyStackStart ? inputBody.slice(bodyStackStart) : [];
77
+ const filePathWithNumber = bodyStack.length ? (_a = bodyStack[0].match(/\(([^(]+)\)$/)) === null || _a === void 0 ? void 0 : _a[1] : undefined;
78
+ const splitFilePath = (_b = filePathWithNumber === null || filePathWithNumber === void 0 ? void 0 : filePathWithNumber.split(':')) !== null && _b !== void 0 ? _b : [];
79
+ const filePath = (_c = splitFilePath[0]) === null || _c === void 0 ? void 0 : _c.trim();
80
+ const line = Number((_d = splitFilePath[1]) !== null && _d !== void 0 ? _d : 1);
81
+ const column = Number((_e = splitFilePath[2]) !== null && _e !== void 0 ? _e : 1);
82
+ let frame = '';
83
+ if (filePath && !filePath.includes('node_modules')) {
84
+ try {
85
+ const source = fs.readFileSync(filePath, 'utf8');
86
+ frame = codeFrameColumns(source, { start: { line, column } }, { highlightCode: true });
87
+ }
88
+ catch (e) { }
89
+ }
90
+ else {
91
+ frame = inputFrame.join('\n');
92
+ }
93
+ const title = bodyText.trim();
94
+ const baseOffset = ' '.repeat(2);
95
+ const offset = baseOffset.repeat(deep);
96
+ const titleOffset = offset + baseOffset + baseOffset;
97
+ let hiddenCount = 0;
98
+ let collapse = titleOffset + 'at ... (0 more node_modules calls)';
99
+ const stack = hide
100
+ ? bodyStack.slice(1).reduce((cur, line) => {
101
+ if (line.includes('node_modules')) {
102
+ if (cur.at(-1) === collapse) {
103
+ collapse = collapse.replace(`${hiddenCount} more`, `${++hiddenCount} more`);
104
+ return [
105
+ ...cur.slice(0, -1),
106
+ collapse,
107
+ ];
108
+ }
109
+ collapse = collapse.replace(`${hiddenCount} more`, `${++hiddenCount} more`);
110
+ return [...cur, collapse];
111
+ }
112
+ hiddenCount = 0;
113
+ collapse = titleOffset + 'at ... (0 more node_modules calls)';
114
+ return [...cur, line];
115
+ }, [])
116
+ : bodyStack.slice(1);
117
+ return [
118
+ chalk.red(`${titleOffset}${title}`),
119
+ bodyStack[0],
120
+ frame && `${offset}${frame.replaceAll('\n', `\n${offset}`)}`,
121
+ ...stack
122
+ .filter(line => line.trim() !== '}')
123
+ .map(line => line.includes('node_modules') ? chalk.gray(line) : line),
124
+ printErrorWithFrame(inputCauses.join('\n'), deep + 1, hide),
125
+ ].filter(Boolean).join('\n');
126
+ }
61
127
  const scriptExtensions = ['ts', 'js', 'tsx', 'jsx'];
62
128
  const indexExt = scriptExtensions.join(',');
63
129
  class InnetJS {
@@ -250,7 +316,7 @@ class InnetJS {
250
316
  }
251
317
  });
252
318
  }
253
- start({ node = false, inject = false, error = false, index = 'index', } = {}) {
319
+ start({ node = false, inject = false, error = false, usualConsoleOutput = false, index = 'index', } = {}) {
254
320
  return __awaiter(this, void 0, void 0, function* () {
255
321
  const pkg = yield this.getPackage();
256
322
  const input = glob.sync(`src/${index}.{${indexExt}}`);
@@ -280,8 +346,11 @@ class InnetJS {
280
346
  if (warning.code === 'THIS_IS_UNDEFINED' || warning.code === 'SOURCEMAP_ERROR')
281
347
  return;
282
348
  if (warning.plugin === 'typescript') {
283
- const { loc: { line, column, file }, frame, message } = warning;
284
- console.log(`ERROR in ${file}:${line}:${column}`);
349
+ const { loc, frame, message } = warning;
350
+ if (loc) {
351
+ const { line, column, file } = loc;
352
+ console.log(`ERROR in ${file}:${line}:${column}`);
353
+ }
285
354
  console.log(message);
286
355
  console.log(frame);
287
356
  return;
@@ -299,7 +368,7 @@ class InnetJS {
299
368
  options.plugins.push(nodeResolve(), string({
300
369
  include: '**/*.*',
301
370
  exclude: stringExcludeNode,
302
- }), this.createServer(input));
371
+ }), this.createServer(input, error, usualConsoleOutput));
303
372
  }
304
373
  else {
305
374
  const key = path.basename(this.sslKey) !== this.sslKey
@@ -692,17 +761,34 @@ class InnetJS {
692
761
  }),
693
762
  };
694
763
  }
695
- createServer(input) {
764
+ createServer(input, error = false, usualConsoleOutput = false) {
696
765
  const apps = {};
697
766
  return {
698
767
  name: 'server',
699
768
  writeBundle: () => __awaiter(this, void 0, void 0, function* () {
700
769
  var _a;
701
770
  for (const file of input) {
771
+ let stderrBuffer = '';
702
772
  const { name } = path.parse(file);
703
773
  (_a = apps[name]) === null || _a === void 0 ? void 0 : _a.kill();
704
774
  const filePath = path.resolve(this.devBuildFolder, `${name}.js`);
705
- apps[name] = spawn('node', ['-r', 'source-map-support/register', filePath], { stdio: 'inherit' });
775
+ if (usualConsoleOutput) {
776
+ apps[name] = spawn('node', ['-r', 'source-map-support/register', filePath], { stdio: 'inherit' });
777
+ return;
778
+ }
779
+ const child = spawn('node', ['-r', 'source-map-support/register', filePath], {
780
+ stdio: ['inherit', 'pipe'],
781
+ });
782
+ apps[name] = child;
783
+ child.stderr.on('data', (chunk) => {
784
+ stderrBuffer += chunk.toString();
785
+ });
786
+ child.on('close', (code) => {
787
+ if (code !== 0 && stderrBuffer) {
788
+ console.error(printErrorWithFrame(stderrBuffer, 0, !error));
789
+ stderrBuffer = '';
790
+ }
791
+ });
706
792
  }
707
793
  }),
708
794
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "innetjs",
3
- "version": "3.1.0",
3
+ "version": "3.2.0",
4
4
  "description": "CLI for innet boilerplate",
5
5
  "homepage": "https://github.com/d8corp/innetjs",
6
6
  "author": "Mikhail Lysikov <d8corp@mail.ru>",
@@ -49,6 +49,7 @@
49
49
  "url": "https://github.com/d8corp/innetjs/issues"
50
50
  },
51
51
  "dependencies": {
52
+ "@babel/code-frame": "^7.29.0",
52
53
  "@cantinc/logger": "^1.1.0",
53
54
  "@rollup/plugin-commonjs": "^24.0.1",
54
55
  "@rollup/plugin-eslint": "^9.0.1",
@@ -86,7 +87,6 @@
86
87
  "rollup-plugin-styles": "^4.0.0",
87
88
  "rollup-plugin-terser": "^7.0.2",
88
89
  "sass": "^1.55.0",
89
- "tmp": "^0.2.1",
90
- "typescript": "^4.8.4"
90
+ "tmp": "^0.2.1"
91
91
  }
92
92
  }