shopify-accelerate-app 1.3.0 → 1.3.1
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
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);
|
|
@@ -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
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
-
|
|
61
|
-
const rawContent = fs.readFileSync(name, { encoding: "utf-8" });
|
|
40
|
+
const startTime = Date.now();
|
|
62
41
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
-
|
|
76
|
-
|
|
80
|
+
if (event === "remove" && delete_external_assets) {
|
|
81
|
+
const targetFile = fs.existsSync(targetPath);
|
|
77
82
|
|
|
78
|
-
|
|
79
|
-
|
|
83
|
+
if (targetFile) {
|
|
84
|
+
deleteFile(targetPath);
|
|
85
|
+
}
|
|
80
86
|
}
|
|
81
87
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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
|
-
|
|
91
|
-
)}
|
|
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
|
};
|