@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/lib/types.d.ts ADDED
@@ -0,0 +1,48 @@
1
+ import { SpawnSyncReturns } from "child_process";
2
+ import type { ChildProcess } from "child_process";
3
+ export interface Config {
4
+ gulpFile: string;
5
+ gulp: string;
6
+ themeRoot: string;
7
+ seedConfig: string;
8
+ seedConfigDelimiter: string;
9
+ }
10
+ export interface ShopifyCLI {
11
+ login: (store: string) => SpawnSyncReturns<Buffer>;
12
+ serve: (store: string, options?: Record<string, unknown>) => ChildProcess;
13
+ pull: (store: string, themeId?: string | undefined, dir?: string, nodelete?: boolean) => ChildProcess;
14
+ push: (store: string, themeId?: string | undefined, nodelete?: boolean) => ChildProcess;
15
+ package: () => ChildProcess;
16
+ }
17
+ export interface SeedConfig {
18
+ store?: string;
19
+ stores?: {
20
+ [key: string]: {
21
+ domain: string;
22
+ themes: {
23
+ [key: string]: string;
24
+ };
25
+ };
26
+ };
27
+ themes?: {
28
+ [key: string]: string;
29
+ };
30
+ __developmentThemeId?: string;
31
+ }
32
+ export interface SeedProjectConfig {
33
+ stores: {
34
+ [key: string]: {
35
+ domain: string;
36
+ password?: string;
37
+ };
38
+ };
39
+ pull: {
40
+ ignoreFiles: string[];
41
+ };
42
+ build: {
43
+ js: {
44
+ type: "legacy" | "bundle";
45
+ };
46
+ };
47
+ }
48
+ export type { BuildConfig, PathConfig, TmpPathConfig, DistPathConfig, RootsConfig, PluginsConfig, } from "./tasks/includes/config";
package/lib/types.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
package/lib/utils.d.ts ADDED
@@ -0,0 +1,90 @@
1
+ import type { ChildProcess } from "child_process";
2
+ import { SeedConfig, ShopifyCLI, SeedProjectConfig } from "./types";
3
+ /**
4
+ * Get seed.project.json from project root dir
5
+ *
6
+ * @param {string} themeRoot - the path to theme root dir
7
+ * @returns {SeedProjectConfig | null} - project config object or null if not found
8
+ */
9
+ export declare function getProjectConfig(themeRoot: string): SeedProjectConfig | null;
10
+ /**
11
+ * Get seed.config.js from project root dir
12
+ *
13
+ * @param {string} themeRoot - the path to theme root dir
14
+ * @returns {SeedConfig} - seed config object
15
+ */
16
+ export declare function getSeedConfig(themeRoot: string): SeedConfig;
17
+ /**
18
+ * Get store name from seed.project.json or seed.config.js
19
+ *
20
+ * @param {string} themeRoot - the path to theme root dir
21
+ * @param {string} [store] - optional store name, defaults to "main"
22
+ * @returns {string | undefined} - store domain or undefined if not found
23
+ */
24
+ export declare function getStoreName(themeRoot: string, store?: string): string | undefined;
25
+ /**
26
+ * Get store password from seed.project.json
27
+ *
28
+ * @param {string} themeRoot - the path to theme root dir
29
+ * @param {string} [store] - optional store name, defaults to "main"
30
+ * @returns {string | undefined} - store password or undefined if not found
31
+ */
32
+ export declare function getStorePassword(themeRoot: string, store?: string): string | undefined;
33
+ /**
34
+ * Wrappers for Shopify CLI commands
35
+ *
36
+ * @summary a set of utility functions used to wrap shopify's CLI
37
+ * @namespace seed-cli.shopifyCLI
38
+ * @memberof seed-cli
39
+ */
40
+ export declare const shopifyCLI: ShopifyCLI;
41
+ /**
42
+ * Get theme ID from seed.config.js
43
+ *
44
+ * @param {string} themeRoot - the path to theme root dir
45
+ * @param {string} environment - theme name/environment
46
+ * @param {string} [store] - optional store name
47
+ * @returns {string} themeID
48
+ */
49
+ export declare function getThemeID(themeRoot: string, environment: string, store?: string): string | undefined;
50
+ /**
51
+ * Get dev theme ID from seed.config.js
52
+ *
53
+ * @param {string} themeRoot - the path to theme root dir
54
+ * @returns {string} - development store theme ID
55
+ */
56
+ export declare function getDevThemeID(themeRoot: string): string | undefined;
57
+ /**
58
+ * Given a string, finds the first themeID and returns it, if no themeID found
59
+ * returns false.
60
+ *
61
+ * @param {string} string - string to extract theme id from
62
+ * @return {string|boolean} - themeID or false if not found
63
+ */
64
+ export declare function extractThemeId(string: string): string | false;
65
+ /**
66
+ * Logs out to terminal the output of a piped child process
67
+ *
68
+ * @param {child_process} serveProcess shopify cli serve spawned child process
69
+ */
70
+ export declare function logChildProcessOutput(process: ChildProcess): void;
71
+ /**
72
+ * Writes the development theme ID as a key to seed config file
73
+ *
74
+ * @param {string} themeID - development theme ID
75
+ */
76
+ export declare function setDevThemeID(themeID: string): void;
77
+ /**
78
+ * Logs into seed config shopify store while logging useful messages
79
+ * and handling errors.
80
+ *
81
+ * @param {string} [store] - optional store name, defaults to "main"
82
+ * @returns {boolean} whether login was successful or not
83
+ */
84
+ export declare function login(store?: string): boolean;
85
+ /**
86
+ * Outputs error message if there's no store field in seed config
87
+ *
88
+ * @param {string} [store] - optional store name that was not found
89
+ */
90
+ export declare function storeErrorMessage(store?: string): void;
package/lib/utils.js CHANGED
@@ -1,10 +1,13 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.shopifyCLI = void 0;
7
+ exports.getProjectConfig = getProjectConfig;
6
8
  exports.getSeedConfig = getSeedConfig;
