innetjs 2.6.0-alpha.6 → 2.6.0-alpha.8

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.6.0-alpha.6"};
4
+ const env = {"__INNETJS__PACKAGE_VERSION":"2.6.0-alpha.8"};
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.6.0-alpha.6"};
2
+ const env = {"__INNETJS__PACKAGE_VERSION":"2.6.0-alpha.8"};
3
3
  if (typeof process === 'undefined') {
4
4
  globalThis.process = { env: env };
5
5
  } else if (process.env) {
package/bin/innet CHANGED
@@ -22,7 +22,7 @@ var glob = require('glob');
22
22
  var http = require('node:http');
23
23
  var https = require('node:https');
24
24
  var linesAndColumns = require('lines-and-columns');
25
- var path$1 = require('node:path');
25
+ var path = require('node:path');
26
26
  var prompt = require('prompts');
27
27
  var rollup = require('rollup');
28
28
  var external = require('rollup-plugin-external-node-modules');
@@ -34,9 +34,10 @@ var rollupPluginPreserveShebangs = require('rollup-plugin-preserve-shebangs');
34
34
  var env = require('rollup-plugin-process-env');
35
35
  var styles = require('rollup-plugin-styles');
36
36
  var rollupPluginTerser = require('rollup-plugin-terser');
37
+ var stream = require('node:stream');
37
38
  var tmp = require('tmp');
38
- var node_util = require('node:util');
39
39
  var unzipper = require('unzipper');
40
+ var node_util = require('node:util');
40
41
 
41
42
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
42
43
 
@@ -57,7 +58,7 @@ var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
57
58
  var glob__default = /*#__PURE__*/_interopDefaultLegacy(glob);
58
59
  var http__default = /*#__PURE__*/_interopDefaultLegacy(http);
59
60
  var https__default = /*#__PURE__*/_interopDefaultLegacy(https);
60
- var path__default = /*#__PURE__*/_interopDefaultLegacy(path$1);
61
+ var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
61
62
  var prompt__default = /*#__PURE__*/_interopDefaultLegacy(prompt);
62
63
  var rollup__default = /*#__PURE__*/_interopDefaultLegacy(rollup);
63
64
  var external__default = /*#__PURE__*/_interopDefaultLegacy(external);
@@ -67,6 +68,7 @@ var externals__default = /*#__PURE__*/_interopDefaultLegacy(externals);
67
68
  var polyfill__default = /*#__PURE__*/_interopDefaultLegacy(polyfill);
68
69
  var env__default = /*#__PURE__*/_interopDefaultLegacy(env);
69
70
  var styles__default = /*#__PURE__*/_interopDefaultLegacy(styles);
71
+ var stream__default = /*#__PURE__*/_interopDefaultLegacy(stream);
70
72
  var tmp__default = /*#__PURE__*/_interopDefaultLegacy(tmp);
71
73
 
72
74
  const lintInclude = [
@@ -97,48 +99,6 @@ const stringExcludeNode = [
97
99
  '**/*.json',
98
100
  ];
99
101
 
100
- const Writer = require('fstream').Writer;
101
- const path = require('path');
102
- const stream = require('stream');
103
- const duplexer2 = require('duplexer2');
104
- const Promise$1 = require('bluebird');
105
- function Extract(opts, template) {
106
- const reduceCount = 19 + template.length;
107
- // make sure path is normalized before using it
108
- opts.path = path.resolve(path.normalize(opts.path));
109
- // @ts-expect-error
110
- const parser = new unzipper.Parse(opts);
111
- const outStream = new stream.Writable({ objectMode: true });
112
- outStream._write = function (entry, encoding, cb) {
113
- if (entry.type === 'Directory')
114
- return cb();
115
- const extractPath = path.join(opts.path, entry.path.slice(reduceCount));
116
- if (extractPath.indexOf(opts.path) !== 0) {
117
- return cb();
118
- }
119
- const writer = opts.getWriter ? opts.getWriter({ path: extractPath }) : Writer({ path: extractPath });
120
- entry.pipe(writer)
121
- .on('error', cb)
122
- .on('close', cb);
123
- };
124
- const extract = duplexer2(parser, outStream);
125
- parser.once('crx-header', function (crxHeader) {
126
- extract.crxHeader = crxHeader;
127
- });
128
- parser
129
- .pipe(outStream)
130
- .on('finish', function () {
131
- extract.emit('close');
132
- });
133
- extract.promise = function () {
134
- return new Promise$1(function (resolve, reject) {
135
- extract.on('close', resolve);
136
- extract.on('error', reject);
137
- });
138
- };
139
- return extract;
140
- }
141
-
142
102
  function getFile(file) {
143
103
  file = path__default["default"].resolve(file);
144
104
  if (!fs__default["default"].existsSync(file)) {
@@ -194,6 +154,7 @@ const readline = require('readline');
194
154
  const importAssets = require('rollup-plugin-import-assets');
195
155
  const execAsync = node_util.promisify(exec);
196
156
  const copyFiles = node_util.promisify(fs__default["default"].copy);
157
+ const pipeline = node_util.promisify(stream__default["default"].pipeline);
197
158
  updateDotenv();
198
159
  const REG_CLEAR_TEXT = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g;
199
160
  const REG_RPT_ERROR_FILE = /(src[^:]+):(\d+):(\d+)/;
@@ -266,14 +227,20 @@ class InnetJS {
266
227
  }));
267
228
  }
268
229
  yield logger__default["default"].start('Download template', () => tslib.__awaiter(this, void 0, void 0, function* () {
230
+ if (!fs__default["default"].existsSync(appPath)) {
231
+ fs__default["default"].mkdirSync(appPath);
232
+ }
233
+ const zipPath = `${path__default["default"].join(appPath, 'template.zip')}`;
269
234
  const { data } = yield axios__default["default"].get(`https://github.com/d8corp/innetjs-templates/archive/refs/heads/${template}.zip`, {
270
235
  responseType: 'stream',
271
236
  });
237
+ yield pipeline(data, fs__default["default"].createWriteStream(zipPath));
272
238
  yield new Promise((resolve, reject) => {
273
- data.pipe(Extract({
274
- path: appPath,
275
- }, template)).on('finish', resolve).on('error', reject);
239
+ fs__default["default"].createReadStream(zipPath)
240
+ .pipe(unzipper.Extract({ path: appPath }))
241
+ .on('finish', resolve).on('error', reject);
276
242
  });
243
+ yield fs__default["default"].remove(zipPath);
277
244
  }));
278
245
  yield logger__default["default"].start('Install packages', () => execAsync(`cd ${appPath} && npm i`));
279
246
  });
