Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
120 commits
Select commit Hold shift + click to select a range
4e98c39
first commit
pyramation Feb 28, 2018
2f3df76
remove bin
pyramation Feb 28, 2018
0133aa4
update tests, version bump
pyramation Feb 28, 2018
fa6a91c
readme
pyramation Feb 28, 2018
78edce1
readme
pyramation Feb 28, 2018
1670b8c
add npm install
pyramation Feb 28, 2018
dab03eb
update package
pyramation Jul 31, 2018
0e37ead
updated for filter function
pyramation Sep 24, 2018
b9ede69
Update readme.md
pyramation Mar 29, 2019
06bc4ce
Update readme.md
pyramation Mar 29, 2019
275efd8
first commit 📝
pyramation Apr 21, 2024
988db99
chore(release): publish
pyramation Apr 21, 2024
93ee9ca
checkbox
pyramation Apr 21, 2024
ff2a41e
key codes
pyramation Apr 21, 2024
6f2fe4c
autocomplete
pyramation Apr 21, 2024
e8fe766
scrolling
pyramation Apr 21, 2024
ddc64b4
colorize
pyramation Apr 21, 2024
fd18ab9
checkbox
pyramation Apr 21, 2024
8b50ef9
options
pyramation Apr 21, 2024
c85c831
opts
pyramation Apr 21, 2024
083084f
test with mocks
pyramation Apr 22, 2024
d20249f
test more events
pyramation Apr 22, 2024
b10ae84
autocomplete tests
pyramation Apr 22, 2024
05518ab
pkg
pyramation Apr 22, 2024
4170e05
pkg
pyramation Apr 22, 2024
27935b6
strip ansi for CI
pyramation Apr 22, 2024
022621c
inquirerer
pyramation Apr 22, 2024
4a28bd1
chore(release): publish
pyramation Apr 22, 2024
f8dab7d
type
pyramation Apr 22, 2024
e0e0688
pkg
pyramation Apr 22, 2024
a8472a9
chore(release): publish
pyramation Apr 22, 2024
e6fe13f
commander
pyramation Apr 22, 2024
c439f88
chore(release): publish
pyramation Apr 22, 2024
17439b7
commander and defaults
pyramation Apr 22, 2024
26c6d34
chore(release): publish
pyramation Apr 22, 2024
255a380
useDefaults
pyramation Apr 22, 2024
49eaa8d
chore(release): publish
pyramation Apr 22, 2024
4187ac0
useDefault
pyramation Apr 22, 2024
085d11b
chore(release): publish
pyramation Apr 22, 2024
19c0c92
defaults
pyramation Apr 22, 2024
622bb3b
index
pyramation Apr 22, 2024
3b4b7a1
chore(release): publish
pyramation Apr 22, 2024
bff3c4d
prompts and OptionValue[]
pyramation Apr 22, 2024
6c687ab
chore(release): publish
pyramation Apr 22, 2024
0a46466
prompt
pyramation Apr 22, 2024
b95bf2e
chore(release): publish
pyramation Apr 22, 2024
b405197
prompt
pyramation Apr 22, 2024
64d3b21
reorder
pyramation Apr 22, 2024
7acf30e
chore(release): publish
pyramation Apr 22, 2024
b1e14eb
fuzzy
pyramation Apr 22, 2024
b99717c
chore(release): publish
pyramation Apr 22, 2024
908300d
sanitize options
pyramation Apr 22, 2024
181e8fa
chore(release): publish
pyramation Apr 22, 2024
5178402
prompt
pyramation Apr 22, 2024
1f5c988
validations
pyramation Apr 22, 2024
9822897
usage
pyramation Apr 22, 2024
9393d09
chore(release): publish
pyramation Apr 22, 2024
cb1129b
defaults
pyramation Apr 22, 2024
df754ef
chore(release): publish
pyramation Apr 22, 2024
2e1881c
revert
pyramation Apr 22, 2024
fd80e23
chore(release): publish
pyramation Apr 22, 2024
e724a9a
cli
pyramation Apr 22, 2024
1c3d999
chore(release): publish
pyramation Apr 22, 2024
03f9d5f
noTty false
pyramation Apr 22, 2024
b782a9a
chore(release): publish
pyramation Apr 22, 2024
c9f278d
fixed fuzzy
pyramation Apr 22, 2024
6242063
chore(release): publish
pyramation Apr 22, 2024
56fa6a1
mutateArgs 🙏🏻
pyramation Apr 22, 2024
3944618
errors for nonsensical errors
pyramation Apr 22, 2024
7c0bfaa
chore(release): publish
pyramation Apr 22, 2024
a0eeecd
mutateArgs
pyramation Apr 22, 2024
25c70c8
chore(release): publish
pyramation Apr 22, 2024
451c13a
provided args used, not just defaults
pyramation Apr 24, 2024
273e730
chore(release): publish
pyramation Apr 24, 2024
8b841ea
handle overrides
pyramation Apr 24, 2024
b664b9a
chore(release): publish
pyramation Apr 24, 2024
8db8334
tty
pyramation Apr 30, 2024
9cda01f
chore(release): publish
pyramation Apr 30, 2024
4ebf045
add number
pyramation May 9, 2025
fb3f169
lerna
pyramation May 9, 2025
fd38ea8
lerna
pyramation May 9, 2025
8cd37ae
chore(release): publish
pyramation May 9, 2025
21b4c82
defaults for text/number
pyramation May 12, 2025
f4985e5
Defaults for checkbox
pyramation May 13, 2025
0161537
proper option values
pyramation May 13, 2025
aa6ac28
chore(release): publish
pyramation May 13, 2025
f6f0f50
handlers
pyramation May 13, 2025
b20090e
chore(release): publish
pyramation May 13, 2025
a1d5b4c
overrides coersion
pyramation May 13, 2025
09049ba
prompts
pyramation May 13, 2025
6aacc5c
comments
pyramation May 13, 2025
31272da
snap
pyramation May 13, 2025
fc307e6
test case
pyramation May 13, 2025
f98034d
chore(release): publish
pyramation May 13, 2025
1495040
keypress can be null
pyramation May 14, 2025
9f50b55
chore(release): publish
pyramation May 14, 2025
236da46
test prompt for overrides
pyramation May 14, 2025
fe5ce05
chore(release): publish
pyramation May 14, 2025
7eb4709
AllowCustomOptions
pyramation May 14, 2025
5302e9c
chore(release): publish
pyramation May 14, 2025
7169149
allowCustomOptions on list/autocomplete
pyramation May 14, 2025
e3b1d18
chore(release): publish
pyramation May 14, 2025
641ed48
Import inquirerer history into origin/
pyramation May 22, 2025
f502adc
saved
pyramation May 22, 2025
646165d
Merge pull request #1 from pyramation/feat/merge-history
pyramation May 22, 2025
2d42574
readme
pyramation May 22, 2025
7287f9c
chore(release): publish
pyramation May 22, 2025
9c77e90
when()
pyramation May 25, 2025
4758990
chore(release): publish
pyramation May 25, 2025
70221ca
lock
pyramation Nov 16, 2025
192eb9e
scaffold
pyramation Nov 16, 2025
bb0c24a
deps
pyramation Nov 16, 2025
228dce1
cga
pyramation Nov 16, 2025
695e1bf
ci
pyramation Nov 16, 2025
5ec77e0
Merge pull request #3 from pyramation/create-gen-app
pyramation Nov 16, 2025
e1b5c30
chore(release): publish
pyramation Nov 16, 2025
ae28783
Import inquirerer repository into inquirerer/
pyramation Nov 23, 2025
bc03c86
move inquirerer
pyramation Nov 23, 2025
c70f9e5
adding inquirerer
pyramation Nov 23, 2025
c4d9774
pkg
pyramation Nov 23, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ jobs:
- schema-typescript
- strfy-js
- yanse
- inquirerer
- create-gen-app

