@zimbra/zimlet-cli 12.13.0 → 14.2.0

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.
Files changed (45) hide show
  1. package/.browserslistrc +1 -0
  2. package/dist/cli.js +11 -17
  3. package/dist/commands/create.js +206 -324
  4. package/dist/commands/package.js +144 -93
  5. package/dist/entry.js +14 -12
  6. package/dist/index.js +89 -114
  7. package/dist/lib/async-command.js +8 -14
  8. package/dist/lib/setup.js +55 -133
  9. package/dist/lib/webpack/transform-config.js +8 -8
  10. package/dist/shims/@apollo/client/index.js +92 -82
  11. package/dist/shims/@apollo/client/react/components/index.js +6 -6
  12. package/dist/shims/@apollo/client/react/hoc/index.js +8 -8
  13. package/dist/shims/@apollo/client/react/index.js +16 -16
  14. package/dist/shims/@zimbra-client/blocks/index.js +28 -28
  15. package/dist/shims/@zimbra-client/browser/index.js +4 -4
  16. package/dist/shims/@zimbra-client/components/index.js +53 -51
  17. package/dist/shims/@zimbra-client/constants/index.js +7 -7
  18. package/dist/shims/@zimbra-client/enhancers/index.js +10 -10
  19. package/dist/shims/@zimbra-client/errors/index.js +5 -5
  20. package/dist/shims/@zimbra-client/graphql/index.js +29 -29
  21. package/dist/shims/@zimbra-client/hooks/graphql/index.js +8 -8
  22. package/dist/shims/@zimbra-client/hooks/index.js +8 -8
  23. package/dist/shims/@zimbra-client/platform/index.js +5 -5
  24. package/dist/shims/@zimbra-client/util/contacts/index.js +4 -4
  25. package/dist/shims/@zimbra-client/util/index.js +15 -13
  26. package/dist/shims/@zimbra-client/util/redux/index.js +8 -8
  27. package/dist/shims/clipboard-polyfill/index.js +4 -4
  28. package/dist/shims/index.js +2 -2
  29. package/dist/shims/moment/index.js +43 -43
  30. package/dist/shims/preact/compat/index.js +40 -52
  31. package/dist/shims/preact/hooks/index.js +14 -14
  32. package/dist/shims/preact/index.js +15 -15
  33. package/dist/shims/preact-context-provider/index.js +6 -6
  34. package/dist/shims/preact-i18n/index.js +12 -12
  35. package/dist/shims/preact-pwa-install/index.js +3 -3
  36. package/dist/shims/preact-render-to-string/index.js +5 -5
  37. package/dist/shims/preact-router/index.js +9 -9
  38. package/dist/shims/preact-router/match/index.js +4 -4
  39. package/dist/shims/react-redux/index.js +16 -16
  40. package/dist/shims/recompose/index.js +46 -46
  41. package/dist/shims/redux-actions/index.js +9 -9
  42. package/dist/util.js +11 -11
  43. package/dist/zimlet-style-loader.js +8 -4
  44. package/package-lock.json +6400 -6926
  45. package/package.json +41 -44
package/dist/index.js CHANGED
@@ -1,13 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
3
 
4
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
5
-
6
4
  Object.defineProperty(exports, "__esModule", {
7
5
  value: true
8
6
  });
9
- exports["default"] = run;
10
7
  exports.configure = configure;
8
+ exports.default = run;
11
9
 
12
10
  var _fs = _interopRequireDefault(require("fs"));
13
11
 
@@ -37,90 +35,69 @@ var _shims = require("./shims");
37
35
 
38
36
  var _copyWebpackPlugin = _interopRequireDefault(require("copy-webpack-plugin"));
39
37
 
40
- function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
41
-
42
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
43
-
44
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
45
-
46
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
47
-
48
- 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."); }
49
-
50
- 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); }
51
-
52
- 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; }
53
-
54
- function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; 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"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
55
-
56
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
38
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
57
39
 
