@relesio/cli 0.2.6 → 0.3.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 +40 -18
- package/dist/commands/auth/__tests__/login.test.d.ts +12 -0
- package/dist/commands/auth/__tests__/login.test.js +450 -0
- package/dist/commands/auth/login.d.ts +77 -0
- package/dist/commands/auth/login.js +381 -58
- package/dist/commands/environments/create.d.ts +2 -0
- package/dist/commands/environments/create.js +53 -0
- package/dist/commands/environments/get.d.ts +2 -0
- package/dist/commands/environments/get.js +65 -0
- package/dist/commands/environments/index.d.ts +2 -0
- package/dist/commands/environments/index.js +12 -0
- package/dist/commands/environments/list.d.ts +2 -0
- package/dist/commands/environments/list.js +54 -0
- package/dist/commands/environments/update.d.ts +2 -0
- package/dist/commands/environments/update.js +51 -0
- package/dist/commands/organizations/set.js +21 -11
- package/dist/index.js +10 -4
- package/dist/lib/api/client.js +2 -1
- package/dist/lib/api/environments.d.ts +62 -0
- package/dist/lib/api/environments.js +42 -0
- package/dist/lib/version.d.ts +2 -0
- package/dist/lib/version.js +5 -0
- package/package.json +4 -2
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import ora from "ora";
|
|
3
|
+
import { RelesioAPIClient } from "../../lib/api/client.js";
|
|
4
|
+
import { ConfigManager } from "../../lib/config/manager.js";
|
|
5
|
+
import { updateEnvironment } from "../../lib/api/environments.js";
|
|
6
|
+
import { handleError } from "../../lib/errors/handler.js";
|
|
7
|
+
export const updateEnvironmentCommand = new Command("update")
|
|
8
|
+
.description("Update environment metadata")
|
|
9
|
+
.argument("<environmentId>", "Environment ID (UUID)")
|
|
10
|
+
.option("--name <name>", "New environment name")
|
|
11
|
+
.option("--json", "Output as JSON")
|
|
12
|
+
.action(async (environmentId, options, command) => {
|
|
13
|
+
const updates = {};
|
|
14
|
+
if (options.name) {
|
|
15
|
+
updates.name = options.name;
|
|
16
|
+
}
|
|
17
|
+
if (Object.keys(updates).length === 0) {
|
|
18
|
+
console.error("Error: At least one update option is required (e.g. --name).");
|
|
19
|
+
process.exit(1);
|
|
20
|
+
}
|
|
21
|
+
const spinner = ora("Updating environment...").start();
|
|
22
|
+
try {
|
|
23
|
+
const config = ConfigManager.load();
|
|
24
|
+
if (!config.apiToken) {
|
|
25
|
+
spinner.fail("Not authenticated. Run 'relesio auth login' first.");
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
|
28
|
+
const orgId = command.parent?.opts().org || config.activeOrganizationId;
|
|
29
|
+
if (!orgId) {
|
|
30
|
+
spinner.fail("No organization context. Use --org flag, set RELESIO_ORG_ID, or run 'relesio organizations set <org-id>'");
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
const client = new RelesioAPIClient(config.apiBaseUrl, config.apiToken);
|
|
34
|
+
const environment = await updateEnvironment(client, environmentId, updates);
|
|
35
|
+
spinner.stop();
|
|
36
|
+
if (options.json) {
|
|
37
|
+
console.log(JSON.stringify({ environment }, null, 2));
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
console.log(`\n✅ Environment updated successfully!\n`);
|
|
41
|
+
console.log(` ID: ${environment.id}`);
|
|
42
|
+
console.log(` Name: ${environment.name}`);
|
|
43
|
+
console.log(` Slug: ${environment.slug}`);
|
|
44
|
+
console.log(` Type: ${environment.isProduction ? "Production" : "Staging"}`);
|
|
45
|
+
console.log(` Updated: ${new Date(environment.updatedAt).toLocaleString()}`);
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
spinner.fail("Failed to update environment");
|
|
49
|
+
handleError(error);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
2
|
import ora from "ora";
|
|
3
|
+
import chalk from "chalk";
|
|
3
4
|
import { ConfigManager } from "../../lib/config/manager.js";
|
|
4
5
|
import { RelesioAPIClient } from "../../lib/api/client.js";
|
|
5
6
|
import { handleError } from "../../lib/errors/handler.js";
|
|
@@ -15,17 +16,26 @@ export const setOrganizationCommand = new Command("set")
|
|
|
15
16
|
process.exit(1);
|
|
16
17
|
}
|
|
17
18
|
const client = new RelesioAPIClient(config.apiBaseUrl, config.apiToken);
|
|
18
|
-
//
|
|
19
|
-
const response = await client.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
19
|
+
// Fetch the user's org memberships to verify access and resolve slug → id
|
|
20
|
+
const response = await client.get("/v1/users/me/organizations", { raw: true });
|
|
21
|
+
const orgs = response.data.organizations;
|
|
22
|
+
const match = orgs.find((o) => o.id === orgIdOrSlug || o.slug === orgIdOrSlug);
|
|
23
|
+
if (!match) {
|
|
24
|
+
spinner.fail("Organization not found or you are not a member.");
|
|
25
|
+
console.log(chalk.dim(` Available: ${orgs.map((o) => `${o.name} (${o.slug})`).join(", ") || "none"}`));
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
|
28
|
+
// For API key auth the active org lives entirely in the local config;
|
|
29
|
+
// the x-organization-id header sent with every request carries it to the API.
|
|
30
|
+
ConfigManager.save({
|
|
31
|
+
activeOrganizationId: match.id,
|
|
32
|
+
activeOrganizationName: match.name,
|
|
33
|
+
activeOrganizationSlug: match.slug,
|
|
34
|
+
// Legacy fields
|
|
35
|
+
currentOrgId: match.id,
|
|
36
|
+
currentOrgName: match.name
|
|
37
|
+
});
|
|
38
|
+
spinner.succeed(`Active organization set to: ${match.name} (${match.slug})`);
|
|
29
39
|
}
|
|
30
40
|
catch (error) {
|
|
31
41
|
spinner.fail("Failed to switch organization");
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { createRequire } from "node:module";
|
|
3
2
|
import { Command } from "commander";
|
|
4
|
-
|
|
5
|
-
const { version } = require("../package.json");
|
|
3
|
+
import { CLI_VERSION } from "./lib/version.js";
|
|
6
4
|
import { authCommand } from "./commands/auth/index.js";
|
|
7
5
|
import { organizationsCommand } from "./commands/organizations/index.js";
|
|
8
6
|
import { teamCommand } from "./commands/team/index.js";
|
|
9
7
|
import { whoamiCommand } from "./commands/whoami.js";
|
|
10
8
|
import { projectsCommand } from "./commands/projects/index.js";
|
|
9
|
+
import { environmentsCommand } from "./commands/environments/index.js";
|
|
11
10
|
import { versionsCommand } from "./commands/versions/index.js";
|
|
12
11
|
import { uploadCommand } from "./commands/upload.js";
|
|
13
12
|
import { deployCommand } from "./commands/deploy.js";
|
|
@@ -18,7 +17,7 @@ const program = new Command();
|
|
|
18
17
|
program
|
|
19
18
|
.name("relesio")
|
|
20
19
|
.description("CLI tool for Relesio - Modern Micro-Frontend Hosting")
|
|
21
|
-
.version(
|
|
20
|
+
.version(CLI_VERSION)
|
|
22
21
|
.option("--org <org-id>", "Override organization context (ID or slug)")
|
|
23
22
|
.addHelpText("after", `
|
|
24
23
|
Examples:
|
|
@@ -37,6 +36,12 @@ Examples:
|
|
|
37
36
|
$ relesio versions list <project-slug>
|
|
38
37
|
$ relesio status <project-slug>
|
|
39
38
|
|
|
39
|
+
Environments:
|
|
40
|
+
$ relesio environments list
|
|
41
|
+
$ relesio environments create --name Production --slug production --production
|
|
42
|
+
$ relesio environments get env_abc123
|
|
43
|
+
$ relesio environments update env_abc123 --name "Prod"
|
|
44
|
+
|
|
40
45
|
Upload & Deployment:
|
|
41
46
|
$ relesio upload ./dist --project my-app --version 1.0.0
|
|
42
47
|
$ relesio upload ./build -p my-app -v 1.0.1 --require-clean
|
|
@@ -65,6 +70,7 @@ program.addCommand(organizationsCommand);
|
|
|
65
70
|
program.addCommand(teamCommand);
|
|
66
71
|
program.addCommand(whoamiCommand);
|
|
67
72
|
program.addCommand(projectsCommand);
|
|
73
|
+
program.addCommand(environmentsCommand);
|
|
68
74
|
program.addCommand(versionsCommand);
|
|
69
75
|
program.addCommand(uploadCommand);
|
|
70
76
|
program.addCommand(deployCommand);
|
package/dist/lib/api/client.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { request } from "undici";
|
|
2
2
|
import { ConfigManager } from "../config/manager.js";
|
|
3
|
+
import { USER_AGENT } from "../version.js";
|
|
3
4
|
export class APIError extends Error {
|
|
4
5
|
statusCode;
|
|
5
6
|
response;
|
|
@@ -40,7 +41,7 @@ export class RelesioAPIClient {
|
|
|
40
41
|
getHeaders(additionalHeaders) {
|
|
41
42
|
const headers = {
|
|
42
43
|
"Content-Type": "application/json",
|
|
43
|
-
"User-Agent":
|
|
44
|
+
"User-Agent": USER_AGENT,
|
|
44
45
|
...additionalHeaders
|
|
45
46
|
};
|
|
46
47
|
// Better Auth requires x-api-key header (not Authorization)
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { RelesioAPIClient } from "./client.js";
|
|
2
|
+
export interface Environment {
|
|
3
|
+
id: string;
|
|
4
|
+
projectId: string;
|
|
5
|
+
organizationId: string;
|
|
6
|
+
name: string;
|
|
7
|
+
slug: string;
|
|
8
|
+
isProduction: boolean;
|
|
9
|
+
createdAt: string;
|
|
10
|
+
updatedAt: string;
|
|
11
|
+
}
|
|
12
|
+
export interface DeploymentSummary {
|
|
13
|
+
deploymentId: string;
|
|
14
|
+
versionId: string;
|
|
15
|
+
deployedAt: string;
|
|
16
|
+
deployedBy: string;
|
|
17
|
+
version: string;
|
|
18
|
+
deploymentType?: string;
|
|
19
|
+
gitSha?: string;
|
|
20
|
+
gitBranch?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface EnvironmentWithDeployment extends Environment {
|
|
23
|
+
currentDeployment: DeploymentSummary | null;
|
|
24
|
+
}
|
|
25
|
+
export interface EnvironmentDetails {
|
|
26
|
+
environment: Environment;
|
|
27
|
+
recentDeployments: DeploymentSummary[];
|
|
28
|
+
}
|
|
29
|
+
export interface ListEnvironmentsOptions {
|
|
30
|
+
limit?: number;
|
|
31
|
+
offset?: number;
|
|
32
|
+
}
|
|
33
|
+
export interface ListEnvironmentsResponse {
|
|
34
|
+
environments: EnvironmentWithDeployment[];
|
|
35
|
+
count: number;
|
|
36
|
+
}
|
|
37
|
+
export interface CreateEnvironmentInput {
|
|
38
|
+
name: string;
|
|
39
|
+
slug: string;
|
|
40
|
+
isProduction?: boolean;
|
|
41
|
+
}
|
|
42
|
+
export interface UpdateEnvironmentInput {
|
|
43
|
+
name?: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* List all environments for the organization
|
|
47
|
+
*/
|
|
48
|
+
export declare function listEnvironments(client: RelesioAPIClient, opts?: ListEnvironmentsOptions): Promise<ListEnvironmentsResponse>;
|
|
49
|
+
/**
|
|
50
|
+
* Create a new environment
|
|
51
|
+
*/
|
|
52
|
+
export declare function createEnvironment(client: RelesioAPIClient, input: CreateEnvironmentInput): Promise<Environment>;
|
|
53
|
+
/**
|
|
54
|
+
* Get a single environment with recent deployment history
|
|
55
|
+
*/
|
|
56
|
+
export declare function getEnvironment(client: RelesioAPIClient, environmentId: string, opts?: {
|
|
57
|
+
limit?: number;
|
|
58
|
+
}): Promise<EnvironmentDetails>;
|
|
59
|
+
/**
|
|
60
|
+
* Update environment metadata
|
|
61
|
+
*/
|
|
62
|
+
export declare function updateEnvironment(client: RelesioAPIClient, environmentId: string, updates: UpdateEnvironmentInput): Promise<Environment>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* List all environments for the organization
|
|
3
|
+
*/
|
|
4
|
+
export async function listEnvironments(client, opts) {
|
|
5
|
+
const response = await client.get("/v1/environments", {
|
|
6
|
+
raw: true,
|
|
7
|
+
query: {
|
|
8
|
+
...(opts?.limit !== undefined && { limit: opts.limit }),
|
|
9
|
+
...(opts?.offset !== undefined && { offset: opts.offset })
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
return {
|
|
13
|
+
environments: response.data,
|
|
14
|
+
count: response.meta?.count ?? response.data.length
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Create a new environment
|
|
19
|
+
*/
|
|
20
|
+
export async function createEnvironment(client, input) {
|
|
21
|
+
const response = await client.post("/v1/environments", input, { raw: true });
|
|
22
|
+
return response.data;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Get a single environment with recent deployment history
|
|
26
|
+
*/
|
|
27
|
+
export async function getEnvironment(client, environmentId, opts) {
|
|
28
|
+
const response = await client.get(`/v1/environments/${environmentId}`, {
|
|
29
|
+
raw: true,
|
|
30
|
+
query: {
|
|
31
|
+
...(opts?.limit !== undefined && { limit: opts.limit })
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
return response.data;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Update environment metadata
|
|
38
|
+
*/
|
|
39
|
+
export async function updateEnvironment(client, environmentId, updates) {
|
|
40
|
+
const response = await client.patch(`/v1/environments/${environmentId}`, updates, { raw: true });
|
|
41
|
+
return response.data;
|
|
42
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@relesio/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "CLI tool for Relesio - Modern Micro-Frontend Hosting",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"lint": "biome lint --write .",
|
|
19
19
|
"format": "biome format --write .",
|
|
20
20
|
"format:check": "biome format .",
|
|
21
|
-
"test": "
|
|
21
|
+
"test": "bun test",
|
|
22
22
|
"clean": "rm -rf dist"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
@@ -28,12 +28,14 @@
|
|
|
28
28
|
"conf": "^13.0.1",
|
|
29
29
|
"inquirer": "^10.2.2",
|
|
30
30
|
"mime-types": "^2.1.35",
|
|
31
|
+
"open": "11.0.0",
|
|
31
32
|
"ora": "^8.1.2",
|
|
32
33
|
"undici": "^6.0.0",
|
|
33
34
|
"zod": "^3.23.8"
|
|
34
35
|
},
|
|
35
36
|
"devDependencies": {
|
|
36
37
|
"@biomejs/biome": "2.3.10",
|
|
38
|
+
"@types/bun": "^1.3.9",
|
|
37
39
|
"@types/inquirer": "^9.0.7",
|
|
38
40
|
"@types/mime-types": "^2.1.4",
|
|
39
41
|
"@types/node": "^22.10.6",
|