@wp-typia/project-tools 0.24.8 → 0.24.9

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.
@@ -10,9 +10,23 @@ const WORDPRESS_VERSION_CHECK_CODES = {
10
10
  featureMinimum: "wp-typia.workspace.wordpress.feature-minimum",
11
11
  testedTarget: "wp-typia.workspace.wordpress.tested-target",
12
12
  };
13
+ // Both entries read the same `variations` field and are distinguished by value type.
14
+ const BLOCK_VARIATION_BLOCK_JSON_KEYS = {
15
+ registrationBlockJsonMetadata: "variations",
16
+ registrationMetadataFile: "variations",
17
+ };
13
18
  function isEnabledMetadataValue(value) {
14
19
  return value !== undefined && value !== false && value !== null;
15
20
  }
21
+ function isEnabledBlockVariationMetadataFeature(feature, value) {
22
+ if (feature === "registrationBlockJsonMetadata") {
23
+ return Array.isArray(value) && value.length > 0;
24
+ }
25
+ if (feature === "registrationMetadataFile") {
26
+ return typeof value === "string" && value.trim().length > 0;
27
+ }
28
+ return isEnabledMetadataValue(value);
29
+ }
16
30
  function getNestedMetadataValue(object, key) {
17
31
  if (!object) {
18
32
  return undefined;
@@ -101,12 +115,55 @@ function collectBlockMetadataRequirements(workspace, inventory) {
101
115
  pushBlockApiRequirement(requirements, `Block ${block.slug}`, entry);
102
116
  }
103
117
  }
118
+ for (const [feature, entry] of Object.entries(WORDPRESS_BLOCK_API_COMPATIBILITY.blockVariations)) {
119
+ if (!entry.runtime.includes("block-json")) {
120
+ continue;
121
+ }
122
+ const blockJsonFeature = feature;
123
+ const blockJsonKey = BLOCK_VARIATION_BLOCK_JSON_KEYS[blockJsonFeature];
124
+ if (isEnabledBlockVariationMetadataFeature(blockJsonFeature, getNestedMetadataValue(blockJson, blockJsonKey))) {
125
+ pushBlockApiRequirement(requirements, `Block ${block.slug}`, entry);
126
+ }
127
+ }
104
128
  }
105
129
  return {
106
130
  issues,
107
131
  requirements,
108
132
  };
109
133
  }
134
+ function hasGeneratedCoreVariationModule(directoryPath, isRootDirectory = true) {
135
+ if (!fs.existsSync(directoryPath)) {
136
+ return false;
137
+ }
138
+ for (const entry of fs.readdirSync(directoryPath, { withFileTypes: true })) {
139
+ const entryPath = path.join(directoryPath, entry.name);
140
+ if (entry.isDirectory() && hasGeneratedCoreVariationModule(entryPath, false)) {
141
+ return true;
142
+ }
143
+ if (!isRootDirectory &&
144
+ entry.isFile() &&
145
+ entry.name.endsWith(".ts") &&
146
+ entry.name !== "index.ts") {
147
+ return true;
148
+ }
149
+ }
150
+ return false;
151
+ }
152
+ function collectVariationRequirements(workspace, inventory) {
153
+ const requirements = [];
154
+ const variationEntries = WORDPRESS_BLOCK_API_COMPATIBILITY.blockVariations;
155
+ for (const variation of inventory.variations) {
156
+ pushBlockApiRequirement(requirements, `Variation ${variation.block}/${variation.slug}`, variationEntries.editorRegistration);
157
+ }
158
+ const coreVariationsDir = path.join(workspace.projectDir, "src", "editor-plugins", "core-variations");
159
+ if (hasGeneratedCoreVariationModule(coreVariationsDir)) {
160
+ pushBlockApiRequirement(requirements, "Core variations editor plugin", variationEntries.editorRegistration);
161
+ }
162
+ return {
163
+ issues: [],
164
+ requirements,
165
+ };
166
+ }
110
167
  function collectInventoryCompatibilityRequirements(inventory) {
111
168
  const requirements = [];
112
169
  for (const ability of inventory.abilities) {
@@ -154,16 +211,19 @@ function collectBindingSourceRequirements(workspace, inventory) {
154
211
  }
155
212
  function collectWordPressVersionRequirements(workspace, inventory) {
156
213
  const blockRequirements = collectBlockMetadataRequirements(workspace, inventory);
214
+ const variationRequirements = collectVariationRequirements(workspace, inventory);
157
215
  const bindingRequirements = collectBindingSourceRequirements(workspace, inventory);
158
216
  const inventoryRequirements = collectInventoryCompatibilityRequirements(inventory);
159
217
  return {
160
218
  issues: [
161
219
  ...blockRequirements.issues,
220
+ ...variationRequirements.issues,
162
221
  ...bindingRequirements.issues,
163
222
  ...inventoryRequirements.issues,
164
223
  ],
165
224
  requirements: [
166
225
  ...blockRequirements.requirements,
226
+ ...variationRequirements.requirements,
167
227
  ...bindingRequirements.requirements,
168
228
  ...inventoryRequirements.requirements,
169
229
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wp-typia/project-tools",
3
- "version": "0.24.8",
3
+ "version": "0.24.9",
4
4
  "description": "Project orchestration and programmatic tooling for wp-typia",
5
5
  "packageManager": "bun@1.3.11",
6
6
  "type": "module",
@@ -168,7 +168,7 @@
168
168
  "@wp-typia/api-client": "^0.4.6",
169
169
  "@wp-typia/block-runtime": "^0.7.1",
170
170
  "@wp-typia/rest": "^0.3.14",
171
- "@wp-typia/block-types": "^0.3.4",
171
+ "@wp-typia/block-types": "^0.3.5",
172
172
  "mustache": "^4.2.0",
173
173
  "npm-package-arg": "^13.0.0",
174
174
  "semver": "^7.7.3",