7
9
  exports.getStoreName = getStoreName;
10
+ exports.getStorePassword = getStorePassword;
8
11
  exports.getThemeID = getThemeID;
9
12
  exports.getDevThemeID = getDevThemeID;
10
13
  exports.extractThemeId = extractThemeId;
@@ -12,159 +15,174 @@ exports.logChildProcessOutput = logChildProcessOutput;
12
15
  exports.setDevThemeID = setDevThemeID;
13
16
  exports.login = login;
14
17
  exports.storeErrorMessage = storeErrorMessage;
15
- exports.shopifyCLI = void 0;
16
-
17
- var _chalk = require("chalk");
18
-
19
- var _figures = _interopRequireDefault(require("figures"));
20
-
21
- var _crossSpawn = _interopRequireDefault(require("cross-spawn"));
22
-
23
- var _path = require("path");
24
-
25
- var _fs = require("fs");
26
-
27
- var _config = _interopRequireDefault(require("./config"));
28
-
29
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
30
-
31
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
32
-
33
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
34
-
35
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
36
-
18
+ const chalk_1 = require("chalk");
19
+ const figures_1 = __importDefault(require("figures"));
20
+ const cross_spawn_1 = __importDefault(require("cross-spawn"));
21
+ const path_1 = require("path");
22
+ const fs_1 = require("fs");
23
+ const config_1 = __importDefault(require("./config"));
37
24
  /**
38
- * Wrappers for Shopify CLI commands
25
+ * Get seed.project.json from project root dir
39
26
  *
40
- * @summary a set of utility functions used to wrap shopify's CLI
41
- * @namespace seed-cli.shopifyCLI
42
- * @memberof seed-cli
27
+ * @param {string} themeRoot - the path to theme root dir
28
+ * @returns {SeedProjectConfig | null} - project config object or null if not found
43
29
  */
