innetjs 2.5.1 → 2.5.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.
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  ;(function () {
4
- const env = {"__INNETJS__PACKAGE_VERSION":"2.5.1"};
4
+ const env = {"__INNETJS__PACKAGE_VERSION":"2.5.3"};
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":"2.5.1"};
2
+ const env = {"__INNETJS__PACKAGE_VERSION":"2.5.3"};
3
3
  if (typeof process === 'undefined') {
4
4
  globalThis.process = { env: env };
5
5
  } else if (process.env) {
package/bin/innet CHANGED
@@ -163,13 +163,16 @@ function getFile(file) {
163
163
  }
164
164
  return file;
165
165
  }
166
- function convertIndexFile(data, version, baseUrl, index) {
166
+ function convertIndexFile(data, version, baseUrl, index, inject) {
167
167
  return tslib.__awaiter(this, void 0, void 0, function* () {
168
168
  const { env } = process;
169
- return data
169
+ const indexString = data
170
170
  .toString()
171
- .replace('</head>', `<script type="module" defer src="${baseUrl}${index}.js${version ? `?v=${version}` : ''}"></script></head>`)
172
171
  .replace(/%([A-Z0-9_]+)%/g, (placeholder, placeholderId) => { var _a; return (_a = env[placeholderId]) !== null && _a !== void 0 ? _a : placeholder; });
172
+ return inject
173
+ ? indexString
174
+ .replace('</head>', `<script type="module" defer src="${baseUrl}${index}.js${version ? `?v=${version}` : ''}"></script></head>`)
175
+ : indexString;
173
176
  });
174
177
  }
175
178
  const reporter = (options, outputOptions, info) => {
@@ -277,7 +280,7 @@ class InnetJS {
277
280
  yield logger__default["default"].start('Install packages', () => execAsync(`cd ${appPath} && npm i`));
278
281
  });
279
282
  }
280
- build({ node = false, index = 'index' } = {}) {
283
+ build({ node = false, inject = false, index = 'index' } = {}) {
281
284
  return tslib.__awaiter(this, void 0, void 0, function* () {
282
285
  const input = glob__default["default"].sync(`src/${index}.{${indexExt}}`);
283
286
  if (!input.length) {
@@ -355,7 +358,7 @@ class InnetJS {
355
358
  yield copyFiles(this.publicFolder, this.buildFolder);
356
359
  const data = yield fs.promises.readFile(this.publicIndexFile);
357
360
  const pkg = yield this.getPackage();
358
- yield fs.promises.writeFile(this.buildIndexFile, yield convertIndexFile(data, pkg.version, this.baseUrl, path__default["default"].parse(input[0]).name));
361
+ yield fs.promises.writeFile(this.buildIndexFile, yield convertIndexFile(data, pkg.version, this.baseUrl, path__default["default"].parse(input[0]).name, inject));
359
362
  }
360
363
  }));
361
364
  if (pkg) {
@@ -374,7 +377,7 @@ class InnetJS {
374
377
  }
375
378
  });
376
379
  }
377
- start({ node = false, error = false, index = 'index' } = {}) {
380
+ start({ node = false, inject = false, error = false, index = 'index' } = {}) {
378
381
  return tslib.__awaiter(this, void 0, void 0, function* () {
379
382
  const pkg = yield this.getPackage();
380
383
  const input = glob__default["default"].sync(`src/${index}.{${indexExt}}`);
@@ -393,7 +396,6 @@ class InnetJS {
393
396
  commonjs__default["default"](),
394
397
  json__default["default"](),
395
398
  typescript__default["default"]({
396
- noEmitOnError: true,
397
399
  compilerOptions: {
398
400
  declaration: false,
399
401
  sourceMap: true,
@@ -404,6 +406,13 @@ class InnetJS {
404
406
  onwarn(warning, warn) {
405
407
  if (warning.code === 'THIS_IS_UNDEFINED' || warning.code === 'SOURCEMAP_ERROR')
406
408
  return;
409
+ if (warning.plugin === 'typescript') {
410
+ const { loc: { line, column, file }, frame, message } = warning;
411
+ console.log(`ERROR in ${file}:${line}:${column}`);
412
+ console.log(message);
413
+ console.log(frame);
414
+ return;
415
+ }
407
416
  warn(warning);
408
417
  },
409
418
  };
@@ -447,7 +456,7 @@ class InnetJS {
447
456
  }), string({
448
457
  include: '**/*.*',
449
458
  exclude: stringExcludeDom,
450
- }), this.createClient(key, cert, pkg, path__default["default"].parse(input[0]).name), livereload(Object.assign({ exts: ['html', 'css', 'js', 'png', 'svg', 'webp', 'gif', 'jpg', 'json'], watch: [this.devBuildFolder, this.publicFolder], verbose: false }, (key && cert ? { https: { key, cert } } : {}))));
459
+ }), this.createClient(key, cert, pkg, path__default["default"].parse(input[0]).name, inject), livereload(Object.assign({ exts: ['html', 'css', 'js', 'png', 'svg', 'webp', 'gif', 'jpg', 'json'], watch: [this.devBuildFolder, this.publicFolder], verbose: false }, (key && cert ? { https: { key, cert } } : {}))));
451
460
  }
452
461
  this.withEnv(options, true);
453
462
  const watcher = rollup__default["default"].watch(options);
@@ -727,7 +736,7 @@ class InnetJS {
727
736
  return this.package;
728
737
  });
729
738
  }
730
- createClient(key, cert, pkg, index) {
739
+ createClient(key, cert, pkg, index, inject) {
731
740
  let app;
732
741
  return {
733
742
  name: 'client',
@@ -737,7 +746,7 @@ class InnetJS {
737
746
  app = express__default["default"]();
738
747
  const update = () => tslib.__awaiter(this, void 0, void 0, function* () {
739
748
  const data = yield fs.promises.readFile(this.publicIndexFile);
740
- yield fs.promises.writeFile(this.devBuildIndexFile, yield convertIndexFile(data, pkg.version, this.baseUrl, index));
749
+ yield fs.promises.writeFile(this.devBuildIndexFile, yield convertIndexFile(data, pkg.version, this.baseUrl, index, inject));
741
750
  });
742
751
  fs__default["default"].watch(this.publicIndexFile, update);
743
752
  yield update();
@@ -802,7 +811,7 @@ class InnetJS {
802
811
  }
803
812
 
804
813
  (function () {
805
- const env = {"__INNETJS__PACKAGE_VERSION":"2.5.1"};
814
+ const env = {"__INNETJS__PACKAGE_VERSION":"2.5.3"};
806
815
  if (typeof process === 'undefined') {
807
816
  globalThis.process = { env: env };
808
817
  } else if (process.env) {
@@ -845,10 +854,11 @@ commander.program
845
854
  .command('start')
846
855
  .description('Start development with innet boilerplate')
847
856
  .option('-n, --node', 'Start development for Node.js')
857
+ .option('-in, --inject', 'Injects script element into index.html')
848
858
  .option('-i, --index <index>', 'Root index file name', 'index')
849
859
  .addOption(errorOption)
850
- .action(({ error, node, index }) => {
851
- innetJS.start({ node, error, index }).catch(e => {
860
+ .action(({ error, node, index, inject }) => {
861
+ innetJS.start({ node, error, index, inject }).catch(e => {
852
862
  if (error) {
853
863
  console.error(e);
854
864
  process.exit(1);
@@ -860,9 +870,10 @@ commander.program
860
870
  .description('Build production bundle')
861
871
  .addOption(errorOption)
862
872
  .option('-n, --node', 'Build for node.js')
873
+ .option('-in, --inject', 'Injects script element into index.html')
863
874
  .option('-i, --index <index>', 'Root index file name', 'index')
864
- .action(({ error, node, index }) => {
865
- innetJS.build({ node, index }).catch(e => {
875
+ .action(({ error, node, index, inject }) => {
876
+ innetJS.build({ node, index, inject }).catch(e => {
866
877
  if (error) {
867
878
  console.error(e);
868
879
  process.exit(1);
package/helpers.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
2
  import { FileSizeRender } from 'rollup-plugin-filesize';
3
3
  export declare function getFile(file: any): any;
4
- export declare function convertIndexFile(data: Buffer, version: string, baseUrl: string, index: string): Promise<string>;
4
+ export declare function convertIndexFile(data: Buffer, version: string, baseUrl: string, index: string, inject: boolean): Promise<string>;
5
5
  export declare const reporter: FileSizeRender<string | Promise<string>>;
package/helpers.js CHANGED
@@ -37,13 +37,16 @@ function getFile(file) {
37
37
  }
38
38
  return file;
39
39
  }
40
- function convertIndexFile(data, version, baseUrl, index) {
40
+ function convertIndexFile(data, version, baseUrl, index, inject) {
41
41
  return tslib.__awaiter(this, void 0, void 0, function* () {
42
42
  const { env } = process;
43
- return data
43
+ const indexString = data
44
44
  .toString()
45
- .replace('</head>', `<script type="module" defer src="${baseUrl}${index}.js${version ? `?v=${version}` : ''}"></script></head>`)
46
45
  .replace(/%([A-Z0-9_]+)%/g, (placeholder, placeholderId) => { var _a; return (_a = env[placeholderId]) !== null && _a !== void 0 ? _a : placeholder; });
46
+ return inject
47
+ ? indexString
48
+ .replace('</head>', `<script type="module" defer src="${baseUrl}${index}.js${version ? `?v=${version}` : ''}"></script></head>`)
49
+ : indexString;
47
50
  });
48
51
  }
49
52
  const reporter = (options, outputOptions, info) => {
package/helpers.mjs CHANGED
@@ -26,13 +26,16 @@ function getFile(file) {
26
26
  }
27
27
  return file;
28
28
  }
29
- function convertIndexFile(data, version, baseUrl, index) {
29
+ function convertIndexFile(data, version, baseUrl, index, inject) {
30
30
  return __awaiter(this, void 0, void 0, function* () {
31
31
  const { env } = process;
32
- return data
32
+ const indexString = data
33
33
  .toString()
34
- .replace('</head>', `<script type="module" defer src="${baseUrl}${index}.js${version ? `?v=${version}` : ''}"></script></head>`)
35
34
  .replace(/%([A-Z0-9_]+)%/g, (placeholder, placeholderId) => { var _a; return (_a = env[placeholderId]) !== null && _a !== void 0 ? _a : placeholder; });
35
+ return inject
36
+ ? indexString
37
+ .replace('</head>', `<script type="module" defer src="${baseUrl}${index}.js${version ? `?v=${version}` : ''}"></script></head>`)
38
+ : indexString;
36
39
  });
37
40
  }
38
41
  const reporter = (options, outputOptions, info) => {
package/index.d.ts CHANGED
@@ -53,12 +53,14 @@ export declare class InnetJS {
53
53
  api?: string;
54
54
  });
55
55
  init(appName: string, { template, force }?: any): Promise<void>;
56
- build({ node, index }?: {
56
+ build({ node, inject, index }?: {
57
57
  node?: boolean;
58
+ inject?: boolean;
58
59
  index?: string;
59
60
  }): Promise<void>;
60
- start({ node, error, index }?: {
61
+ start({ node, inject, error, index }?: {
61
62
  node?: boolean;
63
+ inject?: boolean;
62
64
  error?: boolean;
63
65
  index?: string;
64
66
  }): Promise<void>;
@@ -69,6 +71,6 @@ export declare class InnetJS {
69
71
  withEnv(options: rollup.RollupOptions, virtual?: boolean): void;
70
72
  increaseVersion(release: string): Promise<void>;
71
73
  getPackage(): Promise<Record<string, any>>;
72
- createClient(key: any, cert: any, pkg: any, index: string): rollup.Plugin;
74
+ createClient(key: any, cert: any, pkg: any, index: string, inject: boolean): rollup.Plugin;
73
75
  createServer(): rollup.Plugin;
74
76
  }
package/index.js CHANGED
@@ -166,7 +166,7 @@ class InnetJS {
166
166
  yield logger__default["default"].start('Install packages', () => execAsync(`cd ${appPath} && npm i`));
167
167
  });
168
168
  }
169
- build({ node = false, index = 'index' } = {}) {
169
+ build({ node = false, inject = false, index = 'index' } = {}) {
170
170
  return tslib.__awaiter(this, void 0, void 0, function* () {
171
171
  const input = glob__default["default"].sync(`src/${index}.{${indexExt}}`);
172
172
  if (!input.length) {
@@ -244,7 +244,7 @@ class InnetJS {
244
244
  yield copyFiles(this.publicFolder, this.buildFolder);
245
245
  const data = yield fs.promises.readFile(this.publicIndexFile);
246
246
  const pkg = yield this.getPackage();
247
- yield fs.promises.writeFile(this.buildIndexFile, yield helpers.convertIndexFile(data, pkg.version, this.baseUrl, path__default["default"].parse(input[0]).name));
247
+ yield fs.promises.writeFile(this.buildIndexFile, yield helpers.convertIndexFile(data, pkg.version, this.baseUrl, path__default["default"].parse(input[0]).name, inject));
248
248
  }
249
249
  }));
250
250
  if (pkg) {
@@ -263,7 +263,7 @@ class InnetJS {
263
263
  }
264
264
  });
265
265
  }
266
- start({ node = false, error = false, index = 'index' } = {}) {
266
+ start({ node = false, inject = false, error = false, index = 'index' } = {}) {
267
267
  return tslib.__awaiter(this, void 0, void 0, function* () {
268
268
  const pkg = yield this.getPackage();
269
269
  const input = glob__default["default"].sync(`src/${index}.{${indexExt}}`);
@@ -282,7 +282,6 @@ class InnetJS {
282
282
  commonjs__default["default"](),
283
283
  json__default["default"](),
284
284
  typescript__default["default"]({
285
- noEmitOnError: true,
286
285
  compilerOptions: {
287
286
  declaration: false,
288
287
  sourceMap: true,
@@ -293,6 +292,13 @@ class InnetJS {
293
292
  onwarn(warning, warn) {
294
293
  if (warning.code === 'THIS_IS_UNDEFINED' || warning.code === 'SOURCEMAP_ERROR')
295
294
  return;
295
+ if (warning.plugin === 'typescript') {
296
+ const { loc: { line, column, file }, frame, message } = warning;
297
+ console.log(`ERROR in ${file}:${line}:${column}`);
298
+ console.log(message);
299
+ console.log(frame);
300
+ return;
301
+ }
296
302
  warn(warning);
297
303
  },
298
304
  };
@@ -336,7 +342,7 @@ class InnetJS {
336
342
  }), string({
337
343
  include: '**/*.*',
338
344
  exclude: constants.stringExcludeDom,
339
- }), this.createClient(key, cert, pkg, path__default["default"].parse(input[0]).name), livereload(Object.assign({ exts: ['html', 'css', 'js', 'png', 'svg', 'webp', 'gif', 'jpg', 'json'], watch: [this.devBuildFolder, this.publicFolder], verbose: false }, (key && cert ? { https: { key, cert } } : {}))));
345
+ }), this.createClient(key, cert, pkg, path__default["default"].parse(input[0]).name, inject), livereload(Object.assign({ exts: ['html', 'css', 'js', 'png', 'svg', 'webp', 'gif', 'jpg', 'json'], watch: [this.devBuildFolder, this.publicFolder], verbose: false }, (key && cert ? { https: { key, cert } } : {}))));
340
346
  }
341
347
  this.withEnv(options, true);
342
348
  const watcher = rollup__default["default"].watch(options);
@@ -616,7 +622,7 @@ class InnetJS {
616
622
  return this.package;
617
623
  });
618
624
  }
619
- createClient(key, cert, pkg, index) {
625
+ createClient(key, cert, pkg, index, inject) {
620
626
  let app;
621
627
  return {
622
628
  name: 'client',
@@ -626,7 +632,7 @@ class InnetJS {
626
632
  app = express__default["default"]();
627
633
  const update = () => tslib.__awaiter(this, void 0, void 0, function* () {
628
634
  const data = yield fs.promises.readFile(this.publicIndexFile);
629
- yield fs.promises.writeFile(this.devBuildIndexFile, yield helpers.convertIndexFile(data, pkg.version, this.baseUrl, index));
635
+ yield fs.promises.writeFile(this.devBuildIndexFile, yield helpers.convertIndexFile(data, pkg.version, this.baseUrl, index, inject));
630
636
  });
631
637
  fs__default["default"].watch(this.publicIndexFile, update);
632
638
  yield update();
package/index.mjs CHANGED
@@ -130,7 +130,7 @@ class InnetJS {
130
130
  yield logger.start('Install packages', () => execAsync(`cd ${appPath} && npm i`));
131
131
  });
132
132
  }
133
- build({ node = false, index = 'index' } = {}) {
133
+ build({ node = false, inject = false, index = 'index' } = {}) {
134
134
  return __awaiter(this, void 0, void 0, function* () {
135
135
  const input = glob.sync(`src/${index}.{${indexExt}}`);
136
136
  if (!input.length) {
@@ -208,7 +208,7 @@ class InnetJS {
208
208
  yield copyFiles(this.publicFolder, this.buildFolder);
209
209
  const data = yield promises.readFile(this.publicIndexFile);
210
210
  const pkg = yield this.getPackage();
211
- yield promises.writeFile(this.buildIndexFile, yield convertIndexFile(data, pkg.version, this.baseUrl, path.parse(input[0]).name));
211
+ yield promises.writeFile(this.buildIndexFile, yield convertIndexFile(data, pkg.version, this.baseUrl, path.parse(input[0]).name, inject));
212
212
  }
213
213
  }));
214
214
  if (pkg) {
@@ -227,7 +227,7 @@ class InnetJS {
227
227
  }
228
228
  });
229
229
  }
230
- start({ node = false, error = false, index = 'index' } = {}) {
230
+ start({ node = false, inject = false, error = false, index = 'index' } = {}) {
231
231
  return __awaiter(this, void 0, void 0, function* () {
232
232
  const pkg = yield this.getPackage();
233
233
  const input = glob.sync(`src/${index}.{${indexExt}}`);
@@ -246,7 +246,6 @@ class InnetJS {
246
246
  commonjs(),
247
247
  json(),
248
248
  typescript({
249
- noEmitOnError: true,
250
249
  compilerOptions: {
251
250
  declaration: false,
252
251
  sourceMap: true,
@@ -257,6 +256,13 @@ class InnetJS {
257
256
  onwarn(warning, warn) {
258
257
  if (warning.code === 'THIS_IS_UNDEFINED' || warning.code === 'SOURCEMAP_ERROR')
259
258
  return;
259
+ if (warning.plugin === 'typescript') {
260
+ const { loc: { line, column, file }, frame, message } = warning;
261
+ console.log(`ERROR in ${file}:${line}:${column}`);
262
+ console.log(message);
263
+ console.log(frame);
264
+ return;
265
+ }
260
266
  warn(warning);
261
267
  },
262
268
  };
@@ -300,7 +306,7 @@ class InnetJS {
300
306
  }), string({
301
307
  include: '**/*.*',
302
308
  exclude: stringExcludeDom,
303
- }), this.createClient(key, cert, pkg, path.parse(input[0]).name), livereload(Object.assign({ exts: ['html', 'css', 'js', 'png', 'svg', 'webp', 'gif', 'jpg', 'json'], watch: [this.devBuildFolder, this.publicFolder], verbose: false }, (key && cert ? { https: { key, cert } } : {}))));
309
+ }), this.createClient(key, cert, pkg, path.parse(input[0]).name, inject), livereload(Object.assign({ exts: ['html', 'css', 'js', 'png', 'svg', 'webp', 'gif', 'jpg', 'json'], watch: [this.devBuildFolder, this.publicFolder], verbose: false }, (key && cert ? { https: { key, cert } } : {}))));
304
310
  }
305
311
  this.withEnv(options, true);
306
312
  const watcher = rollup.watch(options);
@@ -580,7 +586,7 @@ class InnetJS {
580
586
  return this.package;
581
587
  });
582
588
  }
583
- createClient(key, cert, pkg, index) {
589
+ createClient(key, cert, pkg, index, inject) {
584
590
  let app;
585
591
  return {
586
592
  name: 'client',
@@ -590,7 +596,7 @@ class InnetJS {
590
596
  app = express();
591
597
  const update = () => __awaiter(this, void 0, void 0, function* () {
592
598
  const data = yield promises.readFile(this.publicIndexFile);
593
- yield promises.writeFile(this.devBuildIndexFile, yield convertIndexFile(data, pkg.version, this.baseUrl, index));
599
+ yield promises.writeFile(this.devBuildIndexFile, yield convertIndexFile(data, pkg.version, this.baseUrl, index, inject));
594
600
  });
595
601
  fs.watch(this.publicIndexFile, update);
596
602
  yield update();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "innetjs",
3
- "version": "2.5.1",
3
+ "version": "2.5.3",
4
4
  "description": "CLI for innet boilerplate",
5
5
  "homepage": "https://github.com/d8corp/innetjs",
6
6
  "author": "Mikhail Lysikov <d8corp@mail.ru>",