@wp-typia/project-tools 0.19.1 → 0.19.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/runtime/built-in-block-non-ts-artifacts.js +1 -1039
- package/dist/runtime/built-in-block-non-ts-family-artifacts.d.ts +30 -0
- package/dist/runtime/built-in-block-non-ts-family-artifacts.js +1035 -0
- package/dist/runtime/built-in-block-non-ts-render-utils.d.ts +27 -0
- package/dist/runtime/built-in-block-non-ts-render-utils.js +51 -0
- package/dist/runtime/cli-add-workspace-rest-anchors.d.ts +3 -0
- package/dist/runtime/cli-add-workspace-rest-anchors.js +188 -0
- package/dist/runtime/cli-add-workspace-rest-source-emitters.d.ts +7 -0
- package/dist/runtime/cli-add-workspace-rest-source-emitters.js +379 -0
- package/dist/runtime/cli-add-workspace-rest.js +5 -564
- package/dist/runtime/cli-diagnostics.d.ts +2 -0
- package/dist/runtime/cli-diagnostics.js +10 -1
- package/dist/runtime/cli-help.js +3 -0
- package/dist/runtime/cli-init.d.ts +49 -0
- package/dist/runtime/cli-init.js +354 -0
- package/dist/runtime/cli-scaffold.d.ts +1 -0
- package/dist/runtime/cli-scaffold.js +5 -1
- package/dist/runtime/cli-templates.js +36 -6
- package/dist/runtime/external-template-guards.d.ts +31 -0
- package/dist/runtime/external-template-guards.js +132 -0
- package/dist/runtime/package-managers.d.ts +8 -0
- package/dist/runtime/package-managers.js +13 -0
- package/dist/runtime/package-versions.d.ts +8 -0
- package/dist/runtime/package-versions.js +84 -19
- package/dist/runtime/scaffold-documents.js +19 -1
- package/dist/runtime/scaffold-onboarding.d.ts +4 -0
- package/dist/runtime/scaffold-onboarding.js +25 -1
- package/dist/runtime/scaffold.js +2 -5
- package/dist/runtime/template-registry.d.ts +23 -1
- package/dist/runtime/template-registry.js +37 -3
- package/dist/runtime/template-source-external.js +9 -3
- package/dist/runtime/template-source-remote.js +5 -0
- package/dist/runtime/template-source-seeds.js +40 -6
- package/package.json +7 -2
- package/templates/_shared/base/package.json.mustache +0 -1
- package/templates/_shared/compound/core/package.json.mustache +0 -1
- package/templates/_shared/compound/persistence/package.json.mustache +0 -1
- package/templates/_shared/persistence/core/package.json.mustache +0 -1
- package/templates/interactivity/package.json.mustache +0 -1
|
@@ -2,9 +2,10 @@ import fs from 'node:fs';
|
|
|
2
2
|
import { promises as fsp } from 'node:fs';
|
|
3
3
|
import { createRequire } from 'node:module';
|
|
4
4
|
import path from 'node:path';
|
|
5
|
-
import {
|
|
5
|
+
import { spawnSync } from 'node:child_process';
|
|
6
6
|
import semver from 'semver';
|
|
7
7
|
import { x as extractTarball } from 'tar';
|
|
8
|
+
import { createExternalTemplateTimeoutError, fetchWithExternalTemplateTimeout, getExternalTemplateMetadataMaxBytes, getExternalTemplateTarballMaxBytes, getExternalTemplateTimeoutMs, readBufferResponseWithLimit, readJsonResponseWithLimit, } from './external-template-guards.js';
|
|
8
9
|
import { OFFICIAL_WORKSPACE_TEMPLATE_PACKAGE, PROJECT_TOOLS_PACKAGE_ROOT, } from './template-registry.js';
|
|
9
10
|
import { isPlainObject } from './object-utils.js';
|
|
10
11
|
import { createManagedTempRoot } from './temp-roots.js';
|
|
@@ -43,11 +44,17 @@ function selectRegistryVersion(metadata, locator) {
|
|
|
43
44
|
}
|
|
44
45
|
async function fetchNpmTemplateSource(locator) {
|
|
45
46
|
const registryBase = (process.env.NPM_CONFIG_REGISTRY ?? 'https://registry.npmjs.org').replace(/\/$/, '');
|
|
46
|
-
const
|
|
47
|
+
const metadataLabel = `fetching npm template metadata for ${locator.raw}`;
|
|
48
|
+
const metadataResponse = await fetchWithExternalTemplateTimeout(`${registryBase}/${encodeURIComponent(locator.name)}`, {
|
|
49
|
+
label: metadataLabel,
|
|
50
|
+
});
|
|
47
51
|
if (!metadataResponse.ok) {
|
|
48
52
|
throw new Error(`Failed to fetch npm template metadata for ${locator.raw}: ${metadataResponse.status}`);
|
|
49
53
|
}
|
|
50
|
-
const metadata =
|
|
54
|
+
const metadata = await readJsonResponseWithLimit(metadataResponse, {
|
|
55
|
+
label: `npm template metadata for ${locator.raw}`,
|
|
56
|
+
maxBytes: getExternalTemplateMetadataMaxBytes(),
|
|
57
|
+
});
|
|
51
58
|
const resolvedVersion = selectRegistryVersion(metadata, locator);
|
|
52
59
|
const versions = isPlainObject(metadata.versions) ? metadata.versions : {};
|
|
53
60
|
const versionMetadata = versions[resolvedVersion];
|
|
@@ -60,14 +67,19 @@ async function fetchNpmTemplateSource(locator) {
|
|
|
60
67
|
}
|
|
61
68
|
const { path: tempRoot, cleanup } = await createManagedTempRoot('wp-typia-template-source-');
|
|
62
69
|
try {
|
|
63
|
-
const tarballResponse = await
|
|
70
|
+
const tarballResponse = await fetchWithExternalTemplateTimeout(tarballUrl, {
|
|
71
|
+
label: `downloading npm template tarball for ${locator.raw}@${resolvedVersion}`,
|
|
72
|
+
});
|
|
64
73
|
if (!tarballResponse.ok) {
|
|
65
74
|
throw new Error(`Failed to download npm template tarball for ${locator.raw}: ${tarballResponse.status}`);
|
|
66
75
|
}
|
|
67
76
|
const tarballPath = path.join(tempRoot, 'template.tgz');
|
|
68
77
|
const unpackDir = path.join(tempRoot, 'source');
|
|
69
78
|
await fsp.mkdir(unpackDir, { recursive: true });
|
|
70
|
-
await fsp.writeFile(tarballPath,
|
|
79
|
+
await fsp.writeFile(tarballPath, await readBufferResponseWithLimit(tarballResponse, {
|
|
80
|
+
label: `npm template tarball for ${locator.raw}@${resolvedVersion}`,
|
|
81
|
+
maxBytes: getExternalTemplateTarballMaxBytes(),
|
|
82
|
+
}));
|
|
71
83
|
await extractTarball({
|
|
72
84
|
cwd: unpackDir,
|
|
73
85
|
file: tarballPath,
|
|
@@ -183,7 +195,29 @@ async function resolveGitHubTemplateSource(locator) {
|
|
|
183
195
|
args.push('--branch', locator.ref);
|
|
184
196
|
}
|
|
185
197
|
args.push(`https://github.com/${locator.owner}/${locator.repo}.git`, checkoutDir);
|
|
186
|
-
|
|
198
|
+
const cloneTimeoutMs = getExternalTemplateTimeoutMs();
|
|
199
|
+
const cloneResult = spawnSync('git', args, {
|
|
200
|
+
stdio: 'ignore',
|
|
201
|
+
timeout: cloneTimeoutMs,
|
|
202
|
+
});
|
|
203
|
+
if (cloneResult.error) {
|
|
204
|
+
const errorCode = typeof cloneResult.error === 'object' &&
|
|
205
|
+
cloneResult.error !== null &&
|
|
206
|
+
'code' in cloneResult.error
|
|
207
|
+
? String(cloneResult.error.code)
|
|
208
|
+
: '';
|
|
209
|
+
if (errorCode === 'ETIMEDOUT') {
|
|
210
|
+
throw createExternalTemplateTimeoutError(`cloning GitHub template ${locator.owner}/${locator.repo}`, cloneTimeoutMs);
|
|
211
|
+
}
|
|
212
|
+
throw cloneResult.error;
|
|
213
|
+
}
|
|
214
|
+
if (cloneResult.signal === 'SIGTERM' ||
|
|
215
|
+
cloneResult.signal === 'SIGKILL') {
|
|
216
|
+
throw createExternalTemplateTimeoutError(`cloning GitHub template ${locator.owner}/${locator.repo}`, cloneTimeoutMs);
|
|
217
|
+
}
|
|
218
|
+
if (cloneResult.status !== 0) {
|
|
219
|
+
throw new Error(`Failed to clone GitHub template source ${locator.owner}/${locator.repo}.`);
|
|
220
|
+
}
|
|
187
221
|
const sourceDir = path.resolve(checkoutDir, locator.sourcePath);
|
|
188
222
|
const relativeSourceDir = path.relative(checkoutDir, sourceDir);
|
|
189
223
|
if (relativeSourceDir.startsWith('..') ||
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wp-typia/project-tools",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.3",
|
|
4
4
|
"description": "Project orchestration and programmatic tooling for wp-typia",
|
|
5
5
|
"packageManager": "bun@1.3.11",
|
|
6
6
|
"type": "module",
|
|
@@ -27,6 +27,11 @@
|
|
|
27
27
|
"import": "./dist/runtime/cli-doctor.js",
|
|
28
28
|
"default": "./dist/runtime/cli-doctor.js"
|
|
29
29
|
},
|
|
30
|
+
"./cli-init": {
|
|
31
|
+
"types": "./dist/runtime/cli-init.d.ts",
|
|
32
|
+
"import": "./dist/runtime/cli-init.js",
|
|
33
|
+
"default": "./dist/runtime/cli-init.js"
|
|
34
|
+
},
|
|
30
35
|
"./cli-prompt": {
|
|
31
36
|
"types": "./dist/runtime/cli-prompt.d.ts",
|
|
32
37
|
"import": "./dist/runtime/cli-prompt.js",
|
|
@@ -90,7 +95,7 @@
|
|
|
90
95
|
"prepack": "bun run build && node ./scripts/publish-manifest.mjs prepare",
|
|
91
96
|
"postpack": "node ./scripts/publish-manifest.mjs restore",
|
|
92
97
|
"test": "bun run build && bun test tests/*.test.ts",
|
|
93
|
-
"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",
|
|
98
|
+
"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/init-command.test.ts tests/cli-entry.test.ts tests/cli-prompt.test.ts tests/import-policy.test.ts",
|
|
94
99
|
"test:workspace": "bun run build && bun test tests/workspace-add.test.ts tests/workspace-doctor.test.ts",
|
|
95
100
|
"test:compound": "bun run build && bun test tests/scaffold-compound.test.ts",
|
|
96
101
|
"test:migration-planning": "bun run build && bun test tests/migration-init.test.ts tests/migration-config.test.ts tests/migration-plan-wizard.test.ts",
|
|
@@ -21,7 +21,6 @@
|
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@wp-typia/block-runtime": "{{blockRuntimePackageVersion}}",
|
|
23
23
|
"@wp-typia/block-types": "{{blockTypesPackageVersion}}",
|
|
24
|
-
"ajv": "^8.18.0",
|
|
25
24
|
"@types/wordpress__block-editor": "^11.5.17",
|
|
26
25
|
"@types/wordpress__blocks": "^12.5.18",
|
|
27
26
|
"@wordpress/browserslist-config": "^6.42.0",
|
|
@@ -24,7 +24,6 @@
|
|
|
24
24
|
"@wp-typia/api-client": "{{apiClientPackageVersion}}",
|
|
25
25
|
"@wp-typia/block-types": "{{blockTypesPackageVersion}}",
|
|
26
26
|
"@wp-typia/rest": "{{restPackageVersion}}",
|
|
27
|
-
"ajv": "^8.18.0",
|
|
28
27
|
"@types/wordpress__block-editor": "^11.5.17",
|
|
29
28
|
"@types/wordpress__blocks": "^12.5.18",
|
|
30
29
|
"@wordpress/browserslist-config": "^6.42.0",
|
|
@@ -21,7 +21,6 @@
|
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@wp-typia/block-runtime": "{{blockRuntimePackageVersion}}",
|
|
23
23
|
"@wp-typia/block-types": "{{blockTypesPackageVersion}}",
|
|
24
|
-
"ajv": "^8.18.0",
|
|
25
24
|
"@types/wordpress__block-editor": "^11.5.17",
|
|
26
25
|
"@types/wordpress__blocks": "^12.5.18",
|
|
27
26
|
"@wordpress/browserslist-config": "^6.42.0",
|