44
- var shopifyCLI = {
45
- /**
46
- * shopify login
47
- *
48
- * @memberof seed-cli.shopifyCLI
49
- * @param {string} store - store's myshopify domain name
50
- * @returns {object} - spawnSync object or, node's <ChildProcess> object if async
51
- */
52
- login: function login(store) {
53
- var args = ["switch", "--store", store];
54
- var options = {
55
- env: process.env,
56
- stdio: "inherit",
57
- shell: true
58
- };
59
- return _crossSpawn["default"].sync("shopify", args, options);
60
- },
61
-
62
- /**
63
- * shopify theme serve
64
- *
65
- * @memberof seed-cli.shopifyCLI
66
- * @param {object} options - node spawn options
67
- * @returns {object} - node's ChildProcess
68
- */
69
- serve: function serve(store) {
70
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
71
- return (0, _crossSpawn["default"])("shopify theme", ["dev", "--store", store, "--path", "dist"], _objectSpread({
72
- env: process.env,
73
- stdio: "inherit",
74
- shell: true
75
- }, options));
76
- },
77
-
78
- /**
79
- * shopify theme push
80
- *
81
- * @memberof seed-cli.shopifyCLI
82
- * @param {string} themeId - shopify theme id to pull from
83
- * @param {string} dir - directory to pull into
84
- * @param {boolean} [nodelete = true] - run command with --no-delete flag
85
- * @returns {object} - node's ChildProcess
86
- */
87
- pull: function pull(store) {
88
- var themeId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
89
- var dir = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "./src";
90
- var nodelete = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
91
- var args = ["pull", "--store", store];
92
- if (themeId) args = args.concat(["--theme", themeId, "--path", dir]);
93
- if (nodelete) args.push("--nodelete");
94
- return (0, _crossSpawn["default"])("shopify theme", args, {
95
- env: process.env,
96
- stdio: "inherit",
97
- shell: true
98
- });
99
- },
100
-
101
- /**
102
- * shopify theme push
103
- *
104
- * @memberof seed-cli.shopifyCLI
105
- * @param {string} themeId - shopify theme id to push into
106
- * @param {boolean} [nodelete = true] - run command with --no-delete flag
107
- * @returns {ChildProcess} - node's ChildProcess
108
- */
109
- push: function push(store) {
110
- var themeId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
111
- var nodelete = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
112
- var args = ["push", "--store", store, "--path", "dist"];
113
- if (themeId) args = args.concat(["--theme", themeId]);
114
- if (nodelete) args.push("--nodelete");
115
- return (0, _crossSpawn["default"])("shopify theme", args, {
116
- env: process.env,
117
- stdio: "inherit",
118
- shell: true
119
- });
120
- },
121
-
122
- /**
123
- * shopify theme package
124
- *
125
- * @memberof seed-cli.shopifyCLI
126
- * @returns {ChildProcess}
127
- */
128
- "package": function _package() {
129
- return (0, _crossSpawn["default"])("shopify theme", ["package", "--path", "dist"], {
130
- env: process.env,
131
- stdio: "inherit",
132
- shell: true
133
- });
134
- }
135
- };
30
+ function getProjectConfig(themeRoot) {
31
+ console.log(require((0, path_1.join)(themeRoot, "seed.project.json")));
32
+ return require((0, path_1.join)(themeRoot, "seed.project.json"));
33
+ }
136
34
  /**
137
35
  * Get seed.config.js from project root dir
138
36
  *
139
37
  * @param {string} themeRoot - the path to theme root dir
38
+ * @returns {SeedConfig} - seed config object
140
39
  */
141
-
142
- exports.shopifyCLI = shopifyCLI;
143
-
144
40
  function getSeedConfig(themeRoot) {
145
- return require((0, _path.join)(themeRoot, "seed.config.js"));
41
+ return require((0, path_1.join)(themeRoot, "seed.config.js"));
146
42
  }
147
43
  /**
148
- * Get store name from seed.config.js
44
+ * Get store name from seed.project.json or seed.config.js
149
45
  *
150
46
  * @param {string} themeRoot - the path to theme root dir
47
+ * @param {string} [store] - optional store name, defaults to "main"
48
+ * @returns {string | undefined} - store domain or undefined if not found
151
49
  */
