@liquidmetal-ai/raindrop 0.9.6 → 0.10.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/README.md +86 -86
- package/bundle/{chunk-AWVSG5HH.js → chunk-2GD7Q3YS.js} +1 -1
- package/bundle/{chunk-FYMUM7KM.js → chunk-2QH4PO44.js} +1 -1
- package/bundle/{chunk-2KEFV5U5.js → chunk-3DZWEZ2R.js} +1 -1
- package/bundle/{chunk-B4MQISI4.js → chunk-45V47YNS.js} +4 -4
- package/bundle/{chunk-ILG4QJPW.js → chunk-4FXE4I6S.js} +2 -2
- package/bundle/{chunk-43UGYZQA.js → chunk-4RN4TIJI.js} +1 -1
- package/bundle/{chunk-OHP3SQGY.js → chunk-4U2CSHCN.js} +1 -1
- package/bundle/{chunk-T3VHOMDJ.js → chunk-4UUTGMDZ.js} +1 -1
- package/bundle/{chunk-Z2VVSBIX.js → chunk-4WNBHWJP.js} +4 -4
- package/bundle/{chunk-CEFC4JXX.js → chunk-5KMI72AS.js} +1 -1
- package/bundle/{chunk-GBFY2PMX.js → chunk-5REFCZTG.js} +2 -2
- package/bundle/chunk-6BCRCAR4.js +22452 -0
- package/bundle/{chunk-YWKX37S2.js → chunk-7GDFE7HE.js} +3 -1
- package/bundle/{chunk-4NTUYQ5R.js → chunk-AI5PKHR7.js} +1 -1
- package/bundle/chunk-D5MXH3QV.js +133 -0
- package/bundle/chunk-ETDAUGBG.js +74 -0
- package/bundle/chunk-GBUNP7OT.js +4539 -0
- package/bundle/chunk-GRUPCK5H.js +384 -0
- package/bundle/chunk-JENN4EVA.js +75 -0
- package/bundle/chunk-JZYHHRGL.js +292 -0
- package/bundle/chunk-LJKAU7FY.js +4486 -0
- package/bundle/{chunk-E7J2LWQ5.js → chunk-MJZG4ABT.js} +1 -1
- package/bundle/chunk-MZZHXHB4.js +805 -0
- package/bundle/{chunk-B6JLI47W.js → chunk-ORUMKXQZ.js} +2 -2
- package/bundle/chunk-PMHLHYMI.js +231 -0
- package/bundle/chunk-QRJUX37T.js +48 -0
- package/bundle/chunk-QTCJ6YYG.js +147 -0
- package/bundle/chunk-RAPSKVRO.js +12148 -0
- package/bundle/chunk-U7NHRBYD.js +502 -0
- package/bundle/chunk-WDR5M2SS.js +238746 -0
- package/bundle/{chunk-SPBJ5BNI.js → chunk-YXJU5KSB.js} +1 -1
- package/bundle/chunk-ZQIPU6IX.js +44 -0
- package/bundle/commands/annotation/get.js +3 -3
- package/bundle/commands/annotation/list.js +3 -3
- package/bundle/commands/annotation/put.js +3 -3
- package/bundle/commands/auth/list.js +2 -2
- package/bundle/commands/auth/login.js +3 -3
- package/bundle/commands/auth/logout.js +2 -2
- package/bundle/commands/auth/select.js +3 -3
- package/bundle/commands/bucket/create-credential.js +2 -2
- package/bundle/commands/bucket/delete-credential.js +2 -2
- package/bundle/commands/bucket/get-credential.js +2 -2
- package/bundle/commands/bucket/list-credentials.js +2 -2
- package/bundle/commands/build/branch.js +9 -9
- package/bundle/commands/build/checkout.js +6 -6
- package/bundle/commands/build/clone.js +7 -7
- package/bundle/commands/build/delete.js +6 -6
- package/bundle/commands/build/deploy.js +9 -9
- package/bundle/commands/build/env/get.js +2 -2
- package/bundle/commands/build/env/set.js +2 -2
- package/bundle/commands/build/find.js +4 -4
- package/bundle/commands/build/generate.js +3 -3
- package/bundle/commands/build/init-workspace.js +3 -3
- package/bundle/commands/build/init.js +3 -3
- package/bundle/commands/build/list.js +5 -5
- package/bundle/commands/build/sandbox.js +7 -7
- package/bundle/commands/build/start.js +2 -2
- package/bundle/commands/build/status.js +5 -5
- package/bundle/commands/build/stop.js +2 -2
- package/bundle/commands/build/tools/check.js +2 -2
- package/bundle/commands/build/tools/fmt.js +2 -2
- package/bundle/commands/build/unsandbox.js +7 -7
- package/bundle/commands/build/upload.js +5 -5
- package/bundle/commands/build/validate.js +4 -4
- package/bundle/commands/build/workos/delete.js +4 -4
- package/bundle/commands/build/workos/env/attach.js +3 -3
- package/bundle/commands/build/workos/env/create.js +3 -3
- package/bundle/commands/build/workos/env/delete.js +3 -3
- package/bundle/commands/build/workos/env/detach.js +3 -3
- package/bundle/commands/build/workos/env/get.js +3 -3
- package/bundle/commands/build/workos/env/list.js +3 -3
- package/bundle/commands/build/workos/env/set.js +3 -3
- package/bundle/commands/build/workos/invite.js +3 -3
- package/bundle/commands/build/workos/setup.js +3 -3
- package/bundle/commands/build/workos/status.js +3 -3
- package/bundle/commands/dns/create.js +2 -2
- package/bundle/commands/dns/delete.js +4 -4
- package/bundle/commands/dns/get.js +4 -4
- package/bundle/commands/dns/list.js +3 -3
- package/bundle/commands/dns/records/create.js +2 -2
- package/bundle/commands/dns/records/delete.js +3 -3
- package/bundle/commands/dns/records/get.js +2 -2
- package/bundle/commands/dns/records/list.js +2 -2
- package/bundle/commands/dns/records/update.js +2 -2
- package/bundle/commands/logs/query.js +3 -3
- package/bundle/commands/logs/tail.js +3 -3
- package/bundle/commands/mcp/install-claude.js +2 -2
- package/bundle/commands/mcp/install-gemini.js +2 -2
- package/bundle/commands/mcp/install-goose.js +2 -2
- package/bundle/commands/mcp/status.js +2 -2
- package/bundle/commands/object/delete.js +2 -2
- package/bundle/commands/object/get.js +2 -2
- package/bundle/commands/object/list.js +73 -7
- package/bundle/commands/object/put.js +2 -2
- package/bundle/commands/query/chunk-search.js +3 -3
- package/bundle/commands/query/document.js +3 -3
- package/bundle/commands/query/events.js +2 -2
- package/bundle/commands/query/reindex.js +2 -2
- package/bundle/commands/query/search.js +3 -3
- package/bundle/commands/tail.js +2 -2
- package/bundle/index.js +1 -1
- package/dist/build.test.d.ts +2 -0
- package/dist/build.test.d.ts.map +1 -0
- package/dist/build.test.js +46 -0
- package/dist/codegen.test.d.ts +2 -0
- package/dist/codegen.test.d.ts.map +1 -0
- package/dist/codegen.test.js +223 -0
- package/dist/commands/logs/tail.test.d.ts +2 -0
- package/dist/commands/logs/tail.test.d.ts.map +1 -0
- package/dist/commands/logs/tail.test.js +366 -0
- package/dist/commands/object/list.d.ts.map +1 -1
- package/dist/commands/object/list.js +91 -4
- package/dist/config.test.d.ts +2 -0
- package/dist/config.test.d.ts.map +1 -0
- package/dist/config.test.js +27 -0
- package/dist/index.test.d.ts +2 -0
- package/dist/index.test.d.ts.map +1 -0
- package/dist/index.test.js +56 -0
- package/oclif.manifest.json +2569 -2569
- package/package.json +3 -3
- package/templates/db/node_modules/.bin/prisma +2 -2
- package/templates/db/node_modules/.bin/prisma-kysely +2 -2
- package/templates/db/node_modules/.bin/tsc +3 -7
- package/templates/db/node_modules/.bin/tsserver +3 -7
- package/templates/db/node_modules/.bin/zx +2 -2
- package/templates/init/RAINDROP.md.hbs +3 -3
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
source_default
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-2GD7Q3YS.js";
|
|
4
4
|
import {
|
|
5
5
|
UnitState,
|
|
6
6
|
init_cjs_shims,
|
|
7
7
|
timestampDate,
|
|
8
8
|
valueOf
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-WDR5M2SS.js";
|
|
10
10
|
|
|
11
11
|
// src/status.ts
|
|
12
12
|
init_cjs_shims();
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import {
|
|
2
|
+
tmpdir
|
|
3
|
+
} from "./chunk-6BCRCAR4.js";
|
|
4
|
+
import {
|
|
5
|
+
FileSystemBundle,
|
|
6
|
+
archive
|
|
7
|
+
} from "./chunk-2QH4PO44.js";
|
|
8
|
+
import {
|
|
9
|
+
buildHandlers
|
|
10
|
+
} from "./chunk-JZYHHRGL.js";
|
|
11
|
+
import {
|
|
12
|
+
BundleArchiveType,
|
|
13
|
+
Code,
|
|
14
|
+
ConnectError,
|
|
15
|
+
ReleaseRequest_LockSchema,
|
|
16
|
+
create,
|
|
17
|
+
init_cjs_shims,
|
|
18
|
+
listEnvVars,
|
|
19
|
+
valueOf
|
|
20
|
+
} from "./chunk-7GDFE7HE.js";
|
|
21
|
+
|
|
22
|
+
// src/deploy.ts
|
|
23
|
+
init_cjs_shims();
|
|
24
|
+
import fs from "node:fs/promises";
|
|
25
|
+
import * as path from "node:path";
|
|
26
|
+
async function deploy(options) {
|
|
27
|
+
const { command, root, manifest, output } = options;
|
|
28
|
+
const manifestPath = path.isAbsolute(manifest) ? manifest : path.join(root, manifest);
|
|
29
|
+
const buildDir = path.isAbsolute(output) ? output : path.join(root, output);
|
|
30
|
+
const apps = await command.loadManifest();
|
|
31
|
+
if (apps[0] === void 0) {
|
|
32
|
+
command.error("There are no applications in the manifest");
|
|
33
|
+
return "";
|
|
34
|
+
}
|
|
35
|
+
const app = apps[0];
|
|
36
|
+
const manifestContents = await fs.readFile(manifestPath, "utf8");
|
|
37
|
+
await buildHandlers(command, apps, buildDir, root);
|
|
38
|
+
const runtimeVersion = await command.raindropFrameworkVersion();
|
|
39
|
+
const { client: catalogService, userId, organizationId: defaultOrganizationId } = await command.catalogService();
|
|
40
|
+
const organizationId = options.impersonate ?? defaultOrganizationId;
|
|
41
|
+
let deployResp;
|
|
42
|
+
try {
|
|
43
|
+
deployResp = await catalogService.deploy({
|
|
44
|
+
userId,
|
|
45
|
+
organizationId,
|
|
46
|
+
applications: [
|
|
47
|
+
{
|
|
48
|
+
application: valueOf(app.name),
|
|
49
|
+
previousVersionId: options.previousVersionId,
|
|
50
|
+
currentVersionId: options.currentVersionId,
|
|
51
|
+
branch: options.branch,
|
|
52
|
+
amend: options.amend,
|
|
53
|
+
metadata: {
|
|
54
|
+
runtimeVersion
|
|
55
|
+
},
|
|
56
|
+
manifest: manifestContents,
|
|
57
|
+
lock: options.lock,
|
|
58
|
+
suite: ""
|
|
59
|
+
}
|
|
60
|
+
]
|
|
61
|
+
});
|
|
62
|
+
} catch (err) {
|
|
63
|
+
if (err instanceof ConnectError && err.code === Code.FailedPrecondition) {
|
|
64
|
+
command.error(
|
|
65
|
+
`Failed to ${options.amend ? "amend" : "deploy"} ${valueOf(app.name)}@${options.previousVersionId}=>${options.currentVersionId}: ${err.message}`
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
throw err;
|
|
69
|
+
}
|
|
70
|
+
if (deployResp.applications[0] === void 0) {
|
|
71
|
+
command.error("Failed to deploy application");
|
|
72
|
+
}
|
|
73
|
+
const currentVersionId = deployResp.applications[0].currentVersionId;
|
|
74
|
+
if (!currentVersionId) {
|
|
75
|
+
command.error("Failed to retrieve current version ID from deployment response.");
|
|
76
|
+
}
|
|
77
|
+
const lock = deployResp.applications[0].lock;
|
|
78
|
+
const config = await command.loadConfig();
|
|
79
|
+
config.versionId = currentVersionId;
|
|
80
|
+
config.lock = lock;
|
|
81
|
+
await command.saveConfig(config);
|
|
82
|
+
await checkEnvironmentVariables(command, app, catalogService, userId, organizationId, currentVersionId);
|
|
83
|
+
await uploadBundles(command, app, buildDir, catalogService, userId, organizationId, currentVersionId);
|
|
84
|
+
await uploadDbBundle(command, root, catalogService, userId, organizationId, app, currentVersionId);
|
|
85
|
+
if (options.start) {
|
|
86
|
+
await catalogService.setActive({
|
|
87
|
+
userId,
|
|
88
|
+
organizationId,
|
|
89
|
+
applications: deployResp.applications.map((a) => ({
|
|
90
|
+
applicationName: a.applicationName,
|
|
91
|
+
currentVersionId: a.currentVersionId,
|
|
92
|
+
isActive: options.start
|
|
93
|
+
}))
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
await catalogService.release({
|
|
97
|
+
userId,
|
|
98
|
+
organizationId,
|
|
99
|
+
locks: deployResp.applications.map(
|
|
100
|
+
(a) => create(ReleaseRequest_LockSchema, {
|
|
101
|
+
applicationName: a.applicationName,
|
|
102
|
+
currentVersionId: a.currentVersionId,
|
|
103
|
+
lock: a.lock
|
|
104
|
+
})
|
|
105
|
+
)
|
|
106
|
+
});
|
|
107
|
+
config.lock = void 0;
|
|
108
|
+
await command.saveConfig(config);
|
|
109
|
+
return currentVersionId;
|
|
110
|
+
}
|
|
111
|
+
async function checkEnvironmentVariables(command, app, catalogService, userId, organizationId, currentVersionId) {
|
|
112
|
+
const envVars = listEnvVars(app);
|
|
113
|
+
if (Object.keys(envVars).length > 0) {
|
|
114
|
+
const getEnvsResp = await catalogService.getEnvs({
|
|
115
|
+
userId,
|
|
116
|
+
organizationId,
|
|
117
|
+
envs: Object.keys(envVars).map((key) => ({
|
|
118
|
+
applicationName: valueOf(app.name),
|
|
119
|
+
currentVersionId,
|
|
120
|
+
key
|
|
121
|
+
}))
|
|
122
|
+
});
|
|
123
|
+
let unset = false;
|
|
124
|
+
const remoteEnvVars = Object.fromEntries(getEnvsResp.envs.map((env) => [env.key, env.value]));
|
|
125
|
+
for (const key of Object.keys(envVars)) {
|
|
126
|
+
const manifestDefault = envVars[key]?.default;
|
|
127
|
+
const remoteValue = remoteEnvVars[key];
|
|
128
|
+
if (remoteValue === void 0 && manifestDefault === void 0) {
|
|
129
|
+
if (!unset) {
|
|
130
|
+
command.warn(`The following environment variables were not set and are required for deployment:`);
|
|
131
|
+
}
|
|
132
|
+
unset = true;
|
|
133
|
+
command.warn(key);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
if (unset) {
|
|
137
|
+
command.error(
|
|
138
|
+
"Please set environment variables before deploying. You can resume using `raindrop build deploy --amend`"
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
async function uploadBundles(command, app, buildDir, catalogService, userId, organizationId, currentVersionId) {
|
|
144
|
+
await Promise.all(
|
|
145
|
+
app.handlers().map(async (handler) => {
|
|
146
|
+
const bundle = new FileSystemBundle(path.join(buildDir, valueOf(handler.name)));
|
|
147
|
+
await catalogService.uploadBundle({
|
|
148
|
+
userId,
|
|
149
|
+
organizationId,
|
|
150
|
+
applicationName: valueOf(app.name),
|
|
151
|
+
applicationVersionId: currentVersionId,
|
|
152
|
+
archiveType: BundleArchiveType.ZIP,
|
|
153
|
+
bundleName: valueOf(handler.name),
|
|
154
|
+
archive: Buffer.from(await archive(bundle))
|
|
155
|
+
});
|
|
156
|
+
command.log(`Uploaded bundle "${valueOf(handler.name)}"`);
|
|
157
|
+
})
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
async function uploadDbBundle(command, root, catalogService, userId, organizationId, app, currentVersionId) {
|
|
161
|
+
const dbDir = path.join(root, "db");
|
|
162
|
+
let dbExists = false;
|
|
163
|
+
try {
|
|
164
|
+
const stat = await fs.lstat(dbDir);
|
|
165
|
+
dbExists = stat.isDirectory();
|
|
166
|
+
} catch (_e) {
|
|
167
|
+
}
|
|
168
|
+
if (dbExists) {
|
|
169
|
+
command.log(`Checking for SQL files in ${dbDir}`);
|
|
170
|
+
const files = await fs.readdir(dbDir, {
|
|
171
|
+
withFileTypes: true
|
|
172
|
+
});
|
|
173
|
+
const folders = files.filter((file) => file.isDirectory());
|
|
174
|
+
try {
|
|
175
|
+
const tempDir = tmpdir();
|
|
176
|
+
for (const folder of folders) {
|
|
177
|
+
const sqlFiles = (await fs.readdir(path.join(dbDir, folder.name))).filter((file) => file.endsWith(".sql"));
|
|
178
|
+
const tmpDbFolder = await fs.mkdir(path.join(tempDir, folder.name), { recursive: true });
|
|
179
|
+
for (const sqlFile of sqlFiles) {
|
|
180
|
+
await fs.copyFile(path.join(dbDir, folder.name, sqlFile), path.join(tmpDbFolder, sqlFile));
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
const dbBundle = new FileSystemBundle(tempDir);
|
|
184
|
+
await catalogService.uploadBundle({
|
|
185
|
+
userId,
|
|
186
|
+
organizationId,
|
|
187
|
+
applicationName: valueOf(app.name),
|
|
188
|
+
applicationVersionId: currentVersionId,
|
|
189
|
+
archiveType: BundleArchiveType.ZIP,
|
|
190
|
+
bundleName: "db",
|
|
191
|
+
archive: Buffer.from(await archive(dbBundle))
|
|
192
|
+
});
|
|
193
|
+
command.log(`Uploaded db bundle with SQL files`);
|
|
194
|
+
await fs.rm(tempDir, { recursive: true, force: true });
|
|
195
|
+
} catch (error) {
|
|
196
|
+
command.log(`Failed to upload db bundle: ${error}`);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
async function sandbox(options) {
|
|
201
|
+
const { command, versionId: versionIdRaw, impersonate, isSandboxed } = options;
|
|
202
|
+
const config = await command.loadConfig();
|
|
203
|
+
const { client: catalogService, userId, organizationId: defaultOrganizationId } = await command.catalogService();
|
|
204
|
+
const organizationId = impersonate ?? defaultOrganizationId;
|
|
205
|
+
const apps = await command.loadManifest();
|
|
206
|
+
const app = apps[0];
|
|
207
|
+
const versionId = versionIdRaw ?? config.versionId;
|
|
208
|
+
if (!app) {
|
|
209
|
+
throw new Error("No application found");
|
|
210
|
+
}
|
|
211
|
+
const applications = [
|
|
212
|
+
{
|
|
213
|
+
applicationName: valueOf(app.name),
|
|
214
|
+
currentVersionId: versionId,
|
|
215
|
+
isSandboxed
|
|
216
|
+
}
|
|
217
|
+
];
|
|
218
|
+
await catalogService.setSandbox({
|
|
219
|
+
userId,
|
|
220
|
+
organizationId,
|
|
221
|
+
applications
|
|
222
|
+
});
|
|
223
|
+
config.sandbox = isSandboxed;
|
|
224
|
+
await command.saveConfig(config);
|
|
225
|
+
return applications;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export {
|
|
229
|
+
deploy,
|
|
230
|
+
sandbox
|
|
231
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import {
|
|
2
|
+
init_cjs_shims
|
|
3
|
+
} from "./chunk-WDR5M2SS.js";
|
|
4
|
+
|
|
5
|
+
// src/lib/dns-utils.ts
|
|
6
|
+
init_cjs_shims();
|
|
7
|
+
async function resolveDnsNameToZoneId(dnsClient, organizationId, userId, dnsName) {
|
|
8
|
+
try {
|
|
9
|
+
const normalizedDnsName = dnsName.endsWith(".") ? dnsName.slice(0, -1) : dnsName;
|
|
10
|
+
let pageToken;
|
|
11
|
+
do {
|
|
12
|
+
const response = await dnsClient.listDNSZones({
|
|
13
|
+
organizationId,
|
|
14
|
+
userId,
|
|
15
|
+
pageSize: 100,
|
|
16
|
+
// Use a larger page size for efficiency
|
|
17
|
+
pageToken
|
|
18
|
+
});
|
|
19
|
+
if (response.zones) {
|
|
20
|
+
const exactMatch = response.zones.find(
|
|
21
|
+
(zone) => zone.fullyQualifiedDomainName === normalizedDnsName
|
|
22
|
+
);
|
|
23
|
+
if (exactMatch?.zoneId) {
|
|
24
|
+
return exactMatch.zoneId;
|
|
25
|
+
}
|
|
26
|
+
const parentZone = response.zones.find((zone) => {
|
|
27
|
+
if (!zone.fullyQualifiedDomainName) return false;
|
|
28
|
+
const zoneFqdn = zone.fullyQualifiedDomainName;
|
|
29
|
+
return normalizedDnsName.endsWith(`.${zoneFqdn}`) || normalizedDnsName === zoneFqdn;
|
|
30
|
+
});
|
|
31
|
+
if (parentZone?.zoneId) {
|
|
32
|
+
return parentZone.zoneId;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
pageToken = response.nextPageToken;
|
|
36
|
+
} while (pageToken);
|
|
37
|
+
throw new Error(`No DNS zone found for domain name: ${dnsName}`);
|
|
38
|
+
} catch (error) {
|
|
39
|
+
if (error instanceof Error) {
|
|
40
|
+
throw error;
|
|
41
|
+
}
|
|
42
|
+
throw new Error(`Failed to resolve DNS name to zone ID: ${error}`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export {
|
|
47
|
+
resolveDnsNameToZoneId
|
|
48
|
+
};
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import {
|
|
2
|
+
source_default
|
|
3
|
+
} from "./chunk-U7NHRBYD.js";
|
|
4
|
+
import {
|
|
5
|
+
UnitState,
|
|
6
|
+
init_cjs_shims,
|
|
7
|
+
valueOf
|
|
8
|
+
} from "./chunk-7GDFE7HE.js";
|
|
9
|
+
|
|
10
|
+
// src/status.ts
|
|
11
|
+
init_cjs_shims();
|
|
12
|
+
import * as readline from "readline";
|
|
13
|
+
var statusString = {
|
|
14
|
+
[UnitState.UNSPECIFIED]: "<unknown>",
|
|
15
|
+
[UnitState.PENDING]: "pending...",
|
|
16
|
+
[UnitState.STARTING]: "starting...",
|
|
17
|
+
[UnitState.RUNNING]: "running",
|
|
18
|
+
[UnitState.STOPPING]: "stopping...",
|
|
19
|
+
[UnitState.STOPPED]: "stopped",
|
|
20
|
+
[UnitState.DELETING]: "deleting...",
|
|
21
|
+
[UnitState.DELETED]: "deleted"
|
|
22
|
+
};
|
|
23
|
+
async function getStatus(options) {
|
|
24
|
+
const { command, impersonate } = options;
|
|
25
|
+
let applicationName = options.applicationName;
|
|
26
|
+
let versionId = options.versionId;
|
|
27
|
+
if (!versionId) {
|
|
28
|
+
const config = await command.loadConfig();
|
|
29
|
+
versionId = config.versionId;
|
|
30
|
+
}
|
|
31
|
+
if (!applicationName) {
|
|
32
|
+
const apps = await command.loadManifest();
|
|
33
|
+
const app = apps[0];
|
|
34
|
+
if (app === void 0) {
|
|
35
|
+
command.error("No application provided or found in manifest");
|
|
36
|
+
}
|
|
37
|
+
applicationName = valueOf(app.name);
|
|
38
|
+
}
|
|
39
|
+
const { client: catalogService, userId, organizationId: defaultOrganizationId } = await command.catalogService();
|
|
40
|
+
const organizationId = impersonate ?? defaultOrganizationId;
|
|
41
|
+
const status = await catalogService.status({
|
|
42
|
+
userId,
|
|
43
|
+
organizationId,
|
|
44
|
+
applicationName,
|
|
45
|
+
currentVersionId: versionId || ""
|
|
46
|
+
});
|
|
47
|
+
if (status === void 0) {
|
|
48
|
+
command.error(`Application ${applicationName} not found`);
|
|
49
|
+
}
|
|
50
|
+
return status;
|
|
51
|
+
}
|
|
52
|
+
async function watchStatus(options) {
|
|
53
|
+
const { command } = options;
|
|
54
|
+
const renderer = new StatusRenderer();
|
|
55
|
+
let applicationName = options.applicationName;
|
|
56
|
+
let versionId = options.versionId;
|
|
57
|
+
if (!applicationName) {
|
|
58
|
+
const apps = await command.loadManifest();
|
|
59
|
+
const app = apps[0];
|
|
60
|
+
if (app) {
|
|
61
|
+
applicationName = valueOf(app.name);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (!versionId) {
|
|
65
|
+
const config = await command.loadConfig();
|
|
66
|
+
versionId = config.versionId;
|
|
67
|
+
}
|
|
68
|
+
let status = await getStatus(options);
|
|
69
|
+
while (true) {
|
|
70
|
+
renderer.renderLive(status, applicationName, versionId);
|
|
71
|
+
if (status.state === UnitState.RUNNING || status.state === UnitState.STOPPED) {
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
75
|
+
status = await getStatus(options);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
var StatusRenderer = class {
|
|
79
|
+
linesLastRendered = 0;
|
|
80
|
+
getStatusColor(state) {
|
|
81
|
+
switch (state) {
|
|
82
|
+
case UnitState.RUNNING:
|
|
83
|
+
return source_default.green;
|
|
84
|
+
case UnitState.PENDING:
|
|
85
|
+
case UnitState.STARTING:
|
|
86
|
+
return source_default.yellow;
|
|
87
|
+
case UnitState.STOPPING:
|
|
88
|
+
case UnitState.DELETING:
|
|
89
|
+
return source_default.yellow;
|
|
90
|
+
case UnitState.STOPPED:
|
|
91
|
+
case UnitState.DELETED:
|
|
92
|
+
return source_default.red;
|
|
93
|
+
default:
|
|
94
|
+
return source_default.gray;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
renderLive(status, applicationName, versionId) {
|
|
98
|
+
if (this.linesLastRendered > 0) {
|
|
99
|
+
readline.moveCursor(process.stdout, 0, -this.linesLastRendered);
|
|
100
|
+
readline.clearScreenDown(process.stdout);
|
|
101
|
+
}
|
|
102
|
+
const lines = [];
|
|
103
|
+
lines.push("");
|
|
104
|
+
lines.push(`${source_default.bold(applicationName)} ${source_default.dim(versionId ? `@${versionId.substring(0, 8)}...` : "")}`);
|
|
105
|
+
lines.push(source_default.dim(`Status: ${this.getStatusColor(status.state)(statusString[status.state])}`));
|
|
106
|
+
lines.push("");
|
|
107
|
+
lines.push(`${source_default.bold("Modules")} ${source_default.dim(`(${status.modules.length})`)}`);
|
|
108
|
+
for (const module of status.modules) {
|
|
109
|
+
const statusColor = this.getStatusColor(module.state);
|
|
110
|
+
const notification = module.notification ? ` - ${source_default.cyan(module.notification)}` : "";
|
|
111
|
+
lines.push(` \u2514\u2500 ${source_default.yellow(module.name)} - ${statusColor(statusString[module.state])}${notification}`);
|
|
112
|
+
}
|
|
113
|
+
const runningModules = status.modules.filter((m) => m.state === UnitState.RUNNING).length;
|
|
114
|
+
const totalModules = status.modules.length;
|
|
115
|
+
lines.push("");
|
|
116
|
+
lines.push(source_default.dim("\u2500".repeat(50)));
|
|
117
|
+
lines.push(source_default.dim(`Total: ${totalModules} modules (${runningModules} running)`));
|
|
118
|
+
for (const line of lines) {
|
|
119
|
+
console.log(line);
|
|
120
|
+
}
|
|
121
|
+
this.linesLastRendered = lines.length;
|
|
122
|
+
}
|
|
123
|
+
renderCompact(status, applicationName, versionId) {
|
|
124
|
+
console.log(`
|
|
125
|
+
${source_default.bold(applicationName)} ${source_default.dim(versionId ? `@${versionId.substring(0, 8)}...` : "")}`);
|
|
126
|
+
console.log(source_default.dim(`Status: ${this.getStatusColor(status.state)(statusString[status.state])}`));
|
|
127
|
+
console.log(`
|
|
128
|
+
${source_default.bold("Modules")} ${source_default.dim(`(${status.modules.length})`)}`);
|
|
129
|
+
for (const module of status.modules) {
|
|
130
|
+
const statusColor = this.getStatusColor(module.state);
|
|
131
|
+
const notification = module.notification ? ` - ${source_default.cyan(module.notification)}` : "";
|
|
132
|
+
console.log(` \u2514\u2500 ${source_default.yellow(module.name)} - ${statusColor(statusString[module.state])}${notification}`);
|
|
133
|
+
}
|
|
134
|
+
const runningModules = status.modules.filter((m) => m.state === UnitState.RUNNING).length;
|
|
135
|
+
const totalModules = status.modules.length;
|
|
136
|
+
console.log("");
|
|
137
|
+
console.log(source_default.dim("\u2500".repeat(50)));
|
|
138
|
+
console.log(source_default.dim(`Total: ${totalModules} modules (${runningModules} running)`));
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
export {
|
|
143
|
+
statusString,
|
|
144
|
+
getStatus,
|
|
145
|
+
watchStatus,
|
|
146
|
+
StatusRenderer
|
|
147
|
+
};
|