galbe 0.1.1 → 0.1.4
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/cli.ts +9 -12
- package/package.json +1 -1
- package/scripts/postinstall.ts +2 -0
package/bin/cli.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { $, Glob } from 'bun'
|
|
4
4
|
import type { RouteMeta } from '../src/routes'
|
|
5
5
|
import { program } from 'commander'
|
|
6
6
|
import { relative, resolve } from 'path'
|
|
7
|
-
import { mkdir, readdir, rm } from 'fs/promises'
|
|
7
|
+
import { mkdir, readdir, lstat, rm } from 'fs/promises'
|
|
8
8
|
import { metaAnalysis } from '../src/routes'
|
|
9
9
|
import { randomUUID } from 'crypto'
|
|
10
|
-
import { glob } from 'glob'
|
|
11
10
|
import { Galbe } from '../src'
|
|
12
11
|
|
|
13
12
|
const ROOT = process.cwd()
|
|
@@ -19,22 +18,20 @@ const parseRoutes = async (routes?: string | string[]): Promise<{ path: string;
|
|
|
19
18
|
if (!routes) return []
|
|
20
19
|
let files: { path: string; meta: RouteMeta }[] = []
|
|
21
20
|
if (typeof routes === 'string') {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if (file.type === 'File') files.push({ path, meta: await metaAnalysis(path) })
|
|
26
|
-
else if (file.type === 'Directory') {
|
|
21
|
+
for await (const path of new Glob(routes).scan({ cwd: ROOT, absolute: true, onlyFiles: false })) {
|
|
22
|
+
const isDir = (await lstat(path)).isDirectory()
|
|
23
|
+
if (isDir) {
|
|
27
24
|
files = files.concat(
|
|
28
25
|
await Promise.all(
|
|
29
26
|
(
|
|
30
|
-
await readdir(
|
|
27
|
+
await readdir(path)
|
|
31
28
|
).map(async f => ({
|
|
32
|
-
path:
|
|
33
|
-
meta: await metaAnalysis(
|
|
29
|
+
path: f,
|
|
30
|
+
meta: await metaAnalysis(path)
|
|
34
31
|
}))
|
|
35
32
|
)
|
|
36
33
|
)
|
|
37
|
-
}
|
|
34
|
+
} else files.push({ path, meta: await metaAnalysis(path) })
|
|
38
35
|
}
|
|
39
36
|
}
|
|
40
37
|
if (Array.isArray(routes)) for (const r of routes) files = files.concat(await parseRoutes(r))
|
package/package.json
CHANGED