@liquidmetal-ai/raindrop 0.0.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 +777 -0
- package/bin/dev.cmd +3 -0
- package/bin/dev.js +6 -0
- package/bin/run.cmd +3 -0
- package/bin/run.js +5 -0
- package/dist/base-command.d.ts +27 -0
- package/dist/base-command.d.ts.map +1 -0
- package/dist/base-command.js +69 -0
- package/dist/build.d.ts +13 -0
- package/dist/build.d.ts.map +1 -0
- package/dist/build.js +86 -0
- package/dist/build.test.d.ts +2 -0
- package/dist/build.test.d.ts.map +1 -0
- package/dist/build.test.js +41 -0
- package/dist/codegen.d.ts +32 -0
- package/dist/codegen.d.ts.map +1 -0
- package/dist/codegen.js +212 -0
- package/dist/codegen.test.d.ts +2 -0
- package/dist/codegen.test.d.ts.map +1 -0
- package/dist/codegen.test.js +97 -0
- package/dist/commands/auth/list.d.ts +10 -0
- package/dist/commands/auth/list.d.ts.map +1 -0
- package/dist/commands/auth/list.js +55 -0
- package/dist/commands/auth/login.d.ts +10 -0
- package/dist/commands/auth/login.d.ts.map +1 -0
- package/dist/commands/auth/login.js +69 -0
- package/dist/commands/auth/logout.d.ts +8 -0
- package/dist/commands/auth/logout.d.ts.map +1 -0
- package/dist/commands/auth/logout.js +15 -0
- package/dist/commands/auth/select.d.ts +10 -0
- package/dist/commands/auth/select.d.ts.map +1 -0
- package/dist/commands/auth/select.js +39 -0
- package/dist/commands/build/branch.d.ts +16 -0
- package/dist/commands/build/branch.d.ts.map +1 -0
- package/dist/commands/build/branch.js +81 -0
- package/dist/commands/build/delete.d.ts +19 -0
- package/dist/commands/build/delete.d.ts.map +1 -0
- package/dist/commands/build/delete.js +99 -0
- package/dist/commands/build/deploy.d.ts +18 -0
- package/dist/commands/build/deploy.d.ts.map +1 -0
- package/dist/commands/build/deploy.js +144 -0
- package/dist/commands/build/env/get.d.ts +19 -0
- package/dist/commands/build/env/get.d.ts.map +1 -0
- package/dist/commands/build/env/get.js +101 -0
- package/dist/commands/build/env/set.d.ts +20 -0
- package/dist/commands/build/env/set.d.ts.map +1 -0
- package/dist/commands/build/env/set.js +115 -0
- package/dist/commands/build/find.d.ts +24 -0
- package/dist/commands/build/find.d.ts.map +1 -0
- package/dist/commands/build/find.js +110 -0
- package/dist/commands/build/generate.d.ts +13 -0
- package/dist/commands/build/generate.d.ts.map +1 -0
- package/dist/commands/build/generate.js +38 -0
- package/dist/commands/build/init.d.ts +15 -0
- package/dist/commands/build/init.d.ts.map +1 -0
- package/dist/commands/build/init.js +57 -0
- package/dist/commands/build/list.d.ts +17 -0
- package/dist/commands/build/list.d.ts.map +1 -0
- package/dist/commands/build/list.js +100 -0
- package/dist/commands/build/start.d.ts +16 -0
- package/dist/commands/build/start.d.ts.map +1 -0
- package/dist/commands/build/start.js +71 -0
- package/dist/commands/build/stop.d.ts +15 -0
- package/dist/commands/build/stop.d.ts.map +1 -0
- package/dist/commands/build/stop.js +67 -0
- package/dist/commands/build/token.d.ts +9 -0
- package/dist/commands/build/token.d.ts.map +1 -0
- package/dist/commands/build/token.js +42 -0
- package/dist/commands/build/upload.d.ts +17 -0
- package/dist/commands/build/upload.d.ts.map +1 -0
- package/dist/commands/build/upload.js +75 -0
- package/dist/commands/build/validate.d.ts +13 -0
- package/dist/commands/build/validate.d.ts.map +1 -0
- package/dist/commands/build/validate.js +26 -0
- package/dist/config.d.ts +13 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +34 -0
- package/dist/config.test.d.ts +2 -0
- package/dist/config.test.d.ts.map +1 -0
- package/dist/config.test.js +24 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +140 -0
- package/dist/index.test.d.ts +2 -0
- package/dist/index.test.d.ts.map +1 -0
- package/dist/index.test.js +4 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/oclif.manifest.json +1208 -0
- package/package.json +107 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { valueOf } from '@liquidmetal-ai/drizzle/appify/build';
|
|
2
|
+
import { Args, Flags } from '@oclif/core';
|
|
3
|
+
import { BaseCommand } from '../../../base-command.js';
|
|
4
|
+
export default class Get extends BaseCommand {
|
|
5
|
+
static args = {
|
|
6
|
+
var: Args.string({ char: 'v', description: 'env var/secret name', required: true }),
|
|
7
|
+
};
|
|
8
|
+
static description = 'get an env var/secret';
|
|
9
|
+
static examples = [
|
|
10
|
+
`<%= config.bin %> <%= command.id %> my-app:env:MY_VAR
|
|
11
|
+
sets an env var/secret.
|
|
12
|
+
`,
|
|
13
|
+
];
|
|
14
|
+
static flags = {
|
|
15
|
+
output: Flags.string({ char: 'o', description: 'output format', default: 'table' }),
|
|
16
|
+
rainbowAuthService: Flags.string({
|
|
17
|
+
default: 'https://liquidmetal.run/api/connect',
|
|
18
|
+
hidden: true,
|
|
19
|
+
env: 'LIQUIDMETAL_RAINBOW_AUTH_SERVICE',
|
|
20
|
+
}),
|
|
21
|
+
manifest: Flags.string({
|
|
22
|
+
char: 'm',
|
|
23
|
+
description: 'project manifest',
|
|
24
|
+
required: false,
|
|
25
|
+
default: 'raindrop.manifest',
|
|
26
|
+
}),
|
|
27
|
+
versionId: Flags.string({
|
|
28
|
+
char: 'v',
|
|
29
|
+
aliases: ['version'],
|
|
30
|
+
description: 'version ID',
|
|
31
|
+
required: false,
|
|
32
|
+
}),
|
|
33
|
+
application: Flags.string({
|
|
34
|
+
char: 'a',
|
|
35
|
+
description: 'application',
|
|
36
|
+
required: false,
|
|
37
|
+
}),
|
|
38
|
+
impersonate: Flags.string({
|
|
39
|
+
char: 'i',
|
|
40
|
+
description: 'impersonate organization',
|
|
41
|
+
required: false,
|
|
42
|
+
hidden: true,
|
|
43
|
+
}),
|
|
44
|
+
config: Flags.string({ char: 'c', description: 'config file', required: false, default: '.raindrop/config.json' }),
|
|
45
|
+
};
|
|
46
|
+
async run() {
|
|
47
|
+
const apps = await this.loadManifest();
|
|
48
|
+
const app = apps.find((app) => valueOf(app.name) === this.flags.application) || apps[0];
|
|
49
|
+
if (app === undefined) {
|
|
50
|
+
this.error(`application ${this.flags.application} not found in manifest`, { exit: 1 });
|
|
51
|
+
}
|
|
52
|
+
// All of this is to determine if the variable is a secret.
|
|
53
|
+
let isSecret = false;
|
|
54
|
+
// Split up the variable path.
|
|
55
|
+
const path = this.args.var.split(':');
|
|
56
|
+
if (path.shift() !== valueOf(app.name)) {
|
|
57
|
+
this.error(`variable does not belong to application ${valueOf(app.name)}`, { exit: 1 });
|
|
58
|
+
}
|
|
59
|
+
const envVarName = path.pop();
|
|
60
|
+
if (envVarName === undefined) {
|
|
61
|
+
this.error('variable name not specified', { exit: 1 });
|
|
62
|
+
}
|
|
63
|
+
// If there's anything left in the path, it's nested.
|
|
64
|
+
if (path.length == 0) {
|
|
65
|
+
// It's a top level variable.
|
|
66
|
+
const envStanza = app.env.find((env) => valueOf(env.name) === envVarName);
|
|
67
|
+
if (envStanza === undefined) {
|
|
68
|
+
this.error(`variable ${envVarName} not found in manifest`, { exit: 1 });
|
|
69
|
+
}
|
|
70
|
+
isSecret = envStanza.secret && valueOf(envStanza.secret) || false;
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
// It's nested on some scripted module.
|
|
74
|
+
const scriptModules = app.handlers();
|
|
75
|
+
const scriptModule = scriptModules.find((module) => valueOf(module.name) === path[0]);
|
|
76
|
+
if (scriptModule === undefined) {
|
|
77
|
+
this.error(`script module ${path[0]} not found in manifest`, { exit: 1 });
|
|
78
|
+
}
|
|
79
|
+
const envStanza = scriptModule.env.find((env) => valueOf(env.name) === envVarName);
|
|
80
|
+
if (envStanza === undefined) {
|
|
81
|
+
this.error(`variable ${envVarName} not found in manifest`, { exit: 1 });
|
|
82
|
+
}
|
|
83
|
+
isSecret = envStanza.secret && valueOf(envStanza.secret) || false;
|
|
84
|
+
}
|
|
85
|
+
const config = await this.loadConfig();
|
|
86
|
+
const { client: catalogService, userId, organizationId } = await this.catalogService();
|
|
87
|
+
const resp = await catalogService.getEnv({
|
|
88
|
+
userId,
|
|
89
|
+
organizationId: this.flags.impersonate ?? organizationId,
|
|
90
|
+
applicationName: valueOf(app.name),
|
|
91
|
+
applicationVersionId: this.flags.versionId || config.versionId,
|
|
92
|
+
key: this.args.var,
|
|
93
|
+
});
|
|
94
|
+
if (isSecret) {
|
|
95
|
+
console.log(`${this.args.var}=[hash: ${resp.value}]`);
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
console.log(`${this.args.var}=${resp.value}`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { BaseCommand } from '../../../base-command.js';
|
|
2
|
+
export default class Set extends BaseCommand<typeof Set> {
|
|
3
|
+
static args: {
|
|
4
|
+
var: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
5
|
+
value: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
6
|
+
};
|
|
7
|
+
static description: string;
|
|
8
|
+
static examples: string[];
|
|
9
|
+
static flags: {
|
|
10
|
+
output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
manifest: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
versionId: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
application: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
impersonate: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
+
rainbowAuthService: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
|
+
config: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
|
+
};
|
|
18
|
+
run(): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=set.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set.d.ts","sourceRoot":"","sources":["../../../../src/commands/build/env/set.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGvD,MAAM,CAAC,OAAO,OAAO,GAAI,SAAQ,WAAW,CAAC,OAAO,GAAG,CAAC;IACtD,MAAM,CAAC,IAAI;;;MAGT;IAEF,MAAM,CAAC,WAAW,SAA2B;IAE7C,MAAM,CAAC,QAAQ,WAIb;IAEF,MAAM,CAAC,KAAK;;;;;;;;MA+BV;IAEI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAuE3B"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { valueOf } from '@liquidmetal-ai/drizzle/appify/build';
|
|
2
|
+
import { CatalogService } from '@liquidmetal-ai/drizzle/liquidmetal/v1alpha1/catalog_connect';
|
|
3
|
+
import { RainbowAuthService } from '@liquidmetal-ai/drizzle/liquidmetal/v1alpha1/rainbow_auth_connect';
|
|
4
|
+
import { Args, Flags } from '@oclif/core';
|
|
5
|
+
import { BaseCommand } from '../../../base-command.js';
|
|
6
|
+
import { createAuthenticatingClient, useClient } from '../../../index.js';
|
|
7
|
+
export default class Set extends BaseCommand {
|
|
8
|
+
static args = {
|
|
9
|
+
var: Args.string({ char: 'v', description: 'env var/secret name', required: true }),
|
|
10
|
+
value: Args.string({ char: 'V', description: 'env var/secret value', required: false }),
|
|
11
|
+
};
|
|
12
|
+
static description = 'set an env var/secret';
|
|
13
|
+
static examples = [
|
|
14
|
+
`<%= config.bin %> <%= command.id %> .
|
|
15
|
+
sets an env var/secret.
|
|
16
|
+
`,
|
|
17
|
+
];
|
|
18
|
+
static flags = {
|
|
19
|
+
output: Flags.string({ char: 'o', description: 'output format', default: 'table' }),
|
|
20
|
+
manifest: Flags.string({
|
|
21
|
+
char: 'm',
|
|
22
|
+
description: 'project manifest',
|
|
23
|
+
required: false,
|
|
24
|
+
default: 'raindrop.manifest',
|
|
25
|
+
}),
|
|
26
|
+
versionId: Flags.string({
|
|
27
|
+
char: 'v',
|
|
28
|
+
aliases: ['version'],
|
|
29
|
+
description: 'version ID',
|
|
30
|
+
required: false,
|
|
31
|
+
}),
|
|
32
|
+
application: Flags.string({
|
|
33
|
+
char: 'a',
|
|
34
|
+
description: 'application to start',
|
|
35
|
+
required: false,
|
|
36
|
+
}),
|
|
37
|
+
impersonate: Flags.string({
|
|
38
|
+
char: 'i',
|
|
39
|
+
description: 'impersonate organization',
|
|
40
|
+
required: false,
|
|
41
|
+
hidden: true,
|
|
42
|
+
}),
|
|
43
|
+
rainbowAuthService: Flags.string({
|
|
44
|
+
default: 'https://liquidmetal.run/api/connect',
|
|
45
|
+
hidden: true,
|
|
46
|
+
env: 'LIQUIDMETAL_RAINBOW_AUTH_SERVICE',
|
|
47
|
+
}),
|
|
48
|
+
config: Flags.string({ char: 'c', description: 'config file', required: false, default: '.raindrop/config.json' }),
|
|
49
|
+
};
|
|
50
|
+
async run() {
|
|
51
|
+
const apps = await this.loadManifest();
|
|
52
|
+
// find app that has matching name or error out
|
|
53
|
+
const app = apps.find((app) => valueOf(app.name) === this.flags.application) || apps[0];
|
|
54
|
+
if (app === undefined) {
|
|
55
|
+
this.error(`application ${this.flags.application} not found in manifest`, { exit: 1 });
|
|
56
|
+
}
|
|
57
|
+
// set env var value
|
|
58
|
+
const rainbowAuth = useClient(RainbowAuthService, this.flags.rainbowAuthService);
|
|
59
|
+
const { client: catalogService, userId, organizationId: defaultOrganizationId, } = await createAuthenticatingClient(CatalogService, this.config.configDir, rainbowAuth);
|
|
60
|
+
const organizationId = this.flags.impersonate ?? defaultOrganizationId;
|
|
61
|
+
// All of this is to determine if the variable is a secret.
|
|
62
|
+
let isSecret = false;
|
|
63
|
+
// Split up the variable path.
|
|
64
|
+
const path = this.args.var.split(':');
|
|
65
|
+
if (path.shift() !== valueOf(app.name)) {
|
|
66
|
+
this.error(`variable does not belong to application ${valueOf(app.name)}`, { exit: 1 });
|
|
67
|
+
}
|
|
68
|
+
const envVarName = path.pop();
|
|
69
|
+
if (envVarName === undefined) {
|
|
70
|
+
this.error('variable name not specified', { exit: 1 });
|
|
71
|
+
}
|
|
72
|
+
// If there's anything left in the path, it's nested.
|
|
73
|
+
if (path.length == 0) {
|
|
74
|
+
// It's a top level variable.
|
|
75
|
+
const envStanza = app.env.find((env) => valueOf(env.name) === envVarName);
|
|
76
|
+
if (envStanza === undefined) {
|
|
77
|
+
this.error(`variable ${envVarName} not found in manifest`, { exit: 1 });
|
|
78
|
+
}
|
|
79
|
+
isSecret = envStanza.secret && valueOf(envStanza.secret) || false;
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
// It's nested on some scripted module.
|
|
83
|
+
const scriptModules = app.handlers();
|
|
84
|
+
const scriptModule = scriptModules.find((module) => valueOf(module.name) === path[0]);
|
|
85
|
+
if (scriptModule === undefined) {
|
|
86
|
+
this.error(`script module ${path[0]} not found in manifest`, { exit: 1 });
|
|
87
|
+
}
|
|
88
|
+
const envStanza = scriptModule.env.find((env) => valueOf(env.name) === envVarName);
|
|
89
|
+
if (envStanza === undefined) {
|
|
90
|
+
this.error(`variable ${envVarName} not found in manifest`, { exit: 1 });
|
|
91
|
+
}
|
|
92
|
+
isSecret = envStanza.secret && valueOf(envStanza.secret) || false;
|
|
93
|
+
}
|
|
94
|
+
// Read stdin if no value is supplied.
|
|
95
|
+
if (this.args.value === undefined) {
|
|
96
|
+
this.log('no value supplied, reading stdin...');
|
|
97
|
+
const chunks = [];
|
|
98
|
+
for await (const chunk of process.stdin) {
|
|
99
|
+
chunk.push(chunk);
|
|
100
|
+
}
|
|
101
|
+
this.args.value = Buffer.concat(chunks).toString('utf8');
|
|
102
|
+
}
|
|
103
|
+
const config = await this.loadConfig();
|
|
104
|
+
await catalogService.setEnv({
|
|
105
|
+
userId,
|
|
106
|
+
organizationId,
|
|
107
|
+
applicationName: valueOf(app.name),
|
|
108
|
+
applicationVersionId: this.flags.versionId || config.versionId,
|
|
109
|
+
key: this.args.var,
|
|
110
|
+
value: this.args.value,
|
|
111
|
+
isSecret: isSecret,
|
|
112
|
+
});
|
|
113
|
+
console.log(`set ${this.args.var}`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base-command.js';
|
|
2
|
+
export default class Find extends BaseCommand<typeof Find> {
|
|
3
|
+
static args: {};
|
|
4
|
+
static description: string;
|
|
5
|
+
static examples: string[];
|
|
6
|
+
static flags: {
|
|
7
|
+
application: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
version: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
sudo: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
impersonate: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
rainbowAuthService: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
manifest: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
config: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
+
};
|
|
16
|
+
queryResources(flags: {
|
|
17
|
+
output: string;
|
|
18
|
+
rainbowAuthService: string;
|
|
19
|
+
application?: string;
|
|
20
|
+
version?: string;
|
|
21
|
+
}): Promise<void>;
|
|
22
|
+
run(): Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=find.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../../src/commands/build/find.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,WAAW,CAAC,OAAO,IAAI,CAAC;IACxD,MAAM,CAAC,IAAI,KAAM;IAEjB,MAAM,CAAC,WAAW,SAAgC;IAElD,MAAM,CAAC,QAAQ,WAGb;IAEF,MAAM,CAAC,KAAK;;;;;;;;;MAqCV;IAEI,cAAc,CAAC,KAAK,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,kBAAkB,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE;IA4D5G,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAO3B"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { valueOf } from '@liquidmetal-ai/drizzle/appify/build';
|
|
2
|
+
import { Flags } from '@oclif/core';
|
|
3
|
+
import { BaseCommand } from '../../base-command.js';
|
|
4
|
+
export default class Find extends BaseCommand {
|
|
5
|
+
static args = {};
|
|
6
|
+
static description = 'find resources in Raindrop';
|
|
7
|
+
static examples = [
|
|
8
|
+
`<%= config.bin %> <%= command.id %> .
|
|
9
|
+
`,
|
|
10
|
+
];
|
|
11
|
+
static flags = {
|
|
12
|
+
application: Flags.string({
|
|
13
|
+
char: 'a',
|
|
14
|
+
description: 'application',
|
|
15
|
+
required: false,
|
|
16
|
+
}),
|
|
17
|
+
version: Flags.string({
|
|
18
|
+
char: 'v',
|
|
19
|
+
description: 'application version',
|
|
20
|
+
required: false,
|
|
21
|
+
}),
|
|
22
|
+
output: Flags.string({
|
|
23
|
+
char: 'o',
|
|
24
|
+
description: 'output format',
|
|
25
|
+
default: 'table',
|
|
26
|
+
options: ['text', 'table', 'json'],
|
|
27
|
+
}),
|
|
28
|
+
sudo: Flags.boolean({
|
|
29
|
+
char: 's',
|
|
30
|
+
default: false,
|
|
31
|
+
description: 'superuser mode',
|
|
32
|
+
required: false,
|
|
33
|
+
hidden: true,
|
|
34
|
+
}),
|
|
35
|
+
impersonate: Flags.string({
|
|
36
|
+
char: 'i',
|
|
37
|
+
description: 'impersonate organization',
|
|
38
|
+
required: false,
|
|
39
|
+
hidden: true,
|
|
40
|
+
}),
|
|
41
|
+
rainbowAuthService: Flags.string({
|
|
42
|
+
default: 'https://liquidmetal.run/api/connect',
|
|
43
|
+
hidden: true,
|
|
44
|
+
env: 'LIQUIDMETAL_RAINBOW_AUTH_SERVICE',
|
|
45
|
+
}),
|
|
46
|
+
manifest: Flags.string({ default: 'raindrop.manifest', description: 'project manifest' }),
|
|
47
|
+
config: Flags.string({ default: '.raindrop/config.json', hidden: true }),
|
|
48
|
+
};
|
|
49
|
+
async queryResources(flags) {
|
|
50
|
+
if (!flags.version) {
|
|
51
|
+
const config = await this.loadConfig();
|
|
52
|
+
flags.version = config.versionId;
|
|
53
|
+
}
|
|
54
|
+
if (!flags.application) {
|
|
55
|
+
const apps = await this.loadManifest();
|
|
56
|
+
const app = apps[0];
|
|
57
|
+
if (app === undefined) {
|
|
58
|
+
this.error('No application provided or found in manifest', { exit: 1 });
|
|
59
|
+
}
|
|
60
|
+
flags.application = valueOf(app.name);
|
|
61
|
+
}
|
|
62
|
+
const { client: catalogService, userId, organizationId: defaultOrganizationId } = await this.catalogService();
|
|
63
|
+
const organizationId = this.flags.impersonate ?? defaultOrganizationId;
|
|
64
|
+
const resp = await catalogService.queryResources({
|
|
65
|
+
userId,
|
|
66
|
+
applicationName: flags.application,
|
|
67
|
+
applicationVersionId: flags.version,
|
|
68
|
+
organizationId,
|
|
69
|
+
});
|
|
70
|
+
if (flags.output === 'table') {
|
|
71
|
+
console.table(resp.resources.reduce((acc, v) => {
|
|
72
|
+
const dateStr = v.createdAt ? v.createdAt.toDate().toISOString() : '';
|
|
73
|
+
acc[dateStr] = {
|
|
74
|
+
...v,
|
|
75
|
+
attributes: v.attributes?.toJson(),
|
|
76
|
+
createdAt: dateStr,
|
|
77
|
+
updatedAt: v.updatedAt ? v.updatedAt.toDate().toISOString() : '',
|
|
78
|
+
};
|
|
79
|
+
return acc;
|
|
80
|
+
},
|
|
81
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
82
|
+
{}), [
|
|
83
|
+
'name',
|
|
84
|
+
'resourceId',
|
|
85
|
+
'applicationName',
|
|
86
|
+
'applicationVersionId',
|
|
87
|
+
'type',
|
|
88
|
+
'createdAt',
|
|
89
|
+
'updatedAt',
|
|
90
|
+
'attributes',
|
|
91
|
+
]);
|
|
92
|
+
}
|
|
93
|
+
else if (flags.output === 'json') {
|
|
94
|
+
this.log(JSON.stringify(resp, null, 2));
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
for (const r of resp.resources) {
|
|
98
|
+
console.log(`${r.name} ${r.resourceId} ${r.applicationName} ${r.applicationVersionId} ${r.type} ${r.createdAt?.toDate().toISOString()} ${r.updatedAt?.toDate().toISOString()} ${JSON.stringify(r.attributes)}`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
async run() {
|
|
103
|
+
if (this.flags.sudo) {
|
|
104
|
+
await this.queryResources(this.flags);
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
this.error('Not implemented, try --sudo mode', { exit: 1 });
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base-command.js';
|
|
2
|
+
export default class Generate extends BaseCommand<typeof Generate> {
|
|
3
|
+
static args: {};
|
|
4
|
+
static description: string;
|
|
5
|
+
static examples: string[];
|
|
6
|
+
static flags: {
|
|
7
|
+
root: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
manifest: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
};
|
|
11
|
+
run(): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=generate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../src/commands/build/generate.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AASpD,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,WAAW,CAAC,OAAO,QAAQ,CAAC;IAChE,OAAgB,IAAI,KAAM;IAE1B,OAAgB,WAAW,SAAwD;IAEnF,OAAgB,QAAQ,WAA2C;IAEnE,OAAgB,KAAK;;;;MAInB;IAEW,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CA8BlC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { valueOf } from '@liquidmetal-ai/drizzle/appify/build';
|
|
2
|
+
import { Flags } from '@oclif/core';
|
|
3
|
+
import * as fs from 'node:fs/promises';
|
|
4
|
+
import * as path from 'node:path';
|
|
5
|
+
import { BaseCommand } from '../../base-command.js';
|
|
6
|
+
import { codegenPlan, gatherEnvForHandler, HANDLERS_DIR, RAINDROP_TYPES_FILENAME, renderCodegenPlan, } from '../../codegen.js';
|
|
7
|
+
export default class Generate extends BaseCommand {
|
|
8
|
+
static args = {};
|
|
9
|
+
static description = '(re)generate all code for a LiquidMetal.AI project';
|
|
10
|
+
static examples = ['<%= config.bin %> <%= command.id %>'];
|
|
11
|
+
static flags = {
|
|
12
|
+
root: Flags.string({ char: 'r', description: 'root directory', default: process.cwd() }),
|
|
13
|
+
manifest: Flags.string({ char: 'm', description: 'manifest file', default: 'raindrop.manifest' }),
|
|
14
|
+
output: Flags.string({ char: 'o', description: 'output directory', default: 'dist' }),
|
|
15
|
+
};
|
|
16
|
+
async run() {
|
|
17
|
+
const apps = await this.loadManifest();
|
|
18
|
+
const plan = codegenPlan(apps);
|
|
19
|
+
// TODO [bosgood] Constellation support needed here
|
|
20
|
+
const app = apps[0];
|
|
21
|
+
const templateContext = {
|
|
22
|
+
applicationName: valueOf(app.name),
|
|
23
|
+
};
|
|
24
|
+
await renderCodegenPlan(plan, this.flags.root, {
|
|
25
|
+
renderScaffoldingCode: false,
|
|
26
|
+
renderUserModifiableCode: true,
|
|
27
|
+
renderNonUserModifiableCode: true,
|
|
28
|
+
overwrite: false,
|
|
29
|
+
}, templateContext);
|
|
30
|
+
// Write the gen files.
|
|
31
|
+
const handlers = app.handlers();
|
|
32
|
+
for (const handler of handlers) {
|
|
33
|
+
const dest = path.join(this.flags.root, HANDLERS_DIR, valueOf(handler.name), RAINDROP_TYPES_FILENAME);
|
|
34
|
+
await fs.mkdir(path.dirname(dest), { recursive: true });
|
|
35
|
+
await fs.writeFile(dest, gatherEnvForHandler(handler, app));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base-command.js';
|
|
2
|
+
export default class Init extends BaseCommand<typeof Init> {
|
|
3
|
+
static args: {
|
|
4
|
+
path: import("@oclif/core/interfaces").Arg<string, {
|
|
5
|
+
exists?: boolean;
|
|
6
|
+
}>;
|
|
7
|
+
};
|
|
8
|
+
static description: string;
|
|
9
|
+
static examples: string[];
|
|
10
|
+
static flags: {
|
|
11
|
+
overwrite: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
12
|
+
};
|
|
13
|
+
run(): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=init.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/commands/build/init.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAGpD,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,WAAW,CAAC,OAAO,IAAI,CAAC;IACxD,MAAM,CAAC,IAAI;;;;MAET;IAEF,MAAM,CAAC,WAAW,SAAwC;IAE1D,MAAM,CAAC,QAAQ,WAIb;IAEF,MAAM,CAAC,KAAK;;MAEV;IAEI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CA4C3B"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { mustManifestFromString } from '@liquidmetal-ai/drizzle/appify/index';
|
|
2
|
+
import { Args, Flags } from '@oclif/core';
|
|
3
|
+
import fs from 'node:fs/promises';
|
|
4
|
+
import * as path from 'node:path';
|
|
5
|
+
import { BaseCommand } from '../../base-command.js';
|
|
6
|
+
import { codegenPlan, fileExists, renderCodegenPlan } from '../../codegen.js';
|
|
7
|
+
export default class Init extends BaseCommand {
|
|
8
|
+
static args = {
|
|
9
|
+
path: Args.directory({ default: '.', description: 'Path to initialize the project in', required: false }),
|
|
10
|
+
};
|
|
11
|
+
static description = 'start a new LiquidMetal.AI project';
|
|
12
|
+
static examples = [
|
|
13
|
+
`<%= config.bin %> <%= command.id %> .
|
|
14
|
+
Initialize a project in the current directory.
|
|
15
|
+
`,
|
|
16
|
+
];
|
|
17
|
+
static flags = {
|
|
18
|
+
overwrite: Flags.boolean({ description: 'Overwrite existing files', default: false }),
|
|
19
|
+
};
|
|
20
|
+
async run() {
|
|
21
|
+
this.log(`path: ${this.args.path}`);
|
|
22
|
+
// Prepare and destination directory exists
|
|
23
|
+
if (!(await fileExists(this.args.path))) {
|
|
24
|
+
try {
|
|
25
|
+
await fs.mkdir(this.args.path, { recursive: true });
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
this.error(`Could not create directory ${this.args.path}`, { exit: 1 });
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const pathStat = await fs.lstat(this.args.path);
|
|
32
|
+
if (!pathStat.isDirectory()) {
|
|
33
|
+
this.error(`${this.args.path} is not a directory.`, { exit: 1 });
|
|
34
|
+
}
|
|
35
|
+
// Use package.json to determine if the directory is already initialized
|
|
36
|
+
if (!this.flags.overwrite && (await fileExists(path.join(this.args.path, 'package.json')))) {
|
|
37
|
+
this.error(`A project ${this.args.path} has already been initialized.`, { exit: 1 });
|
|
38
|
+
}
|
|
39
|
+
// Codegen a default configuration
|
|
40
|
+
const apps = await mustManifestFromString('application "hello-world" {}');
|
|
41
|
+
const plan = codegenPlan(apps);
|
|
42
|
+
try {
|
|
43
|
+
await renderCodegenPlan(plan, this.args.path, {
|
|
44
|
+
renderScaffoldingCode: false,
|
|
45
|
+
renderUserModifiableCode: true,
|
|
46
|
+
renderNonUserModifiableCode: true,
|
|
47
|
+
overwrite: false,
|
|
48
|
+
}, {
|
|
49
|
+
applicationName: path.basename(this.args.path),
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
this.error(`Could not initialize project at ${this.args.path}: ${error}`, { exit: 1 });
|
|
54
|
+
}
|
|
55
|
+
this.log(`Initialized LiquidMetal.AI in ${this.args.path}`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base-command.js';
|
|
2
|
+
export default class List extends BaseCommand<typeof List> {
|
|
3
|
+
static args: {};
|
|
4
|
+
static description: string;
|
|
5
|
+
static examples: string[];
|
|
6
|
+
static flags: {
|
|
7
|
+
type: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
all: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
9
|
+
output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
impersonate: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
rainbowAuthService: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
};
|
|
13
|
+
listVersions(): Promise<void>;
|
|
14
|
+
listApplications(): Promise<void>;
|
|
15
|
+
run(): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=list.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/commands/build/list.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAGpD,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,WAAW,CAAC,OAAO,IAAI,CAAC;IACxD,MAAM,CAAC,IAAI,KAAM;IAEjB,MAAM,CAAC,WAAW,SAAqC;IAEvD,MAAM,CAAC,QAAQ,WAIb;IAEF,MAAM,CAAC,KAAK;;;;;;MAoBV;IAEI,YAAY;IAmCZ,gBAAgB;IA0ChB,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAW3B"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { CatalogService } from '@liquidmetal-ai/drizzle/liquidmetal/v1alpha1/catalog_connect';
|
|
2
|
+
import { RainbowAuthService } from '@liquidmetal-ai/drizzle/liquidmetal/v1alpha1/rainbow_auth_connect';
|
|
3
|
+
import { Flags } from '@oclif/core';
|
|
4
|
+
import { BaseCommand } from '../../base-command.js';
|
|
5
|
+
import { createAuthenticatingClient, useClient } from '../../index.js';
|
|
6
|
+
export default class List extends BaseCommand {
|
|
7
|
+
static args = {};
|
|
8
|
+
static description = 'list Raindrop catalog resources';
|
|
9
|
+
static examples = [
|
|
10
|
+
`<%= config.bin %> <%= command.id %> .
|
|
11
|
+
List Raindrop catalog resources.
|
|
12
|
+
`,
|
|
13
|
+
];
|
|
14
|
+
static flags = {
|
|
15
|
+
type: Flags.string({ char: 't', description: 'resource type', default: 'application' }),
|
|
16
|
+
all: Flags.boolean({ char: 'a', description: 'show even deleted resources', default: false }),
|
|
17
|
+
output: Flags.string({
|
|
18
|
+
char: 'o',
|
|
19
|
+
description: 'output format',
|
|
20
|
+
default: 'table',
|
|
21
|
+
options: ['text', 'table', 'json'],
|
|
22
|
+
}),
|
|
23
|
+
impersonate: Flags.string({
|
|
24
|
+
char: 'i',
|
|
25
|
+
description: 'impersonate organization',
|
|
26
|
+
required: false,
|
|
27
|
+
hidden: true,
|
|
28
|
+
}),
|
|
29
|
+
rainbowAuthService: Flags.string({
|
|
30
|
+
default: 'https://liquidmetal.run/api/connect',
|
|
31
|
+
hidden: true,
|
|
32
|
+
env: 'LIQUIDMETAL_RAINBOW_AUTH_SERVICE',
|
|
33
|
+
}),
|
|
34
|
+
};
|
|
35
|
+
async listVersions() {
|
|
36
|
+
const rainbowAuth = useClient(RainbowAuthService, this.flags.rainbowAuthService);
|
|
37
|
+
const { client: catalogService, userId, organizationId: defaultOrganizationId, } = await createAuthenticatingClient(CatalogService, this.config.configDir, rainbowAuth);
|
|
38
|
+
const organizationId = this.flags.impersonate ?? defaultOrganizationId;
|
|
39
|
+
const resp = await catalogService.versions({
|
|
40
|
+
userId,
|
|
41
|
+
organizationId,
|
|
42
|
+
});
|
|
43
|
+
if (this.flags.output === 'table') {
|
|
44
|
+
console.table(resp.versions.reduce((acc, v) => {
|
|
45
|
+
const dateStr = v.createdAt ? v.createdAt.toDate().toISOString() : '';
|
|
46
|
+
acc[dateStr] = v;
|
|
47
|
+
return acc;
|
|
48
|
+
}, {}), ['versionId', 'previousVersionId']);
|
|
49
|
+
}
|
|
50
|
+
else if (this.flags.output === 'json') {
|
|
51
|
+
this.log(JSON.stringify(resp, null, 2));
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
for (const v of resp.versions) {
|
|
55
|
+
console.log(`${v.createdAt?.toDate().toISOString()} ${v.versionId}`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
async listApplications() {
|
|
60
|
+
const rainbowAuth = useClient(RainbowAuthService, this.flags.rainbowAuthService);
|
|
61
|
+
const { client: catalogService, userId, organizationId: defaultOrganizationId, } = await createAuthenticatingClient(CatalogService, this.config.configDir, rainbowAuth);
|
|
62
|
+
const organizationId = this.flags.impersonate ?? defaultOrganizationId;
|
|
63
|
+
const resp = await catalogService.applications({
|
|
64
|
+
userId,
|
|
65
|
+
organizationId,
|
|
66
|
+
showDeleted: this.flags.all,
|
|
67
|
+
});
|
|
68
|
+
if (this.flags.output === 'table') {
|
|
69
|
+
console.table(resp.applications.reduce((acc, a) => {
|
|
70
|
+
const dateStr = a.createdAt ? a.createdAt.toDate().toISOString() : '';
|
|
71
|
+
acc[dateStr] = {
|
|
72
|
+
...a,
|
|
73
|
+
deletedAt: a.deletedAt ? a.deletedAt.toDate().toISOString() : a.deletedAt,
|
|
74
|
+
};
|
|
75
|
+
return acc;
|
|
76
|
+
},
|
|
77
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
78
|
+
{}), ['name', 'versionId', 'isActive', ...(this.flags.all ? ['deletedAt'] : [])]);
|
|
79
|
+
}
|
|
80
|
+
else if (this.flags.output === 'json') {
|
|
81
|
+
this.log(JSON.stringify(resp, null, 2));
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
for (const a of resp.applications) {
|
|
85
|
+
console.log(`${a.createdAt?.toDate().toISOString()} ${a.versionId} ${a.name} (${a.isActive ? 'active' : 'inactive'})`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
async run() {
|
|
90
|
+
if (this.flags.type === 'version' || this.flags.type === 'versions') {
|
|
91
|
+
await this.listVersions();
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
else if (this.flags.type === 'app' || this.flags.type === 'application' || this.flags.type === 'applications') {
|
|
95
|
+
await this.listApplications();
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
this.error(`Unknown resource type: ${this.flags.type}`, { exit: 1 });
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base-command.js';
|
|
2
|
+
export default class Start extends BaseCommand<typeof Start> {
|
|
3
|
+
static args: {};
|
|
4
|
+
static description: string;
|
|
5
|
+
static examples: string[];
|
|
6
|
+
static flags: {
|
|
7
|
+
config: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
manifest: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
application: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
version: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
impersonate: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
rainbowAuthService: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
};
|
|
14
|
+
run(): Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=start.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../../src/commands/build/start.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD,MAAM,CAAC,OAAO,OAAO,KAAM,SAAQ,WAAW,CAAC,OAAO,KAAK,CAAC;IAC1D,MAAM,CAAC,IAAI,KAAM;IAEjB,MAAM,CAAC,WAAW,SAAkC;IAEpD,MAAM,CAAC,QAAQ,WAIb;IAEF,MAAM,CAAC,KAAK;;;;;;;MA6BV;IAEI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CA+B3B"}
|