@wp-typia/project-tools 0.22.2 → 0.22.4
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/dist/runtime/built-in-block-code-templates/interactivity.d.ts +1 -1
- package/dist/runtime/built-in-block-code-templates/interactivity.js +4 -2
- package/dist/runtime/cli-add-block-json.d.ts +31 -0
- package/dist/runtime/cli-add-block-json.js +65 -0
- package/dist/runtime/cli-add-collision.d.ts +129 -0
- package/dist/runtime/cli-add-collision.js +293 -0
- package/dist/runtime/cli-add-filesystem.d.ts +29 -0
- package/dist/runtime/cli-add-filesystem.js +77 -0
- package/dist/runtime/cli-add-help.d.ts +4 -0
- package/dist/runtime/cli-add-help.js +41 -0
- package/dist/runtime/cli-add-shared.d.ts +6 -255
- package/dist/runtime/cli-add-shared.js +6 -391
- package/dist/runtime/cli-add-types.d.ts +247 -0
- package/dist/runtime/cli-add-types.js +64 -0
- package/dist/runtime/cli-add-validation.d.ts +87 -0
- package/dist/runtime/cli-add-validation.js +147 -0
- package/dist/runtime/cli-add-workspace-ability-scaffold.d.ts +5 -0
- package/dist/runtime/cli-add-workspace-ability-scaffold.js +366 -0
- package/dist/runtime/cli-add-workspace-ability-templates.d.ts +34 -0
- package/dist/runtime/cli-add-workspace-ability-templates.js +500 -0
- package/dist/runtime/cli-add-workspace-ability-types.d.ts +27 -0
- package/dist/runtime/cli-add-workspace-ability-types.js +14 -0
- package/dist/runtime/cli-add-workspace-ability.js +12 -852
- package/dist/runtime/cli-add-workspace-admin-view-scaffold.js +35 -61
- package/dist/runtime/cli-add-workspace-ai-scaffold.d.ts +21 -0
- package/dist/runtime/cli-add-workspace-ai-scaffold.js +87 -0
- package/dist/runtime/cli-add-workspace-ai-templates.d.ts +4 -0
- package/dist/runtime/cli-add-workspace-ai-templates.js +607 -0
- package/dist/runtime/cli-add-workspace-ai.js +15 -688
- package/dist/runtime/cli-add-workspace-assets.js +7 -4
- package/dist/runtime/cli-add-workspace-mutation.d.ts +30 -0
- package/dist/runtime/cli-add-workspace-mutation.js +60 -0
- package/dist/runtime/cli-add-workspace.js +2 -98
- package/dist/runtime/cli-add.d.ts +2 -2
- package/dist/runtime/cli-add.js +2 -2
- package/dist/runtime/cli-doctor-workspace-bindings.d.ts +11 -0
- package/dist/runtime/cli-doctor-workspace-bindings.js +134 -0
- package/dist/runtime/cli-doctor-workspace-blocks.d.ts +11 -0
- package/dist/runtime/cli-doctor-workspace-blocks.js +439 -0
- package/dist/runtime/cli-doctor-workspace-features.d.ts +11 -0
- package/dist/runtime/cli-doctor-workspace-features.js +383 -0
- package/dist/runtime/cli-doctor-workspace-package.d.ts +18 -0
- package/dist/runtime/cli-doctor-workspace-package.js +59 -0
- package/dist/runtime/cli-doctor-workspace-shared.d.ts +69 -0
- package/dist/runtime/cli-doctor-workspace-shared.js +87 -0
- package/dist/runtime/cli-doctor-workspace.js +25 -1062
- package/dist/runtime/index.d.ts +2 -0
- package/dist/runtime/index.js +1 -0
- package/dist/runtime/migration-utils.d.ts +2 -1
- package/dist/runtime/migration-utils.js +3 -11
- package/dist/runtime/package-managers.d.ts +19 -0
- package/dist/runtime/package-managers.js +62 -0
- package/dist/runtime/template-source-cache.d.ts +59 -0
- package/dist/runtime/template-source-cache.js +160 -0
- package/dist/runtime/ts-source-masking.d.ts +28 -0
- package/dist/runtime/ts-source-masking.js +104 -0
- package/dist/runtime/typia-llm.d.ts +9 -1
- package/dist/runtime/typia-llm.js +20 -5
- package/dist/runtime/workspace-inventory.js +116 -59
- package/dist/runtime/workspace-project.d.ts +1 -1
- package/dist/runtime/workspace-project.js +2 -10
- package/package.json +4 -4
|
@@ -4,7 +4,8 @@ import path from 'node:path';
|
|
|
4
4
|
import { appendWorkspaceInventoryEntries, readWorkspaceInventory, } from './workspace-inventory.js';
|
|
5
5
|
import { buildAdminViewConfigEntry, buildAdminViewConfigSource, buildAdminViewEntrySource, buildAdminViewPhpSource, buildAdminViewRegistrySource, buildAdminViewScreenSource, buildAdminViewStyleSource, buildAdminViewTypesSource, buildCoreDataAdminViewDataSource, buildCoreDataAdminViewScreenSource, buildDefaultAdminViewDataSource, buildRestAdminViewDataSource, } from './cli-add-workspace-admin-view-templates.js';
|
|
6
6
|
import { ADMIN_VIEWS_PHP_GLOB, isAdminViewCoreDataSource, } from './cli-add-workspace-admin-view-types.js';
|
|
7
|
-
import { getWorkspaceBootstrapPath, patchFile,
|
|
7
|
+
import { getWorkspaceBootstrapPath, patchFile, } from './cli-add-shared.js';
|
|
8
|
+
import { appendPhpSnippetBeforeClosingTag, executeWorkspaceMutationPlan, insertPhpSnippetBeforeWorkspaceAnchors, } from './cli-add-workspace-mutation.js';
|
|
8
9
|
import { DEFAULT_WORDPRESS_CORE_DATA_VERSION, DEFAULT_WORDPRESS_DATA_VERSION, DEFAULT_WORDPRESS_DATAVIEWS_VERSION, DEFAULT_WP_TYPIA_DATAVIEWS_VERSION, resolveManagedPackageVersionRange, } from './package-versions.js';
|
|
9
10
|
import { findPhpFunctionRange, hasPhpFunctionDefinition, replacePhpFunctionDefinition, } from './php-utils.js';
|
|
10
11
|
function detectJsonIndent(source) {
|
|
@@ -77,30 +78,8 @@ function ${loadFunctionName}() {
|
|
|
77
78
|
\t}
|
|
78
79
|
}
|
|
79
80
|
`;
|
|
80
|
-
const insertionAnchors = [
|
|
81
|
-
/add_action\(\s*["']init["']\s*,\s*["'][^"']+_load_textdomain["']\s*\);\s*\n/u,
|
|
82
|
-
/\?>\s*$/u,
|
|
83
|
-
];
|
|
84
|
-
const insertPhpSnippet = (snippet) => {
|
|
85
|
-
for (const anchor of insertionAnchors) {
|
|
86
|
-
const candidate = nextSource.replace(anchor, (match) => `${snippet}\n${match}`);
|
|
87
|
-
if (candidate !== nextSource) {
|
|
88
|
-
nextSource = candidate;
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
nextSource = `${nextSource.trimEnd()}\n${snippet}\n`;
|
|
93
|
-
};
|
|
94
|
-
const appendPhpSnippet = (snippet) => {
|
|
95
|
-
const closingTagPattern = /\?>\s*$/u;
|
|
96
|
-
if (closingTagPattern.test(nextSource)) {
|
|
97
|
-
nextSource = nextSource.replace(closingTagPattern, `${snippet}\n?>`);
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
nextSource = `${nextSource.trimEnd()}\n${snippet}\n`;
|
|
101
|
-
};
|
|
102
81
|
if (!hasPhpFunctionDefinition(nextSource, loadFunctionName)) {
|
|
103
|
-
|
|
82
|
+
nextSource = insertPhpSnippetBeforeWorkspaceAnchors(nextSource, loadFunction);
|
|
104
83
|
}
|
|
105
84
|
else {
|
|
106
85
|
const functionRange = findPhpFunctionRange(nextSource, loadFunctionName);
|
|
@@ -116,7 +95,7 @@ function ${loadFunctionName}() {
|
|
|
116
95
|
}
|
|
117
96
|
}
|
|
118
97
|
if (!loadHookPattern.test(nextSource)) {
|
|
119
|
-
|
|
98
|
+
nextSource = appendPhpSnippetBeforeClosingTag(nextSource, loadHook);
|
|
120
99
|
}
|
|
121
100
|
return nextSource;
|
|
122
101
|
});
|
|
@@ -211,47 +190,42 @@ export async function scaffoldAdminViewWorkspace(options) {
|
|
|
211
190
|
const adminViewsIndexPath = resolveAdminViewRegistryPath(workspace.projectDir);
|
|
212
191
|
const adminViewDir = path.join(workspace.projectDir, 'src', 'admin-views', adminViewSlug);
|
|
213
192
|
const adminViewPhpPath = path.join(workspace.projectDir, 'inc', 'admin-views', `${adminViewSlug}.php`);
|
|
214
|
-
|
|
215
|
-
|
|
193
|
+
await executeWorkspaceMutationPlan({
|
|
194
|
+
filePaths: [
|
|
216
195
|
adminViewsIndexPath,
|
|
217
196
|
blockConfigPath,
|
|
218
197
|
bootstrapPath,
|
|
219
198
|
buildScriptPath,
|
|
220
199
|
packageJsonPath,
|
|
221
200
|
webpackConfigPath,
|
|
222
|
-
]
|
|
223
|
-
snapshotDirs: [],
|
|
201
|
+
],
|
|
224
202
|
targetPaths: [adminViewDir, adminViewPhpPath],
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
catch (error) {
|
|
254
|
-
await rollbackWorkspaceMutation(mutationSnapshot);
|
|
255
|
-
throw error;
|
|
256
|
-
}
|
|
203
|
+
run: async () => {
|
|
204
|
+
await fsp.mkdir(adminViewDir, { recursive: true });
|
|
205
|
+
await fsp.mkdir(path.dirname(adminViewPhpPath), { recursive: true });
|
|
206
|
+
await ensureAdminViewPackageDependencies(workspace, parsedSource);
|
|
207
|
+
await ensureAdminViewBootstrapAnchors(workspace);
|
|
208
|
+
await ensureAdminViewBuildScriptAnchors(workspace);
|
|
209
|
+
await ensureAdminViewWebpackAnchors(workspace);
|
|
210
|
+
await fsp.writeFile(path.join(adminViewDir, 'types.ts'), buildAdminViewTypesSource(adminViewSlug, restResource, coreDataSource), 'utf8');
|
|
211
|
+
await fsp.writeFile(path.join(adminViewDir, 'config.ts'), buildAdminViewConfigSource(adminViewSlug, workspace.workspace.textDomain, parsedSource, restResource), 'utf8');
|
|
212
|
+
await fsp.writeFile(path.join(adminViewDir, 'data.ts'), coreDataSource
|
|
213
|
+
? buildCoreDataAdminViewDataSource(adminViewSlug, coreDataSource)
|
|
214
|
+
: restResource
|
|
215
|
+
? buildRestAdminViewDataSource(adminViewSlug, restResource)
|
|
216
|
+
: buildDefaultAdminViewDataSource(adminViewSlug), 'utf8');
|
|
217
|
+
await fsp.writeFile(path.join(adminViewDir, 'Screen.tsx'), coreDataSource
|
|
218
|
+
? buildCoreDataAdminViewScreenSource(adminViewSlug, workspace.workspace.textDomain)
|
|
219
|
+
: buildAdminViewScreenSource(adminViewSlug, workspace.workspace.textDomain), 'utf8');
|
|
220
|
+
await fsp.writeFile(path.join(adminViewDir, 'index.tsx'), buildAdminViewEntrySource(adminViewSlug), 'utf8');
|
|
221
|
+
await fsp.writeFile(path.join(adminViewDir, 'style.scss'), buildAdminViewStyleSource(), 'utf8');
|
|
222
|
+
await fsp.writeFile(adminViewPhpPath, buildAdminViewPhpSource(adminViewSlug, workspace), 'utf8');
|
|
223
|
+
await writeAdminViewRegistry(workspace.projectDir, adminViewSlug);
|
|
224
|
+
await appendWorkspaceInventoryEntries(workspace.projectDir, {
|
|
225
|
+
adminViewEntries: [
|
|
226
|
+
buildAdminViewConfigEntry(adminViewSlug, parsedSource),
|
|
227
|
+
],
|
|
228
|
+
});
|
|
229
|
+
},
|
|
230
|
+
});
|
|
257
231
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ScaffoldCompatibilityPolicy } from "./scaffold-compatibility.js";
|
|
2
|
+
import type { WorkspaceProject } from "./workspace-project.js";
|
|
3
|
+
/**
|
|
4
|
+
* Inputs required to scaffold a generated AI feature into a workspace.
|
|
5
|
+
*/
|
|
6
|
+
export interface ScaffoldAiFeatureWorkspaceOptions {
|
|
7
|
+
/** Kebab-case feature slug used for file paths and route ids. */
|
|
8
|
+
aiFeatureSlug: string;
|
|
9
|
+
/** Compatibility metadata applied to the generated workspace bootstrap. */
|
|
10
|
+
compatibilityPolicy: ScaffoldCompatibilityPolicy;
|
|
11
|
+
/** WordPress REST namespace used for generated feature routes. */
|
|
12
|
+
namespace: string;
|
|
13
|
+
/** Resolved workspace metadata and filesystem paths for the target project. */
|
|
14
|
+
workspace: WorkspaceProject;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Write generated AI feature sources and patch shared workspace anchors.
|
|
18
|
+
*/
|
|
19
|
+
export declare function scaffoldAiFeatureWorkspace({ aiFeatureSlug, compatibilityPolicy, namespace, workspace, }: ScaffoldAiFeatureWorkspaceOptions): Promise<{
|
|
20
|
+
warnings: string[];
|
|
21
|
+
}>;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { promises as fsp } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { ensureBlockConfigCanAddRestManifests } from "./cli-add-block-legacy-validator.js";
|
|
4
|
+
import { buildAiFeatureConfigEntry, buildAiFeatureDataSource, buildAiFeatureSyncScriptSource, buildAiFeatureTypesSource, buildAiFeatureValidatorsSource, buildAiFeatureApiSource, } from "./cli-add-workspace-ai-source-emitters.js";
|
|
5
|
+
import { ensureAiFeatureBootstrapAnchors, ensureAiFeaturePackageScripts, ensureAiFeatureSyncProjectAnchors, ensureAiFeatureSyncRestAnchors, } from "./cli-add-workspace-ai-anchors.js";
|
|
6
|
+
import { buildAiFeaturePhpSource } from "./cli-add-workspace-ai-templates.js";
|
|
7
|
+
import { appendWorkspaceInventoryEntries } from "./workspace-inventory.js";
|
|
8
|
+
import { getWorkspaceBootstrapPath, patchFile, } from "./cli-add-shared.js";
|
|
9
|
+
import { executeWorkspaceMutationPlan } from "./cli-add-workspace-mutation.js";
|
|
10
|
+
import { updatePluginHeaderCompatibility } from "./scaffold-compatibility.js";
|
|
11
|
+
import { toPascalCase, toTitleCase } from "./string-case.js";
|
|
12
|
+
import { syncAiFeatureRestArtifacts, syncAiFeatureSchemaArtifact, } from "./ai-feature-artifacts.js";
|
|
13
|
+
/**
|
|
14
|
+
* Write generated AI feature sources and patch shared workspace anchors.
|
|
15
|
+
*/
|
|
16
|
+
export async function scaffoldAiFeatureWorkspace({ aiFeatureSlug, compatibilityPolicy, namespace, workspace, }) {
|
|
17
|
+
const blockConfigPath = path.join(workspace.projectDir, "scripts", "block-config.ts");
|
|
18
|
+
const bootstrapPath = getWorkspaceBootstrapPath(workspace);
|
|
19
|
+
const packageJsonPath = path.join(workspace.projectDir, "package.json");
|
|
20
|
+
const syncAiScriptPath = path.join(workspace.projectDir, "scripts", "sync-ai-features.ts");
|
|
21
|
+
const syncProjectScriptPath = path.join(workspace.projectDir, "scripts", "sync-project.ts");
|
|
22
|
+
const syncRestScriptPath = path.join(workspace.projectDir, "scripts", "sync-rest-contracts.ts");
|
|
23
|
+
const aiFeatureDir = path.join(workspace.projectDir, "src", "ai-features", aiFeatureSlug);
|
|
24
|
+
const typesFilePath = path.join(aiFeatureDir, "api-types.ts");
|
|
25
|
+
const validatorsFilePath = path.join(aiFeatureDir, "api-validators.ts");
|
|
26
|
+
const apiFilePath = path.join(aiFeatureDir, "api.ts");
|
|
27
|
+
const dataFilePath = path.join(aiFeatureDir, "data.ts");
|
|
28
|
+
const phpFilePath = path.join(workspace.projectDir, "inc", "ai-features", `${aiFeatureSlug}.php`);
|
|
29
|
+
return executeWorkspaceMutationPlan({
|
|
30
|
+
filePaths: [
|
|
31
|
+
blockConfigPath,
|
|
32
|
+
bootstrapPath,
|
|
33
|
+
packageJsonPath,
|
|
34
|
+
syncAiScriptPath,
|
|
35
|
+
syncProjectScriptPath,
|
|
36
|
+
syncRestScriptPath,
|
|
37
|
+
],
|
|
38
|
+
targetPaths: [aiFeatureDir, phpFilePath, syncAiScriptPath],
|
|
39
|
+
run: async () => {
|
|
40
|
+
await fsp.mkdir(aiFeatureDir, { recursive: true });
|
|
41
|
+
await fsp.mkdir(path.dirname(phpFilePath), { recursive: true });
|
|
42
|
+
await ensureAiFeatureBootstrapAnchors(workspace);
|
|
43
|
+
await patchFile(bootstrapPath, (source) => updatePluginHeaderCompatibility(source, compatibilityPolicy));
|
|
44
|
+
const packageScriptChanges = await ensureAiFeaturePackageScripts(workspace);
|
|
45
|
+
await ensureAiFeatureSyncProjectAnchors(workspace);
|
|
46
|
+
await ensureAiFeatureSyncRestAnchors(workspace);
|
|
47
|
+
await fsp.writeFile(syncAiScriptPath, buildAiFeatureSyncScriptSource(), "utf8");
|
|
48
|
+
await fsp.writeFile(typesFilePath, buildAiFeatureTypesSource(aiFeatureSlug), "utf8");
|
|
49
|
+
await fsp.writeFile(validatorsFilePath, buildAiFeatureValidatorsSource(aiFeatureSlug), "utf8");
|
|
50
|
+
await fsp.writeFile(apiFilePath, buildAiFeatureApiSource(aiFeatureSlug), "utf8");
|
|
51
|
+
await fsp.writeFile(dataFilePath, buildAiFeatureDataSource(aiFeatureSlug), "utf8");
|
|
52
|
+
await fsp.writeFile(phpFilePath, buildAiFeaturePhpSource(aiFeatureSlug, namespace, workspace.workspace.phpPrefix, workspace.workspace.textDomain), "utf8");
|
|
53
|
+
const pascalCase = toPascalCase(aiFeatureSlug);
|
|
54
|
+
await syncAiFeatureRestArtifacts({
|
|
55
|
+
clientFile: `src/ai-features/${aiFeatureSlug}/api-client.ts`,
|
|
56
|
+
outputDir: path.join("src", "ai-features", aiFeatureSlug),
|
|
57
|
+
projectDir: workspace.projectDir,
|
|
58
|
+
typesFile: `src/ai-features/${aiFeatureSlug}/api-types.ts`,
|
|
59
|
+
validatorsFile: `src/ai-features/${aiFeatureSlug}/api-validators.ts`,
|
|
60
|
+
variables: {
|
|
61
|
+
namespace,
|
|
62
|
+
pascalCase,
|
|
63
|
+
slugKebabCase: aiFeatureSlug,
|
|
64
|
+
title: toTitleCase(aiFeatureSlug),
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
await syncAiFeatureSchemaArtifact({
|
|
68
|
+
aiSchemaFile: `src/ai-features/${aiFeatureSlug}/ai-schemas/feature-result.ai.schema.json`,
|
|
69
|
+
outputDir: path.join("src", "ai-features", aiFeatureSlug),
|
|
70
|
+
projectDir: workspace.projectDir,
|
|
71
|
+
});
|
|
72
|
+
await appendWorkspaceInventoryEntries(workspace.projectDir, {
|
|
73
|
+
aiFeatureEntries: [
|
|
74
|
+
buildAiFeatureConfigEntry(aiFeatureSlug, namespace),
|
|
75
|
+
],
|
|
76
|
+
transformSource: ensureBlockConfigCanAddRestManifests,
|
|
77
|
+
});
|
|
78
|
+
return {
|
|
79
|
+
warnings: packageScriptChanges.addedProjectToolsDependency
|
|
80
|
+
? [
|
|
81
|
+
"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`.",
|
|
82
|
+
]
|
|
83
|
+
: [],
|
|
84
|
+
};
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
}
|