shopify-accelerate-app 1.3.0 → 1.3.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shopify-accelerate-app",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "description": "Shopify App development with full Typescript Support",
5
5
  "author": "Felix Tellmann",
6
6
  "license": "MIT",
package/require.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { createRequire } from "module";
2
-
3
- // export const require = createRequire(import.meta.url);
1
+ import { createRequire } from "module";
2
+
3
+ // export const require = createRequire(import.meta.url);
@@ -195,16 +195,15 @@ const runBlockJsEsbuild = async (entryFile, block: ShopifyAppBlock & { path: str
195
195
 
196
196
  if (process.env.SHOPIFY_ACCELERATE_TAILWIND_PREFIX) {
197
197
  clearTimeout(current.timeout);
198
- current.timeout = setTimeout(() => {
198
+ const cssPath = path.join(config.extension_path, `assets/tailwind.css`);
199
+ const runFinalPass = () => {
200
+ if (!fs.existsSync(cssPath)) {
201
+ current.timeout = setTimeout(runFinalPass, 300);
202
+ return;
203
+ }
199
204
  Object.values(config.sources.blockSchemas ?? {})?.forEach(({ folder }) => {
200
205
  if (!content.includes("/* CSS CROSS CHECKED */")) {
201
- const finalContent = transformContent(
202
- content,
203
- true,
204
- fs.readFileSync(path.join(config.extension_path, `assets/tailwind.css`), {
205
- encoding: "utf-8",
206
- })
207
- );
206
+ const finalContent = transformContent(content, true, fs.readFileSync(cssPath, { encoding: "utf-8" }));
208
207
  console.log(Object.fromEntries(notCSSClasses.entries()));
209
208
  fs.writeFileSync(finalPath, `${finalContent}\n\n/* CSS CROSS CHECKED */`);
210
209
  if (process.env.SHOPIFY_ACCELERATE_THEME_OUTPUT_PATH) {
@@ -212,7 +211,8 @@ const runBlockJsEsbuild = async (entryFile, block: ShopifyAppBlock & { path: str
212
211
  }
213
212
  }
214
213
  });
215
- }, 1800);
214
+ };
215
+ current.timeout = setTimeout(runFinalPass, 1800);
216
216
  }
217
217
 
218
218
  try {
@@ -393,13 +393,14 @@ export const generateLiquidFiles = (final?: boolean, cssOutput?: string) => {
393
393
 
394
394
  clearTimeout(current.timeout);
395
395
  if (!final) {
396
- current.timeout = setTimeout(() => {
397
- generateLiquidFiles(
398
- true,
399
- fs.readFileSync(path.join(config.extension_path, `assets/tailwind.css`), {
400
- encoding: "utf-8",
401
- })
402
- );
403
- }, 1800);
396
+ const cssPath = path.join(config.extension_path, `assets/tailwind.css`);
397
+ const runFinalPass = () => {
398
+ if (!fs.existsSync(cssPath)) {
399
+ current.timeout = setTimeout(runFinalPass, 300);
400
+ return;
401
+ }
402
+ generateLiquidFiles(true, fs.readFileSync(cssPath, { encoding: "utf-8" }));
403
+ };
404
+ current.timeout = setTimeout(runFinalPass, 1800);
404
405
  }
405
406
  };
@@ -2,7 +2,7 @@ import chalk from "chalk";
2
2
  import fs from "fs";
3
3
  import watch from "node-watch";
4
4
  import path from "path";
5
- import { config, root_dir } from "../../shopify-accelerate-app";
5
+ import { config } from "../../shopify-accelerate-app";
6
6
  import { generateBlocksTypes } from "../scaffold-theme/generate-blocks-types";
7
7
  import { generateLiquidFiles } from "../scaffold-theme/generate-liquid-files";
8
8
  import { generateSchemaLocales } from "../scaffold-theme/generate-schema-locales";
@@ -32,65 +32,79 @@ export const watchAppExtension = () => {
32
32
 
33
33
  let running = false;
34
34
  watch(watchable_folders, { recursive: true }, (event, name) => {
35
- if (running) return;
36
- const startTime = Date.now();
37
- running = true;
38
- if (event === "remove") {
39
- getSources();
40
- getTargets();
41
- }
42
- if (isTypeScriptSchema(name)) {
43
- getTargets();
44
- getSchemaSources();
45
- parseLocales();
46
- generateSchemaVariables();
47
- generateSchemaLocales();
48
- generateBlocksTypes();
49
- generateLiquidFiles();
50
- console.log(
51
- `[${chalk.gray(new Date().toLocaleTimeString())}]: [${chalk.magentaBright(
52
- `${Date.now() - startTime}ms`
53
- )}] ${chalk.cyan(`File modified: ${name.replace(process.cwd(), "")}`)}`
54
- );
35
+ // Ignore atomic-write temp files (Claude Code, VSCode, etc. write `<file>.tmp.<pid>.<ts>` then rename).
36
+ if (/\.tmp\.\d+\.\d+$/i.test(name)) {
37
+ return;
55
38
  }
56
- if (isAsset(name)) {
57
- const fileName = name.split(/[\\/]/gi).at(-1);
58
- const targetPath = path.join(process.cwd(), extension_path, "assets", fileName);
59
39
 
60
- if (event !== "remove") {
61
- const rawContent = fs.readFileSync(name, { encoding: "utf-8" });
40
+ const startTime = Date.now();
62
41
 
63
- if (ignore_assets?.includes(targetPath.split(/[/\\]/)?.at(-1))) {
64
- console.log(
65
- `[${chalk.gray(new Date().toLocaleTimeString())}]: ${chalk.greenBright(
66
- `Ignored: ${targetPath.replace(process.cwd(), "")}`
67
- )}`
68
- );
69
- writeOnlyNew(targetPath, rawContent);
70
- } else {
71
- writeCompareFile(targetPath, rawContent);
72
- }
42
+ try {
43
+ if (running) return;
44
+ running = true;
45
+ if (event === "remove") {
46
+ getSources();
47
+ getTargets();
73
48
  }
49
+ if (isTypeScriptSchema(name)) {
50
+ getTargets();
51
+ getSchemaSources();
52
+ parseLocales();
53
+ generateSchemaVariables();
54
+ generateSchemaLocales();
55
+ generateBlocksTypes();
56
+ generateLiquidFiles();
57
+ console.log(
58
+ `[${chalk.gray(new Date().toLocaleTimeString())}]: [${chalk.magentaBright(`${Date.now() - startTime}ms`)}] ${chalk.cyan(
59
+ `File modified: ${name.replace(process.cwd(), "")}`
60
+ )}`
61
+ );
62
+ }
63
+ if (isAsset(name)) {
64
+ const fileName = name.split(/[\\/]/gi).at(-1);
65
+ const targetPath = path.join(process.cwd(), extension_path, "assets", fileName);
66
+
67
+ if (event !== "remove") {
68
+ const rawContent = fs.readFileSync(name, { encoding: "utf-8" });
69
+
70
+ if (ignore_assets?.includes(targetPath.split(/[/\\]/)?.at(-1))) {
71
+ console.log(
72
+ `[${chalk.gray(new Date().toLocaleTimeString())}]: ${chalk.greenBright(`Ignored: ${targetPath.replace(process.cwd(), "")}`)}`
73
+ );
74
+ writeOnlyNew(targetPath, rawContent);
75
+ } else {
76
+ writeCompareFile(targetPath, rawContent);
77
+ }
78
+ }
74
79
 
75
- if (event === "remove" && delete_external_assets) {
76
- const targetFile = fs.existsSync(targetPath);
80
+ if (event === "remove" && delete_external_assets) {
81
+ const targetFile = fs.existsSync(targetPath);
77
82
 
78
- if (targetFile) {
79
- deleteFile(targetPath);
83
+ if (targetFile) {
84
+ deleteFile(targetPath);
85
+ }
80
86
  }
81
87
  }
82
- }
83
- if (isLiquid(name) || isSectionTs(name) || isBlockTs(name)) {
84
- getTargets();
85
- getSources();
86
- generateSchemaVariables();
87
- generateLiquidFiles();
88
+ if (isLiquid(name) || isSectionTs(name) || isBlockTs(name)) {
89
+ getTargets();
90
+ getSources();
91
+ generateSchemaVariables();
92
+ generateLiquidFiles();
93
+ console.log(
94
+ `[${chalk.gray(new Date().toLocaleTimeString())}]: [${chalk.magentaBright(`${Date.now() - startTime}ms`)}] ${chalk.cyan(
95
+ `File modified: ${name.replace(process.cwd(), "")}`
96
+ )}`
97
+ );
98
+ }
99
+ } catch (err) {
88
100
  console.log(
89
- `[${chalk.gray(new Date().toLocaleTimeString())}]: [${chalk.magentaBright(
90
- `${Date.now() - startTime}ms`
91
- )}] ${chalk.cyan(`File modified: ${name.replace(process.cwd(), "")}`)}`
101
+ `[${chalk.gray(new Date().toLocaleTimeString())}]: [${chalk.magentaBright(`${Date.now() - startTime}ms`)}] ${chalk.cyan(
102
+ `File modified: ${name.replace(process.cwd(), "")}`
103
+ )}`,
104
+ err
92
105
  );
106
+ } finally {
107
+ running = false;
93
108
  }
94
- running = false;
95
109
  });
96
110
  };