innetjs 2.2.10 → 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 +16 -28
- package/index.d.ts +4 -1
- package/index.js +16 -17
- package/index.mjs +16 -17
- package/package.json +1 -1
- package/_virtual/_rollup-plugin-inject-process-env.js +0 -13
- package/_virtual/_rollup-plugin-inject-process-env.mjs +0 -11
package/bin/innet
CHANGED
|
@@ -67,18 +67,6 @@ 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.10"};
|
|
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 } = {}) {
|
|
@@ -333,7 +311,7 @@ class InnetJS {
|
|
|
333
311
|
}), string({
|
|
334
312
|
include: '**/*.*',
|
|
335
313
|
exclude: stringExcludeDom,
|
|
336
|
-
})
|
|
314
|
+
}));
|
|
337
315
|
outputOptions.format = 'es';
|
|
338
316
|
outputOptions.plugins = [
|
|
339
317
|
rollupPluginTerser.terser(),
|
|
@@ -342,6 +320,7 @@ class InnetJS {
|
|
|
342
320
|
}),
|
|
343
321
|
];
|
|
344
322
|
}
|
|
323
|
+
this.withEnv(inputOptions);
|
|
345
324
|
yield logger__default["default"].start('Build production bundle', () => tslib.__awaiter(this, void 0, void 0, function* () {
|
|
346
325
|
const bundle = yield rollup__default["default"].rollup(inputOptions);
|
|
347
326
|
yield bundle.write(outputOptions);
|
|
@@ -431,8 +410,9 @@ class InnetJS {
|
|
|
431
410
|
}), string({
|
|
432
411
|
include: '**/*.*',
|
|
433
412
|
exclude: stringExcludeDom,
|
|
434
|
-
}), 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 } } : {}))));
|
|
435
414
|
}
|
|
415
|
+
this.withEnv(options);
|
|
436
416
|
const watcher = rollup__default["default"].watch(options);
|
|
437
417
|
watcher.on('event', (e) => tslib.__awaiter(this, void 0, void 0, function* () {
|
|
438
418
|
if (e.code === 'ERROR') {
|
|
@@ -548,7 +528,6 @@ class InnetJS {
|
|
|
548
528
|
},
|
|
549
529
|
}),
|
|
550
530
|
jsx__default["default"](),
|
|
551
|
-
env__default["default"](innetEnv, { include: input }),
|
|
552
531
|
],
|
|
553
532
|
};
|
|
554
533
|
this.withLint(options);
|
|
@@ -580,6 +559,7 @@ class InnetJS {
|
|
|
580
559
|
}),
|
|
581
560
|
];
|
|
582
561
|
}
|
|
562
|
+
this.withEnv(options);
|
|
583
563
|
const bundle = yield rollup__default["default"].rollup(options);
|
|
584
564
|
yield bundle.write(options.output);
|
|
585
565
|
yield bundle.close();
|
|
@@ -623,10 +603,10 @@ class InnetJS {
|
|
|
623
603
|
}),
|
|
624
604
|
externals__default["default"](),
|
|
625
605
|
jsx__default["default"](),
|
|
626
|
-
env__default["default"](innetEnv, { include: input }),
|
|
627
606
|
],
|
|
628
607
|
};
|
|
629
608
|
this.withLint(options);
|
|
609
|
+
this.withEnv(options);
|
|
630
610
|
const bundle = yield rollup__default["default"].rollup(options);
|
|
631
611
|
yield bundle.write(options.output);
|
|
632
612
|
yield bundle.close();
|
|
@@ -666,6 +646,9 @@ class InnetJS {
|
|
|
666
646
|
}));
|
|
667
647
|
}
|
|
668
648
|
}
|
|
649
|
+
withEnv(options) {
|
|
650
|
+
options.plugins.push(env__default["default"](this.envPrefix, { include: options.input }));
|
|
651
|
+
}
|
|
669
652
|
increaseVersion(release) {
|
|
670
653
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
671
654
|
const pkg = yield this.getPackage();
|
|
@@ -774,6 +757,11 @@ class InnetJS {
|
|
|
774
757
|
}
|
|
775
758
|
}
|
|
776
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
|
+
}
|
|
777
765
|
updateDotenv();
|
|
778
766
|
const innetJS = new InnetJS();
|
|
779
767
|
const errorOption = new commander.Option('-e, --error', 'Show error details');
|
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;
|
|
@@ -62,6 +64,7 @@ export declare class InnetJS {
|
|
|
62
64
|
release({ node, index, pub }?: ReleaseOptions): Promise<void>;
|
|
63
65
|
private _lintUsage;
|
|
64
66
|
withLint(options: rollup.RollupOptions): void;
|
|
67
|
+
withEnv(options: rollup.RollupOptions): void;
|
|
65
68
|
increaseVersion(release: string): Promise<void>;
|
|
66
69
|
getPackage(): Promise<Record<string, any>>;
|
|
67
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');
|
|
@@ -71,6 +70,11 @@ 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 } = {}) {
|
|
@@ -211,7 +205,7 @@ class InnetJS {
|
|
|
211
205
|
}), string({
|
|
212
206
|
include: '**/*.*',
|
|
213
207
|
exclude: constants.stringExcludeDom,
|
|
214
|
-
})
|
|
208
|
+
}));
|
|
215
209
|
outputOptions.format = 'es';
|
|
216
210
|
outputOptions.plugins = [
|
|
217
211
|
rollupPluginTerser.terser(),
|
|
@@ -220,6 +214,7 @@ class InnetJS {
|
|
|
220
214
|
}),
|
|
221
215
|
];
|
|
222
216
|
}
|
|
217
|
+
this.withEnv(inputOptions);
|
|
223
218
|
yield logger__default["default"].start('Build production bundle', () => tslib.__awaiter(this, void 0, void 0, function* () {
|
|
224
219
|
const bundle = yield rollup__default["default"].rollup(inputOptions);
|
|
225
220
|
yield bundle.write(outputOptions);
|
|
@@ -309,8 +304,9 @@ class InnetJS {
|
|
|
309
304
|
}), string({
|
|
310
305
|
include: '**/*.*',
|
|
311
306
|
exclude: constants.stringExcludeDom,
|
|
312
|
-
}), 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 } } : {}))));
|
|
313
308
|
}
|
|
309
|
+
this.withEnv(options);
|
|
314
310
|
const watcher = rollup__default["default"].watch(options);
|
|
315
311
|
watcher.on('event', (e) => tslib.__awaiter(this, void 0, void 0, function* () {
|
|
316
312
|
if (e.code === 'ERROR') {
|
|
@@ -426,7 +422,6 @@ class InnetJS {
|
|
|
426
422
|
},
|
|
427
423
|
}),
|
|
428
424
|
jsx__default["default"](),
|
|
429
|
-
env__default["default"](innetEnv, { include: input }),
|
|
430
425
|
],
|
|
431
426
|
};
|
|
432
427
|
this.withLint(options);
|
|
@@ -458,6 +453,7 @@ class InnetJS {
|
|
|
458
453
|
}),
|
|
459
454
|
];
|
|
460
455
|
}
|
|
456
|
+
this.withEnv(options);
|
|
461
457
|
const bundle = yield rollup__default["default"].rollup(options);
|
|
462
458
|
yield bundle.write(options.output);
|
|
463
459
|
yield bundle.close();
|
|
@@ -501,10 +497,10 @@ class InnetJS {
|
|
|
501
497
|
}),
|
|
502
498
|
externals__default["default"](),
|
|
503
499
|
jsx__default["default"](),
|
|
504
|
-
env__default["default"](innetEnv, { include: input }),
|
|
505
500
|
],
|
|
506
501
|
};
|
|
507
502
|
this.withLint(options);
|
|
503
|
+
this.withEnv(options);
|
|
508
504
|
const bundle = yield rollup__default["default"].rollup(options);
|
|
509
505
|
yield bundle.write(options.output);
|
|
510
506
|
yield bundle.close();
|
|
@@ -544,6 +540,9 @@ class InnetJS {
|
|
|
544
540
|
}));
|
|
545
541
|
}
|
|
546
542
|
}
|
|
543
|
+
withEnv(options) {
|
|
544
|
+
options.plugins.push(env__default["default"](this.envPrefix, { include: options.input }));
|
|
545
|
+
}
|
|
547
546
|
increaseVersion(release) {
|
|
548
547
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
549
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';
|
|
@@ -37,6 +36,11 @@ 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 } = {}) {
|
|
@@ -177,7 +171,7 @@ class InnetJS {
|
|
|
177
171
|
}), string({
|
|
178
172
|
include: '**/*.*',
|
|
179
173
|
exclude: stringExcludeDom,
|
|
180
|
-
})
|
|
174
|
+
}));
|
|
181
175
|
outputOptions.format = 'es';
|
|
182
176
|
outputOptions.plugins = [
|
|
183
177
|
terser(),
|
|
@@ -186,6 +180,7 @@ class InnetJS {
|
|
|
186
180
|
}),
|
|
187
181
|
];
|
|
188
182
|
}
|
|
183
|
+
this.withEnv(inputOptions);
|
|
189
184
|
yield logger.start('Build production bundle', () => __awaiter(this, void 0, void 0, function* () {
|
|
190
185
|
const bundle = yield rollup.rollup(inputOptions);
|
|
191
186
|
yield bundle.write(outputOptions);
|
|
@@ -275,8 +270,9 @@ class InnetJS {
|
|
|
275
270
|
}), string({
|
|
276
271
|
include: '**/*.*',
|
|
277
272
|
exclude: stringExcludeDom,
|
|
278
|
-
}), 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 } } : {}))));
|
|
279
274
|
}
|
|
275
|
+
this.withEnv(options);
|
|
280
276
|
const watcher = rollup.watch(options);
|
|
281
277
|
watcher.on('event', (e) => __awaiter(this, void 0, void 0, function* () {
|
|
282
278
|
if (e.code === 'ERROR') {
|
|
@@ -392,7 +388,6 @@ class InnetJS {
|
|
|
392
388
|
},
|
|
393
389
|
}),
|
|
394
390
|
jsx(),
|
|
395
|
-
env(innetEnv, { include: input }),
|
|
396
391
|
],
|
|
397
392
|
};
|
|
398
393
|
this.withLint(options);
|
|
@@ -424,6 +419,7 @@ class InnetJS {
|
|
|
424
419
|
}),
|
|
425
420
|
];
|
|
426
421
|
}
|
|
422
|
+
this.withEnv(options);
|
|
427
423
|
const bundle = yield rollup.rollup(options);
|
|
428
424
|
yield bundle.write(options.output);
|
|
429
425
|
yield bundle.close();
|
|
@@ -467,10 +463,10 @@ class InnetJS {
|
|
|
467
463
|
}),
|
|
468
464
|
externals(),
|
|
469
465
|
jsx(),
|
|
470
|
-
env(innetEnv, { include: input }),
|
|
471
466
|
],
|
|
472
467
|
};
|
|
473
468
|
this.withLint(options);
|
|
469
|
+
this.withEnv(options);
|
|
474
470
|
const bundle = yield rollup.rollup(options);
|
|
475
471
|
yield bundle.write(options.output);
|
|
476
472
|
yield bundle.close();
|
|
@@ -510,6 +506,9 @@ class InnetJS {
|
|
|
510
506
|
}));
|
|
511
507
|
}
|
|
512
508
|
}
|
|
509
|
+
withEnv(options) {
|
|
510
|
+
options.plugins.push(env(this.envPrefix, { include: options.input }));
|
|
511
|
+
}
|
|
513
512
|
increaseVersion(release) {
|
|
514
513
|
return __awaiter(this, void 0, void 0, function* () {
|
|
515
514
|
const pkg = yield this.getPackage();
|
package/package.json
CHANGED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
(function() {
|
|
4
|
-
const env = {"INNETJS_INNETJS_PACKAGE_VERSION":"2.2.10"};
|
|
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.10"};
|
|
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
|
-
})();
|