@cardelli/ambit 0.3.3 → 0.3.4
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/esm/cli/commands/create/index.js +1 -1
- package/esm/cli/commands/deploy/index.js +1 -1
- package/esm/cli/commands/destroy/app.js +1 -1
- package/esm/cli/commands/destroy/index.js +4 -1
- package/esm/cli/commands/destroy/network.js +1 -1
- package/esm/cli/commands/doctor.js +5 -3
- package/esm/cli/commands/list/apps.js +1 -1
- package/esm/cli/commands/list/index.js +4 -1
- package/esm/cli/commands/list/networks.js +1 -1
- package/esm/cli/commands/share.js +1 -1
- package/esm/cli/commands/status/app.js +1 -1
- package/esm/cli/commands/status/index.js +4 -1
- package/esm/cli/commands/status/network.js +1 -1
- package/esm/cli/commands/status/networks.js +1 -1
- package/esm/deno.js +1 -1
- package/esm/lib/args.d.ts +6 -3
- package/esm/lib/args.d.ts.map +1 -1
- package/esm/lib/args.js +12 -3
- package/package.json +1 -1
|
@@ -245,7 +245,7 @@ const create = async (argv) => {
|
|
|
245
245
|
alias: { y: "yes" },
|
|
246
246
|
};
|
|
247
247
|
const args = parseArgs(argv, opts);
|
|
248
|
-
checkArgs(args, opts, "ambit create");
|
|
248
|
+
checkArgs(args, opts, "ambit create", 1);
|
|
249
249
|
if (args.help) {
|
|
250
250
|
console.log(`
|
|
251
251
|
${bold("ambit create")} - Create Tailscale Subnet Router
|
|
@@ -153,7 +153,7 @@ const deploy = async (argv) => {
|
|
|
153
153
|
default: { "main-port": "80" },
|
|
154
154
|
};
|
|
155
155
|
const args = parseArgs(argv, opts);
|
|
156
|
-
checkArgs(args, opts, "ambit deploy");
|
|
156
|
+
checkArgs(args, opts, "ambit deploy", 1);
|
|
157
157
|
if (args.help) {
|
|
158
158
|
console.log(`
|
|
159
159
|
${bold("ambit deploy")} - Deploy an App Safely on a Custom Private Network
|
|
@@ -107,7 +107,7 @@ export const destroyApp = async (argv) => {
|
|
|
107
107
|
alias: { y: "yes" },
|
|
108
108
|
};
|
|
109
109
|
const args = parseArgs(argv, opts);
|
|
110
|
-
checkArgs(args, opts, "ambit destroy app");
|
|
110
|
+
checkArgs(args, opts, "ambit destroy app", 1);
|
|
111
111
|
if (args.help) {
|
|
112
112
|
console.log(`
|
|
113
113
|
${bold("ambit destroy app")} - Destroy a Workload App
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import * as dntShim from "../../../_dnt.shims.js";
|
|
5
5
|
import { parseArgs } from "../../../deps/jsr.io/@std/cli/1.0.28/mod.js";
|
|
6
6
|
import { bold } from "../../../lib/cli.js";
|
|
7
|
+
import { checkArgs } from "../../../lib/args.js";
|
|
7
8
|
import { registerCommand } from "../../mod.js";
|
|
8
9
|
import { destroyNetwork } from "./network.js";
|
|
9
10
|
import { destroyApp } from "./app.js";
|
|
@@ -46,7 +47,9 @@ const destroy = async (argv) => {
|
|
|
46
47
|
if (subcommand === "app") {
|
|
47
48
|
return destroyApp(argv.slice(1));
|
|
48
49
|
}
|
|
49
|
-
const
|
|
50
|
+
const opts = { boolean: ["help"] };
|
|
51
|
+
const args = parseArgs(argv, opts);
|
|
52
|
+
checkArgs(args, opts, "ambit destroy", 0);
|
|
50
53
|
if (args.help) {
|
|
51
54
|
showDestroyHelp();
|
|
52
55
|
return;
|
|
@@ -225,7 +225,7 @@ export const destroyNetwork = async (argv) => {
|
|
|
225
225
|
alias: { y: "yes" },
|
|
226
226
|
};
|
|
227
227
|
const args = parseArgs(argv, opts);
|
|
228
|
-
checkArgs(args, opts, "ambit destroy network");
|
|
228
|
+
checkArgs(args, opts, "ambit destroy network", 1);
|
|
229
229
|
if (args.help) {
|
|
230
230
|
console.log(`
|
|
231
231
|
${bold("ambit destroy network")} - Tear Down Router
|
|
@@ -145,7 +145,7 @@ const doctorNetwork = async (argv) => {
|
|
|
145
145
|
boolean: ["help", "json"],
|
|
146
146
|
};
|
|
147
147
|
const args = parseArgs(argv, opts);
|
|
148
|
-
checkArgs(args, opts, "ambit doctor network");
|
|
148
|
+
checkArgs(args, opts, "ambit doctor network", 1);
|
|
149
149
|
if (args.help) {
|
|
150
150
|
console.log(`
|
|
151
151
|
${bold("ambit doctor network")} - Check Router Health
|
|
@@ -192,7 +192,7 @@ const doctorApp = async (argv) => {
|
|
|
192
192
|
boolean: ["help", "json"],
|
|
193
193
|
};
|
|
194
194
|
const args = parseArgs(argv, opts);
|
|
195
|
-
checkArgs(args, opts, "ambit doctor app");
|
|
195
|
+
checkArgs(args, opts, "ambit doctor app", 1);
|
|
196
196
|
if (args.help) {
|
|
197
197
|
console.log(`
|
|
198
198
|
${bold("ambit doctor app")} - Check App Health
|
|
@@ -286,7 +286,9 @@ const doctor = async (argv) => {
|
|
|
286
286
|
return doctorNetwork(argv.slice(1));
|
|
287
287
|
if (subcommand === "app")
|
|
288
288
|
return doctorApp(argv.slice(1));
|
|
289
|
-
const
|
|
289
|
+
const opts = { string: ["org"], boolean: ["help", "json"] };
|
|
290
|
+
const args = parseArgs(argv, opts);
|
|
291
|
+
checkArgs(args, opts, "ambit doctor", 0);
|
|
290
292
|
if (args.help) {
|
|
291
293
|
showDoctorHelp();
|
|
292
294
|
return;
|
|
@@ -14,7 +14,7 @@ import { initSession } from "../../../util/session.js";
|
|
|
14
14
|
export const listApps = async (argv) => {
|
|
15
15
|
const opts = { string: ["org"], boolean: ["help", "json"] };
|
|
16
16
|
const args = parseArgs(argv, opts);
|
|
17
|
-
checkArgs(args, opts, "ambit list apps");
|
|
17
|
+
checkArgs(args, opts, "ambit list apps", 1);
|
|
18
18
|
if (args.help) {
|
|
19
19
|
console.log(`
|
|
20
20
|
${bold("ambit list apps")} - List Apps on a Network
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import * as dntShim from "../../../_dnt.shims.js";
|
|
5
5
|
import { parseArgs } from "../../../deps/jsr.io/@std/cli/1.0.28/mod.js";
|
|
6
6
|
import { bold } from "../../../lib/cli.js";
|
|
7
|
+
import { checkArgs } from "../../../lib/args.js";
|
|
7
8
|
import { registerCommand } from "../../mod.js";
|
|
8
9
|
import { listNetworks } from "./networks.js";
|
|
9
10
|
import { listApps } from "./apps.js";
|
|
@@ -43,7 +44,9 @@ const list = async (argv) => {
|
|
|
43
44
|
return listNetworks(argv.slice(1));
|
|
44
45
|
if (subcommand === "apps")
|
|
45
46
|
return listApps(argv.slice(1));
|
|
46
|
-
const
|
|
47
|
+
const opts = { boolean: ["help"] };
|
|
48
|
+
const args = parseArgs(argv, opts);
|
|
49
|
+
checkArgs(args, opts, "ambit list", 0);
|
|
47
50
|
if (args.help) {
|
|
48
51
|
showListHelp();
|
|
49
52
|
return;
|
|
@@ -52,7 +52,7 @@ const stageRender = (out, routers) => {
|
|
|
52
52
|
export const listNetworks = async (argv) => {
|
|
53
53
|
const opts = { string: ["org"], boolean: ["help", "json"] };
|
|
54
54
|
const args = parseArgs(argv, opts);
|
|
55
|
-
checkArgs(args, opts, "ambit list networks");
|
|
55
|
+
checkArgs(args, opts, "ambit list networks", 0);
|
|
56
56
|
if (args.help) {
|
|
57
57
|
console.log(`
|
|
58
58
|
${bold("ambit list networks")} - List All Networks
|
|
@@ -168,7 +168,7 @@ const share = async (argv) => {
|
|
|
168
168
|
boolean: ["help", "json"],
|
|
169
169
|
};
|
|
170
170
|
const args = parseArgs(argv, opts);
|
|
171
|
-
checkArgs(args, opts, "ambit share");
|
|
171
|
+
checkArgs(args, opts, "ambit share", Infinity);
|
|
172
172
|
if (args.help) {
|
|
173
173
|
console.log(`
|
|
174
174
|
${bold("ambit share")} - Grant Members Access to a Network
|
|
@@ -100,7 +100,7 @@ export const statusApp = async (argv) => {
|
|
|
100
100
|
boolean: ["help", "json"],
|
|
101
101
|
};
|
|
102
102
|
const args = parseArgs(argv, opts);
|
|
103
|
-
checkArgs(args, opts, "ambit status app");
|
|
103
|
+
checkArgs(args, opts, "ambit status app", 1);
|
|
104
104
|
if (args.help) {
|
|
105
105
|
console.log(`
|
|
106
106
|
${bold("ambit status app")} - Show App Status
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// =============================================================================
|
|
4
4
|
import { parseArgs } from "../../../deps/jsr.io/@std/cli/1.0.28/mod.js";
|
|
5
5
|
import { bold } from "../../../lib/cli.js";
|
|
6
|
+
import { checkArgs } from "../../../lib/args.js";
|
|
6
7
|
import { registerCommand } from "../../mod.js";
|
|
7
8
|
import { statusNetworks } from "./networks.js";
|
|
8
9
|
import { statusNetwork } from "./network.js";
|
|
@@ -50,7 +51,9 @@ const status = async (argv) => {
|
|
|
50
51
|
return statusNetwork(argv.slice(1));
|
|
51
52
|
if (subcommand === "app")
|
|
52
53
|
return statusApp(argv.slice(1));
|
|
53
|
-
const
|
|
54
|
+
const opts = { string: ["org"], boolean: ["help", "json"] };
|
|
55
|
+
const args = parseArgs(argv, opts);
|
|
56
|
+
checkArgs(args, opts, "ambit status", 0);
|
|
54
57
|
if (args.help) {
|
|
55
58
|
showStatusHelp();
|
|
56
59
|
return;
|
|
@@ -73,7 +73,7 @@ const stageNetworkStatus = async (fly, tailscale, network, org, json) => {
|
|
|
73
73
|
export const statusNetwork = async (argv) => {
|
|
74
74
|
const opts = { string: ["org"], boolean: ["help", "json"] };
|
|
75
75
|
const args = parseArgs(argv, opts);
|
|
76
|
-
checkArgs(args, opts, "ambit status network");
|
|
76
|
+
checkArgs(args, opts, "ambit status network", 1);
|
|
77
77
|
if (args.help) {
|
|
78
78
|
console.log(`
|
|
79
79
|
${bold("ambit status network")} - Show Detailed Status for a Network
|
|
@@ -14,7 +14,7 @@ import { initSession } from "../../../util/session.js";
|
|
|
14
14
|
export const statusNetworks = async (argv) => {
|
|
15
15
|
const opts = { string: ["org"], boolean: ["help", "json"] };
|
|
16
16
|
const args = parseArgs(argv, opts);
|
|
17
|
-
checkArgs(args, opts, "ambit status networks");
|
|
17
|
+
checkArgs(args, opts, "ambit status networks", 0);
|
|
18
18
|
if (args.help) {
|
|
19
19
|
console.log(`
|
|
20
20
|
${bold("ambit status networks")} - Show Status of All Networks
|
package/esm/deno.js
CHANGED
package/esm/lib/args.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Validates parsed args against the declared options spec.
|
|
3
|
-
* Dies with a Title Case error if unknown flags
|
|
4
|
-
* Pass the same options object you gave to parseArgs.
|
|
3
|
+
* Dies with a Title Case error if unknown flags or unexpected positional
|
|
4
|
+
* arguments are found. Pass the same options object you gave to parseArgs.
|
|
5
|
+
*
|
|
6
|
+
* `maxPositional` (default 0) limits how many bare positional args are
|
|
7
|
+
* allowed. Set it to the number the command actually expects.
|
|
5
8
|
*/
|
|
6
9
|
export declare const checkArgs: (args: Record<string, unknown>, opts: {
|
|
7
10
|
string?: readonly string[] | string[];
|
|
8
11
|
boolean?: readonly string[] | string[];
|
|
9
12
|
alias?: Record<string, string | string[]>;
|
|
10
|
-
}, command: string) => void;
|
|
13
|
+
}, command: string, maxPositional?: number) => void;
|
|
11
14
|
//# sourceMappingURL=args.d.ts.map
|
package/esm/lib/args.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../../src/lib/args.ts"],"names":[],"mappings":"AAMA
|
|
1
|
+
{"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../../src/lib/args.ts"],"names":[],"mappings":"AAMA;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,GACpB,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,MAAM;IACJ,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;IACtC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;CAC3C,EACD,SAAS,MAAM,EACf,sBAAiB,KAChB,IA4BF,CAAC"}
|
package/esm/lib/args.js
CHANGED
|
@@ -4,10 +4,13 @@
|
|
|
4
4
|
import { createOutput } from "./output.js";
|
|
5
5
|
/**
|
|
6
6
|
* Validates parsed args against the declared options spec.
|
|
7
|
-
* Dies with a Title Case error if unknown flags
|
|
8
|
-
* Pass the same options object you gave to parseArgs.
|
|
7
|
+
* Dies with a Title Case error if unknown flags or unexpected positional
|
|
8
|
+
* arguments are found. Pass the same options object you gave to parseArgs.
|
|
9
|
+
*
|
|
10
|
+
* `maxPositional` (default 0) limits how many bare positional args are
|
|
11
|
+
* allowed. Set it to the number the command actually expects.
|
|
9
12
|
*/
|
|
10
|
-
export const checkArgs = (args, opts, command) => {
|
|
13
|
+
export const checkArgs = (args, opts, command, maxPositional = 0) => {
|
|
11
14
|
const known = new Set(["_"]);
|
|
12
15
|
for (const k of opts.string ?? [])
|
|
13
16
|
known.add(k);
|
|
@@ -25,4 +28,10 @@ export const checkArgs = (args, opts, command) => {
|
|
|
25
28
|
const out = createOutput(!!args.json);
|
|
26
29
|
out.die(`Unknown Flag(s): ${bad.join(", ")}. Run '${command} --help' for Usage.`);
|
|
27
30
|
}
|
|
31
|
+
const positional = Array.isArray(args._) ? args._ : [];
|
|
32
|
+
if (positional.length > maxPositional) {
|
|
33
|
+
const extra = positional.slice(maxPositional).join(", ");
|
|
34
|
+
const out = createOutput(!!args.json);
|
|
35
|
+
out.die(`Unexpected Argument(s): ${extra}. Run '${command} --help' for Usage.`);
|
|
36
|
+
}
|
|
28
37
|
};
|