Skip to content

feat: introduce v1 modern TypeScript + ESM CLI#130

Draft
Copilot wants to merge 7 commits intomainfrom
copilot/introduce-v1-typescript-esm-cli
Draft

feat: introduce v1 modern TypeScript + ESM CLI#130
Copilot wants to merge 7 commits intomainfrom
copilot/introduce-v1-typescript-esm-cli

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 26, 2026

Replaces the old JSON-config-driven generator with a modern, interactive CLI built on TypeScript + ESM (Node ≥ 20.9.0). Ignores legacy swaaplate.json logic entirely.

New CLI architecture

  • src/cli/index.ts — entry point with #!/usr/bin/env node shebang; bin maps swaaplatedist/cli/index.js
  • src/cli/init.tsswaaplate init [name] command; interactive (@inquirer/prompts select/input) and non-interactive via flags
  • src/cli/types.ts — shared Preset, PackageManager, InitOptions types
  • tsconfig.jsonmodule/moduleResolution: NodeNext, targets src/cli/** only (excludes legacy template .ts stubs)

swaaplate init flags

Flag Values Default
--preset preset-angular-only | preset-angular-java | preset-angular-php prompted
--pm pnpm | npm | yarn pnpm
--yes / -y false
--force / -f false

What each preset generates

<name>/
├── apps/
│   ├── frontend/        # via npx @angular/cli@latest new (--skip-git --skip-tests)
│   └── backend/         # java: README.md skeleton | php: public/index.php + README.md
├── package.json         # workspaces: ["apps/*"]
├── pnpm-workspace.yaml  # only when pm=pnpm
└── README.md

Package changes

  • package.json: "type": "module", new bin/scripts/dependencies/devDependencies, version bumped to 3.0.0-SNAPSHOT
  • Migrated from yarn to npm; yarn.lock removed, package-lock.json added
  • Runtime deps: commander, @inquirer/prompts, execa, fs-extra
  • Dev deps: typescript, tsx, @types/node, @types/fs-extra
Original prompt

Create a PR for repository inpercima/swaaplate that introduces a v1 modern TypeScript + ESM CLI.

Context:

  • Current project is an older Node CLI (swaaplate.js) that reads a swaaplate.json configuration and uses internal modules under src/js/**.
  • For this new v1, we will ignore the old JSON-based generator logic and introduce a new CLI architecture.
  • Must support Windows/macOS/Linux.

Requirements (v1):

  1. Implement a new CLI written in TypeScript using ESM:

    • Use Node >= 20.9.0.
    • Use ESM via "type": "module" and TypeScript module/moduleResolution set to NodeNext.
    • Build output goes to dist/.
    • Provide an executable entry point with a shebang in the built CLI.
  2. CLI commands:

    • swaaplate init [name]
    • Interactive prompts similar to modern CLIs (Angular CLI-style), using a prompt library.
    • Also support non-interactive flags:
      • --preset <preset> where preset is one of:
        • preset-angular-only
        • preset-angular-java
        • preset-angular-php
      • --pm <pm> where pm is one of pnpm|npm|yarn (default should be pnpm if not provided)
      • --yes to skip prompts where possible
      • --force to overwrite existing non-empty target directory
  3. Output project structure (monorepo):

    • Create a monorepo folder named [name] (or prompt for it).
    • Create apps/ subfolder.
    • Create Angular frontend under apps/frontend using official Angular CLI via npx -y @angular/cli@latest new ....
      • Must be cross-platform (no bash scripts).
      • Must avoid creating a git repo inside frontend (skip git).
      • Keep tests skipped for speed in v1.
      • Ensure directory is apps/frontend.
    • For backend:
      • preset-angular-only: no backend.
      • preset-angular-java: create apps/backend/README.md placeholder (skeleton). Do not yet integrate Spring Boot initializr.
      • preset-angular-php: create apps/backend/public/index.php that returns JSON and a README.md.
  4. Root workspace setup:

    • Create minimal root package.json in the generated monorepo enabling workspaces for apps/* and add a convenience script to run the frontend.
    • Prefer a simple, compatible approach; if pnpm is selected, optionally add pnpm-workspace.yaml.
  5. Repository changes:

    • Add new TS sources under src/cli/** (or similar) and necessary config files (tsconfig.json).
    • Update the repository root package.json to include:
      • type: module
      • bin entry for swaaplate -> dist/cli/index.js
      • scripts: build, dev, start
      • dependencies for the CLI (commander, @inquirer/prompts, execa, fs-extra)
      • devDependencies: typescript, tsx
    • Keep existing legacy files in place for now (do not delete old generator), but the new CLI should be the primary entry for bin.
  6. Documentation:

    • Update README.md with new usage examples for swaaplate init and presets.

Acceptance criteria:

  • npm run build produces dist/cli/index.js.
  • Running node dist/cli/index.js init test-app --preset preset-angular-only --pm pnpm --yes generates the monorepo with Angular frontend.
  • Interactive mode works when running npm run dev -- init or equivalent.
  • Works on Windows/macOS/Linux by relying on Node APIs + cross-platform process spawning.

Notes:

  • Do not rely on the old swaaplate.json configuration.
  • Default package manager should be pnpm.

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: Das ist ein sehr altes Projekt, womit ich vor hatte, einen einfachen Generator zu haben für Apps, die ich oft baue. Leider konnte ich das nicht damals weiterführen, würde es jetzt aber angehen.

Ich möchte also eine console app, mit der ich sagen kann:

  • ich arbeite im frontend mit: Angular, oder plain html
  • ich nutze im backend: java, php, nestjs usw.
  • ich möchte spring boot oder nicht
  • ich habe pnpm, npm, yarn oder was auch immer
  • ich möchte tailwind oder bootstrap, angular-material usw.

das mit einer sehr coolen consolen anwendungen und ggf. templates.

Wie würde ich das heuzutage angehen oder gibts das schon enau für meinen geschmack?

Assistant: Am sinnvollsten würdest du das heute als „Opinionated App Generator“ angehen – also ein CLI, das deine wiederkehrenden Entscheidungen (Angular vs. plain, Nest vs. Java, pnpm vs. npm, Tailwind vs. Bootstrap/Material, optional Spring Boot) in vordefinierte Presets + Templates gießt und dann reproduzierbar ein Projekt ausspuckt.

1) Gibt’s das schon „genau so“?

Es gibt viele Generatoren, aber meist nicht in genau der Kombi und Opinionated-Form, die du beschreibst:

  • Frontend-CLIs: Angular CLI etc. (super, aber nur Frontend-lastig)
  • Backend-CLIs: Nest CLI, Spring Initializr (super, aber nur Backend-lastig)
  • Fullstack-Generatoren: teils sehr „Framework-first“ (z. B. immer React/Next o. ä.) oder zu unflexibel für deine Matrix aus Optionen.
  • Monorepo-Tools (Nx, Tu...

This pull request was created from Copilot chat.


📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.

Co-authored-by: inpercima <10551931+inpercima@users.noreply.github.com>
Agent-Logs-Url: https://github.com/inpercima/swaaplate/sessions/3b10058e-1b0b-46ae-a9c5-c610386eaf75
Copilot AI changed the title [WIP] Add v1 modern TypeScript + ESM CLI implementation feat: introduce v1 modern TypeScript + ESM CLI Mar 26, 2026
Copilot AI requested a review from inpercima March 26, 2026 15:00
@inpercima inpercima force-pushed the copilot/introduce-v1-typescript-esm-cli branch 2 times, most recently from e1544aa to 49268ec Compare March 30, 2026 07:03
@inpercima inpercima force-pushed the copilot/introduce-v1-typescript-esm-cli branch from 49268ec to 1954182 Compare March 30, 2026 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants