@wp-typia/project-tools 0.23.0 → 0.24.0
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/ai-feature-artifacts.js +4 -1
- package/dist/runtime/block-generator-service-spec.js +2 -1
- package/dist/runtime/built-in-block-non-ts-basic-artifacts.d.ts +9 -0
- package/dist/runtime/built-in-block-non-ts-basic-artifacts.js +84 -0
- package/dist/runtime/built-in-block-non-ts-compound-artifacts.d.ts +9 -0
- package/dist/runtime/built-in-block-non-ts-compound-artifacts.js +36 -0
- package/dist/runtime/built-in-block-non-ts-compound-templates.d.ts +23 -0
- package/dist/runtime/built-in-block-non-ts-compound-templates.js +453 -0
- package/dist/runtime/built-in-block-non-ts-family-artifacts.d.ts +8 -26
- package/dist/runtime/built-in-block-non-ts-family-artifacts.js +8 -1034
- package/dist/runtime/built-in-block-non-ts-interactivity-artifacts.d.ts +9 -0
- package/dist/runtime/built-in-block-non-ts-interactivity-artifacts.js +83 -0
- package/dist/runtime/built-in-block-non-ts-persistence-artifacts.d.ts +9 -0
- package/dist/runtime/built-in-block-non-ts-persistence-artifacts.js +33 -0
- package/dist/runtime/built-in-block-non-ts-persistence-templates.d.ts +23 -0
- package/dist/runtime/built-in-block-non-ts-persistence-templates.js +395 -0
- package/dist/runtime/cli-add-block-json.js +5 -1
- package/dist/runtime/cli-add-collision.js +8 -0
- package/dist/runtime/cli-add-help.js +14 -10
- package/dist/runtime/cli-add-kind-ids.d.ts +1 -1
- package/dist/runtime/cli-add-kind-ids.js +1 -0
- package/dist/runtime/cli-add-types.d.ts +45 -6
- package/dist/runtime/cli-add-types.js +2 -0
- package/dist/runtime/cli-add-validation.d.ts +7 -0
- package/dist/runtime/cli-add-validation.js +9 -0
- package/dist/runtime/cli-add-workspace-ability-anchors.d.ts +24 -0
- package/dist/runtime/cli-add-workspace-ability-anchors.js +294 -0
- package/dist/runtime/cli-add-workspace-ability-registry.d.ts +10 -0
- package/dist/runtime/cli-add-workspace-ability-registry.js +51 -0
- package/dist/runtime/cli-add-workspace-ability-scaffold.d.ts +1 -1
- package/dist/runtime/cli-add-workspace-ability-scaffold.js +5 -308
- package/dist/runtime/cli-add-workspace-admin-view-scaffold.js +6 -2
- package/dist/runtime/cli-add-workspace-admin-view-templates-core-data.d.ts +34 -0
- package/dist/runtime/cli-add-workspace-admin-view-templates-core-data.js +483 -0
- package/dist/runtime/cli-add-workspace-admin-view-templates-default.d.ts +30 -0
- package/dist/runtime/cli-add-workspace-admin-view-templates-default.js +310 -0
- package/dist/runtime/cli-add-workspace-admin-view-templates-rest.d.ts +25 -0
- package/dist/runtime/cli-add-workspace-admin-view-templates-rest.js +124 -0
- package/dist/runtime/cli-add-workspace-admin-view-templates-settings.d.ts +34 -0
- package/dist/runtime/cli-add-workspace-admin-view-templates-settings.js +370 -0
- package/dist/runtime/cli-add-workspace-admin-view-templates-shared.d.ts +49 -0
- package/dist/runtime/cli-add-workspace-admin-view-templates-shared.js +259 -0
- package/dist/runtime/cli-add-workspace-admin-view-templates.d.ts +18 -27
- package/dist/runtime/cli-add-workspace-admin-view-templates.js +30 -1326
- package/dist/runtime/cli-add-workspace-ai-anchors.d.ts +4 -4
- package/dist/runtime/cli-add-workspace-ai-anchors.js +8 -233
- package/dist/runtime/cli-add-workspace-ai-scaffold.js +4 -2
- package/dist/runtime/cli-add-workspace-ai-source-emitters.d.ts +1 -4
- package/dist/runtime/cli-add-workspace-ai-source-emitters.js +1 -129
- package/dist/runtime/cli-add-workspace-ai-sync-rest-anchors.d.ts +5 -0
- package/dist/runtime/cli-add-workspace-ai-sync-rest-anchors.js +236 -0
- package/dist/runtime/cli-add-workspace-ai-sync-script-source.d.ts +4 -0
- package/dist/runtime/cli-add-workspace-ai-sync-script-source.js +145 -0
- package/dist/runtime/cli-add-workspace-assets.d.ts +6 -63
- package/dist/runtime/cli-add-workspace-assets.js +6 -950
- package/dist/runtime/cli-add-workspace-binding-source-anchors.d.ts +23 -0
- package/dist/runtime/cli-add-workspace-binding-source-anchors.js +112 -0
- package/dist/runtime/cli-add-workspace-binding-source-source-emitters.d.ts +33 -0
- package/dist/runtime/cli-add-workspace-binding-source-source-emitters.js +436 -0
- package/dist/runtime/cli-add-workspace-binding-source-types.d.ts +20 -0
- package/dist/runtime/cli-add-workspace-binding-source-types.js +1 -0
- package/dist/runtime/cli-add-workspace-binding-source.d.ts +40 -0
- package/dist/runtime/cli-add-workspace-binding-source.js +275 -0
- package/dist/runtime/cli-add-workspace-block-style.d.ts +22 -0
- package/dist/runtime/cli-add-workspace-block-style.js +148 -0
- package/dist/runtime/cli-add-workspace-block-transform.d.ts +32 -0
- package/dist/runtime/cli-add-workspace-block-transform.js +197 -0
- package/dist/runtime/cli-add-workspace-contract.js +1 -1
- package/dist/runtime/cli-add-workspace-core-variation.d.ts +20 -0
- package/dist/runtime/cli-add-workspace-core-variation.js +322 -0
- package/dist/runtime/cli-add-workspace-editor-plugin-anchors.d.ts +37 -0
- package/dist/runtime/cli-add-workspace-editor-plugin-anchors.js +206 -0
- package/dist/runtime/cli-add-workspace-editor-plugin-source-emitters.d.ts +47 -0
- package/dist/runtime/cli-add-workspace-editor-plugin-source-emitters.js +219 -0
- package/dist/runtime/cli-add-workspace-editor-plugin.d.ts +22 -0
- package/dist/runtime/cli-add-workspace-editor-plugin.js +78 -0
- package/dist/runtime/cli-add-workspace-hooked-block.d.ts +23 -0
- package/dist/runtime/cli-add-workspace-hooked-block.js +57 -0
- package/dist/runtime/cli-add-workspace-integration-env-files.d.ts +33 -0
- package/dist/runtime/cli-add-workspace-integration-env-files.js +65 -0
- package/dist/runtime/cli-add-workspace-integration-env-package-json.d.ts +38 -0
- package/dist/runtime/cli-add-workspace-integration-env-package-json.js +122 -0
- package/dist/runtime/cli-add-workspace-integration-env-source-emitters.d.ts +44 -0
- package/dist/runtime/cli-add-workspace-integration-env-source-emitters.js +262 -0
- package/dist/runtime/cli-add-workspace-integration-env.d.ts +3 -1
- package/dist/runtime/cli-add-workspace-integration-env.js +10 -313
- package/dist/runtime/cli-add-workspace-pattern-anchors.d.ts +10 -0
- package/dist/runtime/cli-add-workspace-pattern-anchors.js +95 -0
- package/dist/runtime/cli-add-workspace-pattern-options.d.ts +20 -0
- package/dist/runtime/cli-add-workspace-pattern-options.js +113 -0
- package/dist/runtime/cli-add-workspace-pattern-source-emitters.d.ts +20 -0
- package/dist/runtime/cli-add-workspace-pattern-source-emitters.js +57 -0
- package/dist/runtime/cli-add-workspace-pattern.d.ts +42 -0
- package/dist/runtime/cli-add-workspace-pattern.js +99 -0
- package/dist/runtime/cli-add-workspace-post-meta.js +1 -1
- package/dist/runtime/cli-add-workspace-registration-hooks.d.ts +50 -0
- package/dist/runtime/cli-add-workspace-registration-hooks.js +162 -0
- package/dist/runtime/cli-add-workspace-rest-anchors.d.ts +9 -4
- package/dist/runtime/cli-add-workspace-rest-anchors.js +9 -428
- package/dist/runtime/cli-add-workspace-rest-bootstrap-anchors.d.ts +17 -0
- package/dist/runtime/cli-add-workspace-rest-bootstrap-anchors.js +108 -0
- package/dist/runtime/cli-add-workspace-rest-contract-sync-anchors.d.ts +9 -0
- package/dist/runtime/cli-add-workspace-rest-contract-sync-anchors.js +142 -0
- package/dist/runtime/cli-add-workspace-rest-generated-source-emitters.d.ts +51 -0
- package/dist/runtime/cli-add-workspace-rest-generated-source-emitters.js +415 -0
- package/dist/runtime/cli-add-workspace-rest-generated.d.ts +9 -0
- package/dist/runtime/cli-add-workspace-rest-generated.js +160 -0
- package/dist/runtime/cli-add-workspace-rest-manual-source-emitters.d.ts +80 -0
- package/dist/runtime/cli-add-workspace-rest-manual-source-emitters.js +238 -0
- package/dist/runtime/cli-add-workspace-rest-manual.d.ts +8 -0
- package/dist/runtime/cli-add-workspace-rest-manual.js +266 -0
- package/dist/runtime/cli-add-workspace-rest-php-templates.d.ts +18 -0
- package/dist/runtime/cli-add-workspace-rest-php-templates.js +359 -0
- package/dist/runtime/cli-add-workspace-rest-resource-php-routing-template.d.ts +33 -0
- package/dist/runtime/cli-add-workspace-rest-resource-php-routing-template.js +145 -0
- package/dist/runtime/cli-add-workspace-rest-resource-sync-anchors.d.ts +9 -0
- package/dist/runtime/cli-add-workspace-rest-resource-sync-anchors.js +162 -0
- package/dist/runtime/cli-add-workspace-rest-schema-helper-php-template.d.ts +7 -0
- package/dist/runtime/cli-add-workspace-rest-schema-helper-php-template.js +193 -0
- package/dist/runtime/cli-add-workspace-rest-source-emitters.d.ts +5 -91
- package/dist/runtime/cli-add-workspace-rest-source-emitters.js +5 -642
- package/dist/runtime/cli-add-workspace-rest-source-utils.d.ts +17 -0
- package/dist/runtime/cli-add-workspace-rest-source-utils.js +50 -0
- package/dist/runtime/cli-add-workspace-rest-sync-script-shared.d.ts +56 -0
- package/dist/runtime/cli-add-workspace-rest-sync-script-shared.js +122 -0
- package/dist/runtime/cli-add-workspace-rest-types.d.ts +108 -0
- package/dist/runtime/cli-add-workspace-rest-types.js +1 -0
- package/dist/runtime/cli-add-workspace-rest.d.ts +3 -20
- package/dist/runtime/cli-add-workspace-rest.js +33 -788
- package/dist/runtime/cli-add-workspace-variation.d.ts +22 -0
- package/dist/runtime/cli-add-workspace-variation.js +162 -0
- package/dist/runtime/cli-add-workspace.d.ts +42 -107
- package/dist/runtime/cli-add-workspace.js +42 -674
- package/dist/runtime/cli-add.d.ts +3 -3
- package/dist/runtime/cli-add.js +2 -2
- package/dist/runtime/cli-core.d.ts +3 -2
- package/dist/runtime/cli-core.js +2 -2
- package/dist/runtime/cli-diagnostics.d.ts +3 -1
- package/dist/runtime/cli-diagnostics.js +17 -5
- package/dist/runtime/cli-doctor-workspace-bindings.js +63 -1
- package/dist/runtime/cli-doctor-workspace-block-addons.d.ts +12 -0
- package/dist/runtime/cli-doctor-workspace-block-addons.js +162 -0
- package/dist/runtime/cli-doctor-workspace-block-iframe.d.ts +9 -0
- package/dist/runtime/cli-doctor-workspace-block-iframe.js +228 -0
- package/dist/runtime/cli-doctor-workspace-block-metadata.d.ts +11 -0
- package/dist/runtime/cli-doctor-workspace-block-metadata.js +111 -0
- package/dist/runtime/cli-doctor-workspace-blocks.js +6 -424
- package/dist/runtime/cli-doctor-workspace-features-abilities.d.ts +11 -0
- package/dist/runtime/cli-doctor-workspace-features-abilities.js +112 -0
- package/dist/runtime/cli-doctor-workspace-features-admin-views.d.ts +11 -0
- package/dist/runtime/cli-doctor-workspace-features-admin-views.js +128 -0
- package/dist/runtime/cli-doctor-workspace-features-ai.d.ts +11 -0
- package/dist/runtime/cli-doctor-workspace-features-ai.js +57 -0
- package/dist/runtime/cli-doctor-workspace-features-editor-plugins.d.ts +11 -0
- package/dist/runtime/cli-doctor-workspace-features-editor-plugins.js +80 -0
- package/dist/runtime/cli-doctor-workspace-features-post-meta.d.ts +11 -0
- package/dist/runtime/cli-doctor-workspace-features-post-meta.js +77 -0
- package/dist/runtime/cli-doctor-workspace-features-rest.d.ts +11 -0
- package/dist/runtime/cli-doctor-workspace-features-rest.js +120 -0
- package/dist/runtime/cli-doctor-workspace-features.js +14 -487
- package/dist/runtime/cli-doctor.d.ts +54 -3
- package/dist/runtime/cli-doctor.js +92 -10
- package/dist/runtime/cli-help.js +12 -7
- package/dist/runtime/cli-init-package-json.js +4 -2
- package/dist/runtime/cli-prompt.d.ts +16 -2
- package/dist/runtime/cli-prompt.js +29 -12
- package/dist/runtime/cli-scaffold.d.ts +2 -1
- package/dist/runtime/cli-scaffold.js +19 -10
- package/dist/runtime/external-template-guards.js +4 -6
- package/dist/runtime/index.d.ts +6 -3
- package/dist/runtime/index.js +4 -2
- package/dist/runtime/json-utils.d.ts +62 -4
- package/dist/runtime/json-utils.js +78 -4
- package/dist/runtime/local-dev-presets.js +6 -2
- package/dist/runtime/migration-ui-capability.js +4 -1
- package/dist/runtime/migration-utils.js +4 -1
- package/dist/runtime/package-managers.js +6 -1
- package/dist/runtime/package-versions.d.ts +1 -0
- package/dist/runtime/package-versions.js +16 -3
- package/dist/runtime/pattern-catalog.d.ts +122 -0
- package/dist/runtime/pattern-catalog.js +471 -0
- package/dist/runtime/post-meta-binding-fields.d.ts +46 -0
- package/dist/runtime/post-meta-binding-fields.js +135 -0
- package/dist/runtime/scaffold-bootstrap.js +7 -2
- package/dist/runtime/scaffold-package-manager-files.js +5 -1
- package/dist/runtime/scaffold-repository-reference.js +4 -2
- package/dist/runtime/scaffold-template-variables.js +2 -1
- package/dist/runtime/scaffold.d.ts +18 -1
- package/dist/runtime/scaffold.js +55 -2
- package/dist/runtime/temp-roots.js +4 -1
- package/dist/runtime/template-layers.js +4 -1
- package/dist/runtime/template-registry.js +9 -3
- package/dist/runtime/template-source-contracts.d.ts +2 -0
- package/dist/runtime/template-source-normalization.js +2 -1
- package/dist/runtime/template-source-remote.js +18 -5
- package/dist/runtime/template-source-seeds.js +10 -3
- package/dist/runtime/typia-llm-json-schema.d.ts +24 -0
- package/dist/runtime/typia-llm-json-schema.js +33 -0
- package/dist/runtime/typia-llm-openapi-constraints.d.ts +20 -0
- package/dist/runtime/typia-llm-openapi-constraints.js +254 -0
- package/dist/runtime/typia-llm-projection.d.ts +25 -0
- package/dist/runtime/typia-llm-projection.js +58 -0
- package/dist/runtime/typia-llm-render.d.ts +21 -0
- package/dist/runtime/typia-llm-render.js +252 -0
- package/dist/runtime/typia-llm-sync.d.ts +10 -0
- package/dist/runtime/typia-llm-sync.js +63 -0
- package/dist/runtime/typia-llm-types.d.ts +197 -0
- package/dist/runtime/typia-llm-types.js +1 -0
- package/dist/runtime/typia-llm.d.ts +9 -255
- package/dist/runtime/typia-llm.js +5 -634
- package/dist/runtime/workspace-inventory-mutations.js +15 -1
- package/dist/runtime/workspace-inventory-parser-entries.d.ts +17 -0
- package/dist/runtime/workspace-inventory-parser-entries.js +157 -0
- package/dist/runtime/workspace-inventory-parser-validation.d.ts +104 -0
- package/dist/runtime/workspace-inventory-parser-validation.js +34 -0
- package/dist/runtime/workspace-inventory-parser.d.ts +3 -45
- package/dist/runtime/workspace-inventory-parser.js +3 -581
- package/dist/runtime/workspace-inventory-section-descriptors.d.ts +19 -0
- package/dist/runtime/workspace-inventory-section-descriptors.js +443 -0
- package/dist/runtime/workspace-inventory-templates.d.ts +3 -3
- package/dist/runtime/workspace-inventory-templates.js +10 -1
- package/dist/runtime/workspace-inventory-types.d.ts +10 -1
- package/dist/runtime/workspace-project.js +4 -6
- package/package.json +8 -3
- package/templates/_shared/compound/core/scripts/block-config.ts.mustache +22 -0
- package/templates/_shared/compound/core/scripts/sync-types-to-block-json.ts.mustache +103 -2
- package/templates/_shared/compound/core/src/inner-blocks-templates.ts.mustache +13 -0
- package/templates/_shared/compound/persistence/scripts/block-config.ts.mustache +22 -1
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type RunAddVariationCommandOptions } from "./cli-add-shared.js";
|
|
2
|
+
/**
|
|
3
|
+
* Add one variation entry to an existing workspace block.
|
|
4
|
+
*
|
|
5
|
+
* @param options Command options for the variation scaffold workflow.
|
|
6
|
+
* @param options.blockName Target workspace block slug that will own the variation.
|
|
7
|
+
* @param options.cwd Working directory used to resolve the nearest official workspace.
|
|
8
|
+
* Defaults to `process.cwd()`.
|
|
9
|
+
* @param options.variationName Human-entered variation name that will be normalized
|
|
10
|
+
* and validated before files are written.
|
|
11
|
+
* @returns A promise that resolves with the normalized `blockSlug`,
|
|
12
|
+
* `variationSlug`, and owning `projectDir` after the variation files and
|
|
13
|
+
* inventory entry have been written successfully.
|
|
14
|
+
* @throws {Error} When the command is run outside an official workspace, when
|
|
15
|
+
* the target block is unknown, when the variation slug is invalid, or when a
|
|
16
|
+
* conflicting file or inventory entry already exists.
|
|
17
|
+
*/
|
|
18
|
+
export declare function runAddVariationCommand({ blockName, cwd, variationName, }: RunAddVariationCommandOptions): Promise<{
|
|
19
|
+
blockSlug: string;
|
|
20
|
+
projectDir: string;
|
|
21
|
+
variationSlug: string;
|
|
22
|
+
}>;
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { promises as fsp } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { pathExists } from "./fs-async.js";
|
|
4
|
+
import { assertVariationDoesNotExist, assertValidGeneratedSlug, normalizeBlockSlug, quoteTsString, resolveWorkspaceBlock, rollbackWorkspaceMutation, snapshotWorkspaceFiles, } from "./cli-add-shared.js";
|
|
5
|
+
import { ensureWorkspaceEntrypointCall } from "./cli-add-workspace-registration-hooks.js";
|
|
6
|
+
import { appendWorkspaceInventoryEntries, readWorkspaceInventoryAsync, } from "./workspace-inventory.js";
|
|
7
|
+
import { resolveWorkspaceProject } from "./workspace-project.js";
|
|
8
|
+
import { toKebabCase, toTitleCase } from "./string-case.js";
|
|
9
|
+
const VARIATIONS_IMPORT_LINE = "import { registerWorkspaceVariations } from './variations';";
|
|
10
|
+
const VARIATIONS_IMPORT_PATTERN = /^\s*import\s*\{\s*registerWorkspaceVariations\s*\}\s*from\s*["']\.\/variations["']\s*;?\s*$/mu;
|
|
11
|
+
const VARIATIONS_CALL_LINE = "registerWorkspaceVariations();";
|
|
12
|
+
const VARIATIONS_CALL_PATTERN = /registerWorkspaceVariations\s*\(\s*\)\s*;?/u;
|
|
13
|
+
function buildVariationConfigEntry(blockSlug, variationSlug) {
|
|
14
|
+
return [
|
|
15
|
+
"\t{",
|
|
16
|
+
`\t\tblock: ${quoteTsString(blockSlug)},`,
|
|
17
|
+
`\t\tfile: ${quoteTsString(`src/blocks/${blockSlug}/variations/${variationSlug}.ts`)},`,
|
|
18
|
+
`\t\tslug: ${quoteTsString(variationSlug)},`,
|
|
19
|
+
"\t},",
|
|
20
|
+
].join("\n");
|
|
21
|
+
}
|
|
22
|
+
function buildVariationConstName(variationSlug) {
|
|
23
|
+
const identifierSegments = toKebabCase(variationSlug)
|
|
24
|
+
.split("-")
|
|
25
|
+
.filter(Boolean);
|
|
26
|
+
return `workspaceVariation_${identifierSegments.join("_")}`;
|
|
27
|
+
}
|
|
28
|
+
function getVariationConstBindings(variationSlugs) {
|
|
29
|
+
const seenConstNames = new Map();
|
|
30
|
+
return variationSlugs.map((variationSlug) => {
|
|
31
|
+
const constName = buildVariationConstName(variationSlug);
|
|
32
|
+
const previousSlug = seenConstNames.get(constName);
|
|
33
|
+
if (previousSlug && previousSlug !== variationSlug) {
|
|
34
|
+
throw new Error(`Variation slugs "${previousSlug}" and "${variationSlug}" generate the same registry identifier "${constName}". Rename one of the variations.`);
|
|
35
|
+
}
|
|
36
|
+
seenConstNames.set(constName, variationSlug);
|
|
37
|
+
return { constName, variationSlug };
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
function buildVariationSource(variationSlug, textDomain) {
|
|
41
|
+
const variationTitle = toTitleCase(variationSlug);
|
|
42
|
+
const variationConstName = buildVariationConstName(variationSlug);
|
|
43
|
+
return `import type { BlockVariation } from '@wp-typia/block-types/blocks/registration';
|
|
44
|
+
import { __ } from '@wordpress/i18n';
|
|
45
|
+
|
|
46
|
+
export const ${variationConstName} = {
|
|
47
|
+
\tname: ${quoteTsString(variationSlug)},
|
|
48
|
+
\ttitle: __( ${quoteTsString(variationTitle)}, ${quoteTsString(textDomain)} ),
|
|
49
|
+
\tdescription: __(
|
|
50
|
+
\t\t${quoteTsString(`A starter variation for ${variationTitle}.`)},
|
|
51
|
+
\t\t${quoteTsString(textDomain)},
|
|
52
|
+
\t),
|
|
53
|
+
\tattributes: {},
|
|
54
|
+
\tscope: ['inserter'],
|
|
55
|
+
} satisfies BlockVariation;
|
|
56
|
+
`;
|
|
57
|
+
}
|
|
58
|
+
function buildVariationIndexSource(variationSlugs) {
|
|
59
|
+
const variationBindings = getVariationConstBindings(variationSlugs);
|
|
60
|
+
const importLines = variationBindings
|
|
61
|
+
.map(({ constName, variationSlug }) => {
|
|
62
|
+
return `import { ${constName} } from './${variationSlug}';`;
|
|
63
|
+
})
|
|
64
|
+
.join("\n");
|
|
65
|
+
const variationConstNames = variationBindings
|
|
66
|
+
.map(({ constName }) => constName)
|
|
67
|
+
.join(",\n\t\t");
|
|
68
|
+
return `import { registerBlockVariation } from '@wordpress/blocks';
|
|
69
|
+
import metadata from '../block.json';
|
|
70
|
+
${importLines ? `\n${importLines}` : ""}
|
|
71
|
+
|
|
72
|
+
const WORKSPACE_VARIATIONS = [
|
|
73
|
+
\t${variationConstNames}
|
|
74
|
+
\t// wp-typia add variation entries
|
|
75
|
+
];
|
|
76
|
+
|
|
77
|
+
export function registerWorkspaceVariations() {
|
|
78
|
+
\tfor (const variation of WORKSPACE_VARIATIONS) {
|
|
79
|
+
\t\tregisterBlockVariation(metadata.name, variation);
|
|
80
|
+
\t}
|
|
81
|
+
}
|
|
82
|
+
`;
|
|
83
|
+
}
|
|
84
|
+
async function ensureVariationRegistrationHook(blockIndexPath) {
|
|
85
|
+
await ensureWorkspaceEntrypointCall({
|
|
86
|
+
blockIndexPath,
|
|
87
|
+
callLine: VARIATIONS_CALL_LINE,
|
|
88
|
+
callPattern: VARIATIONS_CALL_PATTERN,
|
|
89
|
+
importLine: VARIATIONS_IMPORT_LINE,
|
|
90
|
+
importPattern: VARIATIONS_IMPORT_PATTERN,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
async function writeVariationRegistry(projectDir, blockSlug, variationSlug) {
|
|
94
|
+
const variationsDir = path.join(projectDir, "src", "blocks", blockSlug, "variations");
|
|
95
|
+
const variationsIndexPath = path.join(variationsDir, "index.ts");
|
|
96
|
+
await fsp.mkdir(variationsDir, { recursive: true });
|
|
97
|
+
const existingVariationSlugs = (await fsp.readdir(variationsDir))
|
|
98
|
+
.filter((entry) => entry.endsWith(".ts") && entry !== "index.ts")
|
|
99
|
+
.map((entry) => entry.replace(/\.ts$/u, ""));
|
|
100
|
+
const nextVariationSlugs = Array.from(new Set([...existingVariationSlugs, variationSlug])).sort();
|
|
101
|
+
await fsp.writeFile(variationsIndexPath, buildVariationIndexSource(nextVariationSlugs), "utf8");
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Add one variation entry to an existing workspace block.
|
|
105
|
+
*
|
|
106
|
+
* @param options Command options for the variation scaffold workflow.
|
|
107
|
+
* @param options.blockName Target workspace block slug that will own the variation.
|
|
108
|
+
* @param options.cwd Working directory used to resolve the nearest official workspace.
|
|
109
|
+
* Defaults to `process.cwd()`.
|
|
110
|
+
* @param options.variationName Human-entered variation name that will be normalized
|
|
111
|
+
* and validated before files are written.
|
|
112
|
+
* @returns A promise that resolves with the normalized `blockSlug`,
|
|
113
|
+
* `variationSlug`, and owning `projectDir` after the variation files and
|
|
114
|
+
* inventory entry have been written successfully.
|
|
115
|
+
* @throws {Error} When the command is run outside an official workspace, when
|
|
116
|
+
* the target block is unknown, when the variation slug is invalid, or when a
|
|
117
|
+
* conflicting file or inventory entry already exists.
|
|
118
|
+
*/
|
|
119
|
+
export async function runAddVariationCommand({ blockName, cwd = process.cwd(), variationName, }) {
|
|
120
|
+
const workspace = resolveWorkspaceProject(cwd);
|
|
121
|
+
const blockSlug = normalizeBlockSlug(blockName);
|
|
122
|
+
const variationSlug = assertValidGeneratedSlug("Variation name", normalizeBlockSlug(variationName), "wp-typia add variation <name> --block <block-slug>");
|
|
123
|
+
const inventory = await readWorkspaceInventoryAsync(workspace.projectDir);
|
|
124
|
+
resolveWorkspaceBlock(inventory, blockSlug);
|
|
125
|
+
assertVariationDoesNotExist(workspace.projectDir, blockSlug, variationSlug, inventory);
|
|
126
|
+
const blockConfigPath = path.join(workspace.projectDir, "scripts", "block-config.ts");
|
|
127
|
+
const blockIndexPath = path.join(workspace.projectDir, "src", "blocks", blockSlug, "index.tsx");
|
|
128
|
+
const variationsDir = path.join(workspace.projectDir, "src", "blocks", blockSlug, "variations");
|
|
129
|
+
const variationFilePath = path.join(variationsDir, `${variationSlug}.ts`);
|
|
130
|
+
const variationsIndexPath = path.join(variationsDir, "index.ts");
|
|
131
|
+
const shouldRemoveVariationsDirOnRollback = !(await pathExists(variationsDir));
|
|
132
|
+
const mutationSnapshot = {
|
|
133
|
+
fileSources: await snapshotWorkspaceFiles([
|
|
134
|
+
blockConfigPath,
|
|
135
|
+
blockIndexPath,
|
|
136
|
+
variationsIndexPath,
|
|
137
|
+
]),
|
|
138
|
+
snapshotDirs: [],
|
|
139
|
+
targetPaths: [
|
|
140
|
+
variationFilePath,
|
|
141
|
+
...(shouldRemoveVariationsDirOnRollback ? [variationsDir] : []),
|
|
142
|
+
],
|
|
143
|
+
};
|
|
144
|
+
try {
|
|
145
|
+
await fsp.mkdir(variationsDir, { recursive: true });
|
|
146
|
+
await fsp.writeFile(variationFilePath, buildVariationSource(variationSlug, workspace.workspace.textDomain), "utf8");
|
|
147
|
+
await writeVariationRegistry(workspace.projectDir, blockSlug, variationSlug);
|
|
148
|
+
await ensureVariationRegistrationHook(blockIndexPath);
|
|
149
|
+
await appendWorkspaceInventoryEntries(workspace.projectDir, {
|
|
150
|
+
variationEntries: [buildVariationConfigEntry(blockSlug, variationSlug)],
|
|
151
|
+
});
|
|
152
|
+
return {
|
|
153
|
+
blockSlug,
|
|
154
|
+
projectDir: workspace.projectDir,
|
|
155
|
+
variationSlug,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
catch (error) {
|
|
159
|
+
await rollbackWorkspaceMutation(mutationSnapshot);
|
|
160
|
+
throw error;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
@@ -1,136 +1,71 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Compatibility facade for workspace add commands.
|
|
3
|
+
*
|
|
4
|
+
* Keep the public runtime import path stable while each workflow lives in a
|
|
5
|
+
* focused implementation module.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Re-export the typed workflow ability scaffold workflow from the focused
|
|
9
|
+
* ability runtime helper module.
|
|
10
|
+
*/
|
|
11
|
+
export { runAddAbilityCommand } from "./cli-add-workspace-ability.js";
|
|
3
12
|
/**
|
|
4
13
|
* Re-export the DataViews admin screen scaffold workflow from the focused
|
|
5
14
|
* admin-view runtime helper module.
|
|
6
15
|
*/
|
|
7
|
-
export { runAddAdminViewCommand
|
|
16
|
+
export { runAddAdminViewCommand } from "./cli-add-workspace-admin-view.js";
|
|
17
|
+
/**
|
|
18
|
+
* Re-export the server-only AI feature scaffold workflow from the focused
|
|
19
|
+
* AI-feature runtime helper module.
|
|
20
|
+
*/
|
|
21
|
+
export { runAddAiFeatureCommand } from "./cli-add-workspace-ai.js";
|
|
8
22
|
/**
|
|
9
23
|
* Re-export focused workspace asset scaffold commands from the companion
|
|
10
24
|
* `cli-add-workspace-assets` module.
|
|
11
25
|
*/
|
|
12
|
-
export {
|
|
26
|
+
export { runAddBindingSourceCommand, runAddEditorPluginCommand, runAddPatternCommand, } from "./cli-add-workspace-assets.js";
|
|
13
27
|
/**
|
|
14
|
-
* Re-export the
|
|
15
|
-
*
|
|
28
|
+
* Re-export the block style scaffold workflow from the focused block-style
|
|
29
|
+
* runtime helper module.
|
|
16
30
|
*/
|
|
17
|
-
export {
|
|
31
|
+
export { runAddBlockStyleCommand } from "./cli-add-workspace-block-style.js";
|
|
18
32
|
/**
|
|
19
|
-
* Re-export the
|
|
20
|
-
*
|
|
33
|
+
* Re-export the block transform scaffold workflow from the focused
|
|
34
|
+
* block-transform runtime helper module.
|
|
21
35
|
*/
|
|
22
|
-
export {
|
|
36
|
+
export { runAddBlockTransformCommand, } from "./cli-add-workspace-block-transform.js";
|
|
23
37
|
/**
|
|
24
38
|
* Re-export the standalone contract scaffold workflow from the focused
|
|
25
39
|
* contract runtime helper module.
|
|
26
40
|
*/
|
|
27
41
|
export { runAddContractCommand } from "./cli-add-workspace-contract.js";
|
|
28
42
|
/**
|
|
29
|
-
* Re-export the
|
|
30
|
-
*
|
|
43
|
+
* Re-export the generic core/external block variation scaffold workflow from
|
|
44
|
+
* the focused core-variation runtime helper module.
|
|
31
45
|
*/
|
|
32
|
-
export {
|
|
46
|
+
export { runAddCoreVariationCommand } from "./cli-add-workspace-core-variation.js";
|
|
33
47
|
/**
|
|
34
|
-
* Re-export the
|
|
35
|
-
*
|
|
48
|
+
* Re-export the hooked-block scaffold workflow from the focused hooked-block
|
|
49
|
+
* runtime helper module.
|
|
36
50
|
*/
|
|
37
|
-
export {
|
|
51
|
+
export { runAddHookedBlockCommand } from "./cli-add-workspace-hooked-block.js";
|
|
38
52
|
/**
|
|
39
|
-
* Re-export the
|
|
40
|
-
*
|
|
41
|
-
*/
|
|
42
|
-
export { runAddAiFeatureCommand } from "./cli-add-workspace-ai.js";
|
|
43
|
-
/**
|
|
44
|
-
* Add one variation entry to an existing workspace block.
|
|
45
|
-
*
|
|
46
|
-
* @param options Command options for the variation scaffold workflow.
|
|
47
|
-
* @param options.blockName Target workspace block slug that will own the variation.
|
|
48
|
-
* @param options.cwd Working directory used to resolve the nearest official workspace.
|
|
49
|
-
* Defaults to `process.cwd()`.
|
|
50
|
-
* @param options.variationName Human-entered variation name that will be normalized
|
|
51
|
-
* and validated before files are written.
|
|
52
|
-
* @returns A promise that resolves with the normalized `blockSlug`,
|
|
53
|
-
* `variationSlug`, and owning `projectDir` after the variation files and
|
|
54
|
-
* inventory entry have been written successfully.
|
|
55
|
-
* @throws {Error} When the command is run outside an official workspace, when
|
|
56
|
-
* the target block is unknown, when the variation slug is invalid, or when a
|
|
57
|
-
* conflicting file or inventory entry already exists.
|
|
53
|
+
* Re-export the local integration environment scaffold workflow from the
|
|
54
|
+
* focused integration-env runtime helper module.
|
|
58
55
|
*/
|
|
59
|
-
export
|
|
60
|
-
blockSlug: string;
|
|
61
|
-
projectDir: string;
|
|
62
|
-
variationSlug: string;
|
|
63
|
-
}>;
|
|
56
|
+
export { runAddIntegrationEnvCommand } from "./cli-add-workspace-integration-env.js";
|
|
64
57
|
/**
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
* @param options Command options for the Block Styles scaffold workflow.
|
|
68
|
-
* @param options.blockName Target workspace block slug that will own the style.
|
|
69
|
-
* @param options.cwd Working directory used to resolve the nearest official workspace.
|
|
70
|
-
* Defaults to `process.cwd()`.
|
|
71
|
-
* @param options.styleName Human-entered style name that will be normalized and
|
|
72
|
-
* validated before files are written.
|
|
73
|
-
* @returns A promise that resolves with the normalized `blockSlug`, `styleSlug`,
|
|
74
|
-
* and owning `projectDir` after the style module, style registry, entrypoint
|
|
75
|
-
* hook, and inventory entry have been written successfully.
|
|
76
|
-
* @throws {Error} When the command is run outside an official workspace, when
|
|
77
|
-
* the target block is unknown, when the style slug is invalid, or when a
|
|
78
|
-
* conflicting file or inventory entry already exists.
|
|
58
|
+
* Re-export the typed post-meta contract scaffold workflow from the focused
|
|
59
|
+
* post-meta runtime helper module.
|
|
79
60
|
*/
|
|
80
|
-
export
|
|
81
|
-
blockSlug: string;
|
|
82
|
-
projectDir: string;
|
|
83
|
-
styleSlug: string;
|
|
84
|
-
}>;
|
|
61
|
+
export { runAddPostMetaCommand } from "./cli-add-workspace-post-meta.js";
|
|
85
62
|
/**
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
* @param options Command options for the block transform scaffold workflow.
|
|
89
|
-
* @param options.cwd Working directory used to resolve the nearest official workspace.
|
|
90
|
-
* Defaults to `process.cwd()`.
|
|
91
|
-
* @param options.fromBlockName Source block name for `--from`. This must be the
|
|
92
|
-
* full `namespace/block` form because transforms may originate from WordPress
|
|
93
|
-
* core or third-party blocks outside the workspace.
|
|
94
|
-
* @param options.toBlockName Target block for `--to`. A workspace block slug is
|
|
95
|
-
* resolved against the workspace namespace, while a full `namespace/block` name
|
|
96
|
-
* must still point at an existing workspace block.
|
|
97
|
-
* @param options.transformName Human-entered transform name that will be
|
|
98
|
-
* normalized and validated before files are written.
|
|
99
|
-
* @returns A promise that resolves with the normalized target `blockSlug`,
|
|
100
|
-
* resolved `fromBlockName`, resolved `toBlockName`, `transformSlug`, and owning
|
|
101
|
-
* `projectDir` after the transform module, transform registry, entrypoint hook,
|
|
102
|
-
* and inventory entry have been written successfully.
|
|
103
|
-
* @throws {Error} When the command is run outside an official workspace, when
|
|
104
|
-
* the target block is unknown, when `--from` is not a full block name, when
|
|
105
|
-
* `--to` uses a non-workspace namespace, when the target block entrypoint does
|
|
106
|
-
* not expose `registration.settings`, when the transform slug is invalid, or
|
|
107
|
-
* when a conflicting file or inventory entry already exists.
|
|
63
|
+
* Re-export the plugin-level REST resource scaffold workflow from the focused
|
|
64
|
+
* rest-resource runtime helper module.
|
|
108
65
|
*/
|
|
109
|
-
export
|
|
110
|
-
blockSlug: string;
|
|
111
|
-
fromBlockName: string;
|
|
112
|
-
projectDir: string;
|
|
113
|
-
toBlockName: string;
|
|
114
|
-
transformSlug: string;
|
|
115
|
-
}>;
|
|
66
|
+
export { runAddRestResourceCommand } from "./cli-add-workspace-rest.js";
|
|
116
67
|
/**
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
* @param options Command options for the hooked-block workflow.
|
|
120
|
-
* @param options.anchorBlockName Full block name that will anchor the insertion.
|
|
121
|
-
* @param options.blockName Existing workspace block slug to patch.
|
|
122
|
-
* @param options.cwd Working directory used to resolve the nearest official workspace.
|
|
123
|
-
* Defaults to `process.cwd()`.
|
|
124
|
-
* @param options.position Hook position to store in `block.json`.
|
|
125
|
-
* @returns A promise that resolves with the normalized target block slug, anchor
|
|
126
|
-
* block name, position, and owning project directory after `block.json` is written.
|
|
127
|
-
* @throws {Error} When the command is run outside an official workspace, when
|
|
128
|
-
* the target block is unknown, when required flags are missing, or when the
|
|
129
|
-
* block already defines a hook for the requested anchor.
|
|
68
|
+
* Re-export the block variation scaffold workflow from the focused variation
|
|
69
|
+
* runtime helper module.
|
|
130
70
|
*/
|
|
131
|
-
export
|
|
132
|
-
anchorBlockName: string;
|
|
133
|
-
blockSlug: string;
|
|
134
|
-
position: HookedBlockPositionId;
|
|
135
|
-
projectDir: string;
|
|
136
|
-
}>;
|
|
71
|
+
export { runAddVariationCommand } from "./cli-add-workspace-variation.js";
|