jscrambler 6.1.0 → 6.1.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/dist/queries.js CHANGED
@@ -1,16 +1,23 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getApplication = getApplication;
7
- exports.getApplicationSource = getApplicationSource;
8
7
  exports.getApplicationProtections = getApplicationProtections;
9
8
  exports.getApplicationProtectionsCount = getApplicationProtectionsCount;
10
- exports.getTemplates = getTemplates;
9
+ exports.getApplicationSource = getApplicationSource;
11
10
  exports.getApplications = getApplications;
12
11
  exports.getProtection = getProtection;
13
- var getApplicationDefaultFragments = '\n _id,\n name,\n createdAt,\n sources {\n _id,\n filename,\n extension\n }\n';
12
+ exports.getTemplates = getTemplates;
13
+
14
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
15
+
16
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
17
+
18
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
19
+
20
+ var getApplicationDefaultFragments = "\n _id,\n name,\n createdAt,\n sources {\n _id,\n filename,\n extension\n }\n";
14
21
  /**
15
22
  * Return one application by id.
16
23
  * The options params argument can be used to filter protections by version and limit the number of protections returned.
@@ -18,101 +25,96 @@ var getApplicationDefaultFragments = '\n _id,\n name,\n createdAt,\n sources
18
25
  * @param {fragment} fragments GraphQL fragment
19
26
  * @param {Array} params {{String}protectionsVersion, {Integer} protectionsNumber}
20
27
  */
