app-factory-cli
v1.4.1
Published
CLI to generate applications from templates
Readme
app-factory-cli
A Node.js CLI that scaffolds new applications from your GitHub template repositories, runs each template’s initializer, creates a brand new GitHub repository (user or org), pushes the initial commit, and leaves you with a ready-to-work local repo.
Requirements
- Node.js 18+
gitinstalled and available on PATH- For GitHub repository creation:
- Option A: a GitHub token in
GITHUB_TOKEN - Option B: GitHub CLI (
gh) installed and already authenticated (gh auth login)
- Option A: a GitHub token in
For Go templates, you also need
goinstalled (forgo run ...).
Installation
Global install
npm i -g app-factory-cliVerify:
app-factory --helpProject-local install (works with npm only)
If you prefer not to install globally:
npm i -D app-factory-cliRun via npm:
npm exec -- app-factory --helpQuick start
Interactive wizard
Global:
app-factory createLocal (npm only):
npm exec -- app-factory createNon-interactive (flags)
app-factory create \
--template go-api-rest-template \
--name payments-api \
--owner UlisesNiSchreiner \
--visibility public \
--out ./payments-apiIf you want to create the repo inside an organization:
app-factory create \
--template node-api-rest-template \
--name billing-api \
--owner my-org \
--org \
--visibility privateSupported templates
go-api-rest-templatenode-api-rest-templatereact-ts-web-app-templatereact-next-ts-web-app-templatetypescript-lib-templatetemplate_gn_middleendtemplate_gn_web_clitemplate_gn_rn_cli
You can add/remove templates easily: see Adding templates below.
What the CLI does
- Prompts for (or reads flags):
- template
- app name
- owner (user/org)
- repo visibility
- output directory
- Downloads the template into the output directory (using
degit) - Runs the template initializer (per template)
- Initializes a new git repo locally, commits the generated code
- Creates a new GitHub repository via API
- Adds
origin, pushesmaster
Authentication
This CLI tries to authenticate with GitHub like this:
- If
GITHUB_TOKENis set, it uses it. - Else, if
ghis installed, it runsgh auth tokenand uses that token.
Recommended token permissions
Classic PAT (ghp_*)
reporead:org(often required for org operations)
Fine-grained PAT (githubpat*)
- Repository permissions:
- Administration: Read and write (create repo)
- Contents: Read and write (push)
If you create repos in orgs, ensure the token is allowed for that org (and SSO if applicable).
Commands
create
app-factory create [options]Options:
--template <name>: template key (one of the configured templates)--name <appName>: new application name (and GitHub repo name)--owner <owner>: GitHub username or org name--org: treat--owneras an organization (creates under org)--visibility <public|private>: repo visibility--out <path>: output directory (./<appName>relative to where you run the command)--skip-github: only scaffold locally, do not create remote repo--skip-init: do not run the init-template script--yes: skip confirmation prompts
Adding templates
Edit src/templates.ts.
Each template has:
key: the CLI identifierrepo: GitHubowner/repotech: used to select an init strategyinitializer: optional override
Example:
{
key: "kotlin-api-template",
repo: "UlisesNiSchreiner/kotlin-api-template",
tech: "kotlin",
}Then implement the initializer in src/core/init.ts (or add a new one).
How template initialization works
The CLI chooses an initializer based on tech:
node/react/typescript:- runs
npm install - then
npm run init-template <appName>
- runs
go:- runs
go run scripts/init-template.go github.com/<owner>/<repo>
- runs
kotlin/java:- not implemented yet (throws a clear error)
Local development
npm install
npm run dev -- createBuild:
npm run buildLicense
MIT