steps:
- name: Checkout code
Expand Down
8 changes: 8 additions & 0 deletions packages/create-gen-app/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Change Log

All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# 0.1.0 (2025-11-16)

**Note:** Version bump only for package create-gen-app
152 changes: 152 additions & 0 deletions packages/create-gen-app/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
# create-gen-app

<p align="center" width="100%">
<img height="90" src="https://user-images.githubusercontent.com/545047/190171475-b416f99e-2831-4786-9ba3-a7ff4d95b0d3.svg" />
</p>

<p align="center" width="100%">

<a href="https://github.com/hyperweb-io/dev-utils/actions/workflows/ci.yml">
<img height="20" src="https://github.com/hyperweb-io/dev-utils/actions/workflows/ci.yml/badge.svg" />
</a>
<a href="https://github.com/hyperweb-io/dev-utils/blob/main/LICENSE">
<img height="20" src="https://img.shields.io/badge/license-MIT-blue.svg"/>
</a>
<a href="https://www.npmjs.com/package/create-gen-app"><img height="20" src="https://img.shields.io/npm/dt/create-gen-app"></a>
<a href="https://www.npmjs.com/package/create-gen-app"><img height="20" src="https://img.shields.io/github/package-json/v/hyperweb-io/dev-utils?filename=packages%2Fcreate-gen-app%2Fpackage.json"></a>
</p>

