@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,157 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import log from "fancy-log";
|
|
3
|
+
|
|
4
|
+
interface PathObject {
|
|
5
|
+
file: string;
|
|
6
|
+
dir: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Separates filename and directory from a path string. Returns an object containing both.
|
|
11
|
+
*
|
|
12
|
+
* @param path {String} - a string representing the path to a file
|
|
13
|
+
* @returns {Object} - an object with separated `file` (the filename) and `dir` (path minus filename) properties
|
|
14
|
+
* @private
|
|
15
|
+
*/
|
|
16
|
+
function separatePath(path: string): PathObject {
|
|
17
|
+
const tmp = path.split("/");
|
|
18
|
+
|
|
19
|
+
return {
|
|
20
|
+
file: tmp.pop() || "",
|
|
21
|
+
dir: tmp.join("/"),
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const messages = {
|
|
26
|
+
logFileEvent: (event: string, path: string, dist = false): void => {
|
|
27
|
+
const pathObject = separatePath(path);
|
|
28
|
+
|
|
29
|
+
if (dist) {
|
|
30
|
+
log(
|
|
31
|
+
"updated",
|
|
32
|
+
chalk.green("dist"),
|
|
33
|
+
chalk.magenta(pathObject.dir),
|
|
34
|
+
chalk.white("-"),
|
|
35
|
+
chalk.cyan(event),
|
|
36
|
+
chalk.yellow(pathObject.file),
|
|
37
|
+
);
|
|
38
|
+
} else {
|
|
39
|
+
log(
|
|
40
|
+
"change in",
|
|
41
|
+
chalk.magenta(pathObject.dir),
|
|
42
|
+
chalk.white("-"),
|
|
43
|
+
chalk.cyan(event),
|
|
44
|
+
chalk.yellow(pathObject.file),
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
logTransferDone: (): void => {
|
|
50
|
+
log(
|
|
51
|
+
"Transfer Complete:",
|
|
52
|
+
chalk.green("File changes successfully synced to store"),
|
|
53
|
+
);
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
logTransferFailed: (errMsg?: string): void => {
|
|
57
|
+
log(
|
|
58
|
+
"Transfer Failed:",
|
|
59
|
+
chalk.yellow(
|
|
60
|
+
`${
|
|
61
|
+
typeof errMsg === "string"
|
|
62
|
+
? errMsg
|
|
63
|
+
: "File(s) failed to upload to store. See log notes in deploy.log"
|
|
64
|
+
}`,
|
|
65
|
+
),
|
|
66
|
+
);
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
logProcessFiles: (processName: string): void => {
|
|
70
|
+
log("running task", chalk.white("-"), chalk.cyan(processName));
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
logChildProcess: (cmd: string): void => {
|
|
74
|
+
log(
|
|
75
|
+
"running task",
|
|
76
|
+
chalk.bold("[child process]"),
|
|
77
|
+
chalk.white("-"),
|
|
78
|
+
chalk.cyan(cmd),
|
|
79
|
+
);
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
logDeploys: (cmd: string, files: string[]): string => {
|
|
83
|
+
const timestamp = `Deploy complete @ ${new Date()}. `;
|
|
84
|
+
const action = cmd === "upload" ? "added/changed " : "removed ";
|
|
85
|
+
const amount = `${files.length} file(s): `;
|
|
86
|
+
const fileList = `${files.join(", ")}.\n`;
|
|
87
|
+
|
|
88
|
+
return timestamp + action + amount + fileList;
|
|
89
|
+
},
|
|
90
|
+
|
|
91
|
+
logDeployErrors: (cmd: string, files: string[], err: string): string => {
|
|
92
|
+
const timestamp = `Deploy error @ ${new Date()}. `;
|
|
93
|
+
const action = cmd === "upload" ? "added/changed " : "removed ";
|
|
94
|
+
const amount = `${files.length} file(s): `;
|
|
95
|
+
const fileList = `${files.join(", ")}.\n`;
|
|
96
|
+
const errMsg = `${err} \n`;
|
|
97
|
+
|
|
98
|
+
return timestamp + action + amount + fileList + errMsg;
|
|
99
|
+
},
|
|
100
|
+
|
|
101
|
+
logError: (message: string): void => {
|
|
102
|
+
log(chalk.red(message));
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
logBundleJs: (): void => {
|
|
106
|
+
log("Updating JS Bundle...");
|
|
107
|
+
},
|
|
108
|
+
|
|
109
|
+
configChange: (): string => {
|
|
110
|
+
return (
|
|
111
|
+
"Changes to seed.config.js Detected: You may need to quit <seed watch>" +
|
|
112
|
+
" and run a full <seed deploy> as a result."
|
|
113
|
+
);
|
|
114
|
+
},
|
|
115
|
+
|
|
116
|
+
translationsFailed: (): string => {
|
|
117
|
+
return "Translation errors detected.";
|
|
118
|
+
},
|
|
119
|
+
|
|
120
|
+
invalidThemeId: (themeId: string, env: string): void => {
|
|
121
|
+
log(
|
|
122
|
+
"Invalid theme id for",
|
|
123
|
+
chalk.cyan(`${env}: ${themeId}`),
|
|
124
|
+
chalk.yellow("`theme_id` must be a string."),
|
|
125
|
+
);
|
|
126
|
+
},
|
|
127
|
+
|
|
128
|
+
logStoreNotFound: (): void => {
|
|
129
|
+
log(
|
|
130
|
+
chalk.red(
|
|
131
|
+
"Store domain not found in seed.project.json or seed.config.js. If this is a multi-store project, pass in --store <store>.",
|
|
132
|
+
),
|
|
133
|
+
);
|
|
134
|
+
},
|
|
135
|
+
|
|
136
|
+
configError: (): void => {
|
|
137
|
+
log(
|
|
138
|
+
"File missing:",
|
|
139
|
+
chalk.yellow(
|
|
140
|
+
"`seed.config.js` does not exist. You need to add a config file before you can make changes to your Shopify store.",
|
|
141
|
+
),
|
|
142
|
+
);
|
|
143
|
+
},
|
|
144
|
+
|
|
145
|
+
deployTo: (environment: string): void => {
|
|
146
|
+
log("Environment:", chalk.bold(environment));
|
|
147
|
+
},
|
|
148
|
+
|
|
149
|
+
allDeploysComplete: (): void => {
|
|
150
|
+
log(
|
|
151
|
+
"Multiple environments:",
|
|
152
|
+
chalk.green("Deploy completed for all environments in series"),
|
|
153
|
+
);
|
|
154
|
+
},
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
export default messages;
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import log from "fancy-log";
|
|
3
|
+
import _ from "lodash";
|
|
4
|
+
import Promise from "bluebird";
|
|
5
|
+
|
|
6
|
+
let errors: Error[] = [];
|
|
7
|
+
|
|
8
|
+
interface EventCacheOptions {
|
|
9
|
+
changeEvents?: string[];
|
|
10
|
+
unlinkEvents?: string[];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface EventCache {
|
|
14
|
+
change: string[];
|
|
15
|
+
unlink: string[];
|
|
16
|
+
addEvent: (event: string, path: string) => void;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Utility and reusable functions used by our Gulp Tasks
|
|
21
|
+
*
|
|
22
|
+
* @summary a set of utility functions used within the gulp tasks of seed-cli
|
|
23
|
+
* @namespace seed-cli.utilities
|
|
24
|
+
* @memberof seed-cli
|
|
25
|
+
*/
|
|
26
|
+
const utilities = {
|
|
27
|
+
/**
|
|
28
|
+
* Indicates whether there are errors during build/watch
|
|
29
|
+
*
|
|
30
|
+
* @returns {Boolean}
|
|
31
|
+
*/
|
|
32
|
+
hasErrors: (): boolean => errors.length > 0,
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Handles the output for any errors that might have been captured
|
|
36
|
+
* during the build and zip Gulp tasks.
|
|
37
|
+
*
|
|
38
|
+
* @memberof seed-cli.utilities
|
|
39
|
+
*/
|
|
40
|
+
outputErrors: (): void => {
|
|
41
|
+
if (!errors.length) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
log(chalk.red("There were errors during the build:\n"));
|
|
46
|
+
errors.forEach((err) => {
|
|
47
|
+
log(chalk.red(err));
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
errors = [];
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Generic error handler for streams called in `watch` tasks (used by gulp-plumber).
|
|
55
|
+
* Any error that is thrown inside of a task is added to the errors array.
|
|
56
|
+
*
|
|
57
|
+
* @memberof seed-cli.utilities
|
|
58
|
+
* @param {Error} err
|
|
59
|
+
*/
|
|
60
|
+
errorHandler: (err: Error): void => {
|
|
61
|
+
log(chalk.red(err));
|
|
62
|
+
errors.push(err);
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Executes an array of promises in series
|
|
67
|
+
*
|
|
68
|
+
* @param promiseArrayFactory {Function} - an array of promise factories
|
|
69
|
+
* @returns {Promise} - promise.all() style array of results from each promise
|
|
70
|
+
*/
|
|
71
|
+
promiseSeries: <T>(
|
|
72
|
+
promiseArrayFactory: Array<() => Promise<T>>,
|
|
73
|
+
): Promise<T[]> => {
|
|
74
|
+
const results: T[] = [];
|
|
75
|
+
|
|
76
|
+
return Promise.each(promiseArrayFactory, (factory) => {
|
|
77
|
+
const result = factory();
|
|
78
|
+
// @ts-ignore
|
|
79
|
+
results.push(result);
|
|
80
|
+
return result;
|
|
81
|
+
})
|
|
82
|
+
.thenReturn(results)
|
|
83
|
+
.all();
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Factory for creating an event cache - used with a short debounce to batch any
|
|
88
|
+
* file changes that occur in rapid succession during Watch tasks.
|
|
89
|
+
*
|
|
90
|
+
* @memberof seed-cli.utilities
|
|
91
|
+
* @param {Object} options
|
|
92
|
+
* @returns {eventCache} see type definition for more robust documentation
|
|
93
|
+
*/
|
|
94
|
+
createEventCache: (options?: EventCacheOptions): EventCache => {
|
|
95
|
+
const opts = _.defaults(options || {}, {
|
|
96
|
+
changeEvents: ["add", "change"],
|
|
97
|
+
unlinkEvents: ["unlink"],
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* A cache object used for caching `[chokidar]{@link https://github.com/paulmillr/chokidar}`
|
|
102
|
+
* events - used with a short `debounce` to batch any file changes that occur in rapid
|
|
103
|
+
* succession during Watch tasks.
|
|
104
|
+
*
|
|
105
|
+
* @typedef {Object} eventCache
|
|
106
|
+
* @prop {Array} change - an array for caching `add` and `change` events
|
|
107
|
+
* @prop {Array} unlink - an array for caching `unlink` events
|
|
108
|
+
* @prop {Function} addEvent - a function to push events to the appropriate `cache` array
|
|
109
|
+
*/
|
|
110
|
+
return {
|
|
111
|
+
change: [],
|
|
112
|
+
unlink: [],
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Pushes events to upload & remove caches for later batch deployment
|
|
116
|
+
*
|
|
117
|
+
* @function addEvent
|
|
118
|
+
* @memberof eventCache
|
|
119
|
+
* @param {String} event - chokidar event type - only cares about `(add|change|unlink)`
|
|
120
|
+
* @param {String} path - relative path to file passed via event
|
|
121
|
+
*/
|
|
122
|
+
addEvent: function (event: string, path: string): void {
|
|
123
|
+
_.each(opts.changeEvents, (eventType) => {
|
|
124
|
+
if (event === eventType) {
|
|
125
|
+
this.change.push(path);
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
_.each(opts.unlinkEvents, (eventType) => {
|
|
130
|
+
if (event === eventType) {
|
|
131
|
+
this.unlink.push(path);
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
},
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Debounced (320ms) delegator function passing an {@link eventCache} object
|
|
140
|
+
* through to a pair of custom functions for processing batch add/change or unlink events.
|
|
141
|
+
* Clears the appropriate cache array after a change/delete function has been
|
|
142
|
+
* called.
|
|
143
|
+
*
|
|
144
|
+
* @memberof seed-cli.utilities
|
|
145
|
+
* @method
|
|
146
|
+
* @param {eventCache} cache - a specific cache object for tracking file events
|
|
147
|
+
* @param {Function} changeFn - a custom function to process the set of files that have changed
|
|
148
|
+
* @param {Function} delFn - a custom function to remove the set of files that have changed from the `dist` directory
|
|
149
|
+
*/
|
|
150
|
+
processCache: _.debounce(
|
|
151
|
+
(
|
|
152
|
+
cache: EventCache,
|
|
153
|
+
changeFn: (files: string[]) => void,
|
|
154
|
+
delFn: (files: string[]) => void,
|
|
155
|
+
): void => {
|
|
156
|
+
if (cache.change.length) {
|
|
157
|
+
changeFn(cache.change);
|
|
158
|
+
cache.change = [];
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (cache.unlink.length) {
|
|
162
|
+
delFn(cache.unlink);
|
|
163
|
+
cache.unlink = [];
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
320,
|
|
167
|
+
),
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
export default utilities;
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import gulp from "gulp";
|
|
2
|
+
import { ChildProcess } from "child_process";
|
|
3
|
+
import {
|
|
4
|
+
shopifyCLI,
|
|
5
|
+
extractThemeId,
|
|
6
|
+
logChildProcessOutput,
|
|
7
|
+
getDevThemeID,
|
|
8
|
+
setDevThemeID,
|
|
9
|
+
getThemeID,
|
|
10
|
+
getStoreName,
|
|
11
|
+
} from "../utils";
|
|
12
|
+
import config from "./includes/config";
|
|
13
|
+
import messages from "./includes/messages";
|
|
14
|
+
|
|
15
|
+
const environment = config.environment.split(/\s*,\s*|\s+/)[0];
|
|
16
|
+
const store = config.store || undefined;
|
|
17
|
+
const storePassword = config.storePassword;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Takes the output of shopify cli serve, extracts dev theme ID and persists
|
|
21
|
+
* in seed.config.js
|
|
22
|
+
*
|
|
23
|
+
* @param {child_process} serveProcess shopify cli serve spawned child process
|
|
24
|
+
*/
|
|
25
|
+
function persistDevThemeID(serveProcess: ChildProcess): void {
|
|
26
|
+
serveProcess.stdout?.on("data", (data: Buffer | string) => {
|
|
27
|
+
const devThemeId = extractThemeId(data.toString());
|
|
28
|
+
const currentDevThemeId = getDevThemeID(config.themeRoot);
|
|
29
|
+
|
|
30
|
+
// If we already have latest dev theme ID, we got nothing left to do
|
|
31
|
+
if (devThemeId === currentDevThemeId) return;
|
|
32
|
+
|
|
33
|
+
// Else, write dev theme ID into seed.config.js
|
|
34
|
+
if (devThemeId) {
|
|
35
|
+
setDevThemeID(devThemeId);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Initiates shopify's cli command 'shopify theme serve' on the dist folder,
|
|
42
|
+
* watching files and uploading them to development store
|
|
43
|
+
*
|
|
44
|
+
* @function shopify:serve:dist
|
|
45
|
+
* @memberof seed-cli.tasks.watch
|
|
46
|
+
* @static
|
|
47
|
+
*/
|
|
48
|
+
gulp.task("shopify:serve:dist", () => {
|
|
49
|
+
const domain = getStoreName(config.themeRoot, store);
|
|
50
|
+
if (!domain) {
|
|
51
|
+
messages.logStoreNotFound();
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
54
|
+
messages.logChildProcess(
|
|
55
|
+
`'shopify theme dev --store ${domain}${
|
|
56
|
+
storePassword ? ` --store-password ${storePassword}` : ""
|
|
57
|
+
}' on dist...`,
|
|
58
|
+
);
|
|
59
|
+
const childProcess = shopifyCLI.serve(domain, {
|
|
60
|
+
stdio: ["inherit", "pipe", "inherit"],
|
|
61
|
+
});
|
|
62
|
+
childProcess.stdout?.setEncoding("utf8");
|
|
63
|
+
logChildProcessOutput(childProcess);
|
|
64
|
+
persistDevThemeID(childProcess);
|
|
65
|
+
return childProcess;
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Pulls theme files from the development theme specified in seed config into src
|
|
70
|
+
*
|
|
71
|
+
* @function shopify:pull:dev
|
|
72
|
+
* @memberof seed-cli.tasks.deploy
|
|
73
|
+
* @static
|
|
74
|
+
*/
|
|
75
|
+
gulp.task("shopify:pull:dev", (done) => {
|
|
76
|
+
const domain = getStoreName(config.themeRoot, store);
|
|
77
|
+
if (!domain) {
|
|
78
|
+
messages.logStoreNotFound();
|
|
79
|
+
process.exit(1);
|
|
80
|
+
}
|
|
81
|
+
messages.logChildProcess(
|
|
82
|
+
`'shopify theme pull --store ${domain}' on development theme...`,
|
|
83
|
+
);
|
|
84
|
+
const devThemeId = getDevThemeID(config.themeRoot);
|
|
85
|
+
if (!devThemeId || devThemeId === "false") {
|
|
86
|
+
return done();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return shopifyCLI.pull(domain, devThemeId);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Pulls theme files from the development theme specified in seed config into tmp
|
|
94
|
+
*
|
|
95
|
+
* @function shopify:pull:dev:tmp
|
|
96
|
+
* @memberof seed-cli.tasks.deploy
|
|
97
|
+
* @static
|
|
98
|
+
*/
|
|
99
|
+
gulp.task("shopify:pull:dev:tmp", (done) => {
|
|
100
|
+
const domain = getStoreName(config.themeRoot, store);
|
|
101
|
+
if (!domain) return done();
|
|
102
|
+
|
|
103
|
+
messages.logChildProcess(
|
|
104
|
+
`'shopify theme pull --store ${domain}' on tmp folder...`,
|
|
105
|
+
);
|
|
106
|
+
const devThemeId = getDevThemeID(config.themeRoot);
|
|
107
|
+
if (!devThemeId || devThemeId === "false") {
|
|
108
|
+
return done();
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return shopifyCLI.pull(domain, devThemeId, config.tmp.root);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Pulls theme files from the seed config theme environment into tmp
|
|
116
|
+
*
|
|
117
|
+
* @function shopify:pull:origin:tmp
|
|
118
|
+
* @memberof seed-cli.tasks.deploy
|
|
119
|
+
* @static
|
|
120
|
+
*/
|
|
121
|
+
gulp.task("shopify:pull:origin:tmp", () => {
|
|
122
|
+
const domain = getStoreName(config.themeRoot, store);
|
|
123
|
+
if (!domain) {
|
|
124
|
+
messages.logStoreNotFound();
|
|
125
|
+
process.exit(1);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
messages.logChildProcess(
|
|
129
|
+
`'shopify theme pull --store ${domain} ${environment}${
|
|
130
|
+
config.nodelete ? " --nodelete" : ""
|
|
131
|
+
}' into tmp...`,
|
|
132
|
+
);
|
|
133
|
+
const themeId = getThemeID(config.themeRoot, environment, store);
|
|
134
|
+
return shopifyCLI.pull(domain, themeId, config.tmp.root);
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Pulls theme files from the seed config theme environment into src
|
|
139
|
+
*
|
|
140
|
+
* @function shopify:pull:origin:src
|
|
141
|
+
* @memberof seed-cli.tasks.deploy
|
|
142
|
+
* @static
|
|
143
|
+
*/
|
|
144
|
+
gulp.task("shopify:pull:origin:src", () => {
|
|
145
|
+
const domain = getStoreName(config.themeRoot, store);
|
|
146
|
+
if (!domain) {
|
|
147
|
+
messages.logStoreNotFound();
|
|
148
|
+
process.exit(1);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
messages.logChildProcess(
|
|
152
|
+
`'shopify theme pull --store ${domain} ${environment}${
|
|
153
|
+
config.nodelete ? " --nodelete" : ""
|
|
154
|
+
}' into src...`,
|
|
155
|
+
);
|
|
156
|
+
const themeId = getThemeID(config.themeRoot, environment, store);
|
|
157
|
+
return shopifyCLI.pull(domain, themeId, config.src.root, config.nodelete);
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Initiates shopify's cli command 'shopify theme push' on the dist folder,
|
|
162
|
+
* pushing it to stores theme
|
|
163
|
+
*
|
|
164
|
+
* @function deploy:dist
|
|
165
|
+
* @memberof seed-cli.tasks.deploy
|
|
166
|
+
* @static
|
|
167
|
+
*/
|
|
168
|
+
gulp.task("shopify:push:dist", () => {
|
|
169
|
+
const domain = getStoreName(config.themeRoot, store);
|
|
170
|
+
if (!domain) {
|
|
171
|
+
messages.logStoreNotFound();
|
|
172
|
+
process.exit(1);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// Use explicit theme ID if provided, otherwise use environment-based theme
|
|
176
|
+
const themeId = config.theme || getThemeID(config.themeRoot, config.environment, store);
|
|
177
|
+
|
|
178
|
+
messages.logChildProcess(
|
|
179
|
+
`'shopify theme push --store ${domain}${themeId ? ` --theme ${themeId}` : ""}${config.nodelete ? " --nodelete" : ""}' on dist folder...`,
|
|
180
|
+
);
|
|
181
|
+
return shopifyCLI.push(domain, themeId, config.nodelete);
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Initiates 'shopify theme package' on the dist folder, creating a zip.
|
|
186
|
+
*
|
|
187
|
+
* @function shopify:package:dist
|
|
188
|
+
* @memberof seed-cli.tasks.zip
|
|
189
|
+
* @static
|
|
190
|
+
*/
|
|
191
|
+
gulp.task("shopify:package:dist", () => {
|
|
192
|
+
const domain = getStoreName(config.themeRoot, store);
|
|
193
|
+
if (!domain) {
|
|
194
|
+
messages.logStoreNotFound();
|
|
195
|
+
process.exit(1);
|
|
196
|
+
}
|
|
197
|
+
messages.logChildProcess("shopify theme package on dist folder...");
|
|
198
|
+
return shopifyCLI.package();
|
|
199
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import gulp from "gulp";
|
|
2
|
+
import chokidar from "chokidar";
|
|
3
|
+
import config from "./includes/config";
|
|
4
|
+
import utils from "./includes/utilities";
|
|
5
|
+
import messages from "./includes/messages";
|
|
6
|
+
|
|
7
|
+
const cache = utils.createEventCache();
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Aggregate task watching for file changes in `src` and
|
|
11
|
+
* building/cleaning/updating `dist` accordingly. *Made up of individual tasks
|
|
12
|
+
* referenced in other files
|
|
13
|
+
*
|
|
14
|
+
* @function watch:src
|
|
15
|
+
* @memberof seed-cli.tasks.watch
|
|
16
|
+
* @static
|
|
17
|
+
*/
|
|
18
|
+
gulp.task("watch:src", () => {
|
|
19
|
+
return gulp.parallel(
|
|
20
|
+
"watch:css",
|
|
21
|
+
"watch:js",
|
|
22
|
+
"watch:vendor-js",
|
|
23
|
+
"watch:assets",
|
|
24
|
+
"watch:svg",
|
|
25
|
+
)((err) => {
|
|
26
|
+
if (err) console.error(err);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Watches for changes in the `./dist` folder and passes event data to the
|
|
32
|
+
* `cache` via {@link pushToCache}.
|
|
33
|
+
* @function watch:dist
|
|
34
|
+
* @memberof seed-cli.tasks.watch
|
|
35
|
+
* @static
|
|
36
|
+
*/
|
|
37
|
+
gulp.task("watch:dist", () => {
|
|
38
|
+
const watcher = chokidar.watch(["./"], {
|
|
39
|
+
cwd: config.dist.root,
|
|
40
|
+
ignored: /(^|[/\\])\../,
|
|
41
|
+
ignoreInitial: true,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
watcher.on("all", (event: string, path: string) => {
|
|
45
|
+
if (!utils.hasErrors()) {
|
|
46
|
+
messages.logFileEvent(event, path, true);
|
|
47
|
+
cache.addEvent(event, path);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
});
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
declare module "gulp-ext-replace" {
|
|
2
|
+
function extReplace(extension: string): NodeJS.ReadWriteStream;
|
|
3
|
+
export default extReplace;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
declare module "postcss-pxtorem" {
|
|
7
|
+
interface PxToRemOptions {
|
|
8
|
+
rootValue: number;
|
|
9
|
+
unitPrecision: number;
|
|
10
|
+
propList: string[];
|
|
11
|
+
selectorBlackList: string[];
|
|
12
|
+
replace: boolean;
|
|
13
|
+
mediaQuery: boolean;
|
|
14
|
+
exclude: RegExp;
|
|
15
|
+
}
|
|
16
|
+
function pxtorem(options: PxToRemOptions): any;
|
|
17
|
+
export default pxtorem;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
declare module "postcss-reporter" {
|
|
21
|
+
interface ReporterOptions {
|
|
22
|
+
clearReportedMessages: boolean;
|
|
23
|
+
}
|
|
24
|
+
function reporter(options: ReporterOptions): any;
|
|
25
|
+
export default reporter;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
declare module "postcss-import" {
|
|
29
|
+
function postcssImport(): any;
|
|
30
|
+
export default postcssImport;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
declare module "cssnano" {
|
|
34
|
+
interface CssnanoOptions {
|
|
35
|
+
preset: string;
|
|
36
|
+
}
|
|
37
|
+
function cssnano(options: CssnanoOptions): any;
|
|
38
|
+
export default cssnano;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
declare module "sass" {
|
|
42
|
+
interface Options {
|
|
43
|
+
[key: string]: any;
|
|
44
|
+
}
|
|
45
|
+
function sass(options?: Options): any;
|
|
46
|
+
export default sass;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
declare module "require-directory" {
|
|
50
|
+
interface RequireDirectoryOptions {
|
|
51
|
+
recurse?: boolean;
|
|
52
|
+
visit?: (obj: any) => any;
|
|
53
|
+
rename?: (name: string) => string;
|
|
54
|
+
exclude?: RegExp | ((path: string) => boolean);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function requireDirectory(
|
|
58
|
+
module: NodeModule,
|
|
59
|
+
path: string,
|
|
60
|
+
options?: RequireDirectoryOptions,
|
|
61
|
+
): { [key: string]: any };
|
|
62
|
+
|
|
63
|
+
export = requireDirectory;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
declare module "gulp-include" {
|
|
67
|
+
interface IncludeOptions {
|
|
68
|
+
separateInputs?: boolean;
|
|
69
|
+
}
|
|
70
|
+
function include(options?: IncludeOptions): NodeJS.ReadWriteStream;
|
|
71
|
+
export default include;
|
|
72
|
+
}
|