wp-typia 0.22.5 → 0.22.7
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/README.md +7 -0
- package/bin/wp-typia.js +83 -0
- package/dist-bunli/.bunli/commands.gen.js +2000 -1256
- package/dist-bunli/{cli-xbzfx7qz.js → cli-27v2qpjg.js} +4 -4
- package/dist-bunli/{cli-1sm60g1z.js → cli-2hsp17nd.js} +2 -2
- package/dist-bunli/{cli-hb9vpsev.js → cli-2rqf6t0b.js} +1 -1
- package/dist-bunli/{cli-6bhfzq5e.js → cli-52ke0ptp.js} +2 -2
- package/dist-bunli/{cli-ctddkm3n.js → cli-8snabymq.js} +405 -204
- package/dist-bunli/{cli-add-1gqgshf0.js → cli-add-8jpdnz1r.js} +85 -64
- package/dist-bunli/{cli-nzwpmw4y.js → cli-cjygr56g.js} +98 -32
- package/dist-bunli/{cli-doctor-w35s8y9w.js → cli-doctor-h5tq4ztr.js} +15 -18
- package/dist-bunli/cli-fys8vm2t.js +20 -0
- package/dist-bunli/{cli-btbpt84c.js → cli-hhp1d348.js} +1 -1
- package/dist-bunli/{cli-init-z8sjmkvc.js → cli-init-w9p558th.js} +414 -393
- package/dist-bunli/{cli-scaffold-ad3bd555.js → cli-scaffold-qve8rqja.js} +9 -8
- package/dist-bunli/{cli-j30rk466.js → cli-ta3y0hp2.js} +697 -298
- package/dist-bunli/cli.js +8 -6
- package/dist-bunli/{command-list-scd6zqp8.js → command-list-6zr1tj96.js} +16 -12
- package/dist-bunli/{migrations-skkzdvhm.js → migrations-v0avgyg6.js} +7 -6
- package/dist-bunli/node-cli.js +253 -97
- package/dist-bunli/{workspace-project-7826tewa.js → workspace-project-csnnggz6.js} +2 -2
- package/package.json +2 -2
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
scaffoldProject,
|
|
22
22
|
syncPersistenceRestArtifacts,
|
|
23
23
|
updatePluginHeaderCompatibility
|
|
24
|
-
} from "./cli-
|
|
24
|
+
} from "./cli-8snabymq.js";
|
|
25
25
|
import {
|
|
26
26
|
DEFAULT_WORDPRESS_ABILITIES_VERSION,
|
|
27
27
|
DEFAULT_WORDPRESS_CORE_ABILITIES_VERSION,
|
|
@@ -31,16 +31,16 @@ import {
|
|
|
31
31
|
DEFAULT_WP_TYPIA_DATAVIEWS_VERSION,
|
|
32
32
|
getPackageVersions,
|
|
33
33
|
resolveManagedPackageVersionRange
|
|
34
|
-
} from "./cli-
|
|
34
|
+
} from "./cli-2hsp17nd.js";
|
|
35
35
|
import {
|
|
36
36
|
snapshotProjectVersion
|
|
37
|
-
} from "./cli-
|
|
37
|
+
} from "./cli-27v2qpjg.js";
|
|
38
38
|
import {
|
|
39
39
|
ensureMigrationDirectories,
|
|
40
40
|
parseMigrationConfig,
|
|
41
41
|
writeInitialMigrationScaffold,
|
|
42
42
|
writeMigrationConfig
|
|
43
|
-
} from "./cli-
|
|
43
|
+
} from "./cli-2rqf6t0b.js";
|
|
44
44
|
import"./cli-bq2v559b.js";
|
|
45
45
|
import {
|
|
46
46
|
findExecutablePatternMatch,
|
|
@@ -54,7 +54,6 @@ import {
|
|
|
54
54
|
} from "./cli-tke8twkn.js";
|
|
55
55
|
import {
|
|
56
56
|
ADD_BLOCK_TEMPLATE_IDS,
|
|
57
|
-
ADD_KIND_IDS,
|
|
58
57
|
EDITOR_PLUGIN_SLOT_IDS,
|
|
59
58
|
appendWorkspaceInventoryEntries,
|
|
60
59
|
assertAbilityDoesNotExist,
|
|
@@ -79,10 +78,12 @@ import {
|
|
|
79
78
|
getMutableBlockHooks,
|
|
80
79
|
getWorkspaceBlockSelectOptions,
|
|
81
80
|
getWorkspaceBootstrapPath,
|
|
81
|
+
hasPhpFunctionCall,
|
|
82
82
|
hasPhpFunctionDefinition,
|
|
83
83
|
isAddBlockTemplateId,
|
|
84
84
|
normalizeBlockSlug,
|
|
85
85
|
patchFile,
|
|
86
|
+
pathExists,
|
|
86
87
|
quotePhpString,
|
|
87
88
|
quoteTsString,
|
|
88
89
|
readOptionalFile,
|
|
@@ -100,26 +101,25 @@ import {
|
|
|
100
101
|
toPascalCase,
|
|
101
102
|
toSnakeCase,
|
|
102
103
|
toTitleCase
|
|
103
|
-
} from "./cli-
|
|
104
|
+
} from "./cli-ta3y0hp2.js";
|
|
104
105
|
import {
|
|
105
106
|
createManagedTempRoot
|
|
106
107
|
} from "./cli-t73q5aqz.js";
|
|
107
108
|
import {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
109
|
+
ADD_KIND_IDS
|
|
110
|
+
} from "./cli-fys8vm2t.js";
|
|
111
|
+
import"./cli-p95wr1q8.js";
|
|
111
112
|
import {
|
|
112
113
|
resolveWorkspaceProject
|
|
113
|
-
} from "./cli-
|
|
114
|
+
} from "./cli-hhp1d348.js";
|
|
114
115
|
import {
|
|
115
116
|
formatInstallCommand
|
|
116
|
-
} from "./cli-
|
|
117
|
+
} from "./cli-52ke0ptp.js";
|
|
117
118
|
import {
|
|
118
119
|
__reExport,
|
|
119
120
|
__toESM
|
|
120
121
|
} from "./cli-xnn9xjcy.js";
|
|
121
122
|
// ../wp-typia-project-tools/src/runtime/cli-add-block.ts
|
|
122
|
-
import fs2 from "fs";
|
|
123
123
|
import { promises as fsp2 } from "fs";
|
|
124
124
|
import path3 from "path";
|
|
125
125
|
import {
|
|
@@ -485,11 +485,16 @@ async function renderWorkspacePersistenceServerModule(projectDir, variables) {
|
|
|
485
485
|
const templateDir = buildServerTemplateRoot(variables.persistencePolicy);
|
|
486
486
|
await copyInterpolatedDirectory(templateDir, targetDir, variables);
|
|
487
487
|
}
|
|
488
|
-
function hasInstalledWorkspaceDependencies(projectDir) {
|
|
489
|
-
|
|
488
|
+
async function hasInstalledWorkspaceDependencies(projectDir) {
|
|
489
|
+
for (const marker of WORKSPACE_INSTALL_MARKERS) {
|
|
490
|
+
if (await pathExists(path3.join(projectDir, marker))) {
|
|
491
|
+
return true;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
return false;
|
|
490
495
|
}
|
|
491
|
-
function assertWorkspaceDependenciesInstalled(workspace) {
|
|
492
|
-
if (hasInstalledWorkspaceDependencies(workspace.projectDir)) {
|
|
496
|
+
async function assertWorkspaceDependenciesInstalled(workspace) {
|
|
497
|
+
if (await hasInstalledWorkspaceDependencies(workspace.projectDir)) {
|
|
493
498
|
return;
|
|
494
499
|
}
|
|
495
500
|
throw new Error(`Workspace dependencies have not been installed yet. Run \`${formatInstallCommand(workspace.packageManager)}\` from the workspace root before using \`wp-typia add block ...\`.`);
|
|
@@ -561,19 +566,19 @@ function collectWorkspaceBlockPaths(projectDir, templateId, variables) {
|
|
|
561
566
|
}
|
|
562
567
|
return [path3.join(projectDir, "src", "blocks", variables.slugKebabCase)];
|
|
563
568
|
}
|
|
564
|
-
function assertBlockTargetsDoNotExist(projectDir, templateId, variables) {
|
|
569
|
+
async function assertBlockTargetsDoNotExist(projectDir, templateId, variables) {
|
|
565
570
|
for (const targetPath of collectWorkspaceBlockPaths(projectDir, templateId, variables)) {
|
|
566
|
-
if (
|
|
571
|
+
if (await pathExists(targetPath)) {
|
|
567
572
|
throw new Error(`A block already exists at ${path3.relative(projectDir, targetPath)}. Choose a different name.`);
|
|
568
573
|
}
|
|
569
574
|
}
|
|
570
575
|
}
|
|
571
576
|
async function updateWorkspaceMigrationConfigIfPresent(projectDir, newBlocks) {
|
|
572
577
|
const configPath = path3.join(projectDir, "src", "migrations", "config.ts");
|
|
573
|
-
|
|
578
|
+
const configSource = await readOptionalFile(configPath);
|
|
579
|
+
if (configSource === null) {
|
|
574
580
|
return;
|
|
575
581
|
}
|
|
576
|
-
const configSource = await fsp2.readFile(configPath, "utf8");
|
|
577
582
|
const config = parseMigrationConfig(configSource);
|
|
578
583
|
const existingBlocks = Array.isArray(config.blocks) ? config.blocks : [];
|
|
579
584
|
const nextBlocks = [
|
|
@@ -682,7 +687,7 @@ async function runAddBlockCommand({
|
|
|
682
687
|
assertCompoundInnerBlocksPresetAllowed(resolvedTemplateId, innerBlocksPreset);
|
|
683
688
|
const resolvedInnerBlocksPreset = parseCompoundInnerBlocksPreset(innerBlocksPreset);
|
|
684
689
|
const workspace = resolveWorkspaceProject(cwd);
|
|
685
|
-
assertWorkspaceDependenciesInstalled(workspace);
|
|
690
|
+
await assertWorkspaceDependenciesInstalled(workspace);
|
|
686
691
|
const normalizedExternalLayerId = normalizeOptionalCliString(externalLayerId);
|
|
687
692
|
const normalizedExternalLayerSource = resolveLocalCliPathOption({
|
|
688
693
|
cwd,
|
|
@@ -753,7 +758,7 @@ async function runAddBlockCommand({
|
|
|
753
758
|
});
|
|
754
759
|
return scaffoldResult;
|
|
755
760
|
})();
|
|
756
|
-
assertBlockTargetsDoNotExist(workspace.projectDir, resolvedTemplateId, result.variables);
|
|
761
|
+
await assertBlockTargetsDoNotExist(workspace.projectDir, resolvedTemplateId, result.variables);
|
|
757
762
|
const mutationSnapshot = {
|
|
758
763
|
fileSources: await snapshotWorkspaceFiles([
|
|
759
764
|
blockConfigPath,
|
|
@@ -789,7 +794,6 @@ async function runAddBlockCommand({
|
|
|
789
794
|
}
|
|
790
795
|
}
|
|
791
796
|
// ../wp-typia-project-tools/src/runtime/cli-add-workspace.ts
|
|
792
|
-
import fs6 from "fs";
|
|
793
797
|
import { promises as fsp9 } from "fs";
|
|
794
798
|
import path14 from "path";
|
|
795
799
|
|
|
@@ -808,8 +812,6 @@ var ADMIN_VIEWS_ASSET = "build/admin-views/index.asset.php";
|
|
|
808
812
|
var ADMIN_VIEWS_STYLE = "build/admin-views/style-index.css";
|
|
809
813
|
var ADMIN_VIEWS_STYLE_RTL = "build/admin-views/style-index-rtl.css";
|
|
810
814
|
var ADMIN_VIEWS_PHP_GLOB = "/inc/admin-views/*.php";
|
|
811
|
-
var ADMIN_VIEW_ALLOW_UNPUBLISHED_DATAVIEWS_ENV = "WP_TYPIA_ALLOW_UNPUBLISHED_DATAVIEWS";
|
|
812
|
-
var ADMIN_VIEW_PUBLIC_INSTALLS_ENABLED = false;
|
|
813
815
|
function isAdminViewCoreDataSource(source) {
|
|
814
816
|
return source?.kind === ADMIN_VIEW_CORE_DATA_SOURCE_KIND;
|
|
815
817
|
}
|
|
@@ -824,14 +826,8 @@ function formatAdminViewSourceLocator(source) {
|
|
|
824
826
|
}
|
|
825
827
|
|
|
826
828
|
// ../wp-typia-project-tools/src/runtime/cli-add-workspace-admin-view-source.ts
|
|
827
|
-
function isAdminViewUnpublishedDataViewsOverrideEnabled() {
|
|
828
|
-
return process.env[ADMIN_VIEW_ALLOW_UNPUBLISHED_DATAVIEWS_ENV]?.trim() === "1";
|
|
829
|
-
}
|
|
830
829
|
function assertAdminViewPackageAvailability() {
|
|
831
|
-
|
|
832
|
-
return;
|
|
833
|
-
}
|
|
834
|
-
throw createCliDiagnosticCodeError(CLI_DIAGNOSTIC_CODES.INVALID_ARGUMENT, "`wp-typia add admin-view` is temporarily unavailable because `@wp-typia/dataviews` is not published to npm for public installs yet.");
|
|
830
|
+
return;
|
|
835
831
|
}
|
|
836
832
|
function assertValidCoreDataEntitySegment(label, value) {
|
|
837
833
|
const trimmed = value.trim();
|
|
@@ -908,7 +904,7 @@ function resolveAdminViewCoreDataSource(source) {
|
|
|
908
904
|
}
|
|
909
905
|
|
|
910
906
|
// ../wp-typia-project-tools/src/runtime/cli-add-workspace-admin-view-scaffold.ts
|
|
911
|
-
import
|
|
907
|
+
import fs2 from "fs";
|
|
912
908
|
import { promises as fsp3 } from "fs";
|
|
913
909
|
import path5 from "path";
|
|
914
910
|
|
|
@@ -2094,13 +2090,13 @@ function resolveAdminViewRegistryPath(projectDir) {
|
|
|
2094
2090
|
return [
|
|
2095
2091
|
path5.join(adminViewsDir, "index.ts"),
|
|
2096
2092
|
path5.join(adminViewsDir, "index.js")
|
|
2097
|
-
].find((candidatePath) =>
|
|
2093
|
+
].find((candidatePath) => fs2.existsSync(candidatePath)) ?? path5.join(adminViewsDir, "index.ts");
|
|
2098
2094
|
}
|
|
2099
2095
|
function readAdminViewRegistrySlugs(registryPath) {
|
|
2100
|
-
if (!
|
|
2096
|
+
if (!fs2.existsSync(registryPath)) {
|
|
2101
2097
|
return [];
|
|
2102
2098
|
}
|
|
2103
|
-
const source =
|
|
2099
|
+
const source = fs2.readFileSync(registryPath, "utf8");
|
|
2104
2100
|
return Array.from(source.matchAll(/^\s*import\s+['"]\.\/([^/'"]+)(?:\/index(?:\.[cm]?[jt]sx?)?)?['"];?\s*$/gmu)).map((match) => match[1]);
|
|
2105
2101
|
}
|
|
2106
2102
|
async function writeAdminViewRegistry(projectDir, adminViewSlug) {
|
|
@@ -2196,7 +2192,7 @@ async function runAddAdminViewCommand({
|
|
|
2196
2192
|
}
|
|
2197
2193
|
// ../wp-typia-project-tools/src/runtime/cli-add-workspace-assets.ts
|
|
2198
2194
|
var import_typescript = __toESM(require_typescript(), 1);
|
|
2199
|
-
import
|
|
2195
|
+
import fs3 from "fs";
|
|
2200
2196
|
import { promises as fsp4 } from "fs";
|
|
2201
2197
|
import path6 from "path";
|
|
2202
2198
|
import {
|
|
@@ -2936,13 +2932,13 @@ async function ensureEditorPluginWebpackAnchors(workspace) {
|
|
|
2936
2932
|
}
|
|
2937
2933
|
function resolveBindingSourceRegistryPath(projectDir) {
|
|
2938
2934
|
const bindingsDir = path6.join(projectDir, "src", "bindings");
|
|
2939
|
-
return [path6.join(bindingsDir, "index.ts"), path6.join(bindingsDir, "index.js")].find((candidatePath) =>
|
|
2935
|
+
return [path6.join(bindingsDir, "index.ts"), path6.join(bindingsDir, "index.js")].find((candidatePath) => fs3.existsSync(candidatePath)) ?? path6.join(bindingsDir, "index.ts");
|
|
2940
2936
|
}
|
|
2941
2937
|
async function writeBindingSourceRegistry(projectDir, bindingSourceSlug) {
|
|
2942
2938
|
const bindingsDir = path6.join(projectDir, "src", "bindings");
|
|
2943
2939
|
const bindingsIndexPath = resolveBindingSourceRegistryPath(projectDir);
|
|
2944
2940
|
await fsp4.mkdir(bindingsDir, { recursive: true });
|
|
2945
|
-
const existingBindingSourceSlugs =
|
|
2941
|
+
const existingBindingSourceSlugs = fs3.readdirSync(bindingsDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
|
|
2946
2942
|
const nextBindingSourceSlugs = Array.from(new Set([...existingBindingSourceSlugs, bindingSourceSlug])).sort();
|
|
2947
2943
|
await fsp4.writeFile(bindingsIndexPath, buildBindingSourceIndexSource(nextBindingSourceSlugs), "utf8");
|
|
2948
2944
|
}
|
|
@@ -2951,13 +2947,13 @@ function resolveEditorPluginRegistryPath(projectDir) {
|
|
|
2951
2947
|
return [
|
|
2952
2948
|
path6.join(editorPluginsDir, "index.ts"),
|
|
2953
2949
|
path6.join(editorPluginsDir, "index.js")
|
|
2954
|
-
].find((candidatePath) =>
|
|
2950
|
+
].find((candidatePath) => fs3.existsSync(candidatePath)) ?? path6.join(editorPluginsDir, "index.ts");
|
|
2955
2951
|
}
|
|
2956
2952
|
function readEditorPluginRegistrySlugs(registryPath) {
|
|
2957
|
-
if (!
|
|
2953
|
+
if (!fs3.existsSync(registryPath)) {
|
|
2958
2954
|
return [];
|
|
2959
2955
|
}
|
|
2960
|
-
const source =
|
|
2956
|
+
const source = fs3.readFileSync(registryPath, "utf8");
|
|
2961
2957
|
return Array.from(source.matchAll(/^\s*import\s+['"]\.\/([^/'"]+)(?:\/index(?:\.[cm]?[jt]sx?)?)?['"];?\s*$/gmu)).map((match) => match[1]);
|
|
2962
2958
|
}
|
|
2963
2959
|
async function writeEditorPluginRegistry(projectDir, editorPluginSlug) {
|
|
@@ -4324,7 +4320,7 @@ async function runAddRestResourceCommand({
|
|
|
4324
4320
|
}
|
|
4325
4321
|
// ../wp-typia-project-tools/src/runtime/cli-add-workspace-ability-scaffold.ts
|
|
4326
4322
|
var import_semver = __toESM(require_semver(), 1);
|
|
4327
|
-
import
|
|
4323
|
+
import fs4 from "fs";
|
|
4328
4324
|
import { promises as fsp6 } from "fs";
|
|
4329
4325
|
import path10 from "path";
|
|
4330
4326
|
import { syncTypeSchemas as syncTypeSchemas2 } from "@wp-typia/block-runtime/metadata-core";
|
|
@@ -4818,13 +4814,13 @@ function resolveManagedDependencyVersion(existingVersion, requiredVersion) {
|
|
|
4818
4814
|
}
|
|
4819
4815
|
function resolveAbilityRegistryPath(projectDir) {
|
|
4820
4816
|
const abilitiesDir = path10.join(projectDir, "src", "abilities");
|
|
4821
|
-
return [path10.join(abilitiesDir, "index.ts"), path10.join(abilitiesDir, "index.js")].find((candidatePath) =>
|
|
4817
|
+
return [path10.join(abilitiesDir, "index.ts"), path10.join(abilitiesDir, "index.js")].find((candidatePath) => fs4.existsSync(candidatePath)) ?? path10.join(abilitiesDir, "index.ts");
|
|
4822
4818
|
}
|
|
4823
4819
|
function readAbilityRegistrySlugs(registryPath) {
|
|
4824
|
-
if (!
|
|
4820
|
+
if (!fs4.existsSync(registryPath)) {
|
|
4825
4821
|
return [];
|
|
4826
4822
|
}
|
|
4827
|
-
const source =
|
|
4823
|
+
const source = fs4.readFileSync(registryPath, "utf8");
|
|
4828
4824
|
return Array.from(source.matchAll(/^\s*export\s+\*\s+from\s+['"]\.\/([^/'"]+)\/client['"];?\s*$/gmu)).map((match) => match[1]);
|
|
4829
4825
|
}
|
|
4830
4826
|
async function writeAbilityRegistry(projectDir, abilitySlug) {
|
|
@@ -4835,7 +4831,7 @@ async function writeAbilityRegistry(projectDir, abilitySlug) {
|
|
|
4835
4831
|
const existingRegistrySlugs = readAbilityRegistrySlugs(registryPath);
|
|
4836
4832
|
const nextAbilitySlugs = Array.from(new Set([...existingAbilitySlugs, ...existingRegistrySlugs, abilitySlug])).sort();
|
|
4837
4833
|
const generatedSection = buildAbilityRegistrySource(nextAbilitySlugs);
|
|
4838
|
-
const existingSource =
|
|
4834
|
+
const existingSource = fs4.existsSync(registryPath) ? fs4.readFileSync(registryPath, "utf8") : "";
|
|
4839
4835
|
const generatedSectionPattern = new RegExp(`${escapeRegex(ABILITY_REGISTRY_START_MARKER)}[\\s\\S]*?${escapeRegex(ABILITY_REGISTRY_END_MARKER)}\\n?`, "u");
|
|
4840
4836
|
const nextSource = existingSource ? generatedSectionPattern.test(existingSource) ? existingSource.replace(generatedSectionPattern, generatedSection) : `${existingSource.trimEnd()}
|
|
4841
4837
|
|
|
@@ -4916,8 +4912,16 @@ function ${enqueueFunctionName}() {
|
|
|
4916
4912
|
}
|
|
4917
4913
|
if (!hasPhpFunctionDefinition(nextSource, enqueueFunctionName)) {
|
|
4918
4914
|
nextSource = insertPhpSnippetBeforeWorkspaceAnchors(nextSource, enqueueFunction);
|
|
4919
|
-
} else
|
|
4920
|
-
|
|
4915
|
+
} else {
|
|
4916
|
+
const functionRange = findPhpFunctionRange(nextSource, enqueueFunctionName);
|
|
4917
|
+
const functionSource = functionRange ? nextSource.slice(functionRange.start, functionRange.end) : "";
|
|
4918
|
+
if (!hasPhpFunctionCall(functionSource, "wp_enqueue_script_module")) {
|
|
4919
|
+
const replacedSource = replacePhpFunctionDefinition(nextSource, enqueueFunctionName, enqueueFunction, { trimReplacementStart: true });
|
|
4920
|
+
if (!replacedSource) {
|
|
4921
|
+
throw new Error(`Unable to repair ${path10.basename(bootstrapPath)} for ${enqueueFunctionName}.`);
|
|
4922
|
+
}
|
|
4923
|
+
nextSource = replacedSource;
|
|
4924
|
+
}
|
|
4921
4925
|
}
|
|
4922
4926
|
if (!nextSource.includes(loadHook)) {
|
|
4923
4927
|
nextSource = appendPhpSnippetBeforeClosingTag(nextSource, loadHook);
|
|
@@ -5088,6 +5092,7 @@ async function scaffoldAbilityWorkspace({
|
|
|
5088
5092
|
compatibilityPolicy,
|
|
5089
5093
|
workspace
|
|
5090
5094
|
}) {
|
|
5095
|
+
const compatibilityWarnings = [];
|
|
5091
5096
|
const blockConfigPath = path10.join(workspace.projectDir, "scripts", "block-config.ts");
|
|
5092
5097
|
const bootstrapPath = getWorkspaceBootstrapPath(workspace);
|
|
5093
5098
|
const buildScriptPath = path10.join(workspace.projectDir, "scripts", "build-workspace.mjs");
|
|
@@ -5118,7 +5123,11 @@ async function scaffoldAbilityWorkspace({
|
|
|
5118
5123
|
await fsp6.mkdir(abilityDir, { recursive: true });
|
|
5119
5124
|
await fsp6.mkdir(path10.dirname(phpFilePath), { recursive: true });
|
|
5120
5125
|
await ensureAbilityBootstrapAnchors(workspace);
|
|
5121
|
-
await patchFile(bootstrapPath, (source) => updatePluginHeaderCompatibility(source, compatibilityPolicy
|
|
5126
|
+
await patchFile(bootstrapPath, (source) => updatePluginHeaderCompatibility(source, compatibilityPolicy, {
|
|
5127
|
+
onWarning: (warning) => {
|
|
5128
|
+
compatibilityWarnings.push(warning);
|
|
5129
|
+
}
|
|
5130
|
+
}));
|
|
5122
5131
|
await ensureAbilityPackageScripts(workspace);
|
|
5123
5132
|
await ensureAbilitySyncProjectAnchors(workspace);
|
|
5124
5133
|
await ensureAbilityBuildScriptAnchors(workspace);
|
|
@@ -5150,6 +5159,9 @@ async function scaffoldAbilityWorkspace({
|
|
|
5150
5159
|
});
|
|
5151
5160
|
}
|
|
5152
5161
|
});
|
|
5162
|
+
return {
|
|
5163
|
+
warnings: compatibilityWarnings
|
|
5164
|
+
};
|
|
5153
5165
|
}
|
|
5154
5166
|
|
|
5155
5167
|
// ../wp-typia-project-tools/src/runtime/cli-add-workspace-ability.ts
|
|
@@ -5162,14 +5174,15 @@ async function runAddAbilityCommand({
|
|
|
5162
5174
|
const inventory = readWorkspaceInventory(workspace.projectDir);
|
|
5163
5175
|
assertAbilityDoesNotExist(workspace.projectDir, abilitySlug, inventory);
|
|
5164
5176
|
const compatibilityPolicy = resolveScaffoldCompatibilityPolicy(REQUIRED_WORKSPACE_ABILITY_COMPATIBILITY);
|
|
5165
|
-
await scaffoldAbilityWorkspace({
|
|
5177
|
+
const scaffoldResult = await scaffoldAbilityWorkspace({
|
|
5166
5178
|
abilitySlug,
|
|
5167
5179
|
compatibilityPolicy,
|
|
5168
5180
|
workspace
|
|
5169
5181
|
});
|
|
5170
5182
|
return {
|
|
5171
5183
|
abilitySlug,
|
|
5172
|
-
projectDir: workspace.projectDir
|
|
5184
|
+
projectDir: workspace.projectDir,
|
|
5185
|
+
warnings: scaffoldResult.warnings
|
|
5173
5186
|
};
|
|
5174
5187
|
}
|
|
5175
5188
|
// ../wp-typia-project-tools/src/runtime/cli-add-workspace-ai-scaffold.ts
|
|
@@ -6612,6 +6625,7 @@ async function scaffoldAiFeatureWorkspace({
|
|
|
6612
6625
|
namespace,
|
|
6613
6626
|
workspace
|
|
6614
6627
|
}) {
|
|
6628
|
+
const compatibilityWarnings = [];
|
|
6615
6629
|
const blockConfigPath = path13.join(workspace.projectDir, "scripts", "block-config.ts");
|
|
6616
6630
|
const bootstrapPath = getWorkspaceBootstrapPath(workspace);
|
|
6617
6631
|
const packageJsonPath = path13.join(workspace.projectDir, "package.json");
|
|
@@ -6638,7 +6652,11 @@ async function scaffoldAiFeatureWorkspace({
|
|
|
6638
6652
|
await fsp8.mkdir(aiFeatureDir, { recursive: true });
|
|
6639
6653
|
await fsp8.mkdir(path13.dirname(phpFilePath), { recursive: true });
|
|
6640
6654
|
await ensureAiFeatureBootstrapAnchors(workspace);
|
|
6641
|
-
await patchFile(bootstrapPath, (source) => updatePluginHeaderCompatibility(source, compatibilityPolicy
|
|
6655
|
+
await patchFile(bootstrapPath, (source) => updatePluginHeaderCompatibility(source, compatibilityPolicy, {
|
|
6656
|
+
onWarning: (warning) => {
|
|
6657
|
+
compatibilityWarnings.push(warning);
|
|
6658
|
+
}
|
|
6659
|
+
}));
|
|
6642
6660
|
const packageScriptChanges = await ensureAiFeaturePackageScripts(workspace);
|
|
6643
6661
|
await ensureAiFeatureSyncProjectAnchors(workspace);
|
|
6644
6662
|
await ensureAiFeatureSyncRestAnchors(workspace);
|
|
@@ -6674,9 +6692,12 @@ async function scaffoldAiFeatureWorkspace({
|
|
|
6674
6692
|
transformSource: ensureBlockConfigCanAddRestManifests
|
|
6675
6693
|
});
|
|
6676
6694
|
return {
|
|
6677
|
-
warnings:
|
|
6678
|
-
|
|
6679
|
-
|
|
6695
|
+
warnings: [
|
|
6696
|
+
...compatibilityWarnings,
|
|
6697
|
+
...packageScriptChanges.addedProjectToolsDependency ? [
|
|
6698
|
+
"Added `@wp-typia/project-tools` to devDependencies for `sync-ai`. If this workspace was already installed, rerun your package manager install command before the first `wp-typia sync ai`."
|
|
6699
|
+
] : []
|
|
6700
|
+
]
|
|
6680
6701
|
};
|
|
6681
6702
|
}
|
|
6682
6703
|
});
|
|
@@ -7095,7 +7116,7 @@ async function writeVariationRegistry(projectDir, blockSlug, variationSlug) {
|
|
|
7095
7116
|
const variationsDir = path14.join(projectDir, "src", "blocks", blockSlug, "variations");
|
|
7096
7117
|
const variationsIndexPath = path14.join(variationsDir, "index.ts");
|
|
7097
7118
|
await fsp9.mkdir(variationsDir, { recursive: true });
|
|
7098
|
-
const existingVariationSlugs =
|
|
7119
|
+
const existingVariationSlugs = (await fsp9.readdir(variationsDir)).filter((entry) => entry.endsWith(".ts") && entry !== "index.ts").map((entry) => entry.replace(/\.ts$/u, ""));
|
|
7099
7120
|
const nextVariationSlugs = Array.from(new Set([...existingVariationSlugs, variationSlug])).sort();
|
|
7100
7121
|
await fsp9.writeFile(variationsIndexPath, buildVariationIndexSource(nextVariationSlugs), "utf8");
|
|
7101
7122
|
}
|
|
@@ -7103,7 +7124,7 @@ async function writeBlockStyleRegistry(projectDir, blockSlug, styleSlug) {
|
|
|
7103
7124
|
const stylesDir = path14.join(projectDir, "src", "blocks", blockSlug, "styles");
|
|
7104
7125
|
const stylesIndexPath = path14.join(stylesDir, "index.ts");
|
|
7105
7126
|
await fsp9.mkdir(stylesDir, { recursive: true });
|
|
7106
|
-
const existingStyleSlugs =
|
|
7127
|
+
const existingStyleSlugs = (await fsp9.readdir(stylesDir)).filter((entry) => entry.endsWith(".ts") && entry !== "index.ts").map((entry) => entry.replace(/\.ts$/u, ""));
|
|
7107
7128
|
const nextStyleSlugs = Array.from(new Set([...existingStyleSlugs, styleSlug])).sort();
|
|
7108
7129
|
await fsp9.writeFile(stylesIndexPath, buildBlockStyleIndexSource(nextStyleSlugs), "utf8");
|
|
7109
7130
|
}
|
|
@@ -7111,7 +7132,7 @@ async function writeBlockTransformRegistry(projectDir, blockSlug, transformSlug)
|
|
|
7111
7132
|
const transformsDir = path14.join(projectDir, "src", "blocks", blockSlug, "transforms");
|
|
7112
7133
|
const transformsIndexPath = path14.join(transformsDir, "index.ts");
|
|
7113
7134
|
await fsp9.mkdir(transformsDir, { recursive: true });
|
|
7114
|
-
const existingTransformSlugs =
|
|
7135
|
+
const existingTransformSlugs = (await fsp9.readdir(transformsDir)).filter((entry) => entry.endsWith(".ts") && entry !== "index.ts").map((entry) => entry.replace(/\.ts$/u, ""));
|
|
7115
7136
|
const nextTransformSlugs = Array.from(new Set([...existingTransformSlugs, transformSlug])).sort();
|
|
7116
7137
|
await fsp9.writeFile(transformsIndexPath, buildBlockTransformIndexSource(nextTransformSlugs), "utf8");
|
|
7117
7138
|
}
|
|
@@ -7160,7 +7181,7 @@ async function runAddVariationCommand({
|
|
|
7160
7181
|
const variationsDir = path14.join(workspace.projectDir, "src", "blocks", blockSlug, "variations");
|
|
7161
7182
|
const variationFilePath = path14.join(variationsDir, `${variationSlug}.ts`);
|
|
7162
7183
|
const variationsIndexPath = path14.join(variationsDir, "index.ts");
|
|
7163
|
-
const shouldRemoveVariationsDirOnRollback = !
|
|
7184
|
+
const shouldRemoveVariationsDirOnRollback = !await pathExists(variationsDir);
|
|
7164
7185
|
const mutationSnapshot = {
|
|
7165
7186
|
fileSources: await snapshotWorkspaceFiles([
|
|
7166
7187
|
blockConfigPath,
|
|
@@ -7207,7 +7228,7 @@ async function runAddBlockStyleCommand({
|
|
|
7207
7228
|
const stylesDir = path14.join(workspace.projectDir, "src", "blocks", blockSlug, "styles");
|
|
7208
7229
|
const styleFilePath = path14.join(stylesDir, `${styleSlug}.ts`);
|
|
7209
7230
|
const stylesIndexPath = path14.join(stylesDir, "index.ts");
|
|
7210
|
-
const shouldRemoveStylesDirOnRollback = !
|
|
7231
|
+
const shouldRemoveStylesDirOnRollback = !await pathExists(stylesDir);
|
|
7211
7232
|
const mutationSnapshot = {
|
|
7212
7233
|
fileSources: await snapshotWorkspaceFiles([
|
|
7213
7234
|
blockConfigPath,
|
|
@@ -7256,7 +7277,7 @@ async function runAddBlockTransformCommand({
|
|
|
7256
7277
|
const transformsDir = path14.join(workspace.projectDir, "src", "blocks", target.blockSlug, "transforms");
|
|
7257
7278
|
const transformFilePath = path14.join(transformsDir, `${transformSlug}.ts`);
|
|
7258
7279
|
const transformsIndexPath = path14.join(transformsDir, "index.ts");
|
|
7259
|
-
const shouldRemoveTransformsDirOnRollback = !
|
|
7280
|
+
const shouldRemoveTransformsDirOnRollback = !await pathExists(transformsDir);
|
|
7260
7281
|
const mutationSnapshot = {
|
|
7261
7282
|
fileSources: await snapshotWorkspaceFiles([
|
|
7262
7283
|
blockConfigPath,
|
|
@@ -7316,7 +7337,7 @@ async function runAddHookedBlockCommand({
|
|
|
7316
7337
|
if (resolvedAnchorBlockName === selfHookAnchor) {
|
|
7317
7338
|
throw new Error("`wp-typia add hooked-block` cannot hook a block relative to its own block name.");
|
|
7318
7339
|
}
|
|
7319
|
-
const { blockJson, blockJsonPath } = readWorkspaceBlockJson(workspace.projectDir, blockSlug);
|
|
7340
|
+
const { blockJson, blockJsonPath } = await readWorkspaceBlockJson(workspace.projectDir, blockSlug);
|
|
7320
7341
|
const blockJsonRelativePath = path14.relative(workspace.projectDir, blockJsonPath);
|
|
7321
7342
|
const blockHooks = getMutableBlockHooks(blockJson, blockJsonRelativePath);
|
|
7322
7343
|
if (Object.prototype.hasOwnProperty.call(blockHooks, resolvedAnchorBlockName)) {
|
|
@@ -7363,4 +7384,4 @@ export {
|
|
|
7363
7384
|
ADD_BLOCK_TEMPLATE_IDS
|
|
7364
7385
|
};
|
|
7365
7386
|
|
|
7366
|
-
//# debugId=
|
|
7387
|
+
//# debugId=DA912BE06859998764756E2164756E21
|