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,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;
@@ -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;
@@ -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;
@@ -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;