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.
Files changed (299) hide show
  1. package/dist/index.cjs +2191 -0
  2. package/dist/index.cjs.map +1 -0
  3. package/dist/index.d.cts +559 -0
  4. package/dist/index.d.ts +559 -0
  5. package/dist/index.js +2098 -0
  6. package/dist/index.js.map +1 -0
  7. package/package.json +48 -123
  8. package/src/balm.ts +103 -0
  9. package/src/bundler/esbuild.ts +47 -0
  10. package/src/bundler/index.ts +3 -0
  11. package/src/bundler/rollup.ts +39 -0
  12. package/src/bundler/webpack.ts +82 -0
  13. package/src/config/constants.ts +12 -0
  14. package/src/config/defaults.ts +209 -0
  15. package/src/config/index.ts +112 -0
  16. package/src/hooks/index.ts +192 -0
  17. package/src/index.ts +16 -0
  18. package/src/pipeline/file.ts +69 -0
  19. package/src/pipeline/index.ts +10 -0
  20. package/src/pipeline/pipeline.ts +132 -0
  21. package/src/pipeline/transforms/cache.ts +96 -0
  22. package/src/pipeline/transforms/htmlmin.ts +18 -0
  23. package/src/pipeline/transforms/less.ts +75 -0
  24. package/src/pipeline/transforms/postcss.ts +43 -0
  25. package/src/pipeline/transforms/rename.ts +37 -0
  26. package/src/pipeline/transforms/replace.ts +30 -0
  27. package/src/pipeline/transforms/sass.ts +106 -0
  28. package/src/pipeline/transforms/terser.ts +20 -0
  29. package/src/runner/dag.ts +77 -0
  30. package/src/runner/task.ts +38 -0
  31. package/src/shims.d.ts +5 -0
  32. package/src/tasks/cache.ts +58 -0
  33. package/src/tasks/clean.ts +21 -0
  34. package/src/tasks/copy.ts +36 -0
  35. package/src/tasks/ftp.ts +90 -0
  36. package/src/tasks/html.ts +78 -0
  37. package/src/tasks/index.ts +13 -0
  38. package/src/tasks/publish.ts +71 -0
  39. package/src/tasks/pwa.ts +49 -0
  40. package/src/tasks/remove.ts +24 -0
  41. package/src/tasks/replace.ts +34 -0
  42. package/src/tasks/script.ts +28 -0
  43. package/src/tasks/server.ts +89 -0
  44. package/src/tasks/style.ts +57 -0
  45. package/src/tasks/zip.ts +65 -0
  46. package/src/types/index.ts +200 -0
  47. package/src/utilities/file.ts +120 -0
  48. package/src/utilities/logger.ts +63 -0
  49. package/src/utilities/utils.ts +46 -0
  50. package/src/utilities/workspace.ts +38 -0
  51. package/src/watcher/index.ts +100 -0
  52. package/tsconfig.json +8 -0
  53. package/tsup.config.ts +12 -0
  54. package/README.md +0 -196
  55. package/index.d.ts +0 -360
  56. package/lib/balm.js +0 -49
  57. package/lib/bootstrap/check_config.js +0 -43
  58. package/lib/bootstrap/index.js +0 -87
  59. package/lib/bundler/esbuild/build.js +0 -26
  60. package/lib/bundler/esbuild/index.js +0 -7
  61. package/lib/bundler/esbuild/options.js +0 -7
  62. package/lib/bundler/esbuild/transform.js +0 -36
  63. package/lib/bundler/rollup/build.js +0 -52
  64. package/lib/bundler/rollup/entry.js +0 -28
  65. package/lib/bundler/rollup/index.js +0 -20
  66. package/lib/bundler/rollup/output.js +0 -20
  67. package/lib/bundler/rollup/plugins.js +0 -31
  68. package/lib/bundler/webpack/config/common.js +0 -135
  69. package/lib/bundler/webpack/config/dev.js +0 -12
  70. package/lib/bundler/webpack/config/env.js +0 -67
  71. package/lib/bundler/webpack/config/index.js +0 -6
  72. package/lib/bundler/webpack/config/prod.js +0 -39
  73. package/lib/bundler/webpack/config/regex.js +0 -10
  74. package/lib/bundler/webpack/entry.js +0 -65
  75. package/lib/bundler/webpack/index.js +0 -32
  76. package/lib/bundler/webpack/loaders.js +0 -50
  77. package/lib/bundler/webpack/output.js +0 -41
  78. package/lib/bundler/webpack/rules/asset.js +0 -33
  79. package/lib/bundler/webpack/rules/babel.js +0 -19
  80. package/lib/bundler/webpack/rules/css.js +0 -109
  81. package/lib/bundler/webpack/rules/html.js +0 -15
  82. package/lib/bundler/webpack/rules/index.js +0 -10
  83. package/lib/config/assets.js +0 -30
  84. package/lib/config/constants.js +0 -14
  85. package/lib/config/env.js +0 -35
  86. package/lib/config/extras.js +0 -6
  87. package/lib/config/ftp.js +0 -6
  88. package/lib/config/globals.js +0 -43
  89. package/lib/config/html.js +0 -22
  90. package/lib/config/images.js +0 -4
  91. package/lib/config/index.js +0 -63
  92. package/lib/config/logs.js +0 -11
  93. package/lib/config/paths.js +0 -46
  94. package/lib/config/pwa.js +0 -24
  95. package/lib/config/roots.js +0 -9
  96. package/lib/config/scripts.js +0 -162
  97. package/lib/config/server.js +0 -84
  98. package/lib/config/spinner.js +0 -9
  99. package/lib/config/styles.js +0 -67
  100. package/lib/hello.js +0 -19
  101. package/lib/hooks/index.js +0 -94
  102. package/lib/hooks/maker.js +0 -59
  103. package/lib/index.js +0 -5
  104. package/lib/middlewares/history.js +0 -6
  105. package/lib/middlewares/index.js +0 -11
  106. package/lib/middlewares/proxy.js +0 -28
  107. package/lib/middlewares/webpack.js +0 -26
  108. package/lib/plugins/htmlmin.js +0 -39
  109. package/lib/plugins/imagemin.js +0 -95
  110. package/lib/plugins/index.js +0 -27
  111. package/lib/plugins/jsmin.js +0 -37
  112. package/lib/plugins/less.js +0 -97
  113. package/lib/plugins/plumber.js +0 -87
  114. package/lib/plugins/postcss-plugins.js +0 -13
  115. package/lib/plugins/postcss.js +0 -117
  116. package/lib/plugins/rename.js +0 -51
  117. package/lib/plugins/replace.js +0 -91
  118. package/lib/plugins/sass-legacy.js +0 -131
  119. package/lib/plugins/sass.js +0 -134
  120. package/lib/plugins/sftp.js +0 -288
  121. package/lib/tasks/default.js +0 -46
  122. package/lib/tasks/foundation/balm.js +0 -72
  123. package/lib/tasks/foundation/balm_style.js +0 -65
  124. package/lib/tasks/foundation/index.js +0 -10
  125. package/lib/tasks/index.js +0 -48
  126. package/lib/tasks/private/build.js +0 -18
  127. package/lib/tasks/private/cache.js +0 -31
  128. package/lib/tasks/private/clean.js +0 -69
  129. package/lib/tasks/private/end.js +0 -24
  130. package/lib/tasks/private/extra.js +0 -35
  131. package/lib/tasks/private/font.js +0 -15
  132. package/lib/tasks/private/image.js +0 -37
  133. package/lib/tasks/private/index.js +0 -34
  134. package/lib/tasks/private/lint.js +0 -20
  135. package/lib/tasks/private/media.js +0 -15
  136. package/lib/tasks/private/modernizr.js +0 -59
  137. package/lib/tasks/private/pwa-cache.js +0 -32
  138. package/lib/tasks/private/script.js +0 -9
  139. package/lib/tasks/private/sprite.js +0 -105
  140. package/lib/tasks/private/start.js +0 -16
  141. package/lib/tasks/private/style.js +0 -9
  142. package/lib/tasks/private/workbox-sw.js +0 -15
  143. package/lib/tasks/public/copy.js +0 -16
  144. package/lib/tasks/public/esbuild.js +0 -18
  145. package/lib/tasks/public/ftp.js +0 -39
  146. package/lib/tasks/public/html.js +0 -65
  147. package/lib/tasks/public/index.js +0 -38
  148. package/lib/tasks/public/jsmin.js +0 -23
  149. package/lib/tasks/public/less.js +0 -21
  150. package/lib/tasks/public/postcss.js +0 -16
  151. package/lib/tasks/public/publish.js +0 -51
  152. package/lib/tasks/public/pwa.js +0 -84
  153. package/lib/tasks/public/remove.js +0 -46
  154. package/lib/tasks/public/replace.js +0 -26
  155. package/lib/tasks/public/rollup.js +0 -17
  156. package/lib/tasks/public/sass.js +0 -27
  157. package/lib/tasks/public/server.js +0 -130
  158. package/lib/tasks/public/url.js +0 -35
  159. package/lib/tasks/public/version.js +0 -23
  160. package/lib/tasks/public/webpack.js +0 -39
  161. package/lib/tasks/public/zip.js +0 -19
  162. package/lib/utilities/address.js +0 -55
  163. package/lib/utilities/cache-core.js +0 -66
  164. package/lib/utilities/color.js +0 -27
  165. package/lib/utilities/compiling.js +0 -24
  166. package/lib/utilities/detect-port.js +0 -100
  167. package/lib/utilities/escape-string-regexp.js +0 -10
  168. package/lib/utilities/file.js +0 -70
  169. package/lib/utilities/index.js +0 -8
  170. package/lib/utilities/loading.js +0 -37
  171. package/lib/utilities/logger.js +0 -99
  172. package/lib/utilities/merge-stream.js +0 -38
  173. package/lib/utilities/namespace.js +0 -11
  174. package/lib/utilities/public-url.js +0 -37
  175. package/lib/utilities/replacestream.js +0 -106
  176. package/lib/utilities/typeof.js +0 -5
  177. package/lib/utilities/utils.js +0 -43
  178. package/tslib/balm.js +0 -44
  179. package/tslib/bootstrap/check_config.js +0 -36
  180. package/tslib/bootstrap/index.js +0 -82
  181. package/tslib/bundler/esbuild/build.js +0 -30
  182. package/tslib/bundler/esbuild/index.js +0 -11
  183. package/tslib/bundler/esbuild/options.js +0 -7
  184. package/tslib/bundler/esbuild/transform.js +0 -38
  185. package/tslib/bundler/rollup/build.js +0 -17
  186. package/tslib/bundler/rollup/entry.js +0 -24
  187. package/tslib/bundler/rollup/index.js +0 -21
  188. package/tslib/bundler/rollup/output.js +0 -23
  189. package/tslib/bundler/rollup/plugins.js +0 -27
  190. package/tslib/bundler/webpack/config/common.js +0 -130
  191. package/tslib/bundler/webpack/config/dev.js +0 -14
  192. package/tslib/bundler/webpack/config/env.js +0 -44
  193. package/tslib/bundler/webpack/config/index.js +0 -8
  194. package/tslib/bundler/webpack/config/prod.js +0 -43
  195. package/tslib/bundler/webpack/config/regex.js +0 -10
  196. package/tslib/bundler/webpack/entry.js +0 -68
  197. package/tslib/bundler/webpack/index.js +0 -30
  198. package/tslib/bundler/webpack/loaders.js +0 -51
  199. package/tslib/bundler/webpack/output.js +0 -41
  200. package/tslib/bundler/webpack/rules/asset.js +0 -33
  201. package/tslib/bundler/webpack/rules/babel.js +0 -16
  202. package/tslib/bundler/webpack/rules/css.js +0 -95
  203. package/tslib/bundler/webpack/rules/html.js +0 -15
  204. package/tslib/bundler/webpack/rules/index.js +0 -10
  205. package/tslib/config/assets.js +0 -24
  206. package/tslib/config/constants.js +0 -14
  207. package/tslib/config/env.js +0 -43
  208. package/tslib/config/extras.js +0 -6
  209. package/tslib/config/ftp.js +0 -6
  210. package/tslib/config/globals.js +0 -47
  211. package/tslib/config/html.js +0 -17
  212. package/tslib/config/images.js +0 -4
  213. package/tslib/config/index.js +0 -56
  214. package/tslib/config/logs.js +0 -6
  215. package/tslib/config/paths.js +0 -30
  216. package/tslib/config/pwa.js +0 -18
  217. package/tslib/config/roots.js +0 -8
  218. package/tslib/config/scripts.js +0 -93
  219. package/tslib/config/server.js +0 -33
  220. package/tslib/config/spinner.js +0 -10
  221. package/tslib/config/styles.js +0 -37
  222. package/tslib/hello.js +0 -19
  223. package/tslib/hooks/index.js +0 -75
  224. package/tslib/hooks/maker.js +0 -66
  225. package/tslib/index.js +0 -5
  226. package/tslib/middlewares/history.js +0 -12
  227. package/tslib/middlewares/index.js +0 -18
  228. package/tslib/middlewares/proxy.js +0 -27
  229. package/tslib/middlewares/webpack.js +0 -29
  230. package/tslib/plugins/htmlmin.js +0 -38
  231. package/tslib/plugins/imagemin.js +0 -97
  232. package/tslib/plugins/index.js +0 -27
  233. package/tslib/plugins/jsmin.js +0 -39
  234. package/tslib/plugins/less.js +0 -90
  235. package/tslib/plugins/plumber.js +0 -81
  236. package/tslib/plugins/postcss-plugins.js +0 -24
  237. package/tslib/plugins/postcss.js +0 -111
  238. package/tslib/plugins/rename.js +0 -51
  239. package/tslib/plugins/replace.js +0 -72
  240. package/tslib/plugins/sass-legacy.js +0 -95
  241. package/tslib/plugins/sass.js +0 -109
  242. package/tslib/plugins/sftp.js +0 -258
  243. package/tslib/tasks/default.js +0 -59
  244. package/tslib/tasks/foundation/balm.js +0 -75
  245. package/tslib/tasks/foundation/balm_style.js +0 -68
  246. package/tslib/tasks/foundation/index.js +0 -10
  247. package/tslib/tasks/index.js +0 -43
  248. package/tslib/tasks/private/build.js +0 -15
  249. package/tslib/tasks/private/cache.js +0 -48
  250. package/tslib/tasks/private/clean.js +0 -82
  251. package/tslib/tasks/private/end.js +0 -21
  252. package/tslib/tasks/private/extra.js +0 -34
  253. package/tslib/tasks/private/font.js +0 -12
  254. package/tslib/tasks/private/image.js +0 -42
  255. package/tslib/tasks/private/index.js +0 -34
  256. package/tslib/tasks/private/lint.js +0 -17
  257. package/tslib/tasks/private/media.js +0 -12
  258. package/tslib/tasks/private/modernizr.js +0 -54
  259. package/tslib/tasks/private/pwa-cache.js +0 -32
  260. package/tslib/tasks/private/script.js +0 -9
  261. package/tslib/tasks/private/sprite.js +0 -93
  262. package/tslib/tasks/private/start.js +0 -13
  263. package/tslib/tasks/private/style.js +0 -12
  264. package/tslib/tasks/private/workbox-sw.js +0 -15
  265. package/tslib/tasks/public/copy.js +0 -18
  266. package/tslib/tasks/public/esbuild.js +0 -18
  267. package/tslib/tasks/public/ftp.js +0 -39
  268. package/tslib/tasks/public/html.js +0 -75
  269. package/tslib/tasks/public/index.js +0 -38
  270. package/tslib/tasks/public/jsmin.js +0 -24
  271. package/tslib/tasks/public/less.js +0 -21
  272. package/tslib/tasks/public/postcss.js +0 -16
  273. package/tslib/tasks/public/publish.js +0 -50
  274. package/tslib/tasks/public/pwa.js +0 -87
  275. package/tslib/tasks/public/remove.js +0 -44
  276. package/tslib/tasks/public/replace.js +0 -27
  277. package/tslib/tasks/public/rollup.js +0 -17
  278. package/tslib/tasks/public/sass.js +0 -27
  279. package/tslib/tasks/public/server.js +0 -129
  280. package/tslib/tasks/public/url.js +0 -35
  281. package/tslib/tasks/public/version.js +0 -27
  282. package/tslib/tasks/public/webpack.js +0 -41
  283. package/tslib/tasks/public/zip.js +0 -19
  284. package/tslib/utilities/address.js +0 -48
  285. package/tslib/utilities/cache-core.js +0 -57
  286. package/tslib/utilities/color.js +0 -33
  287. package/tslib/utilities/compiling.js +0 -16
  288. package/tslib/utilities/detect-port.js +0 -91
  289. package/tslib/utilities/escape-string-regexp.js +0 -7
  290. package/tslib/utilities/file.js +0 -78
  291. package/tslib/utilities/index.js +0 -8
  292. package/tslib/utilities/loading.js +0 -25
  293. package/tslib/utilities/logger.js +0 -92
  294. package/tslib/utilities/merge-stream.js +0 -34
  295. package/tslib/utilities/namespace.js +0 -12
  296. package/tslib/utilities/public-url.js +0 -31
  297. package/tslib/utilities/replacestream.js +0 -112
  298. package/tslib/utilities/typeof.js +0 -8
  299. package/tslib/utilities/utils.js +0 -38
