@govela/create 0.0.0-stage → 0.6.0

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.
Files changed (68) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +17 -2
  3. package/bin/create.js +146 -0
  4. package/package.json +24 -4
  5. package/templates/app/base/AGENTS.md +36 -0
  6. package/templates/app/base/README.md +19 -0
  7. package/templates/app/base/_github/workflows/ci.yml +23 -0
  8. package/templates/app/base/_gitignore +7 -0
  9. package/templates/app/base/cmd/server/main.go +53 -0
  10. package/templates/app/base/go.mod +8 -0
  11. package/templates/app/base/server/routes/load.go +30 -0
  12. package/templates/app/base/vela.config.json +6 -0
  13. package/templates/app/base/vite.config.js +11 -0
  14. package/templates/app/base/vitest.setup.__EXT__ +5 -0
  15. package/templates/app/js/eslint.config.js +12 -0
  16. package/templates/app/js/package.json +29 -0
  17. package/templates/app/js/src/routes/Layout.vela +24 -0
  18. package/templates/app/js/src/routes/Page.test.js +13 -0
  19. package/templates/app/js/src/routes/Page.vela +10 -0
  20. package/templates/app/ts/eslint.config.js +14 -0
  21. package/templates/app/ts/package.json +31 -0
  22. package/templates/app/ts/src/routes/Layout.vela +26 -0
  23. package/templates/app/ts/src/routes/Page.test.ts +13 -0
  24. package/templates/app/ts/src/routes/Page.vela +12 -0
  25. package/templates/app/ts/tsconfig.json +4 -0
  26. package/templates/app/ts/vela.app.json +1 -0
  27. package/templates/default/base/AGENTS.md +28 -0
  28. package/templates/default/base/README.md +17 -0
  29. package/templates/default/base/_github/workflows/ci.yml +20 -0
  30. package/templates/default/base/_gitignore +2 -0
  31. package/templates/default/base/index.html +12 -0
  32. package/templates/default/base/vite.config.js +9 -0
  33. package/templates/default/base/vitest.setup.__EXT__ +5 -0
  34. package/templates/default/js/eslint.config.js +12 -0
  35. package/templates/default/js/package.json +28 -0
  36. package/templates/default/js/src/App.vela +25 -0
  37. package/templates/default/js/src/Counter.test.js +20 -0
  38. package/templates/default/js/src/Counter.vela +23 -0
  39. package/templates/default/js/src/main.js +4 -0
  40. package/templates/default/ts/eslint.config.js +14 -0
  41. package/templates/default/ts/package.json +30 -0
  42. package/templates/default/ts/src/App.vela +25 -0
  43. package/templates/default/ts/src/Counter.test.ts +20 -0
  44. package/templates/default/ts/src/Counter.vela +27 -0
  45. package/templates/default/ts/src/main.ts +4 -0
  46. package/templates/default/ts/tsconfig.json +18 -0
  47. package/templates/ssr/base/AGENTS.md +34 -0
  48. package/templates/ssr/base/README.md +30 -0
  49. package/templates/ssr/base/_github/workflows/ci.yml +23 -0
  50. package/templates/ssr/base/_gitignore +4 -0
  51. package/templates/ssr/base/cmd/server/main.go +57 -0
  52. package/templates/ssr/base/go.mod +5 -0
  53. package/templates/ssr/base/vela.config.json +6 -0
  54. package/templates/ssr/base/vite.config.js +11 -0
  55. package/templates/ssr/base/vitest.setup.__EXT__ +5 -0
  56. package/templates/ssr/js/eslint.config.js +12 -0
  57. package/templates/ssr/js/package.json +30 -0
  58. package/templates/ssr/js/src/App.vela +27 -0
  59. package/templates/ssr/js/src/Counter.test.js +20 -0
  60. package/templates/ssr/js/src/Counter.vela +23 -0
  61. package/templates/ssr/js/src/client.js +5 -0
  62. package/templates/ssr/ts/eslint.config.js +14 -0
  63. package/templates/ssr/ts/package.json +32 -0
  64. package/templates/ssr/ts/src/App.vela +27 -0
  65. package/templates/ssr/ts/src/Counter.test.ts +20 -0
  66. package/templates/ssr/ts/src/Counter.vela +27 -0
  67. package/templates/ssr/ts/src/client.ts +5 -0
  68. package/templates/ssr/ts/tsconfig.json +18 -0
