@batadata/cli 0.1.5 → 0.1.6
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.
|
@@ -2,4 +2,10 @@ export declare function list(): Promise<void>;
|
|
|
2
2
|
export declare function create(): Promise<void>;
|
|
3
3
|
export declare function info(projectId?: string): Promise<void>;
|
|
4
4
|
export declare function deleteProject(projectId?: string): Promise<void>;
|
|
5
|
+
/**
|
|
6
|
+
* Resolve the target project from subcommand args: `--project <id>` /
|
|
7
|
+
* `--project=<id>` wins, otherwise the first non-flag positional. Flags like
|
|
8
|
+
* `--yes` / `--json` are never mistaken for a project ID.
|
|
9
|
+
*/
|
|
10
|
+
export declare function resolveProjectArg(args: string[]): string | undefined;
|
|
5
11
|
export declare function handleProjects(args: string[]): Promise<void>;
|
|
@@ -242,15 +242,29 @@ export async function deleteProject(projectId) {
|
|
|
242
242
|
success(`Project ${id} deleted.`);
|
|
243
243
|
log();
|
|
244
244
|
}
|
|
245
|
+
/**
|
|
246
|
+
* Resolve the target project from subcommand args: `--project <id>` /
|
|
247
|
+
* `--project=<id>` wins, otherwise the first non-flag positional. Flags like
|
|
248
|
+
* `--yes` / `--json` are never mistaken for a project ID.
|
|
249
|
+
*/
|
|
250
|
+
export function resolveProjectArg(args) {
|
|
251
|
+
for (let i = 0; i < args.length; i++) {
|
|
252
|
+
if (args[i] === "--project" && args[i + 1])
|
|
253
|
+
return args[i + 1];
|
|
254
|
+
if (args[i].startsWith("--project="))
|
|
255
|
+
return args[i].slice("--project=".length);
|
|
256
|
+
}
|
|
257
|
+
return args.find((a) => !a.startsWith("-"));
|
|
258
|
+
}
|
|
245
259
|
export async function handleProjects(args) {
|
|
246
260
|
const sub = args[0];
|
|
247
261
|
switch (sub) {
|
|
248
262
|
case "create":
|
|
249
263
|
return create();
|
|
250
264
|
case "info":
|
|
251
|
-
return info(args
|
|
265
|
+
return info(resolveProjectArg(args.slice(1)));
|
|
252
266
|
case "delete":
|
|
253
|
-
return deleteProject(args
|
|
267
|
+
return deleteProject(resolveProjectArg(args.slice(1)));
|
|
254
268
|
case "list":
|
|
255
269
|
case undefined:
|
|
256
270
|
return list();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@batadata/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "CLI for BataDB — serverless Postgres platform",
|
|
5
5
|
"bin": {
|
|
6
6
|
"bata": "./dist/index.js"
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
"build": "tsc -p tsconfig.build.json",
|
|
11
11
|
"dev": "tsc -p tsconfig.build.json --watch",
|
|
12
12
|
"typecheck": "tsc --noEmit",
|
|
13
|
-
"test": "
|
|
13
|
+
"test": "node --test \"test/*.test.mjs\"",
|
|
14
|
+
"pretest": "npm run build"
|
|
14
15
|
},
|
|
15
16
|
"engines": {
|
|
16
17
|
"node": ">=20.0.0"
|