@madebyseed/seed-cli-tools 2.3.1 → 2.4.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.
Files changed (100) hide show
  1. package/lib/commands/build.d.ts +2 -0
  2. package/lib/commands/build.js +30 -29
  3. package/lib/commands/build.js.map +1 -0
  4. package/lib/commands/deploy.d.ts +2 -0
  5. package/lib/commands/deploy.js +42 -30
  6. package/lib/commands/deploy.js.map +1 -0
  7. package/lib/commands/pull.d.ts +2 -0
  8. package/lib/commands/pull.js +39 -29
  9. package/lib/commands/pull.js.map +1 -0
  10. package/lib/commands/watch.d.ts +2 -0
  11. package/lib/commands/watch.js +44 -40
  12. package/lib/commands/watch.js.map +1 -0
  13. package/lib/commands/zip.d.ts +2 -0
  14. package/lib/commands/zip.js +23 -25
  15. package/lib/commands/zip.js.map +1 -0
  16. package/lib/config.d.ts +3 -0
  17. package/lib/config.js +21 -28
  18. package/lib/config.js.map +1 -0
  19. package/lib/gulpfile.d.ts +1 -0
  20. package/lib/gulpfile.js +26 -33
  21. package/lib/gulpfile.js.map +1 -0
  22. package/lib/tasks/build-assets.d.ts +1 -0
  23. package/lib/tasks/build-assets.js +80 -72
  24. package/lib/tasks/build-assets.js.map +1 -0
  25. package/lib/tasks/build-css.d.ts +1 -0
  26. package/lib/tasks/build-css.js +88 -82
  27. package/lib/tasks/build-css.js.map +1 -0
  28. package/lib/tasks/build-js.d.ts +1 -0
  29. package/lib/tasks/build-js.js +77 -83
  30. package/lib/tasks/build-js.js.map +1 -0
  31. package/lib/tasks/build-svg.d.ts +1 -0
  32. package/lib/tasks/build-svg.js +51 -54
  33. package/lib/tasks/build-svg.js.map +1 -0
  34. package/lib/tasks/build-utils.d.ts +1 -0
  35. package/lib/tasks/build-utils.js +68 -49
  36. package/lib/tasks/build-utils.js.map +1 -0
  37. package/lib/tasks/includes/config.d.ts +70 -0
  38. package/lib/tasks/includes/config.js +117 -163
  39. package/lib/tasks/includes/config.js.map +1 -0
  40. package/lib/tasks/includes/messages.d.ts +19 -0
  41. package/lib/tasks/includes/messages.js +80 -72
  42. package/lib/tasks/includes/messages.js.map +1 -0
  43. package/lib/tasks/includes/utilities.d.ts +71 -0
  44. package/lib/tasks/includes/utilities.js +127 -141
  45. package/lib/tasks/includes/utilities.js.map +1 -0
  46. package/lib/tasks/shopify-cli.d.ts +1 -0
  47. package/lib/tasks/shopify-cli.js +106 -93
  48. package/lib/tasks/shopify-cli.js.map +1 -0
  49. package/lib/tasks/watchers.d.ts +1 -0
  50. package/lib/tasks/watchers.js +29 -29
  51. package/lib/tasks/watchers.js.map +1 -0
  52. package/lib/types.d.ts +48 -0
  53. package/lib/types.js +3 -0
  54. package/lib/types.js.map +1 -0
  55. package/lib/utils.d.ts +90 -0
  56. package/lib/utils.js +194 -189
  57. package/lib/utils.js.map +1 -0
  58. package/package.json +36 -16
  59. package/src/commands/build.ts +39 -0
  60. package/src/commands/deploy.ts +70 -0
  61. package/src/commands/pull.ts +58 -0
  62. package/src/commands/watch.ts +72 -0
  63. package/src/commands/zip.ts +28 -0
  64. package/src/config.ts +28 -0
  65. package/src/gulpfile.ts +134 -0
  66. package/src/tasks/build-assets.ts +135 -0
  67. package/src/tasks/build-css.ts +129 -0
  68. package/src/tasks/build-js.ts +108 -0
  69. package/src/tasks/build-svg.ts +92 -0
  70. package/src/tasks/build-utils.ts +137 -0
  71. package/src/tasks/includes/config.ts +222 -0
  72. package/src/tasks/includes/messages.ts +157 -0
  73. package/src/tasks/includes/utilities.ts +170 -0
  74. package/src/tasks/shopify-cli.ts +197 -0
  75. package/src/tasks/watchers.ts +50 -0
  76. package/src/types/declarations.d.ts +72 -0
  77. package/src/types.ts +74 -0
  78. package/src/utils.ts +304 -0
  79. package/{src → src-legacy}/tasks/build-js.js +5 -6
  80. package/tsconfig.json +14 -0
  81. package/tsconfig.tsbuildinfo +1 -0
  82. package/.babelrc +0 -3
  83. package/.eslintrc +0 -8
  84. /package/{src → src-legacy}/commands/build.js +0 -0
  85. /package/{src → src-legacy}/commands/deploy.js +0 -0
  86. /package/{src → src-legacy}/commands/pull.js +0 -0
  87. /package/{src → src-legacy}/commands/watch.js +0 -0
  88. /package/{src → src-legacy}/commands/zip.js +0 -0
  89. /package/{src → src-legacy}/config.js +0 -0
  90. /package/{src → src-legacy}/gulpfile.js +0 -0
  91. /package/{src → src-legacy}/tasks/build-assets.js +0 -0
  92. /package/{src → src-legacy}/tasks/build-css.js +0 -0
  93. /package/{src → src-legacy}/tasks/build-svg.js +0 -0
  94. /package/{src → src-legacy}/tasks/build-utils.js +0 -0
  95. /package/{src → src-legacy}/tasks/includes/config.js +0 -0
  96. /package/{src → src-legacy}/tasks/includes/messages.js +0 -0
  97. /package/{src → src-legacy}/tasks/includes/utilities.js +0 -0
  98. /package/{src → src-legacy}/tasks/shopify-cli.js +0 -0
  99. /package/{src → src-legacy}/tasks/watchers.js +0 -0
  100. /package/{src → src-legacy}/utils.js +0 -0