152
-
153
-
154
50
  function getStoreName(themeRoot, store) {
155
- return store ? getSeedConfig(themeRoot).stores[store].domain : getSeedConfig(themeRoot).store;
51
+ // Default to "main" if no store specified
52
+ const storeKey = store || "main";
53
+ // Try to get from project config first
54
+ const projectConfig = getProjectConfig(themeRoot);
55
+ if (projectConfig?.stores?.[storeKey]) {
56
+ return projectConfig.stores[storeKey].domain;
57
+ }
58
+ // Fallback to legacy config
59
+ const legacyConfig = getSeedConfig(themeRoot);
60
+ return store && legacyConfig.stores?.[store]
61
+ ? legacyConfig.stores[store].domain
62
+ : legacyConfig.store;
63
+ }
64
+ /**
65
+ * Get store password from seed.project.json
66
+ *
67
+ * @param {string} themeRoot - the path to theme root dir
68
+ * @param {string} [store] - optional store name, defaults to "main"
69
+ * @returns {string | undefined} - store password or undefined if not found
70
+ */
71
+ function getStorePassword(themeRoot, store) {
72
+ const storeKey = store || "main";
73
+ const projectConfig = getProjectConfig(themeRoot);
74
+ return projectConfig?.stores?.[storeKey]?.password;
156
75
  }
76
+ /**
77
+ * Wrappers for Shopify CLI commands
78
+ *
79
+ * @summary a set of utility functions used to wrap shopify's CLI
80
+ * @namespace seed-cli.shopifyCLI
81
+ * @memberof seed-cli
82
+ */
83
+ exports.shopifyCLI = {
84
+ /**
85
+ * shopify login
86
+ *
87
+ * @memberof seed-cli.shopifyCLI
88
+ * @param {string} store - store's myshopify domain name
89
+ * @returns {object} - spawnSync object or, node's <ChildProcess> object if async
90
+ */
91
+ login: (store) => {
92
+ const args = ["switch", "--store", store];
93
+ const options = {
94
+ env: process.env,
95
+ stdio: "inherit",
96
+ shell: true,
97
+ };
98
+ return cross_spawn_1.default.sync("shopify", args, options);
99
+ },
100
+ /**
101
+ * shopify theme serve
102
+ *
103
+ * @memberof seed-cli.shopifyCLI
104
+ * @param {string} store - store's myshopify domain name
105
+ * @param {object} options - node spawn options
106
+ * @returns {object} - node's ChildProcess
107
+ */
108
+ serve: (store, options = {}) => {
109
+ return (0, cross_spawn_1.default)("shopify theme", ["dev", "--store", store, "--path", "dist"], {
110
+ env: process.env,
111
+ stdio: "inherit",
112
+ shell: true,
113
+ ...options,
114
+ });
115
+ },
116
+ /**
117
+ * shopify theme pull
118
+ *
119
+ * @memberof seed-cli.shopifyCLI
120
+ * @param {string} store - store's myshopify domain name
121
+ * @param {string} themeId - shopify theme id to pull from
122
+ * @param {string} dir - directory to pull into
123
+ * @param {boolean} [nodelete = true] - run command with --no-delete flag
124
+ * @returns {object} - node's ChildProcess
125
+ */
126
+ pull: (store, themeId, dir = "./src", nodelete = true) => {
127
+ let args = ["pull", "--store", store];
128
+ if (themeId)
129
+ args = args.concat(["--theme", themeId, "--path", dir]);
130
+ if (nodelete)
131
+ args.push("--nodelete");
132
+ return (0, cross_spawn_1.default)("shopify theme", args, {
133
+ env: process.env,
134
+ stdio: "inherit",
135
+ shell: true,
136
+ });
137
+ },
138
+ /**
139
+ * shopify theme push
140
+ *
141
+ * @memberof seed-cli.shopifyCLI
142
+ * @param {string} store - store's myshopify domain name
143
+ * @param {string} themeId - shopify theme id to push into
144
+ * @param {boolean} [nodelete = true] - run command with --no-delete flag
145
+ * @returns {ChildProcess} - node's ChildProcess
146
+ */
147
+ push: (store, themeId, nodelete = true) => {
148
+ let args = ["push", "--store", store, "--path", "dist"];
149
+ if (themeId)
150
+ args = args.concat(["--theme", themeId]);
151
+ if (nodelete)
152
+ args.push("--nodelete");
153
+ return (0, cross_spawn_1.default)("shopify theme", args, {
154
+ env: process.env,
155
+ stdio: "inherit",
156
+ shell: true,
157
+ });
158
+ },
159
+ /**
160
+ * shopify theme package
161
+ *
162
+ * @memberof seed-cli.shopifyCLI
163
+ * @returns {ChildProcess} - node's ChildProcess
164
+ */
165
+ package: () => {
166
+ return (0, cross_spawn_1.default)("shopify theme", ["package", "--path", "dist"], {
167
+ env: process.env,
168
+ stdio: "inherit",
169
+ shell: true,
170
+ });
171
+ },
172
+ };
157
173
  /**
158
174
  * Get theme ID from seed.config.js
159
175
  *
160
176
  * @param {string} themeRoot - the path to theme root dir
161
177
  * @param {string} environment - theme name/environment
178
+ * @param {string} [store] - optional store name
162
179
  * @returns {string} themeID
163
180
  */