@@ -1,95 +0,0 @@
1
- import { Transform } from 'node:stream';
2
- import * as sass from 'sass';
3
- import replaceExtension from 'replace-ext';
4
- import stripAnsi from 'strip-ansi';
5
- import applySourceMap from 'vinyl-sourcemaps-apply';
6
- import ansiColors from 'ansi-colors';
7
- const sassModule = node.getSassModule(sass);
8
- const PLUGIN_NAME = 'sass-legacy';
9
- const transformObj = (transform) => new Transform({ transform, objectMode: true });
10
- function filePush(file, sassObject, callback) {
11
- if (sassObject.map) {
12
- const sassMap = JSON.parse(sassObject.map.toString());
13
- const sassMapFile = sassMap.file.replace(/^stdout$/, 'stdin');
14
- const sassFileSrc = file.relative;
15
- const sassFileSrcPath = node.path.dirname(sassFileSrc);
16
- if (sassFileSrcPath) {
17
- const sourceFileIndex = sassMap.sources.indexOf(sassMapFile);
18
- sassMap.sources = sassMap.sources.map((source, index) => index === sourceFileIndex
19
- ? source
20
- : node.path.join(sassFileSrcPath, source));
21
- }
22
- sassMap.sources = sassMap.sources.filter((src) => src !== 'stdin' && src);
23
- sassMap.file = replaceExtension(sassFileSrc, '.css');
24
- applySourceMap(file, sassMap);
25
- }
26
- file.contents = sassObject.css;
27
- file.path = replaceExtension(file.path, '.css');
28
- if (file.stat) {
29
- file.stat.atime = file.stat.mtime = file.stat.ctime = new Date();
30
- }
31
- callback(null, file);
32
- }
33
- function handleError(error, file, callback) {
34
- const filePath = (error.file === 'stdin' ? file.path : error.file) || file.path;
35
- const relativePath = node.path.relative(process.cwd(), filePath);
36
- const message = `${ansiColors.underline(relativePath)}\n${error.formatted}`;
37
- error.messageFormatted = message;
38
- error.messageOriginal = error.message;
39
- error.message = stripAnsi(message);
40
- error.relativePath = relativePath;
41
- return callback(new PluginError(PLUGIN_NAME, error));
42
- }
43
- const gulpSass = (options, sync = false) => transformObj((file, encoding, callback) => {
44
- if (file.isNull()) {
45
- return callback(null, file);
46
- }
47
- if (file.isStream()) {
48
- return callback(new PluginError(PLUGIN_NAME, 'Streaming not supported'));
49
- }
50
- if (node.path.basename(file.path).startsWith('_')) {
51
- return callback();
52
- }
53
- if (!file.contents.length) {
54
- file.path = replaceExtension(file.path, '.css');
55
- return callback(null, file);
56
- }
57
- const opts = (options || {});
58
- opts.data = file.contents.toString();
59
- opts.file = file.path;
60
- if (node.path.extname(file.path) === '.sass') {
61
- opts.indentedSyntax = true;
62
- }
63
- if (opts.includePaths) {
64
- if (typeof opts.includePaths === 'string') {
65
- opts.includePaths = [opts.includePaths];
66
- }
67
- }
68
- else {
69
- opts.includePaths = [];
70
- }
71
- opts.includePaths.unshift(node.path.dirname(file.path));
72
- if (file.sourceMap) {
73
- opts.sourceMap = file.path;
74
- opts.omitSourceMapUrl = true;
75
- opts.sourceMapContents = true;
76
- }
77
- if (sync !== true) {
78
- sassModule.render(opts, (error, obj) => {
79
- if (error) {
80
- handleError(error, file, callback);
81
- return;
82
- }
83
- filePush(file, obj, callback);
84
- });
85
- }
86
- else {
87
- try {
88
- filePush(file, sassModule.renderSync(opts), callback);
89
- }
90
- catch (error) {
91
- handleError(error, file, callback);
92
- }
93
- }
94
- });
95
- export default gulpSass;
@@ -1,109 +0,0 @@
1
- import { Transform } from 'node:stream';
2
- import * as sass from 'sass';
3
- import replaceExtension from 'replace-ext';
4
- import stripAnsi from 'strip-ansi';
5
- import applySourceMap from 'vinyl-sourcemaps-apply';
6
- import ansiColors from 'ansi-colors';
7
- const sassModule = node.getSassModule(sass);
8
- const PLUGIN_NAME = 'sass';
9
- const transformObj = (transform) => new Transform({ transform, objectMode: true });
10
- function filePush(file, result, callback) {
11
- file.contents = Buffer.from(result.css);
12
- file.path = replaceExtension(file.path, '.css');
13
- if (result.sourceMap) {
14
- const proto = /^file:\/\/?/;
15
- const leadingSlash = /^\//;
16
- const sassMap = result.sourceMap;
17
- const base = node.path.resolve(file.cwd, file.base);
18
- if (!sassMap.file) {
19
- sassMap.file = file.history[0]
20
- .replace(base + node.path.sep, '')
21
- .replace(proto, '');
22
- }
23
- sassMap.sources = sassMap.sources.map((src) => {
24
- const baseUri = base.replace(/\\/g, '/');
25
- if (src.startsWith('data:')) {
26
- return file.history[0]
27
- .replace(/\\/g, '/')
28
- .replace(`${baseUri}/`, '')
29
- .replace(proto, '')
30
- .replace(leadingSlash, '');
31
- }
32
- return src
33
- .replace(proto, '')
34
- .replace(`${baseUri}/`, '')
35
- .replace(leadingSlash, '');
36
- });
37
- const sassFileSrc = file.relative;
38
- sassMap.file = replaceExtension(sassFileSrc, '.css');
39
- if (file.sourceMap &&
40
- file.sourceMap.sourcesContent &&
41
- !sassMap.sourcesContent) {
42
- sassMap.sourcesContent = file.sourceMap.sourcesContent;
43
- }
44
- applySourceMap(file, sassMap);
45
- }
46
- if (file.stat) {
47
- file.stat.atime = file.stat.mtime = file.stat.ctime = new Date();
48
- }
49
- callback(null, file);
50
- }
51
- function handleError(error, file, callback) {
52
- const filePath = (error.file === 'stdin' ? file.path : error.file) || file.path;
53
- const relativePath = node.path.relative(process.cwd(), filePath);
54
- const message = `${ansiColors.underline(relativePath)}\n${error.message}`;
55
- error.message = stripAnsi(message);
56
- return callback(new PluginError(PLUGIN_NAME, error));
57
- }
58
- const gulpSass = (options, sync = false) => transformObj((file, encoding, callback) => {
59
- if (file.isNull()) {
60
- return callback(null, file);
61
- }
62
- if (file.isStream()) {
63
- return callback(new PluginError(PLUGIN_NAME, 'Streaming not supported'));
64
- }
65
- if (node.path.basename(file.path).startsWith('_')) {
66
- return callback();
67
- }
68
- if (!file.contents.length) {
69
- file.path = replaceExtension(file.path, '.css');
70
- return callback(null, file);
71
- }
72
- const opts = (options || {});
73
- if (node.path.extname(file.path) === '.sass') {
74
- opts.syntax = 'indented';
75
- }
76
- if (opts.loadPaths) {
77
- if (typeof opts.loadPaths === 'string') {
78
- opts.loadPaths = [opts.loadPaths];
79
- }
80
- }
81
- else {
82
- opts.loadPaths = [];
83
- }
84
- opts.loadPaths.unshift(node.path.dirname(file.path));
85
- if (file.sourceMap) {
86
- opts.sourceMap = true;
87
- opts.sourceMapIncludeSources = true;
88
- }
89
- const fileContents = file.contents.toString();
90
- if (sync !== true) {
91
- sassModule
92
- .compileStringAsync(fileContents, opts)
93
- .then((compileResult) => {
94
- filePush(file, compileResult, callback);
95
- })
96
- .catch((error) => {
97
- handleError(error, file, callback);
98
- });
99
- }
100
- else {
101
- try {
102
- filePush(file, sassModule.compileString(fileContents, opts), callback);
103
- }
104
- catch (error) {
105
- handleError(error, file, callback);
106
- }
107
- }
108
- });
109
- export default gulpSass;
@@ -1,258 +0,0 @@
1
- import { Client } from 'ssh2';
2
- import parents from 'parents';
3
- import async from 'async';
4
- const PLUGIN_NAME = 'sftp';
5
- const DefaultAlgorithms = {
6
- kex: [
7
- 'curve25519-sha256',
8
- 'curve25519-sha256@libssh.org',
9
- 'ecdh-sha2-nistp256',
10
- 'ecdh-sha2-nistp384',
11
- 'ecdh-sha2-nistp521',
12
- 'diffie-hellman-group-exchange-sha256',
13
- 'diffie-hellman-group14-sha256',
14
- 'diffie-hellman-group15-sha512',
15
- 'diffie-hellman-group16-sha512',
16
- 'diffie-hellman-group17-sha512',
17
- 'diffie-hellman-group18-sha512',
18
- 'diffie-hellman-group-exchange-sha1',
19
- 'diffie-hellman-group14-sha1',
20
- 'diffie-hellman-group1-sha1'
21
- ]
22
- };
23
- const normalizePath = (_path) => _path.replace(/\\/g, '/');
24
- function resolveHomePath(key) {
25
- if (key.location) {
26
- const HOME = process.env.HOME || process.env.USERPROFILE || '';
27
- for (let i = 0, len = key.location.length; i < len; i++) {
28
- if (key.location[i].substr(0, 2) === '~/') {
29
- key.location[i] = node.path.resolve(HOME, key.location[i].replace(/^~\//, ''));
30
- }
31
- }
32
- for (let i = 0, keyPath; (keyPath = key.location[i++]);) {
33
- if (node.fs.existsSync(keyPath)) {
34
- key.contents = node.fs.readFileSync(keyPath);
35
- break;
36
- }
37
- }
38
- }
39
- else if (!key.contents) {
40
- const rsaKey = key.location.join(', ');
41
- throw new PluginError(PLUGIN_NAME, `Cannot find RSA key, searched: ${rsaKey}`);
42
- }
43
- return key;
44
- }
45
- function getKey(options) {
46
- let key = options.key || options.keyLocation || null;
47
- if (key && BalmJS.utils.isString(key)) {
48
- key = {
49
- location: key
50
- };
51
- }
52
- if (!key &&
53
- (options.passphrase || options.keyContents || !options.password)) {
54
- key = {};
55
- }
56
- if (key) {
57
- key.contents = key.contents || options.keyContents;
58
- key.passphrase = key.passphrase || options.passphrase;
59
- key.location = key.location || [
60
- '~/.ssh/id_rsa',
61
- '/.ssh/id_rsa',
62
- '~/.ssh/id_dsa',
63
- '/.ssh/id_dsa'
64
- ];
65
- if (!BalmJS.utils.isArray(key.location)) {
66
- key.location = [key.location];
67
- }
68
- key = resolveHomePath(key);
69
- }
70
- return key;
71
- }
72
- function gulpSftp(options) {
73
- options = Object.assign({}, options);
74
- if (!options.host) {
75
- throw new PluginError(PLUGIN_NAME, '`host` required');
76
- }
77
- let fileCount = 0;
78
- const remotePath = options.remotePath || '/';
79
- const remotePlatform = options.remotePlatform || options.platform || 'unix';
80
- options.authKey = options.authKey || options.auth;
81
- const authFilePath = options.authFile || '.ftppass';
82
- const authFile = node.path.join('./', authFilePath);
83
- if (options.authKey && node.fs.existsSync(authFile)) {
84
- let auth = JSON.parse(node.fs.readFileSync(authFile, 'utf8'))[options.authKey];
85
- if (!auth) {
86
- throw new PluginError(PLUGIN_NAME, 'Could not find authkey in .ftppass');
87
- }
88
- if (BalmJS.utils.isString(auth) && auth.indexOf(':') !== -1) {
89
- const authparts = auth.split(':');
90
- auth = { user: authparts[0], pass: authparts[1] };
91
- }
92
- const authKeys = Object.keys(auth);
93
- for (let i = 0, len = authKeys.length; i < len; i++) {
94
- const attr = authKeys[i];
95
- if (auth[attr]) {
96
- options[attr] = auth[attr];
97
- }
98
- }
99
- }
100
- const password = options.password;
101
- const username = options.username || 'anonymous';
102
- const key = getKey(options);
103
- const mkDirCache = {};
104
- let finished = false;
105
- let sftpCache = null;
106
- let connCache = null;
107
- function _pool(uploader) {
108
- if (sftpCache) {
109
- return uploader(sftpCache);
110
- }
111
- if (password) {
112
- BalmJS.logger.debug(PLUGIN_NAME, 'Authenticating with password');
113
- }
114
- else if (key) {
115
- BalmJS.logger.debug(PLUGIN_NAME, 'Authenticating with private key');
116
- }
117
- const connectionOptions = {
118
- host: options.host,
119
- port: options.port || 22,
120
- username,
121
- algorithms: options.algorithms || DefaultAlgorithms
122
- };
123
- if (password) {
124
- connectionOptions.password = password;
125
- }
126
- else if (options.agent) {
127
- connectionOptions.agent = options.agent;
128
- connectionOptions.agentForward = options.agentForward || false;
129
- }
130
- else if (key) {
131
- connectionOptions.privateKey = key.contents;
132
- connectionOptions.passphrase = key.passphrase;
133
- }
134
- if (options.timeout) {
135
- connectionOptions.readyTimeout = options.timeout;
136
- }
137
- const conn = new Client();
138
- connCache = conn;
139
- conn.on('ready', () => {
140
- BalmJS.logger.debug(PLUGIN_NAME, 'Client :: ready');
141
- conn.sftp((err, sftp) => {
142
- if (err) {
143
- throw err;
144
- }
145
- sftp.on('end', function () {
146
- BalmJS.logger.debug(PLUGIN_NAME, 'SFTP session closed');
147
- sftpCache = null;
148
- if (!finished) {
149
- this.emit('error', new PluginError(PLUGIN_NAME, 'SFTP abrupt closure'));
150
- }
151
- });
152
- sftpCache = sftp;
153
- uploader(sftpCache);
154
- });
155
- });
156
- conn.on('error', (err) => {
157
- const errorMsg = (err && (err.message || err.toString())) || 'SFTP connection error';
158
- this.emit('error', new PluginError(PLUGIN_NAME, errorMsg));
159
- });
160
- conn.on('end', () => {
161
- BalmJS.logger.debug(PLUGIN_NAME, 'Client :: end');
162
- });
163
- conn.on('close', () => {
164
- if (!finished) {
165
- this.emit('error', new PluginError(PLUGIN_NAME, 'SFTP abrupt closure'));
166
- }
167
- if (options.callback) {
168
- options.callback();
169
- }
170
- });
171
- conn.connect(connectionOptions);
172
- }
173
- function transform(file, encoding, callback) {
174
- if (file.isNull()) {
175
- return callback();
176
- }
177
- const finalRemotePath = normalizePath(node.path.join(remotePath, file.relative));
178
- _pool.call(this, (sftp) => {
179
- const dirname = node.path.dirname(finalRemotePath);
180
- let fileDirs = parents(dirname)
181
- .map((d) => d.replace(/^\/~/, '~'))
182
- .map(normalizePath);
183
- if (dirname.search(/^\//) === 0) {
184
- fileDirs = fileDirs.map((dir) => dir.search(/^\//) === 0 ? dir : `/${dir}`);
185
- }
186
- fileDirs = fileDirs.filter((d) => d.length >= remotePath.length && !mkDirCache[d]);
187
- async.whilst((cb) => cb(null, fileDirs && fileDirs.length), (cb) => {
188
- let d = fileDirs.pop();
189
- mkDirCache[d] = true;
190
- if (remotePlatform &&
191
- remotePlatform.toLowerCase().indexOf('win') !== -1) {
192
- d = d.replace('/', '\\');
193
- }
194
- sftp.exists(d, (exist) => {
195
- if (exist) {
196
- cb();
197
- }
198
- else {
199
- const dirMode = options.dirMode || '0755';
200
- sftp.mkdir(d, { mode: dirMode }, (err) => {
201
- if (err) {
202
- BalmJS.logger.warn(PLUGIN_NAME, `Error or directory exists: ${err} ${d}`);
203
- }
204
- else {
205
- BalmJS.logger.debug(PLUGIN_NAME, `Created: ${d}`);
206
- }
207
- cb();
208
- });
209
- }
210
- });
211
- }, () => {
212
- const fileMode = options.fileMode || '0666';
213
- const stream = sftp.createWriteStream(finalRemotePath, {
214
- flags: 'w',
215
- encoding: null,
216
- mode: fileMode,
217
- autoClose: true
218
- });
219
- if (file.isStream()) {
220
- file.contents.pipe(stream);
221
- }
222
- else if (file.isBuffer()) {
223
- stream.end(file.contents);
224
- }
225
- stream.on('close', function (error) {
226
- if (error) {
227
- this.emit('error', new PluginError(PLUGIN_NAME, error));
228
- }
229
- else {
230
- const fileRelativePath = file.relative;
231
- BalmJS.logger.info(PLUGIN_NAME, `Uploaded: ${fileRelativePath} => ${finalRemotePath}`);
232
- fileCount++;
233
- }
234
- return callback(error);
235
- });
236
- });
237
- });
238
- }
239
- function flush(callback) {
240
- if (fileCount > 0) {
241
- const unit = fileCount === 1 ? 'file' : 'files';
242
- BalmJS.logger.info(PLUGIN_NAME, `${fileCount} ${unit} uploaded successfully`);
243
- }
244
- else {
245
- BalmJS.logger.warn(PLUGIN_NAME, 'No files uploaded');
246
- }
247
- finished = true;
248
- if (sftpCache) {
249
- sftpCache.end();
250
- }
251
- if (connCache) {
252
- connCache.end();
253
- }
254
- callback();
255
- }
256
- return through2.obj(transform, flush);
257
- }
258
- export default gulpSftp;
@@ -1,59 +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 = [
14
- 'clean',
15
- ...(BalmJS.config.styles.sprites.length ? ['sprite'] : []),
16
- 'style',
17
- ...(BalmJS.config.scripts.lint ? ['lint'] : []),
18
- 'script',
19
- 'html',
20
- ...(BalmJS.config.env.isProd || !BalmJS.config.inFrontend
21
- ? ['image', 'font', 'media']
22
- : [])
23
- ];
24
- if (BalmJS.config.env.isProd) {
25
- tasks = [
26
- ...tasks,
27
- 'extra',
28
- 'build',
29
- ...(BalmJS.config.assets.cache ? ['cache'] : []),
30
- ...(BalmJS.config.pwa.enabled ? ['workbox-sw', 'pwa'] : [])
31
- ];
32
- }
33
- else {
34
- tasks = [...tasks, 'modernizr', 'serve'];
35
- }
36
- let defaultMainTasks = BalmJS.config.useDefaults
37
- ? BalmJS.toNamespace(tasks)
38
- : [];
39
- if (BalmJS.config.env.inSSR ||
40
- BalmJS.config.env.isMP ||
41
- BalmJS.config.env.inDesktopApp) {
42
- defaultMainTasks = BalmJS.toNamespace(BalmJS.config.env.isMP ? ['style', 'script'] : ['script']);
43
- }
44
- return defaultMainTasks;
45
- }
46
- get subTasks() {
47
- return BalmJS.recipes.length
48
- ? BalmJS.toNamespace(BalmJS.recipes)
49
- : [];
50
- }
51
- get endTask() {
52
- const tasks = BalmJS.toNamespace(['end']);
53
- if (BalmJS.utils.isString(BalmJS.afterTask)) {
54
- tasks.push(BalmJS.afterTask);
55
- }
56
- return tasks;
57
- }
58
- }
59
- export default DefaultTask;
@@ -1,75 +0,0 @@
1
- class BalmTask {
2
- name;
3
- taskName;
4
- defaultInput = '';
5
- defaultOutput = '';
6
- input = '';
7
- output = '';
8
- customOptions = {};
9
- gulpSrcOptions = {};
10
- constructor(name) {
11
- this.name = name;
12
- this.taskName = BalmJS.toNamespace(name);
13
- }
14
- get styleName() {
15
- let name;
16
- switch (BalmJS.config.styles.extname) {
17
- case 'sass':
18
- case 'scss':
19
- name = 'sass';
20
- break;
21
- case 'less':
22
- name = 'less';
23
- break;
24
- default:
25
- name = 'postcss';
26
- }
27
- return name;
28
- }
29
- get src() {
30
- return gulp
31
- .src(this.input, Object.assign({
32
- allowEmpty: true,
33
- encoding: false
34
- }, this.gulpSrcOptions))
35
- .pipe(BalmJS.plugins.plumber((error) => {
36
- BalmJS.logger.error(`${this.name} task`, error.message);
37
- }));
38
- }
39
- init(input, output, options = {}) {
40
- let key = this.name;
41
- switch (key) {
42
- case 'copy':
43
- key = 'rename';
44
- break;
45
- case 'jsmin':
46
- key = 'terser';
47
- break;
48
- default:
49
- }
50
- const useAbsPath = !['webpack', 'rollup', 'esbuild', 'sprite'].includes(key);
51
- this.input = useAbsPath && (input || this.defaultInput)
52
- ? BalmJS.file.absPaths(input || this.defaultInput)
53
- : input || this.defaultInput;
54
- this.output = useAbsPath && typeof (output || this.defaultOutput) === 'string'
55
- ? BalmJS.file.absPath(output || this.defaultOutput)
56
- : output || this.defaultOutput;
57
- this.customOptions = options[key] || {};
58
- const obj = {
59
- input: this.input,
60
- output: this.output
61
- };
62
- if (options[key]) {
63
- obj.customOptions = this.customOptions;
64
- }
65
- if (useAbsPath) {
66
- BalmJS.logger.debug(`${this.name} task`, obj, {
67
- pre: true
68
- });
69
- }
70
- if (options.src) {
71
- this.gulpSrcOptions = options.src;
72
- }
73
- }
74
- }
75
- export default BalmTask;
@@ -1,68 +0,0 @@
1
- import BalmTask from './balm.js';
2
- import { ASSET } from '../../config/constants.js';
3
- class BalmStyleTask extends BalmTask {
4
- constructor(name) {
5
- super(name);
6
- let extname;
7
- switch (name) {
8
- case 'sass':
9
- extname = '{scss,sass}';
10
- break;
11
- case 'less':
12
- extname = 'less';
13
- break;
14
- default:
15
- extname = 'css';
16
- }
17
- if (Array.isArray(BalmJS.config.styles.entry)) {
18
- this.defaultInput = BalmJS.config.styles.entry.map((styleEntry) => node.path.join(BalmJS.config.src.css, styleEntry));
19
- }
20
- else {
21
- if (BalmJS.config.styles.entry) {
22
- this.defaultInput = node.path.join(BalmJS.config.src.css, BalmJS.config.styles.entry);
23
- }
24
- else {
25
- this.defaultInput = node.path.join(BalmJS.config.src.css, '**', `!(_*).${extname}`);
26
- }
27
- }
28
- this.defaultOutput = BalmJS.config.env.isMP
29
- ? node.path.join(BalmJS.config.dest.base, ASSET.mpDir, BalmJS.config.paths.target.css)
30
- : BalmJS.config.dest.css;
31
- }
32
- handleStyle(style, output, options) {
33
- BalmJS.logger.debug(`${this.name} entry`, this.defaultInput, {
34
- pre: true
35
- });
36
- const taskName = `${this.name} task`;
37
- const shouldUseSourceMap = !(BalmJS.config.env.isProd || BalmJS.config.styles.minify);
38
- let stream = gulp
39
- .src(this.input, Object.assign({
40
- sourcemaps: shouldUseSourceMap,
41
- allowEmpty: true
42
- }, this.gulpSrcOptions))
43
- .pipe(BalmJS.plugins.plumber(function (error) {
44
- BalmJS.logger.error(taskName, error.message);
45
- this.emit('end');
46
- this.destroy();
47
- }));
48
- switch (style) {
49
- case 'sass':
50
- stream = stream.pipe(node.isLegacySass
51
- ? BalmJS.plugins.legacySass(options)
52
- : BalmJS.plugins.sass(options));
53
- break;
54
- case 'less':
55
- stream = stream.pipe(BalmJS.plugins.less(options));
56
- break;
57
- default:
58
- }
59
- return stream
60
- .pipe(BalmJS.plugins.postcss(BalmJS.plugins.postcssPlugins(style === 'postcss')))
61
- .pipe($.if(BalmJS.config.env.isMP, BalmJS.plugins.rename({ extname: '.wxss' })))
62
- .pipe(gulp.dest(output, {
63
- sourcemaps: shouldUseSourceMap
64
- }))
65
- .pipe(server.reload({ stream: true }));
66
- }
67
- }
68
- export default BalmStyleTask;
@@ -1,10 +0,0 @@
1
- import BalmTask from './balm.js';
2
- import BalmStyleTask from './balm_style.js';
3
- BalmJS.BalmTask = BalmTask;
4
- BalmJS.BalmStyleTask = BalmStyleTask;
5
- BalmJS.tasks = new Map();
6
- BalmJS.recipes = [];
7
- BalmJS.recipeIndex = 0;
8
- BalmJS.server = null;
9
- BalmJS.watchFtpFile = '';
10
- BalmJS.watching = false;