@temir.ra/create-hono-spa 0.2.0 → 0.2.1
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/CHANGELOG.md +4 -0
- package/README.md +5 -54
- package/buildinfo.txt +1 -1
- package/dist/cli.bundle.js.map +1 -1
- package/dist/cli.js +1 -1
- package/package.json +3 -3
- package/template/README.md +7 -28
- package/template/package.json +54 -54
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -5,18 +5,15 @@ A template for single-page applications distributed as Hono sub-app libraries. T
|
|
|
5
5
|
## Table of Contents
|
|
6
6
|
|
|
7
7
|
1. [Quick Start](#quick-start)
|
|
8
|
-
2. [
|
|
9
|
-
3. [Documentation](#documentation)
|
|
8
|
+
2. [Documentation](#documentation)
|
|
10
9
|
1. [`template/`](#template)
|
|
11
10
|
2. [Architecture](#architecture)
|
|
12
11
|
3. [`src/spa.ts`](#srcspa-ts)
|
|
13
12
|
4. [`src/constants.ts`](#srcconstants-ts)
|
|
14
13
|
5. [`assets/`](#assets)
|
|
15
|
-
|
|
14
|
+
3. [DevOps](#devops)
|
|
16
15
|
1. [Change Management](#change-management)
|
|
17
16
|
2. [Publish](#publish)
|
|
18
|
-
1. [npmjs.org](#npmjsorg)
|
|
19
|
-
2. [Custom registry](#custom-registry)
|
|
20
17
|
|
|
21
18
|
# Quick Start
|
|
22
19
|
|
|
@@ -44,24 +41,12 @@ cd <NEW_PACKAGE>
|
|
|
44
41
|
bun install
|
|
45
42
|
```
|
|
46
43
|
|
|
47
|
-
# AI Assistant Context
|
|
48
|
-
|
|
49
|
-
To generate an AI coding assistant context file for this project:
|
|
50
|
-
|
|
51
|
-
> Generate an AI coding assistant context file. Analyze the project structure and source files, using this README as the primary reference for architecture and conventions. Give particular attention to: the SPA-as-library abstraction and how assets are served via import.meta.url without any file copying on the consuming server, the `./spa` export condition and createSpa() as the library's public API, and the base href patching mechanism that enables client-side routing regardless of mount path.
|
|
52
|
-
|
|
53
44
|
# Documentation
|
|
54
45
|
|
|
55
|
-
The following sections explain the configurations and conventions baked into the generated package.
|
|
46
|
+
The following sections explain the configurations and conventions baked into the generated package. Useful when adapting it to fit specific needs.
|
|
56
47
|
|
|
57
48
|
## `template/`
|
|
58
49
|
|
|
59
|
-
The files in `template/` were created from the [`@temir.ra/ts-lib@0.5.0`](https://www.npmjs.com/package/@temir.ra/create-ts-lib/v/0.5.0) template and then updated to fit the needs of a Hono SPA template.
|
|
60
|
-
|
|
61
|
-
```powershell
|
|
62
|
-
bun create --no-install --no-git --force "@temir.ra/ts-lib@0.5.0" "template/"
|
|
63
|
-
```
|
|
64
|
-
|
|
65
50
|
[Official documentation](https://hono.dev/docs/) provided by the Hono team is a great resource.
|
|
66
51
|
|
|
67
52
|
## Architecture
|
|
@@ -142,13 +127,13 @@ assets/
|
|
|
142
127
|
# DevOps
|
|
143
128
|
|
|
144
129
|
```bash
|
|
145
|
-
# remove dist/ and tsconfig.build.tsbuildinfo
|
|
130
|
+
# remove dist/ and tsconfig.tsbuildinfo and tsconfig.build.tsbuildinfo
|
|
146
131
|
bun run clean
|
|
147
132
|
|
|
148
133
|
# remove dist/ only
|
|
149
134
|
bun run clean:dist
|
|
150
135
|
|
|
151
|
-
# remove tsconfig.build.tsbuildinfo only
|
|
136
|
+
# remove tsconfig.tsbuildinfo and tsconfig.build.tsbuildinfo only
|
|
152
137
|
bun run clean:tsbuildinfo
|
|
153
138
|
|
|
154
139
|
# compile + bundle
|
|
@@ -158,8 +143,6 @@ bun run build
|
|
|
158
143
|
bun run dist/cli.bundle.js -- example
|
|
159
144
|
```
|
|
160
145
|
|
|
161
|
-
**Publish** - see [Publish](#publish).
|
|
162
|
-
|
|
163
146
|
## Change Management
|
|
164
147
|
|
|
165
148
|
1. Create a new branch for the change.
|
|
@@ -172,15 +155,6 @@ bun run dist/cli.bundle.js -- example
|
|
|
172
155
|
|
|
173
156
|
## Publish
|
|
174
157
|
|
|
175
|
-
See the following sources to configure the target registry and authentication.
|
|
176
|
-
|
|
177
|
-
- [Configuring npm - `npmrc`](https://docs.npmjs.com/cli/v10/configuring-npm/npmrc)
|
|
178
|
-
- [Bun package manager - `install.registry`](https://bun.com/docs/runtime/bunfig#install-scopes)
|
|
179
|
-
|
|
180
|
-
⚠️ Package Scope and the authentication for the target registry must be aligned.
|
|
181
|
-
|
|
182
|
-
### `npmjs.org`
|
|
183
|
-
|
|
184
158
|
Publish to the public npm registry.
|
|
185
159
|
|
|
186
160
|
```powershell
|
|
@@ -189,26 +163,3 @@ npm login
|
|
|
189
163
|
# publish
|
|
190
164
|
bun publish --registry https://registry.npmjs.org/ --access public
|
|
191
165
|
```
|
|
192
|
-
|
|
193
|
-
### Custom registry
|
|
194
|
-
|
|
195
|
-
```bash
|
|
196
|
-
# placeholder:
|
|
197
|
-
# <SCOPE_WITHOUT_AT: <SCOPE_WITHOUT_AT>
|
|
198
|
-
# <REGISTRY_URL: <REGISTRY_URL>
|
|
199
|
-
# <BUN_PUBLISH_AUTH_TOKEN: <BUN_PUBLISH_AUTH_TOKEN>
|
|
200
|
-
```
|
|
201
|
-
|
|
202
|
-
`~/.bunfig.toml` or `bunfig.toml`:
|
|
203
|
-
|
|
204
|
-
```toml
|
|
205
|
-
[install.scopes]
|
|
206
|
-
"<SCOPE_WITHOUT_AT>" = { url = "<REGISTRY_URL>", token = "$BUN_PUBLISH_AUTH_TOKEN" }
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
```powershell
|
|
210
|
-
# authenticate
|
|
211
|
-
$env:BUN_PUBLISH_AUTH_TOKEN = "<BUN_PUBLISH_AUTH_TOKEN>"
|
|
212
|
-
# publish
|
|
213
|
-
bun publish
|
|
214
|
-
```
|
package/buildinfo.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.2.
|
|
1
|
+
0.2.1+9a0a8a7
|
package/dist/cli.bundle.js.map
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["..\\src\\cli.ts", "..\\src\\constants.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"#!/usr/bin/env node\r\n\r\nimport { cpSync, readFileSync, renameSync, writeFileSync } from 'fs';\r\nimport { resolve
|
|
5
|
+
"#!/usr/bin/env node\r\n\r\nimport { cpSync, readFileSync, renameSync, writeFileSync } from 'fs';\r\nimport { resolve } from 'path';\r\nimport {\r\n templatePath,\r\n changelogPath,\r\n buildinfoPath,\r\n readmePath\r\n} from './constants.js';\r\n\r\n\r\ntry {\r\n\r\n const packageNameArgument = process.argv[2];\r\n if (!packageNameArgument) throw new Error('Package name argument is required. Usage: `create-hono-spa <package-name>`');\r\n const packageName = packageNameArgument.replace(/\\\\/g, '/');\r\n\r\n const destinationPath = resolve(process.cwd(), packageName);\r\n\r\n cpSync(templatePath, destinationPath, { recursive: true });\r\n cpSync(changelogPath, resolve(destinationPath, 'CHANGELOG-template.md'));\r\n cpSync(buildinfoPath, resolve(destinationPath, 'buildinfo-template.txt'));\r\n cpSync(readmePath, resolve(destinationPath, 'README-template.md'));\r\n\r\n const packageJsonPath = resolve(destinationPath, 'package.json');\r\n const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));\r\n packageJson.name = packageName;\r\n writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));\r\n\r\n renameSync(resolve(destinationPath, 'gitignore'), resolve(destinationPath, '.gitignore'));\r\n\r\n console.log(`Template has been successfully instantiated at '${destinationPath}' with package name '${packageName}'.`);\r\n\r\n}\r\ncatch (error) {\r\n const err = error instanceof Error ? error : new Error(String(error));\r\n console.error('Error:', err.message);\r\n process.exit(1);\r\n}\r\n",
|
|
6
6
|
"import { resolve } from 'path';\r\nimport { fileURLToPath } from 'url';\r\n\r\n\r\nexport const packageUrl: URL = new URL('../', import.meta.url);\r\nexport const packagePath: string = resolve(fileURLToPath(packageUrl));\r\n\r\nexport const templatePath: string = resolve(packagePath, 'template/');\r\n\r\nexport const changelogPath: string = resolve(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package/dist/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { cpSync, readFileSync, renameSync, writeFileSync } from 'fs';
|
|
3
|
-
import { resolve
|
|
3
|
+
import { resolve } from 'path';
|
|
4
4
|
import { templatePath, changelogPath, buildinfoPath, readmePath } from './constants.js';
|
|
5
5
|
try {
|
|
6
6
|
const packageNameArgument = process.argv[2];
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@temir.ra/create-hono-spa",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "SPA template
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"description": "SPA template for Hono server backend",
|
|
5
5
|
"author": "temir.ra",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"keywords": [
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
],
|
|
29
29
|
"scripts": {
|
|
30
30
|
"clean:dist": "rm -rf dist/",
|
|
31
|
-
"clean:tsbuildinfo": "rm -f tsconfig.build.tsbuildinfo",
|
|
31
|
+
"clean:tsbuildinfo": "rm -f tsconfig.tsbuildinfo tsconfig.build.tsbuildinfo",
|
|
32
32
|
"clean": "bun run clean:dist && bun run clean:tsbuildinfo",
|
|
33
33
|
"prebuild": "bun run scripts/buildinfo.ts",
|
|
34
34
|
"tests": "bun test",
|
package/template/README.md
CHANGED
|
@@ -5,9 +5,8 @@
|
|
|
5
5
|
## Table of Contents
|
|
6
6
|
|
|
7
7
|
1. [Quick Start](#quick-start)
|
|
8
|
-
2. [
|
|
9
|
-
3. [
|
|
10
|
-
4. [DevOps](#devops)
|
|
8
|
+
2. [Documentation](#documentation)
|
|
9
|
+
3. [DevOps](#devops)
|
|
11
10
|
1. [Change Management](#change-management)
|
|
12
11
|
2. [Publish](#publish)
|
|
13
12
|
1. [npmjs.org](#npmjsorg)
|
|
@@ -16,13 +15,13 @@
|
|
|
16
15
|
# Quick Start
|
|
17
16
|
|
|
18
17
|
```bash
|
|
19
|
-
# remove dist/ and tsconfig.build.tsbuildinfo
|
|
18
|
+
# remove dist/ and tsconfig.tsbuildinfo and tsconfig.build.tsbuildinfo
|
|
20
19
|
bun run clean
|
|
21
20
|
|
|
22
21
|
# remove dist/ only
|
|
23
22
|
bun run clean:dist
|
|
24
23
|
|
|
25
|
-
# remove tsconfig.build.tsbuildinfo only
|
|
24
|
+
# remove tsconfig.tsbuildinfo and tsconfig.build.tsbuildinfo only
|
|
26
25
|
bun run clean:tsbuildinfo
|
|
27
26
|
|
|
28
27
|
# compile + bundle
|
|
@@ -35,30 +34,10 @@ bun run tests
|
|
|
35
34
|
bun run dev
|
|
36
35
|
```
|
|
37
36
|
|
|
38
|
-
**Publish** - see [Publish](#publish).
|
|
39
|
-
|
|
40
|
-
# AI Assistant Context
|
|
41
|
-
|
|
42
|
-
To generate an AI coding assistant context file for this project:
|
|
43
|
-
|
|
44
|
-
> Generate an AI coding assistant context file. `README-template.md` is available now and documents the architectural conventions of this package — use it as your primary source. The generated context file must be self-contained: `README-template.md` will be deleted after context generation, so do not reference it in the output. Give particular attention to: the dual tsconfig setup and the import constraints it imposes, the `#src/*.js` alias and where it may and may not be used, the `./spa` export condition and createSpa() as the library's public API, the asset resolution via import.meta.url and why it is reliable when the package is loaded externalized, and the base href patching mechanism for client-side routing.
|
|
45
|
-
|
|
46
37
|
# Documentation
|
|
47
38
|
|
|
48
39
|
*<DOCUMENTATION>*
|
|
49
40
|
|
|
50
|
-
## Asset Resolution
|
|
51
|
-
|
|
52
|
-
*<!-- Remove this section if the library has no runtime assets. Replace `@scope/lib-name` throughout with the actual package name. -->*
|
|
53
|
-
|
|
54
|
-
Assets are placed under `assets/@scope/lib-name/` (scoped to the package name to prevent collisions). They are resolved at runtime via `import.meta.url` and loaded with `fetch()` (browser) or `readFile` (Node). `assets/` must be listed in `files` in `package.json`.
|
|
55
|
-
|
|
56
|
-
`import.meta.url` is reliable when the library is loaded as a discrete module (from CDN or `node_modules/`). When the consumer bundles the library, they must copy the assets - see below.
|
|
57
|
-
|
|
58
|
-
### For consumers bundling this library
|
|
59
|
-
|
|
60
|
-
Copy `node_modules/@scope/lib-name/assets/` into your build output alongside the bundle, preserving the relative path. No code configuration is required - only the file copy.
|
|
61
|
-
|
|
62
41
|
# DevOps
|
|
63
42
|
|
|
64
43
|
## Change Management
|
|
@@ -95,9 +74,9 @@ bun publish --registry https://registry.npmjs.org/ --access public
|
|
|
95
74
|
|
|
96
75
|
```bash
|
|
97
76
|
# placeholder:
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
77
|
+
# <SCOPE_WITHOUT_AT: <SCOPE_WITHOUT_AT>
|
|
78
|
+
# <REGISTRY_URL: <REGISTRY_URL>
|
|
79
|
+
# <BUN_PUBLISH_AUTH_TOKEN: <BUN_PUBLISH_AUTH_TOKEN>
|
|
101
80
|
```
|
|
102
81
|
|
|
103
82
|
`~/.bunfig.toml` or `bunfig.toml`:
|
package/template/package.json
CHANGED
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "",
|
|
3
|
-
"version": "0.0.0+FE",
|
|
4
|
-
"description": "",
|
|
5
|
-
"author": "",
|
|
6
|
-
"license": "",
|
|
7
|
-
"keywords": [
|
|
8
|
-
"typescript"
|
|
9
|
-
],
|
|
10
|
-
"repository": {
|
|
11
|
-
"type": "git",
|
|
12
|
-
"url": ""
|
|
13
|
-
},
|
|
14
|
-
"type": "module",
|
|
15
|
-
"exports": {
|
|
16
|
-
".": {
|
|
17
|
-
"entrypoint": "./src/index.ts",
|
|
18
|
-
"types": "./dist/index.d.ts",
|
|
19
|
-
"browser": "./dist/index.bundle.js",
|
|
20
|
-
"import": "./dist/index.js"
|
|
21
|
-
},
|
|
22
|
-
"./spa": {
|
|
23
|
-
"entrypoint": "./src/spa.ts",
|
|
24
|
-
"types": "./dist/spa.d.ts",
|
|
25
|
-
"browser": "./dist/spa.bundle.js",
|
|
26
|
-
"import": "./dist/spa.js"
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
"imports": {
|
|
30
|
-
"#src/*.js": "./src/*.ts"
|
|
31
|
-
},
|
|
32
|
-
"files": [
|
|
33
|
-
"dist",
|
|
34
|
-
"CHANGELOG.md",
|
|
35
|
-
"buildinfo.txt",
|
|
36
|
-
"assets"
|
|
37
|
-
],
|
|
38
|
-
"scripts": {
|
|
39
|
-
"clean:dist": "rm -rf dist/",
|
|
40
|
-
"clean:tsbuildinfo": "rm -f tsconfig.build.tsbuildinfo",
|
|
41
|
-
"clean": "bun run clean:dist && bun run clean:tsbuildinfo",
|
|
42
|
-
"prebuild": "bun run scripts/buildinfo.ts",
|
|
43
|
-
"tests": "bun test",
|
|
44
|
-
"build": "bun run build:lib && bun run build:lib-bundle",
|
|
45
|
-
"build:lib": "tsc --project tsconfig.build.json",
|
|
46
|
-
"build:lib-bundle": "bun run scripts/build-lib-bundle.ts",
|
|
47
|
-
"typecheck": "tsc --noEmit",
|
|
48
|
-
"dev": "bun run --watch src/dev.ts"
|
|
49
|
-
},
|
|
50
|
-
"devDependencies": {
|
|
51
|
-
"@types/bun": "latest",
|
|
52
|
-
"typescript": "^6.0.2",
|
|
53
|
-
"hono": "^4.12.5"
|
|
54
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "",
|
|
3
|
+
"version": "0.0.0+FE",
|
|
4
|
+
"description": "",
|
|
5
|
+
"author": "",
|
|
6
|
+
"license": "",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"typescript"
|
|
9
|
+
],
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": ""
|
|
13
|
+
},
|
|
14
|
+
"type": "module",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"entrypoint": "./src/index.ts",
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"browser": "./dist/index.bundle.js",
|
|
20
|
+
"import": "./dist/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./spa": {
|
|
23
|
+
"entrypoint": "./src/spa.ts",
|
|
24
|
+
"types": "./dist/spa.d.ts",
|
|
25
|
+
"browser": "./dist/spa.bundle.js",
|
|
26
|
+
"import": "./dist/spa.js"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"imports": {
|
|
30
|
+
"#src/*.js": "./src/*.ts"
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"dist",
|
|
34
|
+
"CHANGELOG.md",
|
|
35
|
+
"buildinfo.txt",
|
|
36
|
+
"assets"
|
|
37
|
+
],
|
|
38
|
+
"scripts": {
|
|
39
|
+
"clean:dist": "rm -rf dist/",
|
|
40
|
+
"clean:tsbuildinfo": "rm -f tsconfig.tsbuildinfo tsconfig.build.tsbuildinfo",
|
|
41
|
+
"clean": "bun run clean:dist && bun run clean:tsbuildinfo",
|
|
42
|
+
"prebuild": "bun run scripts/buildinfo.ts",
|
|
43
|
+
"tests": "bun test",
|
|
44
|
+
"build": "bun run build:lib && bun run build:lib-bundle",
|
|
45
|
+
"build:lib": "tsc --project tsconfig.build.json",
|
|
46
|
+
"build:lib-bundle": "bun run scripts/build-lib-bundle.ts",
|
|
47
|
+
"typecheck": "tsc --noEmit",
|
|
48
|
+
"dev": "bun run --watch src/dev.ts"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@types/bun": "latest",
|
|
52
|
+
"typescript": "^6.0.2",
|
|
53
|
+
"hono": "^4.12.5"
|
|
54
|
+
}
|
|
55
55
|
}
|