balm-core 5.2.0 → 6.0.0-alpha.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.
- package/dist/index.cjs +2191 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +559 -0
- package/dist/index.d.ts +559 -0
- package/dist/index.js +2098 -0
- package/dist/index.js.map +1 -0
- package/package.json +48 -123
- package/src/balm.ts +103 -0
- package/src/bundler/esbuild.ts +47 -0
- package/src/bundler/index.ts +3 -0
- package/src/bundler/rollup.ts +39 -0
- package/src/bundler/webpack.ts +82 -0
- package/src/config/constants.ts +12 -0
- package/src/config/defaults.ts +209 -0
- package/src/config/index.ts +112 -0
- package/src/hooks/index.ts +192 -0
- package/src/index.ts +16 -0
- package/src/pipeline/file.ts +69 -0
- package/src/pipeline/index.ts +10 -0
- package/src/pipeline/pipeline.ts +132 -0
- package/src/pipeline/transforms/cache.ts +96 -0
- package/src/pipeline/transforms/htmlmin.ts +18 -0
- package/src/pipeline/transforms/less.ts +75 -0
- package/src/pipeline/transforms/postcss.ts +43 -0
- package/src/pipeline/transforms/rename.ts +37 -0
- package/src/pipeline/transforms/replace.ts +30 -0
- package/src/pipeline/transforms/sass.ts +106 -0
- package/src/pipeline/transforms/terser.ts +20 -0
- package/src/runner/dag.ts +77 -0
- package/src/runner/task.ts +38 -0
- package/src/shims.d.ts +5 -0
- package/src/tasks/cache.ts +58 -0
- package/src/tasks/clean.ts +21 -0
- package/src/tasks/copy.ts +36 -0
- package/src/tasks/ftp.ts +90 -0
- package/src/tasks/html.ts +78 -0
- package/src/tasks/index.ts +13 -0
- package/src/tasks/publish.ts +71 -0
- package/src/tasks/pwa.ts +49 -0
- package/src/tasks/remove.ts +24 -0
- package/src/tasks/replace.ts +34 -0
- package/src/tasks/script.ts +28 -0
- package/src/tasks/server.ts +89 -0
- package/src/tasks/style.ts +57 -0
- package/src/tasks/zip.ts +65 -0
- package/src/types/index.ts +200 -0
- package/src/utilities/file.ts +120 -0
- package/src/utilities/logger.ts +63 -0
- package/src/utilities/utils.ts +46 -0
- package/src/utilities/workspace.ts +38 -0
- package/src/watcher/index.ts +100 -0
- package/tsconfig.json +8 -0
- package/tsup.config.ts +12 -0
- package/README.md +0 -196
- package/index.d.ts +0 -360
- package/lib/balm.js +0 -49
- package/lib/bootstrap/check_config.js +0 -43
- package/lib/bootstrap/index.js +0 -87
- package/lib/bundler/esbuild/build.js +0 -26
- package/lib/bundler/esbuild/index.js +0 -7
- package/lib/bundler/esbuild/options.js +0 -7
- package/lib/bundler/esbuild/transform.js +0 -36
- package/lib/bundler/rollup/build.js +0 -52
- package/lib/bundler/rollup/entry.js +0 -28
- package/lib/bundler/rollup/index.js +0 -20
- package/lib/bundler/rollup/output.js +0 -20
- package/lib/bundler/rollup/plugins.js +0 -31
- package/lib/bundler/webpack/config/common.js +0 -135
- package/lib/bundler/webpack/config/dev.js +0 -12
- package/lib/bundler/webpack/config/env.js +0 -67
- package/lib/bundler/webpack/config/index.js +0 -6
- package/lib/bundler/webpack/config/prod.js +0 -39
- package/lib/bundler/webpack/config/regex.js +0 -10
- package/lib/bundler/webpack/entry.js +0 -65
- package/lib/bundler/webpack/index.js +0 -32
- package/lib/bundler/webpack/loaders.js +0 -50
- package/lib/bundler/webpack/output.js +0 -41
- package/lib/bundler/webpack/rules/asset.js +0 -33
- package/lib/bundler/webpack/rules/babel.js +0 -19
- package/lib/bundler/webpack/rules/css.js +0 -109
- package/lib/bundler/webpack/rules/html.js +0 -15
- package/lib/bundler/webpack/rules/index.js +0 -10
- package/lib/config/assets.js +0 -30
- package/lib/config/constants.js +0 -14
- package/lib/config/env.js +0 -35
- package/lib/config/extras.js +0 -6
- package/lib/config/ftp.js +0 -6
- package/lib/config/globals.js +0 -43
- package/lib/config/html.js +0 -22
- package/lib/config/images.js +0 -4
- package/lib/config/index.js +0 -63
- package/lib/config/logs.js +0 -11
- package/lib/config/paths.js +0 -46
- package/lib/config/pwa.js +0 -24
- package/lib/config/roots.js +0 -9
- package/lib/config/scripts.js +0 -162
- package/lib/config/server.js +0 -84
- package/lib/config/spinner.js +0 -9
- package/lib/config/styles.js +0 -67
- package/lib/hello.js +0 -19
- package/lib/hooks/index.js +0 -94
- package/lib/hooks/maker.js +0 -59
- package/lib/index.js +0 -5
- package/lib/middlewares/history.js +0 -6
- package/lib/middlewares/index.js +0 -11
- package/lib/middlewares/proxy.js +0 -28
- package/lib/middlewares/webpack.js +0 -26
- package/lib/plugins/htmlmin.js +0 -39
- package/lib/plugins/imagemin.js +0 -95
- package/lib/plugins/index.js +0 -27
- package/lib/plugins/jsmin.js +0 -37
- package/lib/plugins/less.js +0 -97
- package/lib/plugins/plumber.js +0 -87
- package/lib/plugins/postcss-plugins.js +0 -13
- package/lib/plugins/postcss.js +0 -117
- package/lib/plugins/rename.js +0 -51
- package/lib/plugins/replace.js +0 -91
- package/lib/plugins/sass-legacy.js +0 -131
- package/lib/plugins/sass.js +0 -134
- package/lib/plugins/sftp.js +0 -288
- package/lib/tasks/default.js +0 -46
- package/lib/tasks/foundation/balm.js +0 -72
- package/lib/tasks/foundation/balm_style.js +0 -65
- package/lib/tasks/foundation/index.js +0 -10
- package/lib/tasks/index.js +0 -48
- package/lib/tasks/private/build.js +0 -18
- package/lib/tasks/private/cache.js +0 -31
- package/lib/tasks/private/clean.js +0 -69
- package/lib/tasks/private/end.js +0 -24
- package/lib/tasks/private/extra.js +0 -35
- package/lib/tasks/private/font.js +0 -15
- package/lib/tasks/private/image.js +0 -37
- package/lib/tasks/private/index.js +0 -34
- package/lib/tasks/private/lint.js +0 -20
- package/lib/tasks/private/media.js +0 -15
- package/lib/tasks/private/modernizr.js +0 -59
- package/lib/tasks/private/pwa-cache.js +0 -32
- package/lib/tasks/private/script.js +0 -9
- package/lib/tasks/private/sprite.js +0 -105
- package/lib/tasks/private/start.js +0 -16
- package/lib/tasks/private/style.js +0 -9
- package/lib/tasks/private/workbox-sw.js +0 -15
- package/lib/tasks/public/copy.js +0 -16
- package/lib/tasks/public/esbuild.js +0 -18
- package/lib/tasks/public/ftp.js +0 -39
- package/lib/tasks/public/html.js +0 -65
- package/lib/tasks/public/index.js +0 -38
- package/lib/tasks/public/jsmin.js +0 -23
- package/lib/tasks/public/less.js +0 -21
- package/lib/tasks/public/postcss.js +0 -16
- package/lib/tasks/public/publish.js +0 -51
- package/lib/tasks/public/pwa.js +0 -84
- package/lib/tasks/public/remove.js +0 -46
- package/lib/tasks/public/replace.js +0 -26
- package/lib/tasks/public/rollup.js +0 -17
- package/lib/tasks/public/sass.js +0 -27
- package/lib/tasks/public/server.js +0 -130
- package/lib/tasks/public/url.js +0 -35
- package/lib/tasks/public/version.js +0 -23
- package/lib/tasks/public/webpack.js +0 -39
- package/lib/tasks/public/zip.js +0 -19
- package/lib/utilities/address.js +0 -55
- package/lib/utilities/cache-core.js +0 -66
- package/lib/utilities/color.js +0 -27
- package/lib/utilities/compiling.js +0 -24
- package/lib/utilities/detect-port.js +0 -100
- package/lib/utilities/escape-string-regexp.js +0 -10
- package/lib/utilities/file.js +0 -70
- package/lib/utilities/index.js +0 -8
- package/lib/utilities/loading.js +0 -37
- package/lib/utilities/logger.js +0 -99
- package/lib/utilities/merge-stream.js +0 -38
- package/lib/utilities/namespace.js +0 -11
- package/lib/utilities/public-url.js +0 -37
- package/lib/utilities/replacestream.js +0 -106
- package/lib/utilities/typeof.js +0 -5
- package/lib/utilities/utils.js +0 -43
- package/tslib/balm.js +0 -44
- package/tslib/bootstrap/check_config.js +0 -36
- package/tslib/bootstrap/index.js +0 -82
- package/tslib/bundler/esbuild/build.js +0 -30
- package/tslib/bundler/esbuild/index.js +0 -11
- package/tslib/bundler/esbuild/options.js +0 -7
- package/tslib/bundler/esbuild/transform.js +0 -38
- package/tslib/bundler/rollup/build.js +0 -17
- package/tslib/bundler/rollup/entry.js +0 -24
- package/tslib/bundler/rollup/index.js +0 -21
- package/tslib/bundler/rollup/output.js +0 -23
- package/tslib/bundler/rollup/plugins.js +0 -27
- package/tslib/bundler/webpack/config/common.js +0 -130
- package/tslib/bundler/webpack/config/dev.js +0 -14
- package/tslib/bundler/webpack/config/env.js +0 -44
- package/tslib/bundler/webpack/config/index.js +0 -8
- package/tslib/bundler/webpack/config/prod.js +0 -43
- package/tslib/bundler/webpack/config/regex.js +0 -10
- package/tslib/bundler/webpack/entry.js +0 -68
- package/tslib/bundler/webpack/index.js +0 -30
- package/tslib/bundler/webpack/loaders.js +0 -51
- package/tslib/bundler/webpack/output.js +0 -41
- package/tslib/bundler/webpack/rules/asset.js +0 -33
- package/tslib/bundler/webpack/rules/babel.js +0 -16
- package/tslib/bundler/webpack/rules/css.js +0 -95
- package/tslib/bundler/webpack/rules/html.js +0 -15
- package/tslib/bundler/webpack/rules/index.js +0 -10
- package/tslib/config/assets.js +0 -24
- package/tslib/config/constants.js +0 -14
- package/tslib/config/env.js +0 -43
- package/tslib/config/extras.js +0 -6
- package/tslib/config/ftp.js +0 -6
- package/tslib/config/globals.js +0 -47
- package/tslib/config/html.js +0 -17
- package/tslib/config/images.js +0 -4
- package/tslib/config/index.js +0 -56
- package/tslib/config/logs.js +0 -6
- package/tslib/config/paths.js +0 -30
- package/tslib/config/pwa.js +0 -18
- package/tslib/config/roots.js +0 -8
- package/tslib/config/scripts.js +0 -93
- package/tslib/config/server.js +0 -33
- package/tslib/config/spinner.js +0 -10
- package/tslib/config/styles.js +0 -37
- package/tslib/hello.js +0 -19
- package/tslib/hooks/index.js +0 -75
- package/tslib/hooks/maker.js +0 -66
- package/tslib/index.js +0 -5
- package/tslib/middlewares/history.js +0 -12
- package/tslib/middlewares/index.js +0 -18
- package/tslib/middlewares/proxy.js +0 -27
- package/tslib/middlewares/webpack.js +0 -29
- package/tslib/plugins/htmlmin.js +0 -38
- package/tslib/plugins/imagemin.js +0 -97
- package/tslib/plugins/index.js +0 -27
- package/tslib/plugins/jsmin.js +0 -39
- package/tslib/plugins/less.js +0 -90
- package/tslib/plugins/plumber.js +0 -81
- package/tslib/plugins/postcss-plugins.js +0 -24
- package/tslib/plugins/postcss.js +0 -111
- package/tslib/plugins/rename.js +0 -51
- package/tslib/plugins/replace.js +0 -72
- package/tslib/plugins/sass-legacy.js +0 -95
- package/tslib/plugins/sass.js +0 -109
- package/tslib/plugins/sftp.js +0 -258
- package/tslib/tasks/default.js +0 -59
- package/tslib/tasks/foundation/balm.js +0 -75
- package/tslib/tasks/foundation/balm_style.js +0 -68
- package/tslib/tasks/foundation/index.js +0 -10
- package/tslib/tasks/index.js +0 -43
- package/tslib/tasks/private/build.js +0 -15
- package/tslib/tasks/private/cache.js +0 -48
- package/tslib/tasks/private/clean.js +0 -82
- package/tslib/tasks/private/end.js +0 -21
- package/tslib/tasks/private/extra.js +0 -34
- package/tslib/tasks/private/font.js +0 -12
- package/tslib/tasks/private/image.js +0 -42
- package/tslib/tasks/private/index.js +0 -34
- package/tslib/tasks/private/lint.js +0 -17
- package/tslib/tasks/private/media.js +0 -12
- package/tslib/tasks/private/modernizr.js +0 -54
- package/tslib/tasks/private/pwa-cache.js +0 -32
- package/tslib/tasks/private/script.js +0 -9
- package/tslib/tasks/private/sprite.js +0 -93
- package/tslib/tasks/private/start.js +0 -13
- package/tslib/tasks/private/style.js +0 -12
- package/tslib/tasks/private/workbox-sw.js +0 -15
- package/tslib/tasks/public/copy.js +0 -18
- package/tslib/tasks/public/esbuild.js +0 -18
- package/tslib/tasks/public/ftp.js +0 -39
- package/tslib/tasks/public/html.js +0 -75
- package/tslib/tasks/public/index.js +0 -38
- package/tslib/tasks/public/jsmin.js +0 -24
- package/tslib/tasks/public/less.js +0 -21
- package/tslib/tasks/public/postcss.js +0 -16
- package/tslib/tasks/public/publish.js +0 -50
- package/tslib/tasks/public/pwa.js +0 -87
- package/tslib/tasks/public/remove.js +0 -44
- package/tslib/tasks/public/replace.js +0 -27
- package/tslib/tasks/public/rollup.js +0 -17
- package/tslib/tasks/public/sass.js +0 -27
- package/tslib/tasks/public/server.js +0 -129
- package/tslib/tasks/public/url.js +0 -35
- package/tslib/tasks/public/version.js +0 -27
- package/tslib/tasks/public/webpack.js +0 -41
- package/tslib/tasks/public/zip.js +0 -19
- package/tslib/utilities/address.js +0 -48
- package/tslib/utilities/cache-core.js +0 -57
- package/tslib/utilities/color.js +0 -33
- package/tslib/utilities/compiling.js +0 -16
- package/tslib/utilities/detect-port.js +0 -91
- package/tslib/utilities/escape-string-regexp.js +0 -7
- package/tslib/utilities/file.js +0 -78
- package/tslib/utilities/index.js +0 -8
- package/tslib/utilities/loading.js +0 -25
- package/tslib/utilities/logger.js +0 -92
- package/tslib/utilities/merge-stream.js +0 -34
- package/tslib/utilities/namespace.js +0 -12
- package/tslib/utilities/public-url.js +0 -31
- package/tslib/utilities/replacestream.js +0 -112
- package/tslib/utilities/typeof.js +0 -8
- package/tslib/utilities/utils.js +0 -38
package/lib/tasks/public/url.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
|
|
2
|
-
function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
|
|
3
|
-
function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
|
|
4
|
-
function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
|
|
5
|
-
var _urlProcessing = /*#__PURE__*/new WeakMap();
|
|
6
|
-
class UrlTask extends BalmJS.BalmTask {
|
|
7
|
-
constructor() {
|
|
8
|
-
super('url');
|
|
9
|
-
_classPrivateFieldInitSpec(this, _urlProcessing, type => {
|
|
10
|
-
const pattern = BalmJS.config.paths.source[type].split('/').pop();
|
|
11
|
-
const pathSrc = new RegExp(`\\.{2}/${pattern}/`, 'g');
|
|
12
|
-
const pathDest = `../${BalmJS.config.paths.target[type]}/`;
|
|
13
|
-
BalmJS.logger.debug(`${this.name} task`, {
|
|
14
|
-
regex: pathSrc,
|
|
15
|
-
replacement: pathDest
|
|
16
|
-
}, {
|
|
17
|
-
pre: true
|
|
18
|
-
});
|
|
19
|
-
return BalmJS.plugins.replace(pathSrc, pathDest);
|
|
20
|
-
});
|
|
21
|
-
this.defaultOutput = BalmJS.config.dest.css;
|
|
22
|
-
this.defaultInput = BalmJS.file.matchAllFiles(this.defaultOutput, '*.css');
|
|
23
|
-
}
|
|
24
|
-
recipe(input, output) {
|
|
25
|
-
const balmUrl = () => {
|
|
26
|
-
this.init(input, output);
|
|
27
|
-
return this.src.pipe(_classPrivateFieldGet(_urlProcessing, this).call(this, 'img')).pipe(_classPrivateFieldGet(_urlProcessing, this).call(this, 'font')).pipe(gulp.dest(this.output));
|
|
28
|
-
};
|
|
29
|
-
return balmUrl;
|
|
30
|
-
}
|
|
31
|
-
get fn() {
|
|
32
|
-
return this.recipe();
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
export default UrlTask;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import revAll from 'gulp-rev-all';
|
|
2
|
-
class VersionTask extends BalmJS.BalmTask {
|
|
3
|
-
constructor() {
|
|
4
|
-
super('version');
|
|
5
|
-
this.defaultOutput = BalmJS.config.dest.base;
|
|
6
|
-
}
|
|
7
|
-
get options() {
|
|
8
|
-
return Object.assign({}, BalmJS.config.assets.options, this.customOptions);
|
|
9
|
-
}
|
|
10
|
-
recipe(input, output, assetsOptions) {
|
|
11
|
-
const balmVersion = () => {
|
|
12
|
-
this.init(input, output, {
|
|
13
|
-
version: assetsOptions
|
|
14
|
-
});
|
|
15
|
-
return this.src.pipe(revAll.revision(this.options)).pipe(gulp.dest(this.output)).pipe(revAll.versionFile()).pipe(gulp.dest(this.output));
|
|
16
|
-
};
|
|
17
|
-
return balmVersion;
|
|
18
|
-
}
|
|
19
|
-
fn(callback) {
|
|
20
|
-
callback();
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
export default VersionTask;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { webpack, webpackConfig } from '../../bundler/webpack/index.js';
|
|
2
|
-
import compiling from '../../utilities/compiling.js';
|
|
3
|
-
class WebpackTask extends BalmJS.BalmTask {
|
|
4
|
-
constructor() {
|
|
5
|
-
super('webpack');
|
|
6
|
-
}
|
|
7
|
-
recipe(input, output, customOptions = {}, fn) {
|
|
8
|
-
const balmBundler = callback => {
|
|
9
|
-
this.init(input || BalmJS.config.scripts.entry, output);
|
|
10
|
-
const isHook = !!input;
|
|
11
|
-
compiling.start();
|
|
12
|
-
BalmJS.webpackCompiler = webpack(webpackConfig(this.input, this.output, customOptions, isHook), (error, stats) => {
|
|
13
|
-
compiling.stop();
|
|
14
|
-
try {
|
|
15
|
-
const scriptLogLevel = stats.hasErrors() ? BalmJS.LogLevel.Error : stats.hasWarnings() ? BalmJS.LogLevel.Warn : BalmJS.LogLevel.Info;
|
|
16
|
-
if (BalmJS.config.logs.level <= scriptLogLevel) {
|
|
17
|
-
console.log(stats.toString(BalmJS.config.scripts.stats));
|
|
18
|
-
}
|
|
19
|
-
} catch (e) {
|
|
20
|
-
// Handle errors here
|
|
21
|
-
BalmJS.logger.error(`${this.name} task`, error.stack || error);
|
|
22
|
-
if (error.details) {
|
|
23
|
-
BalmJS.logger.error(`${this.name} task`, error.details);
|
|
24
|
-
}
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
fn && fn();
|
|
28
|
-
|
|
29
|
-
// Done processing
|
|
30
|
-
callback();
|
|
31
|
-
});
|
|
32
|
-
};
|
|
33
|
-
return balmBundler;
|
|
34
|
-
}
|
|
35
|
-
get fn() {
|
|
36
|
-
return this.recipe();
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
export default WebpackTask;
|
package/lib/tasks/public/zip.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import zip from 'gulp-zip';
|
|
2
|
-
class ZipTask extends BalmJS.BalmTask {
|
|
3
|
-
constructor() {
|
|
4
|
-
super('zip');
|
|
5
|
-
this.defaultInput = BalmJS.file.matchAllFiles(BalmJS.config.roots.target);
|
|
6
|
-
this.defaultOutput = '.';
|
|
7
|
-
}
|
|
8
|
-
recipe(input, output, filename = 'archive.zip') {
|
|
9
|
-
const balmZip = () => {
|
|
10
|
-
this.init(input, output);
|
|
11
|
-
return this.src.pipe(zip(filename)).pipe(gulp.dest(this.output));
|
|
12
|
-
};
|
|
13
|
-
return balmZip;
|
|
14
|
-
}
|
|
15
|
-
fn(callback) {
|
|
16
|
-
callback();
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
export default ZipTask;
|
package/lib/utilities/address.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import os from 'node:os';
|
|
2
|
-
const platform = os.platform();
|
|
3
|
-
|
|
4
|
-
// Get interface name, default is 'eth' on linux, 'en' on mac os.
|
|
5
|
-
function getInterfaceName() {
|
|
6
|
-
let val = 'eth';
|
|
7
|
-
if (platform === 'darwin') {
|
|
8
|
-
val = 'en';
|
|
9
|
-
} else if (platform === 'win32') {
|
|
10
|
-
val = null;
|
|
11
|
-
}
|
|
12
|
-
return val;
|
|
13
|
-
}
|
|
14
|
-
function getInterface(family) {
|
|
15
|
-
const interfaces = os.networkInterfaces();
|
|
16
|
-
const name = getInterfaceName();
|
|
17
|
-
family = family || 'IPv4';
|
|
18
|
-
for (let i = -1; i < 8; i++) {
|
|
19
|
-
const interfaceName = `${name}${i >= 0 ? i : ''}`; // support 'lo' and 'lo0'
|
|
20
|
-
const items = interfaces[interfaceName];
|
|
21
|
-
if (items) {
|
|
22
|
-
for (let j = 0, len = items.length; j < len; j++) {
|
|
23
|
-
const item = items[j];
|
|
24
|
-
if (item.family === family) {
|
|
25
|
-
return item;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// (no interface name) filter 127.0.0.1, get the first ip
|
|
32
|
-
for (const k in interfaces) {
|
|
33
|
-
const items = interfaces[k];
|
|
34
|
-
if (items) {
|
|
35
|
-
for (let i = 0, len = items.length; i < len; i++) {
|
|
36
|
-
const item = items[i];
|
|
37
|
-
if (item.family === family && item.address !== '127.0.0.1') {
|
|
38
|
-
return item;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Get current machine IPv4
|
|
48
|
-
*/
|
|
49
|
-
function ip() {
|
|
50
|
-
const item = getInterface('IPv4');
|
|
51
|
-
return item && item.address;
|
|
52
|
-
}
|
|
53
|
-
export default {
|
|
54
|
-
ip
|
|
55
|
-
};
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import Module from 'node:module';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { homedir } from 'node:os';
|
|
4
|
-
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
5
|
-
import loading from './loading.js';
|
|
6
|
-
const _require = Module.prototype.require;
|
|
7
|
-
const SAVE_FILE = path.join(homedir(), process.env.BALM_CORE_CACHE || '.balm-core-cache.json');
|
|
8
|
-
function cacheBalmCore() {
|
|
9
|
-
let nameCache;
|
|
10
|
-
let originLastFilename;
|
|
11
|
-
try {
|
|
12
|
-
nameCache = existsSync(SAVE_FILE) ? JSON.parse(readFileSync(SAVE_FILE, 'utf-8')) : {};
|
|
13
|
-
originLastFilename = nameCache.lastFilename || '';
|
|
14
|
-
} catch (err) {
|
|
15
|
-
nameCache = {};
|
|
16
|
-
}
|
|
17
|
-
let currentModuleCache;
|
|
18
|
-
let pathToLoad;
|
|
19
|
-
Module.prototype.require = function cachePathsRequire(name) {
|
|
20
|
-
currentModuleCache = nameCache[this.filename];
|
|
21
|
-
if (!currentModuleCache) {
|
|
22
|
-
currentModuleCache = {};
|
|
23
|
-
if (/\/balm-core\//.test(this.filename)) {
|
|
24
|
-
nameCache[this.filename] = currentModuleCache;
|
|
25
|
-
nameCache.lastFilename = this.filename;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
if (currentModuleCache[name] &&
|
|
29
|
-
// Some people hack Object.prototype to insert their own properties on
|
|
30
|
-
// every dictionary (for example, the 'should' testing framework). Check
|
|
31
|
-
// that the key represents a path.
|
|
32
|
-
typeof currentModuleCache[name] === 'string' && existsSync(currentModuleCache[name]) // the file must exist for a cache hit
|
|
33
|
-
) {
|
|
34
|
-
pathToLoad = currentModuleCache[name];
|
|
35
|
-
} else {
|
|
36
|
-
pathToLoad = Module._resolveFilename(name, this);
|
|
37
|
-
currentModuleCache[name] = pathToLoad;
|
|
38
|
-
}
|
|
39
|
-
if (BalmJS.loading) {
|
|
40
|
-
loading.render();
|
|
41
|
-
}
|
|
42
|
-
return _require.call(this, pathToLoad);
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
// function printCache() {
|
|
46
|
-
// Object.keys(nameCache).forEach(function (fromFilename) {
|
|
47
|
-
// console.log(fromFilename);
|
|
48
|
-
// const moduleCache = nameCache[fromFilename];
|
|
49
|
-
// Object.keys(moduleCache).forEach(function (name) {
|
|
50
|
-
// console.log(' ', name, '->', moduleCache[name]);
|
|
51
|
-
// });
|
|
52
|
-
// });
|
|
53
|
-
// }
|
|
54
|
-
|
|
55
|
-
BalmJS.emitter.once('exit', function () {
|
|
56
|
-
if (nameCache.lastFilename !== originLastFilename) {
|
|
57
|
-
try {
|
|
58
|
-
writeFileSync(SAVE_FILE, JSON.stringify(nameCache, null, 2), 'utf-8');
|
|
59
|
-
} catch (error) {
|
|
60
|
-
const err = error;
|
|
61
|
-
console.error(`BalmJS: Failed saving cache: ${err.toString()}`);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
export default cacheBalmCore;
|
package/lib/utilities/color.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import ansiColors from 'ansi-colors';
|
|
2
|
-
const COLOR = {
|
|
3
|
-
PREFIX: 'bg',
|
|
4
|
-
SUFFIX: 'Bright'
|
|
5
|
-
};
|
|
6
|
-
function getStyle(colorStyle = {
|
|
7
|
-
color: 'white'
|
|
8
|
-
}) {
|
|
9
|
-
const color = colorStyle.color.toLowerCase();
|
|
10
|
-
let fn = colorStyle.background ? COLOR.PREFIX + color.replace(/^[a-z]/, str => str.toUpperCase()) : color;
|
|
11
|
-
if (colorStyle.bright) {
|
|
12
|
-
fn += COLOR.SUFFIX;
|
|
13
|
-
}
|
|
14
|
-
const colors = ansiColors;
|
|
15
|
-
const render = colorStyle.modifier ? colors[colorStyle.modifier][fn] : colors[fn];
|
|
16
|
-
const symbols = ansiColors.symbols;
|
|
17
|
-
const icon = colorStyle.symbol && symbols[colorStyle.symbol] ? `${symbols[colorStyle.symbol]} ` : '';
|
|
18
|
-
return {
|
|
19
|
-
icon,
|
|
20
|
-
render
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
function color(label, colorStyle) {
|
|
24
|
-
const result = getStyle(colorStyle);
|
|
25
|
-
return result.render(`${result.icon}${label}`);
|
|
26
|
-
}
|
|
27
|
-
export default color;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
|
|
2
|
-
function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
|
|
3
|
-
function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
|
|
4
|
-
function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
|
|
5
|
-
function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
|
|
6
|
-
import loading from './loading.js';
|
|
7
|
-
var _firstCompile = /*#__PURE__*/new WeakMap();
|
|
8
|
-
class BalmCompiling {
|
|
9
|
-
constructor() {
|
|
10
|
-
_classPrivateFieldInitSpec(this, _firstCompile, true);
|
|
11
|
-
}
|
|
12
|
-
start() {
|
|
13
|
-
if (!BalmJS.useCacache && _classPrivateFieldGet(_firstCompile, this)) {
|
|
14
|
-
loading.render('Compiling to JS...');
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
stop() {
|
|
18
|
-
if (!BalmJS.useCacache && _classPrivateFieldGet(_firstCompile, this)) {
|
|
19
|
-
_classPrivateFieldSet(_firstCompile, this, false);
|
|
20
|
-
loading.clear();
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
export default new BalmCompiling();
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import net from 'node:net';
|
|
2
|
-
import address from './address.js';
|
|
3
|
-
const UTIL_NAME = 'detect port';
|
|
4
|
-
const MAX_PORT = 65535;
|
|
5
|
-
function listen(port, host, callback) {
|
|
6
|
-
const server = new net.Server();
|
|
7
|
-
server.on('error', error => {
|
|
8
|
-
server.close();
|
|
9
|
-
if (error.code === 'ENOTFOUND') {
|
|
10
|
-
BalmJS.logger.error(UTIL_NAME, `ignore dns ENOTFOUND error, get free ${host}:${port}`, {
|
|
11
|
-
logLevel: BalmJS.LogLevel.Debug
|
|
12
|
-
});
|
|
13
|
-
return callback(null, port);
|
|
14
|
-
}
|
|
15
|
-
return callback(error);
|
|
16
|
-
});
|
|
17
|
-
server.listen(port, host, () => {
|
|
18
|
-
port = server.address().port;
|
|
19
|
-
server.close();
|
|
20
|
-
BalmJS.logger.debug(UTIL_NAME, `get free ${host}:${port}`);
|
|
21
|
-
return callback(null, port);
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
function tryListen(port, maxPort, host, callback) {
|
|
25
|
-
function handleError(err) {
|
|
26
|
-
if (err) {
|
|
27
|
-
BalmJS.logger.error(UTIL_NAME, err.message, {
|
|
28
|
-
logLevel: BalmJS.LogLevel.Debug
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
port++;
|
|
32
|
-
if (port >= maxPort) {
|
|
33
|
-
BalmJS.logger.warn(UTIL_NAME, `port: ${port} >= maxPort: ${maxPort}, give up and use random port`, {
|
|
34
|
-
logLevel: BalmJS.LogLevel.Debug
|
|
35
|
-
});
|
|
36
|
-
port = 0;
|
|
37
|
-
maxPort = 0;
|
|
38
|
-
}
|
|
39
|
-
tryListen(port, maxPort, host, callback);
|
|
40
|
-
}
|
|
41
|
-
if (host) {
|
|
42
|
-
listen(port, host, (error, realPort) => {
|
|
43
|
-
if (error) {
|
|
44
|
-
if (error.code === 'EADDRNOTAVAIL') {
|
|
45
|
-
return callback(new Error('the ip that is not unkonwn on the machine'));
|
|
46
|
-
}
|
|
47
|
-
return handleError();
|
|
48
|
-
}
|
|
49
|
-
callback(null, realPort);
|
|
50
|
-
});
|
|
51
|
-
} else {
|
|
52
|
-
// 1. check null
|
|
53
|
-
listen(port, null, (error, realPort) => {
|
|
54
|
-
// ignore random listening
|
|
55
|
-
if (port === 0) {
|
|
56
|
-
return callback(error, realPort);
|
|
57
|
-
}
|
|
58
|
-
if (error) {
|
|
59
|
-
return handleError(error);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// 2. check 0.0.0.0
|
|
63
|
-
listen(port, '0.0.0.0', error => {
|
|
64
|
-
if (error) {
|
|
65
|
-
return handleError(error);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// 3. check localhost
|
|
69
|
-
listen(port, 'localhost', error => {
|
|
70
|
-
// if localhost refer to the ip that is not unkonwn on the machine, you will see the error EADDRNOTAVAIL
|
|
71
|
-
// https://stackoverflow.com/questions/10809740/listen-eaddrnotavail-error-in-node-js
|
|
72
|
-
if (error && error.code !== 'EADDRNOTAVAIL') {
|
|
73
|
-
return handleError(error);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// 4. check current ip
|
|
77
|
-
listen(port, address.ip(), (error, realPort) => {
|
|
78
|
-
if (error) {
|
|
79
|
-
return handleError(error);
|
|
80
|
-
}
|
|
81
|
-
callback(null, realPort);
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
function detectPort(port, host) {
|
|
89
|
-
let maxPort = port + 10;
|
|
90
|
-
if (maxPort > MAX_PORT) {
|
|
91
|
-
maxPort = MAX_PORT;
|
|
92
|
-
}
|
|
93
|
-
BalmJS.logger.debug(UTIL_NAME, `detect free port between [${port}, ${maxPort}]`);
|
|
94
|
-
return new Promise(resolve => {
|
|
95
|
-
tryListen(port, maxPort, host, (error, realPort) => {
|
|
96
|
-
resolve(realPort);
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
export default detectPort;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
const escapeStringRegexp = str => {
|
|
2
|
-
if (typeof str !== 'string') {
|
|
3
|
-
throw new TypeError('Expected a string');
|
|
4
|
-
}
|
|
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
|
-
return str.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&').replace(/-/g, '\\x2d');
|
|
9
|
-
};
|
|
10
|
-
export default escapeStringRegexp;
|
package/lib/utilities/file.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import getPublicUrlOrPath from './public-url.js';
|
|
2
|
-
import { PUBLIC_URL } from '../config/constants.js';
|
|
3
|
-
|
|
4
|
-
// Make sure any symlinks in the project folder are resolved
|
|
5
|
-
const appDirectory = node.fs.realpathSync(process.cwd());
|
|
6
|
-
class File {
|
|
7
|
-
resolveApp(relativePath) {
|
|
8
|
-
return node.path.resolve(appDirectory, relativePath);
|
|
9
|
-
}
|
|
10
|
-
get publicUrlOrPath() {
|
|
11
|
-
// We use `PUBLIC_URL` environment variable or "homepage" field to infer
|
|
12
|
-
// "public path" at which the app is served.
|
|
13
|
-
// webpack needs to know it to put the right <script> hrefs into HTML even in
|
|
14
|
-
// single-page apps that may serve index.html for nested URLs like /todos/42.
|
|
15
|
-
// We can't use a relative path in HTML because we don't want to load something
|
|
16
|
-
// like /todos/42/static/js/bundle.7289d.js. We have to know the root.
|
|
17
|
-
return getPublicUrlOrPath(requireModule(this.resolveApp('package.json')).homepage, process.env.PUBLIC_URL);
|
|
18
|
-
}
|
|
19
|
-
get stylePaths() {
|
|
20
|
-
return [node.path.resolve(BalmJS.config.workspace, '.'), node.path.resolve(BalmJS.config.workspace, 'node_modules'), ...BalmJS.config.styles.atImportPaths];
|
|
21
|
-
}
|
|
22
|
-
get assetsSuffixPath() {
|
|
23
|
-
return !BalmJS.config.inFrontend && BalmJS.config.env.isProd && BalmJS.config.assets.cache // Back-end project in production with cache
|
|
24
|
-
? node.path.join(BalmJS.config.assets.subDir, BalmJS.config.assets.buildDir) : BalmJS.config.assets.subDir;
|
|
25
|
-
}
|
|
26
|
-
get defaultEntry() {
|
|
27
|
-
return node.path.join(BalmJS.config.src.js, 'index.js');
|
|
28
|
-
}
|
|
29
|
-
get templateBasePath() {
|
|
30
|
-
return BalmJS.config.scripts.injectHtml ? BalmJS.config.src.base : BalmJS.config.src.html;
|
|
31
|
-
}
|
|
32
|
-
absPath(_path) {
|
|
33
|
-
return node.path.resolve(BalmJS.config.workspace, _path);
|
|
34
|
-
}
|
|
35
|
-
absPaths(_paths) {
|
|
36
|
-
let paths;
|
|
37
|
-
if (BalmJS.utils.isArray(_paths)) {
|
|
38
|
-
paths = [];
|
|
39
|
-
for (const _path of _paths) {
|
|
40
|
-
const result = /^!(.+)$/.exec(_path);
|
|
41
|
-
if (result) {
|
|
42
|
-
paths.push('!' + this.absPath(result[1]));
|
|
43
|
-
} else {
|
|
44
|
-
paths.push(this.absPath(_path));
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
} else {
|
|
48
|
-
paths = this.absPath(_paths);
|
|
49
|
-
}
|
|
50
|
-
return paths;
|
|
51
|
-
}
|
|
52
|
-
matchAllFiles(_path, _file) {
|
|
53
|
-
return node.path.join(_path, '**', _file || '*');
|
|
54
|
-
}
|
|
55
|
-
assetsPath(_path) {
|
|
56
|
-
return BalmJS.config.env.isProd || !BalmJS.config.inFrontend ? node.path.posix.join(BalmJS.config.assets.virtualDir, this.assetsSuffixPath, _path) : _path;
|
|
57
|
-
}
|
|
58
|
-
setPublicPath() {
|
|
59
|
-
const publicPathSrc = `${PUBLIC_URL}/`;
|
|
60
|
-
const publicPathDest = BalmJS.config.env.inDesktopApp ? `.${this.publicUrlOrPath}` : this.publicUrlOrPath;
|
|
61
|
-
BalmJS.logger.debug(`set public path`, {
|
|
62
|
-
regex: publicPathSrc,
|
|
63
|
-
replacement: publicPathDest
|
|
64
|
-
}, {
|
|
65
|
-
pre: true
|
|
66
|
-
});
|
|
67
|
-
return BalmJS.plugins.replace(publicPathSrc, publicPathDest);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
export default new File();
|
package/lib/utilities/index.js
DELETED
package/lib/utilities/loading.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
|
|
2
|
-
function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
|
|
3
|
-
function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
|
|
4
|
-
function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
|
|
5
|
-
function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
|
|
6
|
-
import readline from 'readline';
|
|
7
|
-
import spinner from '../config/spinner.js';
|
|
8
|
-
var _stream = /*#__PURE__*/new WeakMap();
|
|
9
|
-
var _frameIndex = /*#__PURE__*/new WeakMap();
|
|
10
|
-
var _frameCount = /*#__PURE__*/new WeakMap();
|
|
11
|
-
class BalmLoading {
|
|
12
|
-
constructor() {
|
|
13
|
-
_classPrivateFieldInitSpec(this, _stream, process.stderr);
|
|
14
|
-
_classPrivateFieldInitSpec(this, _frameIndex, 0);
|
|
15
|
-
_classPrivateFieldInitSpec(this, _frameCount, spinner.frames.length);
|
|
16
|
-
}
|
|
17
|
-
get frame() {
|
|
18
|
-
var _this$frameIndex;
|
|
19
|
-
const currentFrame = spinner.frames[_classPrivateFieldGet(_frameIndex, this)];
|
|
20
|
-
_classPrivateFieldSet(_frameIndex, this, _classPrivateFieldSet(_frameIndex, this, (_this$frameIndex = _classPrivateFieldGet(_frameIndex, this), ++_this$frameIndex)) % _classPrivateFieldGet(_frameCount, this));
|
|
21
|
-
return currentFrame;
|
|
22
|
-
}
|
|
23
|
-
clear() {
|
|
24
|
-
// Compatibility on Windows
|
|
25
|
-
readline.clearLine(_classPrivateFieldGet(_stream, this), 0);
|
|
26
|
-
readline.cursorTo(_classPrivateFieldGet(_stream, this), 0);
|
|
27
|
-
}
|
|
28
|
-
render(text = `${this.frame} BalmJS is initializing...`) {
|
|
29
|
-
this.clear();
|
|
30
|
-
_classPrivateFieldGet(_stream, this).write(text);
|
|
31
|
-
}
|
|
32
|
-
succeed() {
|
|
33
|
-
this.clear();
|
|
34
|
-
console.log(`BalmJS core version: ${BalmJS.version}`);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
export default new BalmLoading();
|
package/lib/utilities/logger.js
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
|
|
2
|
-
function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
|
|
3
|
-
function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
|
|
4
|
-
function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
|
|
5
|
-
import util from 'node:util';
|
|
6
|
-
import fancyLog from 'fancy-log';
|
|
7
|
-
import color from './color.js';
|
|
8
|
-
const LOG = {
|
|
9
|
-
FORMAT: '%s %s %s',
|
|
10
|
-
PREFIX: color('BalmJS', {
|
|
11
|
-
color: 'blue',
|
|
12
|
-
background: true,
|
|
13
|
-
bright: true
|
|
14
|
-
}),
|
|
15
|
-
OK: {
|
|
16
|
-
color: 'green',
|
|
17
|
-
bright: true,
|
|
18
|
-
symbol: 'check'
|
|
19
|
-
},
|
|
20
|
-
DEBUG: {
|
|
21
|
-
color: 'blue',
|
|
22
|
-
bright: true,
|
|
23
|
-
symbol: 'mark'
|
|
24
|
-
},
|
|
25
|
-
INFO: {
|
|
26
|
-
color: 'cyan',
|
|
27
|
-
bright: true,
|
|
28
|
-
symbol: 'info'
|
|
29
|
-
},
|
|
30
|
-
WARN: {
|
|
31
|
-
color: 'yellow',
|
|
32
|
-
bright: true,
|
|
33
|
-
symbol: 'warning'
|
|
34
|
-
},
|
|
35
|
-
ERROR: {
|
|
36
|
-
color: 'red',
|
|
37
|
-
bright: true,
|
|
38
|
-
symbol: 'cross'
|
|
39
|
-
},
|
|
40
|
-
beginning: '$'.padStart(36, '*'),
|
|
41
|
-
end: '^'.padEnd(36, '.')
|
|
42
|
-
};
|
|
43
|
-
var _log = /*#__PURE__*/new WeakMap();
|
|
44
|
-
class Logger {
|
|
45
|
-
constructor() {
|
|
46
|
-
_classPrivateFieldInitSpec(this, _log, (obj, pre = false) => {
|
|
47
|
-
const options = Object.assign({
|
|
48
|
-
showHidden: false,
|
|
49
|
-
depth: 2,
|
|
50
|
-
colors: true
|
|
51
|
-
}, BalmJS.config.logs.formatOptions);
|
|
52
|
-
return pre ? util.inspect(obj, options) : obj;
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
success(label, message, options = {}) {
|
|
56
|
-
const logOptions = Object.assign({
|
|
57
|
-
logLevel: BalmJS.LogLevel.Trace
|
|
58
|
-
}, options);
|
|
59
|
-
if (BalmJS.config.logs.level <= logOptions.logLevel) {
|
|
60
|
-
console.log(LOG.beginning);
|
|
61
|
-
fancyLog(LOG.FORMAT, LOG.PREFIX, color(`<${label}>`, LOG.OK), _classPrivateFieldGet(_log, this).call(this, message, logOptions.pre));
|
|
62
|
-
console.log(LOG.end);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
debug(label, message, options = {}) {
|
|
66
|
-
const logOptions = Object.assign({
|
|
67
|
-
logLevel: BalmJS.LogLevel.Debug
|
|
68
|
-
}, options);
|
|
69
|
-
if (BalmJS.config.logs.level <= logOptions.logLevel) {
|
|
70
|
-
fancyLog.info(LOG.FORMAT, LOG.PREFIX, color(`<${label}>`, LOG.DEBUG), _classPrivateFieldGet(_log, this).call(this, message, logOptions.pre));
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
info(label, message, options = {}) {
|
|
74
|
-
const logOptions = Object.assign({
|
|
75
|
-
logLevel: BalmJS.LogLevel.Info
|
|
76
|
-
}, options);
|
|
77
|
-
if (BalmJS.config.logs.level <= logOptions.logLevel) {
|
|
78
|
-
fancyLog.info(LOG.FORMAT, LOG.PREFIX, color(`<${label}>`, LOG.INFO), _classPrivateFieldGet(_log, this).call(this, message, logOptions.pre));
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
warn(label, message, options = {}) {
|
|
82
|
-
const logOptions = Object.assign({
|
|
83
|
-
logLevel: BalmJS.LogLevel.Warn
|
|
84
|
-
}, options);
|
|
85
|
-
if (BalmJS.config.logs.level <= logOptions.logLevel) {
|
|
86
|
-
fancyLog.warn(LOG.FORMAT, LOG.PREFIX, color(`<${label}>`, LOG.WARN), _classPrivateFieldGet(_log, this).call(this, message, logOptions.pre));
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
error(label, message, options = {}) {
|
|
90
|
-
const logOptions = Object.assign({
|
|
91
|
-
logLevel: BalmJS.LogLevel.Error,
|
|
92
|
-
pre: false
|
|
93
|
-
}, options);
|
|
94
|
-
if (BalmJS.config.logs.level <= logOptions.logLevel) {
|
|
95
|
-
fancyLog.error(LOG.FORMAT, LOG.PREFIX, color(`<${label}>`, LOG.ERROR), _classPrivateFieldGet(_log, this).call(this, message, logOptions.pre));
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
export default new Logger();
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { PassThrough } from 'node:stream';
|
|
2
|
-
function mergeStream(...args) {
|
|
3
|
-
let sources = [];
|
|
4
|
-
const output = new PassThrough({
|
|
5
|
-
objectMode: true
|
|
6
|
-
});
|
|
7
|
-
output.setMaxListeners(0);
|
|
8
|
-
function remove(source) {
|
|
9
|
-
sources = sources.filter(it => {
|
|
10
|
-
return it !== source;
|
|
11
|
-
});
|
|
12
|
-
if (!sources.length && output.readable) {
|
|
13
|
-
output.end();
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
function add(source) {
|
|
17
|
-
if (Array.isArray(source)) {
|
|
18
|
-
source.forEach(add);
|
|
19
|
-
return this;
|
|
20
|
-
}
|
|
21
|
-
sources.push(source);
|
|
22
|
-
source.once('end', remove.bind(null, source));
|
|
23
|
-
source.once('error', output.emit.bind(output, 'error'));
|
|
24
|
-
source.pipe(output, {
|
|
25
|
-
end: false
|
|
26
|
-
});
|
|
27
|
-
return this;
|
|
28
|
-
}
|
|
29
|
-
function isEmpty() {
|
|
30
|
-
return sources.length == 0;
|
|
31
|
-
}
|
|
32
|
-
output.add = add;
|
|
33
|
-
output.isEmpty = isEmpty;
|
|
34
|
-
output.on('unpipe', remove);
|
|
35
|
-
[...args].slice().forEach(add);
|
|
36
|
-
return output;
|
|
37
|
-
}
|
|
38
|
-
export default mergeStream;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
const NAMESPACE = 'balm';
|
|
2
|
-
function toNamespace(taskName) {
|
|
3
|
-
let result = 'unknown';
|
|
4
|
-
if (BalmJS.utils.isArray(taskName)) {
|
|
5
|
-
result = taskName.map(name => `${NAMESPACE}:${name}`);
|
|
6
|
-
} else {
|
|
7
|
-
result = `${NAMESPACE}:${taskName}`;
|
|
8
|
-
}
|
|
9
|
-
return result;
|
|
10
|
-
}
|
|
11
|
-
export default toNamespace;
|