@@ -0,0 +1,14 @@
1
+ import { defineConfig } from 'eslint/config';
2
+ import js from '@eslint/js';
3
+ import globals from 'globals';
4
+ import tseslint from 'typescript-eslint';
5
+ import vela from '@govela/eslint-plugin';
6
+
7
+ export default defineConfig(
8
+ { ignores: ['dist/', 'out/', 'build/', 'src/_app/'] },
9
+ js.configs.recommended,
10
+ tseslint.configs.recommended,
11
+ vela.configs.recommended,
12
+ { files: ['src/**/*.ts', '**/*.vela/*.ts'], languageOptions: { globals: globals.browser } },
13
+ { files: ['*.config.js'], languageOptions: { globals: globals.node } },
14
+ );
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "__NAME__",
3
+ "private": true,
4
+ "type": "module",
5
+ "scripts": {
6
+ "dev": "vite",
7
+ "dev:vela": "vela --watch",
8
+ "dev:server": "go run ./cmd/server -dev http://localhost:5173",
9
+ "check": "vela check --project src --types --ssr",
10
+ "lint": "eslint .",
11
+ "test": "vitest run",
12
+ "build": "vela && vite build && go build -o build/server ./cmd/server",
13
+ "start": "./build/server"
14
+ },
15
+ "dependencies": {
16
+ "@govela/runtime": "__VERSION__"
17
+ },
18
+ "devDependencies": {
19
+ "@eslint/js": "^10.0.1",
20
+ "@govela/compiler": "__VERSION__",
21
+ "@govela/eslint-plugin": "__VERSION__",
22
+ "@govela/testing": "__VERSION__",
23
+ "@govela/unplugin": "__VERSION__",
24
+ "eslint": "^10.14.0",
25
+ "globals": "^17.0.0",
26
+ "happy-dom": "^21.0.4",
27
+ "typescript": "^6.0.3",
28
+ "typescript-eslint": "^8.72.1",
29
+ "vite": "^8.3.5",
30
+ "vitest": "^5.1.0"
31
+ }
32
+ }
@@ -0,0 +1,27 @@
1
+ <script lang="ts">
2
+ import Counter from './Counter.vela';
3
+
4
+ export let title: string = 'Vela';
5
+
6
+ let total = $state(0);
7
+
8
+ function changed(event: CustomEvent<number>): void {
9
+ total = event.detail;
10
+ }
11
+ </script>
12
+
13
+ <template>
14
+ <main>
15
+ <h1>{title}</h1>
16
+ <Counter :step={1} @on:change={changed}>Clicks</Counter>
17
+ <p class="total">Total: {total}</p>
18
+ </main>
19
+ </template>
20
+
21
+ <style>
22
+ main {
23
+ font-family: system-ui, sans-serif;
24
+ max-width: 32rem;
25
+ margin: 4rem auto;
26
+ }
27
+ </style>
@@ -0,0 +1,20 @@
1
+ import { expect, test } from 'vitest';
2
+ import { fireEvent, render } from '@govela/testing';
3
+ import Counter from './Counter.vela';
4
+
5
+ test('counts by its step and reports the count', async () => {
6
+ const counts: number[] = [];
7
+ const { container } = render(Counter, {
8
+ props: { step: 2 },
9
+ slots: { default: 'Clicks' },
10
+ events: { change: (event) => counts.push(event.detail) },
11
+ });
12
+ const button = container.querySelector('button')!;
13
+ expect(button.textContent).toBe('Clicks: 0');
14
+
15
+ await fireEvent.click(button);
16
+ await fireEvent.click(button);
17
+
18
+ expect(button.textContent).toBe('Clicks: 4');
19
+ expect(counts).toEqual([2, 4]);
20
+ });
@@ -0,0 +1,27 @@
1
+ <script lang="ts">
2
+ interface $$Events {
3
+ change: number;
4
+ }
5
+
6
+ export let step: number = 1;
7
+
8
+ let count = $state(0);
9
+
10
+ function increment(): void {
11
+ count += step;
12
+ $$dispatch('change', count);
13
+ }
14
+ </script>
15
+
16
+ <template>
17
+ <button @click={increment}>
18
+ <slot>Count</slot>: {count}
19
+ </button>
20
+ </template>
21
+
22
+ <style>
23
+ button {
24
+ font: inherit;
25
+ padding: 0.5rem 1rem;
26
+ }
27
+ </style>
@@ -0,0 +1,5 @@
1
+ // Hydrates the HTML the Go server rendered.
2
+ import { hydrate } from '@govela/runtime/hydrate';
3
+ import App from './App.vela';
4
+
5
+ hydrate(App, document.getElementById('app')!);
@@ -0,0 +1,18 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
+ "strict": true,
7
+ "noEmit": true,
8
+ "isolatedModules": true,
9
+ "verbatimModuleSyntax": true,
10
+ "erasableSyntaxOnly": true,
11
+ "allowImportingTsExtensions": true,
12
+ "useDefineForClassFields": true,
13
+ "skipLibCheck": true,
14
+ "lib": ["ES2022", "DOM", "DOM.Iterable"],
15
+ "types": ["@govela/runtime/ambient"]
16
+ },
17
+ "include": ["src"]
18
+ }