@wp-typia/project-tools 0.16.6 → 0.16.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -8
- package/dist/runtime/block-generator-service.d.ts +5 -1
- package/dist/runtime/block-generator-service.js +132 -15
- package/dist/runtime/block-generator-tool-contract.d.ts +93 -0
- package/dist/runtime/block-generator-tool-contract.js +157 -0
- package/dist/runtime/built-in-block-code-artifacts.js +5 -5
- package/dist/runtime/cli-add-block.d.ts +36 -0
- package/dist/runtime/cli-add-block.js +518 -0
- package/dist/runtime/cli-add-shared.d.ts +93 -0
- package/dist/runtime/cli-add-shared.js +201 -0
- package/dist/runtime/cli-add-workspace.d.ts +81 -0
- package/dist/runtime/cli-add-workspace.js +582 -0
- package/dist/runtime/cli-add.d.ts +11 -131
- package/dist/runtime/cli-add.js +10 -1250
- package/dist/runtime/cli-prompt.d.ts +25 -0
- package/dist/runtime/cli-prompt.js +32 -20
- package/dist/runtime/cli-scaffold.js +1 -2
- package/dist/runtime/index.d.ts +2 -0
- package/dist/runtime/index.js +1 -0
- package/dist/runtime/migration-types.d.ts +9 -53
- package/dist/runtime/scaffold.js +1 -2
- package/dist/runtime/template-builtins.d.ts +11 -1
- package/dist/runtime/template-builtins.js +118 -25
- package/dist/runtime/template-layers.d.ts +31 -0
- package/dist/runtime/template-layers.js +171 -0
- package/dist/runtime/template-render.d.ts +15 -0
- package/dist/runtime/template-render.js +36 -0
- package/dist/runtime/template-source.d.ts +17 -0
- package/dist/runtime/template-source.js +14 -3
- package/package.json +6 -8
- package/templates/_shared/base/package.json.mustache +1 -0
- package/templates/_shared/compound/core/package.json.mustache +1 -1
- package/templates/_shared/compound/core/scripts/add-compound-child.ts.mustache +5 -5
- package/templates/_shared/compound/persistence/package.json.mustache +1 -1
- package/templates/_shared/persistence/core/package.json.mustache +1 -0
- package/templates/interactivity/package.json.mustache +2 -1
|
@@ -26,4 +26,19 @@ export declare function renderMustacheTemplateString(template: string, view: Tem
|
|
|
26
26
|
export declare function copyRawDirectory(sourceDir: string, targetDir: string, options?: CopyRawDirectoryOptions): Promise<void>;
|
|
27
27
|
export declare function copyRenderedDirectory(sourceDir: string, targetDir: string, view: TemplateRenderView): Promise<void>;
|
|
28
28
|
export declare function copyInterpolatedDirectory(sourceDir: string, targetDir: string, view: Record<string, string>): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Lists the output file paths produced by an interpolated template directory
|
|
31
|
+
* without writing any files to disk.
|
|
32
|
+
*
|
|
33
|
+
* This walks the source directory, applies the same filename interpolation and
|
|
34
|
+
* `.mustache` stripping rules as `copyInterpolatedDirectory(...)`, and returns
|
|
35
|
+
* normalized output-relative paths under a virtual root.
|
|
36
|
+
*
|
|
37
|
+
* @param sourceDir - The template directory to traverse.
|
|
38
|
+
* @param view - The interpolation map used when resolving file and directory
|
|
39
|
+
* names.
|
|
40
|
+
* @returns A sorted array of normalized output paths relative to a virtual
|
|
41
|
+
* preview root.
|
|
42
|
+
*/
|
|
43
|
+
export declare function listInterpolatedDirectoryOutputs(sourceDir: string, view: Record<string, string>): Promise<string[]>;
|
|
29
44
|
export declare function pathExists(targetPath: string): boolean;
|
|
@@ -118,6 +118,42 @@ export async function copyInterpolatedDirectory(sourceDir, targetDir, view) {
|
|
|
118
118
|
await fsp.writeFile(destinationPath, renderInterpolatedString(content, view), "utf8");
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
|
+
/**
|
|
122
|
+
* Lists the output file paths produced by an interpolated template directory
|
|
123
|
+
* without writing any files to disk.
|
|
124
|
+
*
|
|
125
|
+
* This walks the source directory, applies the same filename interpolation and
|
|
126
|
+
* `.mustache` stripping rules as `copyInterpolatedDirectory(...)`, and returns
|
|
127
|
+
* normalized output-relative paths under a virtual root.
|
|
128
|
+
*
|
|
129
|
+
* @param sourceDir - The template directory to traverse.
|
|
130
|
+
* @param view - The interpolation map used when resolving file and directory
|
|
131
|
+
* names.
|
|
132
|
+
* @returns A sorted array of normalized output paths relative to a virtual
|
|
133
|
+
* preview root.
|
|
134
|
+
*/
|
|
135
|
+
export async function listInterpolatedDirectoryOutputs(sourceDir, view) {
|
|
136
|
+
const virtualRoot = path.resolve("/wp-typia-template-preview");
|
|
137
|
+
const outputs = [];
|
|
138
|
+
async function visit(currentSourceDir, currentTargetDir) {
|
|
139
|
+
const entries = await fsp.readdir(currentSourceDir, { withFileTypes: true });
|
|
140
|
+
for (const entry of entries) {
|
|
141
|
+
const sourcePath = path.join(currentSourceDir, entry.name);
|
|
142
|
+
const destinationNameTemplate = entry.name.endsWith(".mustache")
|
|
143
|
+
? entry.name.slice(0, -".mustache".length)
|
|
144
|
+
: entry.name;
|
|
145
|
+
const destinationName = renderInterpolatedString(destinationNameTemplate, view);
|
|
146
|
+
const destinationPath = resolveRenderedPath(currentTargetDir, destinationName);
|
|
147
|
+
if (entry.isDirectory()) {
|
|
148
|
+
await visit(sourcePath, destinationPath);
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
outputs.push(path.relative(virtualRoot, destinationPath).replace(/\\/g, "/"));
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
await visit(sourceDir, virtualRoot);
|
|
155
|
+
return outputs.sort((left, right) => left.localeCompare(right));
|
|
156
|
+
}
|
|
121
157
|
export function pathExists(targetPath) {
|
|
122
158
|
return fs.existsSync(targetPath);
|
|
123
159
|
}
|
|
@@ -52,6 +52,14 @@ interface NpmTemplateLocator {
|
|
|
52
52
|
rawSpec: string;
|
|
53
53
|
type: string;
|
|
54
54
|
}
|
|
55
|
+
interface SeedSource {
|
|
56
|
+
assetsDir?: string;
|
|
57
|
+
blockDir: string;
|
|
58
|
+
cleanup?: () => Promise<void>;
|
|
59
|
+
rootDir: string;
|
|
60
|
+
selectedVariant?: string | null;
|
|
61
|
+
warnings?: string[];
|
|
62
|
+
}
|
|
55
63
|
type RemoteTemplateLocator = {
|
|
56
64
|
kind: "github";
|
|
57
65
|
locator: GitHubTemplateLocator;
|
|
@@ -65,6 +73,15 @@ type RemoteTemplateLocator = {
|
|
|
65
73
|
export declare function parseGitHubTemplateLocator(templateId: string): GitHubTemplateLocator | null;
|
|
66
74
|
export declare function parseNpmTemplateLocator(templateId: string): NpmTemplateLocator | null;
|
|
67
75
|
export declare function parseTemplateLocator(templateId: string): RemoteTemplateLocator;
|
|
76
|
+
/**
|
|
77
|
+
* Resolves a template locator into a local seed source directory.
|
|
78
|
+
*
|
|
79
|
+
* @param locator Remote template locator describing a local path, GitHub source, or npm package.
|
|
80
|
+
* @param cwd Current working directory used to resolve local template paths.
|
|
81
|
+
* @returns A local seed source containing the resolved root and block directory, plus optional cleanup.
|
|
82
|
+
* @throws When the locator is invalid, the source cannot be fetched, or filesystem validation fails.
|
|
83
|
+
*/
|
|
84
|
+
export declare function resolveTemplateSeed(locator: RemoteTemplateLocator, cwd: string): Promise<SeedSource>;
|
|
68
85
|
export declare function resolveTemplateSource(templateId: string, cwd: string, variables: {
|
|
69
86
|
[key: string]: string;
|
|
70
87
|
}, variant?: string): Promise<ResolvedTemplateSource>;
|
|
@@ -9,16 +9,16 @@ import { pathToFileURL } from "node:url";
|
|
|
9
9
|
import npa from "npm-package-arg";
|
|
10
10
|
import semver from "semver";
|
|
11
11
|
import { x as extractTarball } from "tar";
|
|
12
|
-
import { BUILTIN_TEMPLATE_IDS, PROJECT_TOOLS_PACKAGE_ROOT, isBuiltInTemplateId, } from "./template-registry.js";
|
|
12
|
+
import { BUILTIN_TEMPLATE_IDS, OFFICIAL_WORKSPACE_TEMPLATE_PACKAGE, PROJECT_TOOLS_PACKAGE_ROOT, isBuiltInTemplateId, } from "./template-registry.js";
|
|
13
13
|
import { isPlainObject } from "./object-utils.js";
|
|
14
14
|
import { getRemovedBuiltInTemplateMessage, isRemovedBuiltInTemplateId, } from "./template-defaults.js";
|
|
15
15
|
import { getBuiltInTemplateLayerDirs, isOmittableBuiltInTemplateLayerDir, resolveBuiltInTemplateSource, } from "./template-builtins.js";
|
|
16
|
+
import { loadExternalTemplateLayerManifest } from "./template-layers.js";
|
|
16
17
|
import { getPackageVersions } from "./package-versions.js";
|
|
17
18
|
import { toSegmentPascalCase } from "./string-case.js";
|
|
18
19
|
import { copyRawDirectory, copyRenderedDirectory } from "./template-render.js";
|
|
19
20
|
const EXTERNAL_TEMPLATE_ENTRY_CANDIDATES = ["index.js", "index.cjs", "index.mjs"];
|
|
20
21
|
const TEMPLATE_WARNING_MESSAGE = "wp-typia owns package/tooling/sync setup for generated projects, so this external template setting is ignored.";
|
|
21
|
-
const OFFICIAL_WORKSPACE_TEMPLATE_PACKAGE = "@wp-typia/create-workspace-template";
|
|
22
22
|
function isTemplatePathLocator(templateId) {
|
|
23
23
|
return path.isAbsolute(templateId) || templateId.startsWith("./") || templateId.startsWith("../");
|
|
24
24
|
}
|
|
@@ -316,6 +316,9 @@ async function detectTemplateSourceFormat(sourceDir) {
|
|
|
316
316
|
if (fs.existsSync(path.join(sourceDir, "package.json.mustache"))) {
|
|
317
317
|
return "wp-typia";
|
|
318
318
|
}
|
|
319
|
+
if (await loadExternalTemplateLayerManifest(sourceDir)) {
|
|
320
|
+
throw new Error(`Template source at ${sourceDir} is an external layer package. External layers currently compose only through built-in scaffolds via the runtime API, not as standalone template ids.`);
|
|
321
|
+
}
|
|
319
322
|
if (getExternalTemplateEntry(sourceDir)) {
|
|
320
323
|
return "create-block-external";
|
|
321
324
|
}
|
|
@@ -729,7 +732,15 @@ async function resolveGitHubTemplateSource(locator) {
|
|
|
729
732
|
throw error;
|
|
730
733
|
}
|
|
731
734
|
}
|
|
732
|
-
|
|
735
|
+
/**
|
|
736
|
+
* Resolves a template locator into a local seed source directory.
|
|
737
|
+
*
|
|
738
|
+
* @param locator Remote template locator describing a local path, GitHub source, or npm package.
|
|
739
|
+
* @param cwd Current working directory used to resolve local template paths.
|
|
740
|
+
* @returns A local seed source containing the resolved root and block directory, plus optional cleanup.
|
|
741
|
+
* @throws When the locator is invalid, the source cannot be fetched, or filesystem validation fails.
|
|
742
|
+
*/
|
|
743
|
+
export async function resolveTemplateSeed(locator, cwd) {
|
|
733
744
|
if (locator.kind === "path") {
|
|
734
745
|
const sourceDir = path.resolve(cwd, locator.templatePath);
|
|
735
746
|
if (!fs.existsSync(sourceDir)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wp-typia/project-tools",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.8",
|
|
4
4
|
"description": "Project orchestration and programmatic tooling for wp-typia",
|
|
5
5
|
"packageManager": "bun@1.3.11",
|
|
6
6
|
"type": "module",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"prepack": "bun run build && node ./scripts/publish-manifest.mjs prepare",
|
|
76
76
|
"postpack": "node ./scripts/publish-manifest.mjs restore",
|
|
77
77
|
"test": "bun run build && bun test tests/*.test.ts",
|
|
78
|
-
"test:scaffold-core": "bun run build && bun test tests/block-generator-service.test.ts tests/built-in-block-artifacts.test.ts tests/scaffold-basic.test.ts tests/scaffold-persistence.test.ts tests/template-source.test.ts tests/cli-entry.test.ts tests/import-policy.test.ts",
|
|
78
|
+
"test:scaffold-core": "bun run build && bun test tests/block-generator-service.test.ts tests/built-in-block-artifacts.test.ts tests/scaffold-basic.test.ts tests/scaffold-persistence.test.ts tests/template-source.test.ts tests/cli-entry.test.ts tests/cli-prompt.test.ts tests/import-policy.test.ts",
|
|
79
79
|
"test:workspace": "bun run build && bun test tests/workspace-add.test.ts tests/workspace-doctor.test.ts",
|
|
80
80
|
"test:compound": "bun run build && bun test tests/scaffold-compound.test.ts",
|
|
81
81
|
"test:migration-planning": "bun run build && bun test tests/migration-init.test.ts tests/migration-config.test.ts tests/migration-plan-wizard.test.ts",
|
|
@@ -114,9 +114,9 @@
|
|
|
114
114
|
"bun": ">=1.3.11"
|
|
115
115
|
},
|
|
116
116
|
"dependencies": {
|
|
117
|
-
"@wp-typia/api-client": "^0.4.
|
|
118
|
-
"@wp-typia/block-runtime": "^0.4.
|
|
119
|
-
"@wp-typia/rest": "^0.3.
|
|
117
|
+
"@wp-typia/api-client": "^0.4.4",
|
|
118
|
+
"@wp-typia/block-runtime": "^0.4.7",
|
|
119
|
+
"@wp-typia/rest": "^0.3.7",
|
|
120
120
|
"@wp-typia/block-types": "^0.2.1",
|
|
121
121
|
"mustache": "^4.2.0",
|
|
122
122
|
"npm-package-arg": "^13.0.0",
|
|
@@ -126,8 +126,6 @@
|
|
|
126
126
|
"typescript": "^5.9.2"
|
|
127
127
|
},
|
|
128
128
|
"devDependencies": {
|
|
129
|
-
"react": "^19.2.0"
|
|
130
|
-
"react-devtools-core": "^7.0.1",
|
|
131
|
-
"ws": "^8.18.0"
|
|
129
|
+
"react": "^19.2.0"
|
|
132
130
|
}
|
|
133
131
|
}
|
|
@@ -460,7 +460,8 @@ function renderEditFile(
|
|
|
460
460
|
): string {
|
|
461
461
|
const childCssClassName = buildBlockCssClassName( PARENT_BLOCK_NAMESPACE, childFolderSlug );
|
|
462
462
|
|
|
463
|
-
return `import {
|
|
463
|
+
return `import type { BlockEditProps } from '@wordpress/blocks';
|
|
464
|
+
import { RichText, useBlockProps } from '@wordpress/block-editor';
|
|
464
465
|
import { Notice } from '@wordpress/components';
|
|
465
466
|
import { __ } from '@wordpress/i18n';
|
|
466
467
|
|
|
@@ -471,13 +472,12 @@ import {
|
|
|
471
472
|
\tvalidate${ childInterfaceName },
|
|
472
473
|
} from './validators';
|
|
473
474
|
|
|
475
|
+
type EditProps = BlockEditProps< ${ childTypeName } >;
|
|
476
|
+
|
|
474
477
|
export default function Edit( {
|
|
475
478
|
\tattributes,
|
|
476
479
|
\tsetAttributes,
|
|
477
|
-
}: {
|
|
478
|
-
\tattributes: ${ childTypeName };
|
|
479
|
-
\tsetAttributes: ( attrs: Partial< ${ childTypeName } > ) => void;
|
|
480
|
-
} ) {
|
|
480
|
+
}: EditProps ) {
|
|
481
481
|
\tconst updateAttribute = createAttributeUpdater( attributes, setAttributes );
|
|
482
482
|
\tconst { errorMessages, isValid } = useTypiaValidation(
|
|
483
483
|
\t\tattributes,
|
|
@@ -25,9 +25,10 @@
|
|
|
25
25
|
"@types/wordpress__block-editor": "^11.5.17",
|
|
26
26
|
"@types/wordpress__blocks": "^12.5.18",
|
|
27
27
|
"@wordpress/browserslist-config": "^6.42.0",
|
|
28
|
-
|
|
28
|
+
"@wordpress/scripts": "^30.22.0",
|
|
29
29
|
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
30
30
|
"@typia/unplugin": "^12.0.1",
|
|
31
|
+
"prettier": "3.8.2",
|
|
31
32
|
"tsx": "^4.20.5",
|
|
32
33
|
"typescript": "^5.9.2",
|
|
33
34
|
"typia": "^12.0.1"
|