ardent-cli-beta 0.0.19 → 0.0.20
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 +8 -2
- package/dist/branches/client.d.ts +1 -1
- package/dist/branches/client.js +2 -2
- package/dist/commands/branch/connect.d.ts +1 -0
- package/dist/commands/branch/connect.js +12 -3
- package/dist/commands/branch/create.d.ts +1 -0
- package/dist/commands/branch/create.js +2 -1
- package/oclif.manifest.json +18 -1
- package/openapi.json +12 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -32,11 +32,15 @@ retained disk, and reports the control plane's refusal, with its stated fallback
|
|
|
32
32
|
changed, and prints only its connection URL to stdout. Progress, credential
|
|
33
33
|
revocation instructions and driver requirements go to stderr. `--driver` selects
|
|
34
34
|
`libpq` (default), `node`, `jdbc` or `prisma`; `--json` returns the active branch,
|
|
35
|
-
operation and credential. `--
|
|
35
|
+
operation and credential. Repeat `--allow-cidr` at creation to restrict branch
|
|
36
|
+
connections, for example `--allow-cidr 192.0.2.0/24 --allow-cidr 2001:db8::/32`.
|
|
37
|
+
The allowlist is fixed at creation and applies to every credential on the branch;
|
|
38
|
+
omitting it preserves unrestricted ingress. `--print` remains accepted. The credential stays active
|
|
36
39
|
after exit. This uses `branch connect --print`'s lifecycle and requires a control
|
|
37
40
|
plane that issues credentials while branches start (`docs/DECISIONS.md` section 17).
|
|
38
41
|
|
|
39
|
-
Use `branch create <name> --to-env`
|
|
42
|
+
Use `branch create <name> --to-env` or `branch connect --to-env` to write
|
|
43
|
+
`DATABASE_URL` to `.env` in the
|
|
40
44
|
current directory instead of printing the URL. The selected `--driver` still
|
|
41
45
|
applies. This option cannot be combined with `--print` or `--json`.
|
|
42
46
|
`writeBranchEnv` preserves unrelated entries and refuses an existing
|
|
@@ -48,6 +52,8 @@ does not coordinate with other editors. Values use a quote delimiter absent
|
|
|
48
52
|
from the connection string; newline, NUL, or values containing all three dotenv
|
|
49
53
|
quote delimiters are refused. Use a dotenv reader without variable expansion.
|
|
50
54
|
Custom destination filenames remain future work.
|
|
55
|
+
`branch connect --to-env` keeps the issued credential instead of opening psql;
|
|
56
|
+
`--role` still selects a source role with a fresh branch-only password.
|
|
51
57
|
|
|
52
58
|
`branch connect` needs a selected active branch, an installed PostgreSQL 16+ `psql`, and the
|
|
53
59
|
system `script` utility on macOS or Linux. It requests a read/write credential for the branch,
|
|
@@ -13,7 +13,7 @@ export interface BranchOperation {
|
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
15
|
export declare function listBranches(token: string, connectorID: string): Promise<Branch[]>;
|
|
16
|
-
export declare function createBranch(token: string, connectorID: string, name: string): Promise<BranchOperation>;
|
|
16
|
+
export declare function createBranch(token: string, connectorID: string, name: string, allowedCIDRs?: string[]): Promise<BranchOperation>;
|
|
17
17
|
export declare function deleteBranch(token: string, connectorID: string, name: string): Promise<BranchOperation>;
|
|
18
18
|
export type BranchLifecycleAction = 'wake' | 'suspend' | 'recover';
|
|
19
19
|
export declare function transitionBranch(token: string, connectorID: string, name: string, action: BranchLifecycleAction): Promise<BranchOperation>;
|
package/dist/branches/client.js
CHANGED
|
@@ -9,9 +9,9 @@ export async function listBranches(token, connectorID) {
|
|
|
9
9
|
}
|
|
10
10
|
return branches;
|
|
11
11
|
}
|
|
12
|
-
export async function createBranch(token, connectorID, name) {
|
|
12
|
+
export async function createBranch(token, connectorID, name, allowedCIDRs) {
|
|
13
13
|
const result = await request(token, '/branches', {
|
|
14
|
-
method: 'POST', body: JSON.stringify({ connector_id: connectorID, name, request_id: randomUUID() }),
|
|
14
|
+
method: 'POST', body: JSON.stringify({ connector_id: connectorID, name, allowed_cidrs: allowedCIDRs, request_id: randomUUID() }),
|
|
15
15
|
});
|
|
16
16
|
validateOperation(result, connectorID, name);
|
|
17
17
|
return result;
|
|
@@ -5,6 +5,7 @@ export default class BranchConnect extends ArdentCommand {
|
|
|
5
5
|
static flags: {
|
|
6
6
|
driver: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
7
|
print: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
8
|
+
'to-env': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
8
9
|
role: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
10
|
};
|
|
10
11
|
static helpGroup: string;
|
|
@@ -5,6 +5,7 @@ import { listBranches } from '../../branches/client.js';
|
|
|
5
5
|
import { connectToBranch } from '../../branches/connection.js';
|
|
6
6
|
import { validSourceRole } from '../../branches/credentials.js';
|
|
7
7
|
import { DRIVERS, validDriver } from '../../branches/drivers.js';
|
|
8
|
+
import { writeBranchEnv } from '../../branches/env.js';
|
|
8
9
|
import { checkPsql } from '../../branches/psql.js';
|
|
9
10
|
import { recoverBranchCredentials } from '../../branches/recovery.js';
|
|
10
11
|
import { ArdentCommand } from '../../command.js';
|
|
@@ -18,13 +19,15 @@ export default class BranchConnect extends ArdentCommand {
|
|
|
18
19
|
options: [...DRIVERS],
|
|
19
20
|
}),
|
|
20
21
|
print: Flags.boolean({ description: 'Print a connection string for --driver and keep the credential active, instead of opening psql' }),
|
|
22
|
+
'to-env': Flags.boolean({ description: 'Write DATABASE_URL to .env instead of opening psql', exclusive: ['print', 'json'] }),
|
|
21
23
|
role: Flags.string({ description: 'Sign in as this source role on the branch (for example postgres), with a fresh password that works on this branch only' }),
|
|
22
24
|
};
|
|
23
25
|
static helpGroup = 'Branches';
|
|
24
26
|
async run() {
|
|
25
27
|
const { flags } = await this.parse(BranchConnect);
|
|
26
28
|
const sourceRole = flags.role;
|
|
27
|
-
const
|
|
29
|
+
const toEnv = flags['to-env'];
|
|
30
|
+
const print = flags.print || toEnv;
|
|
28
31
|
if (!validDriver(flags.driver))
|
|
29
32
|
this.error(`--driver must be one of ${DRIVERS.join(', ')}.`);
|
|
30
33
|
const driver = flags.driver;
|
|
@@ -79,9 +82,15 @@ export default class BranchConnect extends ArdentCommand {
|
|
|
79
82
|
const as = sourceRole === undefined ? '' : ` as source role ${sourceRole}, with a new branch-only password,`;
|
|
80
83
|
const verb = print ? `Issuing a ${driver} connection string for` : 'Connecting to';
|
|
81
84
|
say(`${verb} branch ${terminalText(branch.name)} in connector ${terminalText(connector.name)}${as} via ${terminalText(new URL(API_URL).origin)}...`);
|
|
82
|
-
|
|
85
|
+
const result = await connectToBranch({
|
|
83
86
|
configDir: this.config.configDir, token: session.token, branchID: branch.id, sourceRole, print, driver,
|
|
84
|
-
json: this.jsonEnabled()
|
|
87
|
+
json: this.jsonEnabled() || toEnv, deliver: toEnv ? writeBranchEnv : undefined,
|
|
88
|
+
say, log: (message) => this.log(message), warn: (message) => this.warn(message),
|
|
85
89
|
});
|
|
90
|
+
if (toEnv) {
|
|
91
|
+
say('Wrote DATABASE_URL to .env.');
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
return result;
|
|
86
95
|
}
|
|
87
96
|
}
|
|
@@ -8,6 +8,7 @@ export default class BranchCreate extends ArdentCommand {
|
|
|
8
8
|
static strict: boolean;
|
|
9
9
|
static description: string;
|
|
10
10
|
static flags: {
|
|
11
|
+
'allow-cidr': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
12
|
driver: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
13
|
print: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
13
14
|
'to-env': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
@@ -14,6 +14,7 @@ export default class BranchCreate extends ArdentCommand {
|
|
|
14
14
|
static strict = false;
|
|
15
15
|
static description = 'Create a branch in the selected connector and print its connection URL when ready';
|
|
16
16
|
static flags = {
|
|
17
|
+
'allow-cidr': Flags.string({ multiple: true, multipleNonGreedy: true, description: 'Allow connections only from these IPv4/IPv6 CIDRs; repeat for each network. Fixed at creation; omitted means unrestricted.' }),
|
|
17
18
|
driver: Flags.string({ default: 'libpq', options: [...DRIVERS], description: 'Connection string format: libpq, node, jdbc or prisma' }),
|
|
18
19
|
print: Flags.boolean({ description: 'Print the connection string when ready (the default behavior)' }),
|
|
19
20
|
'to-env': Flags.boolean({ description: 'Write DATABASE_URL to .env instead of printing it', exclusive: ['print', 'json'] }),
|
|
@@ -38,7 +39,7 @@ export default class BranchCreate extends ArdentCommand {
|
|
|
38
39
|
say(`Creating branch ${target}...`);
|
|
39
40
|
let accepted;
|
|
40
41
|
try {
|
|
41
|
-
const result = await createBranch(session.token, session.selectedConnector.id, name);
|
|
42
|
+
const result = await createBranch(session.token, session.selectedConnector.id, name, flags['allow-cidr']);
|
|
42
43
|
accepted = result;
|
|
43
44
|
const credential = await connectToBranch({
|
|
44
45
|
configDir: this.config.configDir, token: session.token, branchID: result.branch.id,
|
package/oclif.manifest.json
CHANGED
|
@@ -127,6 +127,16 @@
|
|
|
127
127
|
"allowNo": false,
|
|
128
128
|
"type": "boolean"
|
|
129
129
|
},
|
|
130
|
+
"to-env": {
|
|
131
|
+
"description": "Write DATABASE_URL to .env instead of opening psql",
|
|
132
|
+
"exclusive": [
|
|
133
|
+
"print",
|
|
134
|
+
"json"
|
|
135
|
+
],
|
|
136
|
+
"name": "to-env",
|
|
137
|
+
"allowNo": false,
|
|
138
|
+
"type": "boolean"
|
|
139
|
+
},
|
|
130
140
|
"role": {
|
|
131
141
|
"description": "Sign in as this source role on the branch (for example postgres), with a fresh password that works on this branch only",
|
|
132
142
|
"name": "role",
|
|
@@ -170,6 +180,13 @@
|
|
|
170
180
|
"allowNo": false,
|
|
171
181
|
"type": "boolean"
|
|
172
182
|
},
|
|
183
|
+
"allow-cidr": {
|
|
184
|
+
"description": "Allow connections only from these IPv4/IPv6 CIDRs; repeat for each network. Fixed at creation; omitted means unrestricted.",
|
|
185
|
+
"name": "allow-cidr",
|
|
186
|
+
"hasDynamicHelp": false,
|
|
187
|
+
"multiple": true,
|
|
188
|
+
"type": "option"
|
|
189
|
+
},
|
|
173
190
|
"driver": {
|
|
174
191
|
"description": "Connection string format: libpq, node, jdbc or prisma",
|
|
175
192
|
"name": "driver",
|
|
@@ -891,5 +908,5 @@
|
|
|
891
908
|
]
|
|
892
909
|
}
|
|
893
910
|
},
|
|
894
|
-
"version": "0.0.
|
|
911
|
+
"version": "0.0.20"
|
|
895
912
|
}
|
package/openapi.json
CHANGED
|
@@ -1608,6 +1608,12 @@
|
|
|
1608
1608
|
"updated_at"
|
|
1609
1609
|
],
|
|
1610
1610
|
"properties": {
|
|
1611
|
+
"allowed_cidrs": {
|
|
1612
|
+
"type": "array",
|
|
1613
|
+
"maxItems": 64,
|
|
1614
|
+
"items": {"type": "string"},
|
|
1615
|
+
"description": "IPv4/IPv6 CIDRs allowed to connect. Empty or omitted means unrestricted. Immutable after creation; host bits are masked and duplicates removed. Mapped IPv6 prefixes are refused."
|
|
1616
|
+
},
|
|
1611
1617
|
"id": {
|
|
1612
1618
|
"type": "string"
|
|
1613
1619
|
},
|
|
@@ -1872,6 +1878,12 @@
|
|
|
1872
1878
|
"request_id"
|
|
1873
1879
|
],
|
|
1874
1880
|
"properties": {
|
|
1881
|
+
"allowed_cidrs": {
|
|
1882
|
+
"type": "array",
|
|
1883
|
+
"maxItems": 64,
|
|
1884
|
+
"items": {"type": "string"},
|
|
1885
|
+
"description": "IPv4/IPv6 CIDRs allowed to connect. Empty or omitted means unrestricted. Immutable after creation; host bits are masked and duplicates removed. Mapped IPv6 prefixes are refused."
|
|
1886
|
+
},
|
|
1875
1887
|
"connector_id": {
|
|
1876
1888
|
"type": "string",
|
|
1877
1889
|
"minLength": 1
|