balm-core 4.10.0 → 4.12.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 (108) hide show
  1. package/lib/balm.js +0 -20
  2. package/lib/bootstrap/check_config.js +6 -9
  3. package/lib/bootstrap/index.js +16 -22
  4. package/lib/bundler/esbuild/build.js +0 -2
  5. package/lib/bundler/esbuild/index.js +0 -2
  6. package/lib/bundler/esbuild/transform.js +0 -4
  7. package/lib/bundler/rollup/build.js +2 -4
  8. package/lib/bundler/rollup/entry.js +2 -5
  9. package/lib/bundler/rollup/index.js +0 -3
  10. package/lib/bundler/rollup/output.js +0 -5
  11. package/lib/bundler/rollup/plugins.js +0 -10
  12. package/lib/bundler/webpack/config/common.js +4 -15
  13. package/lib/bundler/webpack/config/dev.js +2 -3
  14. package/lib/bundler/webpack/config/env.js +12 -14
  15. package/lib/bundler/webpack/config/index.js +0 -2
  16. package/lib/bundler/webpack/config/prod.js +4 -7
  17. package/lib/bundler/webpack/entry.js +8 -12
  18. package/lib/bundler/webpack/index.js +2 -5
  19. package/lib/bundler/webpack/loaders.js +0 -6
  20. package/lib/bundler/webpack/output.js +0 -5
  21. package/lib/bundler/webpack/rules/asset.js +2 -3
  22. package/lib/bundler/webpack/rules/babel.js +3 -4
  23. package/lib/bundler/webpack/rules/css.js +4 -10
  24. package/lib/bundler/webpack/rules/html.js +0 -2
  25. package/lib/config/assets.js +0 -5
  26. package/lib/config/env.js +0 -2
  27. package/lib/config/globals.js +2 -5
  28. package/lib/config/index.js +0 -5
  29. package/lib/config/logs.js +0 -1
  30. package/lib/config/paths.js +3 -3
  31. package/lib/config/pwa.js +0 -3
  32. package/lib/config/roots.js +0 -2
  33. package/lib/config/scripts.js +20 -28
  34. package/lib/config/server.js +4 -10
  35. package/lib/config/styles.js +2 -10
  36. package/lib/hello.js +0 -2
  37. package/lib/hooks/index.js +18 -35
  38. package/lib/hooks/maker.js +0 -14
  39. package/lib/middlewares/history.js +0 -2
  40. package/lib/middlewares/index.js +0 -4
  41. package/lib/middlewares/proxy.js +0 -6
  42. package/lib/middlewares/webpack.js +0 -5
  43. package/lib/plugins/htmlmin.js +1 -7
  44. package/lib/plugins/imagemin.js +1 -18
  45. package/lib/plugins/jsmin.js +0 -10
  46. package/lib/plugins/less.js +7 -14
  47. package/lib/plugins/plumber.js +4 -21
  48. package/lib/plugins/postcss-plugins.js +0 -2
  49. package/lib/plugins/postcss.js +8 -21
  50. package/lib/plugins/rename.js +2 -13
  51. package/lib/plugins/replace.js +4 -22
  52. package/lib/plugins/sass.js +30 -39
  53. package/lib/plugins/sftp.js +33 -62
  54. package/lib/tasks/default.js +10 -19
  55. package/lib/tasks/foundation/balm.js +0 -25
  56. package/lib/tasks/foundation/balm_style.js +2 -15
  57. package/lib/tasks/foundation/index.js +0 -2
  58. package/lib/tasks/index.js +8 -7
  59. package/lib/tasks/private/build.js +0 -5
  60. package/lib/tasks/private/cache.js +0 -6
  61. package/lib/tasks/private/clean.js +0 -20
  62. package/lib/tasks/private/end.js +0 -6
  63. package/lib/tasks/private/extra.js +4 -11
  64. package/lib/tasks/private/font.js +0 -5
  65. package/lib/tasks/private/image.js +0 -11
  66. package/lib/tasks/private/lint.js +0 -5
  67. package/lib/tasks/private/media.js +0 -5
  68. package/lib/tasks/private/modernizr.js +0 -19
  69. package/lib/tasks/private/pwa-cache.js +0 -7
  70. package/lib/tasks/private/script.js +0 -3
  71. package/lib/tasks/private/sprite.js +3 -25
  72. package/lib/tasks/private/start.js +0 -6
  73. package/lib/tasks/private/style.js +0 -3
  74. package/lib/tasks/private/workbox-sw.js +0 -5
  75. package/lib/tasks/public/copy.js +0 -5
  76. package/lib/tasks/public/esbuild.js +0 -6
  77. package/lib/tasks/public/ftp.js +0 -11
  78. package/lib/tasks/public/html.js +0 -20
  79. package/lib/tasks/public/jsmin.js +0 -6
  80. package/lib/tasks/public/less.js +0 -6
  81. package/lib/tasks/public/postcss.js +0 -5
  82. package/lib/tasks/public/publish.js +3 -15
  83. package/lib/tasks/public/pwa.js +0 -13
  84. package/lib/tasks/public/remove.js +2 -18
  85. package/lib/tasks/public/replace.js +0 -7
  86. package/lib/tasks/public/rollup.js +0 -6
  87. package/lib/tasks/public/sass.js +0 -6
  88. package/lib/tasks/public/server.js +4 -32
  89. package/lib/tasks/public/url.js +0 -13
  90. package/lib/tasks/public/version.js +0 -6
  91. package/lib/tasks/public/webpack.js +2 -12
  92. package/lib/tasks/public/zip.js +0 -5
  93. package/lib/utilities/address.js +5 -16
  94. package/lib/utilities/cache-core.js +5 -13
  95. package/lib/utilities/color.js +0 -5
  96. package/lib/utilities/compiling.js +0 -14
  97. package/lib/utilities/detect-port.js +6 -22
  98. package/lib/utilities/escape-string-regexp.js +3 -4
  99. package/lib/utilities/file.js +2 -18
  100. package/lib/utilities/loading.js +0 -23
  101. package/lib/utilities/logger.js +0 -19
  102. package/lib/utilities/merge-stream.js +0 -8
  103. package/lib/utilities/namespace.js +0 -4
  104. package/lib/utilities/public-url.js +10 -10
  105. package/lib/utilities/replacestream.js +5 -27
  106. package/lib/utilities/typeof.js +0 -2
  107. package/lib/utilities/utils.js +2 -9
  108. package/package.json +30 -30
