openpalm 0.2.0 → 0.2.6

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/src/main.ts DELETED
@@ -1,210 +0,0 @@
1
- #!/usr/bin/env bun
2
- import type { ContainerPlatform, InstallOptions, UninstallOptions } from "./types.ts";
3
- import { install } from "./commands/install.ts";
4
- import { uninstall } from "./commands/uninstall.ts";
5
- import { update } from "./commands/update.ts";
6
- import { start } from "./commands/start.ts";
7
- import { stop } from "./commands/stop.ts";
8
- import { restart } from "./commands/restart.ts";
9
- import { logs } from "./commands/logs.ts";
10
- import { status } from "./commands/status.ts";
11
- import { extensions } from "./commands/extensions.ts";
12
- import { preflight } from "./commands/preflight.ts";
13
- import { createChannel } from "./commands/create-channel.ts";
14
- import { log, error, bold, dim } from "@openpalm/lib/ui.ts";
15
- import pkg from "../package.json";
16
-
17
- const VERSION = pkg.version;
18
-
19
- function printHelp(): void {
20
- log(bold("openpalm") + dim(` v${VERSION}`));
21
- log("");
22
- log(bold("Usage:"));
23
- log(" openpalm <command> [options]");
24
- log("");
25
- log(bold("Commands:"));
26
- log(" install Install and start OpenPalm");
27
- log(" uninstall Stop and remove OpenPalm");
28
- log(" update Pull latest images and recreate containers");
29
- log(" start Start services");
30
- log(" stop Stop services");
31
- log(" restart Restart services");
32
- log(" logs View container logs");
33
- log(" status Show container status");
34
- log(" extensions Manage extensions (install, uninstall, list)");
35
- log(" dev Development helpers (preflight, create-channel)");
36
- log(" version Print version");
37
- log(" help Show this help");
38
- log("");
39
- log(bold("Install options:"));
40
- log(" --runtime <docker|podman|orbstack> Force container runtime");
41
- log(" --no-open Don't auto-open browser");
42
- log(" --ref <branch|tag> Git ref for asset download");
43
- log("");
44
- log(bold("Uninstall options:"));
45
- log(" --runtime <docker|podman|orbstack> Force container runtime");
46
- log(" --remove-all Remove all data/config/state");
47
- log(" --remove-images Remove container images");
48
- log(" --yes Skip confirmation prompts");
49
- log("");
50
- log(bold("Management commands accept optional service names:"));
51
- log(" openpalm start [service...]");
52
- log(" openpalm stop [service...]");
53
- log(" openpalm restart [service...]");
54
- log(" openpalm logs [service...]");
55
- log("");
56
- log(bold("Extensions:"));
57
- log(" openpalm extensions install --plugin <id>");
58
- log(" openpalm extensions uninstall --plugin <id>");
59
- log(" openpalm extensions list");
60
- }
61
-
62
- function parseArg(args: string[], name: string): string | undefined {
63
- const index = args.indexOf(`--${name}`);
64
- if (index >= 0 && index + 1 < args.length) {
65
- return args[index + 1];
66
- }
67
- return undefined;
68
- }
69
-
70
- function hasFlag(args: string[], name: string): boolean {
71
- return args.includes(`--${name}`);
72
- }
73
-
74
- function getPositionalArgs(args: string[]): string[] {
75
- const result: string[] = [];
76
- let i = 0;
77
- while (i < args.length) {
78
- if (args[i].startsWith("--")) {
79
- // Skip flag and its value if it has one
80
- const flagName = args[i].slice(2);
81
- if (["runtime", "ref", "plugin"].includes(flagName)) {
82
- i += 2; // skip flag + value
83
- } else {
84
- i += 1; // skip boolean flag
85
- }
86
- } else {
87
- result.push(args[i]);
88
- i += 1;
89
- }
90
- }
91
- return result;
92
- }
93
-
94
- async function main(): Promise<void> {
95
- const [command, ...args] = process.argv.slice(2);
96
-
97
- if (!command || command === "help" || command === "--help" || command === "-h") {
98
- printHelp();
99
- return;
100
- }
101
-
102
- if (command === "version" || command === "--version" || command === "-v") {
103
- log(`openpalm v${VERSION}`);
104
- return;
105
- }
106
-
107
- try {
108
- switch (command) {
109
- case "install": {
110
- const options: InstallOptions = {
111
- runtime: parseArg(args, "runtime") as ContainerPlatform | undefined,
112
- noOpen: hasFlag(args, "no-open"),
113
- ref: parseArg(args, "ref"),
114
- };
115
- await install(options);
116
- break;
117
- }
118
-
119
- case "uninstall": {
120
- const options: UninstallOptions = {
121
- runtime: parseArg(args, "runtime") as ContainerPlatform | undefined,
122
- removeAll: hasFlag(args, "remove-all"),
123
- removeImages: hasFlag(args, "remove-images"),
124
- yes: hasFlag(args, "yes"),
125
- };
126
- await uninstall(options);
127
- break;
128
- }
129
-
130
- case "update": {
131
- await update();
132
- break;
133
- }
134
-
135
- case "start": {
136
- const services = getPositionalArgs(args);
137
- await start(services.length > 0 ? services : undefined);
138
- break;
139
- }
140
-
141
- case "stop": {
142
- const services = getPositionalArgs(args);
143
- await stop(services.length > 0 ? services : undefined);
144
- break;
145
- }
146
-
147
- case "restart": {
148
- const services = getPositionalArgs(args);
149
- await restart(services.length > 0 ? services : undefined);
150
- break;
151
- }
152
-
153
- case "logs": {
154
- const services = getPositionalArgs(args);
155
- await logs(services.length > 0 ? services : undefined);
156
- break;
157
- }
158
-
159
- case "status":
160
- case "ps": {
161
- await status();
162
- break;
163
- }
164
-
165
- case "extensions":
166
- case "ext": {
167
- const [subcommand, ...extArgs] = args;
168
- if (!subcommand) {
169
- error("Missing subcommand. Usage: openpalm extensions <install|uninstall|list>");
170
- process.exit(1);
171
- }
172
- await extensions(subcommand, extArgs);
173
- break;
174
- }
175
-
176
- case "dev": {
177
- const [subcommand, ...devArgs] = args;
178
- if (!subcommand) {
179
- error("Missing subcommand. Usage: openpalm dev <preflight|create-channel>");
180
- process.exit(1);
181
- }
182
- if (subcommand === "preflight") {
183
- preflight();
184
- break;
185
- }
186
- if (subcommand === "create-channel") {
187
- createChannel(devArgs);
188
- break;
189
- }
190
- error(`Unknown dev subcommand: ${subcommand}`);
191
- process.exit(1);
192
- }
193
-
194
- default: {
195
- error(`Unknown command: ${command}`);
196
- log("Run 'openpalm help' for usage information.");
197
- process.exit(1);
198
- }
199
- }
200
- } catch (err) {
201
- if (err instanceof Error) {
202
- error(err.message);
203
- } else {
204
- error(String(err));
205
- }
206
- process.exit(1);
207
- }
208
- }
209
-
210
- main();
package/src/types.ts DELETED
@@ -1,18 +0,0 @@
1
- import type { ContainerPlatform } from "@openpalm/lib/types.ts";
2
-
3
- /** Options for the install command. */
4
- export type InstallOptions = {
5
- runtime?: ContainerPlatform;
6
- noOpen?: boolean;
7
- ref?: string;
8
- };
9
-
10
- /** Options for the uninstall command. */
11
- export type UninstallOptions = {
12
- runtime?: ContainerPlatform;
13
- removeAll?: boolean;
14
- removeImages?: boolean;
15
- yes?: boolean;
16
- };
17
-
18
- export type { ContainerPlatform };