`@push-based/create-ngp`: scaffold an Angular app on vite-plugin-ngp, for `vp create @push-based/ngp` and `npm create @push-based/ngp`

Aperta
#14 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
angular, node.js, typescript, vite

Direzione di ricerca

Read the Getting started and Testing pages, the Server rendering page, and packages/vite-plugin-ngp/package.json plus toolchain/versions.env for the template details and pinned versions. Start by checking the create-vite argument and scaffold patterns, then build both templates under packages/create-ngp/templates/ and add the listed unit and integration coverage. Done means each template scaffolds successfully and the specified build, test, SSR, and available Vite+ checks pass.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

feature

Part of #13. Labels: feature.

What a user does

vp create @push-based/ngp my-app          # Vite+
npm create @push-based/ngp@latest my-app  # npm
pnpm create @push-based/ngp my-app        # pnpm

Then cd my-app and vp dev (or pnpm dev). The app is the one Getting started describes, generated instead of typed.

Behaviour

Arguments and flags (parse with mri, like create-vite):

[directory] Target. Prompted ("Project name:", default ngp-app) when absent and interactive
-t, --template <app|app-ssr> Template. Prompted when absent and interactive. Default app when non-interactive
--overwrite Empty a non-empty target without asking. Without it, interactive asks; non-interactive aborts
--interactive / --no-interactive Default process.stdin.isTTY
-h, --help

No --immediate, no git init, no install. Vite+ does install, git, hooks and formatting itself after the template exits, and a second git init is what create-analog gets wrong. Print "Done. Now run:" with cd, <pm> install, <pm> dev, where <pm> comes from npm_config_user_agent. Under vp the install line is harmless because vp installs right after.

Remember that vp does not prepend the target directory and does not forward --no-interactive; vp create @push-based/ngp -- --no-interactive --template app is the unattended form, and the docs show it.

Templates, as packages/create-ngp/templates/<name>/, copied file by file, with _gitignore → .gitignore, package.json#name set to the valid package name derived from the directory, and <title> in index.html replaced. Nothing else is templated: no placeholders, no engine.

  • app: index.html, vite.config.ts (defineConfig from vite, ngp() with no options), tsconfig.json + tsconfig.app.json + tsconfig.spec.json as ng new writes them, src/main.ts, src/app/app.ts + app.html + app.css, app.config.ts with provideRouter, routes.ts with one route, src/styles.css, src/app/app.spec.ts, src/test-setup.ts, vitest.config.ts per the Testing page, public/favicon.svg, README.md, _gitignore. package.json scripts: dev, build, preview, test. Dependencies: the exact pins from Getting started (@angular/* at the plugin's pinned version, typescript 6.0.3, vite 8.3.4, vitest, jsdom, the plugin at the version released alongside).
  • app-ssr: app plus src/main.server.ts (the Server rendering page's entry, allowedHosts: ['localhost']), provideClientHydration(withEventReplay()) in app.config.ts, ngp({ssr: true}), server.mjs copied from the playground, and a start script.

The pinned versions come from one place: a versions.json that the build writes from packages/vite-plugin-ngp/package.json and toolchain/versions.env, so a plugin release can't ship a template pinned to an older Angular.

Vite+ handling. The output is a plain Vite project. vite is in devDependencies so that vp's post-create rewrite aliases it to @voidzero-dev/vite-plus-core; without that line the plugin can't load under vp (see the epic). Verify in a test that after vp create @push-based/ngp, vp build, vp test run and vp check --fix && vp check all pass. If vp's injected fmt: {} formats Angular sources to double quotes, add fmt: {singleQuote: true} to the template config; vp keeps a template's own fmt/lint keys.

Tests

  • Unit: argument parsing, package-name derivation, overwrite rules, the rename map.
  • Integration (node --test, like the plugin): scaffold each template into a temp dir, pnpm install with the workspace plugin linked, vite build, vitest run. For app-ssr, also node server.mjs and fetch /.
  • Under Vite+: the same, through vp create ./packages/create-ngp -- --no-interactive, when vp is on PATH; skipped otherwise. CI installs vite-plus in that job.

Docs

Covered by the docs sub-issue; this issue is done when the package scaffolds both templates and the tests above pass.

Out of scope

Tailwind, Angular Material, i18n, Nx workspaces, --immediate, an ng new-compatible flag set.

Lingua principale
TypeScript
Stelle
7
Fork
0
Merge medio
12h 24m
PR unite (30g)
13

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di push-based/vite-plugin-ngp

Tutte le issue di push-based/vite-plugin-ngp

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.