@madebyseed/seed-cli-tools 1.0.0 → 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 +3 -1
- 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/commands/deploy.js
CHANGED
|
@@ -13,17 +13,18 @@ var _config = _interopRequireDefault(require("../config"));
|
|
|
13
13
|
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
15
15
|
|
|
16
|
-
var logger = (0, _debug["default"])(
|
|
16
|
+
var logger = (0, _debug["default"])("seed-tools:deploy");
|
|
17
17
|
|
|
18
18
|
function _default(program) {
|
|
19
|
-
program.command(
|
|
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 remove files aren't deleted.").option("-e, --env <environment>[,<environment>...]", "Shopify store(s) to deploy code to (specified in seed.config.js - default: development)", "development").option("-s, --skip-optimization", "Skips asset optimization steps such as compression, minification and purging.", false).action(function () {
|
|
20
20
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
21
21
|
logger("--gulpfile ".concat(_config["default"].gulpFile));
|
|
22
22
|
logger("--cwd ".concat(_config["default"].themeRoot));
|
|
23
|
-
var args = [
|
|
24
|
-
|
|
23
|
+
var args = ["deploy", "--environment", options.env];
|
|
24
|
+
if (options.skipOptimization) args.push("--skip-optimization");else process.env.NODE_ENV = "production";
|
|
25
|
+
(0, _crossSpawn["default"])(_config["default"].gulp, args.concat(["--gulpfile", _config["default"].gulpFile, "--cwd", _config["default"].themeRoot]), {
|
|
25
26
|
detached: false,
|
|
26
|
-
stdio:
|
|
27
|
+
stdio: "inherit"
|
|
27
28
|
});
|
|
28
29
|
});
|
|
29
30
|
}
|
package/lib/commands/watch.js
CHANGED
|
@@ -22,7 +22,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
|
|
|
22
22
|
var logger = (0, _debug["default"])("seed-tools:watch");
|
|
23
23
|
|
|
24
24
|
function _default(program) {
|
|
25
|
-
program.command("watch").alias("w").description("Watches files for code changes and immediately deploys updates to dev theme as they occur. " + "This uses shopify theme serve under the hood.").action(function () {
|
|
25
|
+
program.command("watch").alias("w").description("Watches files for code changes and immediately deploys updates to dev theme as they occur. " + "This uses shopify theme serve under the hood.").option("-o, --optimize", "Optimizes assets by compressing, minifying and purging.", false).action(function () {
|
|
26
26
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
27
27
|
logger("--gulpfile ".concat(_config["default"].gulpFile));
|
|
28
28
|
logger("--cwd ".concat(_config["default"].themeRoot));
|
|
@@ -48,6 +48,8 @@ function _default(program) {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
var gulpArgs = ["watch", "--gulpfile", _config["default"].gulpFile, "--cwd", _config["default"].themeRoot, "--environment", options.env];
|
|
51
|
+
if (!options.optimize) gulpArgs.push("--skip-optimization");
|
|
52
|
+
process.env.NODE_ENV = options.optimize ? 'production' : 'development';
|
|
51
53
|
(0, _crossSpawn["default"])(_config["default"].gulp, gulpArgs, {
|
|
52
54
|
detached: false,
|
|
53
55
|
stdio: "inherit"
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
15
|
+
|
|
16
|
+
var logger = (0, _debug["default"])("seed-tools:zip");
|
|
17
|
+
|
|
18
|
+
function _default(program) {
|
|
19
|
+
program.command("zip").alias("z").description("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).").action(function () {
|
|
20
|
+
logger("--gulpfile ".concat(_config["default"].gulpFile));
|
|
21
|
+
logger("--cwd ".concat(_config["default"].themeRoot));
|
|
22
|
+
(0, _crossSpawn["default"])(_config["default"].gulp, ["zip", "--gulpfile", _config["default"].gulpFile, "--cwd", _config["default"].themeRoot], {
|
|
23
|
+
detached: false,
|
|
24
|
+
stdio: "inherit"
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
}
|
package/lib/config.js
CHANGED
|
@@ -22,7 +22,9 @@ var legacyGulpPath = (0, _path.join)(themeRoot, (0, _path.normalize)("node_modul
|
|
|
22
22
|
var config = {
|
|
23
23
|
gulpFile: (0, _path.join)(currentDirectory, "gulpfile.js"),
|
|
24
24
|
gulp: (0, _fs.existsSync)(defaultGulpPath) ? defaultGulpPath : legacyGulpPath,
|
|
25
|
-
themeRoot: themeRoot
|
|
25
|
+
themeRoot: themeRoot,
|
|
26
|
+
seedConfig: (0, _path.join)(themeRoot, "seed.config.js"),
|
|
27
|
+
seedConfigDelimiter: "/** === delimiter */"
|
|
26
28
|
};
|
|
27
29
|
var _default = config;
|
|
28
30
|
exports["default"] = _default;
|
package/lib/gulpfile.js
CHANGED
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var gulp = require(
|
|
3
|
+
var gulp = require("gulp"); // const argv = require('yargs').argv;
|
|
4
|
+
// const runSequence = require("gulp4-run-sequence");
|
|
5
|
+
// imports gulp tasks from the `tasks` directory
|
|
4
6
|
|
|
5
7
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
require("require-directory")(module, "./tasks");
|
|
9
|
+
/**
|
|
10
|
+
* Does a full clean/rebuild of your theme
|
|
11
|
+
*
|
|
12
|
+
* @function watch
|
|
13
|
+
* @memberof slate-cli.tasks.watch
|
|
14
|
+
* @static
|
|
15
|
+
*/
|
|
8
16
|
|
|
9
|
-
require('require-directory')(module, './tasks');
|
|
10
17
|
|
|
11
|
-
gulp.task(
|
|
12
|
-
gulp.task('build:zip', gulp.series('clean', gulp.parallel('build:js', 'build:vendor-js', 'build:css', 'build:assets', 'build:svg')));
|
|
18
|
+
gulp.task("build", gulp.series("clean", gulp.parallel("build:js", "build:vendor-js", "build:css", "build:assets", "build:svg")));
|
|
13
19
|
/**
|
|
14
20
|
* Does a full clean/rebuild of your theme and creates a `.zip` compatible with
|
|
15
21
|
* shopify.
|
|
@@ -19,20 +25,27 @@ gulp.task('build:zip', gulp.series('clean', gulp.parallel('build:js', 'build:ven
|
|
|
19
25
|
* @static
|
|
20
26
|
*/
|
|
21
27
|
|
|
22
|
-
gulp.task(
|
|
23
|
-
|
|
24
|
-
|
|
28
|
+
gulp.task("zip", gulp.series("build", "compress"));
|
|
29
|
+
/**
|
|
30
|
+
* Syncronizes the development theme settings with our src folder theme settings
|
|
31
|
+
*
|
|
32
|
+
* @function sync-settings
|
|
33
|
+
* @memberof seed-cli.tasks.deploy
|
|
34
|
+
* @static
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
gulp.task("sync-settings", gulp.series("generate:tmp", "shopify:pull:dev:tmp", "sync-settings:tmp:src"));
|
|
25
38
|
/**
|
|
26
39
|
* Simple wrapper around src & dist watchers
|
|
27
40
|
*
|
|
28
41
|
* @summary Monitor your codebase for file changes and take the appropriate
|
|
29
|
-
*
|
|
42
|
+
* action
|
|
30
43
|
* @function watch
|
|
31
44
|
* @memberof slate-cli.tasks.watch
|
|
32
45
|
* @static
|
|
33
46
|
*/
|
|
34
47
|
|
|
35
|
-
gulp.task(
|
|
48
|
+
gulp.task("watch", gulp.series("build", gulp.parallel("watch:src", "watch:dist", "shopify:serve:dist")));
|
|
36
49
|
/**
|
|
37
50
|
* Does a full (re)build followed by a full deploy, cleaning existing files on
|
|
38
51
|
* the remote server and replacing them with the full set of files pushed to
|
|
@@ -40,9 +53,9 @@ gulp.task('watch', gulp.series('build', gulp.parallel('watch:src', 'watch:dist')
|
|
|
40
53
|
*
|
|
41
54
|
* @summary Deploy your built files to the Shopify Store set in
|
|
42
55
|
* `slate-cli.config`
|
|
43
|
-
* @function deploy
|
|
56
|
+
* @function deploy
|
|
44
57
|
* @memberof slate-cli.tasks.deploy
|
|
45
58
|
* @static
|
|
46
59
|
*/
|
|
47
60
|
|
|
48
|
-
gulp.task(
|
|
61
|
+
gulp.task("deploy", gulp.series("sync-settings", "build", "shopify:push:dist"));
|
package/lib/tasks/build-js.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
var gulp = require('gulp');
|
|
4
4
|
|
|
5
|
+
var gulpif = require('gulp-if');
|
|
6
|
+
|
|
5
7
|
var uglify = require('gulp-uglify');
|
|
6
8
|
|
|
7
9
|
var include = require('gulp-include');
|
|
@@ -12,12 +14,11 @@ var chokidar = require('chokidar');
|
|
|
12
14
|
|
|
13
15
|
var config = require('./includes/config.js');
|
|
14
16
|
|
|
15
|
-
var messages = require('./includes/messages.js');
|
|
16
|
-
|
|
17
|
+
var messages = require('./includes/messages.js');
|
|
17
18
|
|
|
18
19
|
function processThemeJs() {
|
|
19
20
|
messages.logProcessFiles('build:js');
|
|
20
|
-
return gulp.src([config.roots.js, "!".concat(config.roots.vendorJs)]).pipe(plumber()).pipe(include()).pipe(gulp.dest(config.dist.assets));
|
|
21
|
+
return gulp.src([config.roots.js, "!".concat(config.roots.vendorJs)]).pipe(plumber()).pipe(include()).pipe(gulpif(config.optimize, uglify())).pipe(gulp.dest(config.dist.assets));
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
function processVendorJs() {
|
package/lib/tasks/build-utils.js
CHANGED
|
@@ -1,18 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var gulp = require(
|
|
3
|
+
var gulp = require("gulp");
|
|
4
4
|
|
|
5
|
-
var del = require(
|
|
5
|
+
var del = require("del");
|
|
6
6
|
|
|
7
|
-
var zip = require(
|
|
7
|
+
var zip = require("gulp-zip");
|
|
8
8
|
|
|
9
|
-
var size = require(
|
|
9
|
+
var size = require("gulp-size");
|
|
10
10
|
|
|
11
|
-
var plumber = require(
|
|
11
|
+
var plumber = require("gulp-plumber");
|
|
12
12
|
|
|
13
|
-
var config = require(
|
|
13
|
+
var config = require("./includes/config.js");
|
|
14
14
|
|
|
15
|
-
var utils = require(
|
|
15
|
+
var utils = require("./includes/utilities.js");
|
|
16
|
+
|
|
17
|
+
var assetsPaths = [config.src.assets, config.src.templates, config.src.sections, config.src.snippets, config.src.locales, config.src.config, config.src.layout];
|
|
18
|
+
var themeSettingsAssets = [config.tmp.templates, config.tmp.config];
|
|
19
|
+
/**
|
|
20
|
+
* Copies files from one fold to another, creating a new dir if doesn't exists and
|
|
21
|
+
* overwriting if it does exist
|
|
22
|
+
*
|
|
23
|
+
* @param {Array} files - files to copy
|
|
24
|
+
* @param {Object} srcOptions - second param for gulp.src function
|
|
25
|
+
* @param {String} dest - destination dir
|
|
26
|
+
* @returns {Stream}
|
|
27
|
+
* @private
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
function copyFiles(files, srcOptions, dest) {
|
|
31
|
+
return gulp.src(files, srcOptions).pipe(plumber(utils.errorHandler)).pipe(size({
|
|
32
|
+
showFiles: true,
|
|
33
|
+
pretty: true
|
|
34
|
+
})).pipe(gulp.dest(dest));
|
|
35
|
+
}
|
|
16
36
|
/**
|
|
17
37
|
* Clean up build dirs/files whenever doing a full/clean (re)build.
|
|
18
38
|
*
|
|
@@ -22,8 +42,8 @@ var utils = require('./includes/utilities.js');
|
|
|
22
42
|
*/
|
|
23
43
|
|
|
24
44
|
|
|
25
|
-
gulp.task(
|
|
26
|
-
return del([
|
|
45
|
+
gulp.task("clean", function () {
|
|
46
|
+
return del(["upload", "dist", "tmp"]);
|
|
27
47
|
});
|
|
28
48
|
/**
|
|
29
49
|
* Compress theme and build a shopify-compatible `.zip` file for uploading to store
|
|
@@ -33,11 +53,36 @@ gulp.task('clean', function () {
|
|
|
33
53
|
* @static
|
|
34
54
|
*/
|
|
35
55
|
|
|
36
|
-
gulp.task(
|
|
56
|
+
gulp.task("compress", function () {
|
|
37
57
|
var distFiles = "".concat(config.dist.root, "**/*");
|
|
38
|
-
|
|
39
|
-
return gulp.src([distFiles, ignoreConfig]).pipe(plumber(utils.errorHandler)).pipe(zip("".concat(config.packageJson.name, ".zip") || 'theme.zip')).pipe(size({
|
|
58
|
+
return gulp.src([distFiles]).pipe(plumber(utils.errorHandler)).pipe(zip("".concat(config.packageJson.name, ".zip") || "theme.zip")).pipe(size({
|
|
40
59
|
showFiles: true,
|
|
41
60
|
pretty: true
|
|
42
|
-
})).pipe(gulp.dest(
|
|
61
|
+
})).pipe(gulp.dest("./upload/"));
|
|
62
|
+
});
|
|
63
|
+
/**
|
|
64
|
+
* Duplicates /src directory into a /tmp directory
|
|
65
|
+
*
|
|
66
|
+
* @function generate:tmp
|
|
67
|
+
* @memberof seed-cli.tasks.sync-settings
|
|
68
|
+
* @static
|
|
69
|
+
*/
|
|
70
|
+
|
|
71
|
+
gulp.task("generate:tmp", function () {
|
|
72
|
+
return copyFiles(assetsPaths, {
|
|
73
|
+
base: config.src.root
|
|
74
|
+
}, config.tmp.root);
|
|
75
|
+
});
|
|
76
|
+
/**
|
|
77
|
+
* Syncronizes the theme settings of /tmp directory into our src directory
|
|
78
|
+
*
|
|
79
|
+
* @function sync-settings:tmp:src
|
|
80
|
+
* @memberof seed-cli.tasks.sync-settings
|
|
81
|
+
* @static
|
|
82
|
+
*/
|
|
83
|
+
|
|
84
|
+
gulp.task("sync-settings:tmp:src", function () {
|
|
85
|
+
return copyFiles(themeSettingsAssets, {
|
|
86
|
+
base: config.tmp.root
|
|
87
|
+
}, config.src.root);
|
|
43
88
|
});
|
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var join = require(
|
|
3
|
+
var join = require("path").join;
|
|
4
4
|
|
|
5
|
-
var logger = require(
|
|
5
|
+
var logger = require("debug")("seed-tools");
|
|
6
6
|
|
|
7
|
-
var findRoot = require(
|
|
7
|
+
var findRoot = require("find-root");
|
|
8
8
|
|
|
9
|
-
var autoprefixer = require(
|
|
9
|
+
var autoprefixer = require("autoprefixer");
|
|
10
10
|
|
|
11
|
-
var tailwindcss = require(
|
|
11
|
+
var tailwindcss = require("tailwindcss");
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var cssnano = require("cssnano");
|
|
14
|
+
|
|
15
|
+
var argv = require("minimist")(process.argv.slice(2));
|
|
14
16
|
|
|
15
17
|
var themeRoot = findRoot(process.cwd());
|
|
18
|
+
var tailwindConfig = 'tailwind.config.js';
|
|
16
19
|
var pkg = {};
|
|
17
20
|
|
|
18
21
|
try {
|
|
19
|
-
pkg = require(join(themeRoot,
|
|
22
|
+
pkg = require(join(themeRoot, "package.json"));
|
|
20
23
|
} catch (err) {
|
|
21
24
|
logger(err);
|
|
22
25
|
}
|
|
@@ -37,10 +40,9 @@ try {
|
|
|
37
40
|
* @memberof seed-cli
|
|
38
41
|
* @summary Configuring seed-cli
|
|
39
42
|
* @prop {String} environment - development | staging | production
|
|
40
|
-
* @prop {String} tkconfig - path to themekit config file
|
|
41
|
-
* @prop {String} scssLintConfig - path to scss-lint config file
|
|
42
43
|
* @prop {String} deployLog - path to deploy log file
|
|
43
44
|
* @prop {String} src - globs (multi-filename matching patterns) for various source files
|
|
45
|
+
* @prop {String} tmp - globs (multi-filename matching patterns) for various tmp files
|
|
44
46
|
* @prop {Object} dist - paths to relevant folder locations in the distributable directory
|
|
45
47
|
* @prop {Object} roots - array of "root" (entry point) JS & CSS files
|
|
46
48
|
* @prop {Object} plugins - configuration objects passed to various plugins used in the task interface
|
|
@@ -48,49 +50,74 @@ try {
|
|
|
48
50
|
|
|
49
51
|
|
|
50
52
|
var config = {
|
|
51
|
-
environment: argv.
|
|
53
|
+
environment: argv.environment || "development",
|
|
54
|
+
optimize: !argv["skip-optimization"],
|
|
52
55
|
themeRoot: themeRoot,
|
|
53
56
|
packageJson: pkg,
|
|
54
|
-
|
|
55
|
-
|
|
57
|
+
tailwindConfig: tailwindConfig,
|
|
58
|
+
seedConfig: "seed.config.js",
|
|
56
59
|
src: {
|
|
57
|
-
root:
|
|
58
|
-
js:
|
|
59
|
-
vendorJs:
|
|
60
|
-
json:
|
|
61
|
-
css:
|
|
62
|
-
cssLint:
|
|
63
|
-
vendorCss:
|
|
64
|
-
assets:
|
|
65
|
-
icons:
|
|
66
|
-
templates:
|
|
67
|
-
snippets:
|
|
68
|
-
sections:
|
|
69
|
-
locales:
|
|
70
|
-
config:
|
|
71
|
-
layout:
|
|
60
|
+
root: "src/",
|
|
61
|
+
js: "src/scripts/**/*.{js,js.liquid}",
|
|
62
|
+
vendorJs: "src/scripts/vendor/*.js",
|
|
63
|
+
json: "src/**/*.json",
|
|
64
|
+
css: "src/styles/**/*.{css,scss,scss.liquid}",
|
|
65
|
+
cssLint: "src/styles/**/*.{css,scss}",
|
|
66
|
+
vendorCss: "src/styles/vendor/*.{css,scss}",
|
|
67
|
+
assets: "src/assets/**/*",
|
|
68
|
+
icons: "src/icons/**/*.svg",
|
|
69
|
+
templates: "src/templates/**/*",
|
|
70
|
+
snippets: "src/snippets/*",
|
|
71
|
+
sections: "src/sections/*",
|
|
72
|
+
locales: "src/locales/*",
|
|
73
|
+
config: "src/config/*",
|
|
74
|
+
layout: "src/layout/*"
|
|
75
|
+
},
|
|
76
|
+
tmp: {
|
|
77
|
+
root: "tmp/",
|
|
78
|
+
js: "tmp/scripts/**/*.{js,js.liquid}",
|
|
79
|
+
vendorJs: "tmp/scripts/vendor/*.js",
|
|
80
|
+
json: "tmp/**/*.json",
|
|
81
|
+
css: "tmp/styles/**/*.{css,scss,scss.liquid}",
|
|
82
|
+
cssLint: "tmp/styles/**/*.{css,scss}",
|
|
83
|
+
vendorCss: "tmp/styles/vendor/*.{css,scss}",
|
|
84
|
+
assets: "tmp/assets/**/*",
|
|
85
|
+
icons: "tmp/icons/**/*.svg",
|
|
86
|
+
templates: "tmp/templates/**/*",
|
|
87
|
+
snippets: "tmp/snippets/*",
|
|
88
|
+
sections: "tmp/sections/*",
|
|
89
|
+
locales: "tmp/locales/*",
|
|
90
|
+
config: "tmp/config/*",
|
|
91
|
+
layout: "tmp/layout/*"
|
|
72
92
|
},
|
|
73
93
|
dist: {
|
|
74
|
-
root:
|
|
75
|
-
assets:
|
|
76
|
-
snippets:
|
|
77
|
-
sections:
|
|
78
|
-
layout:
|
|
79
|
-
templates:
|
|
80
|
-
locales:
|
|
94
|
+
root: "dist/",
|
|
95
|
+
assets: "dist/assets/",
|
|
96
|
+
snippets: "dist/snippets/",
|
|
97
|
+
sections: "dist/sections/",
|
|
98
|
+
layout: "dist/layout/",
|
|
99
|
+
templates: "dist/templates/",
|
|
100
|
+
locales: "dist/locales/"
|
|
81
101
|
},
|
|
82
102
|
roots: {
|
|
83
|
-
js:
|
|
84
|
-
vendorJs:
|
|
85
|
-
css:
|
|
103
|
+
js: "src/scripts/*.{js,js.liquid}",
|
|
104
|
+
vendorJs: "src/scripts/vendor.js",
|
|
105
|
+
css: "src/styles/*.{css,scss}"
|
|
86
106
|
},
|
|
87
107
|
plugins: {
|
|
88
108
|
cheerio: {
|
|
89
|
-
run: require(
|
|
109
|
+
run: require("./utilities.js").processSvg
|
|
90
110
|
},
|
|
91
111
|
postcss: [tailwindcss({
|
|
92
|
-
config: join(themeRoot,
|
|
112
|
+
config: join(themeRoot, tailwindConfig)
|
|
93
113
|
}), autoprefixer()]
|
|
94
114
|
}
|
|
95
115
|
};
|
|
116
|
+
|
|
117
|
+
if (config.optimize) {
|
|
118
|
+
config.plugins.postcss.push(cssnano({
|
|
119
|
+
preset: "default"
|
|
120
|
+
}));
|
|
121
|
+
}
|
|
122
|
+
|
|
96
123
|
module.exports = config;
|
|
@@ -6,12 +6,9 @@ var chalk = require("chalk");
|
|
|
6
6
|
|
|
7
7
|
var log = require("fancy-log");
|
|
8
8
|
|
|
9
|
-
var _ = require(
|
|
9
|
+
var _ = require("lodash");
|
|
10
10
|
|
|
11
|
-
var Promise = require(
|
|
12
|
-
|
|
13
|
-
var _require = require("../../utils"),
|
|
14
|
-
shopifyCLI = _require.shopifyCLI;
|
|
11
|
+
var Promise = require("bluebird");
|
|
15
12
|
|
|
16
13
|
var errors = [];
|
|
17
14
|
/**
|
|
@@ -23,27 +20,6 @@ var errors = [];
|
|
|
23
20
|
*/
|
|
24
21
|
|
|
25
22
|
var utilities = {
|
|
26
|
-
/**
|
|
27
|
-
* Launches shopify theme serve command to serve files on ./dist folder
|
|
28
|
-
*
|
|
29
|
-
* @memberof seed-cli.utilities
|
|
30
|
-
* @returns {object} - ChildProcess
|
|
31
|
-
*/
|
|
32
|
-
serveDist: function serveDist() {
|
|
33
|
-
return shopifyCLI.serve();
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Launches shopify theme push command to deploy files on ./dist folder
|
|
38
|
-
* to a store's theme
|
|
39
|
-
*
|
|
40
|
-
* @memberof seed-cli.utilities
|
|
41
|
-
* @returns {object} - ChildProcess
|
|
42
|
-
*/
|
|
43
|
-
deployDist: function deployDist() {
|
|
44
|
-
return shopifyCLI.push();
|
|
45
|
-
},
|
|
46
|
-
|
|
47
23
|
/**
|
|
48
24
|
* Handles the output for any errors that might have been captured
|
|
49
25
|
* during the build and zip Gulp tasks.
|
|
@@ -73,7 +49,7 @@ var utilities = {
|
|
|
73
49
|
log(chalk.red(err));
|
|
74
50
|
errors.push(err);
|
|
75
51
|
|
|
76
|
-
_this.emit(
|
|
52
|
+
_this.emit("end");
|
|
77
53
|
},
|
|
78
54
|
|
|
79
55
|
/**
|
|
@@ -100,32 +76,32 @@ var utilities = {
|
|
|
100
76
|
* @param {fs} file - reference to current icon file?
|
|
101
77
|
*/
|
|
102
78
|
processSvg: function processSvg($, file) {
|
|
103
|
-
var $svg = $(
|
|
79
|
+
var $svg = $("svg"); // eslint-disable-line no-var
|
|
104
80
|
|
|
105
81
|
var $newSvg = $('<svg aria-hidden="true" focusable="false" role="presentation" class="icon" />'); // eslint-disable-line no-var
|
|
106
82
|
|
|
107
|
-
var fileName = file.relative.replace(
|
|
83
|
+
var fileName = file.relative.replace(".svg", ""); // eslint-disable-line no-var
|
|
108
84
|
|
|
109
|
-
var viewBoxAttr = $svg.attr(
|
|
85
|
+
var viewBoxAttr = $svg.attr("viewbox"); // eslint-disable-line no-var
|
|
110
86
|
// Add necessary attributes
|
|
111
87
|
|
|
112
88
|
if (viewBoxAttr) {
|
|
113
|
-
var width = parseInt(viewBoxAttr.split(
|
|
89
|
+
var width = parseInt(viewBoxAttr.split(" ")[2], 10); // eslint-disable-line no-var
|
|
114
90
|
|
|
115
|
-
var height = parseInt(viewBoxAttr.split(
|
|
91
|
+
var height = parseInt(viewBoxAttr.split(" ")[3], 10); // eslint-disable-line no-var
|
|
116
92
|
|
|
117
93
|
var widthToHeightRatio = width / height; // eslint-disable-line no-var
|
|
118
94
|
|
|
119
95
|
if (widthToHeightRatio >= 1.5) {
|
|
120
|
-
$newSvg.addClass(
|
|
96
|
+
$newSvg.addClass("icon--wide");
|
|
121
97
|
}
|
|
122
98
|
|
|
123
|
-
$newSvg.attr(
|
|
99
|
+
$newSvg.attr("viewBox", viewBoxAttr);
|
|
124
100
|
} // Add required classes to full color icons
|
|
125
101
|
|
|
126
102
|
|
|
127
|
-
if (file.relative.indexOf(
|
|
128
|
-
$newSvg.addClass(
|
|
103
|
+
if (file.relative.indexOf("-full-color") >= 0) {
|
|
104
|
+
$newSvg.addClass("icon--full-color");
|
|
129
105
|
}
|
|
130
106
|
|
|
131
107
|
$newSvg.addClass(fileName).append($svg.contents());
|
|
@@ -145,8 +121,8 @@ var utilities = {
|
|
|
145
121
|
createEventCache: function createEventCache(options) {
|
|
146
122
|
_.defaults(options = options || {}, {
|
|
147
123
|
// eslint-disable-line no-param-reassign
|
|
148
|
-
changeEvents: [
|
|
149
|
-
unlinkEvents: [
|
|
124
|
+
changeEvents: ["add", "change"],
|
|
125
|
+
unlinkEvents: ["unlink"]
|
|
150
126
|
});
|
|
151
127
|
/**
|
|
152
128
|
* A cache object used for caching `[chokidar]{@link https://github.com/paulmillr/chokidar}`
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var gulp = require("gulp"); // const path = require("path");
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _require = require("../utils"),
|
|
7
|
+
shopifyCLI = _require.shopifyCLI,
|
|
8
|
+
extractThemeId = _require.extractThemeId,
|
|
9
|
+
logChildProcessOutput = _require.logChildProcessOutput,
|
|
10
|
+
getDevThemeID = _require.getDevThemeID,
|
|
11
|
+
setDevThemeID = _require.setDevThemeID,
|
|
12
|
+
getThemeID = _require.getThemeID;
|
|
13
|
+
|
|
14
|
+
var config = require("./includes/config");
|
|
15
|
+
/**
|
|
16
|
+
* Initiates shopify's cli command 'shopify theme serve' on the dist folder,
|
|
17
|
+
* watching files and uploading them to development store
|
|
18
|
+
*
|
|
19
|
+
* @function shopify:serve:dist
|
|
20
|
+
* @memberof seed-cli.tasks.watch
|
|
21
|
+
* @static
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
gulp.task("shopify:serve:dist", function () {
|
|
26
|
+
console.log("Running Shopify theme serve...");
|
|
27
|
+
var childProcess = shopifyCLI.serve({
|
|
28
|
+
stdio: ["inherit", "pipe", "inherit"]
|
|
29
|
+
});
|
|
30
|
+
childProcess.stdout.setEncoding("utf8");
|
|
31
|
+
logChildProcessOutput(childProcess);
|
|
32
|
+
persistDevThemeID(childProcess);
|
|
33
|
+
return childProcess;
|
|
34
|
+
});
|
|
35
|
+
/**
|
|
36
|
+
* Pulls theme files from the development theme specified in seed config into src
|
|
37
|
+
*
|
|
38
|
+
* @function shopify:pull:dev
|
|
39
|
+
* @memberof seed-cli.tasks.deploy
|
|
40
|
+
* @static
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
gulp.task("shopify:pull:dev", function (done) {
|
|
44
|
+
var devThemeId = getDevThemeID(config.themeRoot);
|
|
45
|
+
|
|
46
|
+
if (!devThemeId) {
|
|
47
|
+
return done();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return shopifyCLI.pull(devThemeId);
|
|
51
|
+
});
|
|
52
|
+
/**
|
|
53
|
+
* Pulls theme files from the development theme specified in seed config into tmp
|
|
54
|
+
*
|
|
55
|
+
* @function shopify:pull:dev:tmp
|
|
56
|
+
* @memberof seed-cli.tasks.deploy
|
|
57
|
+
* @static
|
|
58
|
+
*/
|
|
59
|
+
|
|
60
|
+
gulp.task("shopify:pull:dev:tmp", function (done) {
|
|
61
|
+
var devThemeId = getDevThemeID(config.themeRoot);
|
|
62
|
+
|
|
63
|
+
if (!devThemeId) {
|
|
64
|
+
return done();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return shopifyCLI.pull(devThemeId, config.tmp.root);
|
|
68
|
+
});
|
|
69
|
+
/**
|
|
70
|
+
* Initiates shopify's cli command 'shopify theme push' on the dist folder,
|
|
71
|
+
* pushing it to stores theme
|
|
72
|
+
*
|
|
73
|
+
* @function deploy:dist
|
|
74
|
+
* @memberof seed-cli.tasks.deploy
|
|
75
|
+
* @static
|
|
76
|
+
*/
|
|
77
|
+
|
|
78
|
+
gulp.task("shopify:push:dist", function () {
|
|
79
|
+
return shopifyCLI.push(getThemeID(config.themeRoot, config.environment));
|
|
80
|
+
});
|
|
81
|
+
/**
|
|
82
|
+
* Takes the output of shopify cli serve, extracts dev theme ID and persists
|
|
83
|
+
* in seed.config.js
|
|
84
|
+
*
|
|
85
|
+
* @param {child_process} serveProcess shopify cli serve spawned child process
|
|
86
|
+
*/
|
|
87
|
+
|
|
88
|
+
function persistDevThemeID(serveProcess) {
|
|
89
|
+
serveProcess.stdout.on("data", function (data) {
|
|
90
|
+
var devThemeId = extractThemeId(data.toString());
|
|
91
|
+
var currentDevThemeId = getDevThemeID(config.themeRoot); // If we already have latest dev theme ID, we got nothing left to do
|
|
92
|
+
|
|
93
|
+
if (devThemeId === currentDevThemeId) return; // Else, write dev theme ID into seed.config.js
|
|
94
|
+
|
|
95
|
+
setDevThemeID(devThemeId);
|
|
96
|
+
});
|
|
97
|
+
}
|