package/package.json CHANGED
@@ -1,32 +1,53 @@
1
1
  {
2
2
  "name": "@madebyseed/seed-cli-tools",
3
- "version": "2.3.1",
3
+ "version": "2.4.0",
4
4
  "description": "Seed CLI Tools",
5
- "main": "index.js",
5
+ "main": "lib/index.js",
6
+ "types": "lib/index.d.ts",
6
7
  "scripts": {
7
8
  "clean": "rm -rf lib/",
8
- "start": "npm run clean && babel -w -d lib/ src/",
9
- "test": "npm run lint",
10
- "prepublish": "npm test && npm run clean && babel -d lib/ src/",
11
- "dev": "npm run prepublish && npm link",
12
9
  "lint": "eslint --max-warnings 0 src/",
13
- "lint-allow-warning": "eslint src/"
10
+ "lint-allow-warning": "eslint src/",
11
+ "build": "npm run clean && npx tsc --build --verbose --force",
12
+ "watch": "tsc --build --watch",
13
+ "test": "npm run lint",
14
+ "prepublish": "npm run build"
14
15
  },
15
16
  "author": "SeedCMS",
16
17
  "license": "ISC",
17
18
  "devDependencies": {
18
- "@babel/cli": "^7.14.8",
19
- "@babel/core": "^7.14.8",
20
- "@babel/preset-env": "^7.14.8",
21
- "@babel/register": "^7.14.5",
22
- "babel-eslint": "^10.1.0",
23
- "eslint": "^7.31.0"
19
+ "@types/bluebird": "^3.5.42",
20
+ "@types/cross-spawn": "^6.0.6",
21
+ "@types/debug": "^4.1.12",
22
+ "@types/fancy-log": "^2.0.2",
23
+ "@types/find-root": "^1.1.4",
24
+ "@types/gulp": "^4.0.17",
25
+ "@types/gulp-if": "^3.0.5",
26
+ "@types/gulp-plumber": "^0.0.37",
27
+ "@types/gulp-postcss": "^8.0.6",
28
+ "@types/gulp-sass": "^5.0.4",
29
+ "@types/gulp-size": "^4.0.3",
30
+ "@types/gulp-uglify": "^3.0.11",
31
+ "@types/lodash": "^4.17.20",
32
+ "@types/node": "^20.11.24",
33
+ "@types/sass": "^1.45.0",
34
+ "@types/uglify-js": "^3.17.5",
35
+ "@types/vinyl-paths": "^5.0.0",
36
+ "@typescript-eslint/eslint-plugin": "^7.1.0",
37
+ "@typescript-eslint/parser": "^7.1.0",
38
+ "eslint": "^9.18.0",
39
+ "eslint-config-prettier": "^10.0.1",
40
+ "eslint-plugin-prettier": "^5.2.2",
41
+ "prettier": "^3.4.2",
42
+ "typescript": "^5.8.3",
43
+ "typescript-eslint": "^8.20.0"
24
44
  },
25
45
  "dependencies": {
26
46
  "autoprefixer": "^10.3.1",
27
47
  "bluebird": "^3.7.2",
28
48
  "chalk": "^4.1.1",
29
49
  "chokidar": "^3.5.2",
50
+ "commander": "^13.1.0",
30
51
  "cross-spawn": "^7.0.3",
31
52
  "cssnano": "^5.0.8",
32
53
  "debug": "^4.3.2",
@@ -45,6 +66,7 @@
45
66
  "gulp-size": "^4.0.1",
46
67
  "gulp-uglify": "^3.0.2",
47
68
  "lodash": "^4.17.21",
69
+ "minimist": "^1.2.5",
48
70
  "postcss": "^8.3.6",
49
71
  "postcss-import": "^14.0.2",
50
72
  "postcss-pxtorem": "^6.0.0",
@@ -54,9 +76,7 @@
54
76
  "tailwindcss": "^3.1.4",
55
77
  "uglify-js": "^3.15.3",
56
78
  "vinyl-paths": "^3.0.1",
57
- "webpack": "^5.72.1",
58
- "webpack-stream": "^7.0.0",
59
79
  "yargs": "^17.0.1"
60
80
  },
61
- "gitHead": "018f1210f603f30c38dfb6cc17eb66967072e3b3"
81
+ "gitHead": "4ada9de9c0d943af873dd565575744aaa0512e41"
62
82
  }
