innetjs 2.5.2 → 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.
- package/_virtual/_rollup-plugin-process-env.js +1 -1
- package/_virtual/_rollup-plugin-process-env.mjs +1 -1
- package/bin/innet +19 -14
- package/helpers.d.ts +1 -1
- package/helpers.js +6 -3
- package/helpers.mjs +6 -3
- package/index.d.ts +5 -3
- package/index.js +6 -6
- package/index.mjs +6 -6
- package/package.json +1 -1
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
|
-
|
|
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}}`);
|
|
@@ -453,7 +456,7 @@ class InnetJS {
|
|
|
453
456
|
}), string({
|
|
454
457
|
include: '**/*.*',
|
|
455
458
|
exclude: stringExcludeDom,
|
|
456
|
-
}), 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 } } : {}))));
|
|
457
460
|
}
|
|
458
461
|
this.withEnv(options, true);
|
|
459
462
|
const watcher = rollup__default["default"].watch(options);
|
|
@@ -733,7 +736,7 @@ class InnetJS {
|
|
|
733
736
|
return this.package;
|
|
734
737
|
});
|
|
735
738
|
}
|
|
736
|
-
createClient(key, cert, pkg, index) {
|
|
739
|
+
createClient(key, cert, pkg, index, inject) {
|
|
737
740
|
let app;
|
|
738
741
|
return {
|
|
739
742
|
name: 'client',
|
|
@@ -743,7 +746,7 @@ class InnetJS {
|
|
|
743
746
|
app = express__default["default"]();
|
|
744
747
|
const update = () => tslib.__awaiter(this, void 0, void 0, function* () {
|
|
745
748
|
const data = yield fs.promises.readFile(this.publicIndexFile);
|
|
746
|
-
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));
|
|
747
750
|
});
|
|
748
751
|
fs__default["default"].watch(this.publicIndexFile, update);
|
|
749
752
|
yield update();
|
|
@@ -808,7 +811,7 @@ class InnetJS {
|
|
|
808
811
|
}
|
|
809
812
|
|
|
810
813
|
(function () {
|
|
811
|
-
const env = {"__INNETJS__PACKAGE_VERSION":"2.5.
|
|
814
|
+
const env = {"__INNETJS__PACKAGE_VERSION":"2.5.3"};
|
|
812
815
|
if (typeof process === 'undefined') {
|
|
813
816
|
globalThis.process = { env: env };
|
|
814
817
|
} else if (process.env) {
|
|
@@ -851,10 +854,11 @@ commander.program
|
|
|
851
854
|
.command('start')
|
|
852
855
|
.description('Start development with innet boilerplate')
|
|
853
856
|
.option('-n, --node', 'Start development for Node.js')
|
|
857
|
+
.option('-in, --inject', 'Injects script element into index.html')
|
|
854
858
|
.option('-i, --index <index>', 'Root index file name', 'index')
|
|
855
859
|
.addOption(errorOption)
|
|
856
|
-
.action(({ error, node, index }) => {
|
|
857
|
-
innetJS.start({ node, error, index }).catch(e => {
|
|
860
|
+
.action(({ error, node, index, inject }) => {
|
|
861
|
+
innetJS.start({ node, error, index, inject }).catch(e => {
|
|
858
862
|
if (error) {
|
|
859
863
|
console.error(e);
|
|
860
864
|
process.exit(1);
|
|
@@ -866,9 +870,10 @@ commander.program
|
|
|
866
870
|
.description('Build production bundle')
|
|
867
871
|
.addOption(errorOption)
|
|
868
872
|
.option('-n, --node', 'Build for node.js')
|
|
873
|
+
.option('-in, --inject', 'Injects script element into index.html')
|
|
869
874
|
.option('-i, --index <index>', 'Root index file name', 'index')
|
|
870
|
-
.action(({ error, node, index }) => {
|
|
871
|
-
innetJS.build({ node, index }).catch(e => {
|
|
875
|
+
.action(({ error, node, index, inject }) => {
|
|
876
|
+
innetJS.build({ node, index, inject }).catch(e => {
|
|
872
877
|
if (error) {
|
|
873
878
|
console.error(e);
|
|
874
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
|
-
|
|
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
|
-
|
|
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}}`);
|
|
@@ -342,7 +342,7 @@ class InnetJS {
|
|
|
342
342
|
}), string({
|
|
343
343
|
include: '**/*.*',
|
|
344
344
|
exclude: constants.stringExcludeDom,
|
|
345
|
-
}), 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 } } : {}))));
|
|
346
346
|
}
|
|
347
347
|
this.withEnv(options, true);
|
|
348
348
|
const watcher = rollup__default["default"].watch(options);
|
|
@@ -622,7 +622,7 @@ class InnetJS {
|
|
|
622
622
|
return this.package;
|
|
623
623
|
});
|
|
624
624
|
}
|
|
625
|
-
createClient(key, cert, pkg, index) {
|
|
625
|
+
createClient(key, cert, pkg, index, inject) {
|
|
626
626
|
let app;
|
|
627
627
|
return {
|
|
628
628
|
name: 'client',
|
|
@@ -632,7 +632,7 @@ class InnetJS {
|
|
|
632
632
|
app = express__default["default"]();
|
|
633
633
|
const update = () => tslib.__awaiter(this, void 0, void 0, function* () {
|
|
634
634
|
const data = yield fs.promises.readFile(this.publicIndexFile);
|
|
635
|
-
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));
|
|
636
636
|
});
|
|
637
637
|
fs__default["default"].watch(this.publicIndexFile, update);
|
|
638
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}}`);
|
|
@@ -306,7 +306,7 @@ class InnetJS {
|
|
|
306
306
|
}), string({
|
|
307
307
|
include: '**/*.*',
|
|
308
308
|
exclude: stringExcludeDom,
|
|
309
|
-
}), 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 } } : {}))));
|
|
310
310
|
}
|
|
311
311
|
this.withEnv(options, true);
|
|
312
312
|
const watcher = rollup.watch(options);
|
|
@@ -586,7 +586,7 @@ class InnetJS {
|
|
|
586
586
|
return this.package;
|
|
587
587
|
});
|
|
588
588
|
}
|
|
589
|
-
createClient(key, cert, pkg, index) {
|
|
589
|
+
createClient(key, cert, pkg, index, inject) {
|
|
590
590
|
let app;
|
|
591
591
|
return {
|
|
592
592
|
name: 'client',
|
|
@@ -596,7 +596,7 @@ class InnetJS {
|
|
|
596
596
|
app = express();
|
|
597
597
|
const update = () => __awaiter(this, void 0, void 0, function* () {
|
|
598
598
|
const data = yield promises.readFile(this.publicIndexFile);
|
|
599
|
-
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));
|
|
600
600
|
});
|
|
601
601
|
fs.watch(this.publicIndexFile, update);
|
|
602
602
|
yield update();
|