balm-core 4.11.0 → 4.13.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 +31 -31
@@ -4,20 +4,15 @@ class ZipTask extends BalmJS.BalmTask {
4
4
  this.defaultInput = BalmJS.file.matchAllFiles(BalmJS.config.roots.target);
5
5
  this.defaultOutput = '.';
6
6
  }
7
-
8
7
  recipe(input, output, filename = 'archive.zip') {
9
8
  const balmZip = () => {
10
9
  this.init(input, output);
11
10
  return this.src.pipe($.zip(filename)).pipe(gulp.dest(this.output));
12
11
  };
13
-
14
12
  return balmZip;
15
13
  }
16
-
17
14
  fn(callback) {
18
15
  callback();
19
16
  }
20
-
21
17
  }
22
-
23
18
  export default ZipTask;
@@ -1,66 +1,55 @@
1
1
  import os from 'node:os';
2
- const platform = os.platform(); // Get interface name, default is 'eth' on linux, 'en' on mac os.
2
+ const platform = os.platform();
3
3
 
4
+ // Get interface name, default is 'eth' on linux, 'en' on mac os.
4
5
  function getInterfaceName() {
5
6
  let val = 'eth';
6
-
7
7
  if (platform === 'darwin') {
8
8
  val = 'en';
9
9
  } else if (platform === 'win32') {
10
10
  val = null;
11
11
  }
12
-
13
12
  return val;
14
13
  }
15
-
16
14
  function getInterface(family) {
17
15
  const interfaces = os.networkInterfaces();
18
16
  const name = getInterfaceName();
19
17
  family = family || 'IPv4';
20
-
21
18
  for (let i = -1; i < 8; i++) {
22
19
  const interfaceName = `${name}${i >= 0 ? i : ''}`; // support 'lo' and 'lo0'
23
-
24
20
  const items = interfaces[interfaceName];
25
-
26
21
  if (items) {
27
22
  for (let j = 0, len = items.length; j < len; j++) {
28
23
  const item = items[j];
29
-
30
24
  if (item.family === family) {
31
25
  return item;
32
26
  }
33
27
  }
34
28
  }
35
- } // (no interface name) filter 127.0.0.1, get the first ip
36
-
29
+ }
37
30
 
31
+ // (no interface name) filter 127.0.0.1, get the first ip
38
32
  for (const k in interfaces) {
39
33
  const items = interfaces[k];
40
-
41
34
  if (items) {
42
35
  for (let i = 0, len = items.length; i < len; i++) {
43
36
  const item = items[i];
44
-
45
37
  if (item.family === family && item.address !== '127.0.0.1') {
46
38
  return item;
47
39
  }
48
40
  }
49
41
  }
50
42
  }
51
-
52
43
  return;
53
44
  }
45
+
54
46
  /**
55
47
  * Get current machine IPv4
56
48
  */
57
-
58
-
59
49
  function ip() {
60
50
  const item = getInterface('IPv4');
61
51
  return item && item.address;
62
52
  }
63
-
64
53
  export default {
65
54
  ip
66
55
  };
@@ -5,34 +5,28 @@ import { existsSync, readFileSync, writeFileSync } from 'node:fs';
5
5
  import loading from './loading.js';
6
6
  const _require = Module.prototype.require;
7
7
  const SAVE_FILE = path.join(homedir(), process.env.BALM_CORE_CACHE || '.balm-core-cache.json');
