@sqaoss/flowy 1.1.1 → 1.1.2
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/docker-compose.yml +22 -8
- package/package.json +1 -1
- package/server/Dockerfile +5 -11
- package/src/commands/setup.ts +42 -14
- package/src/index.ts +13 -2
package/docker-compose.yml
CHANGED
|
@@ -1,14 +1,28 @@
|
|
|
1
1
|
services:
|
|
2
2
|
server:
|
|
3
|
-
build:
|
|
3
|
+
build:
|
|
4
|
+
context: .
|
|
5
|
+
dockerfile_inline: |
|
|
6
|
+
FROM oven/bun:1.3.11
|
|
7
|
+
WORKDIR /app
|
|
8
|
+
RUN bun init -y && bun add @sqaoss/flowy
|
|
9
|
+
WORKDIR /app/node_modules/@sqaoss/flowy/server
|
|
10
|
+
RUN bun install --production
|
|
11
|
+
EXPOSE 4000
|
|
12
|
+
VOLUME /data
|
|
13
|
+
CMD ["bun", "src/index.ts"]
|
|
4
14
|
ports:
|
|
5
15
|
- "4000:4000"
|
|
16
|
+
volumes:
|
|
17
|
+
- flowy-data:/data
|
|
6
18
|
environment:
|
|
7
|
-
-
|
|
8
|
-
|
|
19
|
+
- FLOWY_DB_PATH=/data/flowy.sqlite
|
|
20
|
+
- PORT=4000
|
|
9
21
|
healthcheck:
|
|
10
|
-
test: ["CMD", "bun", "-e", "
|
|
11
|
-
interval:
|
|
12
|
-
timeout:
|
|
13
|
-
retries:
|
|
14
|
-
|
|
22
|
+
test: ["CMD", "bun", "-e", "fetch('http://localhost:4000/health').then(r => r.ok ? process.exit(0) : process.exit(1))"]
|
|
23
|
+
interval: 5s
|
|
24
|
+
timeout: 3s
|
|
25
|
+
retries: 5
|
|
26
|
+
|
|
27
|
+
volumes:
|
|
28
|
+
flowy-data:
|
package/package.json
CHANGED
package/server/Dockerfile
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
FROM oven/bun:1.3.11
|
|
1
|
+
FROM oven/bun:1.3.11
|
|
2
2
|
WORKDIR /app
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
RUN bun install --frozen-lockfile --production
|
|
7
|
-
|
|
8
|
-
FROM base
|
|
9
|
-
COPY --from=install /app/node_modules node_modules
|
|
10
|
-
COPY src src
|
|
11
|
-
COPY tsconfig.json .
|
|
12
|
-
|
|
3
|
+
RUN bun init -y && bun add @sqaoss/flowy
|
|
4
|
+
WORKDIR /app/node_modules/@sqaoss/flowy/server
|
|
5
|
+
RUN bun install --production
|
|
13
6
|
EXPOSE 4000
|
|
7
|
+
VOLUME /data
|
|
14
8
|
CMD ["bun", "src/index.ts"]
|
package/src/commands/setup.ts
CHANGED
|
@@ -1,22 +1,50 @@
|
|
|
1
1
|
import { spawnSync } from 'node:child_process'
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { mkdirSync, writeFileSync } from 'node:fs'
|
|
3
|
+
import { homedir } from 'node:os'
|
|
4
|
+
import { resolve } from 'node:path'
|
|
5
5
|
import { Command } from 'commander'
|
|
6
6
|
import { loadConfig, saveConfig } from '../util/config.ts'
|
|
7
7
|
import { output, outputError } from '../util/format.ts'
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
const COMPOSE_CONTENT = `services:
|
|
10
|
+
server:
|
|
11
|
+
build:
|
|
12
|
+
context: .
|
|
13
|
+
dockerfile_inline: |
|
|
14
|
+
FROM oven/bun:1.3.11
|
|
15
|
+
WORKDIR /app
|
|
16
|
+
RUN bun init -y && bun add @sqaoss/flowy
|
|
17
|
+
WORKDIR /app/node_modules/@sqaoss/flowy/server
|
|
18
|
+
RUN bun install --production
|
|
19
|
+
EXPOSE 4000
|
|
20
|
+
VOLUME /data
|
|
21
|
+
CMD ["bun", "src/index.ts"]
|
|
22
|
+
ports:
|
|
23
|
+
- "4000:4000"
|
|
24
|
+
volumes:
|
|
25
|
+
- flowy-data:/data
|
|
26
|
+
environment:
|
|
27
|
+
- FLOWY_DB_PATH=/data/flowy.sqlite
|
|
28
|
+
- PORT=4000
|
|
29
|
+
healthcheck:
|
|
30
|
+
test: ["CMD", "bun", "-e", "fetch('http://localhost:4000/health').then(r => r.ok ? process.exit(0) : process.exit(1))"]
|
|
31
|
+
interval: 5s
|
|
32
|
+
timeout: 3s
|
|
33
|
+
retries: 5
|
|
34
|
+
|
|
35
|
+
volumes:
|
|
36
|
+
flowy-data:
|
|
37
|
+
`
|
|
38
|
+
|
|
39
|
+
function ensureComposeFile(): string {
|
|
40
|
+
const dir = resolve(homedir(), '.config', 'flowy')
|
|
41
|
+
mkdirSync(dir, { recursive: true })
|
|
42
|
+
const composePath = resolve(dir, 'docker-compose.yml')
|
|
43
|
+
writeFileSync(composePath, COMPOSE_CONTENT)
|
|
44
|
+
return composePath
|
|
17
45
|
}
|
|
18
46
|
|
|
19
|
-
async function pollHealth(url: string, timeoutMs =
|
|
47
|
+
async function pollHealth(url: string, timeoutMs = 60_000): Promise<void> {
|
|
20
48
|
const start = Date.now()
|
|
21
49
|
while (Date.now() - start < timeoutMs) {
|
|
22
50
|
try {
|
|
@@ -31,7 +59,7 @@ async function pollHealth(url: string, timeoutMs = 30_000): Promise<void> {
|
|
|
31
59
|
}
|
|
32
60
|
|
|
33
61
|
export const setupCommand = new Command('setup').description(
|
|
34
|
-
'Configure the Flowy CLI
|
|
62
|
+
'Configure the Flowy CLI \u2014 use "flowy setup local" or "flowy setup remote"',
|
|
35
63
|
)
|
|
36
64
|
|
|
37
65
|
setupCommand
|
|
@@ -46,7 +74,7 @@ setupCommand
|
|
|
46
74
|
throw new Error('Docker is required but was not found.')
|
|
47
75
|
}
|
|
48
76
|
|
|
49
|
-
const composePath =
|
|
77
|
+
const composePath = ensureComposeFile()
|
|
50
78
|
spawnSync(
|
|
51
79
|
'docker',
|
|
52
80
|
['compose', '-f', composePath, 'up', '-d', '--build'],
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
|
+
import { readFileSync } from 'node:fs'
|
|
3
|
+
import { dirname, resolve } from 'node:path'
|
|
4
|
+
import { fileURLToPath } from 'node:url'
|
|
2
5
|
import { Command } from 'commander'
|
|
6
|
+
|
|
7
|
+
const pkgPath = resolve(
|
|
8
|
+
dirname(fileURLToPath(import.meta.url)),
|
|
9
|
+
'..',
|
|
10
|
+
'package.json',
|
|
11
|
+
)
|
|
12
|
+
const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'))
|
|
13
|
+
|
|
3
14
|
import { approveCommand } from './commands/approve.ts'
|
|
4
15
|
import { clientCommand } from './commands/client.ts'
|
|
5
16
|
import { featureCommand } from './commands/feature.ts'
|
|
@@ -14,8 +25,8 @@ import { whoamiCommand } from './commands/whoami.ts'
|
|
|
14
25
|
|
|
15
26
|
const program = new Command()
|
|
16
27
|
.name('flowy')
|
|
17
|
-
.description(
|
|
18
|
-
.version(
|
|
28
|
+
.description(pkg.description)
|
|
29
|
+
.version(pkg.version)
|
|
19
30
|
|
|
20
31
|
program.addCommand(initCommand)
|
|
21
32
|
program.addCommand(setupCommand)
|