@@ -805,7 +772,7 @@ class InnetJS {
805
772
  }
806
773
 
807
774
  (function () {
808
- const env = {"__INNETJS__PACKAGE_VERSION":"2.6.0-alpha.6"};
775
+ const env = {"__INNETJS__PACKAGE_VERSION":"2.6.0-alpha.8"};
809
776
  if (typeof process === 'undefined') {
810
777
  globalThis.process = { env: env };
811
778
  } else if (process.env) {
package/index.js CHANGED
@@ -35,10 +35,11 @@ var rollupPluginPreserveShebangs = require('rollup-plugin-preserve-shebangs');
35
35
  var env = require('rollup-plugin-process-env');
36
36
  var styles = require('rollup-plugin-styles');
37
37
  var rollupPluginTerser = require('rollup-plugin-terser');
38
+ var stream = require('node:stream');
38
39
  var tmp = require('tmp');
40
+ var unzipper = require('unzipper');
39
41
  var node_util = require('node:util');
40
42
  var constants = require('./constants.js');
41
- var extract = require('./extract.js');
42
43
  var helpers = require('./helpers.js');
43
44
  var updateDotenv = require('./updateDotenv.js');
44
45
 
@@ -71,6 +72,7 @@ var externals__default = /*#__PURE__*/_interopDefaultLegacy(externals);
71
72
  var polyfill__default = /*#__PURE__*/_interopDefaultLegacy(polyfill);
72
73
  var env__default = /*#__PURE__*/_interopDefaultLegacy(env);
73
74
  var styles__default = /*#__PURE__*/_interopDefaultLegacy(styles);
75
+ var stream__default = /*#__PURE__*/_interopDefaultLegacy(stream);
74
76
  var tmp__default = /*#__PURE__*/_interopDefaultLegacy(tmp);
75
77
 
76
78
  const livereload = require('rollup-plugin-livereload');
@@ -80,6 +82,7 @@ const readline = require('readline');
80
82
  const importAssets = require('rollup-plugin-import-assets');
81
83
  const execAsync = node_util.promisify(exec);
82
84
  const copyFiles = node_util.promisify(fs__default["default"].copy);
85
+ const pipeline = node_util.promisify(stream__default["default"].pipeline);
83
86
  updateDotenv.updateDotenv();
84
87
  const REG_CLEAR_TEXT = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g;
85
88
  const REG_RPT_ERROR_FILE = /(src[^:]+):(\d+):(\d+)/;
@@ -152,14 +155,20 @@ class InnetJS {
152
155
  }));
153
156
  }
