@madebyseed/seed-cli-tools 1.0.1 → 1.2.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/deploy.js +6 -5
- package/lib/commands/watch.js +3 -1
- package/lib/commands/zip.js +27 -0
- package/lib/config.js +3 -1
- package/lib/gulpfile.js +26 -13
- package/lib/tasks/build-js.js +4 -3
- package/lib/tasks/build-utils.js +58 -13
- package/lib/tasks/includes/config.js +66 -39
- package/lib/tasks/includes/utilities.js +14 -38
- package/lib/tasks/shopify-cli.js +97 -0
- package/lib/tasks/watchers.js +24 -15
- package/lib/utils.js +113 -14
- package/package.json +4 -2
- package/src/commands/deploy.js +32 -15
- package/src/commands/watch.js +10 -0
- package/src/commands/zip.js +27 -0
- package/src/config.js +2 -0
- package/src/gulpfile.js +45 -27
- package/src/tasks/build-js.js +2 -1
- package/src/tasks/build-utils.js +76 -15
- package/src/tasks/includes/config.js +67 -41
- package/src/tasks/includes/utilities.js +24 -45
- package/src/tasks/shopify-cli.js +96 -0
- package/src/tasks/watchers.js +22 -21
- package/src/utils.js +99 -29
- package/lib/tasks/deploy.js +0 -19
- package/src/tasks/deploy.js +0 -15
package/lib/tasks/watchers.js
CHANGED
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
var gulp = require("gulp");
|
|
4
|
+
|
|
5
|
+
var config = require("./includes/config");
|
|
6
|
+
|
|
7
|
+
var chokidar = require("chokidar");
|
|
8
|
+
|
|
9
|
+
var utils = require("./includes/utilities"); // const runSequence = require('gulp4-run-sequence');
|
|
5
10
|
// const _ = require('lodash');
|
|
6
11
|
// const debug = require('debug')('seed-tools:watchers');
|
|
7
|
-
// const chokidar = require('chokidar');
|
|
8
12
|
// const fs = require('fs');
|
|
9
13
|
// const themekit = require('@shopify/themekit');
|
|
10
14
|
// const Promise = require('bluebird');
|
|
11
15
|
// const config = require('./includes/config.js');
|
|
12
16
|
|
|
13
17
|
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
// const environment = config.environment.split(/\s*,\s*|\s+/)[0];
|
|
18
|
+
var messages = require("./includes/messages.js");
|
|
19
|
+
|
|
20
|
+
var cache = utils.createEventCache(); // const environment = config.environment.split(/\s*,\s*|\s+/)[0];
|
|
17
21
|
|
|
18
22
|
/**
|
|
19
23
|
* Aggregate task watching for file changes in `src` and
|
|
@@ -25,20 +29,25 @@ var utils = require('./includes/utilities.js'); // const messages = require('./i
|
|
|
25
29
|
* @static
|
|
26
30
|
*/
|
|
27
31
|
|
|
28
|
-
|
|
29
|
-
gulp.
|
|
30
|
-
return gulp.parallel('watch:css', 'watch:js', 'watch:assets', 'watch:svg')();
|
|
32
|
+
gulp.task("watch:src", function () {
|
|
33
|
+
return gulp.parallel("watch:css", "watch:js", "watch:assets", "watch:svg")();
|
|
31
34
|
});
|
|
32
35
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
+
* Watches for changes in the `./dist` folder and passes event data to the
|
|
37
|
+
* `cache` via {@link pushToCache}.
|
|
36
38
|
* @function watch:dist
|
|
37
39
|
* @memberof seed-cli.tasks.watch
|
|
38
40
|
* @static
|
|
39
41
|
*/
|
|
40
42
|
|
|
41
|
-
gulp.task(
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
gulp.task("watch:dist", function () {
|
|
44
|
+
var watcher = chokidar.watch(["./"], {
|
|
45
|
+
cwd: config.dist.root,
|
|
46
|
+
ignored: /(^|[/\\])\../,
|
|
47
|
+
ignoreInitial: true
|
|
48
|
+
});
|
|
49
|
+
watcher.on("all", function (event, path) {
|
|
50
|
+
messages.logFileEvent(event, path);
|
|
51
|
+
cache.addEvent(event, path);
|
|
52
|
+
});
|
|
44
53
|
});
|
package/lib/utils.js
CHANGED
|
@@ -5,16 +5,29 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.getSeedConfig = getSeedConfig;
|
|
7
7
|
exports.getStoreName = getStoreName;
|
|
8
|
+
exports.getThemeID = getThemeID;
|
|
9
|
+
exports.getDevThemeID = getDevThemeID;
|
|
10
|
+
exports.extractThemeId = extractThemeId;
|
|
11
|
+
exports.logChildProcessOutput = logChildProcessOutput;
|
|
12
|
+
exports.setDevThemeID = setDevThemeID;
|
|
8
13
|
exports.shopifyCLI = void 0;
|
|
9
14
|
|
|
10
15
|
var _crossSpawn = _interopRequireDefault(require("cross-spawn"));
|
|
11
16
|
|
|
12
17
|
var _path = require("path");
|
|
13
18
|
|
|
19
|
+
var _fs = require("fs");
|
|
20
|
+
|
|
14
21
|
var _config = _interopRequireDefault(require("./config"));
|
|
15
22
|
|
|
16
23
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
17
24
|
|
|
25
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
26
|
+
|
|
27
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
28
|
+
|
|
29
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
30
|
+
|
|
18
31
|
/**
|
|
19
32
|
* Wrappers for Shopify CLI commands
|
|
20
33
|
*
|
|
@@ -25,33 +38,52 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
|
|
|
25
38
|
var shopifyCLI = {
|
|
26
39
|
/**
|
|
27
40
|
* shopify login
|
|
28
|
-
*
|
|
41
|
+
*
|
|
29
42
|
* @memberof seed-cli.shopifyCLI
|
|
30
43
|
* @param {string} store - store's myshopify domain name
|
|
31
44
|
* @param {boolean} async - login asynchronously
|
|
32
|
-
*
|
|
45
|
+
*
|
|
33
46
|
* @returns {object} - spawnSync object or, node's <ChildProcess> object if async
|
|
34
47
|
*/
|
|
35
48
|
login: function login(store) {
|
|
36
49
|
var async = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
37
|
-
var args = [
|
|
50
|
+
var args = ["login", "--store", store];
|
|
38
51
|
var options = {
|
|
39
52
|
env: process.env,
|
|
40
53
|
stdio: "inherit",
|
|
41
54
|
shell: true
|
|
42
55
|
};
|
|
43
|
-
if (async) return (0, _crossSpawn["default"])(
|
|
56
|
+
if (async) return (0, _crossSpawn["default"])("shopify", args, options);else return _crossSpawn["default"].sync("shopify", args, options);
|
|
44
57
|
},
|
|
45
58
|
|
|
46
59
|
/**
|
|
47
60
|
* shopify theme serve
|
|
48
|
-
*
|
|
61
|
+
*
|
|
49
62
|
* @memberof seed-cli.shopifyCLI
|
|
50
63
|
* @returns {object} - node's ChildProcess
|
|
51
64
|
*/
|
|
52
65
|
serve: function serve() {
|
|
53
|
-
|
|
54
|
-
|
|
66
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
67
|
+
return (0, _crossSpawn["default"])("shopify theme", ["serve"], _objectSpread({
|
|
68
|
+
cwd: _config["default"].themeRoot + "/dist",
|
|
69
|
+
env: process.env,
|
|
70
|
+
stdio: "inherit",
|
|
71
|
+
shell: true
|
|
72
|
+
}, options));
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* shopify theme push
|
|
77
|
+
*
|
|
78
|
+
* @memberof seed-cli.shopifyCLI
|
|
79
|
+
* @returns {object} - node's ChildProcess
|
|
80
|
+
*/
|
|
81
|
+
pull: function pull() {
|
|
82
|
+
var themeId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
83
|
+
var dir = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "./src";
|
|
84
|
+
var args = ["pull"];
|
|
85
|
+
if (themeId) args = args.concat(["--themeid", themeId, dir]);
|
|
86
|
+
return (0, _crossSpawn["default"])("shopify theme", args, {
|
|
55
87
|
env: process.env,
|
|
56
88
|
stdio: "inherit",
|
|
57
89
|
shell: true
|
|
@@ -60,13 +92,16 @@ var shopifyCLI = {
|
|
|
60
92
|
|
|
61
93
|
/**
|
|
62
94
|
* shopify theme push
|
|
63
|
-
*
|
|
95
|
+
*
|
|
64
96
|
* @memberof seed-cli.shopifyCLI
|
|
65
97
|
* @returns {object} - node's ChildProcess
|
|
66
98
|
*/
|
|
67
99
|
push: function push() {
|
|
68
|
-
|
|
69
|
-
|
|
100
|
+
var themeId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
101
|
+
var args = ["push", "--nodelete"];
|
|
102
|
+
if (themeId) args = args.concat(["--themeid", themeId]);
|
|
103
|
+
return (0, _crossSpawn["default"])("shopify theme", args, {
|
|
104
|
+
cwd: _config["default"].themeRoot + "/dist",
|
|
70
105
|
env: process.env,
|
|
71
106
|
stdio: "inherit",
|
|
72
107
|
shell: true
|
|
@@ -75,22 +110,86 @@ var shopifyCLI = {
|
|
|
75
110
|
};
|
|
76
111
|
/**
|
|
77
112
|
* Get seed.config.js from project root dir
|
|
78
|
-
*
|
|
113
|
+
*
|
|
79
114
|
* @param {string} themeRoot - the path to theme root dir
|
|
80
115
|
*/
|
|
81
116
|
|
|
82
117
|
exports.shopifyCLI = shopifyCLI;
|
|
83
118
|
|
|
84
119
|
function getSeedConfig(themeRoot) {
|
|
85
|
-
return require((0, _path.join)(themeRoot,
|
|
120
|
+
return require((0, _path.join)(themeRoot, "seed.config.js"));
|
|
86
121
|
}
|
|
87
122
|
/**
|
|
88
|
-
* Get store name from seed.config.js
|
|
89
|
-
*
|
|
123
|
+
* Get store name from seed.config.js
|
|
124
|
+
*
|
|
90
125
|
* @param {string} themeRoot - the path to theme root dir
|
|
91
126
|
*/
|
|
92
127
|
|
|
93
128
|
|
|
94
129
|
function getStoreName(themeRoot) {
|
|
95
130
|
return getSeedConfig(themeRoot).store;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Get theme ID from seed.config.js
|
|
134
|
+
*
|
|
135
|
+
* @param {string} themeRoot - the path to theme root dir
|
|
136
|
+
* @param {string} environment - theme name/environment
|
|
137
|
+
* @returns {string} themeID
|
|
138
|
+
*/
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
function getThemeID(themeRoot, environment) {
|
|
142
|
+
return getSeedConfig(themeRoot).themes[environment];
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Get dev theme ID from seed.config.js
|
|
146
|
+
*
|
|
147
|
+
* @param {string} themeRoot - the path to theme root dir
|
|
148
|
+
* @returns {string} - development store theme ID
|
|
149
|
+
*/
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
function getDevThemeID(themeRoot) {
|
|
153
|
+
return getSeedConfig(themeRoot).developmentThemeId;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Given a string, finds the first themeID and returns it, if no themeID found
|
|
157
|
+
* returns false.
|
|
158
|
+
*
|
|
159
|
+
* @param {string} string - string to extract theme id from
|
|
160
|
+
* @return {string|boolean} - themeID or false if not found
|
|
161
|
+
*/
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
function extractThemeId(string) {
|
|
165
|
+
var regex = /\d{12}/;
|
|
166
|
+
var match = string.match(regex);
|
|
167
|
+
return match && match.length ? match[0] : false;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Logs out to terminal the output of a piped child process
|
|
171
|
+
*
|
|
172
|
+
* @param {child_process} serveProcess shopify cli serve spawned child process
|
|
173
|
+
*/
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
function logChildProcessOutput(process) {
|
|
177
|
+
process.stdout.on("data", function (data) {
|
|
178
|
+
console.log(data);
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Writes the development theme ID as a key to seed config file
|
|
183
|
+
*
|
|
184
|
+
* @param {string} themeID - development theme ID
|
|
185
|
+
*/
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
function setDevThemeID(themeID) {
|
|
189
|
+
var data = (0, _fs.readFileSync)(_config["default"].seedConfig, {
|
|
190
|
+
encoding: "utf8"
|
|
191
|
+
});
|
|
192
|
+
data = data.split(_config["default"].seedConfigDelimiter);
|
|
193
|
+
data[1] = "\n developmentThemeId: '".concat(themeID, "'") + "\n};";
|
|
194
|
+
(0, _fs.writeFileSync)(_config["default"].seedConfig, data.join(_config["default"].seedConfigDelimiter));
|
|
96
195
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@madebyseed/seed-cli-tools",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Seed CLI Tools",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"chalk": "^4.1.1",
|
|
29
29
|
"chokidar": "^3.5.2",
|
|
30
30
|
"cross-spawn": "^7.0.3",
|
|
31
|
+
"cssnano": "^5.0.8",
|
|
31
32
|
"debug": "^4.3.2",
|
|
32
33
|
"del": "^6.0.0",
|
|
33
34
|
"fancy-log": "^1.3.3",
|
|
@@ -37,6 +38,7 @@
|
|
|
37
38
|
"gulp-cheerio": "^1.0.0",
|
|
38
39
|
"gulp-cssimport": "^7.0.0",
|
|
39
40
|
"gulp-ext-replace": "^0.3.0",
|
|
41
|
+
"gulp-if": "^3.0.0",
|
|
40
42
|
"gulp-include": "^2.4.1",
|
|
41
43
|
"gulp-plumber": "^1.2.1",
|
|
42
44
|
"gulp-postcss": "^9.0.0",
|
|
@@ -53,5 +55,5 @@
|
|
|
53
55
|
"vinyl-paths": "^3.0.1",
|
|
54
56
|
"yargs": "^17.0.1"
|
|
55
57
|
},
|
|
56
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "c8014098190f878e6bd6623c69c9164a1d94001c"
|
|
57
59
|
}
|
package/src/commands/deploy.js
CHANGED
|
@@ -1,25 +1,42 @@
|
|
|
1
|
-
import spawn from
|
|
2
|
-
import debug from
|
|
3
|
-
import config from
|
|
1
|
+
import spawn from "cross-spawn";
|
|
2
|
+
import debug from "debug";
|
|
3
|
+
import config from "../config";
|
|
4
4
|
|
|
5
|
-
const logger = debug(
|
|
5
|
+
const logger = debug("seed-tools:deploy");
|
|
6
6
|
|
|
7
|
-
export default function(program) {
|
|
7
|
+
export default function (program) {
|
|
8
8
|
program
|
|
9
|
-
.command(
|
|
10
|
-
.alias(
|
|
11
|
-
.description(
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
.command("deploy")
|
|
10
|
+
.alias("d")
|
|
11
|
+
.description(
|
|
12
|
+
"Runs a full deploy of your theme's code to a Shopify store specified in seed.config.js. This runs shopify theme push with the --nodelete flag, so that remove files aren't deleted."
|
|
13
|
+
)
|
|
14
|
+
.option(
|
|
15
|
+
"-e, --env <environment>[,<environment>...]",
|
|
16
|
+
"Shopify store(s) to deploy code to (specified in seed.config.js - default: development)",
|
|
17
|
+
"development"
|
|
18
|
+
)
|
|
19
|
+
.option(
|
|
20
|
+
"-s, --skip-optimization",
|
|
21
|
+
"Skips asset optimization steps such as compression, minification and purging.",
|
|
22
|
+
false
|
|
23
|
+
)
|
|
14
24
|
.action((options = {}) => {
|
|
15
25
|
logger(`--gulpfile ${config.gulpFile}`);
|
|
16
26
|
logger(`--cwd ${config.themeRoot}`);
|
|
17
27
|
|
|
18
|
-
const args = [
|
|
28
|
+
const args = ["deploy", "--environment", options.env];
|
|
19
29
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
30
|
+
if (options.skipOptimization) args.push("--skip-optimization");
|
|
31
|
+
else process.env.NODE_ENV = "production";
|
|
32
|
+
|
|
33
|
+
spawn(
|
|
34
|
+
config.gulp,
|
|
35
|
+
args.concat(["--gulpfile", config.gulpFile, "--cwd", config.themeRoot]),
|
|
36
|
+
{
|
|
37
|
+
detached: false,
|
|
38
|
+
stdio: "inherit",
|
|
39
|
+
}
|
|
40
|
+
);
|
|
24
41
|
});
|
|
25
42
|
}
|
package/src/commands/watch.js
CHANGED
|
@@ -15,6 +15,11 @@ export default function (program) {
|
|
|
15
15
|
"Watches files for code changes and immediately deploys updates to dev theme as they occur. " +
|
|
16
16
|
"This uses shopify theme serve under the hood."
|
|
17
17
|
)
|
|
18
|
+
.option(
|
|
19
|
+
"-o, --optimize",
|
|
20
|
+
"Optimizes assets by compressing, minifying and purging.",
|
|
21
|
+
false
|
|
22
|
+
)
|
|
18
23
|
.action((options = {}) => {
|
|
19
24
|
logger(`--gulpfile ${config.gulpFile}`);
|
|
20
25
|
logger(`--cwd ${config.themeRoot}`);
|
|
@@ -54,6 +59,11 @@ export default function (program) {
|
|
|
54
59
|
options.env,
|
|
55
60
|
];
|
|
56
61
|
|
|
62
|
+
if (!options.optimize)
|
|
63
|
+
gulpArgs.push("--skip-optimization");
|
|
64
|
+
|
|
65
|
+
process.env.NODE_ENV = options.optimize ? 'production' : 'development';
|
|
66
|
+
|
|
57
67
|
spawn(config.gulp, gulpArgs, {
|
|
58
68
|
detached: false,
|
|
59
69
|
stdio: "inherit",
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import spawn from "cross-spawn";
|
|
2
|
+
import debug from "debug";
|
|
3
|
+
import config from "../config";
|
|
4
|
+
|
|
5
|
+
const logger = debug("seed-tools:zip");
|
|
6
|
+
|
|
7
|
+
export default function (program) {
|
|
8
|
+
program
|
|
9
|
+
.command("zip")
|
|
10
|
+
.alias("z")
|
|
11
|
+
.description(
|
|
12
|
+
"Rebuilds the theme's source files and compresses the output. The compressed file is written to <theme>/upload/<theme>.zip (can be used for manual upload)."
|
|
13
|
+
)
|
|
14
|
+
.action(() => {
|
|
15
|
+
logger(`--gulpfile ${config.gulpFile}`);
|
|
16
|
+
logger(`--cwd ${config.themeRoot}`);
|
|
17
|
+
|
|
18
|
+
spawn(
|
|
19
|
+
config.gulp,
|
|
20
|
+
["zip", "--gulpfile", config.gulpFile, "--cwd", config.themeRoot],
|
|
21
|
+
{
|
|
22
|
+
detached: false,
|
|
23
|
+
stdio: "inherit",
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
});
|
|
27
|
+
}
|
package/src/config.js
CHANGED
|
@@ -17,6 +17,8 @@ const config = {
|
|
|
17
17
|
gulpFile: join(currentDirectory, "gulpfile.js"),
|
|
18
18
|
gulp: existsSync(defaultGulpPath) ? defaultGulpPath : legacyGulpPath,
|
|
19
19
|
themeRoot,
|
|
20
|
+
seedConfig: join(themeRoot, "seed.config.js"),
|
|
21
|
+
seedConfigDelimiter: "/** === delimiter */",
|
|
20
22
|
};
|
|
21
23
|
|
|
22
24
|
export default config;
|
package/src/gulpfile.js
CHANGED
|
@@ -1,19 +1,30 @@
|
|
|
1
|
-
const gulp = require(
|
|
1
|
+
const gulp = require("gulp");
|
|
2
2
|
// const argv = require('yargs').argv;
|
|
3
|
-
const runSequence = require(
|
|
3
|
+
// const runSequence = require("gulp4-run-sequence");
|
|
4
4
|
|
|
5
5
|
// imports gulp tasks from the `tasks` directory
|
|
6
|
-
require(
|
|
6
|
+
require("require-directory")(module, "./tasks");
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Does a full clean/rebuild of your theme
|
|
10
|
+
*
|
|
11
|
+
* @function watch
|
|
12
|
+
* @memberof slate-cli.tasks.watch
|
|
13
|
+
* @static
|
|
14
|
+
*/
|
|
15
|
+
gulp.task(
|
|
16
|
+
"build",
|
|
17
|
+
gulp.series(
|
|
18
|
+
"clean",
|
|
19
|
+
gulp.parallel(
|
|
20
|
+
"build:js",
|
|
21
|
+
"build:vendor-js",
|
|
22
|
+
"build:css",
|
|
23
|
+
"build:assets",
|
|
24
|
+
"build:svg"
|
|
25
|
+
)
|
|
26
|
+
)
|
|
27
|
+
);
|
|
17
28
|
|
|
18
29
|
/**
|
|
19
30
|
* Does a full clean/rebuild of your theme and creates a `.zip` compatible with
|
|
@@ -23,25 +34,36 @@ gulp.task('build:zip', gulp.series(
|
|
|
23
34
|
* @memberof slate-cli.tasks
|
|
24
35
|
* @static
|
|
25
36
|
*/
|
|
26
|
-
|
|
27
|
-
runSequence('build:zip', 'compress', done);
|
|
28
|
-
});
|
|
37
|
+
gulp.task("zip", gulp.series("build", "compress"));
|
|
29
38
|
|
|
39
|
+
/**
|
|
40
|
+
* Syncronizes the development theme settings with our src folder theme settings
|
|
41
|
+
*
|
|
42
|
+
* @function sync-settings
|
|
43
|
+
* @memberof seed-cli.tasks.deploy
|
|
44
|
+
* @static
|
|
45
|
+
*/
|
|
46
|
+
gulp.task(
|
|
47
|
+
"sync-settings",
|
|
48
|
+
gulp.series("generate:tmp", "shopify:pull:dev:tmp", "sync-settings:tmp:src")
|
|
49
|
+
);
|
|
30
50
|
|
|
31
51
|
/**
|
|
32
52
|
* Simple wrapper around src & dist watchers
|
|
33
53
|
*
|
|
34
54
|
* @summary Monitor your codebase for file changes and take the appropriate
|
|
35
|
-
*
|
|
55
|
+
* action
|
|
36
56
|
* @function watch
|
|
37
57
|
* @memberof slate-cli.tasks.watch
|
|
38
58
|
* @static
|
|
39
59
|
*/
|
|
40
|
-
gulp.task(
|
|
41
|
-
|
|
42
|
-
gulp.
|
|
43
|
-
|
|
44
|
-
|
|
60
|
+
gulp.task(
|
|
61
|
+
"watch",
|
|
62
|
+
gulp.series(
|
|
63
|
+
"build",
|
|
64
|
+
gulp.parallel("watch:src", "watch:dist", "shopify:serve:dist")
|
|
65
|
+
)
|
|
66
|
+
);
|
|
45
67
|
|
|
46
68
|
/**
|
|
47
69
|
* Does a full (re)build followed by a full deploy, cleaning existing files on
|
|
@@ -50,12 +72,8 @@ gulp.task('watch', gulp.series(
|
|
|
50
72
|
*
|
|
51
73
|
* @summary Deploy your built files to the Shopify Store set in
|
|
52
74
|
* `slate-cli.config`
|
|
53
|
-
* @function deploy
|
|
75
|
+
* @function deploy
|
|
54
76
|
* @memberof slate-cli.tasks.deploy
|
|
55
77
|
* @static
|
|
56
78
|
*/
|
|
57
|
-
gulp.task(
|
|
58
|
-
'build',
|
|
59
|
-
'deploy:dist'
|
|
60
|
-
));
|
|
61
|
-
|
|
79
|
+
gulp.task("deploy", gulp.series("sync-settings", "build", "shopify:push:dist"));
|
package/src/tasks/build-js.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const gulp = require('gulp');
|
|
2
|
+
const gulpif = require('gulp-if');
|
|
2
3
|
const uglify = require('gulp-uglify');
|
|
3
4
|
const include = require('gulp-include');
|
|
4
5
|
const plumber = require('gulp-plumber');
|
|
@@ -6,13 +7,13 @@ const chokidar = require('chokidar');
|
|
|
6
7
|
|
|
7
8
|
const config = require('./includes/config.js');
|
|
8
9
|
const messages = require('./includes/messages.js');
|
|
9
|
-
// const utils = require('./includes/utilities.js');
|
|
10
10
|
|
|
11
11
|
function processThemeJs() {
|
|
12
12
|
messages.logProcessFiles('build:js');
|
|
13
13
|
return gulp.src([config.roots.js, `!${config.roots.vendorJs}`])
|
|
14
14
|
.pipe(plumber())
|
|
15
15
|
.pipe(include())
|
|
16
|
+
.pipe(gulpif(config.optimize, uglify()))
|
|
16
17
|
.pipe(gulp.dest(config.dist.assets));
|
|
17
18
|
}
|
|
18
19
|
|
package/src/tasks/build-utils.js
CHANGED
|
@@ -1,11 +1,46 @@
|
|
|
1
|
-
const gulp = require(
|
|
2
|
-
const del = require(
|
|
3
|
-
const zip = require(
|
|
4
|
-
const size = require(
|
|
5
|
-
const plumber = require(
|
|
1
|
+
const gulp = require("gulp");
|
|
2
|
+
const del = require("del");
|
|
3
|
+
const zip = require("gulp-zip");
|
|
4
|
+
const size = require("gulp-size");
|
|
5
|
+
const plumber = require("gulp-plumber");
|
|
6
6
|
|
|
7
|
-
const config = require(
|
|
8
|
-
const utils = require(
|
|
7
|
+
const config = require("./includes/config.js");
|
|
8
|
+
const utils = require("./includes/utilities.js");
|
|
9
|
+
|
|
10
|
+
const assetsPaths = [
|
|
11
|
+
config.src.assets,
|
|
12
|
+
config.src.templates,
|
|
13
|
+
config.src.sections,
|
|
14
|
+
config.src.snippets,
|
|
15
|
+
config.src.locales,
|
|
16
|
+
config.src.config,
|
|
17
|
+
config.src.layout,
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
const themeSettingsAssets = [config.tmp.templates, config.tmp.config];
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Copies files from one fold to another, creating a new dir if doesn't exists and
|
|
24
|
+
* overwriting if it does exist
|
|
25
|
+
*
|
|
26
|
+
* @param {Array} files - files to copy
|
|
27
|
+
* @param {Object} srcOptions - second param for gulp.src function
|
|
28
|
+
* @param {String} dest - destination dir
|
|
29
|
+
* @returns {Stream}
|
|
30
|
+
* @private
|
|
31
|
+
*/
|
|
32
|
+
function copyFiles(files, srcOptions, dest) {
|
|
33
|
+
return gulp
|
|
34
|
+
.src(files, srcOptions)
|
|
35
|
+
.pipe(plumber(utils.errorHandler))
|
|
36
|
+
.pipe(
|
|
37
|
+
size({
|
|
38
|
+
showFiles: true,
|
|
39
|
+
pretty: true,
|
|
40
|
+
})
|
|
41
|
+
)
|
|
42
|
+
.pipe(gulp.dest(dest));
|
|
43
|
+
}
|
|
9
44
|
|
|
10
45
|
/**
|
|
11
46
|
* Clean up build dirs/files whenever doing a full/clean (re)build.
|
|
@@ -14,8 +49,8 @@ const utils = require('./includes/utilities.js');
|
|
|
14
49
|
* @memberof slate-cli.tasks.build
|
|
15
50
|
* @static
|
|
16
51
|
*/
|
|
17
|
-
gulp.task(
|
|
18
|
-
return del([
|
|
52
|
+
gulp.task("clean", () => {
|
|
53
|
+
return del(["upload", "dist", "tmp"]);
|
|
19
54
|
});
|
|
20
55
|
|
|
21
56
|
/**
|
|
@@ -25,13 +60,39 @@ gulp.task('clean', () => {
|
|
|
25
60
|
* @memberof slate-cli.tasks.deploy
|
|
26
61
|
* @static
|
|
27
62
|
*/
|
|
28
|
-
gulp.task(
|
|
63
|
+
gulp.task("compress", () => {
|
|
29
64
|
const distFiles = `${config.dist.root}**/*`;
|
|
30
|
-
const ignoreConfig = `!${config.dist.root}config.yml`;
|
|
31
65
|
|
|
32
|
-
return gulp
|
|
66
|
+
return gulp
|
|
67
|
+
.src([distFiles])
|
|
33
68
|
.pipe(plumber(utils.errorHandler))
|
|
34
|
-
.pipe(zip(`${config.packageJson.name}.zip` ||
|
|
35
|
-
.pipe(size({showFiles: true, pretty: true}))
|
|
36
|
-
.pipe(gulp.dest(
|
|
69
|
+
.pipe(zip(`${config.packageJson.name}.zip` || "theme.zip"))
|
|
70
|
+
.pipe(size({ showFiles: true, pretty: true }))
|
|
71
|
+
.pipe(gulp.dest("./upload/"));
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Duplicates /src directory into a /tmp directory
|
|
76
|
+
*
|
|
77
|
+
* @function generate:tmp
|
|
78
|
+
* @memberof seed-cli.tasks.sync-settings
|
|
79
|
+
* @static
|
|
80
|
+
*/
|
|
81
|
+
gulp.task("generate:tmp", () => {
|
|
82
|
+
return copyFiles(assetsPaths, { base: config.src.root }, config.tmp.root);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Syncronizes the theme settings of /tmp directory into our src directory
|
|
87
|
+
*
|
|
88
|
+
* @function sync-settings:tmp:src
|
|
89
|
+
* @memberof seed-cli.tasks.sync-settings
|
|
90
|
+
* @static
|
|
91
|
+
*/
|
|
92
|
+
gulp.task("sync-settings:tmp:src", () => {
|
|
93
|
+
return copyFiles(
|
|
94
|
+
themeSettingsAssets,
|
|
95
|
+
{ base: config.tmp.root },
|
|
96
|
+
config.src.root
|
|
97
|
+
);
|
|
37
98
|
});
|