innetjs 2.2.9 → 2.2.11
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/innet +99 -105
- package/constants.js +0 -2
- package/constants.mjs +0 -2
- package/extract.js +0 -1
- package/extract.mjs +0 -1
- package/helpers.js +0 -1
- package/helpers.mjs +0 -1
- package/index.d.ts +6 -1
- package/index.js +99 -94
- package/index.mjs +99 -94
- package/package.json +2 -2
- package/updateDotenv.js +0 -2
- package/updateDotenv.mjs +0 -2
- package/_virtual/_rollup-plugin-inject-process-env.js +0 -13
- package/_virtual/_rollup-plugin-inject-process-env.mjs +0 -11
package/bin/innet
CHANGED
|
@@ -25,11 +25,11 @@ var path$1 = require('node:path');
|
|
|
25
25
|
var prompt = require('prompts');
|
|
26
26
|
var rollup = require('rollup');
|
|
27
27
|
var filesize = require('rollup-plugin-filesize');
|
|
28
|
-
var injectEnv = require('rollup-plugin-inject-process-env');
|
|
29
28
|
var jsx = require('rollup-plugin-innet-jsx');
|
|
30
29
|
var externals = require('rollup-plugin-node-externals');
|
|
31
30
|
var polyfill = require('rollup-plugin-polyfill-node');
|
|
32
31
|
var rollupPluginPreserveShebangs = require('rollup-plugin-preserve-shebangs');
|
|
32
|
+
var env = require('rollup-plugin-process-env');
|
|
33
33
|
var styles = require('rollup-plugin-styles');
|
|
34
34
|
var rollupPluginTerser = require('rollup-plugin-terser');
|
|
35
35
|
var typescript = require('rollup-plugin-typescript2');
|
|
@@ -59,26 +59,14 @@ var path__default = /*#__PURE__*/_interopDefaultLegacy(path$1);
|
|
|
59
59
|
var prompt__default = /*#__PURE__*/_interopDefaultLegacy(prompt);
|
|
60
60
|
var rollup__default = /*#__PURE__*/_interopDefaultLegacy(rollup);
|
|
61
61
|
var filesize__default = /*#__PURE__*/_interopDefaultLegacy(filesize);
|
|
62
|
-
var injectEnv__default = /*#__PURE__*/_interopDefaultLegacy(injectEnv);
|
|
63
62
|
var jsx__default = /*#__PURE__*/_interopDefaultLegacy(jsx);
|
|
64
63
|
var externals__default = /*#__PURE__*/_interopDefaultLegacy(externals);
|
|
65
64
|
var polyfill__default = /*#__PURE__*/_interopDefaultLegacy(polyfill);
|
|
65
|
+
var env__default = /*#__PURE__*/_interopDefaultLegacy(env);
|
|
66
66
|
var styles__default = /*#__PURE__*/_interopDefaultLegacy(styles);
|
|
67
67
|
var typescript__default = /*#__PURE__*/_interopDefaultLegacy(typescript);
|
|
68
68
|
var tmp__default = /*#__PURE__*/_interopDefaultLegacy(tmp);
|
|
69
69
|
|
|
70
|
-
(function() {
|
|
71
|
-
const env = {"INNETJS_INNETJS_PACKAGE_VERSION":"2.2.9"};
|
|
72
|
-
try {
|
|
73
|
-
if (process) {
|
|
74
|
-
process.env = Object.assign({}, process.env);
|
|
75
|
-
Object.assign(process.env, env);
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
} catch (e) {} // avoid ReferenceError: process is not defined
|
|
79
|
-
globalThis.process = { env:env };
|
|
80
|
-
})();
|
|
81
|
-
|
|
82
70
|
const lintInclude = [
|
|
83
71
|
'**/*.ts',
|
|
84
72
|
'**/*.tsx',
|
|
@@ -201,21 +189,10 @@ const execAsync = node_util.promisify(exec);
|
|
|
201
189
|
const copyFiles = node_util.promisify(fs__default["default"].copy);
|
|
202
190
|
updateDotenv();
|
|
203
191
|
const REG_CLEAR_TEXT = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g;
|
|
204
|
-
function normalizeEnv(value) {
|
|
205
|
-
if (value) {
|
|
206
|
-
return value.replace(/\${([a-zA-Z0-9]+)}/g, (placeholder, placeholderId) => { var _a; return (_a = process.env[placeholderId]) !== null && _a !== void 0 ? _a : placeholder; });
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
const innetEnv = Object.keys(process.env).reduce((result, key) => {
|
|
210
|
-
if (key.startsWith('INNETJS_')) {
|
|
211
|
-
result[key] = normalizeEnv(process.env[key]);
|
|
212
|
-
}
|
|
213
|
-
return result;
|
|
214
|
-
}, {});
|
|
215
192
|
const scriptExtensions = ['ts', 'js', 'tsx', 'jsx'];
|
|
216
193
|
const indexExt = scriptExtensions.join(',');
|
|
217
194
|
class InnetJS {
|
|
218
|
-
constructor({ projectFolder = process.env.PROJECT_FOLDER || '', baseUrl = process.env.BASE_URL || '/', publicFolder = process.env.PUBLIC_FOLDER || 'public', releaseFolder = process.env.RELEASE_FOLDER || 'release', buildFolder = process.env.BUILD_FOLDER || 'build', srcFolder = process.env.SRC_FOLDER || 'src', sourcemap = process.env.SOURCEMAP ? process.env.SOURCEMAP === 'true' : false, cssModules = process.env.CSS_MODULES ? process.env.CSS_MODULES === 'true' : true, cssInJs = process.env.CSS_IN_JS ? process.env.CSS_IN_JS === 'true' : true, sslKey = process.env.SSL_KEY || 'localhost.key', sslCrt = process.env.SSL_CRT || 'localhost.crt', proxy = process.env.PROXY || '', port = process.env.PORT ? +process.env.PORT : 3000, api = process.env.API || '/api/?*', } = {}) {
|
|
195
|
+
constructor({ envPrefix = process.env.INNETJS_ENV_PREFIX || 'INNETJS_', projectFolder = process.env.PROJECT_FOLDER || '', baseUrl = process.env.BASE_URL || '/', publicFolder = process.env.PUBLIC_FOLDER || 'public', releaseFolder = process.env.RELEASE_FOLDER || 'release', buildFolder = process.env.BUILD_FOLDER || 'build', srcFolder = process.env.SRC_FOLDER || 'src', sourcemap = process.env.SOURCEMAP ? process.env.SOURCEMAP === 'true' : false, cssModules = process.env.CSS_MODULES ? process.env.CSS_MODULES === 'true' : true, cssInJs = process.env.CSS_IN_JS ? process.env.CSS_IN_JS === 'true' : true, sslKey = process.env.SSL_KEY || 'localhost.key', sslCrt = process.env.SSL_CRT || 'localhost.crt', proxy = process.env.PROXY || '', port = process.env.PORT ? +process.env.PORT : 3000, api = process.env.API || '/api/?*', } = {}) {
|
|
219
196
|
this.projectFolder = path__default["default"].resolve(projectFolder);
|
|
220
197
|
this.publicFolder = path__default["default"].resolve(publicFolder);
|
|
221
198
|
this.releaseFolder = path__default["default"].resolve(releaseFolder);
|
|
@@ -240,6 +217,7 @@ class InnetJS {
|
|
|
240
217
|
this.proxy = proxy;
|
|
241
218
|
this.api = api;
|
|
242
219
|
this.baseUrl = baseUrl;
|
|
220
|
+
this.envPrefix = envPrefix;
|
|
243
221
|
}
|
|
244
222
|
// Methods
|
|
245
223
|
init(appName, { template, force = false } = {}) {
|
|
@@ -305,11 +283,9 @@ class InnetJS {
|
|
|
305
283
|
json__default["default"](),
|
|
306
284
|
typescript__default["default"](),
|
|
307
285
|
jsx__default["default"](),
|
|
308
|
-
eslint__default["default"]({
|
|
309
|
-
include: lintInclude,
|
|
310
|
-
}),
|
|
311
286
|
],
|
|
312
287
|
};
|
|
288
|
+
this.withLint(inputOptions);
|
|
313
289
|
const outputOptions = {
|
|
314
290
|
dir: this.buildFolder,
|
|
315
291
|
sourcemap: this.sourcemap,
|
|
@@ -335,7 +311,7 @@ class InnetJS {
|
|
|
335
311
|
}), string({
|
|
336
312
|
include: '**/*.*',
|
|
337
313
|
exclude: stringExcludeDom,
|
|
338
|
-
})
|
|
314
|
+
}));
|
|
339
315
|
outputOptions.format = 'es';
|
|
340
316
|
outputOptions.plugins = [
|
|
341
317
|
rollupPluginTerser.terser(),
|
|
@@ -344,6 +320,7 @@ class InnetJS {
|
|
|
344
320
|
}),
|
|
345
321
|
];
|
|
346
322
|
}
|
|
323
|
+
this.withEnv(inputOptions);
|
|
347
324
|
yield logger__default["default"].start('Build production bundle', () => tslib.__awaiter(this, void 0, void 0, function* () {
|
|
348
325
|
const bundle = yield rollup__default["default"].rollup(inputOptions);
|
|
349
326
|
yield bundle.write(outputOptions);
|
|
@@ -397,11 +374,9 @@ class InnetJS {
|
|
|
397
374
|
},
|
|
398
375
|
}),
|
|
399
376
|
jsx__default["default"](),
|
|
400
|
-
eslint__default["default"]({
|
|
401
|
-
include: lintInclude,
|
|
402
|
-
}),
|
|
403
377
|
],
|
|
404
378
|
};
|
|
379
|
+
this.withLint(options);
|
|
405
380
|
if (node) {
|
|
406
381
|
// @ts-expect-error
|
|
407
382
|
options.output.format = 'cjs';
|
|
@@ -435,8 +410,9 @@ class InnetJS {
|
|
|
435
410
|
}), string({
|
|
436
411
|
include: '**/*.*',
|
|
437
412
|
exclude: stringExcludeDom,
|
|
438
|
-
}), this.createClient(key, cert, pkg, index), 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 } } : {})))
|
|
413
|
+
}), this.createClient(key, cert, pkg, index), 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 } } : {}))));
|
|
439
414
|
}
|
|
415
|
+
this.withEnv(options);
|
|
440
416
|
const watcher = rollup__default["default"].watch(options);
|
|
441
417
|
watcher.on('event', (e) => tslib.__awaiter(this, void 0, void 0, function* () {
|
|
442
418
|
if (e.code === 'ERROR') {
|
|
@@ -519,74 +495,75 @@ class InnetJS {
|
|
|
519
495
|
const { releaseFolder, cssModules } = this;
|
|
520
496
|
yield logger__default["default"].start('Remove previous release', () => fs__default["default"].remove(releaseFolder));
|
|
521
497
|
const pkg = yield this.getPackage();
|
|
522
|
-
|
|
498
|
+
const build = (format) => tslib.__awaiter(this, void 0, void 0, function* () {
|
|
523
499
|
var _a, _b;
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
],
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
500
|
+
const ext = format === 'es'
|
|
501
|
+
? ((_a = (pkg.module || pkg.esnext || pkg['jsnext:main'])) === null || _a === void 0 ? void 0 : _a.replace('index', '')) || '.mjs'
|
|
502
|
+
: ((_b = pkg.main) === null || _b === void 0 ? void 0 : _b.replace('index', '')) || '.js';
|
|
503
|
+
const input = glob__default["default"].sync(`src/${index}.{${indexExt}}`);
|
|
504
|
+
if (!input.length) {
|
|
505
|
+
throw Error('index file is not detected');
|
|
506
|
+
}
|
|
507
|
+
const options = {
|
|
508
|
+
input,
|
|
509
|
+
external: [...Object.keys(pkg.dependencies), 'tslib'],
|
|
510
|
+
preserveEntrySignatures: 'strict',
|
|
511
|
+
output: {
|
|
512
|
+
dir: releaseFolder,
|
|
513
|
+
entryFileNames: `[name]${ext}`,
|
|
514
|
+
format,
|
|
515
|
+
preserveModules: true,
|
|
516
|
+
exports: 'auto',
|
|
517
|
+
},
|
|
518
|
+
plugins: [
|
|
519
|
+
json__default["default"](),
|
|
520
|
+
typescript__default["default"]({
|
|
521
|
+
clean: true,
|
|
522
|
+
useTsconfigDeclarationDir: true,
|
|
523
|
+
tsconfigOverride: {
|
|
524
|
+
compilerOptions: {
|
|
525
|
+
declarationDir: releaseFolder,
|
|
526
|
+
sourceMap: false,
|
|
527
|
+
},
|
|
528
|
+
},
|
|
529
|
+
}),
|
|
530
|
+
jsx__default["default"](),
|
|
531
|
+
],
|
|
532
|
+
};
|
|
533
|
+
this.withLint(options);
|
|
534
|
+
if (node) {
|
|
535
|
+
options.plugins = [
|
|
536
|
+
...options.plugins,
|
|
537
|
+
externals__default["default"](),
|
|
538
|
+
string({
|
|
539
|
+
include: '**/*.*',
|
|
540
|
+
exclude: stringExcludeNode,
|
|
541
|
+
}),
|
|
542
|
+
];
|
|
543
|
+
}
|
|
544
|
+
else {
|
|
545
|
+
options.plugins = [
|
|
546
|
+
...options.plugins,
|
|
547
|
+
string({
|
|
548
|
+
include: '**/*.*',
|
|
549
|
+
exclude: stringExcludeDom,
|
|
550
|
+
}),
|
|
551
|
+
polyfill__default["default"](),
|
|
552
|
+
image__default["default"](),
|
|
553
|
+
styles__default["default"]({
|
|
554
|
+
mode: 'inject',
|
|
555
|
+
url: true,
|
|
556
|
+
plugins: [autoprefixer__default["default"]()],
|
|
557
|
+
modules: cssModules,
|
|
558
|
+
minimize: true,
|
|
559
|
+
}),
|
|
560
|
+
];
|
|
561
|
+
}
|
|
562
|
+
this.withEnv(options);
|
|
563
|
+
const bundle = yield rollup__default["default"].rollup(options);
|
|
564
|
+
yield bundle.write(options.output);
|
|
565
|
+
yield bundle.close();
|
|
566
|
+
});
|
|
590
567
|
yield logger__default["default"].start('Build cjs bundle', () => tslib.__awaiter(this, void 0, void 0, function* () {
|
|
591
568
|
yield build('cjs');
|
|
592
569
|
}));
|
|
@@ -604,7 +581,7 @@ class InnetJS {
|
|
|
604
581
|
const { bin } = pkg;
|
|
605
582
|
for (const name in bin) {
|
|
606
583
|
const value = bin[name];
|
|
607
|
-
const input = glob__default["default"].sync(`src/${value}.{${
|
|
584
|
+
const input = glob__default["default"].sync(`src/${value}.{${indexExt}}`);
|
|
608
585
|
const file = path__default["default"].join(this.releaseFolder, value);
|
|
609
586
|
const options = {
|
|
610
587
|
input,
|
|
@@ -626,11 +603,10 @@ class InnetJS {
|
|
|
626
603
|
}),
|
|
627
604
|
externals__default["default"](),
|
|
628
605
|
jsx__default["default"](),
|
|
629
|
-
injectEnv__default["default"](innetEnv, {
|
|
630
|
-
include: input,
|
|
631
|
-
}),
|
|
632
606
|
],
|
|
633
607
|
};
|
|
608
|
+
this.withLint(options);
|
|
609
|
+
this.withEnv(options);
|
|
634
610
|
const bundle = yield rollup__default["default"].rollup(options);
|
|
635
611
|
yield bundle.write(options.output);
|
|
636
612
|
yield bundle.close();
|
|
@@ -660,6 +636,19 @@ class InnetJS {
|
|
|
660
636
|
}
|
|
661
637
|
});
|
|
662
638
|
}
|
|
639
|
+
withLint(options) {
|
|
640
|
+
if (this._lintUsage === undefined) {
|
|
641
|
+
this._lintUsage = fs__default["default"].existsSync(path__default["default"].join(this.projectFolder, '.eslintrc'));
|
|
642
|
+
}
|
|
643
|
+
if (this._lintUsage) {
|
|
644
|
+
options.plugins.push(eslint__default["default"]({
|
|
645
|
+
include: lintInclude,
|
|
646
|
+
}));
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
withEnv(options) {
|
|
650
|
+
options.plugins.push(env__default["default"](this.envPrefix, { include: options.input }));
|
|
651
|
+
}
|
|
663
652
|
increaseVersion(release) {
|
|
664
653
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
665
654
|
const pkg = yield this.getPackage();
|
|
@@ -768,6 +757,11 @@ class InnetJS {
|
|
|
768
757
|
}
|
|
769
758
|
}
|
|
770
759
|
|
|
760
|
+
if (typeof process === 'undefined') {
|
|
761
|
+
process = { env: {"INNETJS_INNETJS_PACKAGE_VERSION":"2.2.11"} };
|
|
762
|
+
} else {
|
|
763
|
+
Object.assign(process.env, {"INNETJS_INNETJS_PACKAGE_VERSION":"2.2.11"});
|
|
764
|
+
}
|
|
771
765
|
updateDotenv();
|
|
772
766
|
const innetJS = new InnetJS();
|
|
773
767
|
const errorOption = new commander.Option('-e, --error', 'Show error details');
|
package/constants.js
CHANGED
package/constants.mjs
CHANGED
package/extract.js
CHANGED
package/extract.mjs
CHANGED
package/helpers.js
CHANGED
package/helpers.mjs
CHANGED
package/index.d.ts
CHANGED
|
@@ -31,8 +31,10 @@ export declare class InnetJS {
|
|
|
31
31
|
cssInJs: boolean;
|
|
32
32
|
port: number;
|
|
33
33
|
api: string;
|
|
34
|
+
envPrefix: string;
|
|
34
35
|
private package;
|
|
35
|
-
constructor({ projectFolder, baseUrl, publicFolder, releaseFolder, buildFolder, srcFolder, sourcemap, cssModules, cssInJs, sslKey, sslCrt, proxy, port, api, }?: {
|
|
36
|
+
constructor({ envPrefix, projectFolder, baseUrl, publicFolder, releaseFolder, buildFolder, srcFolder, sourcemap, cssModules, cssInJs, sslKey, sslCrt, proxy, port, api, }?: {
|
|
37
|
+
envPrefix?: string;
|
|
36
38
|
projectFolder?: string;
|
|
37
39
|
baseUrl?: string;
|
|
38
40
|
publicFolder?: string;
|
|
@@ -60,6 +62,9 @@ export declare class InnetJS {
|
|
|
60
62
|
}): Promise<void>;
|
|
61
63
|
run(file: any): Promise<void>;
|
|
62
64
|
release({ node, index, pub }?: ReleaseOptions): Promise<void>;
|
|
65
|
+
private _lintUsage;
|
|
66
|
+
withLint(options: rollup.RollupOptions): void;
|
|
67
|
+
withEnv(options: rollup.RollupOptions): void;
|
|
63
68
|
increaseVersion(release: string): Promise<void>;
|
|
64
69
|
getPackage(): Promise<Record<string, any>>;
|
|
65
70
|
createClient(key: any, cert: any, pkg: any, index: string): rollup.Plugin;
|
package/index.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
require('./_virtual/_rollup-plugin-inject-process-env.js');
|
|
6
5
|
var tslib = require('tslib');
|
|
7
6
|
var logger = require('@cantinc/logger');
|
|
8
7
|
var commonjs = require('@rollup/plugin-commonjs');
|
|
@@ -26,11 +25,11 @@ var path = require('node:path');
|
|
|
26
25
|
var prompt = require('prompts');
|
|
27
26
|
var rollup = require('rollup');
|
|
28
27
|
var filesize = require('rollup-plugin-filesize');
|
|
29
|
-
var injectEnv = require('rollup-plugin-inject-process-env');
|
|
30
28
|
var jsx = require('rollup-plugin-innet-jsx');
|
|
31
29
|
var externals = require('rollup-plugin-node-externals');
|
|
32
30
|
var polyfill = require('rollup-plugin-polyfill-node');
|
|
33
31
|
var rollupPluginPreserveShebangs = require('rollup-plugin-preserve-shebangs');
|
|
32
|
+
var env = require('rollup-plugin-process-env');
|
|
34
33
|
var styles = require('rollup-plugin-styles');
|
|
35
34
|
var rollupPluginTerser = require('rollup-plugin-terser');
|
|
36
35
|
var typescript = require('rollup-plugin-typescript2');
|
|
@@ -63,14 +62,19 @@ var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
|
|
63
62
|
var prompt__default = /*#__PURE__*/_interopDefaultLegacy(prompt);
|
|
64
63
|
var rollup__default = /*#__PURE__*/_interopDefaultLegacy(rollup);
|
|
65
64
|
var filesize__default = /*#__PURE__*/_interopDefaultLegacy(filesize);
|
|
66
|
-
var injectEnv__default = /*#__PURE__*/_interopDefaultLegacy(injectEnv);
|
|
67
65
|
var jsx__default = /*#__PURE__*/_interopDefaultLegacy(jsx);
|
|
68
66
|
var externals__default = /*#__PURE__*/_interopDefaultLegacy(externals);
|
|
69
67
|
var polyfill__default = /*#__PURE__*/_interopDefaultLegacy(polyfill);
|
|
68
|
+
var env__default = /*#__PURE__*/_interopDefaultLegacy(env);
|
|
70
69
|
var styles__default = /*#__PURE__*/_interopDefaultLegacy(styles);
|
|
71
70
|
var typescript__default = /*#__PURE__*/_interopDefaultLegacy(typescript);
|
|
72
71
|
var tmp__default = /*#__PURE__*/_interopDefaultLegacy(tmp);
|
|
73
72
|
|
|
73
|
+
if (typeof process === 'undefined') {
|
|
74
|
+
process = { env: {"INNETJS_INNETJS_PACKAGE_VERSION":"2.2.11"} };
|
|
75
|
+
} else {
|
|
76
|
+
Object.assign(process.env, {"INNETJS_INNETJS_PACKAGE_VERSION":"2.2.11"});
|
|
77
|
+
}
|
|
74
78
|
const livereload = require('rollup-plugin-livereload');
|
|
75
79
|
const { string } = require('rollup-plugin-string');
|
|
76
80
|
const { exec, spawn } = require('child_process');
|
|
@@ -79,21 +83,10 @@ const execAsync = node_util.promisify(exec);
|
|
|
79
83
|
const copyFiles = node_util.promisify(fs__default["default"].copy);
|
|
80
84
|
updateDotenv.updateDotenv();
|
|
81
85
|
const REG_CLEAR_TEXT = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g;
|
|
82
|
-
function normalizeEnv(value) {
|
|
83
|
-
if (value) {
|
|
84
|
-
return value.replace(/\${([a-zA-Z0-9]+)}/g, (placeholder, placeholderId) => { var _a; return (_a = process.env[placeholderId]) !== null && _a !== void 0 ? _a : placeholder; });
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
const innetEnv = Object.keys(process.env).reduce((result, key) => {
|
|
88
|
-
if (key.startsWith('INNETJS_')) {
|
|
89
|
-
result[key] = normalizeEnv(process.env[key]);
|
|
90
|
-
}
|
|
91
|
-
return result;
|
|
92
|
-
}, {});
|
|
93
86
|
const scriptExtensions = ['ts', 'js', 'tsx', 'jsx'];
|
|
94
87
|
const indexExt = scriptExtensions.join(',');
|
|
95
88
|
class InnetJS {
|
|
96
|
-
constructor({ projectFolder = process.env.PROJECT_FOLDER || '', baseUrl = process.env.BASE_URL || '/', publicFolder = process.env.PUBLIC_FOLDER || 'public', releaseFolder = process.env.RELEASE_FOLDER || 'release', buildFolder = process.env.BUILD_FOLDER || 'build', srcFolder = process.env.SRC_FOLDER || 'src', sourcemap = process.env.SOURCEMAP ? process.env.SOURCEMAP === 'true' : false, cssModules = process.env.CSS_MODULES ? process.env.CSS_MODULES === 'true' : true, cssInJs = process.env.CSS_IN_JS ? process.env.CSS_IN_JS === 'true' : true, sslKey = process.env.SSL_KEY || 'localhost.key', sslCrt = process.env.SSL_CRT || 'localhost.crt', proxy = process.env.PROXY || '', port = process.env.PORT ? +process.env.PORT : 3000, api = process.env.API || '/api/?*', } = {}) {
|
|
89
|
+
constructor({ envPrefix = process.env.INNETJS_ENV_PREFIX || 'INNETJS_', projectFolder = process.env.PROJECT_FOLDER || '', baseUrl = process.env.BASE_URL || '/', publicFolder = process.env.PUBLIC_FOLDER || 'public', releaseFolder = process.env.RELEASE_FOLDER || 'release', buildFolder = process.env.BUILD_FOLDER || 'build', srcFolder = process.env.SRC_FOLDER || 'src', sourcemap = process.env.SOURCEMAP ? process.env.SOURCEMAP === 'true' : false, cssModules = process.env.CSS_MODULES ? process.env.CSS_MODULES === 'true' : true, cssInJs = process.env.CSS_IN_JS ? process.env.CSS_IN_JS === 'true' : true, sslKey = process.env.SSL_KEY || 'localhost.key', sslCrt = process.env.SSL_CRT || 'localhost.crt', proxy = process.env.PROXY || '', port = process.env.PORT ? +process.env.PORT : 3000, api = process.env.API || '/api/?*', } = {}) {
|
|
97
90
|
this.projectFolder = path__default["default"].resolve(projectFolder);
|
|
98
91
|
this.publicFolder = path__default["default"].resolve(publicFolder);
|
|
99
92
|
this.releaseFolder = path__default["default"].resolve(releaseFolder);
|
|
@@ -118,6 +111,7 @@ class InnetJS {
|
|
|
118
111
|
this.proxy = proxy;
|
|
119
112
|
this.api = api;
|
|
120
113
|
this.baseUrl = baseUrl;
|
|
114
|
+
this.envPrefix = envPrefix;
|
|
121
115
|
}
|
|
122
116
|
// Methods
|
|
123
117
|
init(appName, { template, force = false } = {}) {
|
|
@@ -183,11 +177,9 @@ class InnetJS {
|
|
|
183
177
|
json__default["default"](),
|
|
184
178
|
typescript__default["default"](),
|
|
185
179
|
jsx__default["default"](),
|
|
186
|
-
eslint__default["default"]({
|
|
187
|
-
include: constants.lintInclude,
|
|
188
|
-
}),
|
|
189
180
|
],
|
|
190
181
|
};
|
|
182
|
+
this.withLint(inputOptions);
|
|
191
183
|
const outputOptions = {
|
|
192
184
|
dir: this.buildFolder,
|
|
193
185
|
sourcemap: this.sourcemap,
|
|
@@ -213,7 +205,7 @@ class InnetJS {
|
|
|
213
205
|
}), string({
|
|
214
206
|
include: '**/*.*',
|
|
215
207
|
exclude: constants.stringExcludeDom,
|
|
216
|
-
})
|
|
208
|
+
}));
|
|
217
209
|
outputOptions.format = 'es';
|
|
218
210
|
outputOptions.plugins = [
|
|
219
211
|
rollupPluginTerser.terser(),
|
|
@@ -222,6 +214,7 @@ class InnetJS {
|
|
|
222
214
|
}),
|
|
223
215
|
];
|
|
224
216
|
}
|
|
217
|
+
this.withEnv(inputOptions);
|
|
225
218
|
yield logger__default["default"].start('Build production bundle', () => tslib.__awaiter(this, void 0, void 0, function* () {
|
|
226
219
|
const bundle = yield rollup__default["default"].rollup(inputOptions);
|
|
227
220
|
yield bundle.write(outputOptions);
|
|
@@ -275,11 +268,9 @@ class InnetJS {
|
|
|
275
268
|
},
|
|
276
269
|
}),
|
|
277
270
|
jsx__default["default"](),
|
|
278
|
-
eslint__default["default"]({
|
|
279
|
-
include: constants.lintInclude,
|
|
280
|
-
}),
|
|
281
271
|
],
|
|
282
272
|
};
|
|
273
|
+
this.withLint(options);
|
|
283
274
|
if (node) {
|
|
284
275
|
// @ts-expect-error
|
|
285
276
|
options.output.format = 'cjs';
|
|
@@ -313,8 +304,9 @@ class InnetJS {
|
|
|
313
304
|
}), string({
|
|
314
305
|
include: '**/*.*',
|
|
315
306
|
exclude: constants.stringExcludeDom,
|
|
316
|
-
}), this.createClient(key, cert, pkg, index), 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 } } : {})))
|
|
307
|
+
}), this.createClient(key, cert, pkg, index), 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 } } : {}))));
|
|
317
308
|
}
|
|
309
|
+
this.withEnv(options);
|
|
318
310
|
const watcher = rollup__default["default"].watch(options);
|
|
319
311
|
watcher.on('event', (e) => tslib.__awaiter(this, void 0, void 0, function* () {
|
|
320
312
|
if (e.code === 'ERROR') {
|
|
@@ -397,74 +389,75 @@ class InnetJS {
|
|
|
397
389
|
const { releaseFolder, cssModules } = this;
|
|
398
390
|
yield logger__default["default"].start('Remove previous release', () => fs__default["default"].remove(releaseFolder));
|
|
399
391
|
const pkg = yield this.getPackage();
|
|
400
|
-
|
|
392
|
+
const build = (format) => tslib.__awaiter(this, void 0, void 0, function* () {
|
|
401
393
|
var _a, _b;
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
],
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
394
|
+
const ext = format === 'es'
|
|
395
|
+
? ((_a = (pkg.module || pkg.esnext || pkg['jsnext:main'])) === null || _a === void 0 ? void 0 : _a.replace('index', '')) || '.mjs'
|
|
396
|
+
: ((_b = pkg.main) === null || _b === void 0 ? void 0 : _b.replace('index', '')) || '.js';
|
|
397
|
+
const input = glob__default["default"].sync(`src/${index}.{${indexExt}}`);
|
|
398
|
+
if (!input.length) {
|
|
399
|
+
throw Error('index file is not detected');
|
|
400
|
+
}
|
|
401
|
+
const options = {
|
|
402
|
+
input,
|
|
403
|
+
external: [...Object.keys(pkg.dependencies), 'tslib'],
|
|
404
|
+
preserveEntrySignatures: 'strict',
|
|
405
|
+
output: {
|
|
406
|
+
dir: releaseFolder,
|
|
407
|
+
entryFileNames: `[name]${ext}`,
|
|
408
|
+
format,
|
|
409
|
+
preserveModules: true,
|
|
410
|
+
exports: 'auto',
|
|
411
|
+
},
|
|
412
|
+
plugins: [
|
|
413
|
+
json__default["default"](),
|
|
414
|
+
typescript__default["default"]({
|
|
415
|
+
clean: true,
|
|
416
|
+
useTsconfigDeclarationDir: true,
|
|
417
|
+
tsconfigOverride: {
|
|
418
|
+
compilerOptions: {
|
|
419
|
+
declarationDir: releaseFolder,
|
|
420
|
+
sourceMap: false,
|
|
421
|
+
},
|
|
422
|
+
},
|
|
423
|
+
}),
|
|
424
|
+
jsx__default["default"](),
|
|
425
|
+
],
|
|
426
|
+
};
|
|
427
|
+
this.withLint(options);
|
|
428
|
+
if (node) {
|
|
429
|
+
options.plugins = [
|
|
430
|
+
...options.plugins,
|
|
431
|
+
externals__default["default"](),
|
|
432
|
+
string({
|
|
433
|
+
include: '**/*.*',
|
|
434
|
+
exclude: constants.stringExcludeNode,
|
|
435
|
+
}),
|
|
436
|
+
];
|
|
437
|
+
}
|
|
438
|
+
else {
|
|
439
|
+
options.plugins = [
|
|
440
|
+
...options.plugins,
|
|
441
|
+
string({
|
|
442
|
+
include: '**/*.*',
|
|
443
|
+
exclude: constants.stringExcludeDom,
|
|
444
|
+
}),
|
|
445
|
+
polyfill__default["default"](),
|
|
446
|
+
image__default["default"](),
|
|
447
|
+
styles__default["default"]({
|
|
448
|
+
mode: 'inject',
|
|
449
|
+
url: true,
|
|
450
|
+
plugins: [autoprefixer__default["default"]()],
|
|
451
|
+
modules: cssModules,
|
|
452
|
+
minimize: true,
|
|
453
|
+
}),
|
|
454
|
+
];
|
|
455
|
+
}
|
|
456
|
+
this.withEnv(options);
|
|
457
|
+
const bundle = yield rollup__default["default"].rollup(options);
|
|
458
|
+
yield bundle.write(options.output);
|
|
459
|
+
yield bundle.close();
|
|
460
|
+
});
|
|
468
461
|
yield logger__default["default"].start('Build cjs bundle', () => tslib.__awaiter(this, void 0, void 0, function* () {
|
|
469
462
|
yield build('cjs');
|
|
470
463
|
}));
|
|
@@ -482,7 +475,7 @@ class InnetJS {
|
|
|
482
475
|
const { bin } = pkg;
|
|
483
476
|
for (const name in bin) {
|
|
484
477
|
const value = bin[name];
|
|
485
|
-
const input = glob__default["default"].sync(`src/${value}.{${
|
|
478
|
+
const input = glob__default["default"].sync(`src/${value}.{${indexExt}}`);
|
|
486
479
|
const file = path__default["default"].join(this.releaseFolder, value);
|
|
487
480
|
const options = {
|
|
488
481
|
input,
|
|
@@ -504,11 +497,10 @@ class InnetJS {
|
|
|
504
497
|
}),
|
|
505
498
|
externals__default["default"](),
|
|
506
499
|
jsx__default["default"](),
|
|
507
|
-
injectEnv__default["default"](innetEnv, {
|
|
508
|
-
include: input,
|
|
509
|
-
}),
|
|
510
500
|
],
|
|
511
501
|
};
|
|
502
|
+
this.withLint(options);
|
|
503
|
+
this.withEnv(options);
|
|
512
504
|
const bundle = yield rollup__default["default"].rollup(options);
|
|
513
505
|
yield bundle.write(options.output);
|
|
514
506
|
yield bundle.close();
|
|
@@ -538,6 +530,19 @@ class InnetJS {
|
|
|
538
530
|
}
|
|
539
531
|
});
|
|
540
532
|
}
|
|
533
|
+
withLint(options) {
|
|
534
|
+
if (this._lintUsage === undefined) {
|
|
535
|
+
this._lintUsage = fs__default["default"].existsSync(path__default["default"].join(this.projectFolder, '.eslintrc'));
|
|
536
|
+
}
|
|
537
|
+
if (this._lintUsage) {
|
|
538
|
+
options.plugins.push(eslint__default["default"]({
|
|
539
|
+
include: constants.lintInclude,
|
|
540
|
+
}));
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
withEnv(options) {
|
|
544
|
+
options.plugins.push(env__default["default"](this.envPrefix, { include: options.input }));
|
|
545
|
+
}
|
|
541
546
|
increaseVersion(release) {
|
|
542
547
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
543
548
|
const pkg = yield this.getPackage();
|
package/index.mjs
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import './_virtual/_rollup-plugin-inject-process-env.mjs';
|
|
2
1
|
import { __awaiter } from 'tslib';
|
|
3
2
|
import logger from '@cantinc/logger';
|
|
4
3
|
import commonjs from '@rollup/plugin-commonjs';
|
|
@@ -22,21 +21,26 @@ import path from 'node:path';
|
|
|
22
21
|
import prompt from 'prompts';
|
|
23
22
|
import rollup from 'rollup';
|
|
24
23
|
import filesize from 'rollup-plugin-filesize';
|
|
25
|
-
import injectEnv from 'rollup-plugin-inject-process-env';
|
|
26
24
|
import jsx from 'rollup-plugin-innet-jsx';
|
|
27
25
|
import externals from 'rollup-plugin-node-externals';
|
|
28
26
|
import polyfill from 'rollup-plugin-polyfill-node';
|
|
29
27
|
import { preserveShebangs } from 'rollup-plugin-preserve-shebangs';
|
|
28
|
+
import env from 'rollup-plugin-process-env';
|
|
30
29
|
import styles from 'rollup-plugin-styles';
|
|
31
30
|
import { terser } from 'rollup-plugin-terser';
|
|
32
31
|
import typescript from 'rollup-plugin-typescript2';
|
|
33
32
|
import tmp from 'tmp';
|
|
34
33
|
import { promisify } from 'node:util';
|
|
35
|
-
import {
|
|
34
|
+
import { stringExcludeNode, stringExcludeDom, lintInclude } from './constants.mjs';
|
|
36
35
|
import { Extract } from './extract.mjs';
|
|
37
36
|
import { reporter, convertIndexFile, getFile } from './helpers.mjs';
|
|
38
37
|
import { updateDotenv } from './updateDotenv.mjs';
|
|
39
38
|
|
|
39
|
+
if (typeof process === 'undefined') {
|
|
40
|
+
process = { env: {"INNETJS_INNETJS_PACKAGE_VERSION":"2.2.11"} };
|
|
41
|
+
} else {
|
|
42
|
+
Object.assign(process.env, {"INNETJS_INNETJS_PACKAGE_VERSION":"2.2.11"});
|
|
43
|
+
}
|
|
40
44
|
const livereload = require('rollup-plugin-livereload');
|
|
41
45
|
const { string } = require('rollup-plugin-string');
|
|
42
46
|
const { exec, spawn } = require('child_process');
|
|
@@ -45,21 +49,10 @@ const execAsync = promisify(exec);
|
|
|
45
49
|
const copyFiles = promisify(fs.copy);
|
|
46
50
|
updateDotenv();
|
|
47
51
|
const REG_CLEAR_TEXT = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g;
|
|
48
|
-
function normalizeEnv(value) {
|
|
49
|
-
if (value) {
|
|
50
|
-
return value.replace(/\${([a-zA-Z0-9]+)}/g, (placeholder, placeholderId) => { var _a; return (_a = process.env[placeholderId]) !== null && _a !== void 0 ? _a : placeholder; });
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
const innetEnv = Object.keys(process.env).reduce((result, key) => {
|
|
54
|
-
if (key.startsWith('INNETJS_')) {
|
|
55
|
-
result[key] = normalizeEnv(process.env[key]);
|
|
56
|
-
}
|
|
57
|
-
return result;
|
|
58
|
-
}, {});
|
|
59
52
|
const scriptExtensions = ['ts', 'js', 'tsx', 'jsx'];
|
|
60
53
|
const indexExt = scriptExtensions.join(',');
|
|
61
54
|
class InnetJS {
|
|
62
|
-
constructor({ projectFolder = process.env.PROJECT_FOLDER || '', baseUrl = process.env.BASE_URL || '/', publicFolder = process.env.PUBLIC_FOLDER || 'public', releaseFolder = process.env.RELEASE_FOLDER || 'release', buildFolder = process.env.BUILD_FOLDER || 'build', srcFolder = process.env.SRC_FOLDER || 'src', sourcemap = process.env.SOURCEMAP ? process.env.SOURCEMAP === 'true' : false, cssModules = process.env.CSS_MODULES ? process.env.CSS_MODULES === 'true' : true, cssInJs = process.env.CSS_IN_JS ? process.env.CSS_IN_JS === 'true' : true, sslKey = process.env.SSL_KEY || 'localhost.key', sslCrt = process.env.SSL_CRT || 'localhost.crt', proxy = process.env.PROXY || '', port = process.env.PORT ? +process.env.PORT : 3000, api = process.env.API || '/api/?*', } = {}) {
|
|
55
|
+
constructor({ envPrefix = process.env.INNETJS_ENV_PREFIX || 'INNETJS_', projectFolder = process.env.PROJECT_FOLDER || '', baseUrl = process.env.BASE_URL || '/', publicFolder = process.env.PUBLIC_FOLDER || 'public', releaseFolder = process.env.RELEASE_FOLDER || 'release', buildFolder = process.env.BUILD_FOLDER || 'build', srcFolder = process.env.SRC_FOLDER || 'src', sourcemap = process.env.SOURCEMAP ? process.env.SOURCEMAP === 'true' : false, cssModules = process.env.CSS_MODULES ? process.env.CSS_MODULES === 'true' : true, cssInJs = process.env.CSS_IN_JS ? process.env.CSS_IN_JS === 'true' : true, sslKey = process.env.SSL_KEY || 'localhost.key', sslCrt = process.env.SSL_CRT || 'localhost.crt', proxy = process.env.PROXY || '', port = process.env.PORT ? +process.env.PORT : 3000, api = process.env.API || '/api/?*', } = {}) {
|
|
63
56
|
this.projectFolder = path.resolve(projectFolder);
|
|
64
57
|
this.publicFolder = path.resolve(publicFolder);
|
|
65
58
|
this.releaseFolder = path.resolve(releaseFolder);
|
|
@@ -84,6 +77,7 @@ class InnetJS {
|
|
|
84
77
|
this.proxy = proxy;
|
|
85
78
|
this.api = api;
|
|
86
79
|
this.baseUrl = baseUrl;
|
|
80
|
+
this.envPrefix = envPrefix;
|
|
87
81
|
}
|
|
88
82
|
// Methods
|
|
89
83
|
init(appName, { template, force = false } = {}) {
|
|
@@ -149,11 +143,9 @@ class InnetJS {
|
|
|
149
143
|
json(),
|
|
150
144
|
typescript(),
|
|
151
145
|
jsx(),
|
|
152
|
-
eslint({
|
|
153
|
-
include: lintInclude,
|
|
154
|
-
}),
|
|
155
146
|
],
|
|
156
147
|
};
|
|
148
|
+
this.withLint(inputOptions);
|
|
157
149
|
const outputOptions = {
|
|
158
150
|
dir: this.buildFolder,
|
|
159
151
|
sourcemap: this.sourcemap,
|
|
@@ -179,7 +171,7 @@ class InnetJS {
|
|
|
179
171
|
}), string({
|
|
180
172
|
include: '**/*.*',
|
|
181
173
|
exclude: stringExcludeDom,
|
|
182
|
-
})
|
|
174
|
+
}));
|
|
183
175
|
outputOptions.format = 'es';
|
|
184
176
|
outputOptions.plugins = [
|
|
185
177
|
terser(),
|
|
@@ -188,6 +180,7 @@ class InnetJS {
|
|
|
188
180
|
}),
|
|
189
181
|
];
|
|
190
182
|
}
|
|
183
|
+
this.withEnv(inputOptions);
|
|
191
184
|
yield logger.start('Build production bundle', () => __awaiter(this, void 0, void 0, function* () {
|
|
192
185
|
const bundle = yield rollup.rollup(inputOptions);
|
|
193
186
|
yield bundle.write(outputOptions);
|
|
@@ -241,11 +234,9 @@ class InnetJS {
|
|
|
241
234
|
},
|
|
242
235
|
}),
|
|
243
236
|
jsx(),
|
|
244
|
-
eslint({
|
|
245
|
-
include: lintInclude,
|
|
246
|
-
}),
|
|
247
237
|
],
|
|
248
238
|
};
|
|
239
|
+
this.withLint(options);
|
|
249
240
|
if (node) {
|
|
250
241
|
// @ts-expect-error
|
|
251
242
|
options.output.format = 'cjs';
|
|
@@ -279,8 +270,9 @@ class InnetJS {
|
|
|
279
270
|
}), string({
|
|
280
271
|
include: '**/*.*',
|
|
281
272
|
exclude: stringExcludeDom,
|
|
282
|
-
}), this.createClient(key, cert, pkg, index), 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 } } : {})))
|
|
273
|
+
}), this.createClient(key, cert, pkg, index), 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 } } : {}))));
|
|
283
274
|
}
|
|
275
|
+
this.withEnv(options);
|
|
284
276
|
const watcher = rollup.watch(options);
|
|
285
277
|
watcher.on('event', (e) => __awaiter(this, void 0, void 0, function* () {
|
|
286
278
|
if (e.code === 'ERROR') {
|
|
@@ -363,74 +355,75 @@ class InnetJS {
|
|
|
363
355
|
const { releaseFolder, cssModules } = this;
|
|
364
356
|
yield logger.start('Remove previous release', () => fs.remove(releaseFolder));
|
|
365
357
|
const pkg = yield this.getPackage();
|
|
366
|
-
|
|
358
|
+
const build = (format) => __awaiter(this, void 0, void 0, function* () {
|
|
367
359
|
var _a, _b;
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
360
|
+
const ext = format === 'es'
|
|
361
|
+
? ((_a = (pkg.module || pkg.esnext || pkg['jsnext:main'])) === null || _a === void 0 ? void 0 : _a.replace('index', '')) || '.mjs'
|
|
362
|
+
: ((_b = pkg.main) === null || _b === void 0 ? void 0 : _b.replace('index', '')) || '.js';
|
|
363
|
+
const input = glob.sync(`src/${index}.{${indexExt}}`);
|
|
364
|
+
if (!input.length) {
|
|
365
|
+
throw Error('index file is not detected');
|
|
366
|
+
}
|
|
367
|
+
const options = {
|
|
368
|
+
input,
|
|
369
|
+
external: [...Object.keys(pkg.dependencies), 'tslib'],
|
|
370
|
+
preserveEntrySignatures: 'strict',
|
|
371
|
+
output: {
|
|
372
|
+
dir: releaseFolder,
|
|
373
|
+
entryFileNames: `[name]${ext}`,
|
|
374
|
+
format,
|
|
375
|
+
preserveModules: true,
|
|
376
|
+
exports: 'auto',
|
|
377
|
+
},
|
|
378
|
+
plugins: [
|
|
379
|
+
json(),
|
|
380
|
+
typescript({
|
|
381
|
+
clean: true,
|
|
382
|
+
useTsconfigDeclarationDir: true,
|
|
383
|
+
tsconfigOverride: {
|
|
384
|
+
compilerOptions: {
|
|
385
|
+
declarationDir: releaseFolder,
|
|
386
|
+
sourceMap: false,
|
|
387
|
+
},
|
|
388
|
+
},
|
|
389
|
+
}),
|
|
390
|
+
jsx(),
|
|
391
|
+
],
|
|
392
|
+
};
|
|
393
|
+
this.withLint(options);
|
|
394
|
+
if (node) {
|
|
395
|
+
options.plugins = [
|
|
396
|
+
...options.plugins,
|
|
397
|
+
externals(),
|
|
398
|
+
string({
|
|
399
|
+
include: '**/*.*',
|
|
400
|
+
exclude: stringExcludeNode,
|
|
401
|
+
}),
|
|
402
|
+
];
|
|
403
|
+
}
|
|
404
|
+
else {
|
|
405
|
+
options.plugins = [
|
|
406
|
+
...options.plugins,
|
|
407
|
+
string({
|
|
408
|
+
include: '**/*.*',
|
|
409
|
+
exclude: stringExcludeDom,
|
|
410
|
+
}),
|
|
411
|
+
polyfill(),
|
|
412
|
+
image(),
|
|
413
|
+
styles({
|
|
414
|
+
mode: 'inject',
|
|
415
|
+
url: true,
|
|
416
|
+
plugins: [autoprefixer()],
|
|
417
|
+
modules: cssModules,
|
|
418
|
+
minimize: true,
|
|
419
|
+
}),
|
|
420
|
+
];
|
|
421
|
+
}
|
|
422
|
+
this.withEnv(options);
|
|
423
|
+
const bundle = yield rollup.rollup(options);
|
|
424
|
+
yield bundle.write(options.output);
|
|
425
|
+
yield bundle.close();
|
|
426
|
+
});
|
|
434
427
|
yield logger.start('Build cjs bundle', () => __awaiter(this, void 0, void 0, function* () {
|
|
435
428
|
yield build('cjs');
|
|
436
429
|
}));
|
|
@@ -448,7 +441,7 @@ class InnetJS {
|
|
|
448
441
|
const { bin } = pkg;
|
|
449
442
|
for (const name in bin) {
|
|
450
443
|
const value = bin[name];
|
|
451
|
-
const input = glob.sync(`src/${value}.{${
|
|
444
|
+
const input = glob.sync(`src/${value}.{${indexExt}}`);
|
|
452
445
|
const file = path.join(this.releaseFolder, value);
|
|
453
446
|
const options = {
|
|
454
447
|
input,
|
|
@@ -470,11 +463,10 @@ class InnetJS {
|
|
|
470
463
|
}),
|
|
471
464
|
externals(),
|
|
472
465
|
jsx(),
|
|
473
|
-
injectEnv(innetEnv, {
|
|
474
|
-
include: input,
|
|
475
|
-
}),
|
|
476
466
|
],
|
|
477
467
|
};
|
|
468
|
+
this.withLint(options);
|
|
469
|
+
this.withEnv(options);
|
|
478
470
|
const bundle = yield rollup.rollup(options);
|
|
479
471
|
yield bundle.write(options.output);
|
|
480
472
|
yield bundle.close();
|
|
@@ -504,6 +496,19 @@ class InnetJS {
|
|
|
504
496
|
}
|
|
505
497
|
});
|
|
506
498
|
}
|
|
499
|
+
withLint(options) {
|
|
500
|
+
if (this._lintUsage === undefined) {
|
|
501
|
+
this._lintUsage = fs.existsSync(path.join(this.projectFolder, '.eslintrc'));
|
|
502
|
+
}
|
|
503
|
+
if (this._lintUsage) {
|
|
504
|
+
options.plugins.push(eslint({
|
|
505
|
+
include: lintInclude,
|
|
506
|
+
}));
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
withEnv(options) {
|
|
510
|
+
options.plugins.push(env(this.envPrefix, { include: options.input }));
|
|
511
|
+
}
|
|
507
512
|
increaseVersion(release) {
|
|
508
513
|
return __awaiter(this, void 0, void 0, function* () {
|
|
509
514
|
const pkg = yield this.getPackage();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "innetjs",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.11",
|
|
4
4
|
"description": "CLI for innet boilerplate",
|
|
5
5
|
"homepage": "https://github.com/d8corp/innetjs",
|
|
6
6
|
"author": "Mikhail Lysikov <d8corp@mail.ru>",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"prompts": "^2.4.2",
|
|
73
73
|
"rollup": "^2.79.1",
|
|
74
74
|
"rollup-plugin-filesize": "^9.1.2",
|
|
75
|
-
"rollup-plugin-
|
|
75
|
+
"rollup-plugin-process-env": "^1.0.0",
|
|
76
76
|
"rollup-plugin-innet-jsx": "^1.3.2",
|
|
77
77
|
"rollup-plugin-livereload": "^2.0.5",
|
|
78
78
|
"rollup-plugin-node-externals": "^5.0.2",
|
package/updateDotenv.js
CHANGED
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
require('./_virtual/_rollup-plugin-inject-process-env.js');
|
|
6
|
-
|
|
7
5
|
function updateDotenv() {
|
|
8
6
|
const { INNETJS_INNETJS_PACKAGE_VERSION } = process.env;
|
|
9
7
|
delete process.env.INNETJS_INNETJS_PACKAGE_VERSION;
|
package/updateDotenv.mjs
CHANGED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
(function() {
|
|
4
|
-
const env = {"INNETJS_INNETJS_PACKAGE_VERSION":"2.2.9"};
|
|
5
|
-
try {
|
|
6
|
-
if (process) {
|
|
7
|
-
process.env = Object.assign({}, process.env);
|
|
8
|
-
Object.assign(process.env, env);
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
} catch (e) {} // avoid ReferenceError: process is not defined
|
|
12
|
-
globalThis.process = { env:env };
|
|
13
|
-
})();
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
(function() {
|
|
2
|
-
const env = {"INNETJS_INNETJS_PACKAGE_VERSION":"2.2.9"};
|
|
3
|
-
try {
|
|
4
|
-
if (process) {
|
|
5
|
-
process.env = Object.assign({}, process.env);
|
|
6
|
-
Object.assign(process.env, env);
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
} catch (e) {} // avoid ReferenceError: process is not defined
|
|
10
|
-
globalThis.process = { env:env };
|
|
11
|
-
})();
|