8
-
9
8
  function cacheBalmCore() {
10
9
  let nameCache;
11
10
  let originLastFilename;
12
-
13
11
  try {
14
12
  nameCache = existsSync(SAVE_FILE) ? JSON.parse(readFileSync(SAVE_FILE, 'utf-8')) : {};
15
13
  originLastFilename = nameCache.lastFilename || '';
16
14
  } catch (err) {
17
15
  nameCache = {};
18
16
  }
19
-
20
17
  let currentModuleCache;
21
18
  let pathToLoad;
22
-
23
19
  Module.prototype.require = function cachePathsRequire(name) {
24
20
  currentModuleCache = nameCache[this.filename];
25
-
26
21
  if (!currentModuleCache) {
27
22
  currentModuleCache = {};
28
-
29
23
  if (/\/balm-core\//.test(this.filename)) {
30
24
  nameCache[this.filename] = currentModuleCache;
31
25
  nameCache.lastFilename = this.filename;
32
26
  }
33
27
  }
34
-
35
- if (currentModuleCache[name] && // Some people hack Object.prototype to insert their own properties on
28
+ if (currentModuleCache[name] &&
29
+ // Some people hack Object.prototype to insert their own properties on
36
30
  // every dictionary (for example, the 'should' testing framework). Check
37
31
  // that the key represents a path.
38
32
  typeof currentModuleCache[name] === 'string' && existsSync(currentModuleCache[name]) // the file must exist for a cache hit
@@ -42,13 +36,13 @@ function cacheBalmCore() {
42
36
  pathToLoad = Module._resolveFilename(name, this);
43
37
  currentModuleCache[name] = pathToLoad;
44
38
  }
45
-
46
39
  if (BalmJS.loading) {
47
40
  loading.render();
48
41
  }
49
-
50
42
  return _require.call(this, pathToLoad);
51
- }; // function printCache() {
43
+ };
44
+
45
+ // function printCache() {
52
46
  // Object.keys(nameCache).forEach(function (fromFilename) {
53
47
  // console.log(fromFilename);
54
48
  // const moduleCache = nameCache[fromFilename];
@@ -58,7 +52,6 @@ function cacheBalmCore() {
58
52
  // });
59
53
  // }
60
54
 
61
-
62
55
  BalmJS.emitter.once('exit', function () {
63
56
  if (nameCache.lastFilename !== originLastFilename) {
64
57
  try {
@@ -70,5 +63,4 @@ function cacheBalmCore() {
70
63
  }
71
64
  });
72
65
  }
73
-
74
66
  export default cacheBalmCore;
@@ -3,17 +3,14 @@ const COLOR = {
3
3
  PREFIX: 'bg',
4
4
  SUFFIX: 'Bright'
5
5
  };
6
-
7
6
  function getStyle(colorStyle = {
8
7
  color: 'white'
9
8
  }) {
10
9
  const color = colorStyle.color.toLowerCase();
11
10
  let fn = colorStyle.background ? COLOR.PREFIX + color.replace(/^[a-z]/, str => str.toUpperCase()) : color;
12
-
13
11
  if (colorStyle.bright) {
14
12
  fn += COLOR.SUFFIX;
15
13
  }
16
-
17
14
  const colors = ansiColors;
18
15
  const render = colorStyle.modifier ? colors[colorStyle.modifier][fn] : colors[fn];
19
16
  const symbols = ansiColors.symbols;
@@ -23,10 +20,8 @@ function getStyle(colorStyle = {
23
20
  render
24
21
  };
25
22
  }
26
-
27
23
  function color(label, colorStyle) {
28
24
  const result = getStyle(colorStyle);
29
25
  return result.render(`${result.icon}${label}`);
30
26
  }
31
-
32
27
  export default color;
@@ -1,21 +1,12 @@
1
1
  function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
2
-
3
2
  function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
4
-
5
3
  function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
6
-
7
4
  function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
8
-
9
5
  function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
10
-
11
6
  function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
12
-
13
7
  function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
14
-
15
8
  import loading from './loading.js';
16
-
17
9
  var _firstCompile = /*#__PURE__*/new WeakMap();
18
-
19
10
  class BalmCompiling {
20
11
  constructor() {
21
12
  _classPrivateFieldInitSpec(this, _firstCompile, {
@@ -23,21 +14,16 @@ class BalmCompiling {
23
14
  value: true
24
15
  });
25
16
  }
26
-
27
17
  start() {
28
18
  if (!BalmJS.useCacache && _classPrivateFieldGet(this, _firstCompile)) {
29
19
  loading.render('Compiling to JS...');
30
20
  }
31
21
  }
32
-
33
22
  stop() {
34
23
  if (!BalmJS.useCacache && _classPrivateFieldGet(this, _firstCompile)) {
35
24
  _classPrivateFieldSet(this, _firstCompile, false);
36
-
37
25
  loading.clear();
38
26
  }
39
27
  }
40
-
41
28
  }
42
-
43
29
  export default new BalmCompiling();
@@ -2,19 +2,16 @@ import net from 'node:net';
2
2
  import address from './address.js';
3
3
  const UTIL_NAME = 'detect port';
4
4
  const MAX_PORT = 65535;
5
-
6
5
  function listen(port, host, callback) {
7
6
  const server = new net.Server();
8
7
  server.on('error', error => {
9
8
  server.close();
10
-
11
9
  if (error.code === 'ENOTFOUND') {
12
10
  BalmJS.logger.error(UTIL_NAME, `ignore dns ENOTFOUND error, get free ${host}:${port}`, {
13
11
  logLevel: BalmJS.LogLevel.Debug
14
12
  });
15
13
  return callback(null, port);
16
14
  }
17
-
18
15
  return callback(error);
19
16
  });
20
17
  server.listen(port, host, () => {
@@ -24,7 +21,6 @@ function listen(port, host, callback) {
24
21
  return callback(null, port);
25
22
  });
26
23
  }
27
-
28
24
  function tryListen(port, maxPort, host, callback) {
29
25
  function handleError(err) {
30
26
  if (err) {
@@ -32,9 +28,7 @@ function tryListen(port, maxPort, host, callback) {
32
28
  logLevel: BalmJS.LogLevel.Debug
33
29
  });
34
30
  }
35
-
36
31
  port++;
37
-
38
32
  if (port >= maxPort) {
39
33
  BalmJS.logger.warn(UTIL_NAME, `port: ${port} >= maxPort: ${maxPort}, give up and use random port`, {
40
34
  logLevel: BalmJS.LogLevel.Debug
@@ -42,20 +36,16 @@ function tryListen(port, maxPort, host, callback) {
42
36
  port = 0;
43
37
  maxPort = 0;
44
38
  }
45
-
46
39
  tryListen(port, maxPort, host, callback);
47
40
  }
48
-
49
41
  if (host) {
50
42
  listen(port, host, (error, realPort) => {
51
43
  if (error) {
52
44
  if (error.code === 'EADDRNOTAVAIL') {
53
45
  return callback(new Error('the ip that is not unkonwn on the machine'));
54
46
  }
55
-
56
47
  return handleError();
57
48
  }
58
-
59
49
  callback(null, realPort);
60
50
  });
61
51
  } else {
@@ -65,31 +55,29 @@ function tryListen(port, maxPort, host, callback) {
65
55
  if (port === 0) {
66
56
  return callback(error, realPort);
67
57
  }
68
-
69
58
  if (error) {
70
59
  return handleError(error);
71
- } // 2. check 0.0.0.0
72
-
60
+ }
73
61
 
62
+ // 2. check 0.0.0.0
74
63
  listen(port, '0.0.0.0', error => {
75
64
  if (error) {
76
65
  return handleError(error);
77
- } // 3. check localhost
78
-
66
+ }
79
67
 
68
+ // 3. check localhost
80
69
  listen(port, 'localhost', error => {
81
70
  // if localhost refer to the ip that is not unkonwn on the machine, you will see the error EADDRNOTAVAIL
82
71
  // https://stackoverflow.com/questions/10809740/listen-eaddrnotavail-error-in-node-js
83
72
  if (error && error.code !== 'EADDRNOTAVAIL') {
84
73
  return handleError(error);
85
- } // 4. check current ip
86
-
74
+ }
87
75
 
76
+ // 4. check current ip
88
77
  listen(port, address.ip(), (error, realPort) => {
89
78
  if (error) {
90
79
  return handleError(error);
91
80
  }
92
-
93
81
  callback(null, realPort);
94
82
  });
95
83
  });
@@ -97,14 +85,11 @@ function tryListen(port, maxPort, host, callback) {
97
85
  });
98
86
  }
99
87
  }
100
-
101
88
  function detectPort(port, host) {
102
89
  let maxPort = port + 10;
103
-
104
90
  if (maxPort > MAX_PORT) {
105
91
  maxPort = MAX_PORT;
106
92
  }
107
-
108
93
  BalmJS.logger.debug(UTIL_NAME, `detect free port between [${port}, ${maxPort}]`);
109
94
  return new Promise(resolve => {
110
95
  tryListen(port, maxPort, host, (error, realPort) => {
@@ -112,5 +97,4 @@ function detectPort(port, host) {
112
97
  });
113
98
  });
114
99
  }
115
-
116
100
  export default detectPort;
@@ -1,11 +1,10 @@
1
1
  const escapeStringRegexp = str => {
2
2
  if (typeof str !== 'string') {
3
3
  throw new TypeError('Expected a string');
4
- } // Escape characters with special meaning either inside or outside character sets.
5
- // Use a simple backslash escape when it’s always valid, and a \unnnn escape when the simpler form would be disallowed by Unicode patterns’ stricter grammar.
6
-
4
+ }
7
5
 
6
+ // Escape characters with special meaning either inside or outside character sets.
7
+ // Use a simple backslash escape when it’s always valid, and a \unnnn escape when the simpler form would be disallowed by Unicode patterns’ stricter grammar.
8
8
  return str.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&').replace(/-/g, '\\x2d');
9
9
  };
10
-
11
10
  export default escapeStringRegexp;
@@ -1,13 +1,12 @@
1
1
  import getPublicUrlOrPath from './public-url.js';
2
- import { PUBLIC_URL } from '../config/constants.js'; // Make sure any symlinks in the project folder are resolved
2
+ import { PUBLIC_URL } from '../config/constants.js';
3
3
 
4
+ // Make sure any symlinks in the project folder are resolved
4
5
  const appDirectory = node.fs.realpathSync(process.cwd());
5
-
6
6
  class File {
7
7
  resolveApp(relativePath) {
8
8
  return node.path.resolve(appDirectory, relativePath);
9
9
  }
10
-
11
10
  get publicUrlOrPath() {
12
11
  // We use `PUBLIC_URL` environment variable or "homepage" field to infer
13
12
  // "public path" at which the app is served.
@@ -17,37 +16,28 @@ class File {
17
16
  // like /todos/42/static/js/bundle.7289d.js. We have to know the root.
18
17
  return getPublicUrlOrPath(requireModule(this.resolveApp('package.json')).homepage, process.env.PUBLIC_URL);
19
18
  }
20
-
21
19
  get stylePaths() {
22
20
  return [node.path.resolve(BalmJS.config.workspace, '.'), node.path.resolve(BalmJS.config.workspace, 'node_modules'), ...BalmJS.config.styles.atImportPaths];
23
21
  }
24
-
25
22
  get assetsSuffixPath() {
26
23
  return !BalmJS.config.inFrontend && BalmJS.config.env.isProd && BalmJS.config.assets.cache // Back-end project in production with cache
27
24
  ? node.path.join(BalmJS.config.assets.subDir, BalmJS.config.assets.buildDir) : BalmJS.config.assets.subDir;
28
25
  }
29
-
30
26
  get defaultEntry() {
31
27
  return node.path.join(BalmJS.config.src.js, 'index.js');
32
28
  }
33
-
34
29
  get templateBasePath() {
35
30
  return BalmJS.config.scripts.injectHtml ? BalmJS.config.src.base : BalmJS.config.src.html;
36
31
  }
37
-
38
32
  absPath(_path) {
39
33
  return node.path.resolve(BalmJS.config.workspace, _path);
40
34
  }
41
-
42
35
  absPaths(_paths) {
43
36
  let paths;
44
-
45
37
  if (BalmJS.utils.isArray(_paths)) {
46
38
  paths = [];
47
-
48
39
  for (const _path of _paths) {
49
40
  const result = /^!(.+)$/.exec(_path);
50
-
51
41
  if (result) {
52
42
  paths.push('!' + this.absPath(result[1]));
53
43
  } else {
@@ -57,18 +47,14 @@ class File {
57
47
  } else {
58
48
  paths = this.absPath(_paths);
59
49
  }
60
-
61
50
  return paths;
62
51
  }
63
-
64
52
  matchAllFiles(_path, _file) {
65
53
  return node.path.join(_path, '**', _file || '*');
66
54
  }
67
-
68
55
  assetsPath(_path) {
69
56
  return BalmJS.config.env.isProd || !BalmJS.config.inFrontend ? node.path.posix.join(BalmJS.config.assets.virtualDir, this.assetsSuffixPath, _path) : _path;
70
57
  }
71
-
72
58
  setPublicPath() {
73
59
  const publicPathSrc = `${PUBLIC_URL}/`;
74
60
  const publicPathDest = BalmJS.config.env.inDesktopApp ? `.${this.publicUrlOrPath}` : this.publicUrlOrPath;
@@ -80,7 +66,5 @@ class File {
80
66
  });
81
67
  return BalmJS.plugins.replace(publicPathSrc, publicPathDest);
82
68
  }
83
-
84
69
  }
85
-
86
70
  export default new File();
@@ -1,71 +1,48 @@
1
1
  function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
2
-
3
2
  function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
4
-
5
3
  function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
6
-
7
4
  function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
8
-
9
5
  function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
10
-
11
6
  function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
12
-
13
7
  function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
14
-
15
8
  import readline from 'readline';
16
9
  import spinner from '../config/spinner.js';
17
-
18
10
  var _stream = /*#__PURE__*/new WeakMap();
19
-
20
11
  var _frameIndex = /*#__PURE__*/new WeakMap();
21
-
22
12
  var _frameCount = /*#__PURE__*/new WeakMap();
23
-
24
13
  class BalmLoading {
25
14
  constructor() {
26
15
  _classPrivateFieldInitSpec(this, _stream, {
27
16
  writable: true,
28
17
  value: process.stderr
29
18
  });
30
-
31
19
  _classPrivateFieldInitSpec(this, _frameIndex, {
32
20
  writable: true,
33
21
  value: 0
34
22
  });
35
-
36
23
  _classPrivateFieldInitSpec(this, _frameCount, {
37
24
  writable: true,
38
25
  value: spinner.frames.length
39
26
  });
40
27
  }
41
-
42
28
  get frame() {
43
29
  var _this$frameIndex;
44
-
45
30
  const currentFrame = spinner.frames[_classPrivateFieldGet(this, _frameIndex)];
46
-
47
31
  _classPrivateFieldSet(this, _frameIndex, _classPrivateFieldSet(this, _frameIndex, (_this$frameIndex = _classPrivateFieldGet(this, _frameIndex), ++_this$frameIndex)) % _classPrivateFieldGet(this, _frameCount));
48
-
49
32
  return currentFrame;
50
33
  }
51
-
52
34
  clear() {
53
35
  // Compatibility on Windows
54
36
  readline.clearLine(_classPrivateFieldGet(this, _stream), 0);
55
37
  readline.cursorTo(_classPrivateFieldGet(this, _stream), 0);
56
38
  }
57
-
58
39
  render(text = `${this.frame} BalmJS is initializing...`) {
59
40
  this.clear();
60
-
61
41
  _classPrivateFieldGet(this, _stream).write(text);
62
42
  }
63
-
64
43
  succeed() {
65
44
  this.clear();
66
45
  console.log(`BalmJS core version: ${BalmJS.version}`);
67
46
  }
68
-
69
47
  }
70
-
71
48
  export default new BalmLoading();
@@ -1,13 +1,8 @@
1
1
  function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
2
-
3
2
  function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
4
-
5
3
  function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
6
-
7
4
  function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
8
-
9
5
  function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
10
-
11
6
  import util from 'node:util';
12
7
  import fancyLog from 'fancy-log';
13
8
  import color from './color.js';
@@ -46,9 +41,7 @@ const LOG = {
46
41
  beginning: '$'.padStart(36, '*'),
47
42
  end: '^'.padEnd(36, '.')
48
43
  };
49
-
50
44
  var _log = /*#__PURE__*/new WeakMap();
51
-
52
45
  class Logger {
53
46
  constructor() {
54
47
  _classPrivateFieldInitSpec(this, _log, {
@@ -63,60 +56,48 @@ class Logger {
63
56
  }
64
57
  });
65
58
  }
66
-
67
59
  success(label, message, options = {}) {
68
60
  const logOptions = Object.assign({
69
61
  logLevel: BalmJS.LogLevel.Trace
70
62
  }, options);
71
-
72
63
  if (BalmJS.config.logs.level <= logOptions.logLevel) {
73
64
  console.log(LOG.beginning);
74
65
  fancyLog(LOG.FORMAT, LOG.PREFIX, color(`<${label}>`, LOG.OK), _classPrivateFieldGet(this, _log).call(this, message, logOptions.pre));
75
66
  console.log(LOG.end);
76
67
  }
77
68
  }
78
-
79
69
  debug(label, message, options = {}) {
80
70
  const logOptions = Object.assign({
81
71
  logLevel: BalmJS.LogLevel.Debug
82
72
  }, options);
83
-
84
73
  if (BalmJS.config.logs.level <= logOptions.logLevel) {
85
74
  fancyLog.info(LOG.FORMAT, LOG.PREFIX, color(`<${label}>`, LOG.DEBUG), _classPrivateFieldGet(this, _log).call(this, message, logOptions.pre));
86
75
  }
87
76
  }
88
-
89
77
  info(label, message, options = {}) {
90
78
  const logOptions = Object.assign({
91
79
  logLevel: BalmJS.LogLevel.Info
92
80
  }, options);
93
-
94
81
  if (BalmJS.config.logs.level <= logOptions.logLevel) {
95
82
  fancyLog.info(LOG.FORMAT, LOG.PREFIX, color(`<${label}>`, LOG.INFO), _classPrivateFieldGet(this, _log).call(this, message, logOptions.pre));
96
83
  }
97
84
  }
98
-
99
85
  warn(label, message, options = {}) {
100
86
  const logOptions = Object.assign({
101
87
  logLevel: BalmJS.LogLevel.Warn
102
88
  }, options);
103
-
104
89
  if (BalmJS.config.logs.level <= logOptions.logLevel) {
105
90
  fancyLog.warn(LOG.FORMAT, LOG.PREFIX, color(`<${label}>`, LOG.WARN), _classPrivateFieldGet(this, _log).call(this, message, logOptions.pre));
106
91
  }
107
92
  }
108
-
109
93
  error(label, message, options = {}) {
110
94
  const logOptions = Object.assign({
111
95
  logLevel: BalmJS.LogLevel.Error,
112
96
  pre: false
113
97
  }, options);
114
-
115
98
  if (BalmJS.config.logs.level <= logOptions.logLevel) {
116
99
  fancyLog.error(LOG.FORMAT, LOG.PREFIX, color(`<${label}>`, LOG.ERROR), _classPrivateFieldGet(this, _log).call(this, message, logOptions.pre));
117
100
  }
118
101
  }
119
-
120
102
  }
121
-
122
103
  export default new Logger();
@@ -1,28 +1,23 @@
1
1
  import { PassThrough } from 'node:stream';
2
-
3
2
  function mergeStream(...args) {
4
3
  let sources = [];
5
4
  const output = new PassThrough({
6
5
  objectMode: true
7
6
  });
8
7
  output.setMaxListeners(0);
9
-
10
8
  function remove(source) {
11
9
  sources = sources.filter(it => {
12
10
  return it !== source;
13
11
  });
14
-
15
12
  if (!sources.length && output.readable) {
16
13
  output.end();
17
14
  }
18
15
  }
19
-
20
16
  function add(source) {
21
17
  if (Array.isArray(source)) {
22
18
  source.forEach(add);
23
19
  return this;
24
20
  }
25
-
26
21
  sources.push(source);
27
22
  source.once('end', remove.bind(null, source));
28
23
  source.once('error', output.emit.bind(output, 'error'));
@@ -31,16 +26,13 @@ function mergeStream(...args) {
31
26
  });
32
27
  return this;
33
28
  }
34
-
35
29
  function isEmpty() {
36
30
  return sources.length == 0;
37
31
  }
38
-
39
32
  output.add = add;
40
33
  output.isEmpty = isEmpty;
41
34
  output.on('unpipe', remove);
42
35
  [...args].slice().forEach(add);
43
36
  return output;
44
37
  }
45
-
46
38
  export default mergeStream;
@@ -1,15 +1,11 @@
1
1
  const NAMESPACE = 'balm';
2
-
3
2
  function toNamespace(taskName) {
4
3
  let result = 'unknown';
5
-
6
4
  if (BalmJS.utils.isArray(taskName)) {
7
5
  result = taskName.map(name => `${NAMESPACE}:${name}`);
8
6
  } else {
9
7
  result = `${NAMESPACE}:${taskName}`;
10
8
  }
11
-
12
9
  return result;
13
10
  }
14
-
15
11
  export default toNamespace;