|
1 | | -const CREATE_HARPER_TREE = 'https://github.com/HarperFast/create-harper/tree/main'; |
| 1 | +import { templates as catalog } from 'create-harper/templates'; |
2 | 2 |
|
3 | | -export const templates = [ |
4 | | - { |
5 | | - id: 'vanilla', |
6 | | - name: 'Vanilla JS', |
7 | | - description: "Define your entities in schema.graphql, add your HTML/CSS/JS in web, and you're cooking!", |
8 | | - tags: ['Vanilla', 'REST', 'GraphQL', 'ORM'], |
9 | | - npm: '@harperfast/template-vanilla-studio', |
10 | | - githubUrl: `${CREATE_HARPER_TREE}/template-vanilla`, |
11 | | - }, |
12 | | - { |
13 | | - id: 'vanilla-ts', |
14 | | - name: 'Vanilla + TypeScript', |
15 | | - description: 'The same Web + REST ORM from the first template, but with TypeScript sprinkled in.', |
16 | | - tags: ['Vanilla', 'TypeScript', 'GraphQL'], |
17 | | - npm: '@harperfast/template-vanilla-ts-studio', |
18 | | - githubUrl: `${CREATE_HARPER_TREE}/template-vanilla-ts`, |
19 | | - }, |
20 | | - { |
21 | | - id: 'react', |
22 | | - name: 'React', |
23 | | - description: "A Vite-powered React single-page app, wired up to Harper's REST + GraphQL APIs out of the box.", |
24 | | - tags: ['React', 'Vite', 'SPA', 'GraphQL'], |
25 | | - npm: '@harperfast/template-react-studio', |
26 | | - githubUrl: `${CREATE_HARPER_TREE}/template-react`, |
27 | | - }, |
28 | | - { |
29 | | - id: 'react-ts', |
30 | | - name: 'React + TypeScript', |
31 | | - description: 'The same Vite-powered React app, with end-to-end type safety from TypeScript.', |
32 | | - tags: ['React', 'TypeScript', 'Vite', 'SPA'], |
33 | | - npm: '@harperfast/template-react-ts-studio', |
34 | | - githubUrl: `${CREATE_HARPER_TREE}/template-react-ts`, |
35 | | - }, |
36 | | - { |
37 | | - id: 'react-ssr', |
38 | | - name: 'React + SSR', |
39 | | - description: 'Server-rendered React with Vite for fast first paints, hydrating into a full SPA on Harper.', |
40 | | - tags: ['React', 'SSR', 'Vite', 'GraphQL'], |
41 | | - npm: '@harperfast/template-react-ssr-studio', |
42 | | - githubUrl: `${CREATE_HARPER_TREE}/template-react-ssr`, |
43 | | - }, |
44 | | - { |
45 | | - id: 'react-ts-ssr', |
46 | | - name: 'React + TypeScript + SSR', |
47 | | - description: 'Server-rendered React with Vite and TypeScript for type-safe, SEO-friendly pages on Harper.', |
48 | | - tags: ['React', 'TypeScript', 'SSR', 'Vite'], |
49 | | - npm: '@harperfast/template-react-ts-ssr-studio', |
50 | | - githubUrl: `${CREATE_HARPER_TREE}/template-react-ts-ssr`, |
51 | | - }, |
52 | | - { |
53 | | - id: 'vue', |
54 | | - name: 'Vue', |
55 | | - description: "A Vite-powered Vue single-page app, wired up to Harper's REST + GraphQL APIs out of the box.", |
56 | | - tags: ['Vue', 'Vite', 'SPA', 'GraphQL'], |
57 | | - npm: '@harperfast/template-vue-studio', |
58 | | - githubUrl: `${CREATE_HARPER_TREE}/template-vue`, |
59 | | - }, |
60 | | - { |
61 | | - id: 'vue-ts', |
62 | | - name: 'Vue + TypeScript', |
63 | | - description: 'The same Vite-powered Vue app, with end-to-end type safety from TypeScript.', |
64 | | - tags: ['Vue', 'TypeScript', 'Vite', 'SPA'], |
65 | | - npm: '@harperfast/template-vue-ts-studio', |
66 | | - githubUrl: `${CREATE_HARPER_TREE}/template-vue-ts`, |
67 | | - }, |
68 | | - { |
69 | | - id: 'vue-ssr', |
70 | | - name: 'Vue + SSR', |
71 | | - description: 'Server-rendered Vue with Vite for fast first paints, hydrating into a full SPA on Harper.', |
72 | | - tags: ['Vue', 'SSR', 'Vite', 'GraphQL'], |
73 | | - npm: '@harperfast/template-vue-ssr-studio', |
74 | | - githubUrl: `${CREATE_HARPER_TREE}/template-vue-ssr`, |
75 | | - }, |
76 | | - { |
77 | | - id: 'vue-ts-ssr', |
78 | | - name: 'Vue + TypeScript + SSR', |
79 | | - description: 'Server-rendered Vue with Vite and TypeScript for type-safe, SEO-friendly pages on Harper.', |
80 | | - tags: ['Vue', 'TypeScript', 'SSR', 'Vite'], |
81 | | - npm: '@harperfast/template-vue-ts-ssr-studio', |
82 | | - githubUrl: `${CREATE_HARPER_TREE}/template-vue-ts-ssr`, |
83 | | - }, |
84 | | -]; |
| 3 | +// create-harper is the single source of truth for the template list, descriptions, npm packages, and |
| 4 | +// GitHub links. New templates added there flow through here (and into the createApp agent tool) |
| 5 | +// automatically. create-harper lists TypeScript-first; we re-sort to Studio's established display order |
| 6 | +// (by framework, then non-SSR before SSR, then JavaScript before TypeScript) so the picker and its |
| 7 | +// default selection stay stable. |
| 8 | +const FRAMEWORK_ORDER = ['vanilla', 'react', 'vue'] as const; |
| 9 | + |
| 10 | +// Rank a framework by its position in FRAMEWORK_ORDER. Any framework not listed (e.g. a future |
| 11 | +// Svelte/Angular template added to create-harper) sorts to the end rather than the top. |
| 12 | +function frameworkRank(framework: string): number { |
| 13 | + const index = (FRAMEWORK_ORDER as readonly string[]).indexOf(framework); |
| 14 | + return index === -1 ? Infinity : index; |
| 15 | +} |
| 16 | + |
| 17 | +export const templates = [...catalog] |
| 18 | + .sort((a, b) => |
| 19 | + frameworkRank(a.framework) - frameworkRank(b.framework) |
| 20 | + || Number(a.ssr) - Number(b.ssr) |
| 21 | + || Number(a.typescript) - Number(b.typescript) |
| 22 | + ) |
| 23 | + .map((t) => ({ |
| 24 | + // Widen to `string`: the New Application form supplies the selected id as a plain string. |
| 25 | + id: t.name as string, |
| 26 | + name: t.title, |
| 27 | + description: t.description, |
| 28 | + tags: [...t.tags], |
| 29 | + npm: t.npmPackage, |
| 30 | + githubUrl: t.githubUrl, |
| 31 | + })); |
0 commit comments