@@ -1,4 +1,5 @@
1
1
  // Reference `gulp-sftp@0.1.5`
2
+
2
3
  import { Client } from 'ssh2';
3
4
  import parents from 'parents';
4
5
  import async from 'async';
@@ -6,19 +7,15 @@ const PLUGIN_NAME = 'sftp';
6
7
  const DefaultAlgorithms = {
7
8
  kex: ['curve25519-sha256', 'curve25519-sha256@libssh.org', 'ecdh-sha2-nistp256', 'ecdh-sha2-nistp384', 'ecdh-sha2-nistp521', 'diffie-hellman-group-exchange-sha256', 'diffie-hellman-group14-sha256', 'diffie-hellman-group15-sha512', 'diffie-hellman-group16-sha512', 'diffie-hellman-group17-sha512', 'diffie-hellman-group18-sha512', 'diffie-hellman-group-exchange-sha1', 'diffie-hellman-group14-sha1', 'diffie-hellman-group1-sha1']
8
9
  };
9
-
10
10
  const normalizePath = _path => _path.replace(/\\/g, '/');
11
-
12
11
  function resolveHomePath(key) {
13
12
  if (key.location) {
14
13
  const HOME = process.env.HOME || process.env.USERPROFILE || '';
15
-
16
14
  for (let i = 0, len = key.location.length; i < len; i++) {
17
15
  if (key.location[i].substr(0, 2) === '~/') {
18
16
  key.location[i] = node.path.resolve(HOME, key.location[i].replace(/^~\//, ''));
19
17
  }
20
18
  }
21
-
22
19
  for (let i = 0, keyPath; keyPath = key.location[i++];) {
23
20
  if (node.fs.existsSync(keyPath)) {
24
21
  key.contents = node.fs.readFileSync(keyPath);
@@ -29,67 +26,59 @@ function resolveHomePath(key) {
29
26
  const rsaKey = key.location.join(', ');
30
27
  throw new PluginError(PLUGIN_NAME, `Cannot find RSA key, searched: ${rsaKey}`);
31
28
  }
32
-
33
29
  return key;
34
30
  }
31
+
35
32
  /**
36
33
  * Lots of ways to present key info
37
34
  */
38
-
39
-
40
35
  function getKey(options) {
41
36
  let key = options.key || options.keyLocation || null;
42
-
43
37
  if (key && BalmJS.utils.isString(key)) {
44
38
  key = {
45
39
  location: key
46
40
  };
47
- } // Check for other options that imply a key or if there is no password
48
-
41
+ }
49
42
 
43
+ // Check for other options that imply a key or if there is no password
50
44
  if (!key && (options.passphrase || options.keyContents || !options.password)) {
51
45
  key = {};
52
46
  }
53
-
54
47
  if (key) {
55
48
  // Aliases
56
49
  key.contents = key.contents || options.keyContents;
57
- key.passphrase = key.passphrase || options.passphrase; // Defaults
50
+ key.passphrase = key.passphrase || options.passphrase;
58
51
 
59
- key.location = key.location || ['~/.ssh/id_rsa', '/.ssh/id_rsa', '~/.ssh/id_dsa', '/.ssh/id_dsa']; // Type normalization
52
+ // Defaults
53
+ key.location = key.location || ['~/.ssh/id_rsa', '/.ssh/id_rsa', '~/.ssh/id_dsa', '/.ssh/id_dsa'];
60
54
 
55
+ // Type normalization
61
56
  if (!BalmJS.utils.isArray(key.location)) {
62
57
  key.location = [key.location];
63
- } // Resolve all home paths
64
-
58
+ }
65
59
 
60
+ // Resolve all home paths
66
61
  key = resolveHomePath(key);
67
62
  }
68
-
69
63
  return key;
70
64
  }
71
-
72
65
  function gulpSftp(options) {
73
66
  options = Object.assign({}, options); // Credit sindresorhus
74
67
 
75
68
  if (options.host === undefined) {
76
69
  throw new PluginError(PLUGIN_NAME, '`host` required');
77
70
  }
78
-
79
71
  let fileCount = 0;
80
72
  const remotePath = options.remotePath || '/';
81
73
  const remotePlatform = options.remotePlatform || options.platform || 'unix';
82
74
  options.authKey = options.authKey || options.auth;
83
75
  const authFilePath = options.authFile || '.ftppass';
84
76
  const authFile = node.path.join('./', authFilePath);
85
-
86
77
  if (options.authKey && node.fs.existsSync(authFile)) {
87
78
  let auth = JSON.parse(node.fs.readFileSync(authFile, 'utf8'))[options.authKey];
88
-
89
79
  if (!auth) {
90
80
  throw new PluginError(PLUGIN_NAME, 'Could not find authkey in .ftppass');
91
81
  }
92
-
93
82
  if (BalmJS.utils.isString(auth) && auth.indexOf(':') !== -1) {
94
83
  const authparts = auth.split(':');
95
84
  auth = {
@@ -97,26 +86,24 @@ function gulpSftp(options) {
97
86
  pass: authparts[1]
98
87
  };
99
88
  }
100
-
101
89
  const authKeys = Object.keys(auth);
102
-
103
90
  for (let i = 0, len = authKeys.length; i < len; i++) {
104
91
  const attr = authKeys[i];
105
-
106
92
  if (auth[attr]) {
107
93
  options[attr] = auth[attr];
108
94
  }
109
95
  }
110
- } // Option aliases
111
-
96
+ }
112
97
 
98
+ // Option aliases
113
99
  const password = options.password;
114
100
  const username = options.username || 'anonymous';
101
+
115
102
  /*
116
103
  * Key info
117
104
  */
118
-
119
105
  const key = getKey(options);
106
+
120
107
  /*
121
108
  * End Key normalization, key should now be of form:
122
109
  * {location:Array,passphrase:String,contents:String}
@@ -126,7 +113,6 @@ function gulpSftp(options) {
126
113
  const mkDirCache = {};
127
114
  let finished = false;
128
115
  let sftpCache = null; // SFTP connection cache
129
-
130
116
  let connCache = null; // SSH connection cache
131
117
 
132
118
  function _pool(uploader) {
@@ -134,24 +120,21 @@ function gulpSftp(options) {
134
120
  if (sftpCache) {
135
121
  return uploader(sftpCache);
136
122
  }
137
-
138
123
  if (password) {
139
124
  BalmJS.logger.debug(PLUGIN_NAME, 'Authenticating with password');
140
125
  } else if (key) {
141
126
  BalmJS.logger.debug(PLUGIN_NAME, 'Authenticating with private key');
142
127
  }
128
+
143
129
  /*
144
130
  * Connection options, may be a key
145
131
  */
146
-
147
-
148
132
  const connectionOptions = {
149
133
  host: options.host,
150
134
  port: options.port || 22,
151
135
  username,
152
136
  algorithms: options.algorithms || DefaultAlgorithms
153
137
  };
154
-
155
138
  if (password) {
156
139
  connectionOptions.password = password;
157
140
  } else if (options.agent) {
@@ -161,11 +144,9 @@ function gulpSftp(options) {
161
144
  connectionOptions.privateKey = key.contents;
162
145
  connectionOptions.passphrase = key.passphrase;
163
146
  }
164
-
165
147
  if (options.timeout) {
166
148
  connectionOptions.readyTimeout = options.timeout;
167
149
  }
168
-
169
150
  const conn = new Client();
170
151
  connCache = conn;
171
152
  conn.on('ready', () => {
@@ -174,11 +155,9 @@ function gulpSftp(options) {
174
155
  if (err) {
175
156
  throw err;
176
157
  }
177
-
178
158
  sftp.on('end', function () {
179
159
  BalmJS.logger.debug(PLUGIN_NAME, 'SFTP session closed');
180
160
  sftpCache = null;
181
-
182
161
  if (!finished) {
183
162
  this.emit('error', new PluginError(PLUGIN_NAME, 'SFTP abrupt closure'));
184
163
  }
@@ -197,49 +176,50 @@ function gulpSftp(options) {
197
176
  if (!finished) {
198
177
  this.emit('error', new PluginError(PLUGIN_NAME, 'SFTP abrupt closure'));
199
178
  }
200
-
201
179
  if (options.callback) {
202
180
  options.callback();
203
181
  }
204
182
  });
205
183
  conn.connect(connectionOptions);
206
184
  }
207
-
208
185
  function transform(file, encoding, callback) {
209
186
  if (file.isNull()) {
210
187
  return callback();
211
- } // Have to create a new connection for each file otherwise they conflict, pulled from sindresorhus
212
-
188
+ }
213
189
 
214
- const finalRemotePath = normalizePath(node.path.join(remotePath, file.relative)); // Connection pulled from pool
190
+ // Have to create a new connection for each file otherwise they conflict, pulled from sindresorhus
191
+ const finalRemotePath = normalizePath(node.path.join(remotePath, file.relative));
215
192
 
193
+ // Connection pulled from pool
216
194
  _pool.call(this, sftp => {
217
195
  /*
218
196
  * Create Directories
219
197
  */
198
+
220
199
  // Get dir name from file path
221
- const dirname = node.path.dirname(finalRemotePath); // Get parents of the target dir
200
+ const dirname = node.path.dirname(finalRemotePath);
201
+ // Get parents of the target dir
222
202
 
223
203
  let fileDirs = parents(dirname).map(d => d.replace(/^\/~/, '~')).map(normalizePath);
224
-
225
204
  if (dirname.search(/^\//) === 0) {
226
205
  fileDirs = fileDirs.map(dir => dir.search(/^\//) === 0 ? dir : `/${dir}`);
227
- } // Get filter out dirs that are closer to root than the base remote path
228
- // also filter out any dirs made during this gulp session
206
+ }
229
207
 
208
+ // Get filter out dirs that are closer to root than the base remote path
209
+ // also filter out any dirs made during this gulp session
210
+ fileDirs = fileDirs.filter(d => d.length >= remotePath.length && !mkDirCache[d]);
230
211
 
231
- fileDirs = fileDirs.filter(d => d.length >= remotePath.length && !mkDirCache[d]); // While there are dirs to create, create them
212
+ // While there are dirs to create, create them
232
213
  // https://github.com/caolan/async#whilst - not the most commonly used async control flow
233
-
234
- async.whilst( // https://github.com/caolan/async/issues/1668
214
+ async.whilst(
215
+ // https://github.com/caolan/async/issues/1668
235
216
  cb => cb(null, fileDirs && fileDirs.length), cb => {
236
217
  let d = fileDirs.pop();
237
- mkDirCache[d] = true; // Mdrake - TODO: use a default file permission instead of defaulting to 755
238
-
218
+ mkDirCache[d] = true;
219
+ // Mdrake - TODO: use a default file permission instead of defaulting to 755
239
220
  if (remotePlatform && remotePlatform.toLowerCase().indexOf('win') !== -1) {
240
221
  d = d.replace('/', '\\');
241
222
  }
242
-
243
223
  sftp.exists(d, exist => {
244
224
  if (exist) {
245
225
  cb();
@@ -254,7 +234,6 @@ function gulpSftp(options) {
254
234
  } else {
255
235
  BalmJS.logger.debug(PLUGIN_NAME, `Created: ${d}`);
256
236
  }
257
-
258
237
  cb();
259
238
  });
260
239
  }
@@ -265,14 +244,14 @@ function gulpSftp(options) {
265
244
  encoding: null,
266
245
  mode: '0666',
267
246
  autoClose: true
268
- }); // Start upload
247
+ });
269
248
 
249
+ // Start upload
270
250
  if (file.isStream()) {
271
251
  file.contents.pipe(stream);
272
252
  } else if (file.isBuffer()) {
273
253
  stream.end(file.contents);
274
254
  }
275
-
276
255
  stream.on('close', function (error) {
277
256
  if (error) {
278
257
  this.emit('error', new PluginError(PLUGIN_NAME, error));
@@ -281,13 +260,11 @@ function gulpSftp(options) {
281
260
  BalmJS.logger.info(PLUGIN_NAME, `Uploaded: ${fileRelativePath} => ${finalRemotePath}`);
282
261
  fileCount++;
283
262
  }
284
-
285
263
  return callback(error);
286
264
  });
287
265
  });
288
266
  });
289
267
  }
290
-
291
268
  function flush(callback) {
292
269
  if (fileCount > 0) {
293
270
  const unit = fileCount === 1 ? 'file' : 'files';
@@ -295,21 +272,15 @@ function gulpSftp(options) {
295
272
  } else {
296
273
  BalmJS.logger.warn(PLUGIN_NAME, 'No files uploaded');
297
274
  }
298
-
299
275
  finished = true;
300
-
301
276
  if (sftpCache) {
302
277
  sftpCache.end();
303
278
  }
304
-
305
279
  if (connCache) {
306
280
  connCache.end();
307
281
  }
308
-
309
282
  callback();
310
283
  }
311
-
312
284
  return through2.obj(transform, flush);
313
285
  }
314
-
315
286
  export default gulpSftp;
@@ -2,54 +2,45 @@ class DefaultTask extends BalmJS.BalmTask {
2
2
  constructor() {
3
3
  super('default');
4
4
  }
5
-
6
5
  get startTask() {
7
6
  const tasks = BalmJS.toNamespace(['start']);
8
-
9
7
  if (BalmJS.utils.isString(BalmJS.beforeTask)) {
10
8
  tasks.unshift(BalmJS.beforeTask);
11
9
  }
12
-
13
10
  return tasks;
14
11
  }
15
-
16
12
  get mainTasks() {
17
- let tasks = ['clean', // Stylesheets
18
- ...(BalmJS.config.styles.sprites.length ? ['sprite'] : []), 'style', // Scripts
19
- ...(BalmJS.config.scripts.lint ? ['lint'] : []), 'script', // Templates
20
- 'html', // Other Assets
13
+ let tasks = ['clean',
14
+ // Stylesheets
15
+ ...(BalmJS.config.styles.sprites.length ? ['sprite'] : []), 'style',
16
+ // Scripts
17
+ ...(BalmJS.config.scripts.lint ? ['lint'] : []), 'script',
18
+ // Templates
19
+ 'html',
20
+ // Other Assets
21
21
  ...(BalmJS.config.env.isProd || !BalmJS.config.inFrontend ? ['image', 'font', 'media'] : [])];
22
-
23
22
  if (BalmJS.config.env.isProd) {
24
- tasks = [...tasks, 'extra', 'build', // Measure size
23
+ tasks = [...tasks, 'extra', 'build',
24
+ // Measure size
25
25
  ...(BalmJS.config.assets.cache ? ['cache'] : []), ...(BalmJS.config.pwa.enabled ? ['workbox-sw', 'pwa'] : [])];
26
26
  } else {
27
27
  tasks = [...tasks, 'modernizr', 'serve'];
28
28
  }
29
-
30
29
  let defaultMainTasks = BalmJS.config.useDefaults ? BalmJS.toNamespace(tasks) : [];
31
-
32
30
  if (BalmJS.config.env.inSSR || BalmJS.config.env.isMP || BalmJS.config.env.inDesktopApp) {
33
31
  defaultMainTasks = BalmJS.toNamespace(BalmJS.config.env.isMP ? ['style', 'script'] : ['script']);
34
32
  }
35
-
36
33
  return defaultMainTasks;
37
34
  }
38
-
39
35
  get subTasks() {
40
36
  return BalmJS.recipes.length ? BalmJS.toNamespace(BalmJS.recipes) : [];
41
37
  }
42
-
43
38
  get endTask() {
44
39
  const tasks = BalmJS.toNamespace(['end']);
45
-
46
40
  if (BalmJS.utils.isString(BalmJS.afterTask)) {
47
41
  tasks.push(BalmJS.afterTask);
48
42
  }
49
-
50
43
  return tasks;
51
44
  }
52
-
53
45
  }
54
-
55
46
  export default DefaultTask;
@@ -1,47 +1,32 @@
1
1
  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; }
2
-
3
2
  class BalmTask {
4
3
  constructor(name) {
5
4
  _defineProperty(this, "name", void 0);
6
-
7
5
  _defineProperty(this, "taskName", void 0);
8
-
9
6
  _defineProperty(this, "defaultInput", '');
10
-
11
7
  _defineProperty(this, "defaultOutput", '');
12
-
13
8
  _defineProperty(this, "input", '');
14
-
15
9
  _defineProperty(this, "output", '');
16
-
17
10
  _defineProperty(this, "customOptions", {});
18
-
19
11
  _defineProperty(this, "gulpSrcOptions", {});
20
-
21
12
  this.name = name;
22
13
  this.taskName = BalmJS.toNamespace(name);
23
14
  }
24
-
25
15
  get styleName() {
26
16
  let name;
27
-
28
17
  switch (BalmJS.config.styles.extname) {
29
18
  case 'sass':
30
19
  case 'scss':
31
20
  name = 'sass';
32
21
  break;
33
-
34
22
  case 'less':
35
23
  name = 'less';
36
24
  break;
37
-
38
25
  default:
39
26
  name = 'postcss';
40
27
  }
41
-
42
28
  return name;
43
29
  }
44
-
45
30
  get src() {
46
31
  return gulp.src(this.input, Object.assign({
47
32
  allowEmpty: true
@@ -49,22 +34,17 @@ class BalmTask {
49
34
  BalmJS.logger.error(`${this.name} task`, error.message);
50
35
  }));
51
36
  }
52
-
53
37
  init(input, output, options = {}) {
54
38
  let key = this.name;
55
-
56
39
  switch (key) {
57
40
  case 'copy':
58
41
  key = 'rename';
59
42
  break;
60
-
61
43
  case 'jsmin':
62
44
  key = 'terser';
63
45
  break;
64
-
65
46
  default:
66
47
  }
67
-
68
48
  const useAbsPath = !['webpack', 'rollup', 'esbuild', 'sprite'].includes(key);
69
49
  this.input = useAbsPath ? BalmJS.file.absPaths(input || this.defaultInput) : input || this.defaultInput;
70
50
  this.output = useAbsPath ? BalmJS.file.absPath(output || this.defaultOutput) : output || this.defaultOutput;
@@ -73,22 +53,17 @@ class BalmTask {
73
53
  input: this.input,
74
54
  output: this.output
75
55
  };
76
-
77
56
  if (options[key]) {
78
57
  obj.customOptions = this.customOptions;
79
58
  }
80
-
81
59
  if (useAbsPath) {
82
60
  BalmJS.logger.debug(`${this.name} task`, obj, {
83
61
  pre: true
84
62
  });
85
63
  }
86
-
87
64
  if (options.src) {
88
65
  this.gulpSrcOptions = options.src;
89
66
  }
90
67
  }
91
-
92
68
  }
93
-
94
69
  export default BalmTask;
@@ -1,24 +1,19 @@
1
1
  import BalmTask from './balm.js';
2
2
  import { ASSET } from '../../config/constants.js';
3
-
4
3
  class BalmStyleTask extends BalmTask {
5
4
  constructor(name) {
6
5
  super(name);
7
6
  let extname;
8
-
9
7
  switch (name) {
10
8
  case 'sass':
11
9
  extname = '{scss,sass}';
12
10
  break;
13
-
14
11
  case 'less':
15
12
  extname = 'less';
16
13
  break;
17
-
18
14
  default:
19
15
  extname = 'css';
20
16
  }
21
-
22
17
  if (Array.isArray(BalmJS.config.styles.entry)) {
23
18
  this.defaultInput = BalmJS.config.styles.entry.map(styleEntry => node.path.join(BalmJS.config.src.css, styleEntry));
24
19
  } else {
@@ -28,10 +23,8 @@ class BalmStyleTask extends BalmTask {
28
23
  this.defaultInput = node.path.join(BalmJS.config.src.css, '**', `!(_*).${extname}`);
29
24
  }
30
25
  }
31
-
32
26
  this.defaultOutput = BalmJS.config.env.isMP ? node.path.join(BalmJS.config.dest.base, ASSET.mpDir, BalmJS.config.paths.target.css) : BalmJS.config.dest.css;
33
27
  }
34
-
35
28
  handleStyle(style, output, options) {
36
29
  BalmJS.logger.debug(`${this.name} entry`, this.defaultInput, {
37
30
  pre: true
@@ -43,27 +36,23 @@ class BalmStyleTask extends BalmTask {
43
36
  allowEmpty: true
44
37
  }, this.gulpSrcOptions)).pipe(BalmJS.plugins.plumber(function (error) {
45
38
  // https://github.com/floatdrop/gulp-plumber/issues/30
46
- BalmJS.logger.error(taskName, error.message); // Must emit end event for any dependent streams to pick up on this. Destroying the stream
39
+ BalmJS.logger.error(taskName, error.message);
40
+ // Must emit end event for any dependent streams to pick up on this. Destroying the stream
47
41
  // ensures nothing else in that stream gets done, for example, if we're dealing with five
48
42
  // files, after an error in one of them, any other won't carry on. Doing destroy without
49
43
  // ending it first will not notify depending streams, tasks like `watch` will hang up.
50
-
51
44
  this.emit('end');
52
45
  this.destroy();
53
46
  }));
54
-
55
47
  switch (style) {
56
48
  case 'sass':
57
49
  stream = stream.pipe(BalmJS.plugins.sass(options));
58
50
  break;
59
-
60
51
  case 'less':
61
52
  stream = stream.pipe(BalmJS.plugins.less(options));
62
53
  break;
63
-
64
54
  default:
65
55
  }
66
-
67
56
  return stream.pipe(BalmJS.plugins.postcss(BalmJS.plugins.postcssPlugins(style === 'postcss'))).pipe($.if(BalmJS.config.env.isMP, BalmJS.plugins.rename({
68
57
  extname: '.wxss'
69
58
  }))).pipe(gulp.dest(output, {
@@ -72,7 +61,5 @@ class BalmStyleTask extends BalmTask {
72
61
  stream: true
73
62
  }));
74
63
  }
75
-
76
64
  }
77
-
78
65
  export default BalmStyleTask;
@@ -3,9 +3,7 @@ import BalmStyleTask from './balm_style.js';
3
3
  BalmJS.BalmTask = BalmTask;
4
4
  BalmJS.BalmStyleTask = BalmStyleTask;
5
5
  BalmJS.tasks = new Map(); // Main tasks
6
-
7
6
  BalmJS.recipes = []; // Sub tasks
8
-
9
7
  BalmJS.recipeIndex = 0;
10
8
  BalmJS.server = null;
11
9
  BalmJS.watchFtpFile = '';
@@ -3,10 +3,10 @@ import PRIVATE_TASKS from './private/index.js';
3
3
  import PUBLIC_TASKS from './public/index.js';
4
4
  import DefaultTask from './default.js';
5
5
  import BalmHooks from '../hooks/index.js';
6
-
7
6
  function registerTasks(recipe) {
8
- const AwesomeTasks = BalmJS.utils.deepMerge(PRIVATE_TASKS, PUBLIC_TASKS); // 1. Register balm tasks
7
+ const AwesomeTasks = BalmJS.utils.deepMerge(PRIVATE_TASKS, PUBLIC_TASKS);
9
8
 
9
+ // 1. Register balm tasks
10
10
  const depsTasks = [];
11
11
  const nonDepsTasks = [];
12
12
  Object.values(AwesomeTasks).forEach(AwesomeTask => {
@@ -26,8 +26,9 @@ function registerTasks(recipe) {
26
26
  };
27
27
  gulp.task(taskName, taskFunction);
28
28
  BalmJS.tasks.set(task.name, task);
29
- }); // 2. Register balm hooks
29
+ });
30
30
 
31
+ // 2. Register balm hooks
31
32
  try {
32
33
  recipe(new BalmHooks());
33
34
  } catch (error) {
@@ -35,13 +36,13 @@ function registerTasks(recipe) {
35
36
  message
36
37
  } = error;
37
38
  BalmJS.logger.error('balm hook', message);
38
- } // 3. Register balm default task
39
-
39
+ }
40
40
 
41
+ // 3. Register balm default task
41
42
  const defaultTask = new DefaultTask();
42
- gulp.task(defaultTask.taskName, gulp.series(...defaultTask.startTask, ...defaultTask.mainTasks, ...defaultTask.subTasks, ...defaultTask.endTask)); // 4. Run
43
+ gulp.task(defaultTask.taskName, gulp.series(...defaultTask.startTask, ...defaultTask.mainTasks, ...defaultTask.subTasks, ...defaultTask.endTask));
43
44
 
45
+ // 4. Run
44
46
  gulp.parallel('balm:default')();
45
47
  }
46
-
47
48
  export default registerTasks;
@@ -1,9 +1,7 @@
1
1
  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; }
2
-
3
2
  class BuildTask extends BalmJS.BalmTask {
4
3
  constructor() {
5
4
  super('build');
6
-
7
5
  _defineProperty(this, "fn", () => {
8
6
  this.init();
9
7
  return this.src.pipe($.size({
@@ -11,10 +9,7 @@ class BuildTask extends BalmJS.BalmTask {
11
9
  gzip: true
12
10
  }));
13
11
  });
14
-
15
12
  this.defaultInput = BalmJS.file.matchAllFiles(BalmJS.config.dest.base);
16
13
  }
17
-
18
14
  }
19
-
20
15
  export default BuildTask;
@@ -1,16 +1,12 @@
1
1
  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; }
2
-
3
2
  import { ASSETS_TYPES, CHUNK, ASSET } from '../../config/constants.js';
4
-
5
3
  class CacheTask extends BalmJS.BalmTask {
6
4
  constructor() {
7
5
  super('cache');
8
-
9
6
  _defineProperty(this, "fn", () => {
10
7
  this.init();
11
8
  return this.src.pipe($.revAll.revision(BalmJS.config.assets.options)).pipe($.if(/\.html$/, BalmJS.file.setPublicPath())).pipe(gulp.dest(this.output)).pipe($.revDeleteOriginal()).pipe($.revAll.manifestFile()).pipe(gulp.dest(this.output));
12
9
  });
13
-
14
10
  const defaultIncludes = BalmJS.config.scripts.useCache ? ASSETS_TYPES.filter(assetType => assetType !== 'js').map(assetType => BalmJS.file.matchAllFiles(BalmJS.config.dest[assetType])) : ASSETS_TYPES.map(assetType => BalmJS.file.matchAllFiles(BalmJS.config.dest[assetType]));
15
11
  const defaultExcludes = [node.path.join(`!${BalmJS.config.dest.js}`, CHUNK.dir, '*'), node.path.join(`!${BalmJS.config.dest.js}`, ASSET.dir, '*'), node.path.join(`!${BalmJS.config.dest.base}`, BalmJS.config.pwa.manifest)];
16
12
  const customIncludes = BalmJS.config.assets.includes;
@@ -20,7 +16,5 @@ class CacheTask extends BalmJS.BalmTask {
20
16
  this.defaultInput = [...defaultIncludes, ...defaultExcludes, ...(BalmJS.config.inFrontend ? [node.path.join(BalmJS.config.dest.base, '*.html')] : []), ...customIncludes, ...customExcludes];
21
17
  this.defaultOutput = BalmJS.config.inFrontend ? BalmJS.config.dest.base : BalmJS.config.dest.static;
22
18
  }
23
-
24
19
  }
25
-
26
20
  export default CacheTask;