@@ -0,0 +1,39 @@
1
+ import spawn from "cross-spawn";
2
+ import debug from "debug";
3
+ import { Command } from "commander";
4
+ import config from "../config";
5
+
6
+ const logger = debug("seed-tools:deploy");
7
+
8
+ interface BuildOptions {
9
+ skipOptimizations?: boolean;
10
+ }
11
+
12
+ export default function (program: Command): void {
13
+ program
14
+ .command("build")
15
+ .alias("b")
16
+ .description("Builds ./src files into dist folder")
17
+ .option(
18
+ "-s, --skip-optimizations",
19
+ "Skips asset optimization steps such as compression, minification and purging.",
20
+ false,
21
+ )
22
+ .action((options: BuildOptions = {}) => {
23
+ logger(`--gulpfile ${config.gulpFile}`);
24
+ logger(`--cwd ${config.themeRoot}`);
25
+
26
+ const args = ["build"];
27
+
28
+ if (options.skipOptimizations) args.push("--skip-optimizations");
29
+
30
+ if (!options.skipOptimizations) {
31
+ process.env.NODE_ENV = "production";
32
+ }
33
+
34
+ spawn(config.gulp, args.concat(["--gulpfile", config.gulpFile, "--cwd", config.themeRoot]), {
35
+ detached: false,
36
+ stdio: "inherit",
37
+ });
38
+ });
39
+ }
@@ -0,0 +1,70 @@
1
+ import spawn from "cross-spawn";
2
+ import debug from "debug";
3
+ import { Command } from "commander";
4
+ import config from "../config";
5
+
6
+ const logger = debug("seed-tools:deploy");
7
+
8
+ interface DeployOptions {
9
+ env?: string;
10
+ store?: string;
11
+ dev?: boolean;
12
+ skipOptimizations?: boolean;
13
+ delete?: boolean;
14
+ }
15
+
16
+ export default function (program: Command): void {
17
+ program
18
+ .command("deploy")
19
+ .alias("d")
20
+ .description(
21
+ "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.",
22
+ )
23
+ .option(
24
+ "-e, --env <environment>",
25
+ "Shopify theme to deploy code to (specified in seed.config.js)",
26
+ "development",
27
+ )
28
+ .option(
29
+ "-st, --store <store>",
30
+ "Shopify store(s) to deploy code to (specified in seed.config.js)",
31
+ )
32
+ .option(
33
+ "-n, --no-dev",
34
+ "Skips pulling theme settings from local development theme",
35
+ false,
36
+ )
37
+ .option(
38
+ "-s, --skip-optimizations",
39
+ "Skips asset optimization steps such as compression, minification and purging.",
40
+ false,
41
+ )
42
+ .option(
43
+ "-d, --delete",
44
+ "By default seed deploy runs 'shopify theme push --nodelete'. With this option it will leave out the --no-delete flag, allowing files to be delete in store theme.",
45
+ false,
46
+ )
47
+ .action((options: DeployOptions = {}) => {
48
+ logger(`--gulpfile ${config.gulpFile}`);
49
+ logger(`--cwd ${config.themeRoot}`);
50
+
51
+ const args = [
52
+ options.dev ? "deploy" : "deploy:no-sync",
53
+ "--environment",
54
+ options.env,
55
+ "--store",
56
+ options.store,
57
+ ];
58
+
59
+ if (options.skipOptimizations) args.push("--skip-optimizations");
60
+ if (options.delete) args.push("--delete");
61
+
62
+ if (!options.skipOptimizations) process.env.NODE_ENV = "production";
63
+
64
+ // @ts-ignore
65
+ spawn(config.gulp, args.concat(["--gulpfile", config.gulpFile, "--cwd", config.themeRoot]), {
66
+ detached: false,
67
+ stdio: "inherit",
68
+ });
69
+ });
70
+ }
@@ -0,0 +1,58 @@
1
+ import spawn from "cross-spawn";
2
+ import debug from "debug";
3
+ import { Command } from "commander";
4
+ import config from "../config";
5
+
6
+ const logger = debug("seed-tools:deploy");
7
+
8
+ interface PullOptions {
9
+ env?: string;
10
+ store?: string;
11
+ all?: boolean;
12
+ delete?: boolean;
13
+ }
14
+
15
+ export default function (program: Command): void {
16
+ program
17
+ .command("pull")
18
+ .alias("p")
19
+ .description(
20
+ "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.",
21
+ )
22
+ .option(
23
+ "-e, --env <environment>[,<environment>...]",
24
+ "Shopify store(s) to deploy code to (specified in seed.config.js)",
25
+ "development",
26
+ )
27
+ .option(
28
+ "-st, --store <store>",
29
+ "Shopify store(s) to deploy code to (specified in seed.config.js)",
30
+ )
31
+ .option("-a, --all", "Pulls all files from specified theme", false)
32
+ .option(
33
+ "-d, --delete",
34
+ "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.",
35
+ false,
36
+ )
37
+ .action((options: PullOptions = {}) => {
38
+ logger(`--gulpfile ${config.gulpFile}`);
39
+ logger(`--cwd ${config.themeRoot}`);
40
+
41
+ const args = [
42
+ options.all ? "pull" : "pull:settings",
43
+ "--environment",
44
+ options.env,
45
+ "--store",
46
+ options.store,
47
+ ];
48
+
49
+ if (options.all) args.push("--all");
50
+ if (options.delete) args.push("--delete");
51
+
52
+ // @ts-ignore
53
+ spawn(config.gulp, args.concat(["--gulpfile", config.gulpFile, "--cwd", config.themeRoot]), {
54
+ detached: false,
55
+ stdio: "inherit",
56
+ });
57
+ });
58
+ }
@@ -0,0 +1,72 @@
1
+ import spawn from "cross-spawn";
2
+ import debug from "debug";
3
+ import { Command } from "commander";
4
+ import config from "../config";
5
+
6
+ const logger = debug("seed-tools:watch");
7
+
8
+ interface WatchOptions {
9
+ store?: string | false;
10
+ storePassword?: string | false;
11
+ optimize?: boolean;
12
+ env?: string;
13
+ }
14
+
15
+ export default function (program: Command): void {
16
+ program
17
+ .command("watch")
18
+ .alias("w")
19
+ .description(
20
+ "Watches files for code changes and immediately deploys updates to dev theme as they occur. " +
21
+ "This uses shopify theme serve under the hood.",
22
+ )
23
+ .option(
24
+ "-s, --store <store>",
25
+ "Used for multi-store projects, specify the store to run the watch command for.",
26
+ false,
27
+ )
28
+ .option(
29
+ "-sp, --store-password <password>",
30
+ "Used for store password protected stores.",
31
+ false,
32
+ )
33
+ .option(
34
+ "-o, --optimize",
35
+ "Optimizes assets by compressing, minifying and purging.",
36
+ false,
37
+ )
38
+ .action((options: WatchOptions = {}) => {
39
+ logger(`--gulpfile ${config.gulpFile}`);
40
+ logger(`--cwd ${config.themeRoot}`);
41
+
42
+ const args = ["watch"];
43
+
44
+ if (options.store) {
45
+ args.push("--store", options.store);
46
+ }
47
+
48
+ if (options.storePassword) {
49
+ args.push("--store-password", options.storePassword);
50
+ }
51
+
52
+ if (!options.optimize) args.push("--skip-optimizations");
53
+
54
+ process.env.NODE_ENV = options.optimize ? "production" : "development";
55
+
56
+ spawn(
57
+ config.gulp,
58
+ args.concat([
59
+ "--gulpfile",
60
+ config.gulpFile,
61
+ "--cwd",
62
+ config.themeRoot,
63
+ "--environment",
64
+ options.env || "development",
65
+ ]),
66
+ {
67
+ detached: false,
68
+ stdio: "inherit",
69
+ },
70
+ );
71
+ });
72
+ }
@@ -0,0 +1,28 @@
1
+ import spawn from "cross-spawn";
2
+ import debug from "debug";
3
+ import { Command } from "commander";
4
+ import config from "../config";
5
+
6
+ const logger = debug("seed-tools:zip");
7
+
8
+ export default function (program: Command): void {
9
+ program
10
+ .command("zip")
11
+ .alias("z")
12
+ .description(
13
+ "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).",
14
+ )
15
+ .action(() => {
16
+ logger(`--gulpfile ${config.gulpFile}`);
17
+ logger(`--cwd ${config.themeRoot}`);
18
+
19
+ spawn(
20
+ config.gulp,
21
+ ["zip", "--gulpfile", config.gulpFile, "--cwd", config.themeRoot],
22
+ {
23
+ detached: false,
24
+ stdio: "inherit",
25
+ },
26
+ );
27
+ });
28
+ }
package/src/config.ts ADDED
@@ -0,0 +1,28 @@
1
+ import { join, normalize } from "path";
2
+ import { existsSync } from "fs";
3
+ import findRoot from "find-root";
4
+ import { Config } from "./types";
5
+
6
+ const workingDirectory: string = process.cwd();
7
+ const currentDirectory: string = __dirname;
8
+
9
+ const themeRoot: string = findRoot(workingDirectory);
10
+ const defaultGulpPath: string = join(
11
+ themeRoot,
12
+ normalize("node_modules/.bin/gulp"),
13
+ );
14
+ // Legacy path for older versions of Node.
15
+ const legacyGulpPath: string = join(
16
+ themeRoot,
17
+ normalize("node_modules/@madebyseed/seed-cli-tools/node_modules/.bin/gulp"),
18
+ );
19
+
20
+ const config: Config = {
21
+ gulpFile: join(currentDirectory, "gulpfile.js"),
22
+ gulp: existsSync(defaultGulpPath) ? defaultGulpPath : legacyGulpPath,
23
+ themeRoot,
24
+ seedConfig: join(themeRoot, "seed.config.js"),
25
+ seedConfigDelimiter: "/** === delimiter */",
26
+ };
27
+
28
+ export default config;
@@ -0,0 +1,134 @@
1
+ import gulp from "gulp";
2
+ import requireDirectory from "require-directory";
3
+ import utils from "./tasks/includes/utilities";
4
+
5
+ // Import gulp tasks from the `tasks` directory
6
+ requireDirectory(module, "./tasks");
7
+
8
+ /**
9
+ * Handles the error summary at the end if there are errors to output.
10
+ * This task will only be run for the build and zip tasks.
11
+ */
12
+ gulp.task("output:errors", (done) => {
13
+ if (utils.hasErrors()) {
14
+ utils.outputErrors();
15
+ } else {
16
+ done();
17
+ }
18
+ });
19
+
20
+ /**
21
+ * Does a full clean/rebuild of your theme
22
+ *
23
+ * @function build
24
+ * @memberof slate-cli.tasks.build
25
+ * @static
26
+ */
27
+ gulp.task(
28
+ "build",
29
+ gulp.series(
30
+ "clean",
31
+ gulp.parallel(
32
+ "build:js",
33
+ "build:vendor-js",
34
+ "build:css",
35
+ "build:assets",
36
+ "build:svg",
37
+ ),
38
+ ),
39
+ );
40
+
41
+ /**
42
+ * Does a full clean/rebuild of your theme and creates a `.zip` compatible with
43
+ * shopify.
44
+ *
45
+ * @function zip
46
+ * @memberof slate-cli.tasks
47
+ * @static
48
+ */
49
+ gulp.task("zip", gulp.series("build", "shopify:package:dist", "copy:zip"));
50
+
51
+ /**
52
+ * Synchronizes the development theme settings with our src folder theme settings
53
+ *
54
+ * @function sync-settings
55
+ * @memberof seed-cli.tasks.deploy
56
+ * @static
57
+ */
58
+ gulp.task(
59
+ "sync-settings",
60
+ gulp.series("generate:tmp", "shopify:pull:dev:tmp", "sync-settings:tmp:src"),
61
+ );
62
+
63
+ /**
64
+ * Simple wrapper around src & dist watchers
65
+ *
66
+ * @summary Monitor your codebase for file changes and take the appropriate
67
+ * action
68
+ * @function watch
69
+ * @memberof slate-cli.tasks.watch
70
+ * @static
71
+ */
72
+ gulp.task(
73
+ "watch",
74
+ gulp.series(
75
+ "build",
76
+ "output:errors",
77
+ gulp.parallel("watch:src", "watch:dist", "shopify:serve:dist"),
78
+ ),
79
+ );
80
+
81
+ /**
82
+ * @summary pulls theme from specified environment theme into src
83
+ * @function pull
84
+ * @memberof slate-cli.tasks.deploy
85
+ * @static
86
+ */
87
+ gulp.task("pull", gulp.series("shopify:pull:origin:src"));
88
+
89
+ /**
90
+ * Does a full (re)build and push dist files into specified theme environment,
91
+ * theme using shopify theme push, by default with the --no-delete flag
92
+ *
93
+ * @summary pulls theme settings from specified environment theme into src
94
+ * @function pull:settings
95
+ * @memberof slate-cli.tasks.deploy
96
+ * @static
97
+ */
98
+ gulp.task(
99
+ "pull:settings",
100
+ gulp.series(
101
+ "generate:tmp",
102
+ "shopify:pull:origin:tmp",
103
+ "sync-settings:tmp:src",
104
+ "clean",
105
+ ),
106
+ );
107
+
108
+ /**
109
+ * Synchronizes src folder theme settings with local development theme settings,
110
+ * then proceeds to do a full (re)build and push files into specified theme
111
+ * environment theme using shopify theme push, by default with the --no-delete flag
112
+ *
113
+ * @summary Deploy your built files to the Shopify Store set in
114
+ * `slate-cli.config`
115
+ * @function deploy
116
+ * @memberof slate-cli.tasks.deploy
117
+ * @static
118
+ */
119
+ gulp.task(
120
+ "deploy",
121
+ gulp.series("sync-settings", "build", "shopify:push:dist", "clean"),
122
+ );
123
+
124
+ /**
125
+ * Does a full (re)build and push dist files into specified theme environment,
126
+ * theme using shopify theme push, by default with the --no-delete flag
127
+ *
128
+ * @summary Deploy your built files to the Shopify Store set in
129
+ * `slate-cli.config`
130
+ * @function deploy:no-sync
131
+ * @memberof slate-cli.tasks.deploy:no-sync
132
+ * @static
133
+ */
134
+ gulp.task("deploy:no-sync", gulp.series("build", "shopify:push:dist"));
@@ -0,0 +1,135 @@
1
+ import gulp from "gulp";
2
+ import plumber from "gulp-plumber";
3
+ import chokidar from "chokidar";
4
+ import vinylPaths from "vinyl-paths";
5
+ import del from "del";
6
+ import size from "gulp-size";
7
+
8
+ import config from "./includes/config";
9
+ import utils from "./includes/utilities";
10
+ import messages from "./includes/messages";
11
+
12
+ const assetsPaths: string[] = [
13
+ config.src.assets,
14
+ config.src.templates,
15
+ config.src.sections,
16
+ config.src.snippets,
17
+ config.src.blocks,
18
+ config.src.locales,
19
+ config.src.config,
20
+ config.src.layout,
21
+ ];
22
+
23
+ const rootAssets: string[] = [config.shopifyIgnore];
24
+
25
+ /**
26
+ * Copies assets to the `/dist` directory
27
+ *
28
+ * @param {Array} files
29
+ * @returns {Stream}
30
+ * @private
31
+ */
32
+ function processAssets(files: string | string[]): NodeJS.ReadWriteStream {
33
+ messages.logProcessFiles("build:assets");
34
+ return gulp
35
+ .src(files, { base: config.src.root })
36
+ .pipe(plumber(utils.errorHandler))
37
+ .pipe(
38
+ size({
39
+ showFiles: true,
40
+ pretty: true,
41
+ }),
42
+ )
43
+ .pipe(gulp.dest(config.dist.root));
44
+ }
45
+
46
+ /**
47
+ * Copies root assets to the `/dist` directory
48
+ *
49
+ * @param {Array} files
50
+ * @returns {Stream}
51
+ * @private
52
+ */
53
+ function processRootAssets(files: string | string[]): NodeJS.ReadWriteStream {
54
+ messages.logProcessFiles("build:assets");
55
+ return gulp
56
+ .src(files, { allowEmpty: true })
57
+ .pipe(plumber(utils.errorHandler))
58
+ .pipe(
59
+ size({
60
+ showFiles: true,
61
+ pretty: true,
62
+ }),
63
+ )
64
+ .pipe(gulp.dest(config.dist.root));
65
+ }
66
+
67
+ /**
68
+ * Deletes specified files
69
+ *
70
+ * @param {Array} files
71
+ * @returns {Stream}
72
+ * @private
73
+ */
74
+ function removeAssets(files: string[]): NodeJS.ReadWriteStream {
75
+ messages.logProcessFiles("remove:assets");
76
+
77
+ const mapFiles = files.map((file) => {
78
+ const distFile = file.replace(config.src.root, config.dist.root);
79
+ return distFile;
80
+ });
81
+
82
+ return gulp
83
+ .src(mapFiles)
84
+ .pipe(plumber(utils.errorHandler))
85
+ .pipe(vinylPaths(del))
86
+ .pipe(
87
+ size({
88
+ showFiles: true,
89
+ pretty: true,
90
+ }),
91
+ );
92
+ }
93
+
94
+ /**
95
+ * Copies assets to the `/dist` directory
96
+ *
97
+ * @function build:assets
98
+ * @memberof seed-cli.tasks.build
99
+ * @static
100
+ */
101
+ gulp.task("build:assets", () => {
102
+ processRootAssets(rootAssets);
103
+ return processAssets(assetsPaths);
104
+ });
105
+
106
+ /**
107
+ * Watches assets in the `/src` directory
108
+ *
109
+ * @function watch:assets
110
+ * @memberof seed-cli.tasks.watch
111
+ * @static
112
+ */
113
+ gulp.task("watch:assets", () => {
114
+ const eventCache = utils.createEventCache();
115
+
116
+ chokidar
117
+ .watch(assetsPaths, {
118
+ ignored: /(^|[/\\])\../,
119
+ ignoreInitial: true,
120
+ })
121
+ .on("all", (event, path) => {
122
+ messages.logFileEvent(event, path);
123
+ eventCache.addEvent(event, path);
124
+ utils.processCache(eventCache, processAssets, removeAssets);
125
+ });
126
+
127
+ chokidar
128
+ .watch(rootAssets, {
129
+ ignoreInitial: true,
130
+ })
131
+ .on("all", (event, path) => {
132
+ messages.logFileEvent(event, path);
133
+ processRootAssets(rootAssets);
134
+ });
135
+ });