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
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
// Reference `gulp-sass@5.1.0`
|
|
2
|
-
import { Transform } from 'node:stream';
|
|
3
|
-
import * as sass from 'sass';
|
|
4
|
-
import replaceExtension from 'replace-ext';
|
|
5
|
-
import stripAnsi from 'strip-ansi';
|
|
6
|
-
import applySourceMap from 'vinyl-sourcemaps-apply';
|
|
7
|
-
import ansiColors from 'ansi-colors';
|
|
8
|
-
const sassModule = node.getSassModule(sass);
|
|
9
|
-
const PLUGIN_NAME = 'sass-legacy';
|
|
10
|
-
const transformObj = transform => new Transform({
|
|
11
|
-
transform,
|
|
12
|
-
objectMode: true
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Handles returning the file to the stream
|
|
17
|
-
*/
|
|
18
|
-
function filePush(file, sassObject, callback) {
|
|
19
|
-
// Build Source Maps!
|
|
20
|
-
if (sassObject.map) {
|
|
21
|
-
// Transform map into JSON
|
|
22
|
-
const sassMap = JSON.parse(sassObject.map.toString());
|
|
23
|
-
// Grab the stdout and transform it into stdin
|
|
24
|
-
const sassMapFile = sassMap.file.replace(/^stdout$/, 'stdin');
|
|
25
|
-
// Grab the base filename that's being worked on
|
|
26
|
-
const sassFileSrc = file.relative;
|
|
27
|
-
// Grab the path portion of the file that's being worked on
|
|
28
|
-
const sassFileSrcPath = node.path.dirname(sassFileSrc);
|
|
29
|
-
if (sassFileSrcPath) {
|
|
30
|
-
const sourceFileIndex = sassMap.sources.indexOf(sassMapFile);
|
|
31
|
-
// Prepend the path to all files in the sources array except the file that's being worked on
|
|
32
|
-
sassMap.sources = sassMap.sources.map((source, index) => index === sourceFileIndex ? source : node.path.join(sassFileSrcPath, source));
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// Remove 'stdin' from sources and replace with filenames!
|
|
36
|
-
sassMap.sources = sassMap.sources.filter(src => src !== 'stdin' && src);
|
|
37
|
-
|
|
38
|
-
// Replace the map file with the original filename (but new extension)
|
|
39
|
-
sassMap.file = replaceExtension(sassFileSrc, '.css');
|
|
40
|
-
// Apply the map
|
|
41
|
-
applySourceMap(file, sassMap);
|
|
42
|
-
}
|
|
43
|
-
file.contents = sassObject.css;
|
|
44
|
-
file.path = replaceExtension(file.path, '.css');
|
|
45
|
-
if (file.stat) {
|
|
46
|
-
file.stat.atime = file.stat.mtime = file.stat.ctime = new Date();
|
|
47
|
-
}
|
|
48
|
-
callback(null, file);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Handles error message
|
|
53
|
-
*/
|
|
54
|
-
function handleError(error, file, callback) {
|
|
55
|
-
const filePath = (error.file === 'stdin' ? file.path : error.file) || file.path;
|
|
56
|
-
const relativePath = node.path.relative(process.cwd(), filePath);
|
|
57
|
-
const message = `${ansiColors.underline(relativePath)}\n${error.formatted}`;
|
|
58
|
-
error.messageFormatted = message;
|
|
59
|
-
error.messageOriginal = error.message;
|
|
60
|
-
error.message = stripAnsi(message);
|
|
61
|
-
error.relativePath = relativePath;
|
|
62
|
-
return callback(new PluginError(PLUGIN_NAME, error));
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
//////////////////////////////
|
|
66
|
-
// Main Gulp Sass function
|
|
67
|
-
//////////////////////////////
|
|
68
|
-
const gulpSass = (options, sync = false) => transformObj((file, encoding, callback) => {
|
|
69
|
-
if (file.isNull()) {
|
|
70
|
-
return callback(null, file);
|
|
71
|
-
}
|
|
72
|
-
if (file.isStream()) {
|
|
73
|
-
return callback(new PluginError(PLUGIN_NAME, 'Streaming not supported'));
|
|
74
|
-
}
|
|
75
|
-
if (node.path.basename(file.path).startsWith('_')) {
|
|
76
|
-
return callback();
|
|
77
|
-
}
|
|
78
|
-
if (!file.contents.length) {
|
|
79
|
-
file.path = replaceExtension(file.path, '.css');
|
|
80
|
-
return callback(null, file);
|
|
81
|
-
}
|
|
82
|
-
const opts = options || {};
|
|
83
|
-
opts.data = file.contents.toString();
|
|
84
|
-
|
|
85
|
-
// We set the file path here so that libsass can correctly resolve import paths
|
|
86
|
-
opts.file = file.path;
|
|
87
|
-
|
|
88
|
-
// Ensure `indentedSyntax` is true if a `.sass` file
|
|
89
|
-
if (node.path.extname(file.path) === '.sass') {
|
|
90
|
-
opts.indentedSyntax = true;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// Ensure file's parent directory in the include path
|
|
94
|
-
if (opts.includePaths) {
|
|
95
|
-
if (typeof opts.includePaths === 'string') {
|
|
96
|
-
opts.includePaths = [opts.includePaths];
|
|
97
|
-
}
|
|
98
|
-
} else {
|
|
99
|
-
opts.includePaths = [];
|
|
100
|
-
}
|
|
101
|
-
opts.includePaths.unshift(node.path.dirname(file.path));
|
|
102
|
-
|
|
103
|
-
// Generate Source Maps if the source-map plugin is present
|
|
104
|
-
if (file.sourceMap) {
|
|
105
|
-
opts.sourceMap = file.path;
|
|
106
|
-
opts.omitSourceMapUrl = true;
|
|
107
|
-
opts.sourceMapContents = true;
|
|
108
|
-
}
|
|
109
|
-
if (sync !== true) {
|
|
110
|
-
/**
|
|
111
|
-
* Async Sass render
|
|
112
|
-
*/
|
|
113
|
-
sassModule.render(opts, (error, obj) => {
|
|
114
|
-
if (error) {
|
|
115
|
-
handleError(error, file, callback);
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
filePush(file, obj, callback);
|
|
119
|
-
});
|
|
120
|
-
} else {
|
|
121
|
-
/**
|
|
122
|
-
* Sync Sass render
|
|
123
|
-
*/
|
|
124
|
-
try {
|
|
125
|
-
filePush(file, sassModule.renderSync(opts), callback);
|
|
126
|
-
} catch (error) {
|
|
127
|
-
handleError(error, file, callback);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
export default gulpSass;
|
package/lib/plugins/sass.js
DELETED
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
// Reference `gulp-sass@6.0.1`
|
|
2
|
-
import { Transform } from 'node:stream';
|
|
3
|
-
import * as sass from 'sass';
|
|
4
|
-
import replaceExtension from 'replace-ext';
|
|
5
|
-
import stripAnsi from 'strip-ansi';
|
|
6
|
-
import applySourceMap from 'vinyl-sourcemaps-apply';
|
|
7
|
-
import ansiColors from 'ansi-colors';
|
|
8
|
-
const sassModule = node.getSassModule(sass);
|
|
9
|
-
const PLUGIN_NAME = 'sass';
|
|
10
|
-
const transformObj = transform => new Transform({
|
|
11
|
-
transform,
|
|
12
|
-
objectMode: true
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Handles returning the file to the stream
|
|
17
|
-
*/
|
|
18
|
-
function filePush(file, result, callback) {
|
|
19
|
-
file.contents = Buffer.from(result.css);
|
|
20
|
-
file.path = replaceExtension(file.path, '.css');
|
|
21
|
-
|
|
22
|
-
// Build Source Maps!
|
|
23
|
-
if (result.sourceMap) {
|
|
24
|
-
const proto = /^file:\/\/?/;
|
|
25
|
-
const leadingSlash = /^\//;
|
|
26
|
-
const sassMap = result.sourceMap;
|
|
27
|
-
const base = node.path.resolve(file.cwd, file.base);
|
|
28
|
-
if (!sassMap.file) {
|
|
29
|
-
// Convert from absolute path to relative as in gulp-sass 5.0.0
|
|
30
|
-
sassMap.file = file.history[0].replace(base + node.path.sep, '').replace(proto, '');
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// Transform to relative file paths as in gulp-sass 5.0.0
|
|
34
|
-
sassMap.sources = sassMap.sources.map(src => {
|
|
35
|
-
// file uses Windows-style path separators, source is a URL.
|
|
36
|
-
const baseUri = base.replace(/\\/g, '/');
|
|
37
|
-
// The current file and its content is included
|
|
38
|
-
// as data:<encoded file contents> in the new Sass JS API.
|
|
39
|
-
// Map it to the original file name (first history entry).
|
|
40
|
-
if (src.startsWith('data:')) {
|
|
41
|
-
return file.history[0].replace(/\\/g, '/').replace(`${baseUri}/`, '').replace(proto, '').replace(leadingSlash, '');
|
|
42
|
-
}
|
|
43
|
-
return src.replace(proto, '').replace(`${baseUri}/`, '').replace(leadingSlash, '');
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
// Grab the base filename that's being worked on
|
|
47
|
-
const sassFileSrc = file.relative;
|
|
48
|
-
// Replace the map file with the original filename (but new extension)
|
|
49
|
-
sassMap.file = replaceExtension(sassFileSrc, '.css');
|
|
50
|
-
if (file.sourceMap && file.sourceMap.sourcesContent && !sassMap.sourcesContent) {
|
|
51
|
-
sassMap.sourcesContent = file.sourceMap.sourcesContent;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// Apply the map
|
|
55
|
-
applySourceMap(file, sassMap);
|
|
56
|
-
}
|
|
57
|
-
if (file.stat) {
|
|
58
|
-
file.stat.atime = file.stat.mtime = file.stat.ctime = new Date();
|
|
59
|
-
}
|
|
60
|
-
callback(null, file);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Handles error message
|
|
65
|
-
*/
|
|
66
|
-
function handleError(error, file, callback) {
|
|
67
|
-
const filePath = (error.file === 'stdin' ? file.path : error.file) || file.path;
|
|
68
|
-
const relativePath = node.path.relative(process.cwd(), filePath);
|
|
69
|
-
const message = `${ansiColors.underline(relativePath)}\n${error.message}`;
|
|
70
|
-
error.message = stripAnsi(message);
|
|
71
|
-
return callback(new PluginError(PLUGIN_NAME, error));
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
//////////////////////////////
|
|
75
|
-
// Main Gulp Sass function
|
|
76
|
-
//////////////////////////////
|
|
77
|
-
const gulpSass = (options, sync = false) => transformObj((file, encoding, callback) => {
|
|
78
|
-
if (file.isNull()) {
|
|
79
|
-
return callback(null, file);
|
|
80
|
-
}
|
|
81
|
-
if (file.isStream()) {
|
|
82
|
-
return callback(new PluginError(PLUGIN_NAME, 'Streaming not supported'));
|
|
83
|
-
}
|
|
84
|
-
if (node.path.basename(file.path).startsWith('_')) {
|
|
85
|
-
return callback();
|
|
86
|
-
}
|
|
87
|
-
if (!file.contents.length) {
|
|
88
|
-
file.path = replaceExtension(file.path, '.css');
|
|
89
|
-
return callback(null, file);
|
|
90
|
-
}
|
|
91
|
-
const opts = options || {};
|
|
92
|
-
|
|
93
|
-
// Ensure `indented` if a `.sass` file
|
|
94
|
-
if (node.path.extname(file.path) === '.sass') {
|
|
95
|
-
opts.syntax = 'indented';
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// Ensure file's parent directory in the include path
|
|
99
|
-
if (opts.loadPaths) {
|
|
100
|
-
if (typeof opts.loadPaths === 'string') {
|
|
101
|
-
opts.loadPaths = [opts.loadPaths];
|
|
102
|
-
}
|
|
103
|
-
} else {
|
|
104
|
-
opts.loadPaths = [];
|
|
105
|
-
}
|
|
106
|
-
opts.loadPaths.unshift(node.path.dirname(file.path));
|
|
107
|
-
|
|
108
|
-
// Generate Source Maps if the source-map plugin is present
|
|
109
|
-
if (file.sourceMap) {
|
|
110
|
-
opts.sourceMap = true;
|
|
111
|
-
opts.sourceMapIncludeSources = true;
|
|
112
|
-
}
|
|
113
|
-
const fileContents = file.contents.toString();
|
|
114
|
-
if (sync !== true) {
|
|
115
|
-
/**
|
|
116
|
-
* Async Sass compile
|
|
117
|
-
*/
|
|
118
|
-
sassModule.compileStringAsync(fileContents, opts).then(compileResult => {
|
|
119
|
-
filePush(file, compileResult, callback);
|
|
120
|
-
}).catch(error => {
|
|
121
|
-
handleError(error, file, callback);
|
|
122
|
-
});
|
|
123
|
-
} else {
|
|
124
|
-
/**
|
|
125
|
-
* Sync Sass compile
|
|
126
|
-
*/
|
|
127
|
-
try {
|
|
128
|
-
filePush(file, sassModule.compileString(fileContents, opts), callback);
|
|
129
|
-
} catch (error) {
|
|
130
|
-
handleError(error, file, callback);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
export default gulpSass;
|
package/lib/plugins/sftp.js
DELETED
|
@@ -1,288 +0,0 @@
|
|
|
1
|
-
// Reference `gulp-sftp@0.1.5`
|
|
2
|
-
|
|
3
|
-
import { Client } from 'ssh2';
|
|
4
|
-
import parents from 'parents';
|
|
5
|
-
import async from 'async';
|
|
6
|
-
const PLUGIN_NAME = 'sftp';
|
|
7
|
-
const DefaultAlgorithms = {
|
|
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']
|
|
9
|
-
};
|
|
10
|
-
const normalizePath = _path => _path.replace(/\\/g, '/');
|
|
11
|
-
function resolveHomePath(key) {
|
|
12
|
-
if (key.location) {
|
|
13
|
-
const HOME = process.env.HOME || process.env.USERPROFILE || '';
|
|
14
|
-
for (let i = 0, len = key.location.length; i < len; i++) {
|
|
15
|
-
if (key.location[i].substr(0, 2) === '~/') {
|
|
16
|
-
key.location[i] = node.path.resolve(HOME, key.location[i].replace(/^~\//, ''));
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
for (let i = 0, keyPath; keyPath = key.location[i++];) {
|
|
20
|
-
if (node.fs.existsSync(keyPath)) {
|
|
21
|
-
key.contents = node.fs.readFileSync(keyPath);
|
|
22
|
-
break;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
} else if (!key.contents) {
|
|
26
|
-
const rsaKey = key.location.join(', ');
|
|
27
|
-
throw new PluginError(PLUGIN_NAME, `Cannot find RSA key, searched: ${rsaKey}`);
|
|
28
|
-
}
|
|
29
|
-
return key;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Lots of ways to present key info
|
|
34
|
-
*/
|
|
35
|
-
function getKey(options) {
|
|
36
|
-
let key = options.key || options.keyLocation || null;
|
|
37
|
-
if (key && BalmJS.utils.isString(key)) {
|
|
38
|
-
key = {
|
|
39
|
-
location: key
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// Check for other options that imply a key or if there is no password
|
|
44
|
-
if (!key && (options.passphrase || options.keyContents || !options.password)) {
|
|
45
|
-
key = {};
|
|
46
|
-
}
|
|
47
|
-
if (key) {
|
|
48
|
-
// Aliases
|
|
49
|
-
key.contents = key.contents || options.keyContents;
|
|
50
|
-
key.passphrase = key.passphrase || options.passphrase;
|
|
51
|
-
|
|
52
|
-
// Defaults
|
|
53
|
-
key.location = key.location || ['~/.ssh/id_rsa', '/.ssh/id_rsa', '~/.ssh/id_dsa', '/.ssh/id_dsa'];
|
|
54
|
-
|
|
55
|
-
// Type normalization
|
|
56
|
-
if (!BalmJS.utils.isArray(key.location)) {
|
|
57
|
-
key.location = [key.location];
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// Resolve all home paths
|
|
61
|
-
key = resolveHomePath(key);
|
|
62
|
-
}
|
|
63
|
-
return key;
|
|
64
|
-
}
|
|
65
|
-
function gulpSftp(options) {
|
|
66
|
-
options = Object.assign({}, options); // Credit sindresorhus
|
|
67
|
-
|
|
68
|
-
if (!options.host) {
|
|
69
|
-
throw new PluginError(PLUGIN_NAME, '`host` required');
|
|
70
|
-
}
|
|
71
|
-
let fileCount = 0;
|
|
72
|
-
const remotePath = options.remotePath || '/';
|
|
73
|
-
const remotePlatform = options.remotePlatform || options.platform || 'unix';
|
|
74
|
-
options.authKey = options.authKey || options.auth;
|
|
75
|
-
const authFilePath = options.authFile || '.ftppass';
|
|
76
|
-
const authFile = node.path.join('./', authFilePath);
|
|
77
|
-
if (options.authKey && node.fs.existsSync(authFile)) {
|
|
78
|
-
let auth = JSON.parse(node.fs.readFileSync(authFile, 'utf8'))[options.authKey];
|
|
79
|
-
if (!auth) {
|
|
80
|
-
throw new PluginError(PLUGIN_NAME, 'Could not find authkey in .ftppass');
|
|
81
|
-
}
|
|
82
|
-
if (BalmJS.utils.isString(auth) && auth.indexOf(':') !== -1) {
|
|
83
|
-
const authparts = auth.split(':');
|
|
84
|
-
auth = {
|
|
85
|
-
user: authparts[0],
|
|
86
|
-
pass: authparts[1]
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
const authKeys = Object.keys(auth);
|
|
90
|
-
for (let i = 0, len = authKeys.length; i < len; i++) {
|
|
91
|
-
const attr = authKeys[i];
|
|
92
|
-
if (auth[attr]) {
|
|
93
|
-
options[attr] = auth[attr];
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// Option aliases
|
|
99
|
-
const password = options.password;
|
|
100
|
-
const username = options.username || 'anonymous';
|
|
101
|
-
|
|
102
|
-
/*
|
|
103
|
-
* Key info
|
|
104
|
-
*/
|
|
105
|
-
const key = getKey(options);
|
|
106
|
-
|
|
107
|
-
/*
|
|
108
|
-
* End Key normalization, key should now be of form:
|
|
109
|
-
* {location:Array,passphrase:String,contents:String}
|
|
110
|
-
* or null
|
|
111
|
-
*/
|
|
112
|
-
|
|
113
|
-
const mkDirCache = {};
|
|
114
|
-
let finished = false;
|
|
115
|
-
let sftpCache = null; // SFTP connection cache
|
|
116
|
-
let connCache = null; // SSH connection cache
|
|
117
|
-
|
|
118
|
-
function _pool(uploader) {
|
|
119
|
-
// Method to get cache or create connection
|
|
120
|
-
if (sftpCache) {
|
|
121
|
-
return uploader(sftpCache);
|
|
122
|
-
}
|
|
123
|
-
if (password) {
|
|
124
|
-
BalmJS.logger.debug(PLUGIN_NAME, 'Authenticating with password');
|
|
125
|
-
} else if (key) {
|
|
126
|
-
BalmJS.logger.debug(PLUGIN_NAME, 'Authenticating with private key');
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/*
|
|
130
|
-
* Connection options, may be a key
|
|
131
|
-
*/
|
|
132
|
-
const connectionOptions = {
|
|
133
|
-
host: options.host,
|
|
134
|
-
port: options.port || 22,
|
|
135
|
-
username,
|
|
136
|
-
algorithms: options.algorithms || DefaultAlgorithms
|
|
137
|
-
};
|
|
138
|
-
if (password) {
|
|
139
|
-
connectionOptions.password = password;
|
|
140
|
-
} else if (options.agent) {
|
|
141
|
-
connectionOptions.agent = options.agent;
|
|
142
|
-
connectionOptions.agentForward = options.agentForward || false;
|
|
143
|
-
} else if (key) {
|
|
144
|
-
connectionOptions.privateKey = key.contents;
|
|
145
|
-
connectionOptions.passphrase = key.passphrase;
|
|
146
|
-
}
|
|
147
|
-
if (options.timeout) {
|
|
148
|
-
connectionOptions.readyTimeout = options.timeout;
|
|
149
|
-
}
|
|
150
|
-
const conn = new Client();
|
|
151
|
-
connCache = conn;
|
|
152
|
-
conn.on('ready', () => {
|
|
153
|
-
BalmJS.logger.debug(PLUGIN_NAME, 'Client :: ready');
|
|
154
|
-
conn.sftp((err, sftp) => {
|
|
155
|
-
if (err) {
|
|
156
|
-
throw err;
|
|
157
|
-
}
|
|
158
|
-
sftp.on('end', function () {
|
|
159
|
-
BalmJS.logger.debug(PLUGIN_NAME, 'SFTP session closed');
|
|
160
|
-
sftpCache = null;
|
|
161
|
-
if (!finished) {
|
|
162
|
-
this.emit('error', new PluginError(PLUGIN_NAME, 'SFTP abrupt closure'));
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
|
-
sftpCache = sftp;
|
|
166
|
-
uploader(sftpCache);
|
|
167
|
-
});
|
|
168
|
-
});
|
|
169
|
-
conn.on('error', err => {
|
|
170
|
-
const errorMsg = err && (err.message || err.toString()) || 'SFTP connection error';
|
|
171
|
-
this.emit('error', new PluginError(PLUGIN_NAME, errorMsg));
|
|
172
|
-
});
|
|
173
|
-
conn.on('end', () => {
|
|
174
|
-
BalmJS.logger.debug(PLUGIN_NAME, 'Client :: end');
|
|
175
|
-
});
|
|
176
|
-
conn.on('close', () => {
|
|
177
|
-
if (!finished) {
|
|
178
|
-
this.emit('error', new PluginError(PLUGIN_NAME, 'SFTP abrupt closure'));
|
|
179
|
-
}
|
|
180
|
-
if (options.callback) {
|
|
181
|
-
options.callback();
|
|
182
|
-
}
|
|
183
|
-
});
|
|
184
|
-
conn.connect(connectionOptions);
|
|
185
|
-
}
|
|
186
|
-
function transform(file, encoding, callback) {
|
|
187
|
-
if (file.isNull()) {
|
|
188
|
-
return callback();
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
// Have to create a new connection for each file otherwise they conflict, pulled from sindresorhus
|
|
192
|
-
const finalRemotePath = normalizePath(node.path.join(remotePath, file.relative));
|
|
193
|
-
|
|
194
|
-
// Connection pulled from pool
|
|
195
|
-
_pool.call(this, sftp => {
|
|
196
|
-
/*
|
|
197
|
-
* Create Directories
|
|
198
|
-
*/
|
|
199
|
-
|
|
200
|
-
// Get dir name from file path
|
|
201
|
-
const dirname = node.path.dirname(finalRemotePath);
|
|
202
|
-
// Get parents of the target dir
|
|
203
|
-
|
|
204
|
-
let fileDirs = parents(dirname).map(d => d.replace(/^\/~/, '~')).map(normalizePath);
|
|
205
|
-
if (dirname.search(/^\//) === 0) {
|
|
206
|
-
fileDirs = fileDirs.map(dir => dir.search(/^\//) === 0 ? dir : `/${dir}`);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
// Get filter out dirs that are closer to root than the base remote path
|
|
210
|
-
// also filter out any dirs made during this gulp session
|
|
211
|
-
fileDirs = fileDirs.filter(d => d.length >= remotePath.length && !mkDirCache[d]);
|
|
212
|
-
|
|
213
|
-
// While there are dirs to create, create them
|
|
214
|
-
// https://github.com/caolan/async#whilst - not the most commonly used async control flow
|
|
215
|
-
async.whilst(
|
|
216
|
-
// https://github.com/caolan/async/issues/1668
|
|
217
|
-
cb => cb(null, fileDirs && fileDirs.length), cb => {
|
|
218
|
-
let d = fileDirs.pop();
|
|
219
|
-
mkDirCache[d] = true;
|
|
220
|
-
if (remotePlatform && remotePlatform.toLowerCase().indexOf('win') !== -1) {
|
|
221
|
-
d = d.replace('/', '\\');
|
|
222
|
-
}
|
|
223
|
-
sftp.exists(d, exist => {
|
|
224
|
-
if (exist) {
|
|
225
|
-
cb();
|
|
226
|
-
} else {
|
|
227
|
-
const dirMode = options.dirMode || '0755';
|
|
228
|
-
sftp.mkdir(d, {
|
|
229
|
-
mode: dirMode
|
|
230
|
-
}, err => {
|
|
231
|
-
// REMOTE PATH
|
|
232
|
-
if (err) {
|
|
233
|
-
// Assuming that the directory exists here, silencing this error
|
|
234
|
-
BalmJS.logger.warn(PLUGIN_NAME, `Error or directory exists: ${err} ${d}`);
|
|
235
|
-
} else {
|
|
236
|
-
BalmJS.logger.debug(PLUGIN_NAME, `Created: ${d}`);
|
|
237
|
-
}
|
|
238
|
-
cb();
|
|
239
|
-
});
|
|
240
|
-
}
|
|
241
|
-
});
|
|
242
|
-
}, () => {
|
|
243
|
-
const fileMode = options.fileMode || '0666';
|
|
244
|
-
const stream = sftp.createWriteStream(finalRemotePath, {
|
|
245
|
-
flags: 'w',
|
|
246
|
-
encoding: null,
|
|
247
|
-
mode: fileMode,
|
|
248
|
-
autoClose: true
|
|
249
|
-
});
|
|
250
|
-
|
|
251
|
-
// Start upload
|
|
252
|
-
if (file.isStream()) {
|
|
253
|
-
file.contents.pipe(stream);
|
|
254
|
-
} else if (file.isBuffer()) {
|
|
255
|
-
stream.end(file.contents);
|
|
256
|
-
}
|
|
257
|
-
stream.on('close', function (error) {
|
|
258
|
-
if (error) {
|
|
259
|
-
this.emit('error', new PluginError(PLUGIN_NAME, error));
|
|
260
|
-
} else {
|
|
261
|
-
const fileRelativePath = file.relative;
|
|
262
|
-
BalmJS.logger.info(PLUGIN_NAME, `Uploaded: ${fileRelativePath} => ${finalRemotePath}`);
|
|
263
|
-
fileCount++;
|
|
264
|
-
}
|
|
265
|
-
return callback(error);
|
|
266
|
-
});
|
|
267
|
-
});
|
|
268
|
-
});
|
|
269
|
-
}
|
|
270
|
-
function flush(callback) {
|
|
271
|
-
if (fileCount > 0) {
|
|
272
|
-
const unit = fileCount === 1 ? 'file' : 'files';
|
|
273
|
-
BalmJS.logger.info(PLUGIN_NAME, `${fileCount} ${unit} uploaded successfully`);
|
|
274
|
-
} else {
|
|
275
|
-
BalmJS.logger.warn(PLUGIN_NAME, 'No files uploaded');
|
|
276
|
-
}
|
|
277
|
-
finished = true;
|
|
278
|
-
if (sftpCache) {
|
|
279
|
-
sftpCache.end();
|
|
280
|
-
}
|
|
281
|
-
if (connCache) {
|
|
282
|
-
connCache.end();
|
|
283
|
-
}
|
|
284
|
-
callback();
|
|
285
|
-
}
|
|
286
|
-
return through2.obj(transform, flush);
|
|
287
|
-
}
|
|
288
|
-
export default gulpSftp;
|
package/lib/tasks/default.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
class DefaultTask extends BalmJS.BalmTask {
|
|
2
|
-
constructor() {
|
|
3
|
-
super('default');
|
|
4
|
-
}
|
|
5
|
-
get startTask() {
|
|
6
|
-
const tasks = BalmJS.toNamespace(['start']);
|
|
7
|
-
if (BalmJS.utils.isString(BalmJS.beforeTask)) {
|
|
8
|
-
tasks.unshift(BalmJS.beforeTask);
|
|
9
|
-
}
|
|
10
|
-
return tasks;
|
|
11
|
-
}
|
|
12
|
-
get mainTasks() {
|
|
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
|
-
...(BalmJS.config.env.isProd || !BalmJS.config.inFrontend ? ['image', 'font', 'media'] : [])];
|
|
22
|
-
if (BalmJS.config.env.isProd) {
|
|
23
|
-
tasks = [...tasks, 'extra', 'build',
|
|
24
|
-
// Measure size
|
|
25
|
-
...(BalmJS.config.assets.cache ? ['cache'] : []), ...(BalmJS.config.pwa.enabled ? ['workbox-sw', 'pwa'] : [])];
|
|
26
|
-
} else {
|
|
27
|
-
tasks = [...tasks, 'modernizr', 'serve'];
|
|
28
|
-
}
|
|
29
|
-
let defaultMainTasks = BalmJS.config.useDefaults ? BalmJS.toNamespace(tasks) : [];
|
|
30
|
-
if (BalmJS.config.env.inSSR || BalmJS.config.env.isMP || BalmJS.config.env.inDesktopApp) {
|
|
31
|
-
defaultMainTasks = BalmJS.toNamespace(BalmJS.config.env.isMP ? ['style', 'script'] : ['script']);
|
|
32
|
-
}
|
|
33
|
-
return defaultMainTasks;
|
|
34
|
-
}
|
|
35
|
-
get subTasks() {
|
|
36
|
-
return BalmJS.recipes.length ? BalmJS.toNamespace(BalmJS.recipes) : [];
|
|
37
|
-
}
|
|
38
|
-
get endTask() {
|
|
39
|
-
const tasks = BalmJS.toNamespace(['end']);
|
|
40
|
-
if (BalmJS.utils.isString(BalmJS.afterTask)) {
|
|
41
|
-
tasks.push(BalmJS.afterTask);
|
|
42
|
-
}
|
|
43
|
-
return tasks;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
export default DefaultTask;
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
2
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
3
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
4
|
-
class BalmTask {
|
|
5
|
-
constructor(name) {
|
|
6
|
-
_defineProperty(this, "name", void 0);
|
|
7
|
-
_defineProperty(this, "taskName", void 0);
|
|
8
|
-
_defineProperty(this, "defaultInput", '');
|
|
9
|
-
_defineProperty(this, "defaultOutput", '');
|
|
10
|
-
_defineProperty(this, "input", '');
|
|
11
|
-
_defineProperty(this, "output", '');
|
|
12
|
-
_defineProperty(this, "customOptions", {});
|
|
13
|
-
_defineProperty(this, "gulpSrcOptions", {});
|
|
14
|
-
this.name = name;
|
|
15
|
-
this.taskName = BalmJS.toNamespace(name);
|
|
16
|
-
}
|
|
17
|
-
get styleName() {
|
|
18
|
-
let name;
|
|
19
|
-
switch (BalmJS.config.styles.extname) {
|
|
20
|
-
case 'sass':
|
|
21
|
-
case 'scss':
|
|
22
|
-
name = 'sass';
|
|
23
|
-
break;
|
|
24
|
-
case 'less':
|
|
25
|
-
name = 'less';
|
|
26
|
-
break;
|
|
27
|
-
default:
|
|
28
|
-
name = 'postcss';
|
|
29
|
-
}
|
|
30
|
-
return name;
|
|
31
|
-
}
|
|
32
|
-
get src() {
|
|
33
|
-
return gulp.src(this.input, Object.assign({
|
|
34
|
-
allowEmpty: true,
|
|
35
|
-
encoding: false
|
|
36
|
-
}, this.gulpSrcOptions)).pipe(BalmJS.plugins.plumber(error => {
|
|
37
|
-
BalmJS.logger.error(`${this.name} task`, error.message);
|
|
38
|
-
}));
|
|
39
|
-
}
|
|
40
|
-
init(input, output, options = {}) {
|
|
41
|
-
let key = this.name;
|
|
42
|
-
switch (key) {
|
|
43
|
-
case 'copy':
|
|
44
|
-
key = 'rename';
|
|
45
|
-
break;
|
|
46
|
-
case 'jsmin':
|
|
47
|
-
key = 'terser';
|
|
48
|
-
break;
|
|
49
|
-
default:
|
|
50
|
-
}
|
|
51
|
-
const useAbsPath = !['webpack', 'rollup', 'esbuild', 'sprite'].includes(key);
|
|
52
|
-
this.input = useAbsPath && (input || this.defaultInput) ? BalmJS.file.absPaths(input || this.defaultInput) : input || this.defaultInput;
|
|
53
|
-
this.output = useAbsPath && typeof (output || this.defaultOutput) === 'string' ? BalmJS.file.absPath(output || this.defaultOutput) : output || this.defaultOutput;
|
|
54
|
-
this.customOptions = options[key] || {};
|
|
55
|
-
const obj = {
|
|
56
|
-
input: this.input,
|
|
57
|
-
output: this.output
|
|
58
|
-
};
|
|
59
|
-
if (options[key]) {
|
|
60
|
-
obj.customOptions = this.customOptions;
|
|
61
|
-
}
|
|
62
|
-
if (useAbsPath) {
|
|
63
|
-
BalmJS.logger.debug(`${this.name} task`, obj, {
|
|
64
|
-
pre: true
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
if (options.src) {
|
|
68
|
-
this.gulpSrcOptions = options.src;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
export default BalmTask;
|