Skip to content

Commit 7e1e374

Browse files
committed
feat(cli): add template listing and viewing commands
- Add `--list-templates` command to display available templates - Add `--view-template <Template-Name>` command to show template details - Update help documentation with new commands - Bump version to 4.0.1
1 parent 6958ff3 commit 7e1e374

6 files changed

Lines changed: 98 additions & 17 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
- **templates:** Added `doctor` script to `react-native-app` template for easier troubleshooting.
1010
- **cli:** Improved entry point detection logic for better compatibility with `npx` and global installs.
1111
- **cli:** Added safeguards to prevent overwriting existing configuration files (`tsconfig.json`, `eslint.config.js`, `.prettierrc`) if provided by the template.
12+
- **cli:** Added `--list-templates` command to list all available templates.
13+
- **cli:** Added `--view-template <Template-Name>` command to view detailed information about a specific template.
1214

1315
### Bug Fixes
1416

dist/create-wizard.js

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17502,15 +17502,17 @@ if (args.includes("-h") || args.includes("--help")) {
1750217502
Initializes a new project using an interactive wizard.
1750317503

1750417504
Arguments:
17505-
projectName The name of the project to create. If provided, the wizard will skip the project name prompt.
17505+
projectName The name of the project to create. If provided, the wizard will skip the project name prompt.
1750617506

1750717507
Options:
17508-
-v, --version Output the current version and exit.
17509-
-h, --help Display this help message and exit.
17510-
--plugin Configure and install a new plugin (e.g., Prettier, ESLint).
17511-
--create-test Set up a new test framework for the project.
17512-
--license Generate a new LICENSE file.
17513-
--debug=TRUE Enable debug logging.
17508+
-v, --version Output the current version and exit.
17509+
-h, --help Display this help message and exit.
17510+
--plugin Configure and install a new plugin (e.g., Prettier, ESLint).
17511+
--create-test Set up a new test framework for the project.
17512+
--license Generate a new LICENSE file.
17513+
--debug=TRUE Enable debug logging.
17514+
--list-templates List all available deployment templates.
17515+
--view-template <Template-Name> View more information about a specific template by name.
1751417516
`);
1751517517
process.exit(0);
1751617518
}
@@ -18107,6 +18109,40 @@ if (resolve(process.argv[1]) === resolve(fileURLToPath3(import.meta.url))) {
1810718109
main3({
1810818110
/* dependencies */
1810918111
});
18112+
} else if (userArgs.includes("--list-templates")) {
18113+
const templatesPath = join4(dirname(fileURLToPath3(import.meta.url)), "..", "template-library");
18114+
const templates = _fs3.readdirSync(templatesPath).filter((file) => {
18115+
const filePath = join4(templatesPath, file);
18116+
return _fs3.statSync(filePath).isDirectory();
18117+
});
18118+
console.log("Available Templates:");
18119+
templates.forEach((t2) => console.log(`- ${t2}`));
18120+
process.exit(0);
18121+
} else if (userArgs.includes("--view-template")) {
18122+
const templateNameIndex = userArgs.indexOf("--view-template") + 1;
18123+
const templateName = userArgs[templateNameIndex];
18124+
if (!templateName || templateName.startsWith("--")) {
18125+
console.error("Error: Please provide a template name.");
18126+
process.exit(1);
18127+
}
18128+
const templatesPath = join4(dirname(fileURLToPath3(import.meta.url)), "..", "template-library");
18129+
const templateDir = join4(templatesPath, templateName);
18130+
if (!_fs3.existsSync(templateDir)) {
18131+
console.error(`Error: Template '${templateName}' not found.`);
18132+
process.exit(1);
18133+
}
18134+
console.log(`Template: ${templateName}`);
18135+
const templateJsonPath = join4(templateDir, "template.json");
18136+
if (_fs3.existsSync(templateJsonPath)) {
18137+
const templateJson = JSON.parse(_fs3.readFileSync(templateJsonPath, "utf-8"));
18138+
console.log("Configuration:", JSON.stringify(templateJson, null, 2));
18139+
}
18140+
const readmePath = join4(templateDir, "README.md");
18141+
if (_fs3.existsSync(readmePath)) {
18142+
console.log("\n--- README ---");
18143+
console.log(_fs3.readFileSync(readmePath, "utf-8"));
18144+
}
18145+
process.exit(0);
1811018146
} else {
1811118147
main4({});
1811218148
}

docs/changelog/v4.0.0.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ tags: [release]
1515
- **templates:** Added `doctor` script to `react-native-app` template for easier troubleshooting.
1616
- **cli:** Improved entry point detection logic for better compatibility with `npx` and global installs.
1717
- **cli:** Added safeguards to prevent overwriting existing configuration files (`tsconfig.json`, `eslint.config.js`, `.prettierrc`) if provided by the template.
18+
- **cli:** Added `--list-templates` command to list all available templates.
19+
- **cli:** Added `--view-template <Template-Name>` command to view detailed information about a specific template.
1820

1921
### Bug Fixes
2022

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@involvex/create-wizard",
3-
"version": "4.0.0",
3+
"version": "4.0.1",
44
"description": "create everything with ease interactive ",
55
"keywords": [
66
"cli",

scripts/create-app.js

Lines changed: 48 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,17 @@ if (args.includes('-h') || args.includes('--help')) {
3030
Initializes a new project using an interactive wizard.
3131
3232
Arguments:
33-
projectName The name of the project to create. If provided, the wizard will skip the project name prompt.
33+
projectName The name of the project to create. If provided, the wizard will skip the project name prompt.
3434
3535
Options:
36-
-v, --version Output the current version and exit.
37-
-h, --help Display this help message and exit.
38-
--plugin Configure and install a new plugin (e.g., Prettier, ESLint).
39-
--create-test Set up a new test framework for the project.
40-
--license Generate a new LICENSE file.
41-
--debug=TRUE Enable debug logging.
36+
-v, --version Output the current version and exit.
37+
-h, --help Display this help message and exit.
38+
--plugin Configure and install a new plugin (e.g., Prettier, ESLint).
39+
--create-test Set up a new test framework for the project.
40+
--license Generate a new LICENSE file.
41+
--debug=TRUE Enable debug logging.
42+
--list-templates List all available deployment templates.
43+
--view-template <Template-Name> View more information about a specific template by name.
4244
`)
4345
process.exit(0)
4446
}
@@ -728,6 +730,45 @@ if (resolve(process.argv[1]) === resolve(fileURLToPath(import.meta.url))) {
728730
createTestSetup({
729731
/* dependencies */
730732
})
733+
} else if (userArgs.includes('--list-templates')) {
734+
const templatesPath = join(dirname(fileURLToPath(import.meta.url)), '..', 'template-library')
735+
const templates = _fs.readdirSync(templatesPath).filter(file => {
736+
const filePath = join(templatesPath, file)
737+
return _fs.statSync(filePath).isDirectory()
738+
})
739+
console.log('Available Templates:')
740+
templates.forEach(t => console.log(`- ${t}`))
741+
process.exit(0)
742+
} else if (userArgs.includes('--view-template')) {
743+
const templateNameIndex = userArgs.indexOf('--view-template') + 1
744+
const templateName = userArgs[templateNameIndex]
745+
746+
if (!templateName || templateName.startsWith('--')) {
747+
console.error('Error: Please provide a template name.')
748+
process.exit(1)
749+
}
750+
751+
const templatesPath = join(dirname(fileURLToPath(import.meta.url)), '..', 'template-library')
752+
const templateDir = join(templatesPath, templateName)
753+
754+
if (!_fs.existsSync(templateDir)) {
755+
console.error(`Error: Template '${templateName}' not found.`)
756+
process.exit(1)
757+
}
758+
759+
console.log(`Template: ${templateName}`)
760+
const templateJsonPath = join(templateDir, 'template.json')
761+
if (_fs.existsSync(templateJsonPath)) {
762+
const templateJson = JSON.parse(_fs.readFileSync(templateJsonPath, 'utf-8'))
763+
console.log('Configuration:', JSON.stringify(templateJson, null, 2))
764+
}
765+
766+
const readmePath = join(templateDir, 'README.md')
767+
if (_fs.existsSync(readmePath)) {
768+
console.log('\n--- README ---')
769+
console.log(_fs.readFileSync(readmePath, 'utf-8'))
770+
}
771+
process.exit(0)
731772
} else {
732773
// If no specific flags are provided by the user, run main
733774
main({})

0 commit comments

Comments
 (0)