shopify-accelerate-app 1.0.3 → 1.0.4

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/@types/shopify.ts CHANGED
@@ -614,6 +614,7 @@ export type ShopifyAppBlock<T = never> = {
614
614
  class?: string;
615
615
  default?: ShopifyAppBlockDefault<T>;
616
616
  javascript?: string;
617
+ disabled?: boolean;
617
618
  locales?: {
618
619
  [T: string]: {
619
620
  [V: string]: string;
package/@types/types.d.ts CHANGED
@@ -2,13 +2,10 @@ declare global {
2
2
  namespace NodeJS {
3
3
  // eslint-disable-next-line @typescript-eslint/no-empty-interface
4
4
  interface ProcessEnv {
5
- SHOPIFY_ACCELERATE_DELETE_EXTERNAL_LAYOUTS?: string;
6
- SHOPIFY_ACCELERATE_DELETE_EXTERNAL_SECTIONS?: string;
7
5
  SHOPIFY_ACCELERATE_DELETE_EXTERNAL_SNIPPETS?: string;
8
6
  SHOPIFY_ACCELERATE_DELETE_EXTERNAL_BLOCKS?: string;
9
7
  SHOPIFY_ACCELERATE_DELETE_EXTERNAL_ASSETS?: string;
10
8
  SHOPIFY_ACCELERATE_DISABLED_LOCALES?: string;
11
- SHOPIFY_ACCELERATE_DISABLE_THEME_BLOCKS?: string;
12
9
  }
13
10
  interface Process {
14
11
  cwd?: () => string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shopify-accelerate-app",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "Shopify App development with full Typescript Support",
5
5
  "author": "Felix Tellmann",
6
6
  "license": "MIT",
@@ -1,26 +1,16 @@
1
1
  #!npx tsx
2
2
 
3
- import { require } from "./require";
4
3
  import fs from "fs";
5
4
  import path from "path";
5
+ import { buildAppExtension } from "./src/scaffold-theme/build-app-extension";
6
+ import { watchAppExtension } from "./src/watch-app-extension/watch-app-extension";
6
7
  import toml from "toml";
7
- import { PresetSchema, ShopifyBlock, ShopifySection, ShopifySettings } from "./@types/shopify";
8
+ import { ShopifyAppBlock } from "./@types/shopify";
9
+ import { require } from "./require";
8
10
  import { runEsbuild } from "./src/esbuild/esbuild";
9
- import { buildTheme } from "./src/scaffold-theme/build-theme";
10
- import { generateBaseTypes } from "./src/scaffold-theme/generate-base-types";
11
- import { generateBlocksTypes } from "./src/scaffold-theme/generate-blocks-types";
12
- import { generateConfigFiles } from "./src/scaffold-theme/generate-config-files";
13
- import { generateSectionsTypes } from "./src/scaffold-theme/generate-section-types";
14
- import { generateSettingTypes } from "./src/scaffold-theme/generate-setting-types";
15
- import { getSchemaSources, getSources } from "./src/scaffold-theme/parse-files";
16
- import { shopifyCliPull } from "./src/shopify-cli/pull";
17
11
  import { runTailwindCSSWatcher } from "./src/tailwind/tailwind-watch";
18
- import { capitalize } from "./src/utils/capitalize";
19
- import { readFile, writeCompareFile, writeOnlyNew } from "./src/utils/fs";
12
+ import { readFile, writeOnlyNew } from "./src/utils/fs";
20
13
  import { JSONParse } from "./src/utils/json";
21
- import { validateCliOptions } from "./src/validate-cli-options";
22
- import { watchHeadless } from "./src/watch-headless/watch-headless";
23
- import { watchTheme } from "./src/watch-theme/watch-theme";
24
14
 
25
15
  const { Command } = require("commander");
26
16
  const program = new Command();
@@ -53,8 +43,6 @@ const shopify_toml = tomlFile
53
43
  mode: "development" | "production";
54
44
  ignore_blocks: string;
55
45
  ignore_snippets: string;
56
- ignore_layouts: string;
57
- ignore_sections: string;
58
46
  ignore_assets: string;
59
47
  };
60
48
  };
@@ -67,74 +55,37 @@ export type GlobalsState = {
67
55
  package_templates: string;
68
56
  package_types: string;
69
57
  project_root: ReturnType<typeof process.cwd>;
70
- all_presets: boolean;
71
- mode: "development" | "production";
72
- theme_id: number;
73
- theme_path: string;
74
- store: string;
75
- environment: string;
76
- environments: (typeof shopify_toml)["environments"];
58
+ extension_path: string;
59
+ theme_output_path: string;
77
60
  ignore_blocks: string[];
78
61
  ignore_snippets: string[];
79
- ignore_layouts: string[];
80
- ignore_sections: string[];
81
62
  ignore_assets: string[];
82
- delete_external_layouts?: boolean;
83
- delete_external_sections?: boolean;
84
63
  delete_external_snippets?: boolean;
85
64
  delete_external_blocks?: boolean;
86
65
  delete_external_assets?: boolean;
87
66
  disabled_locales?: boolean;
88
- disabled_theme_blocks?: boolean;
89
67
  sources: {
90
68
  snippets: string[];
91
- layouts: string[];
92
- sectionsLiquid: string[];
93
- sectionsSchemaFiles: string[];
94
- sectionsJs: string[];
95
- sectionPresetSchemaFiles: string[];
96
- sectionPresetSchemas: { [T: string]: PresetSchema & { path: string; folder: string } };
97
69
  blocksLiquid: string[];
98
70
  blocksSchemaFiles: string[];
99
71
  blocksJs: string[];
100
- blockSchemas: { [T: string]: ShopifyBlock & { path: string; folder: string } };
72
+ blockSchemas: { [T: string]: ShopifyAppBlock & { path: string; folder: string } };
101
73
  assets: string[];
102
- giftCards: string[];
103
- configs: string[];
104
- sectionGroups: string[];
105
- templates: string[];
106
- customerTemplates: string[];
107
- settingsFile: string[];
108
74
  locale_duplicates: { [T: string]: string[] };
109
- settingsSchema: ShopifySettings;
110
- sectionSchemas: { [T: string]: ShopifySection & { path: string; folder: string } };
111
75
  };
112
76
  targets: {
113
77
  assets: string[];
114
78
  dynamicJs: string[];
115
79
  blocks: string[];
116
- layout: string[];
117
80
  locales: string[];
118
81
  snippets: string[];
119
- sections: string[];
120
- settings: string;
121
- giftCards: string[];
122
- sectionGroups: string[];
123
- configs: string[];
124
- templates: string[];
125
- customerTemplates: string[];
126
82
  };
127
83
  folders: {
128
84
  types: string;
129
85
  utils: string;
130
- sections: string;
131
- presets: string;
132
- layout: string;
133
86
  blocks: string;
134
87
  snippets: string;
135
- templates: string;
136
88
  assets: string;
137
- config: string;
138
89
  };
139
90
  };
140
91
 
@@ -147,66 +98,33 @@ export const config: GlobalsState = {
147
98
  shopify_toml?.environments?.["development"]?.ignore_snippets
148
99
  ?.split(",")
149
100
  .map((str) => str.trim()) ?? [],
150
- ignore_layouts:
151
- shopify_toml?.environments?.["development"]?.ignore_layouts
152
- ?.split(",")
153
- .map((str) => str.trim()) ?? [],
154
- ignore_sections:
155
- shopify_toml?.environments?.["development"]?.ignore_sections
156
- ?.split(",")
157
- .map((str) => str.trim()) ?? [],
158
101
  ignore_assets:
159
102
  shopify_toml?.environments?.["development"]?.ignore_assets
160
103
  ?.split(",")
161
104
  .map((str) => str.trim()) ?? [],
162
- delete_external_layouts: process.env.SHOPIFY_ACCELERATE_DELETE_EXTERNAL_LAYOUTS === "true",
163
- delete_external_sections: process.env.SHOPIFY_ACCELERATE_DELETE_EXTERNAL_SECTIONS === "true",
164
105
  delete_external_snippets: process.env.SHOPIFY_ACCELERATE_DELETE_EXTERNAL_SNIPPETS === "true",
165
106
  delete_external_blocks: process.env.SHOPIFY_ACCELERATE_DELETE_EXTERNAL_BLOCKS === "true",
166
107
  delete_external_assets: process.env.SHOPIFY_ACCELERATE_DELETE_EXTERNAL_ASSETS === "true",
167
108
  disabled_locales: process.env.SHOPIFY_ACCELERATE_DISABLED_LOCALES === "true",
168
- disabled_theme_blocks: process.env.SHOPIFY_ACCELERATE_DISABLE_THEME_BLOCKS === "true",
169
109
  package_root: path.resolve(__dirname),
170
110
  project_root: root_dir,
171
111
  package_templates: path.join(path.resolve(__dirname), "./src/templates"),
172
112
  package_types: path.join(path.resolve(__dirname), "./@types"),
173
113
  sources: {
174
114
  snippets: [],
175
- layouts: [],
176
- sectionPresetSchemaFiles: [],
177
- sectionPresetSchemas: {},
178
- sectionsLiquid: [],
179
- sectionsSchemaFiles: [],
180
- sectionsJs: [],
181
115
  blocksLiquid: [],
182
116
  blocksSchemaFiles: [],
183
117
  blocksJs: [],
184
118
  assets: [],
185
- giftCards: [],
186
- configs: [],
187
- sectionGroups: [],
188
- templates: [],
189
- customerTemplates: [],
190
- settingsFile: [],
191
119
  locale_duplicates: {},
192
- settingsSchema: null,
193
- sectionSchemas: {},
194
120
  blockSchemas: {},
195
121
  },
196
122
  targets: {
197
123
  assets: [],
198
124
  dynamicJs: [],
199
125
  blocks: [],
200
- layout: [],
201
126
  locales: [],
202
127
  snippets: [],
203
- sections: [],
204
- settings: null,
205
- giftCards: [],
206
- sectionGroups: [],
207
- configs: [],
208
- templates: [],
209
- customerTemplates: [],
210
128
  },
211
129
  folders: {
212
130
  types: process.env.SHOPIFY_ACCELERATE_TYPES
@@ -215,51 +133,26 @@ export const config: GlobalsState = {
215
133
  utils: process.env.SHOPIFY_ACCELERATE_UTILS
216
134
  ? path.join(process.cwd(), process.env.SHOPIFY_ACCELERATE_UTILS)
217
135
  : path.join(root_dir, "@utils"),
218
- sections: process.env.SHOPIFY_ACCELERATE_SECTIONS
219
- ? path.join(process.cwd(), process.env.SHOPIFY_ACCELERATE_SECTIONS)
220
- : path.join(root_dir, "sections"),
221
- presets: process.env.SHOPIFY_ACCELERATE_PRESETS
222
- ? path.join(process.cwd(), process.env.SHOPIFY_ACCELERATE_PRESETS)
223
- : path.join(root_dir, "presets"),
224
- layout: process.env.SHOPIFY_ACCELERATE_LAYOUT
225
- ? path.join(process.cwd(), process.env.SHOPIFY_ACCELERATE_LAYOUT)
226
- : path.join(root_dir, "layout"),
227
136
  blocks: process.env.SHOPIFY_ACCELERATE_BLOCKS
228
137
  ? path.join(process.cwd(), process.env.SHOPIFY_ACCELERATE_BLOCKS)
229
138
  : path.join(root_dir, "blocks"),
230
139
  snippets: process.env.SHOPIFY_ACCELERATE_SNIPPETS
231
140
  ? path.join(process.cwd(), process.env.SHOPIFY_ACCELERATE_SNIPPETS)
232
141
  : path.join(root_dir, "snippets"),
233
- templates: process.env.SHOPIFY_ACCELERATE_TEMPLATES
234
- ? path.join(process.cwd(), process.env.SHOPIFY_ACCELERATE_TEMPLATES)
235
- : path.join(root_dir, "templates"),
236
142
  assets: process.env.SHOPIFY_ACCELERATE_ASSETS
237
143
  ? path.join(process.cwd(), process.env.SHOPIFY_ACCELERATE_ASSETS)
238
144
  : path.join(root_dir, "assets"),
239
- config: process.env.SHOPIFY_ACCELERATE_CONFIG
240
- ? path.join(process.cwd(), process.env.SHOPIFY_ACCELERATE_CONFIG)
241
- : path.join(root_dir, "config"),
242
145
  },
243
- environments: Object.entries(shopify_toml?.environments ?? {})?.reduce((acc, [key, val]) => {
244
- acc[key] = {
245
- ...val,
246
- store: val?.store?.replace(/\.myshopify\.com/gi, ""),
247
- };
248
- return acc;
249
- }, {}),
250
- environment: shopify_toml?.environments?.["development"]
251
- ? "development"
252
- : Object.keys(shopify_toml?.environments)?.[0] ?? "development",
253
- theme_id: +shopify_toml?.environments?.["development"]?.theme,
254
- theme_path: shopify_toml?.environments?.["development"]?.path ?? "./theme/development",
255
- store: shopify_toml?.environments?.["development"]?.store,
256
- all_presets: shopify_toml?.environments?.["development"]?.all_presets,
257
- mode: shopify_toml?.environments?.["development"]?.mode ?? "production",
146
+ extension_path: process.env.SHOPIFY_ACCELERATE_EXTENSION_PATH ?? "./extensions/theme-extension",
147
+ theme_output_path: process.env.SHOPIFY_ACCELERATE_THEME_OUTPUT_PATH ?? "/themes/development",
258
148
  };
259
149
 
260
- program.name("shopify-accelerate-app").description("CLI for Accelerated Shopify Theme development");
150
+ program
151
+ .name("shopify-accelerate-app")
152
+ .description("CLI for Accelerated App Theme Extensions development");
261
153
  /*.version(require(path.join("./", "package.json")).version);*/
262
154
 
155
+ /*
263
156
  program
264
157
  .command("init")
265
158
  .description("Initialize a local development environment from an existing Shopify theme")
@@ -279,10 +172,11 @@ program
279
172
  generateConfigFiles();
280
173
  await shopifyCliPull();
281
174
  });
175
+ */
282
176
 
283
177
  program
284
178
  .command("dev")
285
- .description("Shopify Theme Development")
179
+ .description("Shopify App Theme Extension Dev")
286
180
  // .argument("<string>", "string to split")
287
181
  .option("-e, --environment <environment_name>", "Development environment name", "development")
288
182
  .option(
@@ -294,13 +188,17 @@ program
294
188
  "Shopify store id. I.e. `https://admin.shopify.com/store/<store_id>/themes/<theme_id>/editor`"
295
189
  )
296
190
  .action(async (options) => {
297
- await validateCliOptions(options);
298
- buildTheme();
299
- generateConfigFiles();
191
+ writeOnlyNew(
192
+ path.join(process.cwd(), ".env"),
193
+ readFile(path.join(config.package_templates, "/.env.template"))
194
+ );
195
+
196
+ buildAppExtension();
300
197
  runEsbuild();
301
198
  runTailwindCSSWatcher();
302
- watchTheme();
199
+ watchAppExtension();
303
200
  });
201
+ /*
304
202
 
305
203
  program
306
204
  .command("tailwind")
@@ -366,7 +264,7 @@ export const ${capitalize(key)} = ({ id, type, settings, blocks, disabled }: ${c
366
264
  key
367
265
  )}Section) => {
368
266
  if (disabled) return null
369
-
267
+
370
268
  return <>${capitalize(key)}</>;
371
269
  };
372
270
  `
@@ -389,5 +287,6 @@ export const ${capitalize(key)} = ({ id, type, settings, blocks, disabled }: ${c
389
287
 
390
288
  watchHeadless();
391
289
  });
290
+ */
392
291
 
393
292
  program.parse(process.argv);
@@ -10,104 +10,6 @@ const { build } = require("esbuild");
10
10
  const watch = require("node-watch");
11
11
  const fs = require("fs");
12
12
 
13
- const runEsBuild = () => {
14
- const entryPoints = [];
15
- if (fs.existsSync(path.join(root_dir, "assets", "theme.ts"))) {
16
- entryPoints.push(path.join(root_dir, "assets", "theme.ts"));
17
- }
18
-
19
- if (fs.existsSync(path.join(root_dir, "assets", "editor.ts"))) {
20
- entryPoints.push(path.join(root_dir, "assets", "editor.ts"));
21
- }
22
- if (!entryPoints.length) {
23
- console.log("No JS/TS entry files found.");
24
- return;
25
- }
26
- build({
27
- entryPoints: entryPoints,
28
- metafile: true,
29
- target: "es2020",
30
- // sourcemap: "external",
31
- treeShaking: true,
32
- bundle: true,
33
- // outfile: "./assets/theme.js",
34
- outdir: path.join(root_dir, "assets"),
35
- minify: false,
36
- ignoreAnnotations: true,
37
- packages: "external",
38
-
39
- format: "esm",
40
- legalComments: "none",
41
- keepNames: true,
42
- plugins: [dtsPlugin({})],
43
-
44
- // splitting: true,
45
- })
46
- .then((e) => {
47
- console.log("theme.js - bundled");
48
- const content = fs.readFileSync(path.join(root_dir, "assets", "editor.js"), {
49
- encoding: "utf-8",
50
- });
51
- fs.writeFileSync(
52
- path.join(root_dir, "assets", "editor.js"),
53
- `${content}\n // random_comment `
54
- );
55
- const content2 = fs.readFileSync(path.join(root_dir, "assets", "theme.js"), {
56
- encoding: "utf-8",
57
- });
58
- fs.writeFileSync(
59
- path.join(root_dir, "assets", "theme.js"),
60
- `${content2}\n // random_comment `
61
- );
62
- })
63
- .catch((error) => {
64
- console.error(error);
65
- // eslint-disable-next-line no-process-exit
66
- });
67
- };
68
-
69
- const runSectionJsEsbuild = (entryFile) => {
70
- build({
71
- entryPoints: [entryFile],
72
- metafile: true,
73
- target: "es2020",
74
- // sourcemap: "external",
75
- treeShaking: true,
76
- // bundle: true,
77
- outfile: path.join(
78
- root_dir,
79
- config.theme_path,
80
- "assets",
81
- `__section--${entryFile
82
- .split(/[\\/]/gi)
83
- .at(-1)
84
- .replace(/\.(ts)x?$/gi, ".js")}`
85
- ),
86
- // outdir: path.join(root_dir, config.theme_path, "assets"),
87
- minify: false,
88
- ignoreAnnotations: true,
89
- packages: "external",
90
- format: "esm",
91
- legalComments: "none",
92
- keepNames: true,
93
- plugins: [dtsPlugin({})],
94
-
95
- // splitting: true,
96
- })
97
- .then((e) => {
98
- console.log(
99
- `__section--${entryFile
100
- .split(/[\\/]/gi)
101
- .at(-1)
102
- .replace(/\.(ts)x?$/gi, ".js")}- bundled`
103
- );
104
- })
105
- .catch((error) => {
106
- console.error(error);
107
- // eslint-disable-next-line no-process-exit
108
- });
109
- };
110
-
111
13
  const runBlockJsEsbuild = (entryFile) => {
112
14
  build({
113
15
  entryPoints: [entryFile],
@@ -118,14 +20,14 @@ const runBlockJsEsbuild = (entryFile) => {
118
20
  // bundle: true,
119
21
  outfile: path.join(
120
22
  root_dir,
121
- config.theme_path,
23
+ config.extension_path,
122
24
  "assets",
123
25
  `__block--${entryFile
124
26
  .split(/[\\/]/gi)
125
27
  .at(-1)
126
28
  .replace(/\.(ts)x?$/gi, ".js")}`
127
29
  ),
128
- // outdir: path.join(root_dir, config.theme_path, "assets"),
30
+ // outdir: path.join(root_dir, config.extension_path, "assets"),
129
31
  minify: false,
130
32
  ignoreAnnotations: true,
131
33
  packages: "external",
@@ -157,24 +59,6 @@ export const runEsbuild = () => {
157
59
  if (!name.match(/\.(ts)x?$/) || /schema\.ts$/gi.test(name)) return;
158
60
  running = true;
159
61
 
160
- if (isSectionTs(name)) {
161
- const filename = name.split(/[\\/]/gi).at(-1);
162
-
163
- const section = Object.values(config.sources.sectionSchemas).find((section) =>
164
- section.path.includes(name.replace(filename, ""))
165
- );
166
-
167
- if (section && !section.disabled) {
168
- try {
169
- runSectionJsEsbuild(name);
170
- } catch (err) {
171
- console.log(err);
172
- }
173
- }
174
- running = false;
175
- return;
176
- }
177
-
178
62
  if (isBlockTs(name)) {
179
63
  const filename = name.split(/[\\/]/gi).at(-1);
180
64
 
@@ -193,36 +77,9 @@ export const runEsbuild = () => {
193
77
  return;
194
78
  }
195
79
 
196
- try {
197
- runEsBuild();
198
- } catch (err) {
199
- console.log(err);
200
- }
201
80
  running = false;
202
81
  });
203
82
 
204
- config.sources.sectionsJs.forEach((name) => {
205
- running = true;
206
-
207
- if (isSectionTs(name)) {
208
- const filename = name.split(/[\\/]/gi).at(-1);
209
-
210
- const section = Object.values(config.sources.sectionSchemas).find((section) =>
211
- section.path.includes(name.replace(filename, ""))
212
- );
213
-
214
- if (section && !section.disabled) {
215
- try {
216
- runSectionJsEsbuild(name);
217
- } catch (err) {
218
- console.log(err);
219
- }
220
- }
221
- running = false;
222
- return;
223
- }
224
- });
225
-
226
83
  config.sources.blocksJs.forEach((name) => {
227
84
  running = true;
228
85
  if (isBlockTs(name)) {
@@ -243,5 +100,4 @@ export const runEsbuild = () => {
243
100
  return;
244
101
  }
245
102
  });
246
- runEsBuild();
247
103
  };
@@ -4,21 +4,17 @@ import { generateBlocksTypes } from "./generate-blocks-types";
4
4
  import { generateLiquidFiles } from "./generate-liquid-files";
5
5
  import { generateSchemaLocales } from "./generate-schema-locales";
6
6
  import { generateSchemaVariables } from "./generate-schema-variables";
7
- import { generateSectionsTypes } from "./generate-section-types";
8
- import { generateSettingTypes } from "./generate-setting-types";
9
7
  import { getSources, getTargets } from "./parse-files";
10
8
  import { parseLocales } from "./parse-locales";
11
9
 
12
- export const buildTheme = () => {
10
+ export const buildAppExtension = () => {
13
11
  generateBaseTypes();
14
12
  getSources();
15
13
  getTargets();
16
14
  parseLocales();
17
15
  generateSchemaVariables();
18
16
  generateSchemaLocales();
19
- generateSectionsTypes();
20
17
  generateBlocksTypes();
21
- generateSettingTypes();
22
18
  generateLiquidFiles();
23
19
  generateAssetFiles();
24
20
  };
@@ -5,11 +5,11 @@ import { config, root_dir } from "../../shopify-accelerate-app";
5
5
  import { deleteFile, writeCompareFile, writeOnlyNew } from "../utils/fs";
6
6
 
7
7
  export const generateAssetFiles = () => {
8
- const { theme_path, sources, targets, delete_external_assets, ignore_assets } = config;
8
+ const { extension_path, sources, targets, delete_external_assets, ignore_assets } = config;
9
9
 
10
10
  sources.assets.forEach((file) => {
11
11
  const fileName = file.split(/[\\/]/gi).at(-1);
12
- const targetPath = path.join(process.cwd(), theme_path, "assets", fileName);
12
+ const targetPath = path.join(process.cwd(), extension_path, "assets", fileName);
13
13
 
14
14
  const rawContent = fs.readFileSync(file, { encoding: "utf-8" });
15
15
 
@@ -8,16 +8,16 @@ export const generateBaseTypes = () => {
8
8
  path.join(folders.types, "shopify.ts"),
9
9
  readFile(path.join(package_types, "shopify.ts"))
10
10
  );
11
- writeOnlyNew(
11
+ /*writeOnlyNew(
12
12
  path.join(folders.types, "settings.ts"),
13
13
  readFile(path.join(package_types, "settings.ts"))
14
14
  );
15
15
  writeOnlyNew(
16
16
  path.join(folders.types, "sections.ts"),
17
17
  readFile(path.join(package_types, "sections.ts"))
18
- );
19
- writeOnlyNew(
18
+ );*/
19
+ /*writeOnlyNew(
20
20
  path.join(folders.types, "metafields.ts"),
21
21
  readFile(path.join(package_types, "metafields.ts"))
22
- );
22
+ );*/
23
23
  };