@madebyseed/seed-cli-tools 1.2.4 → 1.3.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 +8 -3
- package/lib/commands/pull.js +34 -0
- package/lib/commands/watch.js +1 -25
- package/lib/gulpfile.js +36 -4
- package/lib/tasks/build-svg.js +1 -5
- package/lib/tasks/build-utils.js +1 -0
- package/lib/tasks/includes/config.js +16 -4
- package/lib/tasks/includes/utilities.js +0 -43
- package/lib/tasks/shopify-cli.js +30 -5
- package/lib/utils.js +56 -5
- package/package.json +3 -4
- package/src/commands/deploy.js +22 -3
- package/src/commands/pull.js +53 -0
- package/src/commands/watch.js +2 -27
- package/src/config.js +1 -0
- package/src/gulpfile.js +38 -3
- package/src/tasks/build-svg.js +0 -4
- package/src/tasks/build-utils.js +1 -0
- package/src/tasks/includes/config.js +15 -4
- package/src/tasks/includes/utilities.js +0 -38
- package/src/tasks/shopify-cli.js +37 -4
- package/src/utils.js +60 -8
package/lib/commands/deploy.js
CHANGED
|
@@ -11,17 +11,22 @@ var _debug = _interopRequireDefault(require("debug"));
|
|
|
11
11
|
|
|
12
12
|
var _config = _interopRequireDefault(require("../config"));
|
|
13
13
|
|
|
14
|
+
var _utils = require("../utils");
|
|
15
|
+
|
|
14
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
15
17
|
|
|
16
18
|
var logger = (0, _debug["default"])("seed-tools:deploy");
|
|
17
19
|
|
|
18
20
|
function _default(program) {
|
|
19
|
-
program.command("deploy").alias("d").description("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 files aren't deleted.").option("-e, --env <environment>[,<environment>...]", "Shopify store(s) to deploy code to (specified in seed.config.js)", "development").option("-s, --skip-optimizations", "Skips asset optimization steps such as compression, minification and purging.", false).action(function () {
|
|
21
|
+
program.command("deploy").alias("d").description("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 files aren't deleted.").option("-e, --env <environment>[,<environment>...]", "Shopify store(s) to deploy code to (specified in seed.config.js)", "development").option("-n, --no-dev", "Skips pulling theme settings from local development theme", false).option("-s, --skip-optimizations", "Skips asset optimization steps such as compression, minification and purging.", false).option("-d, --delete", "By default seed deploy runs 'shopify theme push --nodelete'. With this option it will leave out the --no-delete flag, allowind files to be delete in store theme.", false).action(function () {
|
|
20
22
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
21
23
|
logger("--gulpfile ".concat(_config["default"].gulpFile));
|
|
22
24
|
logger("--cwd ".concat(_config["default"].themeRoot));
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
if (!(0, _utils.login)()) return;
|
|
26
|
+
var args = [options.dev ? "deploy" : "deploy:no-sync", "--environment", options.env];
|
|
27
|
+
if (options.skipOptimizations) args.push('--skip-optimizations');
|
|
28
|
+
if (options["delete"]) args.push('--delete');
|
|
29
|
+
if (!options.skipOptimizations) process.env.NODE_ENV = "production";
|
|
25
30
|
(0, _crossSpawn["default"])(_config["default"].gulp, args.concat(["--gulpfile", _config["default"].gulpFile, "--cwd", _config["default"].themeRoot]), {
|
|
26
31
|
detached: false,
|
|
27
32
|
stdio: "inherit"
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = _default;
|
|
7
|
+
|
|
8
|
+
var _crossSpawn = _interopRequireDefault(require("cross-spawn"));
|
|
9
|
+
|
|
10
|
+
var _debug = _interopRequireDefault(require("debug"));
|
|
11
|
+
|
|
12
|
+
var _config = _interopRequireDefault(require("../config"));
|
|
13
|
+
|
|
14
|
+
var _utils = require("../utils");
|
|
15
|
+
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
17
|
+
|
|
18
|
+
var logger = (0, _debug["default"])("seed-tools:deploy");
|
|
19
|
+
|
|
20
|
+
function _default(program) {
|
|
21
|
+
program.command("pull").alias("p").description("Pulls the specified theme into your src folder. By default, it only pulls theme settings, if you want to pull all files use the --all flag.").option("-e, --env <environment>[,<environment>...]", "Shopify store(s) to deploy code to (specified in seed.config.js)", "development").option("-a, --all", "Pulls all files from specified theme", false).option("-d, --delete", "By default seed pull doesn't delete any files in you src folder, with this options it will delete any files that diverge from the pulled theme.", false).action(function () {
|
|
22
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
23
|
+
logger("--gulpfile ".concat(_config["default"].gulpFile));
|
|
24
|
+
logger("--cwd ".concat(_config["default"].themeRoot));
|
|
25
|
+
if (!(0, _utils.login)()) return;
|
|
26
|
+
var args = [options.all ? "pull" : "pull:settings", "--environment", options.env];
|
|
27
|
+
if (options.all) args.push('--all');
|
|
28
|
+
if (options["delete"]) args.push('--delete');
|
|
29
|
+
(0, _crossSpawn["default"])(_config["default"].gulp, args.concat(["--gulpfile", _config["default"].gulpFile, "--cwd", _config["default"].themeRoot]), {
|
|
30
|
+
detached: false,
|
|
31
|
+
stdio: "inherit"
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
}
|
package/lib/commands/watch.js
CHANGED
|
@@ -5,10 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = _default;
|
|
7
7
|
|
|
8
|
-
var _chalk = require("chalk");
|
|
9
|
-
|
|
10
|
-
var _figures = _interopRequireDefault(require("figures"));
|
|
11
|
-
|
|
12
8
|
var _crossSpawn = _interopRequireDefault(require("cross-spawn"));
|
|
13
9
|
|
|
14
10
|
var _debug = _interopRequireDefault(require("debug"));
|
|
@@ -26,27 +22,7 @@ function _default(program) {
|
|
|
26
22
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
27
23
|
logger("--gulpfile ".concat(_config["default"].gulpFile));
|
|
28
24
|
logger("--cwd ".concat(_config["default"].themeRoot));
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if (!store) {
|
|
32
|
-
console.log("");
|
|
33
|
-
console.log((0, _chalk.red)(" ".concat(_figures["default"].cross, " no store field in seed.config.js")));
|
|
34
|
-
console.log(" Add 'store: <store.myshopify.com>' to your project seed.config.js");
|
|
35
|
-
console.log("");
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
console.log("Logging into ".concat((0, _chalk.yellow)(store), " with Shopify CLI..."));
|
|
40
|
-
|
|
41
|
-
var loginProcess = _utils.shopifyCLI.login(store);
|
|
42
|
-
|
|
43
|
-
if (loginProcess.error) {
|
|
44
|
-
console.log("");
|
|
45
|
-
console.log((0, _chalk.red)(" ".concat(_figures["default"].cross, " Failed logging into ").concat(store, ", are you sure you're using the correct account?")));
|
|
46
|
-
console.log("");
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
|
|
25
|
+
if (!(0, _utils.login)()) return;
|
|
50
26
|
var gulpArgs = ["watch", "--gulpfile", _config["default"].gulpFile, "--cwd", _config["default"].themeRoot, "--environment", options.env];
|
|
51
27
|
if (!options.optimize) gulpArgs.push("--skip-optimizations");
|
|
52
28
|
process.env.NODE_ENV = options.optimize ? 'production' : 'development';
|
package/lib/gulpfile.js
CHANGED
|
@@ -45,9 +45,29 @@ gulp.task("sync-settings", gulp.series("generate:tmp", "shopify:pull:dev:tmp", "
|
|
|
45
45
|
|
|
46
46
|
gulp.task("watch", gulp.series("build", gulp.parallel("watch:src", "watch:dist", "shopify:serve:dist")));
|
|
47
47
|
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
48
|
+
*
|
|
49
|
+
* @summary pulls theme from specified environment theme into src
|
|
50
|
+
* @function deploy
|
|
51
|
+
* @memberof slate-cli.tasks.deploy
|
|
52
|
+
* @static
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
gulp.task("pull", gulp.series("shopify:pull:origin:src"));
|
|
56
|
+
/**
|
|
57
|
+
* Does a full (re)build and push dist files into specified theme environment,
|
|
58
|
+
* theme using shopify theme push, by default with the --no-delete flag
|
|
59
|
+
*
|
|
60
|
+
* @summary pulls theme settings from specified environment theme into src
|
|
61
|
+
* @function deploy
|
|
62
|
+
* @memberof slate-cli.tasks.deploy
|
|
63
|
+
* @static
|
|
64
|
+
*/
|
|
65
|
+
|
|
66
|
+
gulp.task("pull:settings", gulp.series("generate:tmp", "shopify:pull:origin:tmp", "sync-settings:tmp:src"));
|
|
67
|
+
/**
|
|
68
|
+
* Syncronizes src folder theme settings with local development theme settings,
|
|
69
|
+
* then proceeds to do a full (re)build and push files into specified theme
|
|
70
|
+
* environment theme using shopify theme push, by default with the --no-delete flag
|
|
51
71
|
*
|
|
52
72
|
* @summary Deploy your built files to the Shopify Store set in
|
|
53
73
|
* `slate-cli.config`
|
|
@@ -56,4 +76,16 @@ gulp.task("watch", gulp.series("build", gulp.parallel("watch:src", "watch:dist",
|
|
|
56
76
|
* @static
|
|
57
77
|
*/
|
|
58
78
|
|
|
59
|
-
gulp.task("deploy", gulp.series("sync-settings", "build", "shopify:push:dist"));
|
|
79
|
+
gulp.task("deploy", gulp.series("sync-settings", "build", "shopify:push:dist"));
|
|
80
|
+
/**
|
|
81
|
+
* Does a full (re)build and push dist files into specified theme environment,
|
|
82
|
+
* theme using shopify theme push, by default with the --no-delete flag
|
|
83
|
+
*
|
|
84
|
+
* @summary Deploy your built files to the Shopify Store set in
|
|
85
|
+
* `slate-cli.config`
|
|
86
|
+
* @function deploy
|
|
87
|
+
* @memberof slate-cli.tasks.deploy:no-sync
|
|
88
|
+
* @static
|
|
89
|
+
*/
|
|
90
|
+
|
|
91
|
+
gulp.task("deploy:no-sync", gulp.series("build", "shopify:push:dist"));
|
package/lib/tasks/build-svg.js
CHANGED
|
@@ -10,10 +10,6 @@ var size = require('gulp-size');
|
|
|
10
10
|
|
|
11
11
|
var chokidar = require('chokidar');
|
|
12
12
|
|
|
13
|
-
var svgmin = require('gulp-svgmin');
|
|
14
|
-
|
|
15
|
-
var cheerio = require('gulp-cheerio');
|
|
16
|
-
|
|
17
13
|
var extReplace = require('gulp-ext-replace');
|
|
18
14
|
|
|
19
15
|
var plumber = require('gulp-plumber');
|
|
@@ -35,7 +31,7 @@ var messages = require('./includes/messages.js');
|
|
|
35
31
|
|
|
36
32
|
function processIcons(files) {
|
|
37
33
|
messages.logProcessFiles('build:svg');
|
|
38
|
-
return gulp.src(files).pipe(plumber(utils.errorHandler)).pipe(
|
|
34
|
+
return gulp.src(files).pipe(plumber(utils.errorHandler)).pipe(extReplace('.liquid')).pipe(size({
|
|
39
35
|
showFiles: true,
|
|
40
36
|
pretty: true
|
|
41
37
|
})).pipe(gulp.dest(config.dist.snippets));
|
package/lib/tasks/build-utils.js
CHANGED
|
@@ -88,6 +88,7 @@ gulp.task("generate:tmp", function () {
|
|
|
88
88
|
*/
|
|
89
89
|
|
|
90
90
|
gulp.task("sync-settings:tmp:src", function () {
|
|
91
|
+
messages.logProcessFiles('Syncronizing /tmp theme settings with /src');
|
|
91
92
|
return copyFiles(themeSettingsAssets, {
|
|
92
93
|
base: config.tmp.root
|
|
93
94
|
}, config.src.root);
|
|
@@ -10,6 +10,8 @@ var tailwindcss = require("tailwindcss");
|
|
|
10
10
|
|
|
11
11
|
var cssnano = require("cssnano");
|
|
12
12
|
|
|
13
|
+
var pxtorem = require('postcss-pxtorem');
|
|
14
|
+
|
|
13
15
|
var argv = require("minimist")(process.argv.slice(2));
|
|
14
16
|
|
|
15
17
|
var themeRoot = findRoot(process.cwd());
|
|
@@ -38,6 +40,10 @@ try {
|
|
|
38
40
|
* @memberof seed-cli
|
|
39
41
|
* @summary Configuring seed-cli
|
|
40
42
|
* @prop {String} environment - development | staging | production
|
|
43
|
+
* @prop {Boolean} optimize - whether optimize assets or not
|
|
44
|
+
* @prop {Boolean} nodelete - run shopiy cli commands with --no-delete flag
|
|
45
|
+
* @prop {String} tailwindConfig - tailwind config filename
|
|
46
|
+
* @prop {String} seedConfig - seed config filename
|
|
41
47
|
* @prop {String} deployLog - path to deploy log file
|
|
42
48
|
* @prop {String} src - globs (multi-filename matching patterns) for various source files
|
|
43
49
|
* @prop {String} tmp - globs (multi-filename matching patterns) for various tmp files
|
|
@@ -50,6 +56,7 @@ try {
|
|
|
50
56
|
var config = {
|
|
51
57
|
environment: argv.environment === "undefined" ? "development" : argv.environment,
|
|
52
58
|
optimize: !argv["skip-optimizations"],
|
|
59
|
+
nodelete: !argv["delete"],
|
|
53
60
|
themeRoot: themeRoot,
|
|
54
61
|
packageJson: pkg,
|
|
55
62
|
tailwindConfig: tailwindConfig,
|
|
@@ -103,12 +110,17 @@ var config = {
|
|
|
103
110
|
css: "src/styles/*.{css,scss}"
|
|
104
111
|
},
|
|
105
112
|
plugins: {
|
|
106
|
-
cheerio: {
|
|
107
|
-
run: require("./utilities.js").processSvg
|
|
108
|
-
},
|
|
109
113
|
postcss: [require('postcss-import'), tailwindcss({
|
|
110
114
|
config: join(themeRoot, tailwindConfig)
|
|
111
|
-
}), require('autoprefixer')
|
|
115
|
+
}), require('autoprefixer'), pxtorem({
|
|
116
|
+
rootValue: 16,
|
|
117
|
+
unitPrecision: 5,
|
|
118
|
+
propList: ['*'],
|
|
119
|
+
selectorBlackList: [],
|
|
120
|
+
replace: true,
|
|
121
|
+
mediaQuery: true,
|
|
122
|
+
exclude: /node_modules/i
|
|
123
|
+
})]
|
|
112
124
|
}
|
|
113
125
|
};
|
|
114
126
|
|
|
@@ -67,49 +67,6 @@ var utilities = {
|
|
|
67
67
|
}).thenReturn(results).all();
|
|
68
68
|
},
|
|
69
69
|
|
|
70
|
-
/**
|
|
71
|
-
* Function passed to cheerio.run - adds aria tags & other accessibility
|
|
72
|
-
* based information to each svg element's markup...
|
|
73
|
-
*
|
|
74
|
-
* @memberof seed-cli.utilities
|
|
75
|
-
* @param {Function} $ - jQuery reference
|
|
76
|
-
* @param {fs} file - reference to current icon file?
|
|
77
|
-
*/
|
|
78
|
-
processSvg: function processSvg($, file) {
|
|
79
|
-
var $svg = $("svg"); // eslint-disable-line no-var
|
|
80
|
-
|
|
81
|
-
var $newSvg = $('<svg aria-hidden="true" focusable="false" role="presentation" class="icon" />'); // eslint-disable-line no-var
|
|
82
|
-
|
|
83
|
-
var fileName = file.relative.replace(".svg", ""); // eslint-disable-line no-var
|
|
84
|
-
|
|
85
|
-
var viewBoxAttr = $svg.attr("viewbox"); // eslint-disable-line no-var
|
|
86
|
-
// Add necessary attributes
|
|
87
|
-
|
|
88
|
-
if (viewBoxAttr) {
|
|
89
|
-
var width = parseInt(viewBoxAttr.split(" ")[2], 10); // eslint-disable-line no-var
|
|
90
|
-
|
|
91
|
-
var height = parseInt(viewBoxAttr.split(" ")[3], 10); // eslint-disable-line no-var
|
|
92
|
-
|
|
93
|
-
var widthToHeightRatio = width / height; // eslint-disable-line no-var
|
|
94
|
-
|
|
95
|
-
if (widthToHeightRatio >= 1.5) {
|
|
96
|
-
$newSvg.addClass("icon--wide");
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
$newSvg.attr("viewBox", viewBoxAttr);
|
|
100
|
-
} // Add required classes to full color icons
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
if (file.relative.indexOf("-full-color") >= 0) {
|
|
104
|
-
$newSvg.addClass("icon--full-color");
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
$newSvg.addClass(fileName).append($svg.contents());
|
|
108
|
-
$newSvg.append($svg.contents());
|
|
109
|
-
$svg.after($newSvg);
|
|
110
|
-
$svg.remove();
|
|
111
|
-
},
|
|
112
|
-
|
|
113
70
|
/**
|
|
114
71
|
* Factory for creating an event cache - used with a short debounce to batch any
|
|
115
72
|
* file changes that occur in rapid succession during Watch tasks.
|
package/lib/tasks/shopify-cli.js
CHANGED
|
@@ -13,6 +13,8 @@ var _require = require("../utils"),
|
|
|
13
13
|
var config = require("./includes/config");
|
|
14
14
|
|
|
15
15
|
var messages = require("./includes/messages");
|
|
16
|
+
|
|
17
|
+
var environment = config.environment.split(/\s*,\s*|\s+/)[0];
|
|
16
18
|
/**
|
|
17
19
|
* Initiates shopify's cli command 'shopify theme serve' on the dist folder,
|
|
18
20
|
* watching files and uploading them to development store
|
|
@@ -22,7 +24,6 @@ var messages = require("./includes/messages");
|
|
|
22
24
|
* @static
|
|
23
25
|
*/
|
|
24
26
|
|
|
25
|
-
|
|
26
27
|
gulp.task("shopify:serve:dist", function () {
|
|
27
28
|
messages.logChildProcess("'shopify theme serve' on dist...");
|
|
28
29
|
var childProcess = shopifyCLI.serve({
|
|
@@ -45,7 +46,7 @@ gulp.task("shopify:pull:dev", function (done) {
|
|
|
45
46
|
messages.logChildProcess("'shopify theme pull' on development theme...");
|
|
46
47
|
var devThemeId = getDevThemeID(config.themeRoot);
|
|
47
48
|
|
|
48
|
-
if (!devThemeId) {
|
|
49
|
+
if (!devThemeId || devThemeId === 'false') {
|
|
49
50
|
return done();
|
|
50
51
|
}
|
|
51
52
|
|
|
@@ -63,12 +64,36 @@ gulp.task("shopify:pull:dev:tmp", function (done) {
|
|
|
63
64
|
messages.logChildProcess("'shopify theme pull' on tmp folder...");
|
|
64
65
|
var devThemeId = getDevThemeID(config.themeRoot);
|
|
65
66
|
|
|
66
|
-
if (!devThemeId) {
|
|
67
|
+
if (!devThemeId || devThemeId === 'false') {
|
|
67
68
|
return done();
|
|
68
69
|
}
|
|
69
70
|
|
|
70
71
|
return shopifyCLI.pull(devThemeId, config.tmp.root);
|
|
71
72
|
});
|
|
73
|
+
/**
|
|
74
|
+
* Pulls theme files from the seed config theme enviroment into src
|
|
75
|
+
*
|
|
76
|
+
* @function shopify:pull:dev
|
|
77
|
+
* @memberof seed-cli.tasks.deploy
|
|
78
|
+
* @static
|
|
79
|
+
*/
|
|
80
|
+
|
|
81
|
+
gulp.task("shopify:pull:origin:tmp", function () {
|
|
82
|
+
messages.logChildProcess("'shopify theme pull ".concat(environment).concat(config.nodelete ? ' --nodelete' : '', "' into tmp..."));
|
|
83
|
+
return shopifyCLI.pull(getThemeID(config.themeRoot, environment), config.tmp.root);
|
|
84
|
+
});
|
|
85
|
+
/**
|
|
86
|
+
* Pulls theme files from the seed config theme enviroment into src
|
|
87
|
+
*
|
|
88
|
+
* @function shopify:pull:dev
|
|
89
|
+
* @memberof seed-cli.tasks.deploy
|
|
90
|
+
* @static
|
|
91
|
+
*/
|
|
92
|
+
|
|
93
|
+
gulp.task("shopify:pull:origin:src", function () {
|
|
94
|
+
messages.logChildProcess("'shopify theme pull ".concat(environment).concat(config.nodelete ? ' --nodelete' : '', "' into src..."));
|
|
95
|
+
return shopifyCLI.pull(getThemeID(config.themeRoot, environment), config.tmp.src, config.nodelete);
|
|
96
|
+
});
|
|
72
97
|
/**
|
|
73
98
|
* Initiates shopify's cli command 'shopify theme push' on the dist folder,
|
|
74
99
|
* pushing it to stores theme
|
|
@@ -79,8 +104,8 @@ gulp.task("shopify:pull:dev:tmp", function (done) {
|
|
|
79
104
|
*/
|
|
80
105
|
|
|
81
106
|
gulp.task("shopify:push:dist", function () {
|
|
82
|
-
messages.logChildProcess("'shopify theme push' on dist folder...");
|
|
83
|
-
return shopifyCLI.push(getThemeID(config.themeRoot, config.environment));
|
|
107
|
+
messages.logChildProcess("'shopify theme push".concat(config.nodelete ? ' --nodelete' : '', "' on dist folder..."));
|
|
108
|
+
return shopifyCLI.push(getThemeID(config.themeRoot, config.environment), config.nodelete);
|
|
84
109
|
});
|
|
85
110
|
/**
|
|
86
111
|
* Takes the output of shopify cli serve, extracts dev theme ID and persists
|
package/lib/utils.js
CHANGED
|
@@ -10,8 +10,14 @@ exports.getDevThemeID = getDevThemeID;
|
|
|
10
10
|
exports.extractThemeId = extractThemeId;
|
|
11
11
|
exports.logChildProcessOutput = logChildProcessOutput;
|
|
12
12
|
exports.setDevThemeID = setDevThemeID;
|
|
13
|
+
exports.login = login;
|
|
14
|
+
exports.storeErrorMessage = storeErrorMessage;
|
|
13
15
|
exports.shopifyCLI = void 0;
|
|
14
16
|
|
|
17
|
+
var _chalk = require("chalk");
|
|
18
|
+
|
|
19
|
+
var _figures = _interopRequireDefault(require("figures"));
|
|
20
|
+
|
|
15
21
|
var _crossSpawn = _interopRequireDefault(require("cross-spawn"));
|
|
16
22
|
|
|
17
23
|
var _path = require("path");
|
|
@@ -41,25 +47,23 @@ var shopifyCLI = {
|
|
|
41
47
|
*
|
|
42
48
|
* @memberof seed-cli.shopifyCLI
|
|
43
49
|
* @param {string} store - store's myshopify domain name
|
|
44
|
-
* @param {boolean} async - login asynchronously
|
|
45
|
-
*
|
|
46
50
|
* @returns {object} - spawnSync object or, node's <ChildProcess> object if async
|
|
47
51
|
*/
|
|
48
52
|
login: function login(store) {
|
|
49
|
-
var async = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
50
53
|
var args = ["login", "--store", store];
|
|
51
54
|
var options = {
|
|
52
55
|
env: process.env,
|
|
53
56
|
stdio: "inherit",
|
|
54
57
|
shell: true
|
|
55
58
|
};
|
|
56
|
-
|
|
59
|
+
return _crossSpawn["default"].sync("shopify", args, options);
|
|
57
60
|
},
|
|
58
61
|
|
|
59
62
|
/**
|
|
60
63
|
* shopify theme serve
|
|
61
64
|
*
|
|
62
65
|
* @memberof seed-cli.shopifyCLI
|
|
66
|
+
* @param {object} options - node spawn options
|
|
63
67
|
* @returns {object} - node's ChildProcess
|
|
64
68
|
*/
|
|
65
69
|
serve: function serve() {
|
|
@@ -76,13 +80,18 @@ var shopifyCLI = {
|
|
|
76
80
|
* shopify theme push
|
|
77
81
|
*
|
|
78
82
|
* @memberof seed-cli.shopifyCLI
|
|
83
|
+
* @param {string} themeId - shopify theme id to pull from
|
|
84
|
+
* @param {string} dir - directory to pull into
|
|
85
|
+
* @param {boolean} [nodelete = true] - run command with --no-delete flag
|
|
79
86
|
* @returns {object} - node's ChildProcess
|
|
80
87
|
*/
|
|
81
88
|
pull: function pull() {
|
|
82
89
|
var themeId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
83
90
|
var dir = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "./src";
|
|
91
|
+
var nodelete = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
84
92
|
var args = ["pull"];
|
|
85
93
|
if (themeId) args = args.concat(["--themeid", themeId, dir]);
|
|
94
|
+
if (nodelete) args.push('--nodelete');
|
|
86
95
|
return (0, _crossSpawn["default"])("shopify theme", args, {
|
|
87
96
|
env: process.env,
|
|
88
97
|
stdio: "inherit",
|
|
@@ -94,12 +103,16 @@ var shopifyCLI = {
|
|
|
94
103
|
* shopify theme push
|
|
95
104
|
*
|
|
96
105
|
* @memberof seed-cli.shopifyCLI
|
|
106
|
+
* @param {string} themeId - shopify theme id to push into
|
|
107
|
+
* @param {boolean} [nodelete = true] - run command with --no-delete flag
|
|
97
108
|
* @returns {object} - node's ChildProcess
|
|
98
109
|
*/
|
|
99
110
|
push: function push() {
|
|
100
111
|
var themeId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
101
|
-
var
|
|
112
|
+
var nodelete = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
113
|
+
var args = ["push"];
|
|
102
114
|
if (themeId) args = args.concat(["--themeid", themeId]);
|
|
115
|
+
if (nodelete) args.push('--nodelete');
|
|
103
116
|
return (0, _crossSpawn["default"])("shopify theme", args, {
|
|
104
117
|
cwd: _config["default"].themeRoot + "/dist",
|
|
105
118
|
env: process.env,
|
|
@@ -192,4 +205,42 @@ function setDevThemeID(themeID) {
|
|
|
192
205
|
data = data.split(_config["default"].seedConfigDelimiter);
|
|
193
206
|
data[1] = "\n __developmentThemeId: '".concat(themeID, "'") + "\n};";
|
|
194
207
|
(0, _fs.writeFileSync)(_config["default"].seedConfig, data.join(_config["default"].seedConfigDelimiter));
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Logs into seed config shopify store while logging useful messages
|
|
211
|
+
* and handling errors.
|
|
212
|
+
* @returns {boolean} whether login was succesful or not
|
|
213
|
+
*/
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
function login() {
|
|
217
|
+
var store = getStoreName(_config["default"].themeRoot);
|
|
218
|
+
|
|
219
|
+
if (!store) {
|
|
220
|
+
storeErrorMessage();
|
|
221
|
+
return false;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
console.log("Logging into ".concat((0, _chalk.yellow)(store), " with Shopify CLI..."));
|
|
225
|
+
var loginProcess = shopifyCLI.login(store);
|
|
226
|
+
|
|
227
|
+
if (loginProcess.error) {
|
|
228
|
+
console.log("");
|
|
229
|
+
console.log((0, _chalk.red)(" ".concat(_figures["default"].cross, " Failed logging into ").concat(store, ", are you sure you're using the correct account?")));
|
|
230
|
+
console.log("");
|
|
231
|
+
return false;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
return true;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Outputs error message if there's no store field in seed config
|
|
238
|
+
*/
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
function storeErrorMessage() {
|
|
242
|
+
console.log("");
|
|
243
|
+
console.log((0, _chalk.red)(" ".concat(_figures["default"].cross, " no store field in seed.config.js")));
|
|
244
|
+
console.log(" Add 'store: <store.myshopify.com>' to your project seed.config.js");
|
|
245
|
+
console.log("");
|
|
195
246
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@madebyseed/seed-cli-tools",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Seed CLI Tools",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -34,7 +34,6 @@
|
|
|
34
34
|
"figures": "^3.2.0",
|
|
35
35
|
"find-root": "^1.1.0",
|
|
36
36
|
"gulp": "^4.0.2",
|
|
37
|
-
"gulp-cheerio": "^1.0.0",
|
|
38
37
|
"gulp-ext-replace": "^0.3.0",
|
|
39
38
|
"gulp-if": "^3.0.0",
|
|
40
39
|
"gulp-include": "^2.4.1",
|
|
@@ -42,16 +41,16 @@
|
|
|
42
41
|
"gulp-postcss": "^9.0.0",
|
|
43
42
|
"gulp-sass": "^5.0.0",
|
|
44
43
|
"gulp-size": "^4.0.1",
|
|
45
|
-
"gulp-svgmin": "^4.0.1",
|
|
46
44
|
"gulp-uglify": "^3.0.2",
|
|
47
45
|
"gulp-zip": "^5.1.0",
|
|
48
46
|
"postcss": "^8.3.6",
|
|
49
47
|
"postcss-import": "^14.0.2",
|
|
48
|
+
"postcss-pxtorem": "^6.0.0",
|
|
50
49
|
"require-directory": "^2.1.1",
|
|
51
50
|
"sass": "^1.36.0",
|
|
52
51
|
"tailwindcss": "^2.2.7",
|
|
53
52
|
"vinyl-paths": "^3.0.1",
|
|
54
53
|
"yargs": "^17.0.1"
|
|
55
54
|
},
|
|
56
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "e473267c834d1763af02e4e1b20339b628a6dc3c"
|
|
57
56
|
}
|
package/src/commands/deploy.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import spawn from "cross-spawn";
|
|
2
2
|
import debug from "debug";
|
|
3
3
|
import config from "../config";
|
|
4
|
+
import { login } from "../utils";
|
|
4
5
|
|
|
5
6
|
const logger = debug("seed-tools:deploy");
|
|
6
7
|
|
|
@@ -16,19 +17,37 @@ export default function (program) {
|
|
|
16
17
|
"Shopify store(s) to deploy code to (specified in seed.config.js)",
|
|
17
18
|
"development"
|
|
18
19
|
)
|
|
20
|
+
.option(
|
|
21
|
+
"-n, --no-dev",
|
|
22
|
+
"Skips pulling theme settings from local development theme",
|
|
23
|
+
false
|
|
24
|
+
)
|
|
19
25
|
.option(
|
|
20
26
|
"-s, --skip-optimizations",
|
|
21
27
|
"Skips asset optimization steps such as compression, minification and purging.",
|
|
22
28
|
false
|
|
23
29
|
)
|
|
30
|
+
.option(
|
|
31
|
+
"-d, --delete",
|
|
32
|
+
"By default seed deploy runs 'shopify theme push --nodelete'. With this option it will leave out the --no-delete flag, allowind files to be delete in store theme.",
|
|
33
|
+
false
|
|
34
|
+
)
|
|
24
35
|
.action((options = {}) => {
|
|
25
36
|
logger(`--gulpfile ${config.gulpFile}`);
|
|
26
37
|
logger(`--cwd ${config.themeRoot}`);
|
|
27
38
|
|
|
28
|
-
|
|
39
|
+
if (!login()) return;
|
|
40
|
+
|
|
41
|
+
const args = [
|
|
42
|
+
options.dev ? "deploy" : "deploy:no-sync",
|
|
43
|
+
"--environment", options.env,
|
|
44
|
+
];
|
|
45
|
+
|
|
46
|
+
if (options.skipOptimizations) args.push('--skip-optimizations')
|
|
47
|
+
if (options.delete) args.push('--delete')
|
|
29
48
|
|
|
30
|
-
if (options.skipOptimizations)
|
|
31
|
-
|
|
49
|
+
if (!options.skipOptimizations)
|
|
50
|
+
process.env.NODE_ENV = "production";
|
|
32
51
|
|
|
33
52
|
spawn(
|
|
34
53
|
config.gulp,
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import spawn from "cross-spawn";
|
|
2
|
+
import debug from "debug";
|
|
3
|
+
import config from "../config";
|
|
4
|
+
import { login } from "../utils";
|
|
5
|
+
|
|
6
|
+
const logger = debug("seed-tools:deploy");
|
|
7
|
+
|
|
8
|
+
export default function (program) {
|
|
9
|
+
program
|
|
10
|
+
.command("pull")
|
|
11
|
+
.alias("p")
|
|
12
|
+
.description(
|
|
13
|
+
"Pulls the specified theme into your src folder. By default, it only pulls theme settings, if you want to pull all files use the --all flag."
|
|
14
|
+
)
|
|
15
|
+
.option(
|
|
16
|
+
"-e, --env <environment>[,<environment>...]",
|
|
17
|
+
"Shopify store(s) to deploy code to (specified in seed.config.js)",
|
|
18
|
+
"development"
|
|
19
|
+
)
|
|
20
|
+
.option(
|
|
21
|
+
"-a, --all",
|
|
22
|
+
"Pulls all files from specified theme",
|
|
23
|
+
false
|
|
24
|
+
)
|
|
25
|
+
.option(
|
|
26
|
+
"-d, --delete",
|
|
27
|
+
"By default seed pull doesn't delete any files in you src folder, with this options it will delete any files that diverge from the pulled theme.",
|
|
28
|
+
false
|
|
29
|
+
)
|
|
30
|
+
.action((options = {}) => {
|
|
31
|
+
logger(`--gulpfile ${config.gulpFile}`);
|
|
32
|
+
logger(`--cwd ${config.themeRoot}`);
|
|
33
|
+
if (!login()) return;
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
const args = [
|
|
37
|
+
options.all ? "pull" : "pull:settings",
|
|
38
|
+
"--environment", options.env
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
if (options.all) args.push('--all')
|
|
42
|
+
if (options.delete) args.push('--delete')
|
|
43
|
+
|
|
44
|
+
spawn(
|
|
45
|
+
config.gulp,
|
|
46
|
+
args.concat(["--gulpfile", config.gulpFile, "--cwd", config.themeRoot]),
|
|
47
|
+
{
|
|
48
|
+
detached: false,
|
|
49
|
+
stdio: "inherit",
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
});
|
|
53
|
+
}
|
package/src/commands/watch.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { red, yellow } from "chalk";
|
|
2
|
-
import figures from "figures";
|
|
3
1
|
import spawn from "cross-spawn";
|
|
4
2
|
import debug from "debug";
|
|
5
3
|
import config from "../config";
|
|
6
|
-
import {
|
|
4
|
+
import { login } from "../utils";
|
|
7
5
|
|
|
8
6
|
const logger = debug("seed-tools:watch");
|
|
9
7
|
|
|
@@ -23,31 +21,8 @@ export default function (program) {
|
|
|
23
21
|
.action((options = {}) => {
|
|
24
22
|
logger(`--gulpfile ${config.gulpFile}`);
|
|
25
23
|
logger(`--cwd ${config.themeRoot}`);
|
|
26
|
-
const store = getStoreName(config.themeRoot);
|
|
27
24
|
|
|
28
|
-
if (!
|
|
29
|
-
console.log("");
|
|
30
|
-
console.log(
|
|
31
|
-
red(` ${figures.cross} no store field in seed.config.js`)
|
|
32
|
-
);
|
|
33
|
-
console.log(
|
|
34
|
-
" Add 'store: <store.myshopify.com>' to your project seed.config.js"
|
|
35
|
-
);
|
|
36
|
-
console.log("");
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
console.log(`Logging into ${yellow(store)} with Shopify CLI...`)
|
|
41
|
-
const loginProcess = shopifyCLI.login(store);
|
|
42
|
-
if (loginProcess.error) {
|
|
43
|
-
console.log("");
|
|
44
|
-
console.log(
|
|
45
|
-
red(` ${figures.cross} Failed logging into ${store}, are you sure you're using the correct account?`)
|
|
46
|
-
);
|
|
47
|
-
console.log("");
|
|
48
|
-
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
25
|
+
if (!login()) return;
|
|
51
26
|
|
|
52
27
|
const gulpArgs = [
|
|
53
28
|
"watch",
|
package/src/config.js
CHANGED
package/src/gulpfile.js
CHANGED
|
@@ -63,10 +63,32 @@ gulp.task(
|
|
|
63
63
|
)
|
|
64
64
|
);
|
|
65
65
|
|
|
66
|
+
|
|
66
67
|
/**
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
68
|
+
*
|
|
69
|
+
* @summary pulls theme from specified environment theme into src
|
|
70
|
+
* @function deploy
|
|
71
|
+
* @memberof slate-cli.tasks.deploy
|
|
72
|
+
* @static
|
|
73
|
+
*/
|
|
74
|
+
gulp.task("pull", gulp.series("shopify:pull:origin:src"));
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Does a full (re)build and push dist files into specified theme environment,
|
|
78
|
+
* theme using shopify theme push, by default with the --no-delete flag
|
|
79
|
+
*
|
|
80
|
+
* @summary pulls theme settings from specified environment theme into src
|
|
81
|
+
* @function deploy
|
|
82
|
+
* @memberof slate-cli.tasks.deploy
|
|
83
|
+
* @static
|
|
84
|
+
*/
|
|
85
|
+
gulp.task("pull:settings", gulp.series("generate:tmp", "shopify:pull:origin:tmp", "sync-settings:tmp:src"));
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Syncronizes src folder theme settings with local development theme settings,
|
|
90
|
+
* then proceeds to do a full (re)build and push files into specified theme
|
|
91
|
+
* environment theme using shopify theme push, by default with the --no-delete flag
|
|
70
92
|
*
|
|
71
93
|
* @summary Deploy your built files to the Shopify Store set in
|
|
72
94
|
* `slate-cli.config`
|
|
@@ -75,3 +97,16 @@ gulp.task(
|
|
|
75
97
|
* @static
|
|
76
98
|
*/
|
|
77
99
|
gulp.task("deploy", gulp.series("sync-settings", "build", "shopify:push:dist"));
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Does a full (re)build and push dist files into specified theme environment,
|
|
103
|
+
* theme using shopify theme push, by default with the --no-delete flag
|
|
104
|
+
*
|
|
105
|
+
* @summary Deploy your built files to the Shopify Store set in
|
|
106
|
+
* `slate-cli.config`
|
|
107
|
+
* @function deploy
|
|
108
|
+
* @memberof slate-cli.tasks.deploy:no-sync
|
|
109
|
+
* @static
|
|
110
|
+
*/
|
|
111
|
+
gulp.task("deploy:no-sync", gulp.series("build", "shopify:push:dist"));
|
|
112
|
+
|
package/src/tasks/build-svg.js
CHANGED
|
@@ -3,8 +3,6 @@ const vinylPaths = require('vinyl-paths');
|
|
|
3
3
|
const del = require('del');
|
|
4
4
|
const size = require('gulp-size');
|
|
5
5
|
const chokidar = require('chokidar');
|
|
6
|
-
const svgmin = require('gulp-svgmin');
|
|
7
|
-
const cheerio = require('gulp-cheerio');
|
|
8
6
|
const extReplace = require('gulp-ext-replace');
|
|
9
7
|
const plumber = require('gulp-plumber');
|
|
10
8
|
|
|
@@ -24,8 +22,6 @@ function processIcons(files) {
|
|
|
24
22
|
messages.logProcessFiles('build:svg');
|
|
25
23
|
return gulp.src(files)
|
|
26
24
|
.pipe(plumber(utils.errorHandler))
|
|
27
|
-
.pipe(svgmin())
|
|
28
|
-
.pipe(cheerio(config.plugins.cheerio))
|
|
29
25
|
.pipe(extReplace('.liquid'))
|
|
30
26
|
.pipe(size({
|
|
31
27
|
showFiles: true,
|
package/src/tasks/build-utils.js
CHANGED
|
@@ -3,6 +3,7 @@ const logger = require("debug")("seed-tools");
|
|
|
3
3
|
const findRoot = require("find-root");
|
|
4
4
|
const tailwindcss = require("tailwindcss");
|
|
5
5
|
const cssnano = require("cssnano");
|
|
6
|
+
const pxtorem = require('postcss-pxtorem');
|
|
6
7
|
const argv = require("minimist")(process.argv.slice(2));
|
|
7
8
|
const themeRoot = findRoot(process.cwd());
|
|
8
9
|
const tailwindConfig = 'tailwind.config.js'
|
|
@@ -32,6 +33,10 @@ try {
|
|
|
32
33
|
* @memberof seed-cli
|
|
33
34
|
* @summary Configuring seed-cli
|
|
34
35
|
* @prop {String} environment - development | staging | production
|
|
36
|
+
* @prop {Boolean} optimize - whether optimize assets or not
|
|
37
|
+
* @prop {Boolean} nodelete - run shopiy cli commands with --no-delete flag
|
|
38
|
+
* @prop {String} tailwindConfig - tailwind config filename
|
|
39
|
+
* @prop {String} seedConfig - seed config filename
|
|
35
40
|
* @prop {String} deployLog - path to deploy log file
|
|
36
41
|
* @prop {String} src - globs (multi-filename matching patterns) for various source files
|
|
37
42
|
* @prop {String} tmp - globs (multi-filename matching patterns) for various tmp files
|
|
@@ -42,6 +47,7 @@ try {
|
|
|
42
47
|
const config = {
|
|
43
48
|
environment: argv.environment === "undefined" ? "development" : argv.environment,
|
|
44
49
|
optimize: !argv["skip-optimizations"],
|
|
50
|
+
nodelete: !argv["delete"],
|
|
45
51
|
themeRoot,
|
|
46
52
|
packageJson: pkg,
|
|
47
53
|
|
|
@@ -49,7 +55,6 @@ const config = {
|
|
|
49
55
|
|
|
50
56
|
seedConfig: "seed.config.js",
|
|
51
57
|
|
|
52
|
-
|
|
53
58
|
src: {
|
|
54
59
|
root: "src/",
|
|
55
60
|
js: "src/scripts/**/*.{js,js.liquid}",
|
|
@@ -103,13 +108,19 @@ const config = {
|
|
|
103
108
|
},
|
|
104
109
|
|
|
105
110
|
plugins: {
|
|
106
|
-
cheerio: {
|
|
107
|
-
run: require("./utilities.js").processSvg,
|
|
108
|
-
},
|
|
109
111
|
postcss: [
|
|
110
112
|
require('postcss-import'),
|
|
111
113
|
tailwindcss({ config: join(themeRoot, tailwindConfig) }),
|
|
112
114
|
require('autoprefixer'),
|
|
115
|
+
pxtorem({
|
|
116
|
+
rootValue: 16,
|
|
117
|
+
unitPrecision: 5,
|
|
118
|
+
propList: ['*'],
|
|
119
|
+
selectorBlackList: [],
|
|
120
|
+
replace: true,
|
|
121
|
+
mediaQuery: true,
|
|
122
|
+
exclude: /node_modules/i
|
|
123
|
+
})
|
|
113
124
|
],
|
|
114
125
|
},
|
|
115
126
|
};
|
|
@@ -65,44 +65,6 @@ const utilities = {
|
|
|
65
65
|
.all();
|
|
66
66
|
},
|
|
67
67
|
|
|
68
|
-
/**
|
|
69
|
-
* Function passed to cheerio.run - adds aria tags & other accessibility
|
|
70
|
-
* based information to each svg element's markup...
|
|
71
|
-
*
|
|
72
|
-
* @memberof seed-cli.utilities
|
|
73
|
-
* @param {Function} $ - jQuery reference
|
|
74
|
-
* @param {fs} file - reference to current icon file?
|
|
75
|
-
*/
|
|
76
|
-
processSvg: ($, file) => {
|
|
77
|
-
var $svg = $("svg"); // eslint-disable-line no-var
|
|
78
|
-
var $newSvg = $(
|
|
79
|
-
'<svg aria-hidden="true" focusable="false" role="presentation" class="icon" />'
|
|
80
|
-
); // eslint-disable-line no-var
|
|
81
|
-
var fileName = file.relative.replace(".svg", ""); // eslint-disable-line no-var
|
|
82
|
-
var viewBoxAttr = $svg.attr("viewbox"); // eslint-disable-line no-var
|
|
83
|
-
|
|
84
|
-
// Add necessary attributes
|
|
85
|
-
if (viewBoxAttr) {
|
|
86
|
-
var width = parseInt(viewBoxAttr.split(" ")[2], 10); // eslint-disable-line no-var
|
|
87
|
-
var height = parseInt(viewBoxAttr.split(" ")[3], 10); // eslint-disable-line no-var
|
|
88
|
-
var widthToHeightRatio = width / height; // eslint-disable-line no-var
|
|
89
|
-
if (widthToHeightRatio >= 1.5) {
|
|
90
|
-
$newSvg.addClass("icon--wide");
|
|
91
|
-
}
|
|
92
|
-
$newSvg.attr("viewBox", viewBoxAttr);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// Add required classes to full color icons
|
|
96
|
-
if (file.relative.indexOf("-full-color") >= 0) {
|
|
97
|
-
$newSvg.addClass("icon--full-color");
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
$newSvg.addClass(fileName).append($svg.contents());
|
|
101
|
-
|
|
102
|
-
$newSvg.append($svg.contents());
|
|
103
|
-
$svg.after($newSvg);
|
|
104
|
-
$svg.remove();
|
|
105
|
-
},
|
|
106
68
|
|
|
107
69
|
/**
|
|
108
70
|
* Factory for creating an event cache - used with a short debounce to batch any
|
package/src/tasks/shopify-cli.js
CHANGED
|
@@ -10,6 +10,8 @@ const {
|
|
|
10
10
|
} = require("../utils");
|
|
11
11
|
const config = require("./includes/config");
|
|
12
12
|
const messages = require("./includes/messages")
|
|
13
|
+
const environment = config.environment.split(/\s*,\s*|\s+/)[0];
|
|
14
|
+
|
|
13
15
|
|
|
14
16
|
/**
|
|
15
17
|
* Initiates shopify's cli command 'shopify theme serve' on the dist folder,
|
|
@@ -40,7 +42,7 @@ gulp.task("shopify:serve:dist", () => {
|
|
|
40
42
|
gulp.task("shopify:pull:dev", (done) => {
|
|
41
43
|
messages.logChildProcess("'shopify theme pull' on development theme...");
|
|
42
44
|
const devThemeId = getDevThemeID(config.themeRoot);
|
|
43
|
-
if (!devThemeId) {
|
|
45
|
+
if (!devThemeId || devThemeId === 'false') {
|
|
44
46
|
return done();
|
|
45
47
|
}
|
|
46
48
|
|
|
@@ -57,7 +59,7 @@ gulp.task("shopify:pull:dev", (done) => {
|
|
|
57
59
|
gulp.task("shopify:pull:dev:tmp", (done) => {
|
|
58
60
|
messages.logChildProcess("'shopify theme pull' on tmp folder...");
|
|
59
61
|
const devThemeId = getDevThemeID(config.themeRoot);
|
|
60
|
-
if (!devThemeId) {
|
|
62
|
+
if (!devThemeId || devThemeId === 'false') {
|
|
61
63
|
return done();
|
|
62
64
|
}
|
|
63
65
|
|
|
@@ -67,6 +69,37 @@ gulp.task("shopify:pull:dev:tmp", (done) => {
|
|
|
67
69
|
);
|
|
68
70
|
});
|
|
69
71
|
|
|
72
|
+
/**
|
|
73
|
+
* Pulls theme files from the seed config theme enviroment into src
|
|
74
|
+
*
|
|
75
|
+
* @function shopify:pull:dev
|
|
76
|
+
* @memberof seed-cli.tasks.deploy
|
|
77
|
+
* @static
|
|
78
|
+
*/
|
|
79
|
+
gulp.task("shopify:pull:origin:tmp", () => {
|
|
80
|
+
messages.logChildProcess(`'shopify theme pull ${environment}${config.nodelete ? ' --nodelete' : ''}' into tmp...`);
|
|
81
|
+
return shopifyCLI.pull(
|
|
82
|
+
getThemeID(config.themeRoot, environment),
|
|
83
|
+
config.tmp.root
|
|
84
|
+
);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Pulls theme files from the seed config theme enviroment into src
|
|
89
|
+
*
|
|
90
|
+
* @function shopify:pull:dev
|
|
91
|
+
* @memberof seed-cli.tasks.deploy
|
|
92
|
+
* @static
|
|
93
|
+
*/
|
|
94
|
+
gulp.task("shopify:pull:origin:src", () => {
|
|
95
|
+
messages.logChildProcess(`'shopify theme pull ${environment}${config.nodelete ? ' --nodelete' : ''}' into src...`);
|
|
96
|
+
return shopifyCLI.pull(
|
|
97
|
+
getThemeID(config.themeRoot, environment),
|
|
98
|
+
config.tmp.src,
|
|
99
|
+
config.nodelete
|
|
100
|
+
);
|
|
101
|
+
});
|
|
102
|
+
|
|
70
103
|
/**
|
|
71
104
|
* Initiates shopify's cli command 'shopify theme push' on the dist folder,
|
|
72
105
|
* pushing it to stores theme
|
|
@@ -76,8 +109,8 @@ gulp.task("shopify:pull:dev:tmp", (done) => {
|
|
|
76
109
|
* @static
|
|
77
110
|
*/
|
|
78
111
|
gulp.task("shopify:push:dist", () => {
|
|
79
|
-
messages.logChildProcess(
|
|
80
|
-
return shopifyCLI.push(getThemeID(config.themeRoot, config.environment));
|
|
112
|
+
messages.logChildProcess(`'shopify theme push${config.nodelete ? ' --nodelete' : ''}' on dist folder...`);
|
|
113
|
+
return shopifyCLI.push(getThemeID(config.themeRoot, config.environment), config.nodelete);
|
|
81
114
|
});
|
|
82
115
|
|
|
83
116
|
/**
|
package/src/utils.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { red, yellow } from "chalk";
|
|
2
|
+
import figures from "figures";
|
|
1
3
|
import spawn from "cross-spawn";
|
|
2
4
|
import { join } from "path";
|
|
3
5
|
import { readFileSync, writeFileSync } from "fs";
|
|
@@ -16,11 +18,9 @@ export const shopifyCLI = {
|
|
|
16
18
|
*
|
|
17
19
|
* @memberof seed-cli.shopifyCLI
|
|
18
20
|
* @param {string} store - store's myshopify domain name
|
|
19
|
-
* @param {boolean} async - login asynchronously
|
|
20
|
-
*
|
|
21
21
|
* @returns {object} - spawnSync object or, node's <ChildProcess> object if async
|
|
22
22
|
*/
|
|
23
|
-
login: (store
|
|
23
|
+
login: (store) => {
|
|
24
24
|
const args = ["login", "--store", store];
|
|
25
25
|
const options = {
|
|
26
26
|
env: process.env,
|
|
@@ -28,14 +28,14 @@ export const shopifyCLI = {
|
|
|
28
28
|
shell: true,
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
else return spawn.sync("shopify", args, options);
|
|
31
|
+
return spawn.sync("shopify", args, options);
|
|
33
32
|
},
|
|
34
33
|
|
|
35
34
|
/**
|
|
36
35
|
* shopify theme serve
|
|
37
36
|
*
|
|
38
37
|
* @memberof seed-cli.shopifyCLI
|
|
38
|
+
* @param {object} options - node spawn options
|
|
39
39
|
* @returns {object} - node's ChildProcess
|
|
40
40
|
*/
|
|
41
41
|
serve: (options = {}) => {
|
|
@@ -52,12 +52,17 @@ export const shopifyCLI = {
|
|
|
52
52
|
* shopify theme push
|
|
53
53
|
*
|
|
54
54
|
* @memberof seed-cli.shopifyCLI
|
|
55
|
+
* @param {string} themeId - shopify theme id to pull from
|
|
56
|
+
* @param {string} dir - directory to pull into
|
|
57
|
+
* @param {boolean} [nodelete = true] - run command with --no-delete flag
|
|
55
58
|
* @returns {object} - node's ChildProcess
|
|
56
59
|
*/
|
|
57
|
-
pull: (themeId = null, dir = "./src") => {
|
|
60
|
+
pull: (themeId = null, dir = "./src", nodelete = true) => {
|
|
58
61
|
let args = ["pull"];
|
|
59
62
|
if (themeId) args = args.concat(["--themeid", themeId, dir]);
|
|
60
63
|
|
|
64
|
+
if (nodelete) args.push('--nodelete')
|
|
65
|
+
|
|
61
66
|
return spawn("shopify theme", args, {
|
|
62
67
|
env: process.env,
|
|
63
68
|
stdio: "inherit",
|
|
@@ -69,12 +74,16 @@ export const shopifyCLI = {
|
|
|
69
74
|
* shopify theme push
|
|
70
75
|
*
|
|
71
76
|
* @memberof seed-cli.shopifyCLI
|
|
77
|
+
* @param {string} themeId - shopify theme id to push into
|
|
78
|
+
* @param {boolean} [nodelete = true] - run command with --no-delete flag
|
|
72
79
|
* @returns {object} - node's ChildProcess
|
|
73
80
|
*/
|
|
74
|
-
push: (themeId = null) => {
|
|
75
|
-
let args = ["push"
|
|
81
|
+
push: (themeId = null, nodelete = true) => {
|
|
82
|
+
let args = ["push"];
|
|
76
83
|
if (themeId) args = args.concat(["--themeid", themeId]);
|
|
77
84
|
|
|
85
|
+
if (nodelete) args.push('--nodelete')
|
|
86
|
+
|
|
78
87
|
return spawn("shopify theme", args, {
|
|
79
88
|
cwd: config.themeRoot + "/dist",
|
|
80
89
|
env: process.env,
|
|
@@ -158,3 +167,46 @@ export function setDevThemeID(themeID) {
|
|
|
158
167
|
data[1] = `\n __developmentThemeId: '${themeID}'` + "\n};";
|
|
159
168
|
writeFileSync(config.seedConfig, data.join(config.seedConfigDelimiter));
|
|
160
169
|
}
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Logs into seed config shopify store while logging useful messages
|
|
174
|
+
* and handling errors.
|
|
175
|
+
* @returns {boolean} whether login was succesful or not
|
|
176
|
+
*/
|
|
177
|
+
export function login() {
|
|
178
|
+
const store = getStoreName(config.themeRoot);
|
|
179
|
+
|
|
180
|
+
if (!store) {
|
|
181
|
+
storeErrorMessage();
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
console.log(`Logging into ${yellow(store)} with Shopify CLI...`)
|
|
186
|
+
const loginProcess = shopifyCLI.login(store);
|
|
187
|
+
if (loginProcess.error) {
|
|
188
|
+
console.log("");
|
|
189
|
+
console.log(
|
|
190
|
+
red(` ${figures.cross} Failed logging into ${store}, are you sure you're using the correct account?`)
|
|
191
|
+
);
|
|
192
|
+
console.log("");
|
|
193
|
+
return false;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
return true;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Outputs error message if there's no store field in seed config
|
|
202
|
+
*/
|
|
203
|
+
export function storeErrorMessage() {
|
|
204
|
+
console.log("");
|
|
205
|
+
console.log(
|
|
206
|
+
red(` ${figures.cross} no store field in seed.config.js`)
|
|
207
|
+
);
|
|
208
|
+
console.log(
|
|
209
|
+
" Add 'store: <store.myshopify.com>' to your project seed.config.js"
|
|
210
|
+
);
|
|
211
|
+
console.log("");
|
|
212
|
+
}
|