154
157
  yield logger__default["default"].start('Download template', () => tslib.__awaiter(this, void 0, void 0, function* () {
158
+ if (!fs__default["default"].existsSync(appPath)) {
159
+ fs__default["default"].mkdirSync(appPath);
160
+ }
161
+ const zipPath = `${path__default["default"].join(appPath, 'template.zip')}`;
155
162
  const { data } = yield axios__default["default"].get(`https://github.com/d8corp/innetjs-templates/archive/refs/heads/${template}.zip`, {
156
163
  responseType: 'stream',
157
164
  });
165
+ yield pipeline(data, fs__default["default"].createWriteStream(zipPath));
158
166
  yield new Promise((resolve, reject) => {
159
- data.pipe(extract.Extract({
160
- path: appPath,
161
- }, template)).on('finish', resolve).on('error', reject);
167
+ fs__default["default"].createReadStream(zipPath)
168
+ .pipe(unzipper.Extract({ path: appPath }))
169
+ .on('finish', resolve).on('error', reject);
162
170
  });
171
+ yield fs__default["default"].remove(zipPath);
163
172
  }));
164
173
  yield logger__default["default"].start('Install packages', () => execAsync(`cd ${appPath} && npm i`));
165
174
  });
package/index.mjs CHANGED
@@ -31,10 +31,11 @@ import { preserveShebangs } from 'rollup-plugin-preserve-shebangs';
31
31
  import env from 'rollup-plugin-process-env';
32
32
  import styles from 'rollup-plugin-styles';
33
33
  import { terser } from 'rollup-plugin-terser';
34
+ import stream from 'node:stream';
34
35
  import tmp from 'tmp';
36
+ import { Extract } from 'unzipper';
35
37
  import { promisify } from 'node:util';
36
38
  import { stringExcludeNode, imageInclude, stringExcludeDom, lintInclude } from './constants.mjs';
37
- import { Extract } from './extract.mjs';
38
39
  import { reporter, convertIndexFile, getFile } from './helpers.mjs';
39
40
  import { updateDotenv } from './updateDotenv.mjs';
40
41
 
@@ -45,6 +46,7 @@ const readline = require('readline');
45
46
  const importAssets = require('rollup-plugin-import-assets');
46
47
  const execAsync = promisify(exec);
47
48
  const copyFiles = promisify(fs.copy);
49
+ const pipeline = promisify(stream.pipeline);
48
50
  updateDotenv();
49
51
  const REG_CLEAR_TEXT = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g;
50
52
  const REG_RPT_ERROR_FILE = /(src[^:]+):(\d+):(\d+)/;
@@ -117,14 +119,20 @@ class InnetJS {
117
119
  }));
118
120
  }
119
121
  yield logger.start('Download template', () => __awaiter(this, void 0, void 0, function* () {
122
+ if (!fs.existsSync(appPath)) {
123
+ fs.mkdirSync(appPath);
124
+ }
125
+ const zipPath = `${path.join(appPath, 'template.zip')}`;
120
126
  const { data } = yield axios.get(`https://github.com/d8corp/innetjs-templates/archive/refs/heads/${template}.zip`, {
121
127
  responseType: 'stream',
122
128
  });
129
+ yield pipeline(data, fs.createWriteStream(zipPath));
123
130
  yield new Promise((resolve, reject) => {
124
- data.pipe(Extract({
125
- path: appPath,
126
- }, template)).on('finish', resolve).on('error', reject);
131
+ fs.createReadStream(zipPath)
132
+ .pipe(Extract({ path: appPath }))
133
+ .on('finish', resolve).on('error', reject);
127
134
  });
135
+ yield fs.remove(zipPath);
128
136
  }));
