@madebyseed/seed-cli-tools 2.3.2 → 3.0.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/lib/commands/build.d.ts +2 -0
- package/lib/commands/build.js +30 -29
- package/lib/commands/build.js.map +1 -0
- package/lib/commands/deploy.d.ts +2 -0
- package/lib/commands/deploy.js +47 -30
- package/lib/commands/deploy.js.map +1 -0
- package/lib/commands/pull.d.ts +2 -0
- package/lib/commands/pull.js +39 -29
- package/lib/commands/pull.js.map +1 -0
- package/lib/commands/watch.d.ts +2 -0
- package/lib/commands/watch.js +44 -40
- package/lib/commands/watch.js.map +1 -0
- package/lib/commands/zip.d.ts +2 -0
- package/lib/commands/zip.js +23 -25
- package/lib/commands/zip.js.map +1 -0
- package/lib/config.d.ts +3 -0
- package/lib/config.js +21 -28
- package/lib/config.js.map +1 -0
- package/lib/gulpfile.d.ts +1 -0
- package/lib/gulpfile.js +26 -33
- package/lib/gulpfile.js.map +1 -0
- package/lib/tasks/build-assets.d.ts +1 -0
- package/lib/tasks/build-assets.js +80 -72
- package/lib/tasks/build-assets.js.map +1 -0
- package/lib/tasks/build-css.d.ts +1 -0
- package/lib/tasks/build-css.js +88 -82
- package/lib/tasks/build-css.js.map +1 -0
- package/lib/tasks/build-js.d.ts +1 -0
- package/lib/tasks/build-js.js +78 -82
- package/lib/tasks/build-js.js.map +1 -0
- package/lib/tasks/build-svg.d.ts +1 -0
- package/lib/tasks/build-svg.js +51 -54
- package/lib/tasks/build-svg.js.map +1 -0
- package/lib/tasks/build-utils.d.ts +1 -0
- package/lib/tasks/build-utils.js +68 -49
- package/lib/tasks/build-utils.js.map +1 -0
- package/lib/tasks/includes/config.d.ts +71 -0
- package/lib/tasks/includes/config.js +118 -163
- package/lib/tasks/includes/config.js.map +1 -0
- package/lib/tasks/includes/messages.d.ts +19 -0
- package/lib/tasks/includes/messages.js +80 -72
- package/lib/tasks/includes/messages.js.map +1 -0
- package/lib/tasks/includes/utilities.d.ts +71 -0
- package/lib/tasks/includes/utilities.js +127 -141
- package/lib/tasks/includes/utilities.js.map +1 -0
- package/lib/tasks/shopify-cli.d.ts +1 -0
- package/lib/tasks/shopify-cli.js +107 -93
- package/lib/tasks/shopify-cli.js.map +1 -0
- package/lib/tasks/watchers.d.ts +1 -0
- package/lib/tasks/watchers.js +29 -29
- package/lib/tasks/watchers.js.map +1 -0
- package/lib/types.d.ts +53 -0
- package/lib/types.js +3 -0
- package/lib/types.js.map +1 -0
- package/lib/utils.d.ts +102 -0
- package/lib/utils.js +310 -189
- package/lib/utils.js.map +1 -0
- package/package.json +36 -16
- package/src/commands/build.ts +39 -0
- package/src/commands/deploy.ts +79 -0
- package/src/commands/pull.ts +58 -0
- package/src/commands/watch.ts +72 -0
- package/src/commands/zip.ts +28 -0
- package/src/config.ts +28 -0
- package/src/gulpfile.ts +134 -0
- package/src/tasks/build-assets.ts +135 -0
- package/src/tasks/build-css.ts +129 -0
- package/src/tasks/build-js.ts +108 -0
- package/src/tasks/build-svg.ts +92 -0
- package/src/tasks/build-utils.ts +137 -0
- package/src/tasks/includes/config.ts +224 -0
- package/src/tasks/includes/messages.ts +157 -0
- package/src/tasks/includes/utilities.ts +170 -0
- package/src/tasks/shopify-cli.ts +199 -0
- package/src/tasks/watchers.ts +50 -0
- package/src/types/declarations.d.ts +72 -0
- package/src/types.ts +84 -0
- package/src/utils.ts +444 -0
- package/tsconfig.json +14 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/.babelrc +0 -3
- package/.eslintrc +0 -8
- /package/{src → src-legacy}/commands/build.js +0 -0
- /package/{src → src-legacy}/commands/deploy.js +0 -0
- /package/{src → src-legacy}/commands/pull.js +0 -0
- /package/{src → src-legacy}/commands/watch.js +0 -0
- /package/{src → src-legacy}/commands/zip.js +0 -0
- /package/{src → src-legacy}/config.js +0 -0
- /package/{src → src-legacy}/gulpfile.js +0 -0
- /package/{src → src-legacy}/tasks/build-assets.js +0 -0
- /package/{src → src-legacy}/tasks/build-css.js +0 -0
- /package/{src → src-legacy}/tasks/build-js.js +0 -0
- /package/{src → src-legacy}/tasks/build-svg.js +0 -0
- /package/{src → src-legacy}/tasks/build-utils.js +0 -0
- /package/{src → src-legacy}/tasks/includes/config.js +0 -0
- /package/{src → src-legacy}/tasks/includes/messages.js +0 -0
- /package/{src → src-legacy}/tasks/includes/utilities.js +0 -0
- /package/{src → src-legacy}/tasks/shopify-cli.js +0 -0
- /package/{src → src-legacy}/tasks/watchers.js +0 -0
- /package/{src → src-legacy}/utils.js +0 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import gulp from "gulp";
|
|
3
|
+
import gulpSass from "gulp-sass";
|
|
4
|
+
import sass from "sass";
|
|
5
|
+
import postcss from "gulp-postcss";
|
|
6
|
+
import plumber from "gulp-plumber";
|
|
7
|
+
import chokidar from "chokidar";
|
|
8
|
+
import { glob } from "glob";
|
|
9
|
+
import { utimesSync } from "fs";
|
|
10
|
+
import config from "./includes/config";
|
|
11
|
+
import messages from "./includes/messages";
|
|
12
|
+
import utils from "./includes/utilities";
|
|
13
|
+
|
|
14
|
+
interface TailwindConfig {
|
|
15
|
+
mode?: string;
|
|
16
|
+
[key: string]: unknown;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const sassCompiler = gulpSass(sass);
|
|
20
|
+
const tailwindConfig: TailwindConfig = config.usesTailwind
|
|
21
|
+
? require(path.join(config.themeRoot, config.tailwindConfig))
|
|
22
|
+
: {};
|
|
23
|
+
|
|
24
|
+
const assets: string[] =
|
|
25
|
+
config.usesTailwind || tailwindConfig.mode === "jit"
|
|
26
|
+
? [
|
|
27
|
+
config.src.css,
|
|
28
|
+
config.src.scss,
|
|
29
|
+
config.src.sections,
|
|
30
|
+
config.src.layout,
|
|
31
|
+
config.src.snippets,
|
|
32
|
+
config.src.assets,
|
|
33
|
+
config.src.templates,
|
|
34
|
+
config.src.js,
|
|
35
|
+
config.src.icons,
|
|
36
|
+
config.tailwindConfig,
|
|
37
|
+
]
|
|
38
|
+
: [config.src.css, config.src.scss, config.tailwindConfig];
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Process css and tailwind
|
|
42
|
+
*
|
|
43
|
+
* @returns {Promise<void>}
|
|
44
|
+
* @private
|
|
45
|
+
*/
|
|
46
|
+
function processCss(): Promise<void> {
|
|
47
|
+
return new Promise((resolve, reject) => {
|
|
48
|
+
gulp
|
|
49
|
+
.src(config.roots.css, { allowEmpty: true })
|
|
50
|
+
.pipe(plumber(utils.errorHandler))
|
|
51
|
+
.pipe(postcss(config.plugins.postcss))
|
|
52
|
+
.pipe(gulp.dest(config.dist.assets))
|
|
53
|
+
.on("finish", resolve)
|
|
54
|
+
.on("error", reject);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Process sass files
|
|
60
|
+
*
|
|
61
|
+
* @returns {Promise<void>}
|
|
62
|
+
* @private
|
|
63
|
+
*/
|
|
64
|
+
function processSass(): Promise<void> {
|
|
65
|
+
return new Promise((resolve, reject) => {
|
|
66
|
+
gulp
|
|
67
|
+
.src(config.roots.scss, { allowEmpty: true })
|
|
68
|
+
.pipe(plumber(utils.errorHandler))
|
|
69
|
+
.pipe(sassCompiler())
|
|
70
|
+
.pipe(postcss(config.plugins.postcss))
|
|
71
|
+
.pipe(gulp.dest(config.dist.assets))
|
|
72
|
+
.on("finish", resolve)
|
|
73
|
+
.on("error", reject);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Touch CSS files to update their modification time
|
|
79
|
+
* This ensures Shopify's watcher detects the changes
|
|
80
|
+
*/
|
|
81
|
+
function touchCssFiles(): void {
|
|
82
|
+
try {
|
|
83
|
+
const cssFiles = glob.sync(`${config.dist.assets}*.css`);
|
|
84
|
+
cssFiles.forEach((file) => {
|
|
85
|
+
// Update the file modification time to trigger Shopify's watcher
|
|
86
|
+
const now = new Date();
|
|
87
|
+
utimesSync(file, now, now);
|
|
88
|
+
messages.logFileEvent("touch", file);
|
|
89
|
+
});
|
|
90
|
+
} catch (error) {
|
|
91
|
+
console.error("Error touching CSS files:", error);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Concatenate css via gulp-cssimport
|
|
97
|
+
*
|
|
98
|
+
* @function build:css
|
|
99
|
+
* @memberof seed-cli.tasks.build
|
|
100
|
+
* @static
|
|
101
|
+
*/
|
|
102
|
+
gulp.task("build:css", () => {
|
|
103
|
+
return Promise.all([processCss(), processSass()]);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Watches css in the `/src` directory
|
|
108
|
+
*
|
|
109
|
+
* @function watch:css
|
|
110
|
+
* @memberof seed-cli.tasks.watch
|
|
111
|
+
* @static
|
|
112
|
+
*/
|
|
113
|
+
gulp.task("watch:css", () => {
|
|
114
|
+
chokidar.watch(assets, { ignoreInitial: true }).on("all", (event, path) => {
|
|
115
|
+
const isCssFile = /\.s[ac]ss$/i.test(path);
|
|
116
|
+
// Don't log event twice
|
|
117
|
+
if (isCssFile) {
|
|
118
|
+
processSass();
|
|
119
|
+
messages.logFileEvent(event, path);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
processCss();
|
|
123
|
+
|
|
124
|
+
// Important: Touch CSS files after processing to ensure Shopify detects changes
|
|
125
|
+
setTimeout(() => {
|
|
126
|
+
touchCssFiles();
|
|
127
|
+
}, 500);
|
|
128
|
+
});
|
|
129
|
+
});
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import gulp from "gulp";
|
|
2
|
+
import gulpif from "gulp-if";
|
|
3
|
+
import uglifyjs from "uglify-js";
|
|
4
|
+
import composer from "gulp-uglify/composer";
|
|
5
|
+
import include from "gulp-include";
|
|
6
|
+
import plumber from "gulp-plumber";
|
|
7
|
+
import chokidar from "chokidar";
|
|
8
|
+
import { glob } from "glob";
|
|
9
|
+
import { utimesSync } from "fs";
|
|
10
|
+
import utils from "./includes/utilities";
|
|
11
|
+
import config from "./includes/config";
|
|
12
|
+
import messages from "./includes/messages";
|
|
13
|
+
// Using Console type from Node.js types
|
|
14
|
+
import type { Console } from "console";
|
|
15
|
+
|
|
16
|
+
const minify = composer(uglifyjs, console as Console);
|
|
17
|
+
|
|
18
|
+
interface MinifyOptions {
|
|
19
|
+
mangle: boolean;
|
|
20
|
+
compress: boolean;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function processThemeJs(): NodeJS.ReadWriteStream {
|
|
24
|
+
messages.logProcessFiles("build:js");
|
|
25
|
+
|
|
26
|
+
return gulp
|
|
27
|
+
.src([config.roots.js, `!${config.roots.vendorJs}`], { allowEmpty: true })
|
|
28
|
+
.pipe(plumber(utils.errorHandler))
|
|
29
|
+
.pipe(include({ separateInputs: true }))
|
|
30
|
+
.pipe(gulpif(config.optimize && !config.usesModuleBundler, minify()))
|
|
31
|
+
.pipe(gulp.dest(config.dist.assets));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function processVendorJs(): NodeJS.ReadWriteStream {
|
|
35
|
+
messages.logProcessFiles("build:vendor-js");
|
|
36
|
+
return gulp
|
|
37
|
+
.src(config.roots.vendorJs, { allowEmpty: true })
|
|
38
|
+
.pipe(plumber())
|
|
39
|
+
.pipe(include())
|
|
40
|
+
.pipe(
|
|
41
|
+
minify({
|
|
42
|
+
mangle: true,
|
|
43
|
+
compress: true,
|
|
44
|
+
} as MinifyOptions),
|
|
45
|
+
)
|
|
46
|
+
.pipe(gulp.dest(config.dist.assets));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Touch JS files to update their modification time
|
|
51
|
+
* This ensures Shopify's watcher detects the changes
|
|
52
|
+
*/
|
|
53
|
+
function touchJsFiles(): void {
|
|
54
|
+
try {
|
|
55
|
+
const jsFiles = glob.sync(`${config.dist.assets}*.js`);
|
|
56
|
+
jsFiles.forEach((file) => {
|
|
57
|
+
// Update the file modification time to trigger Shopify's watcher
|
|
58
|
+
const now = new Date();
|
|
59
|
+
utimesSync(file, now, now);
|
|
60
|
+
messages.logFileEvent("touch", file);
|
|
61
|
+
});
|
|
62
|
+
} catch (error) {
|
|
63
|
+
console.error("Error touching JS files:", error);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
gulp.task("build:js", () => {
|
|
68
|
+
return processThemeJs();
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
gulp.task("watch:js", () => {
|
|
72
|
+
chokidar
|
|
73
|
+
.watch(
|
|
74
|
+
[config.src.js, `!${config.roots.vendorJs}`, `!${config.src.vendorJs}`],
|
|
75
|
+
{
|
|
76
|
+
ignoreInitial: true,
|
|
77
|
+
},
|
|
78
|
+
)
|
|
79
|
+
.on("all", (event, path) => {
|
|
80
|
+
messages.logFileEvent(event, path);
|
|
81
|
+
processThemeJs();
|
|
82
|
+
|
|
83
|
+
setTimeout(() => {
|
|
84
|
+
touchJsFiles();
|
|
85
|
+
}, 500);
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
gulp.task("build:vendor-js", () => {
|
|
90
|
+
return processVendorJs();
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
gulp.task("watch:vendor-js", () => {
|
|
94
|
+
chokidar
|
|
95
|
+
.watch([config.roots.vendorJs, config.src.vendorJs], {
|
|
96
|
+
ignoreInitial: true,
|
|
97
|
+
})
|
|
98
|
+
.on("all", (event, path) => {
|
|
99
|
+
messages.logFileEvent(event, path);
|
|
100
|
+
const stream = processVendorJs();
|
|
101
|
+
stream.on("end", () => {
|
|
102
|
+
// Touch JS files after processing to ensure Shopify detects changes
|
|
103
|
+
setTimeout(() => {
|
|
104
|
+
touchJsFiles();
|
|
105
|
+
}, 500);
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
});
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import gulp from "gulp";
|
|
2
|
+
import vinylPaths from "vinyl-paths";
|
|
3
|
+
import del from "del";
|
|
4
|
+
import size from "gulp-size";
|
|
5
|
+
import chokidar from "chokidar";
|
|
6
|
+
import extReplace from "gulp-ext-replace";
|
|
7
|
+
import plumber from "gulp-plumber";
|
|
8
|
+
|
|
9
|
+
import config from "./includes/config";
|
|
10
|
+
import utils from "./includes/utilities";
|
|
11
|
+
import messages from "./includes/messages";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Processing for SVGs prior to deployment - adds accessibility markup, and converts
|
|
15
|
+
* the file to a liquid snippet.
|
|
16
|
+
*
|
|
17
|
+
* @param {String|Array} files - glob/array of files to match & send to the stream
|
|
18
|
+
* @returns {Stream}
|
|
19
|
+
* @private
|
|
20
|
+
*/
|
|
21
|
+
function processIcons(files: string | string[]): NodeJS.ReadWriteStream {
|
|
22
|
+
messages.logProcessFiles("build:svg");
|
|
23
|
+
return gulp
|
|
24
|
+
.src(files)
|
|
25
|
+
.pipe(plumber(utils.errorHandler))
|
|
26
|
+
.pipe(extReplace(".liquid"))
|
|
27
|
+
.pipe(
|
|
28
|
+
size({
|
|
29
|
+
showFiles: true,
|
|
30
|
+
pretty: true,
|
|
31
|
+
}),
|
|
32
|
+
)
|
|
33
|
+
.pipe(gulp.dest(config.dist.snippets));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Cleanup/remove liquid snippets from the `dist` directory during watch tasks if
|
|
38
|
+
* any underlying SVG files in the `src` folder have been removed.
|
|
39
|
+
*
|
|
40
|
+
* @param {String|Array} files - glob/array of files to match & send to the stream
|
|
41
|
+
* @returns {Stream}
|
|
42
|
+
* @private
|
|
43
|
+
*/
|
|
44
|
+
function removeIcons(files: string[]): NodeJS.ReadWriteStream {
|
|
45
|
+
messages.logProcessFiles("remove:svg");
|
|
46
|
+
const mapFiles = files.map((file) => {
|
|
47
|
+
const distFile = file.replace("src/icons", "dist/snippets");
|
|
48
|
+
const snippetFile = distFile.replace(".svg", ".liquid");
|
|
49
|
+
return snippetFile;
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
return gulp
|
|
53
|
+
.src(mapFiles)
|
|
54
|
+
.pipe(plumber(utils.errorHandler))
|
|
55
|
+
.pipe(vinylPaths(del))
|
|
56
|
+
.pipe(
|
|
57
|
+
size({
|
|
58
|
+
showFiles: true,
|
|
59
|
+
pretty: true,
|
|
60
|
+
}),
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Pre-processing for svg icons
|
|
66
|
+
*
|
|
67
|
+
* @function build:svg
|
|
68
|
+
* @memberof slate-cli.tasks.build
|
|
69
|
+
* @static
|
|
70
|
+
*/
|
|
71
|
+
gulp.task("build:svg", () => {
|
|
72
|
+
return processIcons(config.src.icons);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Watches source svg icons for changes...
|
|
77
|
+
*
|
|
78
|
+
* @function watch:svg
|
|
79
|
+
* @memberof slate-cli.tasks.watch
|
|
80
|
+
* @static
|
|
81
|
+
*/
|
|
82
|
+
gulp.task("watch:svg", () => {
|
|
83
|
+
const cache = utils.createEventCache();
|
|
84
|
+
|
|
85
|
+
chokidar
|
|
86
|
+
.watch([config.src.icons], { ignoreInitial: true })
|
|
87
|
+
.on("all", (event, path) => {
|
|
88
|
+
messages.logFileEvent(event, path);
|
|
89
|
+
cache.addEvent(event, path);
|
|
90
|
+
utils.processCache(cache, processIcons, removeIcons);
|
|
91
|
+
});
|
|
92
|
+
});
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import gulp from "gulp";
|
|
2
|
+
import gulpif from "gulp-if";
|
|
3
|
+
import del from "del";
|
|
4
|
+
import size from "gulp-size";
|
|
5
|
+
import plumber from "gulp-plumber";
|
|
6
|
+
|
|
7
|
+
import config from "./includes/config";
|
|
8
|
+
import utils from "./includes/utilities";
|
|
9
|
+
import messages from "./includes/messages";
|
|
10
|
+
import { getProjectConfig } from "../utils";
|
|
11
|
+
|
|
12
|
+
const assetsPaths: string[] = [
|
|
13
|
+
config.src.assets,
|
|
14
|
+
config.src.templates,
|
|
15
|
+
config.src.sections,
|
|
16
|
+
config.src.snippets,
|
|
17
|
+
config.src.blocks,
|
|
18
|
+
config.src.locales,
|
|
19
|
+
config.src.config,
|
|
20
|
+
config.src.layout,
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Get theme settings assets to sync, respecting project config ignore list
|
|
25
|
+
*/
|
|
26
|
+
function getThemeSettingsAssets(): string[] {
|
|
27
|
+
const defaultAssets = [
|
|
28
|
+
config.tmp.templates,
|
|
29
|
+
config.tmp.config,
|
|
30
|
+
config.tmp.sectionsJson,
|
|
31
|
+
config.tmp.blocksJson,
|
|
32
|
+
config.tmp.locales,
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
// Convert ignore patterns to negated glob patterns
|
|
36
|
+
const ignorePatterns = getIgnorePatterns();
|
|
37
|
+
|
|
38
|
+
// Combine default assets with ignore patterns
|
|
39
|
+
return [...defaultAssets, ...ignorePatterns];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function getIgnorePatterns(): string[] {
|
|
43
|
+
const projectConfig = getProjectConfig(config.themeRoot);
|
|
44
|
+
if (!projectConfig?.pull?.ignoreFiles?.length) {
|
|
45
|
+
return [];
|
|
46
|
+
}
|
|
47
|
+
return projectConfig.pull.ignoreFiles.map((pattern) =>
|
|
48
|
+
pattern.startsWith("!") ? pattern : `!tmp/${pattern}`,
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
interface SrcOptions {
|
|
53
|
+
base?: string;
|
|
54
|
+
[key: string]: unknown;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Copies files from one fold to another, creating a new dir if doesn't exists and
|
|
59
|
+
* overwriting if it does exist
|
|
60
|
+
*
|
|
61
|
+
* @param {Array} files - files to copy
|
|
62
|
+
* @param {Object} srcOptions - second param for gulp.src function
|
|
63
|
+
* @param {String} dest - destination dir
|
|
64
|
+
* @returns {Stream}
|
|
65
|
+
* @private
|
|
66
|
+
*/
|
|
67
|
+
function copyFiles(
|
|
68
|
+
files: string | string[],
|
|
69
|
+
srcOptions: SrcOptions,
|
|
70
|
+
dest: string,
|
|
71
|
+
log = false,
|
|
72
|
+
): NodeJS.ReadWriteStream {
|
|
73
|
+
return gulp
|
|
74
|
+
.src(files, srcOptions)
|
|
75
|
+
.pipe(plumber(utils.errorHandler))
|
|
76
|
+
.pipe(gulpif(log, size({ showFiles: true, pretty: true })))
|
|
77
|
+
.pipe(gulp.dest(dest));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Clean up build dirs/files whenever doing a full/clean (re)build.
|
|
82
|
+
*
|
|
83
|
+
* @function build:clean
|
|
84
|
+
* @memberof slate-cli.tasks.build
|
|
85
|
+
* @static
|
|
86
|
+
*/
|
|
87
|
+
gulp.task("clean", () => {
|
|
88
|
+
return del(["upload", "dist", "tmp", "src/*.zip", "*.zip"]);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Duplicates /src directory into a /tmp directory
|
|
93
|
+
*
|
|
94
|
+
* @function generate:tmp
|
|
95
|
+
* @memberof seed-cli.tasks.sync-settings
|
|
96
|
+
* @static
|
|
97
|
+
*/
|
|
98
|
+
gulp.task("generate:tmp", () => {
|
|
99
|
+
messages.logProcessFiles("Generating tmp folder...");
|
|
100
|
+
return copyFiles(assetsPaths, { base: config.src.root }, config.tmp.root);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Synchronizes the theme settings of /tmp directory into our src directory
|
|
105
|
+
*
|
|
106
|
+
* @function sync-settings:tmp:src
|
|
107
|
+
* @memberof seed-cli.tasks.sync-settings
|
|
108
|
+
* @static
|
|
109
|
+
*/
|
|
110
|
+
gulp.task("sync-settings:tmp:src", () => {
|
|
111
|
+
messages.logProcessFiles("Synchronizing /tmp theme settings with /src");
|
|
112
|
+
const ignorePatterns = getIgnorePatterns();
|
|
113
|
+
const themeSettingsAssets = getThemeSettingsAssets();
|
|
114
|
+
messages.logProcessFiles(
|
|
115
|
+
`Using ignore patterns from project config: ${JSON.stringify(ignorePatterns)}`,
|
|
116
|
+
);
|
|
117
|
+
return copyFiles(
|
|
118
|
+
themeSettingsAssets,
|
|
119
|
+
{ base: config.tmp.root },
|
|
120
|
+
config.src.root,
|
|
121
|
+
);
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Copies zip from dist to src
|
|
126
|
+
* @function copy:zip
|
|
127
|
+
* @memberof seed-cli.tasks.sync-settings
|
|
128
|
+
* @static
|
|
129
|
+
*/
|
|
130
|
+
gulp.task("copy:zip", () => {
|
|
131
|
+
return copyFiles(
|
|
132
|
+
config.dist.zip,
|
|
133
|
+
{ base: config.dist.root },
|
|
134
|
+
config.themeRoot,
|
|
135
|
+
true,
|
|
136
|
+
);
|
|
137
|
+
});
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import { join } from "path";
|
|
2
|
+
import debug from "debug";
|
|
3
|
+
import findRoot from "find-root";
|
|
4
|
+
import tailwindcss from "tailwindcss";
|
|
5
|
+
import cssnano from "cssnano";
|
|
6
|
+
import pxtorem from "postcss-pxtorem";
|
|
7
|
+
import reporter from "postcss-reporter";
|
|
8
|
+
import minimist from "minimist";
|
|
9
|
+
import { existsSync } from "fs";
|
|
10
|
+
import autoprefixer from "autoprefixer";
|
|
11
|
+
import postcssImport from "postcss-import";
|
|
12
|
+
|
|
13
|
+
const logger = debug("seed-tools");
|
|
14
|
+
const argv = minimist(process.argv.slice(2));
|
|
15
|
+
const themeRoot = findRoot(process.cwd());
|
|
16
|
+
const tailwindConfig = "tailwind.config.js";
|
|
17
|
+
|
|
18
|
+
interface PackageJson {
|
|
19
|
+
"bundle-js"?: boolean;
|
|
20
|
+
[key: string]: unknown;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
let pkg: PackageJson = {};
|
|
24
|
+
|
|
25
|
+
try {
|
|
26
|
+
pkg = require(join(themeRoot, "package.json"));
|
|
27
|
+
} catch (err) {
|
|
28
|
+
logger(err);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
interface PathConfig {
|
|
32
|
+
root: string;
|
|
33
|
+
js: string;
|
|
34
|
+
vendorJs: string;
|
|
35
|
+
json: string;
|
|
36
|
+
css: string;
|
|
37
|
+
scss: string;
|
|
38
|
+
cssLint: string;
|
|
39
|
+
vendorCss: string;
|
|
40
|
+
assets: string;
|
|
41
|
+
icons: string;
|
|
42
|
+
templates: string;
|
|
43
|
+
snippets: string;
|
|
44
|
+
sections: string;
|
|
45
|
+
blocks: string;
|
|
46
|
+
locales: string;
|
|
47
|
+
config: string;
|
|
48
|
+
layout: string;
|
|
49
|
+
zip: string;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
interface TmpPathConfig extends PathConfig {
|
|
53
|
+
sectionsJson: string;
|
|
54
|
+
blocksJson: string;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
interface DistPathConfig {
|
|
58
|
+
root: string;
|
|
59
|
+
assets: string;
|
|
60
|
+
snippets: string;
|
|
61
|
+
sections: string;
|
|
62
|
+
blocks: string;
|
|
63
|
+
layout: string;
|
|
64
|
+
templates: string;
|
|
65
|
+
locales: string;
|
|
66
|
+
zip: string;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
interface RootsConfig {
|
|
70
|
+
js: string;
|
|
71
|
+
vendorJs: string;
|
|
72
|
+
css: string;
|
|
73
|
+
scss: string;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
interface PluginsConfig {
|
|
77
|
+
postcss: any[];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
interface BuildConfig {
|
|
81
|
+
environment: string;
|
|
82
|
+
store: string | null;
|
|
83
|
+
theme: string | null;
|
|
84
|
+
storePassword: string | null;
|
|
85
|
+
optimize: boolean;
|
|
86
|
+
nodelete: boolean;
|
|
87
|
+
themeRoot: string;
|
|
88
|
+
packageJson: PackageJson;
|
|
89
|
+
tailwindConfig: string;
|
|
90
|
+
usesTailwind: boolean;
|
|
91
|
+
usesModuleBundler: boolean;
|
|
92
|
+
seedConfig: string;
|
|
93
|
+
shopifyIgnore: string;
|
|
94
|
+
src: PathConfig;
|
|
95
|
+
tmp: TmpPathConfig;
|
|
96
|
+
dist: DistPathConfig;
|
|
97
|
+
roots: RootsConfig;
|
|
98
|
+
plugins: PluginsConfig;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const config: BuildConfig = {
|
|
102
|
+
environment:
|
|
103
|
+
argv.environment === "undefined" || !argv.environment
|
|
104
|
+
? "development"
|
|
105
|
+
: argv.environment,
|
|
106
|
+
store: argv.store === "undefined" || !argv.store ? null : argv.store,
|
|
107
|
+
theme: argv.theme === "undefined" || !argv.theme ? null : argv.theme,
|
|
108
|
+
storePassword:
|
|
109
|
+
argv["store-password"] === "undefined" || !argv["store-password"]
|
|
110
|
+
? null
|
|
111
|
+
: argv["store-password"],
|
|
112
|
+
optimize: !argv["skip-optimizations"],
|
|
113
|
+
nodelete: !argv["delete"],
|
|
114
|
+
themeRoot,
|
|
115
|
+
packageJson: pkg,
|
|
116
|
+
tailwindConfig,
|
|
117
|
+
usesTailwind: existsSync(join(themeRoot, tailwindConfig)),
|
|
118
|
+
usesModuleBundler: !!pkg["bundle-js"],
|
|
119
|
+
seedConfig: "seed.config.js",
|
|
120
|
+
shopifyIgnore: join(themeRoot, ".shopifyignore"),
|
|
121
|
+
|
|
122
|
+
src: {
|
|
123
|
+
root: "src/",
|
|
124
|
+
js: "src/scripts/**/*.{js,js.liquid}",
|
|
125
|
+
vendorJs: "src/scripts/vendor/*.js",
|
|
126
|
+
json: "src/**/*.json",
|
|
127
|
+
css: "src/styles/**/*.css",
|
|
128
|
+
scss: "src/styles/**/*.scss",
|
|
129
|
+
cssLint: "src/styles/**/*.{css,scss}",
|
|
130
|
+
vendorCss: "src/styles/vendor/*.{css,scss}",
|
|
131
|
+
assets: "src/assets/**/*",
|
|
132
|
+
icons: "src/icons/**/*.svg",
|
|
133
|
+
templates: "src/templates/**/*",
|
|
134
|
+
snippets: "src/snippets/*",
|
|
135
|
+
sections: "src/sections/*",
|
|
136
|
+
blocks: "src/blocks/*",
|
|
137
|
+
locales: "src/locales/*",
|
|
138
|
+
config: "src/config/*",
|
|
139
|
+
layout: "src/layout/*",
|
|
140
|
+
zip: "src/**/*.zip",
|
|
141
|
+
},
|
|
142
|
+
|
|
143
|
+
tmp: {
|
|
144
|
+
root: "tmp/",
|
|
145
|
+
js: "tmp/scripts/**/*.{js,js.liquid}",
|
|
146
|
+
vendorJs: "tmp/scripts/vendor/*.js",
|
|
147
|
+
json: "tmp/**/*.json",
|
|
148
|
+
css: "tmp/styles/**/*.css",
|
|
149
|
+
scss: "tmp/styles/**/*.scss",
|
|
150
|
+
cssLint: "tmp/styles/**/*.{css,scss}",
|
|
151
|
+
vendorCss: "tmp/styles/vendor/*.{css,scss}",
|
|
152
|
+
assets: "tmp/assets/**/*",
|
|
153
|
+
icons: "tmp/icons/**/*.svg",
|
|
154
|
+
templates: "tmp/templates/**/*",
|
|
155
|
+
snippets: "tmp/snippets/*",
|
|
156
|
+
sections: "tmp/sections/*",
|
|
157
|
+
sectionsJson: "tmp/sections/*.json",
|
|
158
|
+
blocks: "tmp/blocks/*",
|
|
159
|
+
blocksJson: "tmp/blocks/*.json",
|
|
160
|
+
locales: "tmp/locales/*",
|
|
161
|
+
config: "tmp/config/*",
|
|
162
|
+
layout: "tmp/layout/*",
|
|
163
|
+
zip: "tmp/**/*.zip",
|
|
164
|
+
},
|
|
165
|
+
|
|
166
|
+
dist: {
|
|
167
|
+
root: "dist/",
|
|
168
|
+
assets: "dist/assets/",
|
|
169
|
+
snippets: "dist/snippets/",
|
|
170
|
+
sections: "dist/sections/",
|
|
171
|
+
blocks: "dist/blocks",
|
|
172
|
+
layout: "dist/layout/",
|
|
173
|
+
templates: "dist/templates/",
|
|
174
|
+
locales: "dist/locales/",
|
|
175
|
+
zip: "dist/*.zip",
|
|
176
|
+
},
|
|
177
|
+
|
|
178
|
+
roots: {
|
|
179
|
+
js: "src/scripts/*.{js,js.liquid}",
|
|
180
|
+
vendorJs: "src/scripts/vendor.js",
|
|
181
|
+
css: "src/styles/*.css",
|
|
182
|
+
scss: "src/styles/*.scss",
|
|
183
|
+
},
|
|
184
|
+
|
|
185
|
+
plugins: {
|
|
186
|
+
postcss: [postcssImport],
|
|
187
|
+
},
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
if (config.usesTailwind) {
|
|
191
|
+
config.plugins.postcss.push(
|
|
192
|
+
tailwindcss({ config: join(themeRoot, tailwindConfig) }),
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
config.plugins.postcss.push(autoprefixer);
|
|
197
|
+
|
|
198
|
+
config.plugins.postcss.push(
|
|
199
|
+
pxtorem({
|
|
200
|
+
rootValue: 16,
|
|
201
|
+
unitPrecision: 5,
|
|
202
|
+
propList: ["*"],
|
|
203
|
+
selectorBlackList: [],
|
|
204
|
+
replace: true,
|
|
205
|
+
mediaQuery: true,
|
|
206
|
+
exclude: /node_modules/i,
|
|
207
|
+
}),
|
|
208
|
+
);
|
|
209
|
+
|
|
210
|
+
if (config.optimize) {
|
|
211
|
+
config.plugins.postcss.push(cssnano({ preset: "default" }));
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
config.plugins.postcss.push(reporter({ clearReportedMessages: true }));
|
|
215
|
+
|
|
216
|
+
export default config;
|
|
217
|
+
export type {
|
|
218
|
+
BuildConfig,
|
|
219
|
+
PathConfig,
|
|
220
|
+
TmpPathConfig,
|
|
221
|
+
DistPathConfig,
|
|
222
|
+
RootsConfig,
|
|
223
|
+
PluginsConfig,
|
|
224
|
+
};
|