shopify-accelerate-app 1.0.42 → 1.0.44
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
|
@@ -23,13 +23,10 @@ export const generateSchemaVariables = () => {
|
|
|
23
23
|
variables.push("{%- liquid");
|
|
24
24
|
variables.push(` assign block_type = "${schema.folder}"`);
|
|
25
25
|
|
|
26
|
-
schema.settings?.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
RESERVED_VARIABLES.includes(setting.id) ? `_${setting.id}` : setting.id
|
|
31
|
-
} = block.settings.${setting.id}`
|
|
32
|
-
);
|
|
26
|
+
const filteredSettings = schema.settings?.filter((setting) => !(setting.type === "header" || setting.type === "paragraph")) ?? [];
|
|
27
|
+
|
|
28
|
+
filteredSettings?.forEach((setting) => {
|
|
29
|
+
variables.push(` assign ${RESERVED_VARIABLES.includes(setting.id) ? `_${setting.id}` : setting.id} = block.settings.${setting.id}`);
|
|
33
30
|
});
|
|
34
31
|
|
|
35
32
|
variables.push("-%}");
|
|
@@ -41,12 +38,18 @@ export const generateSchemaVariables = () => {
|
|
|
41
38
|
|
|
42
39
|
if (!fs.existsSync(itemLiquid)) {
|
|
43
40
|
console.log(
|
|
44
|
-
`[${chalk.gray(new Date().toLocaleTimeString())}]: ${chalk.cyanBright(
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
`[${chalk.gray(new Date().toLocaleTimeString())}]: ${chalk.cyanBright(`Created: ${itemLiquid.replace(process.cwd(), "")}`)}`
|
|
42
|
+
);
|
|
43
|
+
variables.splice(
|
|
44
|
+
-3,
|
|
45
|
+
0,
|
|
46
|
+
`{%- comment -%} Unused Variables will be stripped in output: ${filteredSettings
|
|
47
|
+
.map((setting) => (RESERVED_VARIABLES.includes(setting.id) ? `_${setting.id}` : setting.id))
|
|
48
|
+
.join(", ")} {%- endcomment -%}`
|
|
47
49
|
);
|
|
48
50
|
fs.writeFileSync(itemLiquid, schema.settings ? variables.join("\n") : "");
|
|
49
51
|
config.sources.blocksLiquid = [...new Set([...config.sources.blocksLiquid, itemLiquid])];
|
|
52
|
+
continue;
|
|
50
53
|
}
|
|
51
54
|
|
|
52
55
|
if (fs.existsSync(itemLiquid)) {
|
|
@@ -54,6 +57,24 @@ export const generateSchemaVariables = () => {
|
|
|
54
57
|
encoding: "utf-8",
|
|
55
58
|
});
|
|
56
59
|
|
|
60
|
+
const contentAfterEnd = itemContent.split(end).at(-1);
|
|
61
|
+
|
|
62
|
+
const unusedSettings = filteredSettings.filter(
|
|
63
|
+
(setting) => !contentAfterEnd.includes(RESERVED_VARIABLES.includes(setting.id) ? `_${setting.id}` : setting.id)
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
console.log({ unusedSettings });
|
|
67
|
+
|
|
68
|
+
if (unusedSettings.length) {
|
|
69
|
+
variables.splice(
|
|
70
|
+
-3,
|
|
71
|
+
0,
|
|
72
|
+
`{%- comment -%} Unused Variables will be stripped in output: ${unusedSettings
|
|
73
|
+
.map((setting) => (RESERVED_VARIABLES.includes(setting.id) ? `_${setting.id}` : setting.id))
|
|
74
|
+
.join(", ")} {%- endcomment -%}`
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
57
78
|
if (itemContent.includes(start) && itemContent.includes(end)) {
|
|
58
79
|
const newContent = itemContent.replace(
|
|
59
80
|
// eslint-disable-next-line max-len
|
|
@@ -63,9 +84,7 @@ export const generateSchemaVariables = () => {
|
|
|
63
84
|
|
|
64
85
|
if (itemContent !== newContent) {
|
|
65
86
|
console.log(
|
|
66
|
-
`[${chalk.gray(new Date().toLocaleTimeString())}]: ${chalk.blueBright(
|
|
67
|
-
`Updated: ${itemLiquid.replace(process.cwd(), "")}`
|
|
68
|
-
)}`
|
|
87
|
+
`[${chalk.gray(new Date().toLocaleTimeString())}]: ${chalk.blueBright(`Updated: ${itemLiquid.replace(process.cwd(), "")}`)}`
|
|
69
88
|
);
|
|
70
89
|
fs.writeFileSync(itemLiquid, newContent);
|
|
71
90
|
}
|
|
@@ -75,9 +94,7 @@ export const generateSchemaVariables = () => {
|
|
|
75
94
|
const newContent = variableContent + itemContent;
|
|
76
95
|
|
|
77
96
|
console.log(
|
|
78
|
-
`[${chalk.gray(new Date().toLocaleTimeString())}]: ${chalk.blueBright(
|
|
79
|
-
`Updated: ${itemLiquid.replace(process.cwd(), "")}`
|
|
80
|
-
)}`
|
|
97
|
+
`[${chalk.gray(new Date().toLocaleTimeString())}]: ${chalk.blueBright(`Updated: ${itemLiquid.replace(process.cwd(), "")}`)}`
|
|
81
98
|
);
|
|
82
99
|
fs.writeFileSync(itemLiquid, newContent);
|
|
83
100
|
}
|