129
137
  yield logger.start('Install packages', () => execAsync(`cd ${appPath} && npm i`));
130
138
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "innetjs",
3
- "version": "2.6.0-alpha.6",
3
+ "version": "2.6.0-alpha.8",
4
4
  "description": "CLI for innet boilerplate",
5
5
  "homepage": "https://github.com/d8corp/innetjs",
6
6
  "author": "Mikhail Lysikov <d8corp@mail.ru>",
package/extract.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare function Extract(opts: any, template: any): any;
package/extract.js DELETED
@@ -1,49 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var unzipper = require('unzipper');
6
-
7
- const Writer = require('fstream').Writer;
8
- const path = require('path');
9
- const stream = require('stream');
10
- const duplexer2 = require('duplexer2');
11
- const Promise$1 = require('bluebird');
12
- function Extract(opts, template) {
13
- const reduceCount = 19 + template.length;
14
- // make sure path is normalized before using it
15
- opts.path = path.resolve(path.normalize(opts.path));
16
- // @ts-expect-error
17
- const parser = new unzipper.Parse(opts);
18
- const outStream = new stream.Writable({ objectMode: true });
19
- outStream._write = function (entry, encoding, cb) {
20
- if (entry.type === 'Directory')
21
- return cb();
22
- const extractPath = path.join(opts.path, entry.path.slice(reduceCount));
23
- if (extractPath.indexOf(opts.path) !== 0) {
24
- return cb();
25
- }
26
- const writer = opts.getWriter ? opts.getWriter({ path: extractPath }) : Writer({ path: extractPath });
27
- entry.pipe(writer)
28
- .on('error', cb)
29
- .on('close', cb);
30
- };
31
- const extract = duplexer2(parser, outStream);
32
- parser.once('crx-header', function (crxHeader) {
33
- extract.crxHeader = crxHeader;
34
- });
35
- parser
36
- .pipe(outStream)
37
- .on('finish', function () {
38
- extract.emit('close');
39
- });
40
- extract.promise = function () {
41
- return new Promise$1(function (resolve, reject) {
42
- extract.on('close', resolve);
43
- extract.on('error', reject);
44
- });
45
- };
46
- return extract;
47
- }
48
-
49
- exports.Extract = Extract;
package/extract.mjs DELETED
@@ -1,45 +0,0 @@
1
- import { Parse } from 'unzipper';
2
-
3
- const Writer = require('fstream').Writer;
4
- const path = require('path');
5
- const stream = require('stream');
6
- const duplexer2 = require('duplexer2');
7
- const Promise$1 = require('bluebird');
8
- function Extract(opts, template) {
9
- const reduceCount = 19 + template.length;
10
- // make sure path is normalized before using it
11
- opts.path = path.resolve(path.normalize(opts.path));
12
- // @ts-expect-error
13
- const parser = new Parse(opts);
14
- const outStream = new stream.Writable({ objectMode: true });
15
- outStream._write = function (entry, encoding, cb) {
16
- if (entry.type === 'Directory')
17
- return cb();
18
- const extractPath = path.join(opts.path, entry.path.slice(reduceCount));
19
- if (extractPath.indexOf(opts.path) !== 0) {
20
- return cb();
21
- }
22
- const writer = opts.getWriter ? opts.getWriter({ path: extractPath }) : Writer({ path: extractPath });
23
- entry.pipe(writer)
24
- .on('error', cb)
25
- .on('close', cb);
26
- };
27
- const extract = duplexer2(parser, outStream);
28
- parser.once('crx-header', function (crxHeader) {
29
- extract.crxHeader = crxHeader;
30
- });
31
- parser
32
- .pipe(outStream)
33
- .on('finish', function () {
34
- extract.emit('close');
35
- });
36
- extract.promise = function () {
37
- return new Promise$1(function (resolve, reject) {
38
- extract.on('close', resolve);
39
- extract.on('error', reject);
40
- });
41
- };
42
- return extract;
43
- }
44
-
45
- export { Extract };