164
-
165
-
166
181
  function getThemeID(themeRoot, environment, store) {
167
- return store ? getSeedConfig(themeRoot).stores[store].themes[environment] : getSeedConfig(themeRoot).themes[environment];
182
+ const config = getSeedConfig(themeRoot);
183
+ return store && config.stores?.[store]
184
+ ? config.stores[store].themes[environment]
185
+ : config.themes?.[environment];
168
186
  }
169
187
  /**
170
188
  * Get dev theme ID from seed.config.js
@@ -172,10 +190,8 @@ function getThemeID(themeRoot, environment, store) {
172
190
  * @param {string} themeRoot - the path to theme root dir
173
191
  * @returns {string} - development store theme ID
174
192
  */
175
-
176
-
177
193
  function getDevThemeID(themeRoot) {
178
- return getSeedConfig(themeRoot).__developmentThemeId;
194
+ return getSeedConfig(themeRoot).__developmentThemeId;
179
195
  }
180
196
  /**
181
197
  * Given a string, finds the first themeID and returns it, if no themeID found
@@ -184,82 +200,71 @@ function getDevThemeID(themeRoot) {
184
200
  * @param {string} string - string to extract theme id from
185
201
  * @return {string|boolean} - themeID or false if not found
186
202
  */
187
-
188
-
189
203
  function extractThemeId(string) {
190
- var regex = /\d{12}/;
191
- var match = string.match(regex);
192
- return match && match.length ? match[0] : false;
204
+ const regex = /\d{12}/;
205
+ const match = string.match(regex);
206
+ return match && match.length ? match[0] : false;
193
207
  }
194
208
  /**
195
209
  * Logs out to terminal the output of a piped child process
196
210
  *
197
211
  * @param {child_process} serveProcess shopify cli serve spawned child process
198
212
  */
199
-
200
-
201
213
  function logChildProcessOutput(process) {
202
- process.stdout.on("data", function (data) {
203
- console.log(data);
204
- });
214
+ process.stdout?.on("data", (data) => {
215
+ console.log(data.toString());
216
+ });
205
217
  }
206
218
  /**
207
219
  * Writes the development theme ID as a key to seed config file
208
220
  *
209
221
  * @param {string} themeID - development theme ID
210
222
  */
211
-
212
-
213
223
  function setDevThemeID(themeID) {
214
- var data = (0, _fs.readFileSync)(_config["default"].seedConfig, {
215
- encoding: "utf8"
216
- });
217
- data = data.split(_config["default"].seedConfigDelimiter);
218
- data[1] = "\n __developmentThemeId: '".concat(themeID, "'") + "\n};";
219
- (0, _fs.writeFileSync)(_config["default"].seedConfig, data.join(_config["default"].seedConfigDelimiter));
224
+ const data = (0, fs_1.readFileSync)(config_1.default.seedConfig, { encoding: "utf8" }).split(config_1.default.seedConfigDelimiter);
225
+ data[1] = `\n __developmentThemeId: '${themeID}'` + "\n};";
226
+ (0, fs_1.writeFileSync)(config_1.default.seedConfig, data.join(config_1.default.seedConfigDelimiter));
220
227
  }
