@wp-typia/project-tools 0.18.0 → 0.19.1
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/alternate-render-targets.d.ts +5 -0
- package/dist/runtime/alternate-render-targets.js +29 -0
- package/dist/runtime/block-generator-service-core.d.ts +1 -1
- package/dist/runtime/block-generator-service-core.js +11 -7
- package/dist/runtime/block-generator-service-spec.d.ts +8 -1
- package/dist/runtime/block-generator-service-spec.js +248 -2
- package/dist/runtime/built-in-block-artifacts.js +3 -1
- package/dist/runtime/built-in-block-code-artifacts.js +3 -1
- package/dist/runtime/built-in-block-code-templates/compound-child.d.ts +1 -1
- package/dist/runtime/built-in-block-code-templates/compound-child.js +14 -9
- package/dist/runtime/built-in-block-code-templates/compound-parent.d.ts +2 -2
- package/dist/runtime/built-in-block-code-templates/compound-parent.js +100 -43
- package/dist/runtime/built-in-block-code-templates/compound-persistence.d.ts +1 -1
- package/dist/runtime/built-in-block-code-templates/compound-persistence.js +11 -8
- package/dist/runtime/built-in-block-non-ts-artifacts.js +505 -2
- package/dist/runtime/cli-add-block.d.ts +4 -1
- package/dist/runtime/cli-add-block.js +66 -31
- package/dist/runtime/cli-add-shared.d.ts +3 -1
- package/dist/runtime/cli-add-shared.js +12 -12
- package/dist/runtime/cli-core.d.ts +2 -0
- package/dist/runtime/cli-core.js +1 -0
- package/dist/runtime/cli-diagnostics.d.ts +26 -0
- package/dist/runtime/cli-diagnostics.js +107 -0
- package/dist/runtime/cli-doctor-workspace.js +4 -4
- package/dist/runtime/cli-help.js +4 -3
- package/dist/runtime/cli-scaffold.d.ts +3 -1
- package/dist/runtime/cli-scaffold.js +91 -15
- package/dist/runtime/cli-templates.js +26 -1
- package/dist/runtime/cli-validation.d.ts +66 -0
- package/dist/runtime/cli-validation.js +92 -0
- package/dist/runtime/compound-inner-blocks.d.ts +78 -0
- package/dist/runtime/compound-inner-blocks.js +88 -0
- package/dist/runtime/index.d.ts +5 -1
- package/dist/runtime/index.js +3 -1
- package/dist/runtime/migration-command-surface.js +2 -0
- package/dist/runtime/package-versions.d.ts +1 -0
- package/dist/runtime/package-versions.js +12 -0
- package/dist/runtime/scaffold-answer-resolution.js +10 -6
- package/dist/runtime/scaffold-bootstrap.js +5 -1
- package/dist/runtime/scaffold-documents.js +29 -6
- package/dist/runtime/scaffold-identifiers.d.ts +17 -0
- package/dist/runtime/scaffold-identifiers.js +22 -0
- package/dist/runtime/scaffold-onboarding.js +21 -13
- package/dist/runtime/scaffold-template-variable-groups.d.ts +154 -0
- package/dist/runtime/scaffold-template-variable-groups.js +13 -0
- package/dist/runtime/scaffold-template-variables.js +80 -1
- package/dist/runtime/scaffold.d.ts +21 -2
- package/dist/runtime/scaffold.js +12 -5
- package/dist/runtime/temp-roots.d.ts +44 -0
- package/dist/runtime/temp-roots.js +129 -0
- package/dist/runtime/template-builtins.js +4 -6
- package/dist/runtime/template-registry.d.ts +8 -0
- package/dist/runtime/template-registry.js +34 -1
- package/dist/runtime/template-source-external.d.ts +1 -0
- package/dist/runtime/template-source-external.js +4 -7
- package/dist/runtime/template-source-remote.js +44 -23
- package/dist/runtime/template-source-seeds.js +3 -9
- package/dist/runtime/template-source.d.ts +2 -3
- package/dist/runtime/template-source.js +13 -5
- package/dist/runtime/workspace-project.js +1 -1
- package/package.json +12 -2
- package/templates/_shared/compound/core/scripts/add-compound-child.ts.mustache +318 -18
|
@@ -4,6 +4,7 @@ import path from "node:path";
|
|
|
4
4
|
import { PROJECT_TOOLS_PACKAGE_ROOT } from "./template-registry.js";
|
|
5
5
|
const require = createRequire(import.meta.url);
|
|
6
6
|
const DEFAULT_VERSION_RANGE = "^0.0.0";
|
|
7
|
+
const DEFAULT_EXACT_VERSION = "0.0.0";
|
|
7
8
|
let cachedPackageVersions = null;
|
|
8
9
|
function getErrorCode(error) {
|
|
9
10
|
return typeof error === "object" && error !== null && "code" in error
|
|
@@ -20,6 +21,16 @@ function normalizeVersionRange(value) {
|
|
|
20
21
|
}
|
|
21
22
|
return /^[~^<>=]/.test(trimmed) ? trimmed : `^${trimmed}`;
|
|
22
23
|
}
|
|
24
|
+
function normalizeExactVersion(value) {
|
|
25
|
+
const trimmed = value?.trim();
|
|
26
|
+
if (!trimmed) {
|
|
27
|
+
return DEFAULT_EXACT_VERSION;
|
|
28
|
+
}
|
|
29
|
+
if (trimmed.startsWith("workspace:")) {
|
|
30
|
+
return DEFAULT_EXACT_VERSION;
|
|
31
|
+
}
|
|
32
|
+
return trimmed.replace(/^[~^<>=]+/, "");
|
|
33
|
+
}
|
|
23
34
|
function readPackageManifest(packageJsonPath) {
|
|
24
35
|
try {
|
|
25
36
|
return JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
|
@@ -67,6 +78,7 @@ export function getPackageVersions() {
|
|
|
67
78
|
projectToolsPackageVersion: normalizeVersionRange(createManifest.version),
|
|
68
79
|
restPackageVersion: normalizeVersionRange(createManifest.dependencies?.["@wp-typia/rest"] ??
|
|
69
80
|
resolveInstalledPackageManifest("@wp-typia/rest")?.version),
|
|
81
|
+
wpTypiaPackageExactVersion: normalizeExactVersion(wpTypiaManifest.version),
|
|
70
82
|
wpTypiaPackageVersion: normalizeVersionRange(wpTypiaManifest.version),
|
|
71
83
|
};
|
|
72
84
|
return cachedPackageVersions;
|
|
@@ -10,6 +10,7 @@ const TEMPLATE_SELECTION_HINT = `--template <${[
|
|
|
10
10
|
WORKSPACE_TEMPLATE_ALIAS,
|
|
11
11
|
].join('|')}|./path|github:owner/repo/path[#ref]|npm-package>`;
|
|
12
12
|
const TEMPLATE_SUGGESTION_IDS = [...TEMPLATE_IDS, WORKSPACE_TEMPLATE_ALIAS];
|
|
13
|
+
const QUERY_POST_TYPE_RULE = 'Use lowercase, 1-20 chars, and only a-z, 0-9, "_" or "-".';
|
|
13
14
|
/**
|
|
14
15
|
* Detect the current author name from local Git config.
|
|
15
16
|
*
|
|
@@ -50,12 +51,15 @@ export function getDefaultAnswers(projectName, templateId) {
|
|
|
50
51
|
};
|
|
51
52
|
}
|
|
52
53
|
function validateQueryPostType(value) {
|
|
53
|
-
const
|
|
54
|
+
const rawValue = value.trim();
|
|
55
|
+
const normalizedValue = rawValue.toLowerCase();
|
|
54
56
|
if (normalizedValue.length === 0) {
|
|
55
57
|
return 'Query post type is required.';
|
|
56
58
|
}
|
|
57
59
|
if (!/^[a-z0-9_-]{1,20}$/u.test(normalizedValue)) {
|
|
58
|
-
return
|
|
60
|
+
return rawValue === normalizedValue
|
|
61
|
+
? `Query post type "${rawValue}" is invalid. ${QUERY_POST_TYPE_RULE}`
|
|
62
|
+
: `Query post type "${rawValue}" normalizes to "${normalizedValue}", which is invalid. ${QUERY_POST_TYPE_RULE}`;
|
|
59
63
|
}
|
|
60
64
|
return true;
|
|
61
65
|
}
|
|
@@ -63,11 +67,11 @@ function normalizeQueryPostType(value) {
|
|
|
63
67
|
if (typeof value !== 'string') {
|
|
64
68
|
return undefined;
|
|
65
69
|
}
|
|
66
|
-
const
|
|
67
|
-
if (
|
|
68
|
-
throw new Error(
|
|
70
|
+
const validationResult = validateQueryPostType(value);
|
|
71
|
+
if (validationResult !== true) {
|
|
72
|
+
throw new Error(validationResult);
|
|
69
73
|
}
|
|
70
|
-
return
|
|
74
|
+
return value.trim().toLowerCase();
|
|
71
75
|
}
|
|
72
76
|
function normalizeTemplateSelection(templateId) {
|
|
73
77
|
return templateId === WORKSPACE_TEMPLATE_ALIAS
|
|
@@ -7,6 +7,7 @@ import { syncPersistenceRestArtifacts } from "./persistence-rest-artifacts.js";
|
|
|
7
7
|
import { getPackageVersions } from "./package-versions.js";
|
|
8
8
|
import { getStarterManifestFiles, stringifyStarterManifest } from "./starter-manifests.js";
|
|
9
9
|
import { OFFICIAL_WORKSPACE_TEMPLATE_PACKAGE, PROJECT_TOOLS_PACKAGE_ROOT, } from "./template-registry.js";
|
|
10
|
+
import { getScaffoldTemplateVariableGroups } from "./scaffold-template-variable-groups.js";
|
|
10
11
|
const EPHEMERAL_NODE_MODULES_LINK_TYPE = process.platform === "win32" ? "junction" : "dir";
|
|
11
12
|
/**
|
|
12
13
|
* Ensures the scaffold target directory exists and is empty unless explicitly allowed.
|
|
@@ -71,8 +72,11 @@ export async function writeStarterManifestFiles(targetDir, templateId, variables
|
|
|
71
72
|
* @returns A promise that resolves after any required persistence artifacts are generated.
|
|
72
73
|
*/
|
|
73
74
|
export async function seedBuiltInPersistenceArtifacts(targetDir, templateId, variables) {
|
|
75
|
+
const compoundGroup = getScaffoldTemplateVariableGroups(variables).compound;
|
|
74
76
|
const needsPersistenceArtifacts = templateId === "persistence" ||
|
|
75
|
-
(templateId === "compound" &&
|
|
77
|
+
(templateId === "compound" &&
|
|
78
|
+
compoundGroup.enabled &&
|
|
79
|
+
compoundGroup.persistenceEnabled);
|
|
76
80
|
if (!needsPersistenceArtifacts) {
|
|
77
81
|
return;
|
|
78
82
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { getPrimaryDevelopmentScript } from './local-dev-presets.js';
|
|
2
2
|
import { getCompoundExtensionWorkflowSection, getInitialCommitCommands, getInitialCommitNote, getOptionalOnboardingNote, getOptionalOnboardingSteps, getQuickStartWorkflowNote, getPhpRestExtensionPointsSection, getTemplateSourceOfTruthNote, } from './scaffold-onboarding.js';
|
|
3
|
-
import { formatInstallCommand, formatRunScript, } from './package-managers.js';
|
|
3
|
+
import { formatPackageExecCommand, formatInstallCommand, formatRunScript, } from './package-managers.js';
|
|
4
|
+
import { getPackageVersions } from './package-versions.js';
|
|
5
|
+
import { getScaffoldTemplateVariableGroups } from './scaffold-template-variable-groups.js';
|
|
4
6
|
/**
|
|
5
7
|
* Builds the generated README markdown for one scaffolded project.
|
|
6
8
|
*
|
|
@@ -11,18 +13,38 @@ import { formatInstallCommand, formatRunScript, } from './package-managers.js';
|
|
|
11
13
|
* @returns Markdown README content for the generated project root.
|
|
12
14
|
*/
|
|
13
15
|
export function buildReadme(templateId, variables, packageManager, { withMigrationUi = false, withTestPreset = false, withWpEnv = false, } = {}) {
|
|
16
|
+
const variableGroups = getScaffoldTemplateVariableGroups(variables);
|
|
17
|
+
const compoundPersistenceEnabled = variableGroups.compound.enabled &&
|
|
18
|
+
variableGroups.compound.persistenceEnabled;
|
|
14
19
|
const optionalOnboardingSteps = getOptionalOnboardingSteps(packageManager, templateId, {
|
|
15
|
-
compoundPersistenceEnabled
|
|
20
|
+
compoundPersistenceEnabled,
|
|
16
21
|
});
|
|
17
22
|
const initialCommitCommands = getInitialCommitCommands();
|
|
18
23
|
const sourceOfTruthNote = getTemplateSourceOfTruthNote(templateId, {
|
|
19
|
-
compoundPersistenceEnabled
|
|
24
|
+
compoundPersistenceEnabled,
|
|
20
25
|
});
|
|
21
|
-
const
|
|
22
|
-
const publicPersistencePolicyNote = variables.isPublicPersistencePolicy === 'true'
|
|
26
|
+
const publicPersistencePolicyNote = variableGroups.persistence.enabled && variableGroups.persistence.auth.isPublic
|
|
23
27
|
? 'Public persistence writes use signed short-lived tokens, per-request ids, and coarse rate limiting by default. Add application-specific abuse controls before using the same pattern for high-value metrics or experiments.'
|
|
24
28
|
: null;
|
|
29
|
+
const alternateRenderTargetSection = variableGroups.alternateRenderTargets.enabled
|
|
30
|
+
? `## Alternate Render Targets\n\nThis scaffold keeps \`${templateId === 'compound' ? `src/blocks/${variables.slugKebabCase}/render.php` : 'src/render.php'}\` as the default web render boundary and also generates ${[
|
|
31
|
+
variableGroups.alternateRenderTargets.hasEmail
|
|
32
|
+
? `\`${templateId === 'compound' ? `src/blocks/${variables.slugKebabCase}/render-email.php` : 'src/render-email.php'}\``
|
|
33
|
+
: null,
|
|
34
|
+
variableGroups.alternateRenderTargets.hasMjml
|
|
35
|
+
? `\`${templateId === 'compound' ? `src/blocks/${variables.slugKebabCase}/render-mjml.php` : 'src/render-mjml.php'}\``
|
|
36
|
+
: null,
|
|
37
|
+
variableGroups.alternateRenderTargets.hasPlainText
|
|
38
|
+
? `\`${templateId === 'compound' ? `src/blocks/${variables.slugKebabCase}/render-text.php` : 'src/render-text.php'}\``
|
|
39
|
+
: null,
|
|
40
|
+
]
|
|
41
|
+
.filter((value) => Boolean(value))
|
|
42
|
+
.join(', ')}. All of those entries delegate through \`${templateId === 'compound' ? `src/blocks/${variables.slugKebabCase}/render-targets.php` : 'src/render-targets.php'}\`, so attribute normalization, validation, and render-target adapter hooks stay aligned across web, email, MJML, and plain-text integrations.`
|
|
43
|
+
: '';
|
|
25
44
|
const compoundExtensionWorkflowSection = getCompoundExtensionWorkflowSection(packageManager, templateId);
|
|
45
|
+
const compoundInnerBlocksSection = templateId === 'compound'
|
|
46
|
+
? `## Compound InnerBlocks Presets\n\nThis scaffold starts with the \`${variables.compoundInnerBlocksPreset}\` preset for compound container authoring. Static nested relationships still belong in each generated \`block.json\` via \`allowedBlocks\`, \`parent\`, and \`ancestor\`, while \`src/blocks/${variables.slugKebabCase}/children.ts\` owns editor-only \`InnerBlocks\` behavior such as \`orientation\`, \`templateLock\`, \`defaultBlock\`, and \`directInsert\`.\n\n- \`freeform\`: unlocked inserter flow with the starter child template.\n- \`ordered\`: vertical ordered flow with \`templateLock="insert"\` and direct inserts.\n- \`horizontal\`: row-like nested authoring with direct inserts.\n- \`locked-structure\`: fully locked starter structure.\n\nWhen you need to change that authoring behavior later, update the preset helpers in \`src/blocks/${variables.slugKebabCase}/children.ts\` and keep fixed child constraints metadata-owned instead of duplicating them in editor props. If you need tighter wrapper ownership or sibling markup control, switch the generated edit components to \`useInnerBlocksProps\` and reuse \`getRootInnerBlocksPropsOptions()\` / \`getChildInnerBlocksPropsOptions( metadata.name )\` so the same preset behavior carries forward without rebuilding the option set by hand.`
|
|
47
|
+
: '';
|
|
26
48
|
const phpRestExtensionPointsSection = getPhpRestExtensionPointsSection(templateId, {
|
|
27
49
|
compoundPersistenceEnabled,
|
|
28
50
|
slug: variables.slug,
|
|
@@ -69,6 +91,7 @@ ${getQuickStartWorkflowNote(packageManager, templateId, {
|
|
|
69
91
|
\`\`\`bash
|
|
70
92
|
${formatRunScript(packageManager, 'build')}
|
|
71
93
|
${formatRunScript(packageManager, 'typecheck')}
|
|
94
|
+
${formatPackageExecCommand(packageManager, `wp-typia@${getPackageVersions().wpTypiaPackageExactVersion}`, 'doctor')}
|
|
72
95
|
\`\`\`
|
|
73
96
|
|
|
74
97
|
${advancedSyncSection}
|
|
@@ -81,7 +104,7 @@ ${initialCommitCommands.join('\n')}
|
|
|
81
104
|
|
|
82
105
|
${getInitialCommitNote()}
|
|
83
106
|
|
|
84
|
-
${sourceOfTruthNote}${publicPersistencePolicyNote ? `\n\n${publicPersistencePolicyNote}` : ''}${migrationSection ? `\n\n${migrationSection}` : ''}${compoundExtensionWorkflowSection ? `\n\n${compoundExtensionWorkflowSection}` : ''}${wpEnvSection ? `\n\n${wpEnvSection}` : ''}${testPresetSection ? `\n\n${testPresetSection}` : ''}${phpRestExtensionPointsSection ? `\n\n${phpRestExtensionPointsSection}` : ''}
|
|
107
|
+
${sourceOfTruthNote}${publicPersistencePolicyNote ? `\n\n${publicPersistencePolicyNote}` : ''}${alternateRenderTargetSection ? `\n\n${alternateRenderTargetSection}` : ''}${compoundInnerBlocksSection ? `\n\n${compoundInnerBlocksSection}` : ''}${migrationSection ? `\n\n${migrationSection}` : ''}${compoundExtensionWorkflowSection ? `\n\n${compoundExtensionWorkflowSection}` : ''}${wpEnvSection ? `\n\n${wpEnvSection}` : ''}${testPresetSection ? `\n\n${testPresetSection}` : ''}${phpRestExtensionPointsSection ? `\n\n${phpRestExtensionPointsSection}` : ''}
|
|
85
108
|
`;
|
|
86
109
|
}
|
|
87
110
|
/**
|
|
@@ -10,6 +10,23 @@ export declare function validateTextDomain(input: string): true | string;
|
|
|
10
10
|
export declare function validatePhpPrefix(input: string): true | string;
|
|
11
11
|
export declare function assertValidIdentifier(label: string, value: string, validate: (value: string) => true | string): string;
|
|
12
12
|
export declare function normalizeBlockSlug(input: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Normalize one human-entered block slug and reject values that collapse to an
|
|
15
|
+
* empty generated slug.
|
|
16
|
+
*
|
|
17
|
+
* @param options Normalization context for one block-like name.
|
|
18
|
+
* @param options.input Raw user input before kebab-case normalization.
|
|
19
|
+
* @param options.label Human-readable field label used in thrown errors.
|
|
20
|
+
* @param options.usage Example CLI usage shown when the input is blank.
|
|
21
|
+
* @returns A non-empty normalized slug.
|
|
22
|
+
* @throws When the input is blank after trimming.
|
|
23
|
+
* @throws When normalization removes every character from the original input.
|
|
24
|
+
*/
|
|
25
|
+
export declare function resolveNonEmptyNormalizedBlockSlug(options: {
|
|
26
|
+
input: string;
|
|
27
|
+
label: string;
|
|
28
|
+
usage: string;
|
|
29
|
+
}): string;
|
|
13
30
|
export declare function resolveValidatedBlockSlug(value: string): string;
|
|
14
31
|
export declare function resolveValidatedNamespace(value: string): string;
|
|
15
32
|
export declare function resolveValidatedTextDomain(value: string): string;
|
|
@@ -34,6 +34,28 @@ export function assertValidIdentifier(label, value, validate) {
|
|
|
34
34
|
export function normalizeBlockSlug(input) {
|
|
35
35
|
return toKebabCase(input);
|
|
36
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Normalize one human-entered block slug and reject values that collapse to an
|
|
39
|
+
* empty generated slug.
|
|
40
|
+
*
|
|
41
|
+
* @param options Normalization context for one block-like name.
|
|
42
|
+
* @param options.input Raw user input before kebab-case normalization.
|
|
43
|
+
* @param options.label Human-readable field label used in thrown errors.
|
|
44
|
+
* @param options.usage Example CLI usage shown when the input is blank.
|
|
45
|
+
* @returns A non-empty normalized slug.
|
|
46
|
+
* @throws When the input is blank after trimming.
|
|
47
|
+
* @throws When normalization removes every character from the original input.
|
|
48
|
+
*/
|
|
49
|
+
export function resolveNonEmptyNormalizedBlockSlug(options) {
|
|
50
|
+
const normalizedSlug = normalizeBlockSlug(options.input);
|
|
51
|
+
if (normalizedSlug.length > 0) {
|
|
52
|
+
return normalizedSlug;
|
|
53
|
+
}
|
|
54
|
+
if (options.input.trim().length === 0) {
|
|
55
|
+
throw new Error(`${options.label} is required. Use \`${options.usage}\`.`);
|
|
56
|
+
}
|
|
57
|
+
throw new Error(`${options.label} "${options.input.trim()}" normalizes to an empty slug. Use letters or numbers so wp-typia can generate a block slug.`);
|
|
58
|
+
}
|
|
37
59
|
export function resolveValidatedBlockSlug(value) {
|
|
38
60
|
return assertValidIdentifier("Block slug", normalizeBlockSlug(value), validateBlockSlug);
|
|
39
61
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { formatRunScript } from "./package-managers.js";
|
|
1
|
+
import { formatPackageExecCommand, formatRunScript, } from "./package-managers.js";
|
|
2
|
+
import { getPackageVersions } from "./package-versions.js";
|
|
2
3
|
import { getPrimaryDevelopmentScript } from "./local-dev-presets.js";
|
|
3
4
|
import { OFFICIAL_WORKSPACE_TEMPLATE_PACKAGE, isBuiltInTemplateId, } from "./template-registry.js";
|
|
4
5
|
const INITIAL_COMMIT_COMMANDS = [
|
|
@@ -6,6 +7,9 @@ const INITIAL_COMMIT_COMMANDS = [
|
|
|
6
7
|
"git add .",
|
|
7
8
|
'git commit -m "Initial scaffold"',
|
|
8
9
|
];
|
|
10
|
+
function getDoctorVerificationCommand(packageManager) {
|
|
11
|
+
return formatPackageExecCommand(packageManager, `wp-typia@${getPackageVersions().wpTypiaPackageExactVersion}`, "doctor");
|
|
12
|
+
}
|
|
9
13
|
function templateHasPersistenceSync(templateId, { compoundPersistenceEnabled = false } = {}) {
|
|
10
14
|
return templateId === "persistence" || (templateId === "compound" && compoundPersistenceEnabled);
|
|
11
15
|
}
|
|
@@ -40,29 +44,31 @@ export function getOptionalOnboardingSteps(packageManager, templateId, options =
|
|
|
40
44
|
* Returns the quick-start note explaining the scaffold's primary local loop.
|
|
41
45
|
*/
|
|
42
46
|
export function getQuickStartWorkflowNote(packageManager, templateId = "basic", options = {}) {
|
|
47
|
+
const doctorCommand = getDoctorVerificationCommand(packageManager);
|
|
43
48
|
if (templateId === "query-loop") {
|
|
44
|
-
return `${formatRunScript(packageManager, "dev")} runs the editor build/watch loop that registers your Query Loop variation in the block editor. This scaffold
|
|
49
|
+
return `${formatRunScript(packageManager, "dev")} runs the editor build/watch loop that registers your Query Loop variation in the block editor. This scaffold intentionally skips \`src/types.ts\`, \`block.json\`, and Typia manifests because the source of truth lives in the variation registration flow. Update \`src/index.ts\` for variation defaults, \`src/patterns/*.php\` for richer connected layouts, \`src/query-extension.ts\` for custom query params, and \`inc/query-runtime.php\` for frontend/editor preview parity. Use ${doctorCommand} when you want a quick environment and workspace sanity check.`;
|
|
45
50
|
}
|
|
46
51
|
const developmentScript = getPrimaryDevelopmentScript(templateId);
|
|
47
52
|
const devCommand = formatRunScript(packageManager, developmentScript);
|
|
48
53
|
const startCommand = formatRunScript(packageManager, "start");
|
|
49
54
|
if (developmentScript === "start") {
|
|
50
|
-
return `${startCommand} is the primary local entry point for this template.
|
|
55
|
+
return `${startCommand} is the primary local entry point for this template. Use ${doctorCommand} when you want a quick environment and workspace sanity check before build or commit.`;
|
|
51
56
|
}
|
|
52
57
|
if (developmentScript !== "dev") {
|
|
53
|
-
return `${devCommand} is the primary local entry point for this template. Use ${startCommand}
|
|
58
|
+
return `${devCommand} is the primary local entry point for this template. Use ${startCommand} for the one-shot startup flow, and ${doctorCommand} when you want a quick verification pass before build or commit.`;
|
|
54
59
|
}
|
|
55
60
|
if (templateHasPersistenceSync(templateId, options)) {
|
|
56
|
-
return `${devCommand} keeps the editor, type-derived artifacts, and REST-derived artifacts moving together during local development. Use ${startCommand}
|
|
61
|
+
return `${devCommand} keeps the editor, type-derived artifacts, and REST-derived artifacts moving together during local development. Use ${startCommand} for a one-shot sync plus editor startup, and ${doctorCommand} when you want an explicit verification pass before build or commit.`;
|
|
57
62
|
}
|
|
58
|
-
return `${devCommand} keeps the editor and type-derived artifacts moving together during local development. Use ${startCommand}
|
|
63
|
+
return `${devCommand} keeps the editor and type-derived artifacts moving together during local development. Use ${startCommand} for a one-shot sync plus editor startup, and ${doctorCommand} when you want an explicit verification pass before build or commit.`;
|
|
59
64
|
}
|
|
60
65
|
/**
|
|
61
66
|
* Returns the onboarding note explaining when manual sync is optional.
|
|
62
67
|
*/
|
|
63
68
|
export function getOptionalOnboardingNote(packageManager, templateId = "basic", options = {}) {
|
|
69
|
+
const doctorCommand = getDoctorVerificationCommand(packageManager);
|
|
64
70
|
if (templateId === "query-loop") {
|
|
65
|
-
return `This scaffold does not generate a \`sync\` script, \`block.json\`, or Typia manifests. Edit \`src/index.ts
|
|
71
|
+
return `This scaffold owns a \`core/query\` variation, so it does not generate a \`sync\` script, \`src/types.ts\`, \`block.json\`, or Typia manifests. Edit \`src/index.ts\`, \`src/patterns/*.php\`, \`src/query-extension.ts\`, and \`inc/query-runtime.php\` as needed, then rerun ${formatRunScript(packageManager, "build")}, ${formatRunScript(packageManager, "typecheck")}, or ${doctorCommand}.`;
|
|
66
72
|
}
|
|
67
73
|
const optionalSyncScripts = getOptionalSyncScriptNames(templateId, options);
|
|
68
74
|
const hasUnifiedSync = optionalSyncScripts.includes("sync");
|
|
@@ -76,7 +82,7 @@ export function getOptionalOnboardingNote(packageManager, templateId = "basic",
|
|
|
76
82
|
const typecheckCommand = formatRunScript(packageManager, "typecheck");
|
|
77
83
|
const strictSyncCommand = formatRunScript(packageManager, "sync-types", "--strict --report json");
|
|
78
84
|
const advancedPersistenceNote = templateHasPersistenceSync(templateId, options)
|
|
79
|
-
? ` ${syncRestCommand} remains available for
|
|
85
|
+
? ` ${syncRestCommand} remains available for REST-only refreshes after ${syncTypesCommand}.`
|
|
80
86
|
: "";
|
|
81
87
|
const isCustomTemplate = !isBuiltInTemplateId(templateId) &&
|
|
82
88
|
templateId !== OFFICIAL_WORKSPACE_TEMPLATE_PACKAGE;
|
|
@@ -86,12 +92,12 @@ export function getOptionalOnboardingNote(packageManager, templateId = "basic",
|
|
|
86
92
|
? `Run ${syncSteps.join(" then ")} manually before build, typecheck, or commit. ${syncCheckCommand} verifies the current type-derived artifacts without rewriting them.${optionalSyncScripts.includes("sync-rest") ? ` ${syncRestCommand} remains available for REST-only refreshes after ${syncTypesCommand}.` : ""}`
|
|
87
93
|
: null;
|
|
88
94
|
if (fallbackCustomTemplateNote) {
|
|
89
|
-
return fallbackCustomTemplateNote
|
|
95
|
+
return `${fallbackCustomTemplateNote} Use ${doctorCommand} when you want a quick environment and workspace sanity check.`;
|
|
90
96
|
}
|
|
91
97
|
if (isCustomTemplate && syncSteps.length === 0) {
|
|
92
|
-
return
|
|
98
|
+
return `No optional sync command was detected for this custom template. Use ${doctorCommand} for a quick environment and workspace sanity check, then follow the template's own artifact-refresh guidance before build, typecheck, or your first commit.`;
|
|
93
99
|
}
|
|
94
|
-
return `You usually do not need to run ${syncCommand} during a normal ${formatRunScript(packageManager, developmentScript)} session. Run ${syncCommand}
|
|
100
|
+
return `You usually do not need to run ${syncCommand} during a normal ${formatRunScript(packageManager, developmentScript)} session. Run ${syncCommand} before ${formatRunScript(packageManager, "build")}, ${typecheckCommand}, or ${doctorCommand} when you want a reviewable refresh. ${syncTypesCommand} stays warn-only by default; use \`${failOnLossySyncCommand}\` or \`${strictSyncCommand}\` for stricter CI checks.${advancedPersistenceNote} Generated syncs do not create migration history, so refresh before your first commit if this directory is new.`;
|
|
95
101
|
}
|
|
96
102
|
/**
|
|
97
103
|
* Returns the recommended version-control commands for a fresh scaffold.
|
|
@@ -110,7 +116,7 @@ export function getInitialCommitNote() {
|
|
|
110
116
|
*/
|
|
111
117
|
export function getTemplateSourceOfTruthNote(templateId, { compoundPersistenceEnabled = false } = {}) {
|
|
112
118
|
if (templateId === "query-loop") {
|
|
113
|
-
return "`src/index.ts` remains the source of truth for the Query Loop variation name, default query attributes, `allowedControls`, and the minimal inline starter `innerBlocks`. Use `src/patterns/*.php` for richer connected layout presets that stay tied to the same variation namespace, use `src/query-extension.ts` for custom query seed values or optional editor-only hook registration, and use `inc/query-runtime.php` to keep frontend and editor preview query mapping aligned for those custom keys. The generated plugin bootstrap should stay focused on script registration, pattern loading, and explicit runtime glue for the variation.";
|
|
119
|
+
return "`src/index.ts` remains the source of truth for the Query Loop variation name, default query attributes, `allowedControls`, and the minimal inline starter `innerBlocks`. This scaffold intentionally does not generate `src/types.ts`, `block.json`, or Typia manifests because those artifacts belong to standalone block families, not `core/query` variation ownership. Use `src/patterns/*.php` for richer connected layout presets that stay tied to the same variation namespace, use `src/query-extension.ts` for custom query seed values or optional editor-only hook registration, and use `inc/query-runtime.php` to keep frontend and editor preview query mapping aligned for those custom keys. The generated plugin bootstrap should stay focused on script registration, pattern loading, and explicit runtime glue for the variation.";
|
|
114
120
|
}
|
|
115
121
|
if (templateId === "compound") {
|
|
116
122
|
const compoundBase = "`src/blocks/*/types.ts` files remain the source of truth for each block's `block.json`, `typia.manifest.json`, and `typia-validator.php`. Fresh scaffolds include starter `typia.manifest.json` files so editor imports resolve before the first sync.";
|
|
@@ -138,10 +144,12 @@ ${formatRunScript(packageManager, "add-child", '--slug faq-item --title "FAQ Ite
|
|
|
138
144
|
|
|
139
145
|
${formatRunScript(packageManager, "add-child", '--slug section --title "Section" --container --inserter visible')}
|
|
140
146
|
|
|
147
|
+
${formatRunScript(packageManager, "add-child", '--slug clause --title "Clause" --ancestor section --dry-run')}
|
|
148
|
+
|
|
141
149
|
${formatRunScript(packageManager, "add-child", '--slug clause --title "Clause" --ancestor section')}
|
|
142
150
|
\`\`\`
|
|
143
151
|
|
|
144
|
-
This scaffolds additional compound child block types, updates \`scripts/block-config.ts\` and \`src/blocks/*/children.ts\`, and now supports root-level hidden children, visible container children, and nested ancestor chains for richer document-style block hierarchies.`;
|
|
152
|
+
This scaffolds additional compound child block types, updates \`scripts/block-config.ts\` and \`src/blocks/*/children.ts\`, and now supports root-level hidden children, visible container children, and nested ancestor chains for richer document-style block hierarchies. Pass \`--dry-run\` when you want a validated child-graph preview and planned write list before the script mutates files.`;
|
|
145
153
|
}
|
|
146
154
|
function formatPhpRestExtensionPointsSection({ apiTypesPath, extraNote, mainPhpPath, mainPhpScope, transportPath, }) {
|
|
147
155
|
const schemaJsonGlob = apiTypesPath.replace(/api-types\.ts$/u, "api-schemas/*.schema.json");
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
export declare const SCAFFOLD_TEMPLATE_VARIABLE_GROUPS: unique symbol;
|
|
2
|
+
export type ScaffoldTemplateFamily = "basic" | "interactivity" | "persistence" | "compound" | "query-loop" | "external";
|
|
3
|
+
export interface ScaffoldSharedTemplateVariableGroup {
|
|
4
|
+
author: string;
|
|
5
|
+
blockMetadataVersion: string;
|
|
6
|
+
category: string;
|
|
7
|
+
cssClassName: string;
|
|
8
|
+
description: string;
|
|
9
|
+
descriptionJson: string;
|
|
10
|
+
frontendCssClassName: string;
|
|
11
|
+
icon: string;
|
|
12
|
+
keyword: string;
|
|
13
|
+
namespace: string;
|
|
14
|
+
pascalCase: string;
|
|
15
|
+
phpPrefix: string;
|
|
16
|
+
phpPrefixUpper: string;
|
|
17
|
+
slug: string;
|
|
18
|
+
slugCamelCase: string;
|
|
19
|
+
slugKebabCase: string;
|
|
20
|
+
slugSnakeCase: string;
|
|
21
|
+
textDomain: string;
|
|
22
|
+
title: string;
|
|
23
|
+
titleCase: string;
|
|
24
|
+
titleJson: string;
|
|
25
|
+
versions: {
|
|
26
|
+
apiClient: string;
|
|
27
|
+
blockRuntime: string;
|
|
28
|
+
blockTypes: string;
|
|
29
|
+
projectTools: string;
|
|
30
|
+
rest: string;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export interface ScaffoldAlternateRenderTargetVariableGroup {
|
|
34
|
+
csv: string;
|
|
35
|
+
enabled: boolean;
|
|
36
|
+
hasEmail: boolean;
|
|
37
|
+
hasMjml: boolean;
|
|
38
|
+
hasPlainText: boolean;
|
|
39
|
+
json: string;
|
|
40
|
+
targets: readonly string[];
|
|
41
|
+
}
|
|
42
|
+
export interface DisabledScaffoldCompoundVariableGroup {
|
|
43
|
+
enabled: false;
|
|
44
|
+
persistenceEnabled: false;
|
|
45
|
+
}
|
|
46
|
+
export interface EnabledScaffoldCompoundVariableGroup {
|
|
47
|
+
child: {
|
|
48
|
+
category: string;
|
|
49
|
+
cssClassName: string;
|
|
50
|
+
icon: string;
|
|
51
|
+
title: string;
|
|
52
|
+
titleJson: string;
|
|
53
|
+
};
|
|
54
|
+
enabled: true;
|
|
55
|
+
innerBlocks: {
|
|
56
|
+
description: string;
|
|
57
|
+
directInsert: boolean;
|
|
58
|
+
label: string;
|
|
59
|
+
orientation: "" | "horizontal" | "vertical";
|
|
60
|
+
orientationExpression: string;
|
|
61
|
+
preset: string;
|
|
62
|
+
templateLockExpression: string;
|
|
63
|
+
};
|
|
64
|
+
persistenceEnabled: boolean;
|
|
65
|
+
}
|
|
66
|
+
export type ScaffoldCompoundVariableGroup = DisabledScaffoldCompoundVariableGroup | EnabledScaffoldCompoundVariableGroup;
|
|
67
|
+
export interface DisabledScaffoldPersistenceVariableGroup {
|
|
68
|
+
enabled: false;
|
|
69
|
+
scope: "none";
|
|
70
|
+
}
|
|
71
|
+
export interface EnabledScaffoldPersistenceVariableGroup {
|
|
72
|
+
auth: {
|
|
73
|
+
bootstrapCredentialDeclarations: string;
|
|
74
|
+
descriptionJson: string;
|
|
75
|
+
intent: "authenticated" | "public-write-protected";
|
|
76
|
+
isAuthenticated: boolean;
|
|
77
|
+
isPublic: boolean;
|
|
78
|
+
mechanism: "public-signed-token" | "rest-nonce";
|
|
79
|
+
mode: "authenticated-rest-nonce" | "public-signed-token";
|
|
80
|
+
publicWriteRequestIdDeclaration: string;
|
|
81
|
+
};
|
|
82
|
+
dataStorageMode: "custom-table" | "post-meta";
|
|
83
|
+
enabled: true;
|
|
84
|
+
policy: "authenticated" | "public";
|
|
85
|
+
scope: "compound-parent" | "single";
|
|
86
|
+
}
|
|
87
|
+
export type ScaffoldPersistenceVariableGroup = DisabledScaffoldPersistenceVariableGroup | EnabledScaffoldPersistenceVariableGroup;
|
|
88
|
+
export interface DisabledScaffoldQueryLoopVariableGroup {
|
|
89
|
+
enabled: false;
|
|
90
|
+
}
|
|
91
|
+
export interface EnabledScaffoldQueryLoopVariableGroup {
|
|
92
|
+
allowedControls: readonly string[];
|
|
93
|
+
allowedControlsJson: string;
|
|
94
|
+
enabled: true;
|
|
95
|
+
postType: string;
|
|
96
|
+
postTypeJson: string;
|
|
97
|
+
variationNamespace: string;
|
|
98
|
+
variationNamespaceJson: string;
|
|
99
|
+
}
|
|
100
|
+
export type ScaffoldQueryLoopVariableGroup = DisabledScaffoldQueryLoopVariableGroup | EnabledScaffoldQueryLoopVariableGroup;
|
|
101
|
+
interface ScaffoldTemplateVariableGroupsBase {
|
|
102
|
+
alternateRenderTargets: ScaffoldAlternateRenderTargetVariableGroup;
|
|
103
|
+
shared: ScaffoldSharedTemplateVariableGroup;
|
|
104
|
+
template: {
|
|
105
|
+
description: string;
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
type DisabledTemplateFamilyGroups<TFamily extends "basic" | "interactivity" | "external"> = ScaffoldTemplateVariableGroupsBase & {
|
|
109
|
+
compound: DisabledScaffoldCompoundVariableGroup;
|
|
110
|
+
persistence: DisabledScaffoldPersistenceVariableGroup;
|
|
111
|
+
queryLoop: DisabledScaffoldQueryLoopVariableGroup;
|
|
112
|
+
templateFamily: TFamily;
|
|
113
|
+
};
|
|
114
|
+
export type BasicScaffoldTemplateVariableGroups = DisabledTemplateFamilyGroups<"basic">;
|
|
115
|
+
export type InteractivityScaffoldTemplateVariableGroups = DisabledTemplateFamilyGroups<"interactivity">;
|
|
116
|
+
export interface PersistenceScaffoldTemplateVariableGroups extends ScaffoldTemplateVariableGroupsBase {
|
|
117
|
+
compound: DisabledScaffoldCompoundVariableGroup;
|
|
118
|
+
persistence: EnabledScaffoldPersistenceVariableGroup & {
|
|
119
|
+
scope: "single";
|
|
120
|
+
};
|
|
121
|
+
queryLoop: DisabledScaffoldQueryLoopVariableGroup;
|
|
122
|
+
templateFamily: "persistence";
|
|
123
|
+
}
|
|
124
|
+
export interface CompoundScaffoldTemplateVariableGroups extends ScaffoldTemplateVariableGroupsBase {
|
|
125
|
+
compound: EnabledScaffoldCompoundVariableGroup;
|
|
126
|
+
persistence: DisabledScaffoldPersistenceVariableGroup | (EnabledScaffoldPersistenceVariableGroup & {
|
|
127
|
+
scope: "compound-parent";
|
|
128
|
+
});
|
|
129
|
+
queryLoop: DisabledScaffoldQueryLoopVariableGroup;
|
|
130
|
+
templateFamily: "compound";
|
|
131
|
+
}
|
|
132
|
+
export interface QueryLoopScaffoldTemplateVariableGroups extends ScaffoldTemplateVariableGroupsBase {
|
|
133
|
+
compound: DisabledScaffoldCompoundVariableGroup;
|
|
134
|
+
persistence: DisabledScaffoldPersistenceVariableGroup;
|
|
135
|
+
queryLoop: EnabledScaffoldQueryLoopVariableGroup;
|
|
136
|
+
templateFamily: "query-loop";
|
|
137
|
+
}
|
|
138
|
+
export type ExternalScaffoldTemplateVariableGroups = DisabledTemplateFamilyGroups<"external">;
|
|
139
|
+
export type ScaffoldTemplateVariableGroups = BasicScaffoldTemplateVariableGroups | InteractivityScaffoldTemplateVariableGroups | PersistenceScaffoldTemplateVariableGroups | CompoundScaffoldTemplateVariableGroups | QueryLoopScaffoldTemplateVariableGroups | ExternalScaffoldTemplateVariableGroups;
|
|
140
|
+
export interface ScaffoldTemplateVariableGroupsCarrier {
|
|
141
|
+
readonly [SCAFFOLD_TEMPLATE_VARIABLE_GROUPS]: ScaffoldTemplateVariableGroups;
|
|
142
|
+
}
|
|
143
|
+
export type CompoundScaffoldTemplateVariablesLike = ScaffoldTemplateVariableGroupsCarrier & {
|
|
144
|
+
slugKebabCase: string;
|
|
145
|
+
};
|
|
146
|
+
export type PersistenceScaffoldTemplateVariablesLike = ScaffoldTemplateVariableGroupsCarrier & {
|
|
147
|
+
namespace: string;
|
|
148
|
+
pascalCase: string;
|
|
149
|
+
slugKebabCase: string;
|
|
150
|
+
title: string;
|
|
151
|
+
};
|
|
152
|
+
export declare function attachScaffoldTemplateVariableGroups<TVariables extends Record<string, string>>(variables: TVariables, groups: ScaffoldTemplateVariableGroups): TVariables & ScaffoldTemplateVariableGroupsCarrier;
|
|
153
|
+
export declare function getScaffoldTemplateVariableGroups(variables: ScaffoldTemplateVariableGroupsCarrier): ScaffoldTemplateVariableGroups;
|
|
154
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const SCAFFOLD_TEMPLATE_VARIABLE_GROUPS = Symbol("wp-typia.scaffold-template-variable-groups");
|
|
2
|
+
export function attachScaffoldTemplateVariableGroups(variables, groups) {
|
|
3
|
+
Object.defineProperty(variables, SCAFFOLD_TEMPLATE_VARIABLE_GROUPS, {
|
|
4
|
+
configurable: false,
|
|
5
|
+
enumerable: false,
|
|
6
|
+
value: groups,
|
|
7
|
+
writable: false,
|
|
8
|
+
});
|
|
9
|
+
return variables;
|
|
10
|
+
}
|
|
11
|
+
export function getScaffoldTemplateVariableGroups(variables) {
|
|
12
|
+
return variables[SCAFFOLD_TEMPLATE_VARIABLE_GROUPS];
|
|
13
|
+
}
|
|
@@ -2,8 +2,10 @@ import { buildTemplateVariablesFromBlockSpec, createBuiltInBlockSpec, } from './
|
|
|
2
2
|
import { getPackageVersions } from './package-versions.js';
|
|
3
3
|
import { buildBlockCssClassName, buildFrontendCssClassName, resolveScaffoldIdentifiers, } from './scaffold-identifiers.js';
|
|
4
4
|
import { BUILTIN_BLOCK_METADATA_VERSION, COMPOUND_CHILD_BLOCK_METADATA_DEFAULTS, getBuiltInTemplateMetadataDefaults, } from './template-defaults.js';
|
|
5
|
+
import { DEFAULT_COMPOUND_INNER_BLOCKS_PRESET_ID, getCompoundInnerBlocksPresetDefinition, } from './compound-inner-blocks.js';
|
|
5
6
|
import { getTemplateById, isBuiltInTemplateId, } from './template-registry.js';
|
|
6
7
|
import { toPascalCase, toSnakeCase, } from './string-case.js';
|
|
8
|
+
import { attachScaffoldTemplateVariableGroups } from "./scaffold-template-variable-groups.js";
|
|
7
9
|
/**
|
|
8
10
|
* Build the normalized template variables used by scaffold rendering.
|
|
9
11
|
*
|
|
@@ -43,6 +45,8 @@ export function getTemplateVariables(templateId, answers) {
|
|
|
43
45
|
const compoundChildTitle = `${title} Item`;
|
|
44
46
|
const cssClassName = buildBlockCssClassName(namespace, slug);
|
|
45
47
|
const compoundChildCssClassName = buildBlockCssClassName(namespace, `${slug}-item`);
|
|
48
|
+
const compoundInnerBlocksPreset = answers.compoundInnerBlocksPreset ?? DEFAULT_COMPOUND_INNER_BLOCKS_PRESET_ID;
|
|
49
|
+
const compoundInnerBlocksPresetDefinition = getCompoundInnerBlocksPresetDefinition(compoundInnerBlocksPreset);
|
|
46
50
|
const compoundPersistenceEnabled = templateId === 'persistence'
|
|
47
51
|
? true
|
|
48
52
|
: templateId === 'compound'
|
|
@@ -54,7 +58,9 @@ export function getTemplateVariables(templateId, answers) {
|
|
|
54
58
|
const persistencePolicy = templateId === 'persistence' || compoundPersistenceEnabled
|
|
55
59
|
? answers.persistencePolicy ?? 'authenticated'
|
|
56
60
|
: 'authenticated';
|
|
57
|
-
|
|
61
|
+
const flatVariables = {
|
|
62
|
+
alternateRenderTargetsCsv: '',
|
|
63
|
+
alternateRenderTargetsJson: '[]',
|
|
58
64
|
apiClientPackageVersion,
|
|
59
65
|
author: answers.author.trim(),
|
|
60
66
|
blockRuntimePackageVersion,
|
|
@@ -68,6 +74,23 @@ export function getTemplateVariables(templateId, answers) {
|
|
|
68
74
|
compoundChildIcon: COMPOUND_CHILD_BLOCK_METADATA_DEFAULTS.icon,
|
|
69
75
|
compoundChildTitleJson: JSON.stringify(compoundChildTitle),
|
|
70
76
|
compoundPersistenceEnabled: compoundPersistenceEnabled ? 'true' : 'false',
|
|
77
|
+
compoundInnerBlocksDirectInsert: compoundInnerBlocksPresetDefinition.directInsert
|
|
78
|
+
? 'true'
|
|
79
|
+
: 'false',
|
|
80
|
+
compoundInnerBlocksOrientation: compoundInnerBlocksPresetDefinition.orientation ?? '',
|
|
81
|
+
compoundInnerBlocksOrientationExpression: compoundInnerBlocksPresetDefinition.orientation
|
|
82
|
+
? `'${compoundInnerBlocksPresetDefinition.orientation}'`
|
|
83
|
+
: 'undefined',
|
|
84
|
+
compoundInnerBlocksPreset,
|
|
85
|
+
compoundInnerBlocksPresetDescription: compoundInnerBlocksPresetDefinition.description,
|
|
86
|
+
compoundInnerBlocksPresetLabel: compoundInnerBlocksPresetDefinition.label,
|
|
87
|
+
compoundInnerBlocksTemplateLockExpression: compoundInnerBlocksPresetDefinition.templateLock === false
|
|
88
|
+
? 'false'
|
|
89
|
+
: `'${compoundInnerBlocksPresetDefinition.templateLock}'`,
|
|
90
|
+
hasAlternateEmailRenderTarget: 'false',
|
|
91
|
+
hasAlternateMjmlRenderTarget: 'false',
|
|
92
|
+
hasAlternatePlainTextRenderTarget: 'false',
|
|
93
|
+
hasAlternateRenderTargets: 'false',
|
|
71
94
|
projectToolsPackageVersion,
|
|
72
95
|
cssClassName,
|
|
73
96
|
dataStorageMode,
|
|
@@ -114,4 +137,60 @@ export function getTemplateVariables(templateId, answers) {
|
|
|
114
137
|
titleCase: pascalCase,
|
|
115
138
|
persistencePolicy,
|
|
116
139
|
};
|
|
140
|
+
return attachScaffoldTemplateVariableGroups(flatVariables, {
|
|
141
|
+
alternateRenderTargets: {
|
|
142
|
+
csv: '',
|
|
143
|
+
enabled: false,
|
|
144
|
+
hasEmail: false,
|
|
145
|
+
hasMjml: false,
|
|
146
|
+
hasPlainText: false,
|
|
147
|
+
json: '[]',
|
|
148
|
+
targets: [],
|
|
149
|
+
},
|
|
150
|
+
compound: {
|
|
151
|
+
enabled: false,
|
|
152
|
+
persistenceEnabled: false,
|
|
153
|
+
},
|
|
154
|
+
persistence: {
|
|
155
|
+
enabled: false,
|
|
156
|
+
scope: 'none',
|
|
157
|
+
},
|
|
158
|
+
queryLoop: {
|
|
159
|
+
enabled: false,
|
|
160
|
+
},
|
|
161
|
+
shared: {
|
|
162
|
+
author: answers.author.trim(),
|
|
163
|
+
blockMetadataVersion: BUILTIN_BLOCK_METADATA_VERSION,
|
|
164
|
+
category: metadataDefaults?.category ?? template?.defaultCategory ?? 'widgets',
|
|
165
|
+
cssClassName,
|
|
166
|
+
description,
|
|
167
|
+
descriptionJson: JSON.stringify(description),
|
|
168
|
+
frontendCssClassName: buildFrontendCssClassName(cssClassName),
|
|
169
|
+
icon: metadataDefaults?.icon ?? 'smiley',
|
|
170
|
+
keyword: slug.replace(/-/g, ' '),
|
|
171
|
+
namespace,
|
|
172
|
+
pascalCase,
|
|
173
|
+
phpPrefix,
|
|
174
|
+
phpPrefixUpper,
|
|
175
|
+
slug,
|
|
176
|
+
slugCamelCase: pascalCase.charAt(0).toLowerCase() + pascalCase.slice(1),
|
|
177
|
+
slugKebabCase: slug,
|
|
178
|
+
slugSnakeCase,
|
|
179
|
+
textDomain,
|
|
180
|
+
title,
|
|
181
|
+
titleCase: pascalCase,
|
|
182
|
+
titleJson: JSON.stringify(title),
|
|
183
|
+
versions: {
|
|
184
|
+
apiClient: apiClientPackageVersion,
|
|
185
|
+
blockRuntime: blockRuntimePackageVersion,
|
|
186
|
+
blockTypes: blockTypesPackageVersion,
|
|
187
|
+
projectTools: projectToolsPackageVersion,
|
|
188
|
+
rest: restPackageVersion,
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
template: {
|
|
192
|
+
description: template?.description ?? 'External scaffold template variables',
|
|
193
|
+
},
|
|
194
|
+
templateFamily: 'external',
|
|
195
|
+
});
|
|
117
196
|
}
|