@wp-typia/project-tools 0.22.4 → 0.22.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/runtime/ai-feature-capability.js +20 -0
- package/dist/runtime/cli-add-block.js +16 -11
- package/dist/runtime/cli-add-collision.js +213 -136
- package/dist/runtime/cli-add-help.js +1 -1
- package/dist/runtime/cli-add-kind-ids.d.ts +11 -0
- package/dist/runtime/cli-add-kind-ids.js +20 -0
- package/dist/runtime/cli-add-types.d.ts +2 -8
- package/dist/runtime/cli-add-types.js +1 -17
- package/dist/runtime/cli-add-workspace-ability-scaffold.d.ts +3 -1
- package/dist/runtime/cli-add-workspace-ability-scaffold.js +22 -5
- package/dist/runtime/cli-add-workspace-ability.d.ts +4 -0
- package/dist/runtime/cli-add-workspace-ability.js +5 -1
- package/dist/runtime/cli-add-workspace-admin-view-source.d.ts +7 -0
- package/dist/runtime/cli-add-workspace-admin-view-source.js +9 -10
- package/dist/runtime/cli-add-workspace-admin-view-types.d.ts +0 -2
- package/dist/runtime/cli-add-workspace-admin-view-types.js +0 -3
- package/dist/runtime/cli-add-workspace-ai-anchors.js +3 -24
- package/dist/runtime/cli-add-workspace-ai-scaffold.js +14 -6
- package/dist/runtime/cli-add-workspace-assets.js +7 -50
- package/dist/runtime/cli-add-workspace-rest-anchors.js +3 -24
- package/dist/runtime/cli-doctor-workspace-bindings.js +2 -3
- package/dist/runtime/cli-doctor-workspace-blocks.js +2 -3
- package/dist/runtime/cli-doctor-workspace-features.js +6 -11
- package/dist/runtime/cli-doctor-workspace-shared.d.ts +8 -0
- package/dist/runtime/cli-doctor-workspace-shared.js +10 -0
- package/dist/runtime/cli-help.js +1 -1
- package/dist/runtime/cli-init-apply.d.ts +15 -0
- package/dist/runtime/cli-init-apply.js +99 -0
- package/dist/runtime/cli-init-package-json.d.ts +19 -0
- package/dist/runtime/cli-init-package-json.js +191 -0
- package/dist/runtime/cli-init-plan.d.ts +39 -0
- package/dist/runtime/cli-init-plan.js +375 -0
- package/dist/runtime/cli-init-templates.d.ts +27 -0
- package/dist/runtime/cli-init-templates.js +244 -0
- package/dist/runtime/cli-init-types.d.ts +84 -0
- package/dist/runtime/cli-init-types.js +3 -0
- package/dist/runtime/cli-init.d.ts +4 -100
- package/dist/runtime/cli-init.js +6 -878
- package/dist/runtime/fs-async.d.ts +28 -0
- package/dist/runtime/fs-async.js +53 -0
- package/dist/runtime/package-managers.js +1 -1
- package/dist/runtime/php-utils.d.ts +16 -0
- package/dist/runtime/php-utils.js +321 -1
- package/dist/runtime/scaffold-apply-utils.js +10 -20
- package/dist/runtime/scaffold-bootstrap.js +6 -8
- package/dist/runtime/scaffold-compatibility.d.ts +15 -3
- package/dist/runtime/scaffold-compatibility.js +42 -11
- package/dist/runtime/scaffold-documents.js +12 -0
- package/dist/runtime/scaffold-package-manager-files.js +4 -3
- package/dist/runtime/string-case.d.ts +5 -0
- package/dist/runtime/string-case.js +52 -2
- package/dist/runtime/template-source-cache.d.ts +19 -0
- package/dist/runtime/template-source-cache.js +164 -28
- package/dist/runtime/template-source-external.d.ts +7 -0
- package/dist/runtime/template-source-external.js +22 -5
- package/dist/runtime/template-source-normalization.d.ts +1 -1
- package/dist/runtime/template-source-normalization.js +12 -12
- package/dist/runtime/template-source-remote.d.ts +14 -0
- package/dist/runtime/template-source-remote.js +91 -15
- package/dist/runtime/template-source.js +35 -25
- package/dist/runtime/typia-llm.js +7 -0
- package/dist/runtime/version-floor.js +8 -2
- package/dist/runtime/workspace-inventory.d.ts +16 -14
- package/dist/runtime/workspace-inventory.js +310 -239
- package/package.json +6 -1
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import { promises as fsp } from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { CLI_DIAGNOSTIC_CODES, createCliDiagnosticCodeError, } from "./cli-diagnostics.js";
|
|
5
|
+
import { rollbackWorkspaceMutation, snapshotWorkspaceFiles, } from "./cli-add-shared.js";
|
|
6
|
+
import { buildNextProjectPackageJson, buildProjectPackageJsonSource, readProjectPackageJson, } from "./cli-init-package-json.js";
|
|
7
|
+
import { createRetrofitPlan, getInitPlan } from "./cli-init-plan.js";
|
|
8
|
+
import { buildRetrofitHelperFiles } from "./cli-init-templates.js";
|
|
9
|
+
import { RETROFIT_APPLY_PREVIEW_NOTE, RETROFIT_ROLLBACK_NOTE, } from "./cli-init-types.js";
|
|
10
|
+
async function createRetrofitMutationSnapshot(projectDir, filePaths) {
|
|
11
|
+
const scriptsDir = path.join(projectDir, "scripts");
|
|
12
|
+
const scriptsDirExisted = fs.existsSync(scriptsDir);
|
|
13
|
+
const fileSources = await snapshotWorkspaceFiles(filePaths);
|
|
14
|
+
const targetPaths = fileSources
|
|
15
|
+
.filter((entry) => entry.source === null)
|
|
16
|
+
.map((entry) => entry.filePath);
|
|
17
|
+
if (!scriptsDirExisted) {
|
|
18
|
+
targetPaths.push(scriptsDir);
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
fileSources,
|
|
22
|
+
snapshotDirs: [],
|
|
23
|
+
targetPaths,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
async function writeRetrofitFiles(options) {
|
|
27
|
+
const helperFiles = buildRetrofitHelperFiles(options.blockTargets);
|
|
28
|
+
const scriptsDir = path.join(options.projectDir, "scripts");
|
|
29
|
+
await fsp.mkdir(scriptsDir, { recursive: true });
|
|
30
|
+
await fsp.writeFile(path.join(options.projectDir, "package.json"), buildProjectPackageJsonSource(options.packageJson), "utf8");
|
|
31
|
+
for (const [relativePath, source] of Object.entries(helperFiles)) {
|
|
32
|
+
await fsp.writeFile(path.join(options.projectDir, relativePath), source, "utf8");
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function buildApplyFailureError(error) {
|
|
36
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
37
|
+
return createCliDiagnosticCodeError(CLI_DIAGNOSTIC_CODES.INVALID_ARGUMENT, `Unable to apply the retrofit init plan safely. The command restored the previous package.json/helper-file snapshot. ${message}`, error instanceof Error ? { cause: error } : undefined);
|
|
38
|
+
}
|
|
39
|
+
function toApplyNotes(previewNotes) {
|
|
40
|
+
return Array.from(new Set([
|
|
41
|
+
...previewNotes.filter((note) => note !== "Preview only: `wp-typia init` does not write files yet." &&
|
|
42
|
+
note !== RETROFIT_APPLY_PREVIEW_NOTE),
|
|
43
|
+
RETROFIT_ROLLBACK_NOTE,
|
|
44
|
+
]));
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Apply the previewed retrofit init plan to disk.
|
|
48
|
+
*
|
|
49
|
+
* The command snapshots package.json and generated helper targets before
|
|
50
|
+
* writing, then rolls those files back automatically if any write fails.
|
|
51
|
+
*
|
|
52
|
+
* @param projectDir Project root that should receive the retrofit surface.
|
|
53
|
+
* @param options Optional package-manager override used for emitted scripts and
|
|
54
|
+
* follow-up guidance.
|
|
55
|
+
* @returns The applied retrofit init plan describing the persisted changes.
|
|
56
|
+
*/
|
|
57
|
+
export async function applyInitPlan(projectDir, options = {}) {
|
|
58
|
+
const previewPlan = getInitPlan(projectDir, options);
|
|
59
|
+
if (previewPlan.detectedLayout.kind === "unsupported") {
|
|
60
|
+
throw createCliDiagnosticCodeError(CLI_DIAGNOSTIC_CODES.INVALID_ARGUMENT, "`wp-typia init --apply` requires a supported retrofit layout. Run `wp-typia init` first to inspect the preview plan and any blocking notes.");
|
|
61
|
+
}
|
|
62
|
+
if (previewPlan.status === "already-initialized") {
|
|
63
|
+
return createRetrofitPlan({
|
|
64
|
+
...previewPlan,
|
|
65
|
+
commandMode: "apply",
|
|
66
|
+
notes: toApplyNotes(previewPlan.notes),
|
|
67
|
+
status: "already-initialized",
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
const nextPackageJson = buildNextProjectPackageJson({
|
|
71
|
+
packageChanges: previewPlan.packageChanges,
|
|
72
|
+
packageJson: readProjectPackageJson(previewPlan.projectDir),
|
|
73
|
+
packageManager: previewPlan.packageManager,
|
|
74
|
+
projectName: previewPlan.projectName,
|
|
75
|
+
});
|
|
76
|
+
const helperFiles = buildRetrofitHelperFiles(previewPlan.blockTargets);
|
|
77
|
+
const filePaths = [
|
|
78
|
+
path.join(previewPlan.projectDir, "package.json"),
|
|
79
|
+
...Object.keys(helperFiles).map((relativePath) => path.join(previewPlan.projectDir, relativePath)),
|
|
80
|
+
];
|
|
81
|
+
const mutationSnapshot = await createRetrofitMutationSnapshot(previewPlan.projectDir, filePaths);
|
|
82
|
+
try {
|
|
83
|
+
await writeRetrofitFiles({
|
|
84
|
+
blockTargets: previewPlan.blockTargets,
|
|
85
|
+
packageJson: nextPackageJson,
|
|
86
|
+
projectDir: previewPlan.projectDir,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
await rollbackWorkspaceMutation(mutationSnapshot);
|
|
91
|
+
throw buildApplyFailureError(error);
|
|
92
|
+
}
|
|
93
|
+
return createRetrofitPlan({
|
|
94
|
+
...previewPlan,
|
|
95
|
+
commandMode: "apply",
|
|
96
|
+
notes: toApplyNotes(previewPlan.notes),
|
|
97
|
+
status: "applied",
|
|
98
|
+
});
|
|
99
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type PackageManagerId } from "./package-managers.js";
|
|
2
|
+
import type { InitDependencyChange, InitPackageManagerFieldChange, InitScriptChange, ProjectPackageJson, RetrofitInitPlan } from "./cli-init-types.js";
|
|
3
|
+
export declare function readProjectPackageJson(projectDir: string): ProjectPackageJson | null;
|
|
4
|
+
export declare function resolveInitPackageManager(projectDir: string, packageJson: ProjectPackageJson | null, override?: string): PackageManagerId;
|
|
5
|
+
export declare function getWpTypiaCliSpecifier(): string;
|
|
6
|
+
export declare function buildDependencyChanges(packageJson: ProjectPackageJson | null): InitDependencyChange[];
|
|
7
|
+
export declare function buildScriptChanges(packageJson: ProjectPackageJson | null, packageManager: PackageManagerId): InitScriptChange[];
|
|
8
|
+
export declare function buildPackageManagerFieldChange(packageJson: ProjectPackageJson | null, packageManager: PackageManagerId, options?: {
|
|
9
|
+
persistExplicitOverride?: boolean;
|
|
10
|
+
}): InitPackageManagerFieldChange | undefined;
|
|
11
|
+
export declare function hasExistingWpTypiaProjectSurface(projectDir: string, packageJson: ProjectPackageJson | null): boolean;
|
|
12
|
+
export declare function buildRequiredDevDependencyMapEntries(): string[];
|
|
13
|
+
export declare function buildNextProjectPackageJson(options: {
|
|
14
|
+
packageChanges: RetrofitInitPlan["packageChanges"];
|
|
15
|
+
packageJson: ProjectPackageJson | null;
|
|
16
|
+
packageManager: PackageManagerId;
|
|
17
|
+
projectName: string;
|
|
18
|
+
}): ProjectPackageJson;
|
|
19
|
+
export declare function buildProjectPackageJsonSource(packageJson: ProjectPackageJson): string;
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { CLI_DIAGNOSTIC_CODES, createCliDiagnosticCodeError, } from "./cli-diagnostics.js";
|
|
4
|
+
import { getPackageManager, transformPackageManagerText, } from "./package-managers.js";
|
|
5
|
+
import { getPackageVersions } from "./package-versions.js";
|
|
6
|
+
import { parseWorkspacePackageManagerId } from "./workspace-project.js";
|
|
7
|
+
const BASE_RETROFIT_SCRIPTS = {
|
|
8
|
+
sync: "tsx scripts/sync-project.ts",
|
|
9
|
+
"sync-types": "tsx scripts/sync-types-to-block-json.ts",
|
|
10
|
+
typecheck: "bun run sync --check && tsc --noEmit",
|
|
11
|
+
};
|
|
12
|
+
const BASE_RETROFIT_DEV_DEPENDENCIES = [
|
|
13
|
+
"@typia/unplugin",
|
|
14
|
+
"@wp-typia/block-runtime",
|
|
15
|
+
"@wp-typia/block-types",
|
|
16
|
+
"tsx",
|
|
17
|
+
"typescript",
|
|
18
|
+
"typia",
|
|
19
|
+
];
|
|
20
|
+
export function readProjectPackageJson(projectDir) {
|
|
21
|
+
const packageJsonPath = path.join(projectDir, "package.json");
|
|
22
|
+
if (!fs.existsSync(packageJsonPath)) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
const source = fs.readFileSync(packageJsonPath, "utf8");
|
|
26
|
+
try {
|
|
27
|
+
return JSON.parse(source);
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
31
|
+
throw createCliDiagnosticCodeError(CLI_DIAGNOSTIC_CODES.INVALID_ARGUMENT, `Unable to parse ${packageJsonPath}: ${message}`, error instanceof Error ? { cause: error } : undefined);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function inferInitPackageManager(projectDir, packageJson) {
|
|
35
|
+
if (packageJson?.packageManager) {
|
|
36
|
+
return parseWorkspacePackageManagerId(packageJson.packageManager);
|
|
37
|
+
}
|
|
38
|
+
if (fs.existsSync(path.join(projectDir, "bun.lock")) ||
|
|
39
|
+
fs.existsSync(path.join(projectDir, "bun.lockb"))) {
|
|
40
|
+
return "bun";
|
|
41
|
+
}
|
|
42
|
+
if (fs.existsSync(path.join(projectDir, "pnpm-lock.yaml"))) {
|
|
43
|
+
return "pnpm";
|
|
44
|
+
}
|
|
45
|
+
if (fs.existsSync(path.join(projectDir, "yarn.lock")) ||
|
|
46
|
+
fs.existsSync(path.join(projectDir, ".yarnrc.yml"))) {
|
|
47
|
+
return "yarn";
|
|
48
|
+
}
|
|
49
|
+
return "npm";
|
|
50
|
+
}
|
|
51
|
+
export function resolveInitPackageManager(projectDir, packageJson, override) {
|
|
52
|
+
if (!override) {
|
|
53
|
+
return inferInitPackageManager(projectDir, packageJson);
|
|
54
|
+
}
|
|
55
|
+
if (override !== "bun" &&
|
|
56
|
+
override !== "npm" &&
|
|
57
|
+
override !== "pnpm" &&
|
|
58
|
+
override !== "yarn") {
|
|
59
|
+
throw createCliDiagnosticCodeError(CLI_DIAGNOSTIC_CODES.INVALID_ARGUMENT, `Unknown package manager "${override}". Expected one of: bun, npm, pnpm, yarn.`);
|
|
60
|
+
}
|
|
61
|
+
return override;
|
|
62
|
+
}
|
|
63
|
+
export function getWpTypiaCliSpecifier() {
|
|
64
|
+
const versions = getPackageVersions();
|
|
65
|
+
return versions.wpTypiaPackageExactVersion === "0.0.0"
|
|
66
|
+
? "wp-typia"
|
|
67
|
+
: `wp-typia@${versions.wpTypiaPackageExactVersion}`;
|
|
68
|
+
}
|
|
69
|
+
function buildRequiredDevDependencyMap() {
|
|
70
|
+
const versions = getPackageVersions();
|
|
71
|
+
return {
|
|
72
|
+
"@typia/unplugin": versions.typiaUnpluginPackageVersion,
|
|
73
|
+
"@wp-typia/block-runtime": versions.blockRuntimePackageVersion,
|
|
74
|
+
"@wp-typia/block-types": versions.blockTypesPackageVersion,
|
|
75
|
+
tsx: versions.tsxPackageVersion,
|
|
76
|
+
typescript: versions.typescriptPackageVersion,
|
|
77
|
+
typia: versions.typiaPackageVersion,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
function getExistingDependencyVersion(packageJson, name) {
|
|
81
|
+
return packageJson?.devDependencies?.[name] ?? packageJson?.dependencies?.[name];
|
|
82
|
+
}
|
|
83
|
+
export function buildDependencyChanges(packageJson) {
|
|
84
|
+
const requiredDependencies = buildRequiredDevDependencyMap();
|
|
85
|
+
return BASE_RETROFIT_DEV_DEPENDENCIES.flatMap((name) => {
|
|
86
|
+
const requiredValue = requiredDependencies[name];
|
|
87
|
+
const currentValue = getExistingDependencyVersion(packageJson, name);
|
|
88
|
+
if (currentValue === requiredValue) {
|
|
89
|
+
return [];
|
|
90
|
+
}
|
|
91
|
+
return [
|
|
92
|
+
{
|
|
93
|
+
action: currentValue ? "update" : "add",
|
|
94
|
+
...(currentValue ? { currentValue } : {}),
|
|
95
|
+
name,
|
|
96
|
+
requiredValue,
|
|
97
|
+
},
|
|
98
|
+
];
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
export function buildScriptChanges(packageJson, packageManager) {
|
|
102
|
+
const scripts = packageJson?.scripts ?? {};
|
|
103
|
+
return Object.entries(BASE_RETROFIT_SCRIPTS).flatMap(([name, commandSource]) => {
|
|
104
|
+
const requiredValue = transformPackageManagerText(commandSource, packageManager);
|
|
105
|
+
const currentValue = scripts[name];
|
|
106
|
+
if (currentValue === requiredValue) {
|
|
107
|
+
return [];
|
|
108
|
+
}
|
|
109
|
+
return [
|
|
110
|
+
{
|
|
111
|
+
action: typeof currentValue === "string" ? "update" : "add",
|
|
112
|
+
...(typeof currentValue === "string" ? { currentValue } : {}),
|
|
113
|
+
name,
|
|
114
|
+
requiredValue,
|
|
115
|
+
},
|
|
116
|
+
];
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
export function buildPackageManagerFieldChange(packageJson, packageManager, options = {}) {
|
|
120
|
+
if (!options.persistExplicitOverride && packageManager === "npm") {
|
|
121
|
+
return undefined;
|
|
122
|
+
}
|
|
123
|
+
const requiredValue = getPackageManager(packageManager).packageManagerField;
|
|
124
|
+
const currentValue = packageJson?.packageManager;
|
|
125
|
+
if (currentValue === requiredValue) {
|
|
126
|
+
return undefined;
|
|
127
|
+
}
|
|
128
|
+
return {
|
|
129
|
+
action: typeof currentValue === "string" ? "update" : "add",
|
|
130
|
+
...(typeof currentValue === "string" ? { currentValue } : {}),
|
|
131
|
+
requiredValue,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
export function hasExistingWpTypiaProjectSurface(projectDir, packageJson) {
|
|
135
|
+
const scripts = packageJson?.scripts ?? {};
|
|
136
|
+
const hasSyncSurface = typeof scripts.sync === "string" || typeof scripts["sync-types"] === "string";
|
|
137
|
+
const hasHelperFiles = [
|
|
138
|
+
path.join("scripts", "block-config.ts"),
|
|
139
|
+
path.join("scripts", "sync-project.ts"),
|
|
140
|
+
path.join("scripts", "sync-types-to-block-json.ts"),
|
|
141
|
+
].every((relativePath) => fs.existsSync(path.join(projectDir, relativePath)));
|
|
142
|
+
const hasRuntimeDeps = typeof getExistingDependencyVersion(packageJson, "@wp-typia/block-runtime") ===
|
|
143
|
+
"string" &&
|
|
144
|
+
typeof getExistingDependencyVersion(packageJson, "@wp-typia/block-types") ===
|
|
145
|
+
"string";
|
|
146
|
+
return hasSyncSurface && hasHelperFiles && hasRuntimeDeps;
|
|
147
|
+
}
|
|
148
|
+
export function buildRequiredDevDependencyMapEntries() {
|
|
149
|
+
return Object.entries(buildRequiredDevDependencyMap()).map(([name, version]) => `${name}@${version.replace(/^workspace:/u, "")}`);
|
|
150
|
+
}
|
|
151
|
+
function setDependencyVersion(packageJson, name, requiredValue) {
|
|
152
|
+
if (packageJson.devDependencies?.[name] !== undefined) {
|
|
153
|
+
packageJson.devDependencies[name] = requiredValue;
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
if (packageJson.dependencies?.[name] !== undefined) {
|
|
157
|
+
packageJson.dependencies[name] = requiredValue;
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
packageJson.devDependencies ?? (packageJson.devDependencies = {});
|
|
161
|
+
packageJson.devDependencies[name] = requiredValue;
|
|
162
|
+
}
|
|
163
|
+
export function buildNextProjectPackageJson(options) {
|
|
164
|
+
const nextPackageJson = options.packageJson
|
|
165
|
+
? JSON.parse(JSON.stringify(options.packageJson))
|
|
166
|
+
: {
|
|
167
|
+
name: options.projectName,
|
|
168
|
+
private: true,
|
|
169
|
+
};
|
|
170
|
+
nextPackageJson.devDependencies ?? (nextPackageJson.devDependencies = {});
|
|
171
|
+
nextPackageJson.scripts ?? (nextPackageJson.scripts = {});
|
|
172
|
+
for (const dependencyChange of options.packageChanges.addDevDependencies) {
|
|
173
|
+
setDependencyVersion(nextPackageJson, dependencyChange.name, dependencyChange.requiredValue);
|
|
174
|
+
}
|
|
175
|
+
if (options.packageChanges.packageManagerField) {
|
|
176
|
+
nextPackageJson.packageManager =
|
|
177
|
+
options.packageChanges.packageManagerField.requiredValue;
|
|
178
|
+
}
|
|
179
|
+
else if (!nextPackageJson.packageManager &&
|
|
180
|
+
options.packageManager !== "npm") {
|
|
181
|
+
nextPackageJson.packageManager =
|
|
182
|
+
getPackageManager(options.packageManager).packageManagerField;
|
|
183
|
+
}
|
|
184
|
+
for (const scriptChange of options.packageChanges.scripts) {
|
|
185
|
+
nextPackageJson.scripts[scriptChange.name] = scriptChange.requiredValue;
|
|
186
|
+
}
|
|
187
|
+
return nextPackageJson;
|
|
188
|
+
}
|
|
189
|
+
export function buildProjectPackageJsonSource(packageJson) {
|
|
190
|
+
return `${JSON.stringify(packageJson, null, 2)}\n`;
|
|
191
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type PackageManagerId } from "./package-managers.js";
|
|
2
|
+
import { type InitCommandMode, type InitFilePlan, type InitPlanLayoutKind, type InitPlanStatus, type RetrofitInitBlockTarget, type RetrofitInitPlan } from "./cli-init-types.js";
|
|
3
|
+
export declare function buildInitLayoutDetails(projectDir: string): {
|
|
4
|
+
blockNames: string[];
|
|
5
|
+
blockTargets: RetrofitInitBlockTarget[];
|
|
6
|
+
description: string;
|
|
7
|
+
generatedArtifacts: string[];
|
|
8
|
+
kind: InitPlanLayoutKind;
|
|
9
|
+
notes: string[];
|
|
10
|
+
};
|
|
11
|
+
export declare function createRetrofitPlan(options: {
|
|
12
|
+
commandMode: InitCommandMode;
|
|
13
|
+
detectedLayout: {
|
|
14
|
+
blockNames: string[];
|
|
15
|
+
description: string;
|
|
16
|
+
kind: InitPlanLayoutKind;
|
|
17
|
+
};
|
|
18
|
+
blockTargets: RetrofitInitBlockTarget[];
|
|
19
|
+
generatedArtifacts: string[];
|
|
20
|
+
nextSteps?: string[];
|
|
21
|
+
notes: string[];
|
|
22
|
+
packageChanges: RetrofitInitPlan["packageChanges"];
|
|
23
|
+
packageManager: PackageManagerId;
|
|
24
|
+
plannedFiles: InitFilePlan[];
|
|
25
|
+
projectDir: string;
|
|
26
|
+
projectName: string;
|
|
27
|
+
status: InitPlanStatus;
|
|
28
|
+
}): RetrofitInitPlan;
|
|
29
|
+
/**
|
|
30
|
+
* Inspect one project directory and return the current retrofit init plan.
|
|
31
|
+
*
|
|
32
|
+
* @param projectDir Project root or nested path that should be analyzed.
|
|
33
|
+
* @param options Optional package-manager override used for emitted scripts and
|
|
34
|
+
* follow-up guidance.
|
|
35
|
+
* @returns The preview-only retrofit init plan for the resolved project.
|
|
36
|
+
*/
|
|
37
|
+
export declare function getInitPlan(projectDir: string, options?: {
|
|
38
|
+
packageManager?: string;
|
|
39
|
+
}): RetrofitInitPlan;
|