58
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
40
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
59
41
 
60
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
61
-
62
- 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; }
42
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
63
43
 
64
44
  function run(args, callback) {
65
- var config = configure(args);
66
- var compiler = (0, _webpack["default"])(config);
67
- var preferredPort = config.devServer && +config.devServer.port;
68
- compiler.hooks.failed.tap('zimlet-cli', function (err) {
45
+ let config = configure(args);
46
+ let compiler = (0, _webpack.default)(config);
47
+ const preferredPort = config.devServer && +config.devServer.port;
48
+ compiler.hooks.failed.tap('zimlet-cli', err => {
69
49
  console.error(err.stack || err);
70
50
  if (err.details) console.error(err.details);
71
51
  });
72
- compiler.hooks.done.tap('zimlet-cli', function (stats) {
73
- var info = stats.toJson();
52
+ compiler.hooks.done.tap('zimlet-cli', stats => {
53
+ let info = stats.toJson();
74
54
 
75
55
  if (stats.hasErrors()) {
76
- process.stdout.write(_chalk["default"].red('Build failed!\n\n'));
77
- info.errors.forEach(function (err) {
78
- return console.error(err);
79
- });
56
+ process.stdout.write(_chalk.default.red('Build failed!\n\n'));
57
+ info.errors.forEach(err => console.error(err));
80
58
  } else {
81
59
  if (stats.hasWarnings()) {
82
- info.warnings.forEach(function (err) {
83
- return console.warn(err);
84
- });
60
+ info.warnings.forEach(err => console.warn(err));
85
61
  }
86
62
 
87
- process.stdout.write(_chalk["default"].green('Compiled successfully!\n\n'));
63
+ process.stdout.write(_chalk.default.green('Compiled successfully!\n\n'));
88
64
 
89
65
  if (config.devServer) {
90
- var _config$devServer = config.devServer,
91
- https = _config$devServer.https,
92
- host = _config$devServer.host,
93
- port = _config$devServer.port;
94
- var protocol = https ? 'https' : 'http';
66
+ let {
67
+ https,
68
+ host,
69
+ port
70
+ } = config.devServer;
71
+ let protocol = https ? 'https' : 'http';
95
72
  if (host === '0.0.0.0') host = 'localhost';
96
- var serverAddr = "".concat(protocol, "://").concat(host, ":").concat(_chalk["default"].bold(port), "/index.js");
97
- var localIpAddr = "".concat(protocol, "://").concat(_ip["default"].address(), ":").concat(_chalk["default"].bold(port), "/index.js");
73
+ let serverAddr = `${protocol}://${host}:${_chalk.default.bold(port)}/index.js`;
74
+ let localIpAddr = `${protocol}://${_ip.default.address()}:${_chalk.default.bold(port)}/index.js`;
98
75
 
99
76
  if (preferredPort !== config.devServer.port) {
100
- process.stdout.write("NOTE: Port ".concat(preferredPort, " is not available, using ").concat(port, " instead.\n\n"));
77
+ process.stdout.write(`NOTE: Port ${preferredPort} is not available, using ${port} instead.\n\n`);
101
78
  }
102
79
 
103
80
  process.stdout.write('You can view the application in browser.\n\n');
104
- process.stdout.write("".concat(_chalk["default"].bold('Local:'), " ").concat(serverAddr, "\n"));
105
- process.stdout.write("".concat(_chalk["default"].bold('On Your Network:'), " ").concat(localIpAddr, "\n"));
81
+ process.stdout.write(`${_chalk.default.bold('Local:')} ${serverAddr}\n`);
82
+ process.stdout.write(`${_chalk.default.bold('On Your Network:')} ${localIpAddr}\n`);
106
83
  }
107
84
  }
108
85
  });
109
86
 
110
87
  if (config.devServer) {
111
- (0, _getPort["default"])({
88
+ (0, _getPort.default)({
112
89
  port: (0, _getPort.makeRange)(preferredPort, preferredPort + 100)
113
- }).then(function (port) {
90
+ }).then(port => {
114
91
  if (config.devServer.port !== port) {
115
92
  config.devServer.port = port;
116
93
  }
117
94
 
118
- new _webpackDevServer["default"](compiler, config.devServer).listen(config.devServer.port);
95
+ new _webpackDevServer.default(compiler, config.devServer).listen(config.devServer.port);
119
96
  });
120
97
  } else {
121
- compiler.run(function (err, stats) {
98
+ compiler.run((err, stats) => {
122
99
  if (!err && stats.hasErrors()) {
123
- err = "".concat(stats.toJson().errors.length, " errors");
100
+ err = `${stats.toJson().errors.length} errors`;
124
101
  }
125
102
 
126
103
  callback(err, null);
@@ -130,17 +107,17 @@ function run(args, callback) {
130
107
 
131
108
  function configure(env) {
132
109
  env = env || {};
133
- var watch = env.watch || env.w || process.env.NODE_ENV === 'dev' || process.env.NODE_ENV === 'development';
134
- var PROD = !watch;
135
- var https = !(process.env.HTTPS === 'false' || env.https === false),
110
+ const watch = env.watch || env.w || process.env.NODE_ENV === 'dev' || process.env.NODE_ENV === 'development';
111
+ const PROD = !watch;
112
+ let https = !(process.env.HTTPS === 'false' || env.https === false),
136
113
  host = process.env.HOST || env.host || 'localhost',
137
114
  port = process.env.PORT || env.port || 8081;
138
- var cwd = env.cwd = process.cwd(),
115
+ let cwd = env.cwd = process.cwd(),
139
116
  context = cwd,
140
117
  pkg;
141
118
 
142
119
  try {
143
- pkg = require(_path["default"].resolve(cwd, 'package.json'));
120
+ pkg = require(_path.default.resolve(cwd, 'package.json'));
144
121
  } catch (e) {}
145
122
 
146
123
  if (!pkg) {
@@ -150,26 +127,25 @@ function configure(env) {
150
127
  } // entry point (initial file to load)
151
128
 
152
129
 
153
- var entry = _path["default"].resolve(cwd, pkg.module || pkg['jsnext:main'] || pkg.main);
130
+ let entry = _path.default.resolve(cwd, pkg.module || pkg['jsnext:main'] || pkg.main);
154
131
 
155
- if (isDir(entry)) entry = _path["default"].resolve(entry, 'index.js'); // attempt to use ./src dir if present:
132
+ if (isDir(entry)) entry = _path.default.resolve(entry, 'index.js'); // attempt to use ./src dir if present:
156
133
 
157
- if (isDir(_path["default"].resolve(cwd, 'src'))) context = _path["default"].resolve(context, 'src'); // normalize desination dir
134
+ if (isDir(_path.default.resolve(cwd, 'src'))) context = _path.default.resolve(context, 'src'); // normalize desination dir
158
135
 
159
- var dest = _path["default"].resolve(cwd, env.dest || 'build'); // use absolute paths
136
+ let dest = _path.default.resolve(cwd, env.dest || 'build'); // use absolute paths
160
137
 
161
138
 
162
- context = _path["default"].resolve(context);
163
- var componentDirs = [_path["default"].resolve(context, 'components'), _path["default"].resolve(context, 'screens'), _path["default"].resolve(context, 'pages')];
164
- var cssLoaderOptions = {
139
+ context = _path.default.resolve(context);
140
+ let componentDirs = [_path.default.resolve(context, 'components'), _path.default.resolve(context, 'screens'), _path.default.resolve(context, 'pages')];
141
+ let cssLoaderOptions = {
165
142
  sourceMap: watch && !PROD
166
143
  };
167
- var postCssLoaderOptions = {
144
+ let postCssLoaderOptions = {
168
145
  sourceMap: true,
169
146
  postcssOptions: {
170
147
  config: false,
171
- plugins: [(0, _postcssPresetEnv["default"])({
172
- browsers: ['last 2 versions', 'not ie > 0', 'iOS >= 8'],
148
+ plugins: [(0, _postcssPresetEnv.default)({
173
149
  stage: 3,
174
150
  autoprefixer: true,
175
151
  features: {
@@ -177,50 +153,46 @@ function configure(env) {
177
153
  // disable customProperties plugin so css variables and :root blocks are preserved
178
154
  'custom-properties': false
179
155
  }
180
- }), (0, _postcssDiscardComments["default"])({
156
+ }), (0, _postcssDiscardComments.default)({
181
157
  removeAll: true
182
158
  })]
183
159
  }
184
160
  };
185
- var cssModulesRegexp = (0, _util.crossPlatformPathRegex)(/(?:([^/@]+?)(?:-(?:pages?|components?|screens?))?\/)?src\/(?:pages|components|screens)\/(.+?)(\/[a-z0-9._-]+[.](less|css))?$/);
186
- var webpackConfig = {
161
+ let cssModulesRegexp = (0, _util.crossPlatformPathRegex)(/(?:([^/@]+?)(?:-(?:pages?|components?|screens?))?\/)?src\/(?:pages|components|screens)\/(.+?)(\/[a-z0-9._-]+[.](less|css))?$/);
162
+ let webpackConfig = {
187
163
  mode: PROD ? 'production' : 'development',
188
- context: context,
189
- entry: _path["default"].resolve(__dirname, 'entry.js'),
164
+ context,
165
+ entry: _path.default.resolve(__dirname, 'entry.js'),
190
166
  output: {
191
167
  path: dest,
192
- filename: "index.js",
168
+ filename: `index.js`,
193
169
  chunkFilename: '[name].[chunkhash:8].chunk.js',
194
170
  // NOTE: Explicit public path is required in order to make HMR work within an sourceless iframe.
195
171
  // This is due to a bug in webpack-dev-server that uses the document protocol for all https pages:
196
172
  // https://github.com/webpack/webpack-dev-server/blob/c490b245ad65f315762e03e51710f7f7177b1e7b/client/index.js#L188-L190
197
- publicPath: watch ? "http".concat(https ? 's' : '', "://").concat(host, ":").concat(port, "/") : env.publicpath || '/'
173
+ publicPath: watch ? `http${https ? 's' : ''}://${host}:${port}/` : env.publicpath || '/'
198
174
  },
199
175
  resolve: {
200
176
  extensions: ['.mjs', '.jsx', '.js', '.json', '.css', '.less'],
201
177
  mainFields: ['browser', 'module', 'jsnext:main', 'main'],
202
- modules: [_path["default"].resolve(cwd, 'node_modules'), 'node_modules'],
203
- alias: _objectSpread(_objectSpread({}, _shims.SHIMMED_MODULES.reduce(function (shimAliases, name) {
204
- if (Array.isArray(name)) {
205
- // If module name is an Array, the first element is the root name of the module
206
- var _name = name;
207
-
208
- var _name2 = _slicedToArray(_name, 1);
209
-
210
- name = _name2[0];
211
- }
212
-
213
- shimAliases[name] = (0, _shims.getShimPath)(name);
214
- return shimAliases;
215
- }, {})), {}, {
178
+ modules: [_path.default.resolve(cwd, 'node_modules'), 'node_modules'],
179
+ alias: { ..._shims.SHIMMED_MODULES.reduce((shimAliases, name) => {
180
+ if (Array.isArray(name)) {
181
+ // If module name is an Array, the first element is the root name of the module
182
+ [name] = name;
183
+ }
184
+
185
+ shimAliases[name] = (0, _shims.getShimPath)(name);
186
+ return shimAliases;
187
+ }, {}),
216
188
  react: (0, _shims.getShimPath)('preact/compat'),
217
189
  'react-dom': (0, _shims.getShimPath)('preact/compat'),
218
- style: _path["default"].resolve(context, 'style'),
219
- 'zimlet-cli-entrypoint': _path["default"].resolve(context, entry)
220
- })
190
+ style: _path.default.resolve(context, 'style'),
191
+ 'zimlet-cli-entrypoint': _path.default.resolve(context, entry)
192
+ }
221
193
  },
222
194
  resolveLoader: {
223
- modules: [_path["default"].resolve(__dirname, 'loaders'), _path["default"].resolve(__dirname, '..', 'node_modules'), _path["default"].resolve(cwd, 'node_modules')]
195
+ modules: [_path.default.resolve(__dirname, 'loaders'), _path.default.resolve(__dirname, '..', 'node_modules'), _path.default.resolve(cwd, 'node_modules')]
224
196
  },
225
197
  module: {
226
198
  rules: [{
@@ -231,7 +203,8 @@ function configure(env) {
231
203
  comments: true,
232
204
  presets: [[require.resolve('@babel/preset-env'), {
233
205
  loose: true,
234
- modules: false
206
+ modules: false,
207
+ bugfixes: true
235
208
  }]],
236
209
  plugins: [require.resolve('@babel/plugin-syntax-dynamic-import'), [require.resolve('@babel/plugin-proposal-decorators'), {
237
210
  legacy: true
@@ -246,16 +219,16 @@ function configure(env) {
246
219
  // include: /(^|\/)src\/(?:components|screens)\//,
247
220
  include: componentDirs,
248
221
  use: [{
249
- loader: _path["default"].resolve(__dirname, 'zimlet-style-loader.js')
222
+ loader: _path.default.resolve(__dirname, 'zimlet-style-loader.js')
250
223
  }, {
251
224
  loader: 'css-loader',
252
- options: _objectSpread(_objectSpread({}, cssLoaderOptions), {}, {
225
+ options: { ...cssLoaderOptions,
253
226
  modules: {
254
227
  localIdentRegExp: cssModulesRegexp,
255
228
  localIdentName: '[1]_[2]_[local]'
256
229
  },
257
230
  importLoaders: 1
258
- })
231
+ }
259
232
  }, {
260
233
  loader: 'postcss-loader',
261
234
  options: postCssLoaderOptions
@@ -267,7 +240,7 @@ function configure(env) {
267
240
  // exclude: /(^|\/)src\/(?:components|screens)\//,
268
241
  exclude: componentDirs,
269
242
  use: [{
270
- loader: _path["default"].resolve(__dirname, 'zimlet-style-loader.js')
243
+ loader: _path.default.resolve(__dirname, 'zimlet-style-loader.js')
271
244
  }, {
272
245
  loader: 'css-loader',
273
246
  options: cssLoaderOptions
@@ -292,23 +265,23 @@ function configure(env) {
292
265
  __dirname: false,
293
266
  setImmediate: false
294
267
  } : {},
295
- plugins: [].concat(PROD ? [new _webpack["default"].HashedModuleIdsPlugin()] : [new _webpack["default"].HotModuleReplacementPlugin()], new _webpack["default"].LoaderOptionsPlugin({
268
+ plugins: [].concat(PROD ? [new _webpack.default.HashedModuleIdsPlugin()] : [new _webpack.default.HotModuleReplacementPlugin()], new _webpack.default.LoaderOptionsPlugin({
296
269
  minimize: PROD,
297
270
  debug: !PROD
298
- }), new _progressBarWebpackPlugin["default"]({
299
- format: "\x1B[90m\x1B[44mBuild\x1B[49m\x1B[39m [:bar] \x1B[32m\x1B[1m:percent\x1B[22m\x1B[39m (:elapseds) \x1B[2m:msg\x1B[22m",
271
+ }), new _progressBarWebpackPlugin.default({
272
+ format: '\u001b[90m\u001b[44mBuild\u001b[49m\u001b[39m [:bar] \u001b[32m\u001b[1m:percent\u001b[22m\u001b[39m (:elapseds) \u001b[2m:msg\u001b[22m',
300
273
  renderThrottle: 100,
301
274
  summary: false
302
- }), new _webpack["default"].DefinePlugin({
275
+ }), new _webpack.default.DefinePlugin({
303
276
  'process.env.NODE_ENV': JSON.stringify(PROD ? 'production' : 'development')
304
- }), isFile(_path["default"].resolve(cwd, 'config_template.xml')) && new _copyWebpackPlugin["default"]({
277
+ }), isFile(_path.default.resolve(cwd, 'config_template.xml')) && new _copyWebpackPlugin.default({
305
278
  patterns: [{
306
- from: _path["default"].join(cwd, 'config_template.xml'),
307
- to: _path["default"].join(dest, 'config_template.xml')
279
+ from: _path.default.join(cwd, 'config_template.xml'),
280
+ to: _path.default.join(dest, 'config_template.xml')
308
281
  }]
309
282
  })).filter(Boolean),
310
283
  watchOptions: {
311
- ignored: ['build', dest, _path["default"].resolve(cwd, 'node_modules')]
284
+ ignored: ['build', dest, _path.default.resolve(cwd, 'node_modules')]
312
285
  },
313
286
  stats: 'errors-only',
314
287
  devtool: watch ? 'cheap-module-eval-source-map' : 'source-map'
@@ -316,21 +289,23 @@ function configure(env) {
316
289
 
317
290
  if (watch) {
318
291
  webpackConfig.devServer = {
319
- host: host,
320
- port: port,
292
+ host,
293
+ port,
321
294
  hot: !process.env.DISABLE_HOT,
322
- https: https,
295
+ https,
323
296
  compress: true,
324
297
  publicPath: '/',
325
298
  contentBase: context,
326
299
  disableHostCheck: true,
327
- before: function before(app) {
300
+
301
+ before(app) {
328
302
  app.use(require('cors')({
329
303
  maxAge: 3600
330
304
  }));
331
305
  },
306
+
332
307
  watchOptions: {
333
- ignored: ['build', dest, _path["default"].resolve(cwd, 'node_modules')]
308
+ ignored: ['build', dest, _path.default.resolve(cwd, 'node_modules')]
334
309
  },
335
310
  overlay: false,
336
311
  noInfo: true,
@@ -339,18 +314,18 @@ function configure(env) {
339
314
  };
340
315
  }
341
316
 
342
- (0, _transformConfig["default"])(env, webpackConfig);
317
+ (0, _transformConfig.default)(env, webpackConfig);
343
318
  return webpackConfig;
344
319
  }
345
320
 
346
321
  function isDir(filepath) {
347
322
  try {
348
- return !!_fs["default"].statSync(filepath).isDirectory();
323
+ return !!_fs.default.statSync(filepath).isDirectory();
349
324
  } catch (err) {}
350
325
  }
351
326
 
352
327
  function isFile(filepath) {
353
328
  try {
354
- return !!_fs["default"].statSync(filepath).isFile();
329
+ return !!_fs.default.statSync(filepath).isFile();
355
330
  } catch (err) {}
356
331
  }
@@ -3,13 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports["default"] = asyncCommand;
7
-
8
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
9
-
10
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
11
-
12
- 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; }
6
+ exports.default = asyncCommand;
13
7
 
14
8
  function done(err, result) {
15
9
  if (err) {
@@ -22,14 +16,14 @@ function done(err, result) {
22
16
  }
23
17
 
24
18
  function asyncCommand(options) {
25
- return _objectSpread(_objectSpread({}, options), {}, {
26
- handler: function handler(argv) {
27
- var r = options.handler(argv, done);
28
- if (r && r.then) r.then(function (result) {
29
- return done(null, result);
30
- }, done);
19
+ return { ...options,
20
+
21
+ handler(argv) {
22
+ let r = options.handler(argv, done);
23
+ if (r && r.then) r.then(result => done(null, result), done);
31
24
  }
32
- });
25
+
26
+ };
33
27
  }
34
28
 
35
29
  module.exports = exports.default;
package/dist/lib/setup.js CHANGED
@@ -3,155 +3,77 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.install = install;
7
6
  exports.addScripts = addScripts;
8
7
  exports.initGit = initGit;
8
+ exports.install = install;
9
9
 
10
10
  var _crossSpawnPromise = _interopRequireDefault(require("cross-spawn-promise"));
11
11
 
12
12
  var _util = require("../util");
13
13
 
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
15
-
16
- 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); } }
17
-
18
- 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); }); }; }
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
15
 
20
16
  function install(cwd, isYarn) {
21
- var cmd = isYarn ? 'yarn' : 'npm';
22
- return (0, _crossSpawnPromise["default"])(cmd, ['install'], {
23
- cwd: cwd,
17
+ let cmd = isYarn ? 'yarn' : 'npm';
18
+ return (0, _crossSpawnPromise.default)(cmd, ['install'], {
19
+ cwd,
24
20
  stdio: 'ignore'
25
21
  });
26
22
  }
27
23
 
28
- function addScripts(_x, _x2, _x3) {
29
- return _addScripts.apply(this, arguments);
24
+ async function addScripts(obj, cwd, isYarn) {
25
+ return {
26
+ build: 'zimlet build',
27
+ watch: 'zimlet watch',
28
+ package: 'zimlet package'
29
+ };
30
30
  } // Initializes the folder using `git init` and a proper `.gitignore` file
31
31
  // if `git` is present in the $PATH.
32
32
 
33
33
 
34
- function _addScripts() {
35
- _addScripts = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(obj, cwd, isYarn) {
36
- return regeneratorRuntime.wrap(function _callee$(_context) {
37
- while (1) {
38
- switch (_context.prev = _context.next) {
39
- case 0:
40
- return _context.abrupt("return", {
41
- build: 'zimlet build',
42
- watch: 'zimlet watch',
43
- "package": 'zimlet package'
44
- });
45
-
46
- case 1:
47
- case "end":
48
- return _context.stop();
49
- }
50
- }
51
- }, _callee);
52
- }));
53
- return _addScripts.apply(this, arguments);
54
- }
55
-
56
- function initGit(_x4) {
57
- return _initGit.apply(this, arguments);
58
- }
59
-
60
- function _initGit() {
61
- _initGit = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(target) {
62
- var git, cwd, gitUser, gitEmail, defaultGitUser, defaultGitEmail;
63
- return regeneratorRuntime.wrap(function _callee2$(_context2) {
64
- while (1) {
65
- switch (_context2.prev = _context2.next) {
66
- case 0:
67
- git = (0, _util.hasCommand)('git');
68
-
69
- if (!git) {
70
- _context2.next = 39;
71
- break;
72
- }
73
-
74
- cwd = target;
75
- _context2.next = 5;
76
- return (0, _crossSpawnPromise["default"])('git', ['init'], {
77
- cwd: cwd
78
- });
79
-
80
- case 5:
81
- _context2.next = 7;
82
- return (0, _crossSpawnPromise["default"])('git', ['add', '-A'], {
83
- cwd: cwd
84
- });
85
-
86
- case 7:
87
- defaultGitUser = 'Zimlet CLI';
88
- defaultGitEmail = 'zimlet-cli@users.noreply.github.com';
89
- _context2.prev = 9;
90
- _context2.next = 12;
91
- return (0, _crossSpawnPromise["default"])('git', ['config', 'user.name']);
92
-
93
- case 12:
94
- gitUser = _context2.sent.toString();
95
- _context2.next = 19;
96
- break;
97
-
98
- case 15:
99
- _context2.prev = 15;
100
- _context2.t0 = _context2["catch"](9);
101
- (0, _util.warn)("Git config value of user.name not defined. Defaulting to ".concat(defaultGitUser, " for initial commit message."));
102
- gitUser = defaultGitUser;
103
-
104
- case 19:
105
- _context2.prev = 19;
106
- _context2.next = 22;
107
- return (0, _crossSpawnPromise["default"])('git', ['config', 'user.email']);
108
-
109
- case 22:
110
- gitEmail = _context2.sent.toString();
111
- _context2.next = 29;
112
- break;
113
-
114
- case 25:
115
- _context2.prev = 25;
116
- _context2.t1 = _context2["catch"](19);
117
- (0, _util.warn)("Git config value of user.email not defined. Defaulting to ".concat(defaultGitEmail, " for initial commit message."));
118
- gitEmail = defaultGitEmail;
119
-
120
- case 29:
121
- _context2.prev = 29;
122
- _context2.next = 32;
123
- return (0, _crossSpawnPromise["default"])('git', ['commit', '-m', 'initial commit from zimlet-cli'], {
124
- cwd: cwd,
125
- env: {
126
- GIT_COMMITTER_NAME: gitUser,
127
- GIT_COMMITTER_EMAIL: gitEmail,
128
- GIT_AUTHOR_NAME: gitUser,
129
- GIT_AUTHOR_EMAIL: gitEmail
130
- }
131
- });
132
-
133
- case 32:
134
- _context2.next = 37;
135
- break;
136
-
137
- case 34:
138
- _context2.prev = 34;
139
- _context2.t2 = _context2["catch"](29);
140
- (0, _util.warn)("could not make initial git commit: ".concat(_context2.t2));
141
-
142
- case 37:
143
- _context2.next = 40;
144
- break;
145
-
146
- case 39:
147
- (0, _util.warn)('Could not locate `git` binary in `$PATH`. Skipping!');
148
-
149
- case 40:
150
- case "end":
151
- return _context2.stop();
34
+ async function initGit(target) {
35
+ let git = (0, _util.hasCommand)('git');
36
+
37
+ if (git) {
38
+ const cwd = target;
39
+ await (0, _crossSpawnPromise.default)('git', ['init'], {
40
+ cwd
41
+ });
42
+ await (0, _crossSpawnPromise.default)('git', ['add', '-A'], {
43
+ cwd
44
+ });
45
+ let gitUser, gitEmail;
46
+ const defaultGitUser = 'Zimlet CLI';
47
+ const defaultGitEmail = 'zimlet-cli@users.noreply.github.com';
48
+
49
+ try {
50
+ gitUser = (await (0, _crossSpawnPromise.default)('git', ['config', 'user.name'])).toString();
51
+ } catch (e) {
52
+ (0, _util.warn)(`Git config value of user.name not defined. Defaulting to ${defaultGitUser} for initial commit message.`);
53
+ gitUser = defaultGitUser;
54
+ }
55
+
56
+ try {
57
+ gitEmail = (await (0, _crossSpawnPromise.default)('git', ['config', 'user.email'])).toString();
58
+ } catch (e) {
59
+ (0, _util.warn)(`Git config value of user.email not defined. Defaulting to ${defaultGitEmail} for initial commit message.`);
60
+ gitEmail = defaultGitEmail;
61
+ }
62
+
63
+ try {
64
+ await (0, _crossSpawnPromise.default)('git', ['commit', '-m', 'initial commit from zimlet-cli'], {
65
+ cwd,
66
+ env: {
67
+ GIT_COMMITTER_NAME: gitUser,
68
+ GIT_COMMITTER_EMAIL: gitEmail,
69
+ GIT_AUTHOR_NAME: gitUser,
70
+ GIT_AUTHOR_EMAIL: gitEmail
152
71
  }
153
- }
154
- }, _callee2, null, [[9, 15], [19, 25], [29, 34]]);
155
- }));
156
- return _initGit.apply(this, arguments);
72
+ });
73
+ } catch (e) {
74
+ (0, _util.warn)(`could not make initial git commit: ${e}`);
75
+ }
76
+ } else {
77
+ (0, _util.warn)('Could not locate `git` binary in `$PATH`. Skipping!');
78
+ }
157
79
  }