spindb 0.1.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/.claude/settings.local.json +20 -0
- package/.env.example +1 -0
- package/.prettierignore +4 -0
- package/.prettierrc +6 -0
- package/CLAUDE.md +162 -0
- package/README.md +204 -0
- package/TODO.md +66 -0
- package/bin/cli.js +7 -0
- package/eslint.config.js +18 -0
- package/package.json +52 -0
- package/seeds/mysql/sample-db.sql +22 -0
- package/seeds/postgres/sample-db.sql +27 -0
- package/src/bin/cli.ts +8 -0
- package/src/cli/commands/clone.ts +101 -0
- package/src/cli/commands/config.ts +215 -0
- package/src/cli/commands/connect.ts +106 -0
- package/src/cli/commands/create.ts +148 -0
- package/src/cli/commands/delete.ts +94 -0
- package/src/cli/commands/list.ts +69 -0
- package/src/cli/commands/menu.ts +675 -0
- package/src/cli/commands/restore.ts +161 -0
- package/src/cli/commands/start.ts +95 -0
- package/src/cli/commands/stop.ts +91 -0
- package/src/cli/index.ts +38 -0
- package/src/cli/ui/prompts.ts +197 -0
- package/src/cli/ui/spinner.ts +94 -0
- package/src/cli/ui/theme.ts +113 -0
- package/src/config/defaults.ts +49 -0
- package/src/config/paths.ts +53 -0
- package/src/core/binary-manager.ts +239 -0
- package/src/core/config-manager.ts +259 -0
- package/src/core/container-manager.ts +234 -0
- package/src/core/port-manager.ts +84 -0
- package/src/core/process-manager.ts +353 -0
- package/src/engines/base-engine.ts +103 -0
- package/src/engines/index.ts +46 -0
- package/src/engines/postgresql/binary-urls.ts +52 -0
- package/src/engines/postgresql/index.ts +298 -0
- package/src/engines/postgresql/restore.ts +173 -0
- package/src/types/index.ts +97 -0
- package/tsconfig.json +24 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Command } from 'commander'
|
|
2
|
+
import chalk from 'chalk'
|
|
3
|
+
import { containerManager } from '@/core/container-manager'
|
|
4
|
+
import { info, error } from '@/cli/ui/theme'
|
|
5
|
+
|
|
6
|
+
export const listCommand = new Command('list')
|
|
7
|
+
.alias('ls')
|
|
8
|
+
.description('List all containers')
|
|
9
|
+
.option('--json', 'Output as JSON')
|
|
10
|
+
.action(async (options: { json?: boolean }) => {
|
|
11
|
+
try {
|
|
12
|
+
const containers = await containerManager.list()
|
|
13
|
+
|
|
14
|
+
if (options.json) {
|
|
15
|
+
console.log(JSON.stringify(containers, null, 2))
|
|
16
|
+
return
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (containers.length === 0) {
|
|
20
|
+
console.log(info('No containers found. Create one with: spindb create'))
|
|
21
|
+
return
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Table header
|
|
25
|
+
console.log()
|
|
26
|
+
console.log(
|
|
27
|
+
chalk.gray(' ') +
|
|
28
|
+
chalk.bold.white('NAME'.padEnd(20)) +
|
|
29
|
+
chalk.bold.white('ENGINE'.padEnd(12)) +
|
|
30
|
+
chalk.bold.white('VERSION'.padEnd(10)) +
|
|
31
|
+
chalk.bold.white('PORT'.padEnd(8)) +
|
|
32
|
+
chalk.bold.white('STATUS'),
|
|
33
|
+
)
|
|
34
|
+
console.log(chalk.gray(' ' + '─'.repeat(60)))
|
|
35
|
+
|
|
36
|
+
// Table rows
|
|
37
|
+
for (const container of containers) {
|
|
38
|
+
const statusDisplay =
|
|
39
|
+
container.status === 'running'
|
|
40
|
+
? chalk.green('● running')
|
|
41
|
+
: chalk.gray('○ stopped')
|
|
42
|
+
|
|
43
|
+
console.log(
|
|
44
|
+
chalk.gray(' ') +
|
|
45
|
+
chalk.cyan(container.name.padEnd(20)) +
|
|
46
|
+
chalk.white(container.engine.padEnd(12)) +
|
|
47
|
+
chalk.yellow(container.version.padEnd(10)) +
|
|
48
|
+
chalk.green(String(container.port).padEnd(8)) +
|
|
49
|
+
statusDisplay,
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
console.log()
|
|
54
|
+
|
|
55
|
+
// Summary
|
|
56
|
+
const running = containers.filter((c) => c.status === 'running').length
|
|
57
|
+
const stopped = containers.filter((c) => c.status !== 'running').length
|
|
58
|
+
console.log(
|
|
59
|
+
chalk.gray(
|
|
60
|
+
` ${containers.length} container(s): ${running} running, ${stopped} stopped`,
|
|
61
|
+
),
|
|
62
|
+
)
|
|
63
|
+
console.log()
|
|
64
|
+
} catch (err) {
|
|
65
|
+
const e = err as Error
|
|
66
|
+
console.error(error(e.message))
|
|
67
|
+
process.exit(1)
|
|
68
|
+
}
|
|
69
|
+
})
|