28
+
21
29
  function getApplication(applicationId) {
22
30
  var fragments = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : getApplicationDefaultFragments;
23
- var params = arguments[2];
24
-
31
+ var params = arguments.length > 2 ? arguments[2] : undefined;
25
32
  return {
26
- query: '\n query getApplication ($applicationId: String!, $protectionsVersion: String, $protectionsLimit: Int) {\n application(_id: $applicationId, protectionsVersion: $protectionsVersion, protectionsLimit: $protectionsLimit) {\n ' + fragments + '\n }\n }\n ',
27
- params: JSON.stringify(Object.assign({
33
+ query: "\n query getApplication ($applicationId: String!, $protectionsVersion: String, $protectionsLimit: Int) {\n application(_id: $applicationId, protectionsVersion: $protectionsVersion, protectionsLimit: $protectionsLimit) {\n ".concat(fragments, "\n }\n }\n "),
34
+ params: JSON.stringify(_objectSpread({
28
35
  applicationId: applicationId
29
36
  }, params))
30
37
  };
31
38
  }
32
39
 
33
- var getApplicationSourceDefaultFragments = '\n _id,\n filename,\n extension\n';
40
+ var getApplicationSourceDefaultFragments = "\n _id,\n filename,\n extension\n";
34
41
 
35
42
  function getApplicationSource(sourceId) {
36
43
  var fragments = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : getApplicationSourceDefaultFragments;
37
- var limits = arguments[2];
38
-
44
+ var limits = arguments.length > 2 ? arguments[2] : undefined;
39
45
  return {
40
- query: '\n query getApplicationSource ($sourceId: String!, $contentLimit: Int, $transformedLimit: Int) {\n applicationSource(_id: $sourceId, contentLimit: $contentLimit, transformedLimit: $transformedLimit) {\n ' + fragments + '\n }\n }\n ',
41
- params: JSON.stringify(Object.assign({
46
+ query: "\n query getApplicationSource ($sourceId: String!, $contentLimit: Int, $transformedLimit: Int) {\n applicationSource(_id: $sourceId, contentLimit: $contentLimit, transformedLimit: $transformedLimit) {\n ".concat(fragments, "\n }\n }\n "),
47
+ params: JSON.stringify(_objectSpread({
42
48
  sourceId: sourceId
43
49
  }, limits))
44
50
  };
45
51
  }
46
52
 
47
- var getApplicationProtectionsDefaultFragments = '\n _id,\n sources,\n parameters,\n finishedAt,\n randomizationSeed\n';
53
+ var getApplicationProtectionsDefaultFragments = "\n _id,\n sources,\n parameters,\n finishedAt,\n randomizationSeed\n";
48
54
 
49
55
  function getApplicationProtections(applicationId, params) {
50
56
  var fragments = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : getApplicationProtectionsDefaultFragments;
51
57
  var queryArgs = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
52
-
53
58
  return {
54
- query: '\n query getApplicationProtections ($applicationId: String!, $sort: String, $order: String, $limit: Int, $page: Int' + queryArgs.map(function (v) {
55
- return ',' + v;
56
- }) + ') {\n applicationProtections(_id: $applicationId, sort: $sort, order: $order, limit: $limit, page: $page' + queryArgs.map(function (v) {
57
- return ', ' + v.split(':')[0].replace('$', '') + ': ' + v.split(':')[0];
58
- }) + ') {\n ' + fragments + '\n }\n }\n ',
59
- params: JSON.stringify(Object.assign({
59
+ query: "\n query getApplicationProtections ($applicationId: String!, $sort: String, $order: String, $limit: Int, $page: Int".concat(queryArgs.map(function (v) {
60
+ return ",".concat(v);
61
+ }), ") {\n applicationProtections(_id: $applicationId, sort: $sort, order: $order, limit: $limit, page: $page").concat(queryArgs.map(function (v) {
62
+ return ", ".concat(v.split(':')[0].replace('$', ''), ": ").concat(v.split(':')[0]);
63
+ }), ") {\n ").concat(fragments, "\n }\n }\n "),
64
+ params: JSON.stringify(_objectSpread({
60
65
  applicationId: applicationId
61
66
  }, params))
62
67
  };
63
68
  }
64
69
 
65
- var getApplicationProtectionsCountDefaultFragments = '\n count\n';
70
+ var getApplicationProtectionsCountDefaultFragments = "\n count\n";
66
71
 
67
72
  function getApplicationProtectionsCount(applicationId) {
68
73
  var fragments = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : getApplicationProtectionsCountDefaultFragments;
69
-
70
74
  return {
71
- query: '\n query getApplicationProtectionsCount ($applicationId: String!) {\n applicationProtectionsCount(_id: $applicationId) {\n ' + fragments + '\n }\n }\n ',
75
+ query: "\n query getApplicationProtectionsCount ($applicationId: String!) {\n applicationProtectionsCount(_id: $applicationId) {\n ".concat(fragments, "\n }\n }\n "),
72
76
  params: JSON.stringify({
73
77
  applicationId: applicationId
74
78
  })
75
79
  };
76
80
  }
77
81
 
78
- var getTemplatesDefaultFragments = '\n _id,\n parameters\n';
82
+ var getTemplatesDefaultFragments = "\n _id,\n parameters\n";
79
83
 
80
84
  function getTemplates() {
81
85
  var fragments = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getTemplatesDefaultFragments;
82
-
83
86
  return {
84
- query: '\n query getTemplates {\n templates {\n ' + fragments + '\n }\n }\n ',
87
+ query: "\n query getTemplates {\n templates {\n ".concat(fragments, "\n }\n }\n "),
85
88
  params: '{}'
86
89
  };
87
90
  }
88
91
 
89
- var getApplicationsDefaultFragments = '\n _id,\n name,\n protections,\n parameters\n';
92
+ var getApplicationsDefaultFragments = "\n _id,\n name,\n protections,\n parameters\n";
90
93
  /**
91
94
  * Return all applications.
92
95
  * The options params argument can be used to filter protections by version and limit the number of protections returned.
93
96
  * @param {fragment} fragments GraphQL fragment
94
97
  * @param {Array} params {{String}protectionsVersion, {Integer} protectionsNumber}
95
98
  */
99
+
96
100
  function getApplications() {
97
101
  var fragments = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getApplicationsDefaultFragments;
98
- var params = arguments[1];
99
-
102
+ var params = arguments.length > 1 ? arguments[1] : undefined;
100
103
  return {
101
- query: '\n query getApplications($protectionsVersion:String, $protectionsLimit: Int) {\n applications(protectionsVersion: $protectionsVersion, protectionsLimit: $protectionsLimit) {\n ' + fragments + '\n }\n }\n ',
102
- params: JSON.stringify(Object.assign({}, params))
104
+ query: "\n query getApplications($protectionsVersion:String, $protectionsLimit: Int) {\n applications(protectionsVersion: $protectionsVersion, protectionsLimit: $protectionsLimit) {\n ".concat(fragments, "\n }\n }\n "),
105
+ params: JSON.stringify(_objectSpread({}, params))
103
106
  };
104
107
  }
105
108
 
106
109
  var getProtectionDefaultFragments = {
107
- application: '\n name\n ',
108
- applicationProtection: '\n _id,\n state,\n bail,\n deprecations {\n type,\n entity\n },\n errorMessage,\n sources {\n filename,\n errorMessages {\n message,\n line,\n column,\n fatal\n }\n }\n '
110
+ application: "\n name\n ",
111
+ applicationProtection: "\n _id,\n state,\n bail,\n deprecations {\n type,\n entity\n },\n errorMessage,\n sources {\n filename,\n errorMessages {\n message,\n line,\n column,\n fatal\n }\n }\n "
109
112
  };
110
113
 
111
114
  function getProtection(applicationId, protectionId) {
112
115
  var fragments = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : getProtectionDefaultFragments;
113
-
114
116
  return {
115
- query: '\n query getProtection ($applicationId: String!, $protectionId: String!) {\n application (_id: $applicationId) {\n ' + fragments.application + '\n }\n applicationProtection (_id: $protectionId) {\n ' + fragments.applicationProtection + '\n }\n }\n ',
117
+ query: "\n query getProtection ($applicationId: String!, $protectionId: String!) {\n application (_id: $applicationId) {\n ".concat(fragments.application, "\n }\n applicationProtection (_id: $protectionId) {\n ").concat(fragments.applicationProtection, "\n }\n }\n "),
116
118
  params: JSON.stringify({
117
119
  applicationId: applicationId,
118
120
  protectionId: protectionId
package/dist/utils.js CHANGED
@@ -1,4 +1,4 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
@@ -6,13 +6,9 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.getMatchedFiles = getMatchedFiles;
7
7
  exports.validateNProtections = validateNProtections;
8
8
 
9
- var _glob = require('glob');
9
+ var _glob = _interopRequireDefault(require("glob"));
10
10
 
11
- var _glob2 = _interopRequireDefault(_glob);
12
-
13
- var _fs = require('fs');
14
-
15
- var _fs2 = _interopRequireDefault(_fs);
11
+ var _fs = _interopRequireDefault(require("fs"));
16
12
 
17
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
14
 
@@ -22,14 +18,15 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
22
18
  * @returns {string[]}
23
19
  */
24
20
  function getMatchedFiles(pattern) {
25
- var matchedFiles = _glob2.default.sync(pattern, {
21
+ var matchedFiles = _glob.default.sync(pattern, {
26
22
  dot: true
27
- });
23
+ }); // special case when the real file name contains a minimatch expression (f.e [id]-1234.js)
24
+
28
25
 
29
- // special case when the real file name contains a minimatch expression (f.e [id]-1234.js)
30
- if (matchedFiles.length === 0 && _fs2.default.existsSync(pattern)) {
26
+ if (matchedFiles.length === 0 && _fs.default.existsSync(pattern)) {
31
27
  matchedFiles = [pattern];
32
28
  }
29
+
33
30
  return matchedFiles;
34
31
  }
35
32
 
@@ -39,9 +36,11 @@ function validateNProtections(n) {
39
36
  }
40
37
 
41
38
  var nProtections = parseInt(n, 10);
39
+
42
40
  if (Number.isNaN(nProtections) || nProtections.toString() !== n.toString() || nProtections < 1) {
43
- console.error('*protections* requires an integer greater than 0.');
41
+ console.error("*protections* requires an integer greater than 0.");
44
42
  process.exit(1);
45
43
  }
44
+
46
45
  return nProtections;
47
46
  }
package/dist/zip.js CHANGED
@@ -1,31 +1,73 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.unzip = exports.zip = exports.outputFileSync = undefined;
6
+ Object.defineProperty(exports, "outputFileSync", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _fsExtra.outputFileSync;
10
+ }
11
+ });
12
+ exports.unzip = unzip;
13
+ exports.zip = zip;
14
+ exports.zipSources = zipSources;
15
+
16
+ var _lodash = _interopRequireDefault(require("lodash.size"));
17
+
18
+ var _temp = _interopRequireDefault(require("temp"));
19
+
20
+ var _jszip = _interopRequireDefault(require("jszip"));
21
+
22
+ var _fsExtra = require("fs-extra");
23
+
24
+ var _path2 = require("path");
25
+
26
+ var _q = require("q");
27
+
28
+ var _util = require("util");
29
+
30
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
31
+
32
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
33
+
34
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
35
+
36
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
37
+
38
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
7
39
 
8
- var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
40
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
9
41
 
10
- var zip = exports.zip = function () {
11
- var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(files, cwd) {
12
- var deferred, hasFiles, _zip, zipFile, _zip2, i, l, buffer, name, sPath, tempFile;
42
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
43
+
44
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
45
+
46
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
47
+
48
+ var debug = !!process.env.DEBUG; // ./zip.js module is excluded from browser-like environments. We take advantage of that here.
49
+
50
+ function zip(_x, _x2) {
51
+ return _zip.apply(this, arguments);
52
+ }
53
+
54
+ function _zip() {
55
+ _zip = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(files, cwd) {
56
+ var deferred, hasFiles, _zip2, zipFile, _zip3, i, l, buffer, name, sPath, tempFile;
13
57
 
14
58
  return regeneratorRuntime.wrap(function _callee$(_context) {
15
59
  while (1) {
16
60
  switch (_context.prev = _context.next) {
17
61
  case 0:
18
62
  debug && console.log('Zipping files', (0, _util.inspect)(files));
19
- deferred = (0, _q.defer)();
20
- // Flag to detect if any file was added to the zip archive
63
+ deferred = (0, _q.defer)(); // Flag to detect if any file was added to the zip archive
21
64
 
22
- hasFiles = false;
23
- // Sanitize `cwd`
65
+ hasFiles = false; // Sanitize `cwd`
24
66
 
25
67
  if (cwd) {
26
68
  cwd = (0, _path2.normalize)(cwd);
27
- }
28
- // If it's already a zip file
69
+ } // If it's already a zip file
70
+
29
71
 
30
72
  if (!(files.length === 1 && /^.*\.zip$/.test(files[0]))) {
31
73
  _context.next = 15;
@@ -33,23 +75,22 @@ var zip = exports.zip = function () {
33
75
  }
34
76
 
35
77
  hasFiles = true;
36
- _zip = new _jszip2.default();
78
+ _zip2 = new _jszip.default();
37
79
  zipFile = (0, _fsExtra.readFileSync)(files[0]);
38
-
39
-
40
- (0, _fsExtra.outputFileSync)(_temp2.default.openSync({ suffix: '.zip' }).path, zipFile);
80
+ (0, _fsExtra.outputFileSync)(_temp.default.openSync({
81
+ suffix: '.zip'
82
+ }).path, zipFile);
41
83
  _context.next = 11;
42
- return _zip.loadAsync(zipFile);
84
+ return _zip2.loadAsync(zipFile);
43
85
 
44
86
  case 11:
45
87
  zipFile = _context.sent;
46
-
47
88
  deferred.resolve(zipFile);
48
89
  _context.next = 43;
49
90
  break;
50
91
 
51
92
  case 15:
52
- _zip2 = new _jszip2.default();
93
+ _zip3 = new _jszip.default();
53
94
  i = 0, l = files.length;
54
95
 
55
96
  case 17:
@@ -61,18 +102,19 @@ var zip = exports.zip = function () {
61
102
  // Sanitise path
62
103
  if (typeof files[i] === 'string') {
63
104
  files[i] = (0, _path2.normalize)(files[i]);
105
+
64
106
  if (files[i].indexOf('../') === 0) {
65
107
  files[i] = (0, _path2.resolve)(files[i]);
66
108
  }
67
- }
68
- // Bypass unwanted patterns from `files`
109
+ } // Bypass unwanted patterns from `files`
110
+
69
111
 
70
112
  if (!/.*\.(git|hg)(\/.*|$)/.test(files[i].path || files[i])) {
71
113
  _context.next = 21;
72
114
  break;
73
115
  }
74
116
 
75
- return _context.abrupt('continue', 26);
117
+ return _context.abrupt("continue", 26);
76
118
 
77
119
  case 21:
78
120
  buffer = void 0, name = void 0;
@@ -82,8 +124,9 @@ var zip = exports.zip = function () {
82
124
  sPath = (0, _path2.join)(cwd, files[i]);
83
125
  } else {
84
126
  sPath = files[i];
85
- }
86
- // If buffer
127
+ } // If buffer
128
+
129
+
87
130
  if (files[i].contents) {
88
131
  name = (0, _path2.relative)(files[i].cwd, files[i].path);
89
132
  buffer = files[i].contents;
@@ -94,14 +137,17 @@ var zip = exports.zip = function () {
94
137
  } else {
95
138
  name = files[i];
96
139
  }
140
+
97
141
  buffer = (0, _fsExtra.readFileSync)(sPath);
98
142
  } else {
99
143
  // Else if it's a directory path
100
- _zip2.folder(sPath);
144
+ _zip3.folder(sPath);
101
145
  }
146
+
102
147
  if (name) {
103
148
  hasFiles = true;
104
- _zip2.file(name, buffer);
149
+
150
+ _zip3.file(name, buffer);
105
151
  }
106
152
 
107
153
  case 26:
@@ -115,19 +161,22 @@ var zip = exports.zip = function () {
115
161
  break;
116
162
  }
117
163
 
118
- tempFile = _temp2.default.openSync({ suffix: '.zip' });
164
+ tempFile = _temp.default.openSync({
165
+ suffix: '.zip'
166
+ });
119
167
  _context.t0 = _fsExtra.outputFileSync;
120
168
  _context.t1 = tempFile.path;
121
169
  _context.next = 35;
122
- return _zip2.generateAsync({ type: 'nodebuffer' });
170
+ return _zip3.generateAsync({
171
+ type: 'nodebuffer'
172
+ });
123
173
 
124
174
  case 35:
125
175
  _context.t2 = _context.sent;
126
176
  (0, _context.t0)(_context.t1, _context.t2);
127
-
128
177
  files[0] = tempFile.path;
129
178
  files.length = 1;
130
- deferred.resolve(_zip2);
179
+ deferred.resolve(_zip3);
131
180
  _context.next = 43;
132
181
  break;
133
182
 
@@ -135,65 +184,107 @@ var zip = exports.zip = function () {
135
184
  throw new Error('No source files found. If you intend to send a whole directory sufix your path with "**" (e.g. ./my-directory/**)');
136
185
 
137
186
  case 43:
138
- return _context.abrupt('return', deferred.promise);
187
+ return _context.abrupt("return", deferred.promise);
139
188
 
140
189
  case 44:
141
- case 'end':
190
+ case "end":
142
191
  return _context.stop();
143
192
  }
144
193
  }
145
- }, _callee, this);
194
+ }, _callee);
146
195
  }));
196
+ return _zip.apply(this, arguments);
197
+ }
198
+
199
+ function zipSources(sources) {
200
+ var zipFile = new _jszip.default();
201
+ var fileNames = sources.map(function (source) {
202
+ zipFile.file(source.filename, source.content);
203
+ return source.filename;
204
+ });
205
+
206
+ if (debug) {
207
+ console.log('Zipping files', (0, _util.inspect)(fileNames));
208
+ }
209
+
210
+ return Promise.resolve(zipFile);
211
+ }
212
+
213
+ function isWinAbsolutePath(path) {
214
+ return (0, _path2.isAbsolute)(path) && /^([a-z]:)(.*)/i.test(path);
215
+ }
216
+
217
+ function parseWinAbsolutePath(_path) {
218
+ var _path$match = _path.match(/^([a-z]:)(.*)/i),
219
+ _path$match2 = _slicedToArray(_path$match, 3),
220
+ full = _path$match2[0],
221
+ drv = _path$match2[1],
222
+ path = _path$match2[2];
147
223
 
148
- return function zip(_x, _x2) {
149
- return _ref.apply(this, arguments);
224
+ return {
225
+ drv: drv,
226
+ path: path
150
227
  };
151
- }();
228
+ }
152
229
 
153
- var unzip = exports.unzip = function () {
154
- var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(zipFile, dest) {
155
- var stream = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
230
+ function unzip(_x3, _x4) {
231
+ return _unzip.apply(this, arguments);
232
+ }
156
233
 
157
- var zip, _size, results, file, buffer, destPath, lastDestChar, _file;
234
+ function _unzip() {
235
+ _unzip = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(zipFile, dest) {
236
+ var stream,
237
+ zip,
238
+ _size,
239
+ results,
240
+ file,
241
+ buffer,
242
+ destPath,
243
+ lastDestChar,
244
+ _file,
245
+ _args2 = arguments;
158
246
 
159
247
  return regeneratorRuntime.wrap(function _callee2$(_context2) {
160
248
  while (1) {
161
249
  switch (_context2.prev = _context2.next) {
162
250
  case 0:
163
- zip = new _jszip2.default();
164
- _context2.next = 3;
251
+ stream = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : true;
252
+ zip = new _jszip.default();
253
+ _context2.next = 4;
165
254
  return zip.loadAsync(zipFile);
166
255
 
167
- case 3:
168
- _size = (0, _lodash2.default)(zip.files);
256
+ case 4:
257
+ _size = (0, _lodash.default)(zip.files);
169
258
  results = [];
170
259
  _context2.t0 = regeneratorRuntime.keys(zip.files);
171
260
 
172
- case 6:
261
+ case 7:
173
262
  if ((_context2.t1 = _context2.t0()).done) {
174
- _context2.next = 15;
263
+ _context2.next = 16;
175
264
  break;
176
265
  }
177
266
 
178
267
  file = _context2.t1.value;
179
268
 
180
269
  if (zip.files[file].dir) {
181
- _context2.next = 13;
270
+ _context2.next = 14;
182
271
  break;
183
272
  }
184
273
 
185
- _context2.next = 11;
274
+ _context2.next = 12;
186
275
  return zip.file(file).async('nodebuffer');
187
276
 
188
- case 11:
277
+ case 12:
189
278
  buffer = _context2.sent;
190
279
 
191
-
192
280
  if (typeof dest === 'function') {
193
281
  if (stream) {
194
282
  dest(buffer, file);
195
283
  } else {
196
- results.push({ filename: file, content: buffer.toString() });
284
+ results.push({
285
+ filename: file,
286
+ content: buffer.toString()
287
+ });
197
288
  }
198
289
  } else if (dest && typeof dest === 'string') {
199
290
  lastDestChar = dest[dest.length - 1];
@@ -201,96 +292,33 @@ var unzip = exports.unzip = function () {
201
292
  if (_size === 1 && lastDestChar !== '/' && lastDestChar !== '\\') {
202
293
  destPath = dest;
203
294
  } else {
204
- _file = file;
205
- // Deal with win path join c:\dest\:c\src
295
+ _file = file; // Deal with win path join c:\dest\:c\src
206
296
 
207
297
  if (isWinAbsolutePath(_file)) {
208
298
  _file = parseWinAbsolutePath(_file).path;
209
299
  }
300
+
210
301
  destPath = (0, _path2.join)(dest, _file);
211
302
  }
303
+
212
304
  (0, _fsExtra.outputFileSync)(destPath, buffer);
213
305
  }
214
306
 
215
- case 13:
216
- _context2.next = 6;
307
+ case 14:
308
+ _context2.next = 7;
217
309
  break;
218
310
 
219
- case 15:
220
-
311
+ case 16:
221
312
  if (!stream) {
222
313
  dest(results);
223
314
  }
224
315
 
225
- case 16:
226
- case 'end':
316
+ case 17:
317
+ case "end":
227
318
  return _context2.stop();
228
319
  }
229
320
  }
230
- }, _callee2, this);
321
+ }, _callee2);
231
322
  }));
232
-
233
- return function unzip(_x4, _x5) {
234
- return _ref2.apply(this, arguments);
235
- };
236
- }();
237
-
238
- exports.zipSources = zipSources;
239
-
240
- var _lodash = require('lodash.size');
241
-
242
- var _lodash2 = _interopRequireDefault(_lodash);
243
-
244
- var _temp = require('temp');
245
-
246
- var _temp2 = _interopRequireDefault(_temp);
247
-
248
- var _jszip = require('jszip');
249
-
250
- var _jszip2 = _interopRequireDefault(_jszip);
251
-
252
- var _fsExtra = require('fs-extra');
253
-
254
- var _path2 = require('path');
255
-
256
- var _q = require('q');
257
-
258
- var _util = require('util');
259
-
260
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
261
-
262
- function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } // TODO Replace `sync` functions with async versions
263
-
264
- var debug = !!process.env.DEBUG;
265
-
266
- // ./zip.js module is excluded from browser-like environments. We take advantage of that here.
267
- exports.outputFileSync = _fsExtra.outputFileSync;
268
- function zipSources(sources) {
269
- var zipFile = new _jszip2.default();
270
- var fileNames = sources.map(function (source) {
271
- zipFile.file(source.filename, source.content);
272
- return source.filename;
273
- });
274
-
275
- if (debug) {
276
- console.log('Zipping files', (0, _util.inspect)(fileNames));
277
- }
278
- return Promise.resolve(zipFile);
279
- }
280
-
281
- function isWinAbsolutePath(path) {
282
- return (0, _path2.isAbsolute)(path) && /^([a-z]:)(.*)/i.test(path);
283
- }
284
-
285
- function parseWinAbsolutePath(_path) {
286
- var _path$match = _path.match(/^([a-z]:)(.*)/i),
287
- _path$match2 = _slicedToArray(_path$match, 3),
288
- full = _path$match2[0],
289
- drv = _path$match2[1],
290
- path = _path$match2[2];
291
-
292
- return {
293
- drv: drv,
294
- path: path
295
- };
323
+ return _unzip.apply(this, arguments);
296
324
  }