wp-typia 0.20.3 → 0.20.5
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-bunli/.bunli/commands.gen.js +427 -293
- package/dist-bunli/{cli-add-43f9hqev.js → cli-add-6byyahb8.js} +148 -51
- package/dist-bunli/{cli-diagnostics-db6kxv83.js → cli-diagnostics-zecc6w1f.js} +1 -1
- package/dist-bunli/{cli-doctor-wnx8rv84.js → cli-doctor-2bc4sq7v.js} +4 -3
- package/dist-bunli/{cli-8rnhjvb8.js → cli-j1tyw390.js} +250 -213
- package/dist-bunli/{cli-scaffold-nt1fx2f0.js → cli-scaffold-19gyvxxt.js} +1 -1
- package/dist-bunli/{cli-z18m4k4g.js → cli-xnh2s5kz.js} +4 -4
- package/dist-bunli/{cli-jcd4wgam.js → cli-xxzpb58s.js} +6 -2
- package/dist-bunli/cli.js +4 -4
- package/dist-bunli/{command-list-g3z86j3x.js → command-list-pztcgga5.js} +8 -8
- package/dist-bunli/node-cli.js +3 -3
- package/package.json +2 -2
|
@@ -695,13 +695,13 @@ var require_hosts = __commonJS((exports, module) => {
|
|
|
695
695
|
var defaults = {
|
|
696
696
|
sshtemplate: ({ domain, user, project, committish }) => `git@${domain}:${user}/${project}.git${maybeJoin("#", committish)}`,
|
|
697
697
|
sshurltemplate: ({ domain, user, project, committish }) => `git+ssh://git@${domain}/${user}/${project}.git${maybeJoin("#", committish)}`,
|
|
698
|
-
edittemplate: ({ domain, user, project, committish, editpath, path:
|
|
698
|
+
edittemplate: ({ domain, user, project, committish, editpath, path: path6 }) => `https://${domain}/${user}/${project}${maybeJoin("/", editpath, "/", maybeEncode(committish || "HEAD"), "/", path6)}`,
|
|
699
699
|
browsetemplate: ({ domain, user, project, committish, treepath }) => `https://${domain}/${user}/${project}${maybeJoin("/", treepath, "/", maybeEncode(committish))}`,
|
|
700
|
-
browsetreetemplate: ({ domain, user, project, committish, treepath, path:
|
|
701
|
-
browseblobtemplate: ({ domain, user, project, committish, blobpath, path:
|
|
700
|
+
browsetreetemplate: ({ domain, user, project, committish, treepath, path: path6, fragment, hashformat }) => `https://${domain}/${user}/${project}/${treepath}/${maybeEncode(committish || "HEAD")}/${path6}${maybeJoin("#", hashformat(fragment || ""))}`,
|
|
701
|
+
browseblobtemplate: ({ domain, user, project, committish, blobpath, path: path6, fragment, hashformat }) => `https://${domain}/${user}/${project}/${blobpath}/${maybeEncode(committish || "HEAD")}/${path6}${maybeJoin("#", hashformat(fragment || ""))}`,
|
|
702
702
|
docstemplate: ({ domain, user, project, treepath, committish }) => `https://${domain}/${user}/${project}${maybeJoin("/", treepath, "/", maybeEncode(committish))}#readme`,
|
|
703
703
|
httpstemplate: ({ auth, domain, user, project, committish }) => `git+https://${maybeJoin(auth, "@")}${domain}/${user}/${project}.git${maybeJoin("#", committish)}`,
|
|
704
|
-
filetemplate: ({ domain, user, project, committish, path:
|
|
704
|
+
filetemplate: ({ domain, user, project, committish, path: path6 }) => `https://${domain}/${user}/${project}/raw/${maybeEncode(committish || "HEAD")}/${path6}`,
|
|
705
705
|
shortcuttemplate: ({ type, user, project, committish }) => `${type}:${user}/${project}${maybeJoin("#", committish)}`,
|
|
706
706
|
pathtemplate: ({ user, project, committish }) => `${user}/${project}${maybeJoin("#", committish)}`,
|
|
707
707
|
bugstemplate: ({ domain, user, project }) => `https://${domain}/${user}/${project}/issues`,
|
|
@@ -714,7 +714,7 @@ var require_hosts = __commonJS((exports, module) => {
|
|
|
714
714
|
treepath: "tree",
|
|
715
715
|
blobpath: "blob",
|
|
716
716
|
editpath: "edit",
|
|
717
|
-
filetemplate: ({ auth, user, project, committish, path:
|
|
717
|
+
filetemplate: ({ auth, user, project, committish, path: path6 }) => `https://${maybeJoin(auth, "@")}raw.githubusercontent.com/${user}/${project}/${maybeEncode(committish || "HEAD")}/${path6}`,
|
|
718
718
|
gittemplate: ({ auth, domain, user, project, committish }) => `git://${maybeJoin(auth, "@")}${domain}/${user}/${project}.git${maybeJoin("#", committish)}`,
|
|
719
719
|
tarballtemplate: ({ domain, user, project, committish }) => `https://codeload.${domain}/${user}/${project}/tar.gz/${maybeEncode(committish || "HEAD")}`,
|
|
720
720
|
extract: (url) => {
|
|
@@ -740,7 +740,7 @@ var require_hosts = __commonJS((exports, module) => {
|
|
|
740
740
|
treepath: "src",
|
|
741
741
|
blobpath: "src",
|
|
742
742
|
editpath: "?mode=edit",
|
|
743
|
-
edittemplate: ({ domain, user, project, committish, treepath, path:
|
|
743
|
+
edittemplate: ({ domain, user, project, committish, treepath, path: path6, editpath }) => `https://${domain}/${user}/${project}${maybeJoin("/", treepath, "/", maybeEncode(committish || "HEAD"), "/", path6, editpath)}`,
|
|
744
744
|
tarballtemplate: ({ domain, user, project, committish }) => `https://${domain}/${user}/${project}/get/${maybeEncode(committish || "HEAD")}.tar.gz`,
|
|
745
745
|
extract: (url) => {
|
|
746
746
|
let [, user, project, aux] = url.pathname.split("/", 4);
|
|
@@ -764,11 +764,11 @@ var require_hosts = __commonJS((exports, module) => {
|
|
|
764
764
|
editpath: "-/edit",
|
|
765
765
|
tarballtemplate: ({ domain, user, project, committish }) => `https://${domain}/${user}/${project}/repository/archive.tar.gz?ref=${maybeEncode(committish || "HEAD")}`,
|
|
766
766
|
extract: (url) => {
|
|
767
|
-
const
|
|
768
|
-
if (
|
|
767
|
+
const path6 = url.pathname.slice(1);
|
|
768
|
+
if (path6.includes("/-/") || path6.includes("/archive.tar.gz")) {
|
|
769
769
|
return;
|
|
770
770
|
}
|
|
771
|
-
const segments =
|
|
771
|
+
const segments = path6.split("/");
|
|
772
772
|
let project = segments.pop();
|
|
773
773
|
if (project.endsWith(".git")) {
|
|
774
774
|
project = project.slice(0, -4);
|
|
@@ -788,11 +788,11 @@ var require_hosts = __commonJS((exports, module) => {
|
|
|
788
788
|
sshurltemplate: ({ domain, project, committish }) => `git+ssh://git@${domain}/${project}.git${maybeJoin("#", committish)}`,
|
|
789
789
|
edittemplate: ({ domain, user, project, committish, editpath }) => `https://${domain}/${user}/${project}${maybeJoin("/", maybeEncode(committish))}/${editpath}`,
|
|
790
790
|
browsetemplate: ({ domain, project, committish }) => `https://${domain}/${project}${maybeJoin("/", maybeEncode(committish))}`,
|
|
791
|
-
browsetreetemplate: ({ domain, project, committish, path:
|
|
792
|
-
browseblobtemplate: ({ domain, project, committish, path:
|
|
791
|
+
browsetreetemplate: ({ domain, project, committish, path: path6, hashformat }) => `https://${domain}/${project}${maybeJoin("/", maybeEncode(committish))}${maybeJoin("#", hashformat(path6))}`,
|
|
792
|
+
browseblobtemplate: ({ domain, project, committish, path: path6, hashformat }) => `https://${domain}/${project}${maybeJoin("/", maybeEncode(committish))}${maybeJoin("#", hashformat(path6))}`,
|
|
793
793
|
docstemplate: ({ domain, project, committish }) => `https://${domain}/${project}${maybeJoin("/", maybeEncode(committish))}`,
|
|
794
794
|
httpstemplate: ({ domain, project, committish }) => `git+https://${domain}/${project}.git${maybeJoin("#", committish)}`,
|
|
795
|
-
filetemplate: ({ user, project, committish, path:
|
|
795
|
+
filetemplate: ({ user, project, committish, path: path6 }) => `https://gist.githubusercontent.com/${user}/${project}/raw${maybeJoin("/", maybeEncode(committish))}/${path6}`,
|
|
796
796
|
shortcuttemplate: ({ type, project, committish }) => `${type}:${project}${maybeJoin("#", committish)}`,
|
|
797
797
|
pathtemplate: ({ project, committish }) => `${project}${maybeJoin("#", committish)}`,
|
|
798
798
|
bugstemplate: ({ domain, project }) => `https://${domain}/${project}`,
|
|
@@ -824,7 +824,7 @@ var require_hosts = __commonJS((exports, module) => {
|
|
|
824
824
|
domain: "git.sr.ht",
|
|
825
825
|
treepath: "tree",
|
|
826
826
|
blobpath: "tree",
|
|
827
|
-
filetemplate: ({ domain, user, project, committish, path:
|
|
827
|
+
filetemplate: ({ domain, user, project, committish, path: path6 }) => `https://${domain}/${user}/${project}/blob/${maybeEncode(committish) || "HEAD"}/${path6}`,
|
|
828
828
|
httpstemplate: ({ domain, user, project, committish }) => `https://${domain}/${user}/${project}.git${maybeJoin("#", committish)}`,
|
|
829
829
|
tarballtemplate: ({ domain, user, project, committish }) => `https://${domain}/${user}/${project}/archive/${maybeEncode(committish) || "HEAD"}.tar.gz`,
|
|
830
830
|
bugstemplate: () => null,
|
|
@@ -1005,8 +1005,8 @@ var require_lib = __commonJS((exports, module) => {
|
|
|
1005
1005
|
return null;
|
|
1006
1006
|
}
|
|
1007
1007
|
const proto = /(?:git\+)http:$/.test(protocol) ? "http:" : "https:";
|
|
1008
|
-
const
|
|
1009
|
-
return `${proto}//${hostname}${
|
|
1008
|
+
const path6 = pathname.replace(/\.git$/, "");
|
|
1009
|
+
return `${proto}//${hostname}${path6}`;
|
|
1010
1010
|
} catch {
|
|
1011
1011
|
return null;
|
|
1012
1012
|
}
|
|
@@ -1099,20 +1099,20 @@ var require_lib = __commonJS((exports, module) => {
|
|
|
1099
1099
|
sshurl(opts) {
|
|
1100
1100
|
return this.#fill(this.sshurltemplate, opts);
|
|
1101
1101
|
}
|
|
1102
|
-
browse(
|
|
1103
|
-
if (typeof
|
|
1104
|
-
return this.#fill(this.browsetemplate,
|
|
1102
|
+
browse(path6, ...args) {
|
|
1103
|
+
if (typeof path6 !== "string") {
|
|
1104
|
+
return this.#fill(this.browsetemplate, path6);
|
|
1105
1105
|
}
|
|
1106
1106
|
if (typeof args[0] !== "string") {
|
|
1107
|
-
return this.#fill(this.browsetreetemplate, { ...args[0], path:
|
|
1107
|
+
return this.#fill(this.browsetreetemplate, { ...args[0], path: path6 });
|
|
1108
1108
|
}
|
|
1109
|
-
return this.#fill(this.browsetreetemplate, { ...args[1], fragment: args[0], path:
|
|
1109
|
+
return this.#fill(this.browsetreetemplate, { ...args[1], fragment: args[0], path: path6 });
|
|
1110
1110
|
}
|
|
1111
|
-
browseFile(
|
|
1111
|
+
browseFile(path6, ...args) {
|
|
1112
1112
|
if (typeof args[0] !== "string") {
|
|
1113
|
-
return this.#fill(this.browseblobtemplate, { ...args[0], path:
|
|
1113
|
+
return this.#fill(this.browseblobtemplate, { ...args[0], path: path6 });
|
|
1114
1114
|
}
|
|
1115
|
-
return this.#fill(this.browseblobtemplate, { ...args[1], fragment: args[0], path:
|
|
1115
|
+
return this.#fill(this.browseblobtemplate, { ...args[1], fragment: args[0], path: path6 });
|
|
1116
1116
|
}
|
|
1117
1117
|
docs(opts) {
|
|
1118
1118
|
return this.#fill(this.docstemplate, opts);
|
|
@@ -1135,11 +1135,11 @@ var require_lib = __commonJS((exports, module) => {
|
|
|
1135
1135
|
tarball(opts) {
|
|
1136
1136
|
return this.#fill(this.tarballtemplate, { ...opts, noCommittish: false });
|
|
1137
1137
|
}
|
|
1138
|
-
file(
|
|
1139
|
-
return this.#fill(this.filetemplate, { ...opts, path:
|
|
1138
|
+
file(path6, opts) {
|
|
1139
|
+
return this.#fill(this.filetemplate, { ...opts, path: path6 });
|
|
1140
1140
|
}
|
|
1141
|
-
edit(
|
|
1142
|
-
return this.#fill(this.edittemplate, { ...opts, path:
|
|
1141
|
+
edit(path6, opts) {
|
|
1142
|
+
return this.#fill(this.edittemplate, { ...opts, path: path6 });
|
|
1143
1143
|
}
|
|
1144
1144
|
getDefaultRepresentation() {
|
|
1145
1145
|
return this.default;
|
|
@@ -3199,7 +3199,7 @@ var require_lib3 = __commonJS((exports, module) => {
|
|
|
3199
3199
|
var require_npa = __commonJS((exports, module) => {
|
|
3200
3200
|
var isWindows = process.platform === "win32";
|
|
3201
3201
|
var { URL: URL2 } = __require("url");
|
|
3202
|
-
var
|
|
3202
|
+
var path6 = isWindows ? __require("path/win32") : __require("path");
|
|
3203
3203
|
var { homedir } = __require("os");
|
|
3204
3204
|
var HostedGit = require_lib();
|
|
3205
3205
|
var semver = require_semver2();
|
|
@@ -3455,7 +3455,7 @@ var require_npa = __commonJS((exports, module) => {
|
|
|
3455
3455
|
let resolvedUrl;
|
|
3456
3456
|
let specUrl;
|
|
3457
3457
|
try {
|
|
3458
|
-
resolvedUrl = new URL2(rawSpec, `${pathToFileURL(
|
|
3458
|
+
resolvedUrl = new URL2(rawSpec, `${pathToFileURL(path6.resolve(where))}/`);
|
|
3459
3459
|
specUrl = new URL2(rawSpec);
|
|
3460
3460
|
} catch (originalError) {
|
|
3461
3461
|
const er = new Error("Invalid file: URL, must comply with RFC 8089");
|
|
@@ -3474,13 +3474,13 @@ var require_npa = __commonJS((exports, module) => {
|
|
|
3474
3474
|
}
|
|
3475
3475
|
if (/^\/~(\/|$)/.test(specPath)) {
|
|
3476
3476
|
res.saveSpec = `file:${specPath.substr(1)}`;
|
|
3477
|
-
resolvedPath =
|
|
3478
|
-
} else if (!
|
|
3479
|
-
res.saveSpec = `file:${
|
|
3477
|
+
resolvedPath = path6.resolve(homedir(), specPath.substr(3));
|
|
3478
|
+
} else if (!path6.isAbsolute(rawSpec.slice(5))) {
|
|
3479
|
+
res.saveSpec = `file:${path6.relative(where, resolvedPath)}`;
|
|
3480
3480
|
} else {
|
|
3481
|
-
res.saveSpec = `file:${
|
|
3481
|
+
res.saveSpec = `file:${path6.resolve(resolvedPath)}`;
|
|
3482
3482
|
}
|
|
3483
|
-
res.fetchSpec =
|
|
3483
|
+
res.fetchSpec = path6.resolve(where, resolvedPath);
|
|
3484
3484
|
res.saveSpec = res.saveSpec.split("\\").join("/");
|
|
3485
3485
|
if (res.saveSpec.startsWith("file://")) {
|
|
3486
3486
|
res.saveSpec = `file:/${res.saveSpec.slice(7)}`;
|
|
@@ -5916,6 +5916,72 @@ function getCompoundInnerBlocksPresetDefinition(value) {
|
|
|
5916
5916
|
|
|
5917
5917
|
// ../wp-typia-project-tools/src/runtime/scaffold-answer-resolution.ts
|
|
5918
5918
|
import { execSync } from "child_process";
|
|
5919
|
+
import path7 from "path";
|
|
5920
|
+
|
|
5921
|
+
// ../wp-typia-project-tools/src/runtime/template-source-locators.ts
|
|
5922
|
+
var import_npm_package_arg = __toESM(require_npa(), 1);
|
|
5923
|
+
import path6 from "path";
|
|
5924
|
+
function isTemplatePathLocator(templateId) {
|
|
5925
|
+
return path6.isAbsolute(templateId) || templateId.startsWith("./") || templateId.startsWith("../");
|
|
5926
|
+
}
|
|
5927
|
+
function parseGitHubTemplateLocator(templateId) {
|
|
5928
|
+
if (!templateId.startsWith("github:")) {
|
|
5929
|
+
return null;
|
|
5930
|
+
}
|
|
5931
|
+
const [locatorBody, refSegment] = templateId.slice("github:".length).split("#", 2);
|
|
5932
|
+
const segments = locatorBody.split("/").filter(Boolean);
|
|
5933
|
+
if (segments.length < 3) {
|
|
5934
|
+
throw new Error(`GitHub template locators must look like github:owner/repo/path[#ref]. Received: ${templateId}`);
|
|
5935
|
+
}
|
|
5936
|
+
const [owner, repo, ...sourcePathSegments] = segments;
|
|
5937
|
+
return {
|
|
5938
|
+
owner,
|
|
5939
|
+
repo,
|
|
5940
|
+
ref: refSegment ?? null,
|
|
5941
|
+
sourcePath: sourcePathSegments.join("/")
|
|
5942
|
+
};
|
|
5943
|
+
}
|
|
5944
|
+
function parseNpmTemplateLocator(templateId) {
|
|
5945
|
+
if (isBuiltInTemplateId(templateId) || isTemplatePathLocator(templateId) || templateId.startsWith("github:")) {
|
|
5946
|
+
return null;
|
|
5947
|
+
}
|
|
5948
|
+
try {
|
|
5949
|
+
const parsed = import_npm_package_arg.default(templateId);
|
|
5950
|
+
if (!parsed.registry || !parsed.name) {
|
|
5951
|
+
return null;
|
|
5952
|
+
}
|
|
5953
|
+
const parsedWithRawSpec = parsed;
|
|
5954
|
+
const rawSpec = typeof parsedWithRawSpec.rawSpec === "string" ? parsedWithRawSpec.rawSpec : "";
|
|
5955
|
+
return {
|
|
5956
|
+
fetchSpec: typeof parsed.fetchSpec === "string" ? parsed.fetchSpec : "",
|
|
5957
|
+
name: parsed.name,
|
|
5958
|
+
raw: templateId,
|
|
5959
|
+
rawSpec,
|
|
5960
|
+
type: parsed.type
|
|
5961
|
+
};
|
|
5962
|
+
} catch {
|
|
5963
|
+
return null;
|
|
5964
|
+
}
|
|
5965
|
+
}
|
|
5966
|
+
function parseTemplateLocator(templateId) {
|
|
5967
|
+
if (isRemovedBuiltInTemplateId(templateId)) {
|
|
5968
|
+
throw new Error(getRemovedBuiltInTemplateMessage(templateId));
|
|
5969
|
+
}
|
|
5970
|
+
const githubLocator = parseGitHubTemplateLocator(templateId);
|
|
5971
|
+
if (githubLocator) {
|
|
5972
|
+
return { kind: "github", locator: githubLocator };
|
|
5973
|
+
}
|
|
5974
|
+
if (isTemplatePathLocator(templateId)) {
|
|
5975
|
+
return { kind: "path", templatePath: templateId };
|
|
5976
|
+
}
|
|
5977
|
+
const npmLocator = parseNpmTemplateLocator(templateId);
|
|
5978
|
+
if (npmLocator) {
|
|
5979
|
+
return { kind: "npm", locator: npmLocator };
|
|
5980
|
+
}
|
|
5981
|
+
throw new Error(`Unknown template "${templateId}". Expected one of: ${BUILTIN_TEMPLATE_IDS.join(", ")}, a local path, github:owner/repo/path[#ref], or an npm package spec.`);
|
|
5982
|
+
}
|
|
5983
|
+
|
|
5984
|
+
// ../wp-typia-project-tools/src/runtime/scaffold-answer-resolution.ts
|
|
5919
5985
|
var WORKSPACE_TEMPLATE_ALIAS = "workspace";
|
|
5920
5986
|
var TEMPLATE_SELECTION_HINT = `--template <${[
|
|
5921
5987
|
...TEMPLATE_IDS,
|
|
@@ -5923,6 +5989,10 @@ var TEMPLATE_SELECTION_HINT = `--template <${[
|
|
|
5923
5989
|
].join("|")}|./path|github:owner/repo/path[#ref]|npm-package>`;
|
|
5924
5990
|
var TEMPLATE_SUGGESTION_IDS = [...TEMPLATE_IDS, WORKSPACE_TEMPLATE_ALIAS];
|
|
5925
5991
|
var QUERY_POST_TYPE_RULE = 'Use lowercase, 1-20 chars, and only a-z, 0-9, "_" or "-".';
|
|
5992
|
+
var USER_FACING_TEMPLATE_IDS = [
|
|
5993
|
+
...TEMPLATE_IDS,
|
|
5994
|
+
WORKSPACE_TEMPLATE_ALIAS
|
|
5995
|
+
];
|
|
5926
5996
|
function detectAuthor() {
|
|
5927
5997
|
try {
|
|
5928
5998
|
return execSync("git config user.name", {
|
|
@@ -5973,8 +6043,14 @@ function normalizeQueryPostType(value) {
|
|
|
5973
6043
|
function normalizeTemplateSelection(templateId) {
|
|
5974
6044
|
return templateId === WORKSPACE_TEMPLATE_ALIAS ? OFFICIAL_WORKSPACE_TEMPLATE_PACKAGE : templateId;
|
|
5975
6045
|
}
|
|
6046
|
+
function looksLikeWindowsAbsoluteTemplatePath(templateId) {
|
|
6047
|
+
return /^[a-z]:[\\/]/iu.test(templateId) || /^\\\\[^\\]+\\[^\\]+/u.test(templateId);
|
|
6048
|
+
}
|
|
6049
|
+
function looksLikeExplicitNonNpmExternalTemplateLocator(templateId) {
|
|
6050
|
+
return path7.isAbsolute(templateId) || looksLikeWindowsAbsoluteTemplatePath(templateId) || templateId.startsWith("./") || templateId.startsWith("../") || templateId.startsWith("@") || templateId.startsWith("github:") || templateId.includes("/");
|
|
6051
|
+
}
|
|
5976
6052
|
function looksLikeExplicitExternalTemplateLocator(templateId) {
|
|
5977
|
-
return
|
|
6053
|
+
return looksLikeExplicitNonNpmExternalTemplateLocator(templateId) || parseNpmTemplateLocator(templateId) !== null;
|
|
5978
6054
|
}
|
|
5979
6055
|
function getEditDistance(left, right) {
|
|
5980
6056
|
const previous = Array.from({ length: right.length + 1 }, (_, index) => index);
|
|
@@ -5993,7 +6069,7 @@ function getEditDistance(left, right) {
|
|
|
5993
6069
|
}
|
|
5994
6070
|
function findMistypedBuiltInTemplateSuggestion(templateId) {
|
|
5995
6071
|
const normalizedTemplateId = templateId.trim().toLowerCase();
|
|
5996
|
-
if (normalizedTemplateId.length === 0 ||
|
|
6072
|
+
if (normalizedTemplateId.length === 0 || looksLikeExplicitNonNpmExternalTemplateLocator(normalizedTemplateId)) {
|
|
5997
6073
|
return null;
|
|
5998
6074
|
}
|
|
5999
6075
|
let bestCandidate = null;
|
|
@@ -6016,6 +6092,13 @@ function getMistypedBuiltInTemplateMessage(templateId) {
|
|
|
6016
6092
|
const suggestionDescription = suggestion === WORKSPACE_TEMPLATE_ALIAS ? "official workspace scaffold" : "built-in scaffold";
|
|
6017
6093
|
return `Unknown template "${templateId}". Did you mean "${suggestion}"? Use \`--template ${suggestion}\` for the ${suggestionDescription}, or pass a local path, \`github:owner/repo/path[#ref]\`, or an npm package spec for an external template.`;
|
|
6018
6094
|
}
|
|
6095
|
+
function getUnknownTemplateMessage(templateId) {
|
|
6096
|
+
return [
|
|
6097
|
+
`Unknown template "${templateId}". Expected one of: ${USER_FACING_TEMPLATE_IDS.join(", ")}.`,
|
|
6098
|
+
"Run `wp-typia templates list` to inspect available templates.",
|
|
6099
|
+
"Pass an explicit external template locator such as `./path`, `github:owner/repo/path[#ref]`, or `@scope/template` for custom templates."
|
|
6100
|
+
].join(" ");
|
|
6101
|
+
}
|
|
6019
6102
|
async function resolveTemplateId({
|
|
6020
6103
|
templateId,
|
|
6021
6104
|
yes = false,
|
|
@@ -6037,6 +6120,9 @@ async function resolveTemplateId({
|
|
|
6037
6120
|
if (mistypedBuiltInTemplateMessage) {
|
|
6038
6121
|
throw new Error(mistypedBuiltInTemplateMessage);
|
|
6039
6122
|
}
|
|
6123
|
+
if (!looksLikeExplicitExternalTemplateLocator(normalizedTemplateId)) {
|
|
6124
|
+
throw new Error(getUnknownTemplateMessage(templateId));
|
|
6125
|
+
}
|
|
6040
6126
|
return normalizedTemplateId;
|
|
6041
6127
|
}
|
|
6042
6128
|
if (yes) {
|
|
@@ -6077,7 +6163,7 @@ async function collectScaffoldAnswers({
|
|
|
6077
6163
|
textDomain
|
|
6078
6164
|
}) {
|
|
6079
6165
|
const defaults = getDefaultAnswers(projectName, templateId);
|
|
6080
|
-
if (yes) {
|
|
6166
|
+
if (yes || !isBuiltInTemplateId(templateId) && !promptText) {
|
|
6081
6167
|
const identifiers2 = resolveScaffoldIdentifiers({
|
|
6082
6168
|
namespace: namespace ?? defaults.namespace,
|
|
6083
6169
|
phpPrefix,
|
|
@@ -6120,23 +6206,23 @@ async function collectScaffoldAnswers({
|
|
|
6120
6206
|
// ../wp-typia-project-tools/src/runtime/scaffold.ts
|
|
6121
6207
|
import fs14 from "fs";
|
|
6122
6208
|
import { promises as fsp10 } from "fs";
|
|
6123
|
-
import
|
|
6209
|
+
import path17 from "path";
|
|
6124
6210
|
|
|
6125
6211
|
// ../wp-typia-project-tools/src/runtime/scaffold-apply-utils.ts
|
|
6126
6212
|
import fs6 from "fs";
|
|
6127
6213
|
import { promises as fsp6 } from "fs";
|
|
6128
|
-
import
|
|
6214
|
+
import path11 from "path";
|
|
6129
6215
|
import { execSync as execSync3 } from "child_process";
|
|
6130
6216
|
import { fileURLToPath } from "url";
|
|
6131
6217
|
|
|
6132
6218
|
// ../wp-typia-project-tools/src/runtime/migration-ui-capability.ts
|
|
6133
6219
|
import { promises as fsp4 } from "fs";
|
|
6134
|
-
import
|
|
6220
|
+
import path8 from "path";
|
|
6135
6221
|
var INITIAL_MIGRATION_VERSION = "v1";
|
|
6136
6222
|
var BLOCK_METADATA_IMPORT_LINE = "import metadata from './block-metadata';";
|
|
6137
6223
|
var LEGACY_BLOCK_JSON_IMPORT_LINE = "import metadata from './block.json';";
|
|
6138
6224
|
async function mutatePackageJson2(projectDir, mutate) {
|
|
6139
|
-
const packageJsonPath =
|
|
6225
|
+
const packageJsonPath = path8.join(projectDir, "package.json");
|
|
6140
6226
|
const packageJson = JSON.parse(await fsp4.readFile(packageJsonPath, "utf8"));
|
|
6141
6227
|
mutate(packageJson);
|
|
6142
6228
|
await fsp4.writeFile(packageJsonPath, `${JSON.stringify(packageJson, null, "\t")}
|
|
@@ -6210,8 +6296,8 @@ function buildMigrationBlocks(templateId, variables) {
|
|
|
6210
6296
|
];
|
|
6211
6297
|
}
|
|
6212
6298
|
async function applySingleBlockPatches(projectDir, variables) {
|
|
6213
|
-
const editPath =
|
|
6214
|
-
const indexPath =
|
|
6299
|
+
const editPath = path8.join(projectDir, "src", "edit.tsx");
|
|
6300
|
+
const indexPath = path8.join(projectDir, "src", "index.tsx");
|
|
6215
6301
|
const deprecatedImport = `import { deprecated } from './migrations/generated/${variables.slugKebabCase}/deprecated';`;
|
|
6216
6302
|
const deprecatedLine = " deprecated,";
|
|
6217
6303
|
const dashboardImport = `import { MigrationDashboard } from './admin/migration-dashboard';`;
|
|
@@ -6232,10 +6318,10 @@ async function applySingleBlockPatches(projectDir, variables) {
|
|
|
6232
6318
|
});
|
|
6233
6319
|
}
|
|
6234
6320
|
async function applyCompoundPatches(projectDir, variables) {
|
|
6235
|
-
const parentEditPath =
|
|
6236
|
-
const parentIndexPath =
|
|
6237
|
-
const childIndexPath =
|
|
6238
|
-
const addChildScriptPath =
|
|
6321
|
+
const parentEditPath = path8.join(projectDir, "src", "blocks", variables.slugKebabCase, "edit.tsx");
|
|
6322
|
+
const parentIndexPath = path8.join(projectDir, "src", "blocks", variables.slugKebabCase, "index.tsx");
|
|
6323
|
+
const childIndexPath = path8.join(projectDir, "src", "blocks", `${variables.slugKebabCase}-item`, "index.tsx");
|
|
6324
|
+
const addChildScriptPath = path8.join(projectDir, "scripts", "add-compound-child.ts");
|
|
6239
6325
|
await patchFile(parentIndexPath, (source) => {
|
|
6240
6326
|
let nextSource = injectAfterBlockMetadataImport(source, `import { deprecated } from '../../migrations/generated/${variables.slugKebabCase}/deprecated';`);
|
|
6241
6327
|
nextSource = injectBefore(nextSource, "\tedit: Edit,", "\tdeprecated,");
|
|
@@ -6305,7 +6391,7 @@ async function applyMigrationUiCapability({
|
|
|
6305
6391
|
templateId,
|
|
6306
6392
|
variables
|
|
6307
6393
|
}) {
|
|
6308
|
-
const commonTemplateDir =
|
|
6394
|
+
const commonTemplateDir = path8.join(SHARED_MIGRATION_UI_TEMPLATE_ROOT, "common");
|
|
6309
6395
|
await copyInterpolatedDirectory(commonTemplateDir, projectDir, variables);
|
|
6310
6396
|
await mutatePackageJson2(projectDir, (packageJson) => {
|
|
6311
6397
|
const wpTypiaPackageVersion = getPackageVersions().wpTypiaPackageVersion;
|
|
@@ -6549,7 +6635,7 @@ function mergeTextLines(primaryContent, existingContent) {
|
|
|
6549
6635
|
import fs4 from "fs";
|
|
6550
6636
|
import { promises as fsp5 } from "fs";
|
|
6551
6637
|
import { execSync as execSync2 } from "child_process";
|
|
6552
|
-
import
|
|
6638
|
+
import path9 from "path";
|
|
6553
6639
|
var LOCKFILES = {
|
|
6554
6640
|
bun: ["bun.lock", "bun.lockb"],
|
|
6555
6641
|
npm: ["package-lock.json"],
|
|
@@ -6557,7 +6643,7 @@ var LOCKFILES = {
|
|
|
6557
6643
|
yarn: ["yarn.lock"]
|
|
6558
6644
|
};
|
|
6559
6645
|
async function normalizePackageManagerFiles(targetDir, packageManagerId) {
|
|
6560
|
-
const yarnRcPath =
|
|
6646
|
+
const yarnRcPath = path9.join(targetDir, ".yarnrc.yml");
|
|
6561
6647
|
if (packageManagerId === "yarn") {
|
|
6562
6648
|
await fsp5.writeFile(yarnRcPath, `nodeLinker: node-modules
|
|
6563
6649
|
`, "utf8");
|
|
@@ -6566,7 +6652,7 @@ async function normalizePackageManagerFiles(targetDir, packageManagerId) {
|
|
|
6566
6652
|
await fsp5.rm(yarnRcPath, { force: true });
|
|
6567
6653
|
}
|
|
6568
6654
|
async function normalizePackageJson(targetDir, packageManagerId) {
|
|
6569
|
-
const packageJsonPath =
|
|
6655
|
+
const packageJsonPath = path9.join(targetDir, "package.json");
|
|
6570
6656
|
if (!fs4.existsSync(packageJsonPath)) {
|
|
6571
6657
|
return;
|
|
6572
6658
|
}
|
|
@@ -6594,7 +6680,7 @@ async function removeUnexpectedLockfiles(targetDir, packageManagerId) {
|
|
|
6594
6680
|
if (keep.has(filename)) {
|
|
6595
6681
|
return;
|
|
6596
6682
|
}
|
|
6597
|
-
await fsp5.rm(
|
|
6683
|
+
await fsp5.rm(path9.join(targetDir, filename), { force: true });
|
|
6598
6684
|
}));
|
|
6599
6685
|
}
|
|
6600
6686
|
async function defaultInstallDependencies({
|
|
@@ -6610,7 +6696,7 @@ async function defaultInstallDependencies({
|
|
|
6610
6696
|
// ../wp-typia-project-tools/src/runtime/scaffold-repository-reference.ts
|
|
6611
6697
|
import fs5 from "fs";
|
|
6612
6698
|
import { createRequire } from "module";
|
|
6613
|
-
import
|
|
6699
|
+
import path10 from "path";
|
|
6614
6700
|
var require2 = createRequire(import.meta.url);
|
|
6615
6701
|
var DEFAULT_SCAFFOLD_REPOSITORY_REFERENCE = "imjlk/wp-typia";
|
|
6616
6702
|
function getErrorCode(error) {
|
|
@@ -6676,9 +6762,9 @@ function parseRepositoryReference(value) {
|
|
|
6676
6762
|
}
|
|
6677
6763
|
function getDefaultRepositoryManifestPaths() {
|
|
6678
6764
|
const candidatePaths = [
|
|
6679
|
-
|
|
6680
|
-
|
|
6681
|
-
|
|
6765
|
+
path10.resolve(PROJECT_TOOLS_PACKAGE_ROOT, "..", "..", "package.json"),
|
|
6766
|
+
path10.resolve(PROJECT_TOOLS_PACKAGE_ROOT, "..", "wp-typia", "package.json"),
|
|
6767
|
+
path10.join(PROJECT_TOOLS_PACKAGE_ROOT, "package.json"),
|
|
6682
6768
|
resolveInstalledPackageManifestPath("wp-typia"),
|
|
6683
6769
|
resolveInstalledPackageManifestPath("@wp-typia/project-tools")
|
|
6684
6770
|
].filter((candidatePath) => Boolean(candidatePath));
|
|
@@ -6705,7 +6791,7 @@ async function reportScaffoldProgress(onProgress, event) {
|
|
|
6705
6791
|
await onProgress?.(event);
|
|
6706
6792
|
}
|
|
6707
6793
|
var EPHEMERAL_NODE_MODULES_LINK_TYPE2 = process.platform === "win32" ? "junction" : "dir";
|
|
6708
|
-
var __dirname2 =
|
|
6794
|
+
var __dirname2 = path11.dirname(fileURLToPath(import.meta.url));
|
|
6709
6795
|
var LOCKFILES2 = {
|
|
6710
6796
|
bun: ["bun.lock", "bun.lockb"],
|
|
6711
6797
|
npm: ["package-lock.json"],
|
|
@@ -6731,42 +6817,42 @@ async function writeStarterManifestFiles2(targetDir, templateId, variables, arti
|
|
|
6731
6817
|
relativePath: `${artifact.relativeDir}/typia.manifest.json`
|
|
6732
6818
|
})) : getStarterManifestFiles(templateId, variables);
|
|
6733
6819
|
for (const { document, relativePath } of manifests) {
|
|
6734
|
-
const destinationPath =
|
|
6735
|
-
await fsp6.mkdir(
|
|
6820
|
+
const destinationPath = path11.join(targetDir, relativePath);
|
|
6821
|
+
await fsp6.mkdir(path11.dirname(destinationPath), { recursive: true });
|
|
6736
6822
|
await fsp6.writeFile(destinationPath, stringifyStarterManifest(document), "utf8");
|
|
6737
6823
|
}
|
|
6738
6824
|
}
|
|
6739
6825
|
async function writeBuiltInStructuralArtifacts(targetDir, artifacts) {
|
|
6740
6826
|
for (const artifact of artifacts) {
|
|
6741
|
-
const destinationDir =
|
|
6827
|
+
const destinationDir = path11.join(targetDir, artifact.relativeDir);
|
|
6742
6828
|
await fsp6.mkdir(destinationDir, { recursive: true });
|
|
6743
|
-
await fsp6.writeFile(
|
|
6744
|
-
await fsp6.writeFile(
|
|
6829
|
+
await fsp6.writeFile(path11.join(destinationDir, "types.ts"), artifact.typesSource, "utf8");
|
|
6830
|
+
await fsp6.writeFile(path11.join(destinationDir, "block.json"), stringifyBuiltInBlockJsonDocument(artifact.blockJsonDocument), "utf8");
|
|
6745
6831
|
}
|
|
6746
6832
|
}
|
|
6747
6833
|
async function writeBuiltInCodeArtifacts(targetDir, codeArtifacts) {
|
|
6748
6834
|
for (const artifact of codeArtifacts) {
|
|
6749
|
-
const destinationPath =
|
|
6750
|
-
await fsp6.mkdir(
|
|
6835
|
+
const destinationPath = path11.join(targetDir, artifact.relativePath);
|
|
6836
|
+
await fsp6.mkdir(path11.dirname(destinationPath), { recursive: true });
|
|
6751
6837
|
await fsp6.writeFile(destinationPath, artifact.source, "utf8");
|
|
6752
6838
|
}
|
|
6753
6839
|
}
|
|
6754
6840
|
function resolveScaffoldGeneratorNodeModulesPath2() {
|
|
6755
|
-
const projectToolsPackageRoot =
|
|
6841
|
+
const projectToolsPackageRoot = path11.resolve(__dirname2, "..", "..");
|
|
6756
6842
|
const candidates = [
|
|
6757
|
-
|
|
6758
|
-
|
|
6759
|
-
|
|
6843
|
+
path11.join(projectToolsPackageRoot, "node_modules"),
|
|
6844
|
+
path11.resolve(projectToolsPackageRoot, "..", ".."),
|
|
6845
|
+
path11.resolve(projectToolsPackageRoot, "..", "..", "node_modules")
|
|
6760
6846
|
];
|
|
6761
6847
|
for (const candidate of candidates) {
|
|
6762
|
-
if (fs6.existsSync(
|
|
6848
|
+
if (fs6.existsSync(path11.join(candidate, "typia", "package.json"))) {
|
|
6763
6849
|
return candidate;
|
|
6764
6850
|
}
|
|
6765
6851
|
}
|
|
6766
6852
|
return null;
|
|
6767
6853
|
}
|
|
6768
6854
|
async function withEphemeralScaffoldNodeModules2(targetDir, callback) {
|
|
6769
|
-
const targetNodeModulesPath =
|
|
6855
|
+
const targetNodeModulesPath = path11.join(targetDir, "node_modules");
|
|
6770
6856
|
if (fs6.existsSync(targetNodeModulesPath)) {
|
|
6771
6857
|
await callback();
|
|
6772
6858
|
return;
|
|
@@ -6790,7 +6876,7 @@ async function seedBuiltInPersistenceArtifacts2(targetDir, templateId, variables
|
|
|
6790
6876
|
await withEphemeralScaffoldNodeModules2(targetDir, async () => {
|
|
6791
6877
|
if (templateId === "persistence") {
|
|
6792
6878
|
await syncPersistenceRestArtifacts({
|
|
6793
|
-
apiTypesFile:
|
|
6879
|
+
apiTypesFile: path11.join("src", "api-types.ts"),
|
|
6794
6880
|
outputDir: "src",
|
|
6795
6881
|
projectDir: targetDir,
|
|
6796
6882
|
variables
|
|
@@ -6798,15 +6884,15 @@ async function seedBuiltInPersistenceArtifacts2(targetDir, templateId, variables
|
|
|
6798
6884
|
return;
|
|
6799
6885
|
}
|
|
6800
6886
|
await syncPersistenceRestArtifacts({
|
|
6801
|
-
apiTypesFile:
|
|
6802
|
-
outputDir:
|
|
6887
|
+
apiTypesFile: path11.join("src", "blocks", variables.slugKebabCase, "api-types.ts"),
|
|
6888
|
+
outputDir: path11.join("src", "blocks", variables.slugKebabCase),
|
|
6803
6889
|
projectDir: targetDir,
|
|
6804
6890
|
variables
|
|
6805
6891
|
});
|
|
6806
6892
|
});
|
|
6807
6893
|
}
|
|
6808
6894
|
async function normalizePackageManagerFiles2(targetDir, packageManagerId) {
|
|
6809
|
-
const yarnRcPath =
|
|
6895
|
+
const yarnRcPath = path11.join(targetDir, ".yarnrc.yml");
|
|
6810
6896
|
if (packageManagerId === "yarn") {
|
|
6811
6897
|
await fsp6.writeFile(yarnRcPath, `nodeLinker: node-modules
|
|
6812
6898
|
`, "utf8");
|
|
@@ -6820,7 +6906,7 @@ async function removeQueryLoopPlaceholderFiles(projectDir, templateId) {
|
|
|
6820
6906
|
if (templateId !== "query-loop") {
|
|
6821
6907
|
return;
|
|
6822
6908
|
}
|
|
6823
|
-
await fsp6.rm(
|
|
6909
|
+
await fsp6.rm(path11.join(projectDir, "src", "validator-toolkit.ts"), {
|
|
6824
6910
|
force: true
|
|
6825
6911
|
});
|
|
6826
6912
|
}
|
|
@@ -6831,7 +6917,7 @@ async function removeUnexpectedLockfiles2(targetDir, packageManagerId) {
|
|
|
6831
6917
|
if (keep.has(filename)) {
|
|
6832
6918
|
return;
|
|
6833
6919
|
}
|
|
6834
|
-
const filePath =
|
|
6920
|
+
const filePath = path11.join(targetDir, filename);
|
|
6835
6921
|
if (fs6.existsSync(filePath)) {
|
|
6836
6922
|
await fsp6.rm(filePath, { force: true });
|
|
6837
6923
|
}
|
|
@@ -6861,11 +6947,11 @@ async function replaceTextRecursively(targetDir, packageManagerId, {
|
|
|
6861
6947
|
if (stats.isDirectory()) {
|
|
6862
6948
|
const entries = await fsp6.readdir(currentPath);
|
|
6863
6949
|
for (const entry of entries) {
|
|
6864
|
-
await visit(
|
|
6950
|
+
await visit(path11.join(currentPath, entry));
|
|
6865
6951
|
}
|
|
6866
6952
|
return;
|
|
6867
6953
|
}
|
|
6868
|
-
if (
|
|
6954
|
+
if (path11.basename(currentPath) === "package.json" || !textExtensions.has(path11.extname(currentPath))) {
|
|
6869
6955
|
return;
|
|
6870
6956
|
}
|
|
6871
6957
|
const content = await fsp6.readFile(currentPath, "utf8");
|
|
@@ -6943,7 +7029,7 @@ async function applyBuiltInScaffoldProjectFiles({
|
|
|
6943
7029
|
phase: "finalize-project",
|
|
6944
7030
|
title: "Finalizing scaffold output"
|
|
6945
7031
|
});
|
|
6946
|
-
const readmePath =
|
|
7032
|
+
const readmePath = path11.join(projectDir, "README.md");
|
|
6947
7033
|
if (!fs6.existsSync(readmePath)) {
|
|
6948
7034
|
await fsp6.writeFile(readmePath, readmeContent ?? buildReadme(templateId, variables, packageManager, {
|
|
6949
7035
|
withMigrationUi,
|
|
@@ -6951,7 +7037,7 @@ async function applyBuiltInScaffoldProjectFiles({
|
|
|
6951
7037
|
withWpEnv
|
|
6952
7038
|
}), "utf8");
|
|
6953
7039
|
}
|
|
6954
|
-
const gitignorePath =
|
|
7040
|
+
const gitignorePath = path11.join(projectDir, ".gitignore");
|
|
6955
7041
|
const existingGitignore = fs6.existsSync(gitignorePath) ? await fsp6.readFile(gitignorePath, "utf8") : "";
|
|
6956
7042
|
await fsp6.writeFile(gitignorePath, mergeTextLines(gitignoreContent ?? buildGitignore(), existingGitignore), "utf8");
|
|
6957
7043
|
await normalizePackageJson(projectDir, packageManager);
|
|
@@ -6983,83 +7069,20 @@ async function applyBuiltInScaffoldProjectFiles({
|
|
|
6983
7069
|
}
|
|
6984
7070
|
}
|
|
6985
7071
|
|
|
6986
|
-
// ../wp-typia-project-tools/src/runtime/template-source-locators.ts
|
|
6987
|
-
var import_npm_package_arg = __toESM(require_npa(), 1);
|
|
6988
|
-
import path10 from "path";
|
|
6989
|
-
function isTemplatePathLocator(templateId) {
|
|
6990
|
-
return path10.isAbsolute(templateId) || templateId.startsWith("./") || templateId.startsWith("../");
|
|
6991
|
-
}
|
|
6992
|
-
function parseGitHubTemplateLocator(templateId) {
|
|
6993
|
-
if (!templateId.startsWith("github:")) {
|
|
6994
|
-
return null;
|
|
6995
|
-
}
|
|
6996
|
-
const [locatorBody, refSegment] = templateId.slice("github:".length).split("#", 2);
|
|
6997
|
-
const segments = locatorBody.split("/").filter(Boolean);
|
|
6998
|
-
if (segments.length < 3) {
|
|
6999
|
-
throw new Error(`GitHub template locators must look like github:owner/repo/path[#ref]. Received: ${templateId}`);
|
|
7000
|
-
}
|
|
7001
|
-
const [owner, repo, ...sourcePathSegments] = segments;
|
|
7002
|
-
return {
|
|
7003
|
-
owner,
|
|
7004
|
-
repo,
|
|
7005
|
-
ref: refSegment ?? null,
|
|
7006
|
-
sourcePath: sourcePathSegments.join("/")
|
|
7007
|
-
};
|
|
7008
|
-
}
|
|
7009
|
-
function parseNpmTemplateLocator(templateId) {
|
|
7010
|
-
if (isBuiltInTemplateId(templateId) || isTemplatePathLocator(templateId) || templateId.startsWith("github:")) {
|
|
7011
|
-
return null;
|
|
7012
|
-
}
|
|
7013
|
-
try {
|
|
7014
|
-
const parsed = import_npm_package_arg.default(templateId);
|
|
7015
|
-
if (!parsed.registry || !parsed.name) {
|
|
7016
|
-
return null;
|
|
7017
|
-
}
|
|
7018
|
-
const parsedWithRawSpec = parsed;
|
|
7019
|
-
const rawSpec = typeof parsedWithRawSpec.rawSpec === "string" ? parsedWithRawSpec.rawSpec : "";
|
|
7020
|
-
return {
|
|
7021
|
-
fetchSpec: typeof parsed.fetchSpec === "string" ? parsed.fetchSpec : "",
|
|
7022
|
-
name: parsed.name,
|
|
7023
|
-
raw: templateId,
|
|
7024
|
-
rawSpec,
|
|
7025
|
-
type: parsed.type
|
|
7026
|
-
};
|
|
7027
|
-
} catch {
|
|
7028
|
-
return null;
|
|
7029
|
-
}
|
|
7030
|
-
}
|
|
7031
|
-
function parseTemplateLocator(templateId) {
|
|
7032
|
-
if (isRemovedBuiltInTemplateId(templateId)) {
|
|
7033
|
-
throw new Error(getRemovedBuiltInTemplateMessage(templateId));
|
|
7034
|
-
}
|
|
7035
|
-
const githubLocator = parseGitHubTemplateLocator(templateId);
|
|
7036
|
-
if (githubLocator) {
|
|
7037
|
-
return { kind: "github", locator: githubLocator };
|
|
7038
|
-
}
|
|
7039
|
-
if (isTemplatePathLocator(templateId)) {
|
|
7040
|
-
return { kind: "path", templatePath: templateId };
|
|
7041
|
-
}
|
|
7042
|
-
const npmLocator = parseNpmTemplateLocator(templateId);
|
|
7043
|
-
if (npmLocator) {
|
|
7044
|
-
return { kind: "npm", locator: npmLocator };
|
|
7045
|
-
}
|
|
7046
|
-
throw new Error(`Unknown template "${templateId}". Expected one of: ${BUILTIN_TEMPLATE_IDS.join(", ")}, a local path, github:owner/repo/path[#ref], or an npm package spec.`);
|
|
7047
|
-
}
|
|
7048
|
-
|
|
7049
7072
|
// ../wp-typia-project-tools/src/runtime/template-source-normalization.ts
|
|
7050
7073
|
import fs11 from "fs";
|
|
7051
|
-
import
|
|
7074
|
+
import path15 from "path";
|
|
7052
7075
|
|
|
7053
7076
|
// ../wp-typia-project-tools/src/runtime/template-layers.ts
|
|
7054
7077
|
import fs7 from "fs";
|
|
7055
|
-
import
|
|
7078
|
+
import path12 from "path";
|
|
7056
7079
|
import { promises as fsp7 } from "fs";
|
|
7057
7080
|
var TEMPLATE_LAYER_MANIFEST_FILENAME = "wp-typia.layers.json";
|
|
7058
7081
|
var TEMPLATE_LAYER_MANIFEST_VERSION = 1;
|
|
7059
7082
|
function resolveLayerPath(sourceRoot, relativePath) {
|
|
7060
|
-
const targetPath =
|
|
7061
|
-
const relativeTarget =
|
|
7062
|
-
if (relativeTarget.startsWith("..") ||
|
|
7083
|
+
const targetPath = path12.resolve(sourceRoot, relativePath);
|
|
7084
|
+
const relativeTarget = path12.relative(sourceRoot, targetPath);
|
|
7085
|
+
if (relativeTarget.startsWith("..") || path12.isAbsolute(relativeTarget)) {
|
|
7063
7086
|
throw new Error(`Template layer path "${relativePath}" must stay within ${sourceRoot}.`);
|
|
7064
7087
|
}
|
|
7065
7088
|
return targetPath;
|
|
@@ -7073,7 +7096,7 @@ async function assertNoSymlinks(sourceDir) {
|
|
|
7073
7096
|
return;
|
|
7074
7097
|
}
|
|
7075
7098
|
for (const entry of await fsp7.readdir(sourceDir)) {
|
|
7076
|
-
await assertNoSymlinks(
|
|
7099
|
+
await assertNoSymlinks(path12.join(sourceDir, entry));
|
|
7077
7100
|
}
|
|
7078
7101
|
}
|
|
7079
7102
|
function parseLayerDefinition(layerId, value) {
|
|
@@ -7102,7 +7125,7 @@ function parseLayerDefinition(layerId, value) {
|
|
|
7102
7125
|
};
|
|
7103
7126
|
}
|
|
7104
7127
|
async function loadExternalTemplateLayerManifest(sourceRoot) {
|
|
7105
|
-
const manifestPath =
|
|
7128
|
+
const manifestPath = path12.join(sourceRoot, TEMPLATE_LAYER_MANIFEST_FILENAME);
|
|
7106
7129
|
if (!fs7.existsSync(manifestPath)) {
|
|
7107
7130
|
return null;
|
|
7108
7131
|
}
|
|
@@ -7239,7 +7262,7 @@ async function assertExternalTemplateLayersDoNotWriteProtectedOutputs({
|
|
|
7239
7262
|
|
|
7240
7263
|
// ../wp-typia-project-tools/src/runtime/template-source-external.ts
|
|
7241
7264
|
import fs9 from "fs";
|
|
7242
|
-
import
|
|
7265
|
+
import path13 from "path";
|
|
7243
7266
|
import { pathToFileURL } from "url";
|
|
7244
7267
|
|
|
7245
7268
|
// ../wp-typia-project-tools/src/runtime/external-template-guards.ts
|
|
@@ -7383,16 +7406,16 @@ function getTemplateWarning(key) {
|
|
|
7383
7406
|
return `Ignoring external template config key "${key}": ${TEMPLATE_WARNING_MESSAGE}`;
|
|
7384
7407
|
}
|
|
7385
7408
|
function resolveSourceSubpath(sourceDir, relativePath) {
|
|
7386
|
-
const targetPath =
|
|
7387
|
-
const relativeTarget =
|
|
7388
|
-
if (relativeTarget.startsWith("..") ||
|
|
7409
|
+
const targetPath = path13.resolve(sourceDir, relativePath);
|
|
7410
|
+
const relativeTarget = path13.relative(sourceDir, targetPath);
|
|
7411
|
+
if (relativeTarget.startsWith("..") || path13.isAbsolute(relativeTarget)) {
|
|
7389
7412
|
throw new Error(`Template path "${relativePath}" must stay within ${sourceDir}.`);
|
|
7390
7413
|
}
|
|
7391
7414
|
return targetPath;
|
|
7392
7415
|
}
|
|
7393
7416
|
function getExternalTemplateEntry(sourceDir) {
|
|
7394
7417
|
for (const filename of EXTERNAL_TEMPLATE_ENTRY_CANDIDATES) {
|
|
7395
|
-
const candidate =
|
|
7418
|
+
const candidate = path13.join(sourceDir, filename);
|
|
7396
7419
|
if (fs9.existsSync(candidate)) {
|
|
7397
7420
|
return candidate;
|
|
7398
7421
|
}
|
|
@@ -7514,22 +7537,22 @@ async function renderCreateBlockExternalTemplate(sourceDir, context, requestedVa
|
|
|
7514
7537
|
const { folderName, formatHint, templatePath } = resolveConfiguredTemplatePath(config, variantConfig);
|
|
7515
7538
|
const { path: tempRoot, cleanup } = await createManagedTempRoot("wp-typia-create-block-external-");
|
|
7516
7539
|
try {
|
|
7517
|
-
const renderedRoot =
|
|
7540
|
+
const renderedRoot = path13.join(tempRoot, "rendered");
|
|
7518
7541
|
const blockDir = resolveSourceSubpath(renderedRoot, folderName);
|
|
7519
7542
|
const view = await buildExternalTemplateView(context, config, selectedVariant, variantConfig);
|
|
7520
7543
|
const blockTemplateDir = resolveSourceSubpath(sourceDir, templatePath);
|
|
7521
7544
|
await copyRenderedDirectory(blockTemplateDir, blockDir, view, {
|
|
7522
7545
|
filter: (sourcePath, _destinationPath, entry) => {
|
|
7523
|
-
const mustacheVariantPath =
|
|
7546
|
+
const mustacheVariantPath = path13.join(path13.dirname(sourcePath), `${entry.name}.mustache`);
|
|
7524
7547
|
return !(entry.isFile() && (entry.name === "package.json" || entry.name === "README.md") && fs9.existsSync(mustacheVariantPath));
|
|
7525
7548
|
}
|
|
7526
7549
|
});
|
|
7527
7550
|
const assetsPath = typeof variantConfig.assetsPath === "string" ? variantConfig.assetsPath : config.assetsPath;
|
|
7528
7551
|
if (typeof assetsPath === "string" && assetsPath.trim().length > 0) {
|
|
7529
|
-
await copyRawDirectory(resolveSourceSubpath(sourceDir, assetsPath),
|
|
7552
|
+
await copyRawDirectory(resolveSourceSubpath(sourceDir, assetsPath), path13.join(tempRoot, "assets"));
|
|
7530
7553
|
}
|
|
7531
7554
|
return {
|
|
7532
|
-
assetsDir: fs9.existsSync(
|
|
7555
|
+
assetsDir: fs9.existsSync(path13.join(tempRoot, "assets")) ? path13.join(tempRoot, "assets") : undefined,
|
|
7533
7556
|
blockDir,
|
|
7534
7557
|
cleanup,
|
|
7535
7558
|
formatHint,
|
|
@@ -7546,7 +7569,7 @@ async function renderCreateBlockExternalTemplate(sourceDir, context, requestedVa
|
|
|
7546
7569
|
// ../wp-typia-project-tools/src/runtime/template-source-remote.ts
|
|
7547
7570
|
import fs10 from "fs";
|
|
7548
7571
|
import { promises as fsp8 } from "fs";
|
|
7549
|
-
import
|
|
7572
|
+
import path14 from "path";
|
|
7550
7573
|
async function cleanupSeedRootPair(cleanup, seedCleanup) {
|
|
7551
7574
|
let cleanupError;
|
|
7552
7575
|
try {
|
|
@@ -7567,10 +7590,10 @@ function getDefaultCategoryFromBlockJson(blockJson) {
|
|
|
7567
7590
|
return typeof blockJson.category === "string" && blockJson.category.trim().length > 0 ? blockJson.category.trim() : "widgets";
|
|
7568
7591
|
}
|
|
7569
7592
|
function readRemoteBlockJson(blockDir) {
|
|
7570
|
-
const sourceRoot = fs10.existsSync(
|
|
7593
|
+
const sourceRoot = fs10.existsSync(path14.join(blockDir, "src")) ? path14.join(blockDir, "src") : blockDir;
|
|
7571
7594
|
for (const candidate of [
|
|
7572
|
-
|
|
7573
|
-
|
|
7595
|
+
path14.join(blockDir, "block.json"),
|
|
7596
|
+
path14.join(sourceRoot, "block.json")
|
|
7574
7597
|
]) {
|
|
7575
7598
|
if (fs10.existsSync(candidate)) {
|
|
7576
7599
|
return JSON.parse(fs10.readFileSync(candidate, "utf8"));
|
|
@@ -7588,8 +7611,8 @@ function getDefaultCategory(sourceDir) {
|
|
|
7588
7611
|
}
|
|
7589
7612
|
function readTemplatePackageJson(sourceDir) {
|
|
7590
7613
|
for (const candidate of [
|
|
7591
|
-
|
|
7592
|
-
|
|
7614
|
+
path14.join(sourceDir, "package.json.mustache"),
|
|
7615
|
+
path14.join(sourceDir, "package.json")
|
|
7593
7616
|
]) {
|
|
7594
7617
|
if (!fs10.existsSync(candidate)) {
|
|
7595
7618
|
continue;
|
|
@@ -7626,16 +7649,16 @@ function getTemplateProjectType(sourceDir) {
|
|
|
7626
7649
|
}
|
|
7627
7650
|
async function normalizeWpTypiaTemplateSeed(seed) {
|
|
7628
7651
|
const { path: tempRoot, cleanup } = await createManagedTempRoot("wp-typia-template-source-");
|
|
7629
|
-
const normalizedDir =
|
|
7652
|
+
const normalizedDir = path14.join(tempRoot, "template");
|
|
7630
7653
|
try {
|
|
7631
7654
|
await copyRawDirectory(seed.blockDir, normalizedDir, {
|
|
7632
7655
|
filter: (sourcePath, _targetPath, entry) => {
|
|
7633
|
-
const mustacheVariantPath =
|
|
7656
|
+
const mustacheVariantPath = path14.join(path14.dirname(sourcePath), `${entry.name}.mustache`);
|
|
7634
7657
|
return !(entry.isFile() && (entry.name === "package.json" || entry.name === "README.md") && fs10.existsSync(mustacheVariantPath));
|
|
7635
7658
|
}
|
|
7636
7659
|
});
|
|
7637
7660
|
if (seed.assetsDir && fs10.existsSync(seed.assetsDir)) {
|
|
7638
|
-
await fsp8.cp(seed.assetsDir,
|
|
7661
|
+
await fsp8.cp(seed.assetsDir, path14.join(normalizedDir, "assets"), {
|
|
7639
7662
|
recursive: true,
|
|
7640
7663
|
force: true
|
|
7641
7664
|
});
|
|
@@ -7724,21 +7747,21 @@ function buildRemoteBlockJsonTemplate(blockJson) {
|
|
|
7724
7747
|
}
|
|
7725
7748
|
async function rewriteBlockJsonImports(directory) {
|
|
7726
7749
|
const textExtensions = new Set([".js", ".jsx", ".ts", ".tsx"]);
|
|
7727
|
-
const targetBlockJsonPath =
|
|
7750
|
+
const targetBlockJsonPath = path14.join(directory, "block.json");
|
|
7728
7751
|
async function visit(currentPath) {
|
|
7729
7752
|
const stats = await fsp8.stat(currentPath);
|
|
7730
7753
|
if (stats.isDirectory()) {
|
|
7731
7754
|
const entries = await fsp8.readdir(currentPath);
|
|
7732
7755
|
for (const entry of entries) {
|
|
7733
|
-
await visit(
|
|
7756
|
+
await visit(path14.join(currentPath, entry));
|
|
7734
7757
|
}
|
|
7735
7758
|
return;
|
|
7736
7759
|
}
|
|
7737
|
-
if (!textExtensions.has(
|
|
7760
|
+
if (!textExtensions.has(path14.extname(currentPath))) {
|
|
7738
7761
|
return;
|
|
7739
7762
|
}
|
|
7740
7763
|
const content = await fsp8.readFile(currentPath, "utf8");
|
|
7741
|
-
const relativeSpecifier =
|
|
7764
|
+
const relativeSpecifier = path14.relative(path14.dirname(currentPath), targetBlockJsonPath).replace(/\\/g, "/");
|
|
7742
7765
|
const normalizedSpecifier = relativeSpecifier.startsWith(".") ? relativeSpecifier : `./${relativeSpecifier}`;
|
|
7743
7766
|
const next = content.replace(/(['"])\.{1,2}\/[^'"]*block\.json\1/g, `$1${normalizedSpecifier}$1`);
|
|
7744
7767
|
if (next !== content) {
|
|
@@ -7748,7 +7771,7 @@ async function rewriteBlockJsonImports(directory) {
|
|
|
7748
7771
|
await visit(directory);
|
|
7749
7772
|
}
|
|
7750
7773
|
async function patchRemotePackageJson(templateDir, needsInteractivity) {
|
|
7751
|
-
const packageJsonPath =
|
|
7774
|
+
const packageJsonPath = path14.join(templateDir, "package.json.mustache");
|
|
7752
7775
|
const packageJson = JSON.parse(await fsp8.readFile(packageJsonPath, "utf8"));
|
|
7753
7776
|
const existingDependencies = { ...packageJson.dependencies ?? {} };
|
|
7754
7777
|
const existingDevDependencies = { ...packageJson.devDependencies ?? {} };
|
|
@@ -7773,12 +7796,12 @@ async function patchRemotePackageJson(templateDir, needsInteractivity) {
|
|
|
7773
7796
|
`, "utf8");
|
|
7774
7797
|
}
|
|
7775
7798
|
function getSeedSourceRoot(blockDir) {
|
|
7776
|
-
return fs10.existsSync(
|
|
7799
|
+
return fs10.existsSync(path14.join(blockDir, "src")) ? path14.join(blockDir, "src") : blockDir;
|
|
7777
7800
|
}
|
|
7778
7801
|
function findSeedRenderPhp(seed) {
|
|
7779
7802
|
for (const candidate of [
|
|
7780
|
-
|
|
7781
|
-
|
|
7803
|
+
path14.join(seed.blockDir, "render.php"),
|
|
7804
|
+
path14.join(seed.rootDir, "render.php")
|
|
7782
7805
|
]) {
|
|
7783
7806
|
if (fs10.existsSync(candidate)) {
|
|
7784
7807
|
return candidate;
|
|
@@ -7819,13 +7842,13 @@ async function removeSeedEntryConflicts(templateDir) {
|
|
|
7819
7842
|
"view.ts",
|
|
7820
7843
|
"view.tsx"
|
|
7821
7844
|
]) {
|
|
7822
|
-
await fsp8.rm(
|
|
7845
|
+
await fsp8.rm(path14.join(templateDir, "src", filename), { force: true });
|
|
7823
7846
|
}
|
|
7824
7847
|
}
|
|
7825
7848
|
async function normalizeCreateBlockSubset(seed, context) {
|
|
7826
7849
|
const { path: tempRoot, cleanup } = await createManagedTempRoot("wp-typia-remote-template-");
|
|
7827
7850
|
try {
|
|
7828
|
-
const templateDir =
|
|
7851
|
+
const templateDir = path14.join(tempRoot, "template");
|
|
7829
7852
|
const blockJson = readRemoteBlockJson(seed.blockDir);
|
|
7830
7853
|
const sourceRoot = getSeedSourceRoot(seed.blockDir);
|
|
7831
7854
|
await fsp8.mkdir(templateDir, { recursive: true });
|
|
@@ -7842,24 +7865,24 @@ async function normalizeCreateBlockSubset(seed, context) {
|
|
|
7842
7865
|
});
|
|
7843
7866
|
}
|
|
7844
7867
|
await removeSeedEntryConflicts(templateDir);
|
|
7845
|
-
await fsp8.cp(sourceRoot,
|
|
7868
|
+
await fsp8.cp(sourceRoot, path14.join(templateDir, "src"), {
|
|
7846
7869
|
recursive: true,
|
|
7847
7870
|
force: true
|
|
7848
7871
|
});
|
|
7849
7872
|
const remoteRenderPath = findSeedRenderPhp(seed);
|
|
7850
7873
|
if (remoteRenderPath) {
|
|
7851
|
-
await fsp8.copyFile(remoteRenderPath,
|
|
7874
|
+
await fsp8.copyFile(remoteRenderPath, path14.join(templateDir, "render.php"));
|
|
7852
7875
|
}
|
|
7853
7876
|
if (seed.assetsDir && fs10.existsSync(seed.assetsDir)) {
|
|
7854
|
-
await fsp8.cp(seed.assetsDir,
|
|
7877
|
+
await fsp8.cp(seed.assetsDir, path14.join(templateDir, "assets"), {
|
|
7855
7878
|
recursive: true,
|
|
7856
7879
|
force: true
|
|
7857
7880
|
});
|
|
7858
7881
|
}
|
|
7859
|
-
await fsp8.writeFile(
|
|
7860
|
-
await fsp8.writeFile(
|
|
7861
|
-
await rewriteBlockJsonImports(
|
|
7862
|
-
const needsInteractivity = typeof blockJson.viewScriptModule === "string" || typeof blockJson.viewScript === "string" || fs10.existsSync(
|
|
7882
|
+
await fsp8.writeFile(path14.join(templateDir, "src", "types.ts"), buildRemoteTypesSource(blockJson, context), "utf8");
|
|
7883
|
+
await fsp8.writeFile(path14.join(templateDir, "src", "block.json"), buildRemoteBlockJsonTemplate(blockJson), "utf8");
|
|
7884
|
+
await rewriteBlockJsonImports(path14.join(templateDir, "src"));
|
|
7885
|
+
const needsInteractivity = typeof blockJson.viewScriptModule === "string" || typeof blockJson.viewScript === "string" || fs10.existsSync(path14.join(templateDir, "src", "view.js")) || fs10.existsSync(path14.join(templateDir, "src", "view.ts")) || fs10.existsSync(path14.join(templateDir, "src", "view.tsx")) || fs10.existsSync(path14.join(templateDir, "src", "interactivity.js")) || fs10.existsSync(path14.join(templateDir, "src", "interactivity.ts"));
|
|
7863
7886
|
await patchRemotePackageJson(templateDir, needsInteractivity);
|
|
7864
7887
|
return {
|
|
7865
7888
|
id: "remote:create-block-subset",
|
|
@@ -7909,7 +7932,7 @@ function getTemplateVariableContext(variables) {
|
|
|
7909
7932
|
};
|
|
7910
7933
|
}
|
|
7911
7934
|
async function detectTemplateSourceFormat(sourceDir) {
|
|
7912
|
-
if (fs11.existsSync(
|
|
7935
|
+
if (fs11.existsSync(path15.join(sourceDir, "package.json.mustache"))) {
|
|
7913
7936
|
return "wp-typia";
|
|
7914
7937
|
}
|
|
7915
7938
|
if (await loadExternalTemplateLayerManifest(sourceDir)) {
|
|
@@ -7921,15 +7944,15 @@ async function detectTemplateSourceFormat(sourceDir) {
|
|
|
7921
7944
|
if (getTemplateProjectType(sourceDir) !== null) {
|
|
7922
7945
|
return "wp-typia";
|
|
7923
7946
|
}
|
|
7924
|
-
const sourceRoot = fs11.existsSync(
|
|
7947
|
+
const sourceRoot = fs11.existsSync(path15.join(sourceDir, "src")) ? path15.join(sourceDir, "src") : sourceDir;
|
|
7925
7948
|
const blockJsonCandidates = [
|
|
7926
|
-
|
|
7927
|
-
|
|
7949
|
+
path15.join(sourceDir, "block.json"),
|
|
7950
|
+
path15.join(sourceRoot, "block.json")
|
|
7928
7951
|
];
|
|
7929
7952
|
const hasBlockJson = blockJsonCandidates.some((candidate) => fs11.existsSync(candidate));
|
|
7930
|
-
const hasIndexFile = ["index.js", "index.jsx", "index.ts", "index.tsx"].some((filename) => fs11.existsSync(
|
|
7931
|
-
const hasEditFile = ["edit.js", "edit.jsx", "edit.ts", "edit.tsx"].some((filename) => fs11.existsSync(
|
|
7932
|
-
const hasSaveFile = ["save.js", "save.jsx", "save.ts", "save.tsx"].some((filename) => fs11.existsSync(
|
|
7953
|
+
const hasIndexFile = ["index.js", "index.jsx", "index.ts", "index.tsx"].some((filename) => fs11.existsSync(path15.join(sourceRoot, filename)));
|
|
7954
|
+
const hasEditFile = ["edit.js", "edit.jsx", "edit.ts", "edit.tsx"].some((filename) => fs11.existsSync(path15.join(sourceRoot, filename)));
|
|
7955
|
+
const hasSaveFile = ["save.js", "save.jsx", "save.ts", "save.tsx"].some((filename) => fs11.existsSync(path15.join(sourceRoot, filename)));
|
|
7933
7956
|
if (hasBlockJson && hasIndexFile && hasEditFile && hasSaveFile) {
|
|
7934
7957
|
return "create-block-subset";
|
|
7935
7958
|
}
|
|
@@ -7941,7 +7964,7 @@ var import_semver = __toESM(require_semver2(), 1);
|
|
|
7941
7964
|
import fs13 from "fs";
|
|
7942
7965
|
import { promises as fsp9 } from "fs";
|
|
7943
7966
|
import { createRequire as createRequire2 } from "module";
|
|
7944
|
-
import
|
|
7967
|
+
import path16 from "path";
|
|
7945
7968
|
import { spawnSync } from "child_process";
|
|
7946
7969
|
|
|
7947
7970
|
// ../../node_modules/.bun/tar@7.5.13/node_modules/tar/dist/esm/index.min.js
|
|
@@ -11092,6 +11115,17 @@ var So = (s3) => {
|
|
|
11092
11115
|
};
|
|
11093
11116
|
|
|
11094
11117
|
// ../wp-typia-project-tools/src/runtime/template-source-seeds.ts
|
|
11118
|
+
var USER_FACING_TEMPLATE_IDS2 = [
|
|
11119
|
+
...TEMPLATE_IDS,
|
|
11120
|
+
OFFICIAL_WORKSPACE_TEMPLATE_ALIAS
|
|
11121
|
+
];
|
|
11122
|
+
function getUnknownNpmTemplateMessage(templateId) {
|
|
11123
|
+
return [
|
|
11124
|
+
`Unknown template "${templateId}". Expected one of: ${USER_FACING_TEMPLATE_IDS2.join(", ")}.`,
|
|
11125
|
+
"Run `wp-typia templates list` to inspect available templates.",
|
|
11126
|
+
"If you meant an npm template package, verify the package name and configured npm registry."
|
|
11127
|
+
].join(" ");
|
|
11128
|
+
}
|
|
11095
11129
|
function selectRegistryVersion(metadata, locator) {
|
|
11096
11130
|
const distTags = isPlainObject(metadata["dist-tags"]) ? metadata["dist-tags"] : {};
|
|
11097
11131
|
const versions = isPlainObject(metadata.versions) ? metadata.versions : {};
|
|
@@ -11130,6 +11164,9 @@ async function fetchNpmTemplateSource(locator) {
|
|
|
11130
11164
|
label: metadataLabel
|
|
11131
11165
|
});
|
|
11132
11166
|
if (!metadataResponse.ok) {
|
|
11167
|
+
if (metadataResponse.status === 404) {
|
|
11168
|
+
throw new Error(getUnknownNpmTemplateMessage(locator.raw));
|
|
11169
|
+
}
|
|
11133
11170
|
throw new Error(`Failed to fetch npm template metadata for ${locator.raw}: ${metadataResponse.status}`);
|
|
11134
11171
|
}
|
|
11135
11172
|
const metadata = await readJsonResponseWithLimit(metadataResponse, {
|
|
@@ -11154,8 +11191,8 @@ async function fetchNpmTemplateSource(locator) {
|
|
|
11154
11191
|
if (!tarballResponse.ok) {
|
|
11155
11192
|
throw new Error(`Failed to download npm template tarball for ${locator.raw}: ${tarballResponse.status}`);
|
|
11156
11193
|
}
|
|
11157
|
-
const tarballPath =
|
|
11158
|
-
const unpackDir =
|
|
11194
|
+
const tarballPath = path16.join(tempRoot, "template.tgz");
|
|
11195
|
+
const unpackDir = path16.join(tempRoot, "source");
|
|
11159
11196
|
await fsp9.mkdir(unpackDir, { recursive: true });
|
|
11160
11197
|
await fsp9.writeFile(tarballPath, await readBufferResponseWithLimit(tarballResponse, {
|
|
11161
11198
|
label: `npm template tarball for ${locator.raw}@${resolvedVersion}`,
|
|
@@ -11181,7 +11218,7 @@ function resolveInstalledNpmTemplateSource(locator, cwd) {
|
|
|
11181
11218
|
if (locator.rawSpec !== "" && locator.rawSpec !== "*") {
|
|
11182
11219
|
return null;
|
|
11183
11220
|
}
|
|
11184
|
-
const workspacePackagesRoot =
|
|
11221
|
+
const workspacePackagesRoot = path16.resolve(PROJECT_TOOLS_PACKAGE_ROOT, "..");
|
|
11185
11222
|
if (fs13.existsSync(workspacePackagesRoot)) {
|
|
11186
11223
|
for (const entry of fs13.readdirSync(workspacePackagesRoot, {
|
|
11187
11224
|
withFileTypes: true
|
|
@@ -11189,8 +11226,8 @@ function resolveInstalledNpmTemplateSource(locator, cwd) {
|
|
|
11189
11226
|
if (!entry.isDirectory()) {
|
|
11190
11227
|
continue;
|
|
11191
11228
|
}
|
|
11192
|
-
const packageDir =
|
|
11193
|
-
const packageJsonPath =
|
|
11229
|
+
const packageDir = path16.join(workspacePackagesRoot, entry.name);
|
|
11230
|
+
const packageJsonPath = path16.join(packageDir, "package.json");
|
|
11194
11231
|
if (!fs13.existsSync(packageJsonPath)) {
|
|
11195
11232
|
continue;
|
|
11196
11233
|
}
|
|
@@ -11203,10 +11240,10 @@ function resolveInstalledNpmTemplateSource(locator, cwd) {
|
|
|
11203
11240
|
}
|
|
11204
11241
|
}
|
|
11205
11242
|
}
|
|
11206
|
-
const workspaceRequire = createRequire2(
|
|
11243
|
+
const workspaceRequire = createRequire2(path16.join(path16.resolve(cwd), "__wp_typia_template_resolver__.cjs"));
|
|
11207
11244
|
try {
|
|
11208
11245
|
const packageJsonPath = fs13.realpathSync(workspaceRequire.resolve(`${locator.name}/package.json`));
|
|
11209
|
-
const sourceDir =
|
|
11246
|
+
const sourceDir = path16.dirname(packageJsonPath);
|
|
11210
11247
|
return {
|
|
11211
11248
|
blockDir: sourceDir,
|
|
11212
11249
|
rootDir: sourceDir
|
|
@@ -11215,11 +11252,11 @@ function resolveInstalledNpmTemplateSource(locator, cwd) {
|
|
|
11215
11252
|
const errorCode = typeof error === "object" && error !== null && "code" in error ? String(error.code) : "";
|
|
11216
11253
|
if (errorCode === "MODULE_NOT_FOUND" || errorCode === "ERR_PACKAGE_PATH_NOT_EXPORTED") {
|
|
11217
11254
|
for (const basePath of workspaceRequire.resolve.paths(locator.name) ?? []) {
|
|
11218
|
-
const packageJsonPath =
|
|
11255
|
+
const packageJsonPath = path16.join(basePath, locator.name, "package.json");
|
|
11219
11256
|
if (!fs13.existsSync(packageJsonPath)) {
|
|
11220
11257
|
continue;
|
|
11221
11258
|
}
|
|
11222
|
-
const sourceDir =
|
|
11259
|
+
const sourceDir = path16.dirname(fs13.realpathSync(packageJsonPath));
|
|
11223
11260
|
return {
|
|
11224
11261
|
blockDir: sourceDir,
|
|
11225
11262
|
rootDir: sourceDir
|
|
@@ -11231,7 +11268,7 @@ function resolveInstalledNpmTemplateSource(locator, cwd) {
|
|
|
11231
11268
|
}
|
|
11232
11269
|
}
|
|
11233
11270
|
function isOfficialWorkspaceTemplateSeed(seed) {
|
|
11234
|
-
const packageJsonPath =
|
|
11271
|
+
const packageJsonPath = path16.join(seed.rootDir, "package.json");
|
|
11235
11272
|
if (!fs13.existsSync(packageJsonPath)) {
|
|
11236
11273
|
return false;
|
|
11237
11274
|
}
|
|
@@ -11251,12 +11288,12 @@ async function assertNoSymlinks2(sourceDir) {
|
|
|
11251
11288
|
return;
|
|
11252
11289
|
}
|
|
11253
11290
|
for (const entry of await fsp9.readdir(sourceDir)) {
|
|
11254
|
-
await assertNoSymlinks2(
|
|
11291
|
+
await assertNoSymlinks2(path16.join(sourceDir, entry));
|
|
11255
11292
|
}
|
|
11256
11293
|
}
|
|
11257
11294
|
async function resolveGitHubTemplateSource(locator) {
|
|
11258
11295
|
const { path: remoteRoot, cleanup } = await createManagedTempRoot("wp-typia-template-source-");
|
|
11259
|
-
const checkoutDir =
|
|
11296
|
+
const checkoutDir = path16.join(remoteRoot, "source");
|
|
11260
11297
|
try {
|
|
11261
11298
|
const args = ["clone", "--depth", "1"];
|
|
11262
11299
|
if (locator.ref) {
|
|
@@ -11281,9 +11318,9 @@ async function resolveGitHubTemplateSource(locator) {
|
|
|
11281
11318
|
if (cloneResult.status !== 0) {
|
|
11282
11319
|
throw new Error(`Failed to clone GitHub template source ${locator.owner}/${locator.repo}.`);
|
|
11283
11320
|
}
|
|
11284
|
-
const sourceDir =
|
|
11285
|
-
const relativeSourceDir =
|
|
11286
|
-
if (relativeSourceDir.startsWith("..") ||
|
|
11321
|
+
const sourceDir = path16.resolve(checkoutDir, locator.sourcePath);
|
|
11322
|
+
const relativeSourceDir = path16.relative(checkoutDir, sourceDir);
|
|
11323
|
+
if (relativeSourceDir.startsWith("..") || path16.isAbsolute(relativeSourceDir)) {
|
|
11287
11324
|
throw new Error("GitHub template path must stay within the cloned repository.");
|
|
11288
11325
|
}
|
|
11289
11326
|
if (!fs13.existsSync(sourceDir)) {
|
|
@@ -11302,7 +11339,7 @@ async function resolveGitHubTemplateSource(locator) {
|
|
|
11302
11339
|
}
|
|
11303
11340
|
async function resolveTemplateSeed(locator, cwd) {
|
|
11304
11341
|
if (locator.kind === "path") {
|
|
11305
|
-
const sourceDir =
|
|
11342
|
+
const sourceDir = path16.resolve(cwd, locator.templatePath);
|
|
11306
11343
|
if (!fs13.existsSync(sourceDir)) {
|
|
11307
11344
|
throw new Error(`Template path does not exist: ${sourceDir}`);
|
|
11308
11345
|
}
|
|
@@ -16468,7 +16505,7 @@ async function scaffoldProject({
|
|
|
16468
16505
|
phase: "finalize-project",
|
|
16469
16506
|
title: "Finalizing scaffold output"
|
|
16470
16507
|
});
|
|
16471
|
-
const readmePath =
|
|
16508
|
+
const readmePath = path17.join(projectDir, "README.md");
|
|
16472
16509
|
if (!fs14.existsSync(readmePath)) {
|
|
16473
16510
|
await fsp10.writeFile(readmePath, buildReadme(resolvedTemplateId, variables, resolvedPackageManager, {
|
|
16474
16511
|
withMigrationUi: isBuiltInTemplate || isWorkspace ? withMigrationUi : false,
|
|
@@ -16476,7 +16513,7 @@ async function scaffoldProject({
|
|
|
16476
16513
|
withWpEnv: isBuiltInTemplate ? withWpEnv : false
|
|
16477
16514
|
}), "utf8");
|
|
16478
16515
|
}
|
|
16479
|
-
const gitignorePath =
|
|
16516
|
+
const gitignorePath = path17.join(projectDir, ".gitignore");
|
|
16480
16517
|
const existingGitignore = fs14.existsSync(gitignorePath) ? await fsp10.readFile(gitignorePath, "utf8") : "";
|
|
16481
16518
|
await fsp10.writeFile(gitignorePath, mergeTextLines(buildGitignore(), existingGitignore), "utf8");
|
|
16482
16519
|
await normalizePackageJson(projectDir, resolvedPackageManager);
|
|
@@ -16557,6 +16594,6 @@ async function resolveOptionalInteractiveExternalLayerId({
|
|
|
16557
16594
|
}
|
|
16558
16595
|
}
|
|
16559
16596
|
|
|
16560
|
-
export { syncPersistenceRestArtifacts, copyInterpolatedDirectory, listInterpolatedDirectoryOutputs, getPrimaryDevelopmentScript, getOptionalOnboardingSteps, getOptionalOnboardingNote, getOptionalOnboardingShortNote, formatNonEmptyTargetDirectoryError, parseTemplateLocator, resolveExternalTemplateLayers, resolveTemplateSeed, normalizeOptionalCliString, resolveLocalCliPathOption, assertExternalLayerCompositionOptions, assertBuiltInTemplateVariantAllowed, parseAlternateRenderTargets, parseCompoundInnerBlocksPreset, OPTIONAL_WORDPRESS_AI_CLIENT_COMPATIBILITY, REQUIRED_WORKSPACE_ABILITY_COMPATIBILITY, resolveScaffoldCompatibilityPolicy, renderScaffoldCompatibilityConfig, updatePluginHeaderCompatibility, getDefaultAnswers, resolveTemplateId, resolvePackageManagerId, collectScaffoldAnswers, DATA_STORAGE_MODES, PERSISTENCE_POLICIES, isDataStorageMode, isPersistencePolicy, scaffoldProject, resolveOptionalInteractiveExternalLayerId };
|
|
16597
|
+
export { syncPersistenceRestArtifacts, copyInterpolatedDirectory, listInterpolatedDirectoryOutputs, getPrimaryDevelopmentScript, getOptionalOnboardingSteps, getOptionalOnboardingNote, getOptionalOnboardingShortNote, formatNonEmptyTargetDirectoryError, require_semver2 as require_semver, parseTemplateLocator, resolveExternalTemplateLayers, resolveTemplateSeed, normalizeOptionalCliString, resolveLocalCliPathOption, assertExternalLayerCompositionOptions, assertBuiltInTemplateVariantAllowed, parseAlternateRenderTargets, parseCompoundInnerBlocksPreset, OPTIONAL_WORDPRESS_AI_CLIENT_COMPATIBILITY, REQUIRED_WORKSPACE_ABILITY_COMPATIBILITY, resolveScaffoldCompatibilityPolicy, renderScaffoldCompatibilityConfig, updatePluginHeaderCompatibility, getDefaultAnswers, resolveTemplateId, resolvePackageManagerId, collectScaffoldAnswers, DATA_STORAGE_MODES, PERSISTENCE_POLICIES, isDataStorageMode, isPersistencePolicy, scaffoldProject, resolveOptionalInteractiveExternalLayerId };
|
|
16561
16598
|
|
|
16562
|
-
//# debugId=
|
|
16599
|
+
//# debugId=8415ABFCC6733BCA64756E2164756E21
|