galbe 0.12.1 → 0.13.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.
- package/bin/commands/generate/code/openapi.parser.ts +18 -11
- package/bin/commands/generate/index.ts +3 -1
- package/bin/commands/generate/model.ts +153 -0
- package/bin/commands/generate/spec.ts +7 -5
- package/bin/util.ts +9 -0
- package/package.json +8 -4
- package/src/types.ts +1 -1
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -35
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -23
- package/.github/workflows/build_test.yml +0 -17
- package/.github/workflows/deploy_website.yml +0 -20
- package/.github/workflows/release.yml +0 -39
- package/.prettierrc +0 -10
- package/bun.lock +0 -904
- package/bunfig.toml +0 -2
- package/docs/CONTRIBUTING.md +0 -105
- package/docs/cli.md +0 -343
- package/docs/configuration.md +0 -80
- package/docs/context.md +0 -104
- package/docs/error-handler.md +0 -54
- package/docs/getting-started.md +0 -164
- package/docs/handler.md +0 -119
- package/docs/hooks.md +0 -90
- package/docs/plugins.md +0 -146
- package/docs/router.md +0 -10
- package/docs/routes.md +0 -133
- package/docs/schemas.md +0 -327
- package/test/hooks.test.ts +0 -200
- package/test/parser.test.ts +0 -1358
- package/test/plugins.test.ts +0 -239
- package/test/requests.test.ts +0 -917
- package/test/resources/image.png +0 -0
- package/test/resources/object.badSyntax.json +0 -8
- package/test/resources/object.json +0 -8
- package/test/resources/object.missing.json +0 -6
- package/test/resources/static/chameleon.png +0 -0
- package/test/resources/static/index.html +0 -13
- package/test/resources/static/sub/index.html +0 -13
- package/test/resources/static/sub/other.html +0 -13
- package/test/resources/test.route.comment.ts +0 -58
- package/test/resources/test.route.empty.ts +0 -9
- package/test/responses.test.ts +0 -483
- package/test/routeFiles.test.ts +0 -239
- package/test/router.test.ts +0 -231
- package/test/test.utils.ts +0 -109
- package/test/types.test.ts +0 -909
- package/tsconfig.json +0 -23
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { semver } from 'bun'
|
|
2
2
|
import { transformSync } from '@swc/core'
|
|
3
3
|
import { resolve, relative, dirname } from 'path'
|
|
4
|
-
import { load as ymlLoad } from 'js-yaml'
|
|
5
4
|
import { OpenAPIV3 } from 'openapi-types'
|
|
6
5
|
import { inferBodyType } from '../../../../src/util'
|
|
7
6
|
|
|
@@ -125,8 +124,6 @@ const parseOapiSchema = (
|
|
|
125
124
|
let optArg = hasOptions ? serialize(options) : ''
|
|
126
125
|
let anyOf = os.oneOf || os.anyOf
|
|
127
126
|
let allOf = os.allOf
|
|
128
|
-
let required = os.required
|
|
129
|
-
let nullable = os.nullable
|
|
130
127
|
|
|
131
128
|
if (os.discriminator) {
|
|
132
129
|
const propName = os.discriminator.propertyName
|
|
@@ -176,7 +173,11 @@ const parseOapiSchema = (
|
|
|
176
173
|
resp = `$T.integer(${hasOptions ? serialize(options) : ''})`
|
|
177
174
|
} else if (os.type === 'string') {
|
|
178
175
|
if (os.format === 'binary') resp = `$T.byteArray(${hasOptions ? serialize(options) : ''})`
|
|
179
|
-
else {
|
|
176
|
+
else if (os.enum?.length === 1) {
|
|
177
|
+
resp = `$T.literal("${os.enum[0]}")`
|
|
178
|
+
} else if (os.enum?.length) {
|
|
179
|
+
resp = `$T.union([${os.enum.map(v => `$T.literal("${v}")`).join(', ')}])`
|
|
180
|
+
} else {
|
|
180
181
|
let minLength = os.minLength
|
|
181
182
|
let maxLength = os.maxLength
|
|
182
183
|
let pattern = os.pattern
|
|
@@ -192,7 +193,16 @@ const parseOapiSchema = (
|
|
|
192
193
|
resp = `$T.array(${parseOapiSchema(os?.items)}, ${optArg})`
|
|
193
194
|
} else if (os.type === 'object') {
|
|
194
195
|
let props = Object.entries(os?.properties || {})
|
|
195
|
-
.map(([k, v]) =>
|
|
196
|
+
.map(([k, v]) => {
|
|
197
|
+
v = v as OpenAPIV3.SchemaObject
|
|
198
|
+
const w = (s: string) => {
|
|
199
|
+
if (!v.required && v.nullable) return `$T.nullish(${s})`
|
|
200
|
+
else if (!v.required) return `$T.optional(${s})`
|
|
201
|
+
else if (v.nullable) return `$T.nullable(${s})`
|
|
202
|
+
return s
|
|
203
|
+
}
|
|
204
|
+
return `"${k}":${w(parseOapiSchema(v))}`
|
|
205
|
+
})
|
|
196
206
|
.join(',')
|
|
197
207
|
if (extra?.media === 'multipart/form-data') {
|
|
198
208
|
resp = `$T.multipartForm({${props}}${optArg ? `, ${optArg}` : ''})`
|
|
@@ -203,10 +213,6 @@ const parseOapiSchema = (
|
|
|
203
213
|
}
|
|
204
214
|
} else throw new Error(`Unknown schema type ${JSON.stringify(os)}`)
|
|
205
215
|
|
|
206
|
-
if (!required && nullable) resp = `$T.nullish(${resp})`
|
|
207
|
-
else if (!required) resp = `$T.optional(${resp})`
|
|
208
|
-
else if (nullable) resp = `$T.nullable(${resp})`
|
|
209
|
-
|
|
210
216
|
return resp
|
|
211
217
|
}
|
|
212
218
|
|
|
@@ -452,7 +458,7 @@ const writeFiles = async (
|
|
|
452
458
|
imports[depOrig].push(depName)
|
|
453
459
|
}
|
|
454
460
|
}
|
|
455
|
-
decl.push(`export const ${s.key} = ${s.schema}\nexport type
|
|
461
|
+
decl.push(`export const ${s.key} = ${s.schema}\nexport type ${s.key} = Static<typeof ${s.key}>\n`)
|
|
456
462
|
})
|
|
457
463
|
if (decl.length === 0) return ''
|
|
458
464
|
return `import type { Static } from 'galbe/schema'\nimport { $T } from 'galbe'\n${Object.entries(imports)
|
|
@@ -539,7 +545,8 @@ export const generateFromOapi = async (
|
|
|
539
545
|
out: string,
|
|
540
546
|
{ version, ext, target }: { version: string; ext: 'json' | 'yaml'; target: 'js' | 'ts' }
|
|
541
547
|
) => {
|
|
542
|
-
let def: OpenAPIV3.Document =
|
|
548
|
+
let def: OpenAPIV3.Document =
|
|
549
|
+
ext === 'json' ? await Bun.file(input).json() : Bun.YAML.parse(await Bun.file(input).text())
|
|
543
550
|
|
|
544
551
|
let v = def?.openapi
|
|
545
552
|
if (!v || !semver.satisfies(v, version)) throw new Error('Invalid openapi version')
|
|
@@ -3,10 +3,12 @@ import { Command } from 'commander'
|
|
|
3
3
|
import client from './client'
|
|
4
4
|
import spec from './spec'
|
|
5
5
|
import code from './code'
|
|
6
|
+
import model from './model'
|
|
6
7
|
|
|
7
8
|
export default (cmd: Command) => {
|
|
8
9
|
cmd.description('generate util')
|
|
9
|
-
client(cmd.command('client'))
|
|
10
10
|
spec(cmd.command('spec'))
|
|
11
|
+
client(cmd.command('client'))
|
|
11
12
|
code(cmd.command('code'))
|
|
13
|
+
model(cmd.command('model'))
|
|
12
14
|
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { Command, Option } from 'commander'
|
|
2
|
+
import { fmtVal, toPascalCase } from '../../util'
|
|
3
|
+
import { SQL } from 'bun'
|
|
4
|
+
import { mkdirSync } from 'fs'
|
|
5
|
+
import path from 'path'
|
|
6
|
+
|
|
7
|
+
const TYPE_MAP: Record<string, string> = {
|
|
8
|
+
// --- Postgres + MySQL numerics ---
|
|
9
|
+
smallint: 'number',
|
|
10
|
+
integer: 'number',
|
|
11
|
+
int: 'number',
|
|
12
|
+
int2: 'number',
|
|
13
|
+
int4: 'number',
|
|
14
|
+
int8: 'number',
|
|
15
|
+
bigint: 'bigint', // or 'number' ?
|
|
16
|
+
decimal: 'number',
|
|
17
|
+
numeric: 'number',
|
|
18
|
+
real: 'number',
|
|
19
|
+
float: 'number',
|
|
20
|
+
float4: 'number',
|
|
21
|
+
float8: 'number',
|
|
22
|
+
double: 'number',
|
|
23
|
+
'double precision': 'number',
|
|
24
|
+
serial: 'number',
|
|
25
|
+
bigserial: 'number',
|
|
26
|
+
smallserial: 'number',
|
|
27
|
+
tinyint: 'number',
|
|
28
|
+
mediumint: 'number',
|
|
29
|
+
bit: 'number',
|
|
30
|
+
|
|
31
|
+
// --- Strings ---
|
|
32
|
+
text: 'string',
|
|
33
|
+
'character varying': 'string',
|
|
34
|
+
varchar: 'string',
|
|
35
|
+
character: 'string',
|
|
36
|
+
char: 'string',
|
|
37
|
+
citext: 'string',
|
|
38
|
+
enum: 'string',
|
|
39
|
+
set: 'string',
|
|
40
|
+
tinytext: 'string',
|
|
41
|
+
mediumtext: 'string',
|
|
42
|
+
longtext: 'string',
|
|
43
|
+
|
|
44
|
+
// --- Binary ---
|
|
45
|
+
bytea: 'Buffer',
|
|
46
|
+
blob: 'Buffer',
|
|
47
|
+
tinyblob: 'Buffer',
|
|
48
|
+
mediumblob: 'Buffer',
|
|
49
|
+
longblob: 'Buffer',
|
|
50
|
+
binary: 'Buffer',
|
|
51
|
+
varbinary: 'Buffer',
|
|
52
|
+
|
|
53
|
+
// --- Booleans ---
|
|
54
|
+
boolean: 'boolean',
|
|
55
|
+
|
|
56
|
+
// --- Date/Time ---
|
|
57
|
+
date: 'Date | string',
|
|
58
|
+
datetime: 'Date | string',
|
|
59
|
+
timestamp: 'Date | string',
|
|
60
|
+
'timestamp without time zone': 'Date | string',
|
|
61
|
+
'timestamp with time zone': 'Date | string',
|
|
62
|
+
time: 'string',
|
|
63
|
+
'time without time zone': 'string',
|
|
64
|
+
'time with time zone': 'string',
|
|
65
|
+
interval: 'string',
|
|
66
|
+
year: 'number',
|
|
67
|
+
|
|
68
|
+
// --- JSON ---
|
|
69
|
+
json: 'any',
|
|
70
|
+
jsonb: 'any',
|
|
71
|
+
|
|
72
|
+
// --- UUID ---
|
|
73
|
+
uuid: 'string',
|
|
74
|
+
|
|
75
|
+
// --- Spatial / geometric ---
|
|
76
|
+
point: 'any',
|
|
77
|
+
line: 'any',
|
|
78
|
+
lseg: 'any',
|
|
79
|
+
box: 'any',
|
|
80
|
+
path: 'any',
|
|
81
|
+
polygon: 'any',
|
|
82
|
+
circle: 'any',
|
|
83
|
+
geometry: 'any',
|
|
84
|
+
linestring: 'any',
|
|
85
|
+
multipoint: 'any',
|
|
86
|
+
multilinestring: 'any',
|
|
87
|
+
multipolygon: 'any',
|
|
88
|
+
geometrycollection: 'any',
|
|
89
|
+
|
|
90
|
+
// --- Other ---
|
|
91
|
+
xml: 'string',
|
|
92
|
+
money: 'string',
|
|
93
|
+
tsvector: 'string',
|
|
94
|
+
tsquery: 'string',
|
|
95
|
+
inet: 'string',
|
|
96
|
+
cidr: 'string',
|
|
97
|
+
macaddr: 'string',
|
|
98
|
+
macaddr8: 'string',
|
|
99
|
+
array: 'any[]',
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export default (cmd: Command) => {
|
|
103
|
+
cmd
|
|
104
|
+
.description('generate TypeScript types from a database')
|
|
105
|
+
.addOption(
|
|
106
|
+
new Option(
|
|
107
|
+
'-u, --url <connection_url>',
|
|
108
|
+
`database connection url (ex. ${fmtVal('postgres://postgres:secret@localhost:5432')})`
|
|
109
|
+
).makeOptionMandatory()
|
|
110
|
+
)
|
|
111
|
+
.addOption(new Option('-t, --table <table_name>', `table name (ex. users or public.users)`))
|
|
112
|
+
.addOption(new Option('-s, --schema <schema_name>', `schema name (ex. public)`).default('public', fmtVal('public')))
|
|
113
|
+
.addOption(new Option('-o, --out <dir|file>', 'output dir or file').default('.', fmtVal('.')))
|
|
114
|
+
.addOption(new Option('-F, --force', 'force overriding output'))
|
|
115
|
+
.action(async props => {
|
|
116
|
+
const { url, table, schema, out, force } = props
|
|
117
|
+
|
|
118
|
+
const db = new SQL({ url })
|
|
119
|
+
let tables: string[] = []
|
|
120
|
+
let types: Record<string, string> = {}
|
|
121
|
+
|
|
122
|
+
if (table) tables = [table]
|
|
123
|
+
else {
|
|
124
|
+
const r = await db.unsafe(`SELECT table_name
|
|
125
|
+
FROM information_schema.tables
|
|
126
|
+
WHERE table_schema = '${schema}'
|
|
127
|
+
AND table_type = 'BASE TABLE'`)
|
|
128
|
+
tables = r.map(r => r.table_name)
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
for (const tableName of tables) {
|
|
132
|
+
const t = await db.unsafe(`SELECT column_name, data_type, is_nullable
|
|
133
|
+
FROM information_schema.columns
|
|
134
|
+
WHERE table_schema = '${schema}' AND table_name = '${tableName}'`)
|
|
135
|
+
types[tableName] = `type ${toPascalCase(tableName)} = {\n${t
|
|
136
|
+
.map(r => ` ${r.column_name}: ${TYPE_MAP?.[r.data_type] ?? 'any'}${r.is_nullable ? ' | null' : ''}`)
|
|
137
|
+
.join(';\n')}\n}`
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
mkdirSync(path.dirname(out), { recursive: true })
|
|
141
|
+
|
|
142
|
+
if (path.extname(out) === '.ts') {
|
|
143
|
+
await Bun.write(
|
|
144
|
+
out,
|
|
145
|
+
Object.values(types).map(type => `export ${type}\n`)
|
|
146
|
+
)
|
|
147
|
+
} else {
|
|
148
|
+
for (const [tableName, type] of Object.entries(types)) {
|
|
149
|
+
await Bun.write(`${out}/${tableName}.ts`, `export ${type}\n`)
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
})
|
|
153
|
+
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Command, Option } from 'commander'
|
|
2
2
|
import { resolve, relative, extname } from 'path'
|
|
3
|
-
import { dump as ymlDump, load as ymlLoad } from 'js-yaml'
|
|
4
3
|
import { CWD, fmtList, instanciateRoutes, silentExec } from '../../util'
|
|
5
4
|
import { Galbe } from '../../../src'
|
|
6
5
|
import { OpenAPISerializer } from '../../../src/extras'
|
|
@@ -47,7 +46,7 @@ export default (cmd: Command) => {
|
|
|
47
46
|
if (base) {
|
|
48
47
|
let ext = extname(base)
|
|
49
48
|
let rd = (str: string) =>
|
|
50
|
-
ext === '.json' ? JSON.parse(str) : ['.yml', '.yaml'].includes(ext) ?
|
|
49
|
+
ext === '.json' ? JSON.parse(str) : ['.yml', '.yaml'].includes(ext) ? Bun.YAML.parse(str) : null
|
|
51
50
|
baseSpec = rd(await Bun.file(relative(CWD, base)).text())
|
|
52
51
|
}
|
|
53
52
|
|
|
@@ -84,11 +83,14 @@ export default (cmd: Command) => {
|
|
|
84
83
|
description: pckg?.description,
|
|
85
84
|
contact: parseAuthor(pckg.author),
|
|
86
85
|
//license: TODO
|
|
87
|
-
version: pckg?.version || '0.1.0'
|
|
88
|
-
}
|
|
86
|
+
version: pckg?.version || '0.1.0',
|
|
87
|
+
},
|
|
89
88
|
}
|
|
90
89
|
openapiSpec = softMerge(openapiSpec, baseSpec) as OpenAPIV3.Document
|
|
91
|
-
Bun.write(
|
|
90
|
+
Bun.write(
|
|
91
|
+
resolve(CWD, out),
|
|
92
|
+
tFormat === 'json' ? JSON.stringify(openapiSpec, null, 2) : Bun.YAML.stringify(openapiSpec, null, 2)
|
|
93
|
+
)
|
|
92
94
|
}
|
|
93
95
|
|
|
94
96
|
Bun.write(Bun.stdout, ' : \x1b[1;30m\x1b[32mdone\x1b[0m\n')
|
package/bin/util.ts
CHANGED
|
@@ -194,3 +194,12 @@ export const HttpStatus = {
|
|
|
194
194
|
507: 'Insufficient Storage',
|
|
195
195
|
511: 'Network Authentication Required',
|
|
196
196
|
}
|
|
197
|
+
|
|
198
|
+
export const toPascalCase = (input: string) =>
|
|
199
|
+
input
|
|
200
|
+
.replace(/([a-z0-9])([A-Z])/g, '$1 $2')
|
|
201
|
+
.replace(/[^a-zA-Z0-9]+/g, ' ')
|
|
202
|
+
.trim()
|
|
203
|
+
.split(/\s+/)
|
|
204
|
+
.map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
|
|
205
|
+
.join('')
|
package/package.json
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "galbe",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "Fast, lightweight and highly customizable JavaScript web framework based on Bun",
|
|
5
5
|
"author": "Pierre Caillaud M (https://github.com/pierre-cm)",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"bin": "./bin/cli.ts",
|
|
8
8
|
"main": "./src/index.ts",
|
|
9
|
+
"files": [
|
|
10
|
+
"bin/",
|
|
11
|
+
"scripts/",
|
|
12
|
+
"src/"
|
|
13
|
+
],
|
|
9
14
|
"exports": {
|
|
10
15
|
".": "./src/index.ts",
|
|
11
16
|
"./schema": "./src/schema.ts",
|
|
@@ -34,7 +39,7 @@
|
|
|
34
39
|
"release": "release-it"
|
|
35
40
|
},
|
|
36
41
|
"devDependencies": {
|
|
37
|
-
"@types/bun": "^1.
|
|
42
|
+
"@types/bun": "^1.2.22",
|
|
38
43
|
"openapi-types": "^12.1.3",
|
|
39
44
|
"release-it": "^17.1.1"
|
|
40
45
|
},
|
|
@@ -47,8 +52,7 @@
|
|
|
47
52
|
"acorn": "^8.11.2",
|
|
48
53
|
"acorn-walk": "^8.3.0",
|
|
49
54
|
"chokidar": "^3.6.0",
|
|
50
|
-
"commander": "^11.1.0"
|
|
51
|
-
"js-yaml": "^4.1.0"
|
|
55
|
+
"commander": "^11.1.0"
|
|
52
56
|
},
|
|
53
57
|
"release-it": {
|
|
54
58
|
"git": {
|
package/src/types.ts
CHANGED
|
@@ -269,7 +269,7 @@ export class RequestError {
|
|
|
269
269
|
payload?: any
|
|
270
270
|
headers?: Record<string, string>
|
|
271
271
|
constructor(options: { status?: number; payload?: any; headers?: Record<string, string> }) {
|
|
272
|
-
this.status = options.status ??
|
|
272
|
+
this.status = options.status ?? 400
|
|
273
273
|
this.payload = options.payload
|
|
274
274
|
this.headers = options.headers
|
|
275
275
|
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: Bug report
|
|
3
|
-
about: Create a report to help us improve
|
|
4
|
-
title: '[bug] '
|
|
5
|
-
labels: bug
|
|
6
|
-
assignees: ''
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
**Describe the bug**
|
|
10
|
-
|
|
11
|
-
<!-- A clear and concise description of what the bug is. -->
|
|
12
|
-
|
|
13
|
-
**Steps To Reproduce**
|
|
14
|
-
|
|
15
|
-
<!-- Steps to reproduce the behavior -->
|
|
16
|
-
|
|
17
|
-
**Expected behavior**
|
|
18
|
-
|
|
19
|
-
<!-- A clear and concise description of what you expected to happen. -->
|
|
20
|
-
|
|
21
|
-
**Screenshots**
|
|
22
|
-
|
|
23
|
-
<!-- If applicable, add screenshots to help explain your problem. -->
|
|
24
|
-
|
|
25
|
-
**Environment (please complete the following information):**
|
|
26
|
-
|
|
27
|
-
<!-- To help us diagnose the issue, please navigate to the root of your project in your terminal and execute "bunx galbe info". Then paste the output bellow -->
|
|
28
|
-
|
|
29
|
-
```txt
|
|
30
|
-
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
**Additional context**
|
|
34
|
-
|
|
35
|
-
<!-- Add any other context about the problem here. -->
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: Feature request
|
|
3
|
-
about: Suggest an idea for this project
|
|
4
|
-
title: '[feat] '
|
|
5
|
-
labels: enhancement
|
|
6
|
-
assignees: ''
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
**Is your feature request related to a problem? Please describe.**
|
|
10
|
-
|
|
11
|
-
<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->
|
|
12
|
-
|
|
13
|
-
**Describe the solution you'd like**
|
|
14
|
-
|
|
15
|
-
<!-- A clear and concise description of what you want to happen. -->
|
|
16
|
-
|
|
17
|
-
**Describe alternatives you've considered**
|
|
18
|
-
|
|
19
|
-
<!-- A clear and concise description of any alternative solutions or features you've considered. -->
|
|
20
|
-
|
|
21
|
-
**Additional context**
|
|
22
|
-
|
|
23
|
-
<!-- Add any other context or screenshots about the feature request here. -->
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
name: Install & Test
|
|
2
|
-
on:
|
|
3
|
-
push:
|
|
4
|
-
pull_request:
|
|
5
|
-
jobs:
|
|
6
|
-
build:
|
|
7
|
-
name: Install & Test
|
|
8
|
-
runs-on: ubuntu-latest
|
|
9
|
-
steps:
|
|
10
|
-
- uses: actions/checkout@v4
|
|
11
|
-
- uses: oven-sh/setup-bun@v1
|
|
12
|
-
with:
|
|
13
|
-
bun-version: latest
|
|
14
|
-
- name: Install
|
|
15
|
-
run: bun install
|
|
16
|
-
- name: Test
|
|
17
|
-
run: bun test
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
name: Redeploy website
|
|
2
|
-
on:
|
|
3
|
-
push:
|
|
4
|
-
branches: [main]
|
|
5
|
-
paths:
|
|
6
|
-
- 'docs/**'
|
|
7
|
-
jobs:
|
|
8
|
-
redeploy_website:
|
|
9
|
-
name: Update website with new doc
|
|
10
|
-
runs-on: ubuntu-latest
|
|
11
|
-
steps:
|
|
12
|
-
- name: Trigger website deployment
|
|
13
|
-
run: |
|
|
14
|
-
curl -L \
|
|
15
|
-
-X POST \
|
|
16
|
-
-H "Accept: application/vnd.github+json" \
|
|
17
|
-
-H "Authorization: Bearer ${{ secrets.GH_WEBSITE_TOKEN }}" \
|
|
18
|
-
-H "X-GitHub-Api-Version: 2022-11-28" \
|
|
19
|
-
https://api.github.com/repos/pierre-cm/galbe-website/actions/workflows/static.yml/dispatches \
|
|
20
|
-
-d '{"ref":"main"}'
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
name: Release
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
workflow_dispatch:
|
|
5
|
-
inputs:
|
|
6
|
-
scope:
|
|
7
|
-
description: 'Version bump scope (patch, minor, major)'
|
|
8
|
-
required: true
|
|
9
|
-
|
|
10
|
-
jobs:
|
|
11
|
-
release:
|
|
12
|
-
runs-on: ubuntu-latest
|
|
13
|
-
env:
|
|
14
|
-
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
|
|
15
|
-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
16
|
-
RELEASE_SCOPE: ${{ github.event.inputs.scope }}
|
|
17
|
-
steps:
|
|
18
|
-
- name: Checkout repository
|
|
19
|
-
uses: actions/checkout@v4
|
|
20
|
-
- name: Setup Bun
|
|
21
|
-
uses: oven-sh/setup-bun@v1
|
|
22
|
-
with:
|
|
23
|
-
bun-version: latest
|
|
24
|
-
registry-url: https://registry.npmjs.org
|
|
25
|
-
- name: Setup SSH
|
|
26
|
-
uses: webfactory/ssh-agent@v0.8.0
|
|
27
|
-
with:
|
|
28
|
-
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
|
|
29
|
-
- name: Setup Git
|
|
30
|
-
run: |
|
|
31
|
-
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
|
|
32
|
-
git config user.name "${GITHUB_ACTOR}"
|
|
33
|
-
- name: Install dependencies
|
|
34
|
-
run: |
|
|
35
|
-
bun install
|
|
36
|
-
- name: Release
|
|
37
|
-
run: |
|
|
38
|
-
npm config set //registry.npmjs.org/:_authToken $NPM_TOKEN
|
|
39
|
-
bun run release --increment $RELEASE_SCOPE --ci --no-git.requireCleanWorkingDir
|