A TypeScript library for cloning and customizing template repositories with variable replacement.

## Features

- Clone GitHub repositories or any git URL
- Extract template variables from filenames and file contents using `__VARIABLE__` syntax
- Load custom questions from `.questions.json` or `.questions.js` files
- Interactive prompts using inquirerer with CLI argument support
- Stream-based file processing for efficient variable replacement

## Installation

```bash
npm install create-gen-app
```

## Usage

### Basic Usage

```typescript
import { createGen } from 'create-gen-app';

await createGen({
templateUrl: 'https://github.com/user/template-repo',
outputDir: './my-new-project',
argv: {
PROJECT_NAME: 'my-project',
AUTHOR: 'John Doe'
}
});
```

### Template Variables

Variables in your template should be wrapped in double underscores:

**Filename variables:**
```
__PROJECT_NAME__/
__MODULE_NAME__.ts
```

**Content variables:**
```typescript
// __MODULE_NAME__.ts
export const projectName = "__PROJECT_NAME__";
export const author = "__AUTHOR__";
```

### Custom Questions

Create a `.questions.json` file in your template repository:

```json
{
"questions": [
{
"name": "PROJECT_NAME",
"type": "text",
"message": "What is your project name?",
"required": true
},
{
"name": "AUTHOR",
"type": "text",
"message": "Who is the author?"
}
]
}
```

Or use `.questions.js` for dynamic questions:

```javascript
/**
* @typedef {Object} Questions
* @property {Array} questions - Array of question objects
*/

module.exports = {
questions: [
{
name: 'PROJECT_NAME',
type: 'text',
message: 'What is your project name?',
required: true
}
]
};
```

## API

### `createGen(options: CreateGenOptions): Promise<string>`

Main function to create a project from a template.

**Options:**
- `templateUrl` (string): URL or path to the template repository
- `outputDir` (string): Destination directory for the generated project
- `argv` (Record<string, any>): Command-line arguments to pre-populate answers
- `noTty` (boolean): Whether to disable TTY mode for non-interactive usage

### `extractVariables(templateDir: string): Promise<ExtractedVariables>`

Extract all variables from a template directory.

### `promptUser(extractedVariables: ExtractedVariables, argv?: Record<string, any>, noTty?: boolean): Promise<Record<string, any>>`

Prompt the user for variable values using inquirerer.

### `replaceVariables(templateDir: string, outputDir: string, extractedVariables: ExtractedVariables, answers: Record<string, any>): Promise<void>`

Replace variables in all files and filenames.

## Variable Naming Rules

Variables can contain:
- Letters (a-z, A-Z)
- Numbers (0-9)
- Underscores (_)
- Must start with a letter or underscore

Examples of valid variables:
- `__PROJECT_NAME__`
- `__author__`
- `__CamelCase__`
- `__snake_case__`
- `__VERSION_1__`

## License

MIT
Loading
Loading