@pump-inc/cli 0.0.1
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 +905 -0
- package/bin/dev.cmd +3 -0
- package/bin/dev.js +7 -0
- package/bin/run-pkg.js +13 -0
- package/bin/run.cmd +3 -0
- package/bin/run.js +7 -0
- package/dist/api-XWM8zKbb.cjs +21 -0
- package/dist/api-client-bnV0ib_r.cjs +1207 -0
- package/dist/base-command-GfDxcqx6.cjs +451 -0
- package/dist/bin.cjs +15 -0
- package/dist/chunk-CbDLau6x.cjs +34 -0
- package/dist/commands/admin/config/set.cjs +40 -0
- package/dist/commands/admin/organization/create.cjs +83 -0
- package/dist/commands/admin/organization/get.cjs +77 -0
- package/dist/commands/admin/organization/list.cjs +103 -0
- package/dist/commands/admin/user/create.cjs +82 -0
- package/dist/commands/api-key/create.cjs +81 -0
- package/dist/commands/api-key/delete.cjs +48 -0
- package/dist/commands/api-key/list.cjs +85 -0
- package/dist/commands/api-key/update.cjs +81 -0
- package/dist/commands/app/create.cjs +97 -0
- package/dist/commands/app/deploy.cjs +74 -0
- package/dist/commands/app/list.cjs +64 -0
- package/dist/commands/app/secrets.cjs +43 -0
- package/dist/commands/app/status.cjs +78 -0
- package/dist/commands/app/stop.cjs +49 -0
- package/dist/commands/app/usage.cjs +79 -0
- package/dist/commands/auth/test.cjs +56 -0
- package/dist/commands/config/validate.cjs +32 -0
- package/dist/commands/project/create.cjs +79 -0
- package/dist/fix-event-emitter-uhRntilb.cjs +21 -0
- package/dist/index.cjs +16 -0
- package/dist/util/api.cjs +3 -0
- package/dist/util/base-command.cjs +4 -0
- package/dist/util/fix-event-emitter.cjs +3 -0
- package/dist/util/validate-config.cjs +3 -0
- package/dist/validate-config-C9krCzRv.cjs +24 -0
- package/oclif.manifest.json +1099 -0
- package/package.json +85 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
const require_chunk = require('../../chunk-CbDLau6x.cjs');
|
|
2
|
+
const require_validate_config = require('../../validate-config-C9krCzRv.cjs');
|
|
3
|
+
const require_base_command = require('../../base-command-GfDxcqx6.cjs');
|
|
4
|
+
const require_api = require('../../api-XWM8zKbb.cjs');
|
|
5
|
+
const require_api_client = require('../../api-client-bnV0ib_r.cjs');
|
|
6
|
+
let __oclif_core = require("@oclif/core");
|
|
7
|
+
let node_fs_promises = require("node:fs/promises");
|
|
8
|
+
|
|
9
|
+
//#region src/commands/app/deploy.ts
|
|
10
|
+
var AppDeploy = class AppDeploy extends require_base_command.BaseCommand {
|
|
11
|
+
static args = { file: __oclif_core.Args.string({ description: "file to read" }) };
|
|
12
|
+
static description = "Deploy an application by providing a config file";
|
|
13
|
+
static examples = ["<%= config.bin %> <%= command.id %> config-file.yaml"];
|
|
14
|
+
static flags = {
|
|
15
|
+
force: __oclif_core.Flags.boolean({ char: "f" }),
|
|
16
|
+
name: __oclif_core.Flags.string({
|
|
17
|
+
char: "n",
|
|
18
|
+
description: "Deployment name"
|
|
19
|
+
}),
|
|
20
|
+
appId: __oclif_core.Flags.string({
|
|
21
|
+
char: "a",
|
|
22
|
+
description: "application id to deploy",
|
|
23
|
+
required: true,
|
|
24
|
+
env: "PUMPINC_APP_ID"
|
|
25
|
+
}),
|
|
26
|
+
apikey: __oclif_core.Flags.string({
|
|
27
|
+
char: "k",
|
|
28
|
+
description: "API key to use for authentication (overrides API_KEY env variable)"
|
|
29
|
+
}),
|
|
30
|
+
json: __oclif_core.Flags.boolean({ description: "Output result as JSON" })
|
|
31
|
+
};
|
|
32
|
+
async run() {
|
|
33
|
+
const { args } = await this.parse(AppDeploy);
|
|
34
|
+
const { flags } = await this.parse(AppDeploy);
|
|
35
|
+
if (!args.file) {
|
|
36
|
+
this.log("Please provide a (yaml) config file. Use --help for more information.");
|
|
37
|
+
return;
|
|
38
|
+
} else {
|
|
39
|
+
const configFile = await (0, node_fs_promises.readFile)(args.file, "utf8");
|
|
40
|
+
const apiClient = new require_api_client.ApiClient(require_api.getApiUrl(), flags.apikey || process.env.API_KEY);
|
|
41
|
+
if (await require_validate_config.validateConfigYaml(configFile, apiClient) === false) {
|
|
42
|
+
this.log(require_base_command.source_default.red("Config file is not valid"));
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (!flags.json) this.log(`- ✅ ${require_base_command.source_default.green("Config file is valid")}`);
|
|
46
|
+
const jsonBodyForDeployment = {
|
|
47
|
+
applicationId: flags.appId,
|
|
48
|
+
configYaml: Buffer.from(configFile).toString("base64")
|
|
49
|
+
};
|
|
50
|
+
const [deployment, error] = (await apiClient.deployments.create(jsonBodyForDeployment)).toTuple();
|
|
51
|
+
if (error) {
|
|
52
|
+
if (flags.json) {
|
|
53
|
+
this.log(JSON.stringify({ error: error.message }, null, 2));
|
|
54
|
+
this.exit(1);
|
|
55
|
+
} else this.log(require_base_command.source_default.red(`CLI: ${error.message}`));
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (deployment) if (flags.json) this.log(JSON.stringify({ deployment }, null, 2));
|
|
59
|
+
else {
|
|
60
|
+
this.log(require_base_command.source_default.green("- ✅ Deployment created successfully"));
|
|
61
|
+
this.log("--------------- Deployment Details ---------------");
|
|
62
|
+
this.log(require_base_command.source_default.blue("Message: " + deployment.data.message));
|
|
63
|
+
this.log(require_base_command.source_default.blue("Reconciler Job ID: " + deployment.data.reconcilerJobId));
|
|
64
|
+
}
|
|
65
|
+
else if (flags.json) {
|
|
66
|
+
this.log(JSON.stringify({ error: "Failed to create deployment" }, null, 2));
|
|
67
|
+
this.exit(1);
|
|
68
|
+
} else this.log(require_base_command.source_default.red("Failed to create deployment :("));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
//#endregion
|
|
74
|
+
module.exports = AppDeploy;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
const require_chunk = require('../../chunk-CbDLau6x.cjs');
|
|
2
|
+
const require_base_command = require('../../base-command-GfDxcqx6.cjs');
|
|
3
|
+
const require_api = require('../../api-XWM8zKbb.cjs');
|
|
4
|
+
const require_api_client = require('../../api-client-bnV0ib_r.cjs');
|
|
5
|
+
let __oclif_core = require("@oclif/core");
|
|
6
|
+
|
|
7
|
+
//#region src/commands/app/list.ts
|
|
8
|
+
var AppList = class AppList extends require_base_command.BaseCommand {
|
|
9
|
+
static args = { file: __oclif_core.Args.string({ description: "file to read" }) };
|
|
10
|
+
static description = "describe the command here";
|
|
11
|
+
static examples = ["<%= config.bin %> <%= command.id %>"];
|
|
12
|
+
static flags = {
|
|
13
|
+
verbose: __oclif_core.Flags.boolean({
|
|
14
|
+
char: "v",
|
|
15
|
+
description: "Show detailed application info"
|
|
16
|
+
}),
|
|
17
|
+
apikey: __oclif_core.Flags.string({
|
|
18
|
+
char: "k",
|
|
19
|
+
description: "API key to use for authentication (overrides API_KEY env variable)"
|
|
20
|
+
})
|
|
21
|
+
};
|
|
22
|
+
async run() {
|
|
23
|
+
const { flags } = await this.parse(AppList);
|
|
24
|
+
const [apps, error] = (await new require_api_client.ApiClient(require_api.getApiUrl(), flags.apikey || process.env.API_KEY).applications.list()).toTuple();
|
|
25
|
+
if (error) {
|
|
26
|
+
this.log(`Error fetching applications: ${error.message}`);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
if (apps.applications.length === 0) {
|
|
30
|
+
this.log("No applications found.");
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
this.log("Applications by Project:");
|
|
34
|
+
const appsByProject = /* @__PURE__ */ new Map();
|
|
35
|
+
for (const app of apps.applications) {
|
|
36
|
+
const projectKey = app.project.id;
|
|
37
|
+
if (!appsByProject.has(projectKey)) appsByProject.set(projectKey, {
|
|
38
|
+
projectName: app.project.name,
|
|
39
|
+
projectId: app.project.id,
|
|
40
|
+
apps: []
|
|
41
|
+
});
|
|
42
|
+
appsByProject.get(projectKey)?.apps.push(app);
|
|
43
|
+
}
|
|
44
|
+
for (const [, projectDetails] of appsByProject) {
|
|
45
|
+
this.log(`📦 ${require_base_command.source_default.blueBright(projectDetails.projectName)} ${require_base_command.source_default.dim(`(${projectDetails.projectId})`)}`);
|
|
46
|
+
for (let i = 0; i < projectDetails.apps.length; i++) {
|
|
47
|
+
const app = projectDetails.apps[i];
|
|
48
|
+
const isLast = i === projectDetails.apps.length - 1;
|
|
49
|
+
const branch = isLast ? "└─" : "├─";
|
|
50
|
+
const continuation = isLast ? " " : "│ ";
|
|
51
|
+
const statusColor = app.status === "active" ? require_base_command.source_default.green : app.status === "stopped" ? require_base_command.source_default.red : require_base_command.source_default.yellow;
|
|
52
|
+
this.log(` ${branch} ⚡ ${require_base_command.source_default.yellow(app.name)} ${require_base_command.source_default.dim(`(${app.id})`)} ${statusColor(`[${app.status}]`)}`);
|
|
53
|
+
if (flags.verbose) {
|
|
54
|
+
this.log(` ${continuation} Created: ${require_base_command.source_default.dim(new Date(app.createdAt).toLocaleString())}`);
|
|
55
|
+
this.log(` ${continuation} Owner: ${require_base_command.source_default.dim(app.ownerId)}`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
this.log("");
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
//#endregion
|
|
64
|
+
module.exports = AppList;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const require_chunk = require('../../chunk-CbDLau6x.cjs');
|
|
2
|
+
const require_base_command = require('../../base-command-GfDxcqx6.cjs');
|
|
3
|
+
const require_api = require('../../api-XWM8zKbb.cjs');
|
|
4
|
+
const require_api_client = require('../../api-client-bnV0ib_r.cjs');
|
|
5
|
+
let __oclif_core = require("@oclif/core");
|
|
6
|
+
|
|
7
|
+
//#region src/commands/app/secrets.ts
|
|
8
|
+
var AppSecrets = class AppSecrets extends require_base_command.BaseCommand {
|
|
9
|
+
static args = { applicationId: __oclif_core.Args.string({
|
|
10
|
+
description: "Application ID to list secrets for",
|
|
11
|
+
required: true
|
|
12
|
+
}) };
|
|
13
|
+
static description = "List all secrets for an application";
|
|
14
|
+
static examples = ["<%= config.bin %> <%= command.id %> app_12345", "<%= config.bin %> <%= command.id %> app_12345 -k your-api-key"];
|
|
15
|
+
static flags = { apikey: __oclif_core.Flags.string({
|
|
16
|
+
char: "k",
|
|
17
|
+
description: "API key to use for authentication (overrides API_KEY env variable)"
|
|
18
|
+
}) };
|
|
19
|
+
async run() {
|
|
20
|
+
const { args, flags } = await this.parse(AppSecrets);
|
|
21
|
+
const [result, error] = (await new require_api_client.ApiClient(require_api.getApiUrl(), flags.apikey || process.env.API_KEY).applications.secrets.list(args.applicationId)).toTuple();
|
|
22
|
+
if (error) {
|
|
23
|
+
this.log(require_base_command.source_default.red(`Error fetching secrets: ${error.message}`));
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if (result.secrets.length === 0) {
|
|
27
|
+
this.log(require_base_command.source_default.yellow("No secrets found for this application."));
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
this.log(require_base_command.source_default.bold(`\nSecrets for application ${require_base_command.source_default.cyan(args.applicationId)}:\n`));
|
|
31
|
+
for (const secret of result.secrets) {
|
|
32
|
+
this.log(require_base_command.source_default.green(` • ${secret.name}`));
|
|
33
|
+
if (secret.description) this.log(` ${require_base_command.source_default.gray(secret.description)}`);
|
|
34
|
+
this.log(` ${require_base_command.source_default.dim(`Created: ${new Date(secret.createdAt).toLocaleString()}`)}`);
|
|
35
|
+
this.log(` ${require_base_command.source_default.dim(`Updated: ${new Date(secret.updatedAt).toLocaleString()}`)}`);
|
|
36
|
+
this.log("");
|
|
37
|
+
}
|
|
38
|
+
this.log(require_base_command.source_default.dim(`Total: ${result.secrets.length} secret${result.secrets.length === 1 ? "" : "s"}`));
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
//#endregion
|
|
43
|
+
module.exports = AppSecrets;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
const require_chunk = require('../../chunk-CbDLau6x.cjs');
|
|
2
|
+
const require_fix_event_emitter = require('../../fix-event-emitter-uhRntilb.cjs');
|
|
3
|
+
const require_base_command = require('../../base-command-GfDxcqx6.cjs');
|
|
4
|
+
const require_api = require('../../api-XWM8zKbb.cjs');
|
|
5
|
+
const require_api_client = require('../../api-client-bnV0ib_r.cjs');
|
|
6
|
+
let __oclif_core = require("@oclif/core");
|
|
7
|
+
|
|
8
|
+
//#region src/commands/app/status.ts
|
|
9
|
+
require_fix_event_emitter.fixEventEmitterWarning();
|
|
10
|
+
var AppStatus = class AppStatus extends require_base_command.BaseCommand {
|
|
11
|
+
static args = { applicationId: __oclif_core.Args.string({ description: "Application ID to get status for eg. app_1234567890abcdef" }) };
|
|
12
|
+
static description = "Get the status of a specific application by its ID";
|
|
13
|
+
static examples = ["<%= config.bin %> <%= command.id %>"];
|
|
14
|
+
static flags = { apikey: __oclif_core.Flags.string({
|
|
15
|
+
char: "k",
|
|
16
|
+
description: "API key to use for authentication (overrides API_KEY env variable)"
|
|
17
|
+
}) };
|
|
18
|
+
generateDomainName(publicWebDomain, organizationDomain, applicationDomain) {
|
|
19
|
+
return publicWebDomain.replace("web.", `${applicationDomain}.${organizationDomain}.`);
|
|
20
|
+
}
|
|
21
|
+
async run() {
|
|
22
|
+
const { flags } = await this.parse(AppStatus);
|
|
23
|
+
const { args } = await this.parse(AppStatus);
|
|
24
|
+
if (!args.applicationId) this.error("Application ID is required. Please provide it as an argument.");
|
|
25
|
+
const applicationId = args.applicationId;
|
|
26
|
+
const apiClient = new require_api_client.ApiClient(require_api.getApiUrl(), flags.apikey || process.env.API_KEY);
|
|
27
|
+
const [application, applicationError] = (await apiClient.applications.get(applicationId)).toTuple();
|
|
28
|
+
if (applicationError) this.error(`Failed to get application details: ${applicationError.message}`);
|
|
29
|
+
const [webSettings, webSettingsError] = (await apiClient.config.getWebSettings()).toTuple();
|
|
30
|
+
if (webSettingsError) this.error(`Failed to get web settings: ${webSettingsError.message}`);
|
|
31
|
+
const [applicationRuns, applicationRunsError] = (await apiClient.applications.runs.getBreakdown(applicationId)).toTuple();
|
|
32
|
+
if (applicationRunsError) this.error(`Failed to get application runs: ${applicationRunsError.message}`);
|
|
33
|
+
const [executionData, executionDataError] = (await apiClient.applications.usage.getExecutionUsage(applicationId)).toTuple();
|
|
34
|
+
if (executionDataError) this.error(`Failed to get execution data: ${executionDataError.message}`);
|
|
35
|
+
let totalExecutionUnitsActive = 0;
|
|
36
|
+
let totalExecutionUnitsIdle = 0;
|
|
37
|
+
let totalExecutionUnitsAccountedFor = 0;
|
|
38
|
+
for (const usage of executionData.usage) {
|
|
39
|
+
totalExecutionUnitsActive += Number(usage.executionUnitsActive);
|
|
40
|
+
totalExecutionUnitsIdle += Number(usage.executionUnitsIddle);
|
|
41
|
+
totalExecutionUnitsAccountedFor += Number(usage.executionUnitsTotal);
|
|
42
|
+
}
|
|
43
|
+
let successfulRuns = 0;
|
|
44
|
+
let failedRuns = 0;
|
|
45
|
+
for (const run of applicationRuns.breakdown) {
|
|
46
|
+
successfulRuns += run.successCount;
|
|
47
|
+
failedRuns += run.failureCount;
|
|
48
|
+
}
|
|
49
|
+
const totalRuns = successfulRuns + failedRuns;
|
|
50
|
+
const orgDomainName = application.project.organization.domainName;
|
|
51
|
+
const appIdDomain = this.generateDomainName(webSettings?.publicDomain ?? "", orgDomainName ?? "", applicationId.replace("_", "-"));
|
|
52
|
+
let appNameDomain = null;
|
|
53
|
+
if (application.domainName !== null) appNameDomain = this.generateDomainName(webSettings?.publicDomain ?? "", orgDomainName ?? "", application.domainName);
|
|
54
|
+
console.log("");
|
|
55
|
+
console.log(require_base_command.source_default.green("--- [ Application Info ] -------------|"));
|
|
56
|
+
console.log("");
|
|
57
|
+
console.log(`Name: ${require_base_command.source_default.blue(application.name)}`);
|
|
58
|
+
console.log(`Domain: ${require_base_command.source_default.blue(appIdDomain)}`);
|
|
59
|
+
console.log(`Custom domain: ${require_base_command.source_default.blue(appNameDomain ? appNameDomain : "-- not set --")}`);
|
|
60
|
+
console.log("");
|
|
61
|
+
console.log(require_base_command.source_default.green("--- [ Runs ] --------------------------|"));
|
|
62
|
+
console.log("");
|
|
63
|
+
console.log(`Successful: ${require_base_command.source_default.green(successfulRuns)} (${successfulRuns === 0 ? "0%" : `${successfulRuns / totalRuns * 100}%`})`);
|
|
64
|
+
console.log(`Failed Runs: ${require_base_command.source_default.red(failedRuns)} (${failedRuns === 0 ? "0%" : `${failedRuns / totalRuns * 100}%`})`);
|
|
65
|
+
console.log("");
|
|
66
|
+
console.log(require_base_command.source_default.green("--- [ Execution Units ] ---------------|"));
|
|
67
|
+
console.log("");
|
|
68
|
+
console.log(` Execution Units Active: ${require_base_command.source_default.blue(totalExecutionUnitsActive)}`);
|
|
69
|
+
console.log(` Execution Units Idle: ${require_base_command.source_default.blue(totalExecutionUnitsIdle)}`);
|
|
70
|
+
console.log(require_base_command.source_default.bold(`[$] Spent Execution Units: ${require_base_command.source_default.blue(totalExecutionUnitsAccountedFor)}`));
|
|
71
|
+
console.log("");
|
|
72
|
+
console.log(require_base_command.source_default.gray("---------------------------------------|"));
|
|
73
|
+
console.log("");
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
//#endregion
|
|
78
|
+
module.exports = AppStatus;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
const require_chunk = require('../../chunk-CbDLau6x.cjs');
|
|
2
|
+
const require_base_command = require('../../base-command-GfDxcqx6.cjs');
|
|
3
|
+
const require_api = require('../../api-XWM8zKbb.cjs');
|
|
4
|
+
const require_api_client = require('../../api-client-bnV0ib_r.cjs');
|
|
5
|
+
let __oclif_core = require("@oclif/core");
|
|
6
|
+
|
|
7
|
+
//#region src/commands/app/stop.ts
|
|
8
|
+
var AppStop = class AppStop extends require_base_command.BaseCommand {
|
|
9
|
+
static description = "Stop the running deployment for an application";
|
|
10
|
+
static examples = ["<%= config.bin %> <%= command.id %> --appId <application-id>"];
|
|
11
|
+
static flags = {
|
|
12
|
+
appId: __oclif_core.Flags.string({
|
|
13
|
+
char: "a",
|
|
14
|
+
description: "application id to stop deployment for",
|
|
15
|
+
required: true,
|
|
16
|
+
env: "PUMPINC_APP_ID"
|
|
17
|
+
}),
|
|
18
|
+
apikey: __oclif_core.Flags.string({
|
|
19
|
+
char: "k",
|
|
20
|
+
description: "API key to use for authentication (overrides API_KEY env variable)"
|
|
21
|
+
}),
|
|
22
|
+
json: __oclif_core.Flags.boolean({ description: "Output result as JSON" })
|
|
23
|
+
};
|
|
24
|
+
async run() {
|
|
25
|
+
const { flags } = await this.parse(AppStop);
|
|
26
|
+
const [result, error] = (await new require_api_client.ApiClient(require_api.getApiUrl(), flags.apikey || process.env.API_KEY).deployments.stop(flags.appId)).toTuple();
|
|
27
|
+
if (error) {
|
|
28
|
+
if (flags.json) {
|
|
29
|
+
this.log(JSON.stringify({ error: error.message }, null, 2));
|
|
30
|
+
this.exit(1);
|
|
31
|
+
} else this.log(require_base_command.source_default.red(`CLI: ${error.message}`));
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (result) if (flags.json) this.log(JSON.stringify(result, null, 2));
|
|
35
|
+
else {
|
|
36
|
+
this.log(require_base_command.source_default.green("- ✅ Deployment stop job created successfully"));
|
|
37
|
+
this.log("--------------- Stop Job Details ---------------");
|
|
38
|
+
this.log(require_base_command.source_default.blue("Message: " + result.data.message));
|
|
39
|
+
this.log(require_base_command.source_default.blue("Reconciler Job ID: " + result.data.reconcilerJobId));
|
|
40
|
+
}
|
|
41
|
+
else if (flags.json) {
|
|
42
|
+
this.log(JSON.stringify({ error: "Failed to stop deployment" }, null, 2));
|
|
43
|
+
this.exit(1);
|
|
44
|
+
} else this.log(require_base_command.source_default.red("Failed to stop deployment :("));
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
//#endregion
|
|
49
|
+
module.exports = AppStop;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
const require_chunk = require('../../chunk-CbDLau6x.cjs');
|
|
2
|
+
const require_base_command = require('../../base-command-GfDxcqx6.cjs');
|
|
3
|
+
const require_api = require('../../api-XWM8zKbb.cjs');
|
|
4
|
+
const require_api_client = require('../../api-client-bnV0ib_r.cjs');
|
|
5
|
+
let __oclif_core = require("@oclif/core");
|
|
6
|
+
|
|
7
|
+
//#region src/commands/app/usage.ts
|
|
8
|
+
var AppUsage = class AppUsage extends require_base_command.BaseCommand {
|
|
9
|
+
static args = { applicationId: __oclif_core.Args.string({ description: "application ID to get usage for" }) };
|
|
10
|
+
static description = "get usage information for an application including execution units and CPU/memory usage";
|
|
11
|
+
static examples = ["<%= config.bin %> <%= command.id %> app_aaaabbbbccccddddeeee"];
|
|
12
|
+
static flags = {
|
|
13
|
+
hide: __oclif_core.Flags.boolean({
|
|
14
|
+
char: "h",
|
|
15
|
+
description: "hide deployment details",
|
|
16
|
+
default: false,
|
|
17
|
+
required: false
|
|
18
|
+
}),
|
|
19
|
+
apikey: __oclif_core.Flags.string({
|
|
20
|
+
char: "k",
|
|
21
|
+
description: "API key to use for authentication (overrides API_KEY env variable)"
|
|
22
|
+
})
|
|
23
|
+
};
|
|
24
|
+
async run() {
|
|
25
|
+
const { args, flags } = await this.parse(AppUsage);
|
|
26
|
+
const apiClient = new require_api_client.ApiClient(require_api.getApiUrl(), flags.apikey || process.env.API_KEY);
|
|
27
|
+
const applicationId = args.applicationId;
|
|
28
|
+
if (!applicationId) {
|
|
29
|
+
this.log("Please provide an application ID. Use --help for more information.");
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
this.log("");
|
|
33
|
+
this.log(`Application usage for ${applicationId}:`);
|
|
34
|
+
this.log("");
|
|
35
|
+
const [executionUnitsData, executionUnitsError] = (await apiClient.applications.usage.getExecutionUnitsCurrentMonth(applicationId)).toTuple();
|
|
36
|
+
if (executionUnitsError) this.log(require_base_command.source_default.red(`Failed to get execution units: ${executionUnitsError.message}`));
|
|
37
|
+
else if (executionUnitsData.executionUnits) {
|
|
38
|
+
const eu = executionUnitsData.executionUnits;
|
|
39
|
+
this.log(require_base_command.source_default.cyan(`------------- [Execution Units - Current Month] --------------`));
|
|
40
|
+
this.log(`Organization: ${require_base_command.source_default.dim(eu.organizationId)}`);
|
|
41
|
+
this.log(`Project: ${require_base_command.source_default.dim(eu.projectId)}`);
|
|
42
|
+
this.log(`Application: ${require_base_command.source_default.dim(eu.applicationId)}`);
|
|
43
|
+
this.log("");
|
|
44
|
+
this.log(`Execution Units:`);
|
|
45
|
+
this.log(` ├ Active: ${require_base_command.source_default.green(eu.totalExecutionUnitsActive)}`);
|
|
46
|
+
this.log(` ├ Idle: ${require_base_command.source_default.yellow(eu.totalExecutionUnitsIdle)}`);
|
|
47
|
+
this.log(` └ Total: ${require_base_command.source_default.blue(eu.totalExecutionUnits)}`);
|
|
48
|
+
this.log("");
|
|
49
|
+
} else {
|
|
50
|
+
this.log(require_base_command.source_default.yellow(`No execution units data available for this application.`));
|
|
51
|
+
this.log("");
|
|
52
|
+
}
|
|
53
|
+
const [usageData, usageError] = (await apiClient.applications.usage.get(applicationId)).toTuple();
|
|
54
|
+
if (usageError) {
|
|
55
|
+
this.log(require_base_command.source_default.red(`Failed to get CPU/memory usage: ${usageError.message}`));
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (flags.hide === false) {
|
|
59
|
+
this.log(require_base_command.source_default.green(`------------- [Deployments] --------------`));
|
|
60
|
+
usageData.usage.deployments.forEach((deployment) => {
|
|
61
|
+
this.log("");
|
|
62
|
+
this.log(`Deployment ID: ${require_base_command.source_default.green(deployment.deploymentId)}`);
|
|
63
|
+
this.log(` ├ CPU Cores 1h: ${require_base_command.source_default.green(deployment.cpuCoresSum1h)}`);
|
|
64
|
+
this.log(` ├ CPU Cores 24h: ${require_base_command.source_default.green(deployment.cpuCoresSum24h)}`);
|
|
65
|
+
this.log(` ├ CPU Cores 7d: ${require_base_command.source_default.green(deployment.cpuCoresSum7d)}`);
|
|
66
|
+
this.log(` └ CPU Cores 30d: ${require_base_command.source_default.green(deployment.cpuCoresSum30d)}`);
|
|
67
|
+
this.log("");
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
this.log(require_base_command.source_default.blue(`--------------- [TOTAL] -----------------`));
|
|
71
|
+
this.log(`CPU Cores 1h: ${require_base_command.source_default.blue(usageData.usage.totals.cpuCoresSum1h)}`);
|
|
72
|
+
this.log(`CPU Cores 24h: ${require_base_command.source_default.blue(usageData.usage.totals.cpuCoresSum24h)}`);
|
|
73
|
+
this.log(`CPU Cores 7d: ${require_base_command.source_default.blue(usageData.usage.totals.cpuCoresSum7d)}`);
|
|
74
|
+
this.log(`CPU Cores 30d: ${require_base_command.source_default.blue(usageData.usage.totals.cpuCoresSum30d)}`);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
//#endregion
|
|
79
|
+
module.exports = AppUsage;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
const require_chunk = require('../../chunk-CbDLau6x.cjs');
|
|
2
|
+
const require_fix_event_emitter = require('../../fix-event-emitter-uhRntilb.cjs');
|
|
3
|
+
const require_base_command = require('../../base-command-GfDxcqx6.cjs');
|
|
4
|
+
const require_api = require('../../api-XWM8zKbb.cjs');
|
|
5
|
+
const require_api_client = require('../../api-client-bnV0ib_r.cjs');
|
|
6
|
+
let __oclif_core = require("@oclif/core");
|
|
7
|
+
|
|
8
|
+
//#region src/commands/auth/test.ts
|
|
9
|
+
require_fix_event_emitter.fixEventEmitterWarning();
|
|
10
|
+
var AuthTest = class AuthTest extends require_base_command.BaseCommand {
|
|
11
|
+
static description = "Test API authentication with the configured API key";
|
|
12
|
+
static examples = ["<%= config.bin %> <%= command.id %>", "<%= config.bin %> <%= command.id %> --verbose"];
|
|
13
|
+
static flags = {
|
|
14
|
+
verbose: __oclif_core.Flags.boolean({
|
|
15
|
+
char: "v",
|
|
16
|
+
description: "Show detailed authentication information"
|
|
17
|
+
}),
|
|
18
|
+
apikey: __oclif_core.Flags.string({
|
|
19
|
+
char: "k",
|
|
20
|
+
description: "API key to use for authentication (overrides API_KEY env variable)"
|
|
21
|
+
})
|
|
22
|
+
};
|
|
23
|
+
async run() {
|
|
24
|
+
const { flags } = await this.parse(AuthTest);
|
|
25
|
+
if (!process.env.API_KEY && !flags.apikey) this.error(require_base_command.source_default.red("❌ API_KEY environment variable is not set. Please configure your API key."));
|
|
26
|
+
const apiUrl = require_api.getApiUrl();
|
|
27
|
+
const apiClient = new require_api_client.ApiClient(apiUrl, flags.apikey || process.env.API_KEY);
|
|
28
|
+
if (flags.verbose) {
|
|
29
|
+
this.log(require_base_command.source_default.blue("🔧 Testing authentication..."));
|
|
30
|
+
this.log(require_base_command.source_default.gray(` API URL: ${apiUrl}`));
|
|
31
|
+
this.log(require_base_command.source_default.gray(` API Key: ${process.env.API_KEY.substring(0, 15)}...`));
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
const [result, error] = (await apiClient.auth.test()).toTuple();
|
|
35
|
+
if (error) {
|
|
36
|
+
this.log(require_base_command.source_default.red("❌ Authentication test failed"));
|
|
37
|
+
this.log(require_base_command.source_default.red(` Error: ${error.message}`));
|
|
38
|
+
this.exit(1);
|
|
39
|
+
}
|
|
40
|
+
this.log(require_base_command.source_default.green("✅ Authentication successful"));
|
|
41
|
+
if (flags.verbose && result) {
|
|
42
|
+
this.log(require_base_command.source_default.gray(` Message: ${result.message}`));
|
|
43
|
+
this.log(require_base_command.source_default.gray(` User ID: ${result.userId}`));
|
|
44
|
+
this.log(require_base_command.source_default.gray(` Organization ID: ${result.orgId}`));
|
|
45
|
+
this.log(require_base_command.source_default.gray(` Auth Type: ${result.authType}`));
|
|
46
|
+
}
|
|
47
|
+
} catch (err) {
|
|
48
|
+
this.log(require_base_command.source_default.red("❌ Authentication test failed"));
|
|
49
|
+
this.log(require_base_command.source_default.red(` Unexpected error: ${err instanceof Error ? err.message : String(err)}`));
|
|
50
|
+
this.exit(1);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
//#endregion
|
|
56
|
+
module.exports = AuthTest;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const require_chunk = require('../../chunk-CbDLau6x.cjs');
|
|
2
|
+
const require_validate_config = require('../../validate-config-C9krCzRv.cjs');
|
|
3
|
+
const require_base_command = require('../../base-command-GfDxcqx6.cjs');
|
|
4
|
+
require('../../api-XWM8zKbb.cjs');
|
|
5
|
+
const require_api_client = require('../../api-client-bnV0ib_r.cjs');
|
|
6
|
+
let __oclif_core = require("@oclif/core");
|
|
7
|
+
let node_fs_promises = require("node:fs/promises");
|
|
8
|
+
|
|
9
|
+
//#region src/commands/config/validate.ts
|
|
10
|
+
var ConfigValidate = class ConfigValidate extends require_base_command.BaseCommand {
|
|
11
|
+
static args = { file: __oclif_core.Args.string({ description: "file to read" }) };
|
|
12
|
+
static description = "validate a config file";
|
|
13
|
+
static examples = ["<%= config.bin %> <%= command.id %> <file>"];
|
|
14
|
+
static flags = { apikey: __oclif_core.Flags.string({
|
|
15
|
+
char: "k",
|
|
16
|
+
description: "API key to use for authentication (overrides API_KEY env variable)"
|
|
17
|
+
}) };
|
|
18
|
+
async run() {
|
|
19
|
+
const { args, flags } = await this.parse(ConfigValidate);
|
|
20
|
+
if (!args.file) {
|
|
21
|
+
this.log("Please provide a (yaml) config file. Use --help for more information.");
|
|
22
|
+
return;
|
|
23
|
+
} else {
|
|
24
|
+
const isConfigValid = await require_validate_config.validateConfigYaml(await (0, node_fs_promises.readFile)(args.file, "utf8"), new require_api_client.ApiClient("http://localhost:8000", flags.apikey || process.env.API_KEY));
|
|
25
|
+
if (isConfigValid === false) this.log(require_base_command.source_default.red("⚠️ Config file is not valid"));
|
|
26
|
+
if (isConfigValid === true) this.log(require_base_command.source_default.green("✅ Config file is valid"));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
//#endregion
|
|
32
|
+
module.exports = ConfigValidate;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
const require_chunk = require('../../chunk-CbDLau6x.cjs');
|
|
2
|
+
const require_fix_event_emitter = require('../../fix-event-emitter-uhRntilb.cjs');
|
|
3
|
+
const require_base_command = require('../../base-command-GfDxcqx6.cjs');
|
|
4
|
+
const require_api = require('../../api-XWM8zKbb.cjs');
|
|
5
|
+
const require_api_client = require('../../api-client-bnV0ib_r.cjs');
|
|
6
|
+
let __oclif_core = require("@oclif/core");
|
|
7
|
+
|
|
8
|
+
//#region src/commands/project/create.ts
|
|
9
|
+
require_fix_event_emitter.fixEventEmitterWarning();
|
|
10
|
+
var ProjectCreate = class ProjectCreate extends require_base_command.BaseCommand {
|
|
11
|
+
static args = { name: __oclif_core.Args.string({
|
|
12
|
+
description: "Project name",
|
|
13
|
+
required: true
|
|
14
|
+
}) };
|
|
15
|
+
static description = "Create a new project in your organization";
|
|
16
|
+
static examples = [
|
|
17
|
+
"<%= config.bin %> <%= command.id %> \"My Project\"",
|
|
18
|
+
"<%= config.bin %> <%= command.id %> \"Web App\" --description=\"A web application project\"",
|
|
19
|
+
"<%= config.bin %> <%= command.id %> \"API Project\" --description=\"Backend API services\" --status=active",
|
|
20
|
+
"<%= config.bin %> <%= command.id %> \"My Project\" --json"
|
|
21
|
+
];
|
|
22
|
+
static flags = {
|
|
23
|
+
description: __oclif_core.Flags.string({
|
|
24
|
+
char: "d",
|
|
25
|
+
description: "Project description"
|
|
26
|
+
}),
|
|
27
|
+
status: __oclif_core.Flags.string({
|
|
28
|
+
char: "s",
|
|
29
|
+
description: "Project status",
|
|
30
|
+
options: [
|
|
31
|
+
"active",
|
|
32
|
+
"inactive",
|
|
33
|
+
"archived"
|
|
34
|
+
],
|
|
35
|
+
default: "active"
|
|
36
|
+
}),
|
|
37
|
+
apikey: __oclif_core.Flags.string({
|
|
38
|
+
char: "k",
|
|
39
|
+
description: "API key to use for authentication (overrides API_KEY env variable)"
|
|
40
|
+
}),
|
|
41
|
+
json: __oclif_core.Flags.boolean({ description: "Output result as JSON" })
|
|
42
|
+
};
|
|
43
|
+
async run() {
|
|
44
|
+
const { args, flags } = await this.parse(ProjectCreate);
|
|
45
|
+
const apiClient = new require_api_client.ApiClient(require_api.getApiUrl(), flags.apikey || process.env.API_KEY);
|
|
46
|
+
const projectData = {
|
|
47
|
+
name: args.name,
|
|
48
|
+
...flags.description && { description: flags.description },
|
|
49
|
+
...flags.status && { status: flags.status }
|
|
50
|
+
};
|
|
51
|
+
if (!flags.json) this.log(require_base_command.source_default.gray("Creating project..."));
|
|
52
|
+
const [result, error] = (await apiClient.projects.create(projectData)).toTuple();
|
|
53
|
+
if (error) {
|
|
54
|
+
if (flags.json) {
|
|
55
|
+
this.log(JSON.stringify({ error: error.message }, null, 2));
|
|
56
|
+
this.exit(1);
|
|
57
|
+
} else this.error(`Failed to create project: ${error.message}`);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const project = result.data.project;
|
|
61
|
+
if (flags.json) this.log(JSON.stringify({ project }, null, 2));
|
|
62
|
+
else {
|
|
63
|
+
this.log(require_base_command.source_default.green("✓ Project created successfully!"));
|
|
64
|
+
this.log(require_base_command.source_default.white(`ID: ${require_base_command.source_default.cyan(project.id)}`));
|
|
65
|
+
this.log(require_base_command.source_default.white(`Name: ${require_base_command.source_default.cyan(project.name)}`));
|
|
66
|
+
const statusColor = {
|
|
67
|
+
active: require_base_command.source_default.green,
|
|
68
|
+
inactive: require_base_command.source_default.gray,
|
|
69
|
+
archived: require_base_command.source_default.yellow
|
|
70
|
+
}[project.status] || require_base_command.source_default.gray;
|
|
71
|
+
this.log(require_base_command.source_default.white(`Status: ${statusColor(project.status)}`));
|
|
72
|
+
this.log(require_base_command.source_default.white(`Created: ${require_base_command.source_default.gray(new Date(project.createdAt).toLocaleDateString())}`));
|
|
73
|
+
this.log(require_base_command.source_default.white(`Organization ID: ${require_base_command.source_default.gray(project.organizationId)}`));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
//#endregion
|
|
79
|
+
module.exports = ProjectCreate;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-CbDLau6x.cjs');
|
|
2
|
+
let node_process = require("node:process");
|
|
3
|
+
node_process = require_chunk.__toESM(node_process);
|
|
4
|
+
|
|
5
|
+
//#region src/util/fix-event-emitter.ts
|
|
6
|
+
/**
|
|
7
|
+
* Fix EventEmitter memory leak warning by increasing max listeners
|
|
8
|
+
* This is needed due to how oclif handles command loading with bundled commands
|
|
9
|
+
*/
|
|
10
|
+
function fixEventEmitterWarning() {
|
|
11
|
+
if (node_process.default.stdout && node_process.default.stdout.setMaxListeners) node_process.default.stdout.setMaxListeners(50);
|
|
12
|
+
if (node_process.default.stderr && node_process.default.stderr.setMaxListeners) node_process.default.stderr.setMaxListeners(50);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
Object.defineProperty(exports, 'fixEventEmitterWarning', {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () {
|
|
19
|
+
return fixEventEmitterWarning;
|
|
20
|
+
}
|
|
21
|
+
});
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-CbDLau6x.cjs');
|
|
2
|
+
let node_process = require("node:process");
|
|
3
|
+
node_process = require_chunk.__toESM(node_process);
|
|
4
|
+
let __oclif_core = require("@oclif/core");
|
|
5
|
+
|
|
6
|
+
//#region src/index.ts
|
|
7
|
+
if (node_process.default.stdout && node_process.default.stdout.setMaxListeners) node_process.default.stdout.setMaxListeners(50);
|
|
8
|
+
if (node_process.default.stderr && node_process.default.stderr.setMaxListeners) node_process.default.stderr.setMaxListeners(50);
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
11
|
+
Object.defineProperty(exports, 'run', {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () {
|
|
14
|
+
return __oclif_core.run;
|
|
15
|
+
}
|
|
16
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/util/validate-config.ts
|
|
3
|
+
const validateConfigYaml = async (config, client, printErrors = true) => {
|
|
4
|
+
const [isValid, error] = (await client.config.validateYaml(config)).toTuple();
|
|
5
|
+
if (error && printErrors) {
|
|
6
|
+
if (error.issues) {
|
|
7
|
+
console.log("Errors:");
|
|
8
|
+
error.issues.forEach((issue) => {
|
|
9
|
+
console.log(`${issue.message} at ${issue.path.join(".")}`);
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
if (error) return false;
|
|
14
|
+
if (isValid.valid === true) return true;
|
|
15
|
+
return false;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
Object.defineProperty(exports, 'validateConfigYaml', {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () {
|
|
22
|
+
return validateConfigYaml;
|
|
23
|
+
}
|
|
24
|
+
});
|