create-awesome-node-app 0.6.5 → 0.6.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +249 -46
- package/dist/chunk-KDVE4P46.js +124 -0
- package/dist/chunk-KDVE4P46.js.map +1 -0
- package/dist/chunk-SIARO2CH.js +123 -0
- package/dist/index.cjs +43 -21
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +38 -135
- package/dist/index.js.map +1 -0
- package/dist/templates.cjs +126 -0
- package/dist/templates.cjs.map +1 -0
- package/dist/templates.d.cts +40 -0
- package/dist/templates.d.ts +40 -0
- package/dist/templates.js +13 -0
- package/dist/templates.js.map +1 -0
- package/package.json +10 -7
package/README.md
CHANGED
|
@@ -3,97 +3,300 @@
|
|
|
3
3
|
<div align="center">
|
|
4
4
|
<h1>🌟 Create Awesome Node App 🚀</h1>
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
<!-- NPM Preview: Keep this block ultra concise (first ~5 lines shown on npm) -->
|
|
7
|
+
|
|
8
|
+
<strong>Bootstrap production‑grade Node / Web / Full‑Stack / Monorepo / Extension apps in minutes.</strong><br/>
|
|
9
|
+
<em>Pick a template → Add addons → Ship faster.</em>
|
|
10
|
+
|
|
8
11
|
[![npm][npmversion]][npmurl]
|
|
9
|
-
[![
|
|
12
|
+
[![Downloads][npmdownloads]][npmurl]
|
|
13
|
+
[![Commit Activity][commitactivitybadge]][commitactivityurl]
|
|
14
|
+
[![Bundle Size][bundlesizebadge]][bundlesizeurl]
|
|
15
|
+
[](https://github.com/vitejs/awesome-vite#get-started)
|
|
10
16
|
[![License: MIT][licensebadge]][licenseurl]
|
|
11
17
|
|
|
12
|
-
|
|
18
|
+
<!-- Extended badges (not all needed in npm fold) -->
|
|
13
19
|
|
|
14
|
-
|
|
20
|
+
[![Tests][testsbadge]][testsurl]
|
|
21
|
+
[![Lint][lintbadge]][linturl]
|
|
22
|
+
[![Typecheck][typecheckbadge]][typecheckurl]
|
|
23
|
+
[![Shellcheck][shellcheckbadge]][shellcheckurl]
|
|
24
|
+
[![Markdown][markdownlintbadge]][markdownlinturl]
|
|
25
|
+
<br />
|
|
26
|
+
<a href="https://create-awesome-node-app.vercel.app" target="_blank"><b>Official Site</b></a> ·
|
|
27
|
+
<a href="https://create-awesome-node-app.vercel.app/templates" target="_blank">Templates</a> ·
|
|
28
|
+
<a href="https://create-awesome-node-app.vercel.app/extensions" target="_blank">Extensions</a> ·
|
|
29
|
+
<a href="https://create-awesome-node-app.vercel.app/docs" target="_blank">Docs</a>
|
|
15
30
|
|
|
16
|
-
|
|
31
|
+
</div>
|
|
17
32
|
|
|
18
|
-
|
|
33
|
+
> Build. Extend. Ship. Pick a production‑grade template, layer powerful addons, and get a project that follows modern conventions, automation, and DX best practices out of the box.
|
|
19
34
|
|
|
20
|
-
|
|
35
|
+
<details>
|
|
36
|
+
<summary><strong>TL;DR (60s)</strong></summary>
|
|
21
37
|
|
|
22
|
-
|
|
38
|
+
```bash
|
|
39
|
+
# Interactive (recommended)
|
|
40
|
+
npm create awesome-node-app@latest my-app -- --interactive
|
|
23
41
|
|
|
24
|
-
|
|
25
|
-
|
|
42
|
+
# Direct + addons
|
|
43
|
+
npx create-awesome-node-app my-app \
|
|
44
|
+
--template react-vite-boilerplate \
|
|
45
|
+
--addons material-ui github-setup
|
|
26
46
|
```
|
|
27
47
|
|
|
28
|
-
|
|
48
|
+
What you get: Modern structure, linting, TS, testing, optional AI `AGENTS.md`, extensible addons, monorepo & full‑stack ready.
|
|
49
|
+
|
|
50
|
+
</details>
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## ✨ Why Create Awesome Node App?
|
|
55
|
+
|
|
56
|
+
`create-awesome-node-app` (CNA) is a batteries‑included scaffolding CLI that lets you:
|
|
57
|
+
|
|
58
|
+
- 🔌 Mix & match **templates + addons** (React, Next.js, NestJS, Turborepo, Web Extensions, UAT, Monorepos, and more)
|
|
59
|
+
- 🧩 Add **extensions** (UI libraries, GitHub setup, auth, testing, tooling) at creation time
|
|
60
|
+
- 🧪 Ship with **testing & linting** pre‑wired (ESLint, TypeScript, formatting, markdown lint, shellcheck, etc.)
|
|
61
|
+
- 🧭 Use **interactive mode** to discover categories, templates, and compatible addons
|
|
62
|
+
- 🚀 Start fast with **production‑ready structure** and opinionated defaults
|
|
63
|
+
- 🤖 Get an automatic **`AGENTS.md` contract** in supported templates for AI assistant alignment
|
|
64
|
+
- 🌐 Pull **remote templates / extensions by URL** – bring your own blueprints
|
|
65
|
+
- 🧵 Keep everything **Node 22 ready** and future‑proof
|
|
66
|
+
|
|
67
|
+
> On the Awesome List? ✅ Yes – we proudly display the [Awesome Vite Mention](https://github.com/vitejs/awesome-vite#get-started).
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## 🔗 Official Site
|
|
72
|
+
|
|
73
|
+
Explore visually: **[create-awesome-node-app.vercel.app](https://create-awesome-node-app.vercel.app)**
|
|
74
|
+
|
|
75
|
+
- Browse all templates & categories
|
|
76
|
+
- Filter by stack type (frontend, backend, full‑stack, monorepo, web extension, UAT, etc.)
|
|
77
|
+
- Discover extensions to enrich your base
|
|
78
|
+
- Learn how the generation pipeline works
|
|
79
|
+
|
|
80
|
+
---
|
|
29
81
|
|
|
30
|
-
|
|
82
|
+
## 🚀 Quick Start
|
|
31
83
|
|
|
32
|
-
|
|
84
|
+
Use via one‑shot runner (recommended – always latest):
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
npm create awesome-node-app@latest my-app -- --interactive
|
|
88
|
+
# or
|
|
89
|
+
pnpm create awesome-node-app my-app --interactive
|
|
90
|
+
# or
|
|
91
|
+
yarn create awesome-node-app my-app --interactive
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Global install (optional):
|
|
95
|
+
|
|
96
|
+
```bash
|
|
33
97
|
npm install -g create-awesome-node-app
|
|
98
|
+
create-awesome-node-app my-app --template react-vite-boilerplate --addons material-ui github-setup
|
|
34
99
|
```
|
|
35
100
|
|
|
36
|
-
|
|
101
|
+
Minimal non‑interactive example:
|
|
37
102
|
|
|
38
|
-
|
|
103
|
+
```bash
|
|
104
|
+
npx create-awesome-node-app my-api \
|
|
105
|
+
--template nestjs-boilerplate \
|
|
106
|
+
--addons github-setup commitlint prettier
|
|
107
|
+
```
|
|
39
108
|
|
|
40
|
-
|
|
109
|
+
---
|
|
41
110
|
|
|
42
|
-
|
|
111
|
+
## 🧪 Interactive Mode Walkthrough
|
|
43
112
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
113
|
+
Launch with `--interactive` to:
|
|
114
|
+
|
|
115
|
+
1. Pick a category (Frontend, Backend, Full Stack, Monorepo, Web Extension, UAT...)
|
|
116
|
+
2. Select a template with description & keywords
|
|
117
|
+
3. Choose compatible extensions grouped by purpose
|
|
118
|
+
4. Optionally extend with custom URLs
|
|
119
|
+
|
|
120
|
+
The CLI builds a tailored `templatesOrExtensions` pipeline and generates the workspace accordingly.
|
|
121
|
+
|
|
122
|
+
---
|
|
47
123
|
|
|
48
|
-
|
|
124
|
+
## 🧱 Template Ecosystem (Highlights)
|
|
49
125
|
|
|
50
|
-
|
|
51
|
-
|
|
126
|
+
| Category | Example Templates |
|
|
127
|
+
| ------------- | ------------------------------------------------- |
|
|
128
|
+
| Frontend | React Vite Boilerplate, Vue (via community), etc. |
|
|
129
|
+
| Backend | NestJS Boilerplate, Express variants |
|
|
130
|
+
| Full Stack | NextJS Starter (SSR + TS + ESLint + Prettier) |
|
|
131
|
+
| Monorepo | Turborepo Boilerplate (TypeScript + Changesets) |
|
|
132
|
+
| Web Extension | Cross‑browser modern extension bases |
|
|
133
|
+
| UAT / Testing | Playwright / Cypress ready setups |
|
|
134
|
+
|
|
135
|
+
Full catalog: <https://create-awesome-node-app.vercel.app/templates>
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## 🧩 Addons / Extensions
|
|
140
|
+
|
|
141
|
+
Enhance your template with modular capabilities (examples):
|
|
142
|
+
|
|
143
|
+
- UI: Material UI, Tailwind, component libraries
|
|
144
|
+
- State / Data: jotai, tRPC, React Query
|
|
145
|
+
- Tooling: GitHub workflows, commit linting, changesets, release automation
|
|
146
|
+
- Quality: ESLint configs, Prettier, TypeScript strictness
|
|
147
|
+
- Testing: Playwright / Cypress scaffolds, vitest
|
|
148
|
+
- DX: Environment setup, conventional commits, docs helpers
|
|
149
|
+
|
|
150
|
+
List what’s available:
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
create-awesome-node-app --list-templates
|
|
154
|
+
create-awesome-node-app --list-addons
|
|
155
|
+
# Filter addons compatible with a template
|
|
156
|
+
create-awesome-node-app --template react-vite-boilerplate --list-addons
|
|
52
157
|
```
|
|
53
158
|
|
|
54
|
-
|
|
159
|
+
Add any extra extension by URL:
|
|
55
160
|
|
|
56
|
-
```
|
|
57
|
-
|
|
161
|
+
```bash
|
|
162
|
+
create-awesome-node-app my-app \
|
|
163
|
+
--template react-vite-boilerplate \
|
|
164
|
+
--addons material-ui github-setup \
|
|
165
|
+
--extend https://github.com/your-org/your-extension
|
|
58
166
|
```
|
|
59
167
|
|
|
60
|
-
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
## 🤖 AGENTS.md: Built-in AI Assistant Contract
|
|
171
|
+
|
|
172
|
+
Many templates ship with an auto‑generated `AGENTS.md` – a structured guide for AI coding assistants to understand project intent, conventions, and constraints. This improves code suggestion relevance and onboarding speed for hybrid human+AI teams.
|
|
61
173
|
|
|
62
|
-
|
|
174
|
+
Learn more: <https://create-awesome-node-app.vercel.app/docs/agents-md>
|
|
63
175
|
|
|
64
|
-
|
|
65
|
-
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## ⚙️ Requirements
|
|
179
|
+
|
|
180
|
+
- **Node.js ≥ 22** (enforced via engine check)
|
|
181
|
+
- Any of: npm / yarn / pnpm
|
|
182
|
+
|
|
183
|
+
We recommend fast version switching with [`fnm`](https://github.com/Schniz/fnm):
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
fnm use 22
|
|
66
187
|
```
|
|
67
188
|
|
|
68
|
-
|
|
189
|
+
---
|
|
69
190
|
|
|
70
|
-
|
|
191
|
+
## 🔍 CLI Options (Core)
|
|
71
192
|
|
|
72
|
-
|
|
193
|
+
| Flag | Description |
|
|
194
|
+
| --------------------------- | ---------------------------------------------- |
|
|
195
|
+
| `--interactive` | Guided selection flow (templates + addons) |
|
|
196
|
+
| `--template <slug\|url>` | Use a known template slug or remote URL |
|
|
197
|
+
| `--addons [list...]` | Space‑separated addon slugs or URLs |
|
|
198
|
+
| `--extend [list...]` | Extra extension URLs (advanced) |
|
|
199
|
+
| `--no-install` | Skip dependency installation |
|
|
200
|
+
| `--use-yarn` / `--use-pnpm` | Force package manager |
|
|
201
|
+
| `--list-templates` | Print templates grouped by category |
|
|
202
|
+
| `--list-addons` | Print addons (optionally filtered by template) |
|
|
203
|
+
| `--verbose` | Output resolved generation config |
|
|
204
|
+
| `--info` | Print environment diagnostics |
|
|
73
205
|
|
|
74
|
-
|
|
75
|
-
# List all available templates
|
|
76
|
-
create-awesome-node-app --list-templates
|
|
206
|
+
---
|
|
77
207
|
|
|
78
|
-
|
|
79
|
-
create-awesome-node-app --list-addons
|
|
208
|
+
## 🛠 Programmatic Usage (Experimental)
|
|
80
209
|
|
|
81
|
-
|
|
82
|
-
|
|
210
|
+
You can import helpers from the core package for custom tooling:
|
|
211
|
+
|
|
212
|
+
```ts
|
|
213
|
+
import { createNodeApp, getTemplateDirPath } from "@create-node-app/core";
|
|
83
214
|
```
|
|
84
215
|
|
|
85
|
-
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
## 🧪 Quality & Toolchain
|
|
219
|
+
|
|
220
|
+
Every generated project leans on modern, maintainable defaults:
|
|
221
|
+
|
|
222
|
+
- TypeScript strict mode
|
|
223
|
+
- ESLint (framework‑specific presets + consistency rules)
|
|
224
|
+
- Prettier formatting (where applicable)
|
|
225
|
+
- Testing support (varies by template: vitest, jest, e2e tooling)
|
|
226
|
+
- GitHub Actions friendly
|
|
227
|
+
- Conventional structure for CI/CD & release automation
|
|
228
|
+
|
|
229
|
+
---
|
|
230
|
+
|
|
231
|
+
## ❓ FAQ
|
|
86
232
|
|
|
87
|
-
|
|
233
|
+
**Why another scaffolder?**
|
|
234
|
+
Because most CLIs lock you into one stack. CNA lets you compose _your_ stack from curated templates + pluggable extensions.
|
|
235
|
+
|
|
236
|
+
**Can I bring my own template?**
|
|
237
|
+
Yes – pass a GitHub (or any) URL pointing to a repository (optionally with subdirectory path) via `--template`.
|
|
238
|
+
|
|
239
|
+
**Are addons order‑sensitive?**
|
|
240
|
+
They’re applied sequentially; conflicting changes should be resolved by your VCS if you customize heavily.
|
|
241
|
+
|
|
242
|
+
**Does it support monorepos?**
|
|
243
|
+
Yes. The Turborepo boilerplate + addons give you multi‑package orchestration fast.
|
|
244
|
+
|
|
245
|
+
**What about AI integration?**
|
|
246
|
+
`AGENTS.md` provides a structured spec for AI tools to align with your conventions.
|
|
247
|
+
|
|
248
|
+
**Is Node 22 required?**
|
|
249
|
+
Yes – we target the latest stable modern runtime for performance & language features.
|
|
250
|
+
|
|
251
|
+
---
|
|
252
|
+
|
|
253
|
+
## 🤝 Contributing
|
|
254
|
+
|
|
255
|
+
We welcome templates, addons, fixes, and ideas! See the root repository guidelines: <https://github.com/Create-Node-App/create-node-app/blob/main/CONTRIBUTING.md>
|
|
256
|
+
|
|
257
|
+
For template & extension data visit: <https://github.com/Create-Node-App/cna-templates>
|
|
258
|
+
|
|
259
|
+
---
|
|
260
|
+
|
|
261
|
+
## Roadmap (Short List)
|
|
262
|
+
|
|
263
|
+
- More framework integrations (Remix, SvelteKit variants)
|
|
264
|
+
- Additional testing packs (contract / performance harnesses)
|
|
265
|
+
- Rich analytics for generation metrics
|
|
266
|
+
- Template version pinning & diff upgrade paths
|
|
267
|
+
|
|
268
|
+
Follow progress in Issues & Discussions.
|
|
269
|
+
|
|
270
|
+
---
|
|
88
271
|
|
|
89
272
|
## 📜 License
|
|
90
273
|
|
|
91
|
-
|
|
274
|
+
MIT © Create Node App Contributors – see [LICENSE][licenseurl]
|
|
275
|
+
|
|
276
|
+
---
|
|
277
|
+
|
|
278
|
+
<div align="center">
|
|
279
|
+
<sub>Built with ♥ for developers who value velocity + clarity.</sub>
|
|
280
|
+
<br />
|
|
281
|
+
<sub><em>Spanish translation coming soon – ¿lo querés antes? Abrí un issue.</em></sub>
|
|
282
|
+
</div>
|
|
92
283
|
|
|
93
|
-
[
|
|
284
|
+
[testsbadge]: https://github.com/Create-Node-App/create-node-app/actions/workflows/test.yml/badge.svg
|
|
285
|
+
[lintbadge]: https://github.com/Create-Node-App/create-node-app/actions/workflows/lint.yml/badge.svg
|
|
286
|
+
[typecheckbadge]: https://github.com/Create-Node-App/create-node-app/actions/workflows/type-check.yml/badge.svg
|
|
287
|
+
[shellcheckbadge]: https://github.com/Create-Node-App/create-node-app/actions/workflows/shellcheck.yml/badge.svg
|
|
288
|
+
[markdownlintbadge]: https://github.com/Create-Node-App/create-node-app/actions/workflows/markdownlint.yml/badge.svg
|
|
94
289
|
[npmversion]: https://img.shields.io/npm/v/create-awesome-node-app.svg?maxAge=2592000?style=plastic
|
|
95
290
|
[npmdownloads]: https://img.shields.io/npm/dm/create-awesome-node-app.svg?maxAge=2592000?style=plastic
|
|
96
291
|
[licensebadge]: https://img.shields.io/badge/License-MIT-blue.svg
|
|
97
|
-
[
|
|
292
|
+
[testsurl]: https://github.com/Create-Node-App/create-node-app/actions/workflows/test.yml
|
|
293
|
+
[linturl]: https://github.com/Create-Node-App/create-node-app/actions/workflows/lint.yml
|
|
294
|
+
[typecheckurl]: https://github.com/Create-Node-App/create-node-app/actions/workflows/type-check.yml
|
|
295
|
+
[shellcheckurl]: https://github.com/Create-Node-App/create-node-app/actions/workflows/shellcheck.yml
|
|
296
|
+
[markdownlinturl]: https://github.com/Create-Node-App/create-node-app/actions/workflows/markdownlint.yml
|
|
98
297
|
[npmurl]: https://www.npmjs.com/package/create-awesome-node-app
|
|
99
298
|
[licenseurl]: https://github.com/Create-Node-App/create-node-app/blob/main/LICENSE
|
|
299
|
+
[commitactivitybadge]: https://img.shields.io/github/commit-activity/m/Create-Node-App/create-node-app?logo=github&label=commits
|
|
300
|
+
[commitactivityurl]: https://github.com/Create-Node-App/create-node-app/pulse
|
|
301
|
+
[bundlesizebadge]: https://img.shields.io/bundlephobia/minzip/create-awesome-node-app?label=bundlephobia
|
|
302
|
+
[bundlesizeurl]: https://bundlephobia.com/package/create-awesome-node-app
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
8
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
9
|
+
}) : x)(function(x) {
|
|
10
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
11
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
12
|
+
});
|
|
13
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
14
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
15
|
+
};
|
|
16
|
+
var __copyProps = (to, from, except, desc) => {
|
|
17
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
18
|
+
for (let key of __getOwnPropNames(from))
|
|
19
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
20
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
24
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
25
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
26
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
27
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
28
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
29
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
30
|
+
mod
|
|
31
|
+
));
|
|
32
|
+
|
|
33
|
+
// src/templates.ts
|
|
34
|
+
import axios from "axios";
|
|
35
|
+
var TEMPLATE_DATA_FILE_URL = "https://raw.githubusercontent.com/Create-Node-App/cna-templates/main/templates.json";
|
|
36
|
+
var CACHE_TTL_MS = 36e5;
|
|
37
|
+
var templateDataCache = {
|
|
38
|
+
data: null,
|
|
39
|
+
timestamp: 0
|
|
40
|
+
};
|
|
41
|
+
var fetchTemplateData = async () => {
|
|
42
|
+
try {
|
|
43
|
+
const response = await axios.get(TEMPLATE_DATA_FILE_URL);
|
|
44
|
+
return response.data;
|
|
45
|
+
} catch {
|
|
46
|
+
throw new Error("Failed to fetch template data");
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var getTemplateData = async () => {
|
|
50
|
+
const currentTime = Date.now();
|
|
51
|
+
if (templateDataCache.data === null || currentTime - templateDataCache.timestamp > CACHE_TTL_MS) {
|
|
52
|
+
templateDataCache.data = await fetchTemplateData();
|
|
53
|
+
templateDataCache.timestamp = currentTime;
|
|
54
|
+
}
|
|
55
|
+
return templateDataCache.data;
|
|
56
|
+
};
|
|
57
|
+
var getTemplateCategories = async (cliArgs) => {
|
|
58
|
+
if (cliArgs?.category) {
|
|
59
|
+
return [cliArgs.category];
|
|
60
|
+
}
|
|
61
|
+
const templateData = await getTemplateData();
|
|
62
|
+
if (templateData.categories && templateData.categories.length > 0) {
|
|
63
|
+
return templateData.categories.map((category) => category.slug);
|
|
64
|
+
}
|
|
65
|
+
const categories = /* @__PURE__ */ new Set();
|
|
66
|
+
templateData.templates.forEach((template) => {
|
|
67
|
+
categories.add(template.category);
|
|
68
|
+
});
|
|
69
|
+
return Array.from(categories);
|
|
70
|
+
};
|
|
71
|
+
var getCategoryData = async (categorySlug) => {
|
|
72
|
+
const templateData = await getTemplateData();
|
|
73
|
+
if (templateData.categories && templateData.categories.length > 0) {
|
|
74
|
+
return templateData.categories.find(
|
|
75
|
+
(category) => category.slug === categorySlug
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
return void 0;
|
|
79
|
+
};
|
|
80
|
+
var getTemplatesForCategory = async (category, cliArgs) => {
|
|
81
|
+
const selectedCategory = cliArgs?.category || category;
|
|
82
|
+
if (!selectedCategory) {
|
|
83
|
+
throw new Error("Category is required in non-interactive mode.");
|
|
84
|
+
}
|
|
85
|
+
const templateData = await getTemplateData();
|
|
86
|
+
const templates = templateData.templates.filter(
|
|
87
|
+
(template) => template.category === selectedCategory
|
|
88
|
+
);
|
|
89
|
+
return templates;
|
|
90
|
+
};
|
|
91
|
+
var getExtensionsGroupedByCategory = async (type, cliArgs) => {
|
|
92
|
+
const selectedType = cliArgs?.type ? cliArgs.type.split(",") : type;
|
|
93
|
+
const safeType = Array.isArray(selectedType) ? selectedType : [selectedType];
|
|
94
|
+
const templateData = await getTemplateData();
|
|
95
|
+
const extensions = templateData.extensions.filter((extension) => {
|
|
96
|
+
const safeExtensionType = Array.isArray(extension.type) ? extension.type : [extension.type];
|
|
97
|
+
return safeExtensionType.some(
|
|
98
|
+
(extensionType) => safeType.includes(extensionType)
|
|
99
|
+
);
|
|
100
|
+
});
|
|
101
|
+
const extensionsGroupedByCategory = extensions.reduce(
|
|
102
|
+
(acc, extension) => {
|
|
103
|
+
const category = extension.category;
|
|
104
|
+
if (!acc[category]) {
|
|
105
|
+
acc[category] = [];
|
|
106
|
+
}
|
|
107
|
+
acc[category].push(extension);
|
|
108
|
+
return acc;
|
|
109
|
+
},
|
|
110
|
+
{}
|
|
111
|
+
);
|
|
112
|
+
return extensionsGroupedByCategory;
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export {
|
|
116
|
+
__require,
|
|
117
|
+
__commonJS,
|
|
118
|
+
__toESM,
|
|
119
|
+
getTemplateCategories,
|
|
120
|
+
getCategoryData,
|
|
121
|
+
getTemplatesForCategory,
|
|
122
|
+
getExtensionsGroupedByCategory
|
|
123
|
+
};
|
|
124
|
+
//# sourceMappingURL=chunk-KDVE4P46.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/templates.ts"],"sourcesContent":["import axios from \"axios\";\nimport type { PromptType } from \"prompts\";\n\nconst TEMPLATE_DATA_FILE_URL =\n \"https://raw.githubusercontent.com/Create-Node-App/cna-templates/main/templates.json\";\n\nexport type TemplateOrExtensionData = {\n name: string;\n slug: string;\n description: string;\n url: string;\n category: string;\n labels?: string[];\n};\n\nexport type TemplateData = TemplateOrExtensionData & {\n type: string;\n customOptions?: {\n name: string;\n type: PromptType;\n [key: string]: unknown;\n }[];\n};\n\nexport type ExtensionType = string | string[];\n\nexport type ExtensionData = TemplateOrExtensionData & {\n type: ExtensionType;\n};\n\nexport type CategoryData = {\n slug: string;\n name: string;\n description: string;\n details: string;\n labels: string[];\n};\n\nexport type Templates = {\n templates: TemplateData[];\n extensions: ExtensionData[];\n categories: CategoryData[];\n};\n\nconst CACHE_TTL_MS = 3600000; // Cache data for 1 hour\n\nconst templateDataCache = {\n data: null as Templates | null,\n timestamp: 0,\n};\n\nconst fetchTemplateData = async () => {\n try {\n const response = await axios.get<Templates>(TEMPLATE_DATA_FILE_URL);\n return response.data;\n } catch {\n // Handle network error, e.g., log it or show a user-friendly message.\n throw new Error(\"Failed to fetch template data\");\n }\n};\n\nconst getTemplateData = async () => {\n const currentTime = Date.now();\n\n if (\n templateDataCache.data === null ||\n currentTime - templateDataCache.timestamp > CACHE_TTL_MS\n ) {\n // Data is not in cache or has expired, fetch and cache it.\n templateDataCache.data = await fetchTemplateData();\n templateDataCache.timestamp = currentTime;\n }\n\n return templateDataCache.data;\n};\n\nexport const getTemplateCategories = async (\n cliArgs?: Record<string, string>,\n) => {\n if (cliArgs?.category) {\n return [cliArgs.category];\n }\n\n const templateData = await getTemplateData();\n\n // If categories are available in the data, use them\n if (templateData.categories && templateData.categories.length > 0) {\n return templateData.categories.map((category) => category.slug);\n }\n\n // Fallback to the old method of extracting categories from templates\n const categories = new Set<string>();\n\n templateData.templates.forEach((template) => {\n categories.add(template.category);\n });\n\n return Array.from(categories);\n};\n\nexport const getCategoryData = async (\n categorySlug: string,\n): Promise<CategoryData | undefined> => {\n const templateData = await getTemplateData();\n\n if (templateData.categories && templateData.categories.length > 0) {\n return templateData.categories.find(\n (category) => category.slug === categorySlug,\n );\n }\n\n return undefined;\n};\n\nexport const getTemplatesForCategory = async (\n category?: string,\n cliArgs?: Record<string, string>,\n) => {\n const selectedCategory = cliArgs?.category || category;\n if (!selectedCategory) {\n throw new Error(\"Category is required in non-interactive mode.\");\n }\n\n const templateData = await getTemplateData();\n\n const templates = templateData.templates.filter(\n (template) => template.category === selectedCategory,\n );\n\n return templates;\n};\n\nexport const getExtensionsGroupedByCategory = async (\n type: ExtensionType,\n cliArgs?: Record<string, string>,\n) => {\n const selectedType = cliArgs?.type ? cliArgs.type.split(\",\") : type;\n\n const safeType = Array.isArray(selectedType) ? selectedType : [selectedType];\n\n const templateData = await getTemplateData();\n\n const extensions = templateData.extensions.filter((extension) => {\n const safeExtensionType = Array.isArray(extension.type)\n ? extension.type\n : [extension.type];\n\n return safeExtensionType.some((extensionType) =>\n safeType.includes(extensionType),\n );\n });\n\n const extensionsGroupedByCategory = extensions.reduce(\n (acc, extension) => {\n const category = extension.category;\n\n if (!acc[category]) {\n acc[category] = [];\n }\n\n acc[category].push(extension);\n\n return acc;\n },\n {} as Record<string, TemplateOrExtensionData[]>,\n );\n\n return extensionsGroupedByCategory;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,WAAW;AAGlB,IAAM,yBACJ;AAwCF,IAAM,eAAe;AAErB,IAAM,oBAAoB;AAAA,EACxB,MAAM;AAAA,EACN,WAAW;AACb;AAEA,IAAM,oBAAoB,YAAY;AACpC,MAAI;AACF,UAAM,WAAW,MAAM,MAAM,IAAe,sBAAsB;AAClE,WAAO,SAAS;AAAA,EAClB,QAAQ;AAEN,UAAM,IAAI,MAAM,+BAA+B;AAAA,EACjD;AACF;AAEA,IAAM,kBAAkB,YAAY;AAClC,QAAM,cAAc,KAAK,IAAI;AAE7B,MACE,kBAAkB,SAAS,QAC3B,cAAc,kBAAkB,YAAY,cAC5C;AAEA,sBAAkB,OAAO,MAAM,kBAAkB;AACjD,sBAAkB,YAAY;AAAA,EAChC;AAEA,SAAO,kBAAkB;AAC3B;AAEO,IAAM,wBAAwB,OACnC,YACG;AACH,MAAI,SAAS,UAAU;AACrB,WAAO,CAAC,QAAQ,QAAQ;AAAA,EAC1B;AAEA,QAAM,eAAe,MAAM,gBAAgB;AAG3C,MAAI,aAAa,cAAc,aAAa,WAAW,SAAS,GAAG;AACjE,WAAO,aAAa,WAAW,IAAI,CAAC,aAAa,SAAS,IAAI;AAAA,EAChE;AAGA,QAAM,aAAa,oBAAI,IAAY;AAEnC,eAAa,UAAU,QAAQ,CAAC,aAAa;AAC3C,eAAW,IAAI,SAAS,QAAQ;AAAA,EAClC,CAAC;AAED,SAAO,MAAM,KAAK,UAAU;AAC9B;AAEO,IAAM,kBAAkB,OAC7B,iBACsC;AACtC,QAAM,eAAe,MAAM,gBAAgB;AAE3C,MAAI,aAAa,cAAc,aAAa,WAAW,SAAS,GAAG;AACjE,WAAO,aAAa,WAAW;AAAA,MAC7B,CAAC,aAAa,SAAS,SAAS;AAAA,IAClC;AAAA,EACF;AAEA,SAAO;AACT;AAEO,IAAM,0BAA0B,OACrC,UACA,YACG;AACH,QAAM,mBAAmB,SAAS,YAAY;AAC9C,MAAI,CAAC,kBAAkB;AACrB,UAAM,IAAI,MAAM,+CAA+C;AAAA,EACjE;AAEA,QAAM,eAAe,MAAM,gBAAgB;AAE3C,QAAM,YAAY,aAAa,UAAU;AAAA,IACvC,CAAC,aAAa,SAAS,aAAa;AAAA,EACtC;AAEA,SAAO;AACT;AAEO,IAAM,iCAAiC,OAC5C,MACA,YACG;AACH,QAAM,eAAe,SAAS,OAAO,QAAQ,KAAK,MAAM,GAAG,IAAI;AAE/D,QAAM,WAAW,MAAM,QAAQ,YAAY,IAAI,eAAe,CAAC,YAAY;AAE3E,QAAM,eAAe,MAAM,gBAAgB;AAE3C,QAAM,aAAa,aAAa,WAAW,OAAO,CAAC,cAAc;AAC/D,UAAM,oBAAoB,MAAM,QAAQ,UAAU,IAAI,IAClD,UAAU,OACV,CAAC,UAAU,IAAI;AAEnB,WAAO,kBAAkB;AAAA,MAAK,CAAC,kBAC7B,SAAS,SAAS,aAAa;AAAA,IACjC;AAAA,EACF,CAAC;AAED,QAAM,8BAA8B,WAAW;AAAA,IAC7C,CAAC,KAAK,cAAc;AAClB,YAAM,WAAW,UAAU;AAE3B,UAAI,CAAC,IAAI,QAAQ,GAAG;AAClB,YAAI,QAAQ,IAAI,CAAC;AAAA,MACnB;AAEA,UAAI,QAAQ,EAAE,KAAK,SAAS;AAE5B,aAAO;AAAA,IACT;AAAA,IACA,CAAC;AAAA,EACH;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
8
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
9
|
+
}) : x)(function(x) {
|
|
10
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
11
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
12
|
+
});
|
|
13
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
14
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
15
|
+
};
|
|
16
|
+
var __copyProps = (to, from, except, desc) => {
|
|
17
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
18
|
+
for (let key of __getOwnPropNames(from))
|
|
19
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
20
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
24
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
25
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
26
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
27
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
28
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
29
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
30
|
+
mod
|
|
31
|
+
));
|
|
32
|
+
|
|
33
|
+
// src/templates.ts
|
|
34
|
+
import axios from "axios";
|
|
35
|
+
var TEMPLATE_DATA_FILE_URL = "https://raw.githubusercontent.com/Create-Node-App/cna-templates/main/templates.json";
|
|
36
|
+
var CACHE_TTL_MS = 36e5;
|
|
37
|
+
var templateDataCache = {
|
|
38
|
+
data: null,
|
|
39
|
+
timestamp: 0
|
|
40
|
+
};
|
|
41
|
+
var fetchTemplateData = async () => {
|
|
42
|
+
try {
|
|
43
|
+
const response = await axios.get(TEMPLATE_DATA_FILE_URL);
|
|
44
|
+
return response.data;
|
|
45
|
+
} catch (error) {
|
|
46
|
+
throw new Error("Failed to fetch template data");
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var getTemplateData = async () => {
|
|
50
|
+
const currentTime = Date.now();
|
|
51
|
+
if (templateDataCache.data === null || currentTime - templateDataCache.timestamp > CACHE_TTL_MS) {
|
|
52
|
+
templateDataCache.data = await fetchTemplateData();
|
|
53
|
+
templateDataCache.timestamp = currentTime;
|
|
54
|
+
}
|
|
55
|
+
return templateDataCache.data;
|
|
56
|
+
};
|
|
57
|
+
var getTemplateCategories = async (cliArgs) => {
|
|
58
|
+
if (cliArgs?.category) {
|
|
59
|
+
return [cliArgs.category];
|
|
60
|
+
}
|
|
61
|
+
const templateData = await getTemplateData();
|
|
62
|
+
if (templateData.categories && templateData.categories.length > 0) {
|
|
63
|
+
return templateData.categories.map((category) => category.slug);
|
|
64
|
+
}
|
|
65
|
+
const categories = /* @__PURE__ */ new Set();
|
|
66
|
+
templateData.templates.forEach((template) => {
|
|
67
|
+
categories.add(template.category);
|
|
68
|
+
});
|
|
69
|
+
return Array.from(categories);
|
|
70
|
+
};
|
|
71
|
+
var getCategoryData = async (categorySlug) => {
|
|
72
|
+
const templateData = await getTemplateData();
|
|
73
|
+
if (templateData.categories && templateData.categories.length > 0) {
|
|
74
|
+
return templateData.categories.find(
|
|
75
|
+
(category) => category.slug === categorySlug
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
return void 0;
|
|
79
|
+
};
|
|
80
|
+
var getTemplatesForCategory = async (category, cliArgs) => {
|
|
81
|
+
const selectedCategory = cliArgs?.category || category;
|
|
82
|
+
if (!selectedCategory) {
|
|
83
|
+
throw new Error("Category is required in non-interactive mode.");
|
|
84
|
+
}
|
|
85
|
+
const templateData = await getTemplateData();
|
|
86
|
+
const templates = templateData.templates.filter(
|
|
87
|
+
(template) => template.category === selectedCategory
|
|
88
|
+
);
|
|
89
|
+
return templates;
|
|
90
|
+
};
|
|
91
|
+
var getExtensionsGroupedByCategory = async (type, cliArgs) => {
|
|
92
|
+
const selectedType = cliArgs?.type ? cliArgs.type.split(",") : type;
|
|
93
|
+
const safeType = Array.isArray(selectedType) ? selectedType : [selectedType];
|
|
94
|
+
const templateData = await getTemplateData();
|
|
95
|
+
const extensions = templateData.extensions.filter((extension) => {
|
|
96
|
+
const safeExtensionType = Array.isArray(extension.type) ? extension.type : [extension.type];
|
|
97
|
+
return safeExtensionType.some(
|
|
98
|
+
(extensionType) => safeType.includes(extensionType)
|
|
99
|
+
);
|
|
100
|
+
});
|
|
101
|
+
const extensionsGroupedByCategory = extensions.reduce(
|
|
102
|
+
(acc, extension) => {
|
|
103
|
+
const category = extension.category;
|
|
104
|
+
if (!acc[category]) {
|
|
105
|
+
acc[category] = [];
|
|
106
|
+
}
|
|
107
|
+
acc[category].push(extension);
|
|
108
|
+
return acc;
|
|
109
|
+
},
|
|
110
|
+
{}
|
|
111
|
+
);
|
|
112
|
+
return extensionsGroupedByCategory;
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export {
|
|
116
|
+
__require,
|
|
117
|
+
__commonJS,
|
|
118
|
+
__toESM,
|
|
119
|
+
getTemplateCategories,
|
|
120
|
+
getCategoryData,
|
|
121
|
+
getTemplatesForCategory,
|
|
122
|
+
getExtensionsGroupedByCategory
|
|
123
|
+
};
|