221
228
  /**
222
229
  * Logs into seed config shopify store while logging useful messages
223
230
  * and handling errors.
224
- * @returns {boolean} whether login was succesful or not
231
+ *
232
+ * @param {string} [store] - optional store name, defaults to "main"
233
+ * @returns {boolean} whether login was successful or not
225
234
  */
226
-
227
-
228
235
  function login(store) {
229
- var domain = getStoreName(_config["default"].themeRoot, store);
230
-
231
- if (!domain) {
232
- storeErrorMessage(store);
233
- return false;
234
- }
235
-
236
- console.log("Logging into ".concat((0, _chalk.yellow)(domain), " with Shopify CLI..."));
237
- var loginProcess = shopifyCLI.login(domain);
238
-
239
- if (loginProcess.error) {
240
- console.log("");
241
- console.log((0, _chalk.red)(" ".concat(_figures["default"].cross, " Failed logging into ").concat(domain, ", are you sure you're using the correct account?")));
242
- console.log("");
243
- return false;
244
- }
245
-
246
- return true;
236
+ const domain = getStoreName(config_1.default.themeRoot, store);
237
+ if (!domain) {
238
+ storeErrorMessage(store);
239
+ return false;
240
+ }
241
+ console.log(`Logging into ${(0, chalk_1.yellow)(domain)} with Shopify CLI...`);
242
+ const loginProcess = exports.shopifyCLI.login(domain);
243
+ if (loginProcess.error) {
244
+ console.log("");
245
+ console.log((0, chalk_1.red)(` ${figures_1.default.cross} Failed logging into ${domain}, are you sure you're using the correct account?`));
246
+ console.log("");
247
+ return false;
248
+ }
249
+ return true;
247
250
  }
248
251
  /**
249
252
  * Outputs error message if there's no store field in seed config
253
+ *
254
+ * @param {string} [store] - optional store name that was not found
250
255
  */
251
-
252
-
253
256
  function storeErrorMessage(store) {
254
- if (store) {
255
- console.log("");
256
- console.log((0, _chalk.red)(" The store ".concat(store, " does not exist in seed.config.js")));
257
- console.log(" Check to see if you spelled the store correctly on seed config and when running the command.");
258
- console.log("");
259
- } else {
260
- console.log("");
261
- console.log((0, _chalk.red)(" ".concat(_figures["default"].cross, " no store field in seed.config.js. Did you forget the --store <store> argument?")));
262
- console.log(" If this is a multi-store project, please specify which store to watch, else add 'store: <store.myshopify.com>' to your project seed.config.js");
263
- console.log("");
264
- }
265
- }
257
+ if (store) {
258
+ console.log("");
259
+ console.log((0, chalk_1.red)(` The store ${store} does not exist in seed.project.json or seed.config.js`));
260
+ console.log(" Check to see if you spelled the store correctly in your config files and when running the command.");
261
+ console.log("");
262
+ }
263
+ else {
264
+ console.log("");
265
+ console.log((0, chalk_1.red)(` ${figures_1.default.cross} No 'main' store found in seed.project.json or seed.config.js`));
266
+ console.log(" Add a 'main' store to your seed.project.json or specify which store to use with --store <store>");
267
+ console.log("");
268
+ }
269
+ }
270
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;;;;AAeA,4CAIC;AAQD,sCAEC;AASD,oCAkBC;AASD,4CAOC;AAiHD,gCASC;AAQD,sCAEC;AASD,wCAIC;AAOD,sDAIC;AAOD,sCAMC;AASD,sBAsBC;AAOD,8CAwBC;AA/SD,iCAAoC;AACpC,sDAA8B;AAC9B,8DAAgC;AAEhC,+BAA4B;AAC5B,2BAA6D;AAC7D,sDAA8B;AAG9B;;;;;GA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