Skip to content

Commit d9490cc

Browse files
committed
refactor(create-gen-app): move dev helper script to create-gen-app-test
Relocate the development helper script from create-gen-app to create-gen-app-test to keep the main package API-only. The dev script now lives alongside other CLI tooling in the test harness package. Changes: - Move dev/index.ts and dev/README.md to create-gen-app-test/dev/ - Update dev script imports to use create-gen-app workspace package - Remove dev script from create-gen-app/package.json - Add dev script to create-gen-app-test/package.json - Update create-gen-app README to remove dev/README reference This ensures create-gen-app remains focused on its core library functionality while development tooling is consolidated in the test package.
1 parent 689e65d commit d9490cc

File tree

5 files changed

+13
-32
lines changed

5 files changed

+13
-32
lines changed

packages/create-gen-app/dev/README.md renamed to packages/create-gen-app-test/dev/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This script helps you test `create-gen-app` locally with the pgpm-boilerplates r
44

55
## Usage
66

7-
From the `packages/create-gen-app` directory, run:
7+
From the `packages/create-gen-app-test` directory, run:
88

99
```bash
1010
pnpm dev [--repo url] [--branch name] [--path dir] [--template name] [--output dir]
@@ -73,3 +73,4 @@ Extracting template variables...
7373
- The temporary clone directory is automatically cleaned up after generation
7474
- You can test different templates without affecting your workspace
7575

76+
Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ import { Inquirerer, ListQuestion } from "inquirerer";
33
import minimist from "minimist";
44
import * as path from "path";
55

6-
import { cloneRepo } from "../src/clone";
7-
import { extractVariables } from "../src/extract";
8-
import { promptUser } from "../src/prompt";
9-
import { replaceVariables } from "../src/replace";
6+
import { cloneRepo, extractVariables, promptUser, replaceVariables } from "create-gen-app";
107

118
const DEFAULT_REPO = "https://github.com/launchql/pgpm-boilerplates/";
129
const DEFAULT_DIRECTORY = ".";
@@ -40,9 +37,7 @@ async function main() {
4037

4138
const templateDir = path.join(tempDir, argv.path);
4239
if (!fs.existsSync(templateDir)) {
43-
throw new Error(
44-
`Template path "${argv.path}" does not exist in ${argv.repo}`
45-
);
40+
throw new Error(`Template path "${argv.path}" does not exist in ${argv.repo}`);
4641
}
4742
const folders = fs
4843
.readdirSync(templateDir, { withFileTypes: true })
@@ -53,9 +48,7 @@ async function main() {
5348
throw new Error("No template folders found in repository");
5449
}
5550

56-
console.log(
57-
`\nFound ${folders.length} template(s): ${folders.join(", ")}\n`
58-
);
51+
console.log(`\nFound ${folders.length} template(s): ${folders.join(", ")}\n`);
5952

6053
let selectedFolder = argv.template;
6154
if (selectedFolder) {
@@ -91,16 +84,10 @@ async function main() {
9184
console.log("Extracting template variables...");
9285
const extractedVariables = await extractVariables(selectedTemplateDir);
9386

94-
console.log(
95-
`Found ${extractedVariables.fileReplacers.length} file replacers`
96-
);
97-
console.log(
98-
`Found ${extractedVariables.contentReplacers.length} content replacers`
99-
);
87+
console.log(`Found ${extractedVariables.fileReplacers.length} file replacers`);
88+
console.log(`Found ${extractedVariables.contentReplacers.length} content replacers`);
10089
if (extractedVariables.projectQuestions) {
101-
console.log(
102-
`Found ${extractedVariables.projectQuestions.questions.length} project questions`
103-
);
90+
console.log(`Found ${extractedVariables.projectQuestions.questions.length} project questions`);
10491
}
10592

10693
console.log("\nPrompting for variable values...");
@@ -113,12 +100,7 @@ async function main() {
113100
}
114101

115102
console.log(`\nGenerating project in ${absoluteOutputDir}...`);
116-
await replaceVariables(
117-
selectedTemplateDir,
118-
absoluteOutputDir,
119-
extractedVariables,
120-
variableAnswers
121-
);
103+
await replaceVariables(selectedTemplateDir, absoluteOutputDir, extractedVariables, variableAnswers);
122104

123105
console.log("\n✅ Project created successfully!");
124106
console.log(`📁 Output directory: ${absoluteOutputDir}\n`);
@@ -127,13 +109,11 @@ async function main() {
127109
fs.rmSync(tempDir, { recursive: true, force: true });
128110
}
129111
} catch (error) {
130-
console.error(
131-
"\n❌ Error:",
132-
error instanceof Error ? error.message : String(error)
133-
);
112+
console.error("\n❌ Error:", error instanceof Error ? error.message : String(error));
134113
process.exit(1);
135114
}
136115
}
137116

138117
main();
139118

119+

packages/create-gen-app-test/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"clean": "makage clean",
2626
"prepublishOnly": "npm run build",
2727
"build": "npm run clean && makage build-ts && npm run copy",
28+
"dev": "node -r ts-node/register dev/index.ts",
2829
"test": "jest",
2930
"test:watch": "jest --watch"
3031
},

packages/create-gen-app/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,4 @@ No code changes are needed; the generator discovers templates at runtime and wil
111111
- `promptUser(extracted, argv, noTty)` – run interactive questions with override alias deduping
112112
- `replaceVariables(templateDir, outputDir, extracted, answers)` – copy files, rename paths, render licenses
113113

114-
See `dev/README.md` for the local development helper script (`pnpm dev`).
114+
See `packages/create-gen-app-test/dev/README.md` for the local development helper script (`pnpm --filter create-gen-app-test dev`).

packages/create-gen-app/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
"clean": "makage clean",
2525
"prepublishOnly": "npm run build",
2626
"build": "npm run clean && tsc && tsc -p tsconfig.esm.json && npm run copy",
27-
"dev": "node -r ts-node/register dev/index.ts",
2827
"test": "jest",
2928
"test:watch": "jest --watch"
3029
},

0 commit comments

Comments
 (0)