@studiometa/forge-cli 0.4.5 → 0.4.7
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 +68 -6
- package/dist/cli.js +1406 -51
- package/dist/cli.js.map +1 -1
- package/dist/commands/completion.d.ts.map +1 -1
- package/dist/commands/daemons/command.d.ts.map +1 -1
- package/dist/commands/daemons/handlers.d.ts +1 -0
- package/dist/commands/daemons/handlers.d.ts.map +1 -1
- package/dist/commands/daemons/help.d.ts.map +1 -1
- package/dist/commands/deployments/command.d.ts.map +1 -1
- package/dist/commands/deployments/handlers.d.ts +3 -0
- package/dist/commands/deployments/handlers.d.ts.map +1 -1
- package/dist/commands/deployments/help.d.ts.map +1 -1
- package/dist/commands/env/env-diff.d.ts +29 -0
- package/dist/commands/env/env-diff.d.ts.map +1 -0
- package/dist/commands/env/handlers.d.ts.map +1 -1
- package/dist/commands/env/help.d.ts.map +1 -1
- package/dist/commands/nginx/handlers.d.ts.map +1 -1
- package/dist/commands/nginx/help.d.ts.map +1 -1
- package/dist/commands/php/command.d.ts +2 -0
- package/dist/commands/php/command.d.ts.map +1 -0
- package/dist/commands/php/handlers.d.ts +42 -0
- package/dist/commands/php/handlers.d.ts.map +1 -0
- package/dist/commands/php/help.d.ts +2 -0
- package/dist/commands/php/help.d.ts.map +1 -0
- package/dist/commands/php/index.d.ts +3 -0
- package/dist/commands/php/index.d.ts.map +1 -0
- package/dist/commands/services/command.d.ts +2 -0
- package/dist/commands/services/command.d.ts.map +1 -0
- package/dist/commands/services/handlers.d.ts +10 -0
- package/dist/commands/services/handlers.d.ts.map +1 -0
- package/dist/commands/services/help.d.ts +2 -0
- package/dist/commands/services/help.d.ts.map +1 -0
- package/dist/commands/services/index.d.ts +3 -0
- package/dist/commands/services/index.d.ts.map +1 -0
- package/dist/commands/ssh-keys/command.d.ts.map +1 -1
- package/dist/commands/ssh-keys/help.d.ts.map +1 -1
- package/dist/commands/ssh-keys/sync-plan.d.ts +56 -0
- package/dist/commands/ssh-keys/sync-plan.d.ts.map +1 -0
- package/dist/commands/ssh-keys/sync.d.ts +6 -0
- package/dist/commands/ssh-keys/sync.d.ts.map +1 -0
- package/dist/{error-handler-peS_8nl4.js → error-handler-Adi84RcF.js} +21 -5
- package/dist/error-handler-Adi84RcF.js.map +1 -0
- package/dist/error-handler.d.ts +5 -0
- package/dist/error-handler.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/output.d.ts +5 -0
- package/dist/output.d.ts.map +1 -1
- package/dist/utils/args.d.ts +6 -0
- package/dist/utils/args.d.ts.map +1 -1
- package/dist/utils/content-source.d.ts +24 -0
- package/dist/utils/content-source.d.ts.map +1 -0
- package/dist/utils/drift.d.ts +33 -0
- package/dist/utils/drift.d.ts.map +1 -0
- package/dist/utils/resolve.d.ts +8 -0
- package/dist/utils/resolve.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/error-handler-peS_8nl4.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"completion.d.ts","sourceRoot":"","sources":["../../src/commands/completion.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"completion.d.ts","sourceRoot":"","sources":["../../src/commands/completion.ts"],"names":[],"mappings":"AAAA;;GAEG;AAkvBH,wBAAgB,kBAAkB,IAAI,IAAI,CA2CzC;AAED,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,EAAE,CAAM,GACxD,IAAI,CAoEN"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../src/commands/daemons/command.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,oBAAoB,
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../src/commands/daemons/command.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,oBAAoB,6GAY/B,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { CommandContext } from "../../context.ts";
|
|
2
2
|
export declare function daemonsList(ctx: CommandContext): Promise<void>;
|
|
3
3
|
export declare function daemonsGet(args: string[], ctx: CommandContext): Promise<void>;
|
|
4
|
+
export declare function daemonsLogs(args: string[], ctx: CommandContext): Promise<void>;
|
|
4
5
|
export declare function daemonsUpdate(args: string[], ctx: CommandContext): Promise<void>;
|
|
5
6
|
export declare function daemonsRestart(args: string[], ctx: CommandContext): Promise<void>;
|
|
6
7
|
//# sourceMappingURL=handlers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../../src/commands/daemons/handlers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../../src/commands/daemons/handlers.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAKvD,wBAAsB,WAAW,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAmBpE;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAmCnF;AAED,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CA+BpF;AAED,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAgDtF;AAED,wBAAsB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CA2BvF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../../src/commands/daemons/help.ts"],"names":[],"mappings":"AAEA,wBAAgB,eAAe,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../../src/commands/daemons/help.ts"],"names":[],"mappings":"AAEA,wBAAgB,eAAe,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAyDzD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../src/commands/deployments/command.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../src/commands/deployments/command.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,wBAAwB,6GAYnC,CAAC"}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import type { CommandContext } from "../../context.ts";
|
|
2
2
|
export declare function deploymentsList(ctx: CommandContext): Promise<void>;
|
|
3
|
+
export declare function deploymentsLogs(args: string[], ctx: CommandContext): Promise<void>;
|
|
4
|
+
export declare function deploymentsScript(ctx: CommandContext): Promise<void>;
|
|
5
|
+
export declare function deploymentsUpdateScript(ctx: CommandContext): Promise<void>;
|
|
3
6
|
export declare function deploymentsDeploy(ctx: CommandContext): Promise<void>;
|
|
4
7
|
//# sourceMappingURL=handlers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../../src/commands/deployments/handlers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../../src/commands/deployments/handlers.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAQvD,wBAAsB,eAAe,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAkCxE;AAED,wBAAsB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CA4CxF;AAED,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAiC1E;AAED,wBAAsB,uBAAuB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAmChF;AAED,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CA+E1E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../../src/commands/deployments/help.ts"],"names":[],"mappings":"AAEA,wBAAgB,mBAAmB,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../../src/commands/deployments/help.ts"],"names":[],"mappings":"AAEA,wBAAgB,mBAAmB,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CA6G7D"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compare two .env files by variable name, without exposing any value.
|
|
3
|
+
*/
|
|
4
|
+
import type { Drift } from "../../utils/drift.ts";
|
|
5
|
+
export interface EnvDiff {
|
|
6
|
+
/** Names only in the local file. */
|
|
7
|
+
added: string[];
|
|
8
|
+
/** Names only on Forge. */
|
|
9
|
+
removed: string[];
|
|
10
|
+
/** Names in both, with a different value. */
|
|
11
|
+
changed: string[];
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Parse a .env file into a map of name to value, with the dotenv rules used by Laravel:
|
|
15
|
+
* an optional `export ` prefix, quoted values that can span lines, and ` #` inline comments
|
|
16
|
+
* after unquoted values. Blank lines, comments and lines without a valid name are ignored,
|
|
17
|
+
* so a part of a value can never show as a name.
|
|
18
|
+
*/
|
|
19
|
+
export declare function parseEnv(content: string): Map<string, string>;
|
|
20
|
+
/**
|
|
21
|
+
* Compare the variables of two .env files. Returns only variable names.
|
|
22
|
+
*/
|
|
23
|
+
export declare function diffEnv(remote: string, local: string): EnvDiff;
|
|
24
|
+
/**
|
|
25
|
+
* Turn an env diff into a drift report, or null when the variables are the same.
|
|
26
|
+
* The report holds variable names only, never values, because CI logs are often shared.
|
|
27
|
+
*/
|
|
28
|
+
export declare function envDrift(remote: string, local: string): Drift | null;
|
|
29
|
+
//# sourceMappingURL=env-diff.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env-diff.d.ts","sourceRoot":"","sources":["../../../src/commands/env/env-diff.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAElD,MAAM,WAAW,OAAO;IACtB,oCAAoC;IACpC,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,2BAA2B;IAC3B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,6CAA6C;IAC7C,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAmBD;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CA8B7D;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAoB9D;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,KAAK,GAAG,IAAI,CAQpE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../../src/commands/env/handlers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../../src/commands/env/handlers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAQvD,wBAAsB,MAAM,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAgC/D;AAED,wBAAsB,SAAS,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAmClE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../../src/commands/env/help.ts"],"names":[],"mappings":"AAEA,wBAAgB,WAAW,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../../src/commands/env/help.ts"],"names":[],"mappings":"AAEA,wBAAgB,WAAW,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAwDrD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../../src/commands/nginx/handlers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../../src/commands/nginx/handlers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAOvD,wBAAsB,QAAQ,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAgCjE;AAED,wBAAsB,WAAW,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAmCpE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../../src/commands/nginx/help.ts"],"names":[],"mappings":"AAEA,wBAAgB,aAAa,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../../src/commands/nginx/help.ts"],"names":[],"mappings":"AAEA,wBAAgB,aAAa,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAsDvD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../src/commands/php/command.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,gBAAgB,6GAsB3B,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { CommandContext } from "../../context.ts";
|
|
2
|
+
/**
|
|
3
|
+
* List the PHP versions installed on a server.
|
|
4
|
+
*/
|
|
5
|
+
export declare function phpList(ctx: CommandContext): Promise<void>;
|
|
6
|
+
/**
|
|
7
|
+
* Print a PHP configuration file (cli, fpm or pool).
|
|
8
|
+
*/
|
|
9
|
+
export declare function phpConfig(ctx: CommandContext): Promise<void>;
|
|
10
|
+
/**
|
|
11
|
+
* Replace a PHP configuration file, or compare it with Forge when --check is set.
|
|
12
|
+
*/
|
|
13
|
+
export declare function phpUpdateConfig(ctx: CommandContext): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Print the PHP max upload size, in megabytes.
|
|
16
|
+
*/
|
|
17
|
+
export declare function phpMaxUploadSize(ctx: CommandContext): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* Set the PHP max upload size, in megabytes.
|
|
20
|
+
*/
|
|
21
|
+
export declare function phpSetMaxUploadSize(args: string[], ctx: CommandContext): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Print the PHP max execution time, in seconds.
|
|
24
|
+
*/
|
|
25
|
+
export declare function phpMaxExecutionTime(ctx: CommandContext): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Set the PHP max execution time, in seconds.
|
|
28
|
+
*/
|
|
29
|
+
export declare function phpSetMaxExecutionTime(args: string[], ctx: CommandContext): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Print whether OPcache is enabled.
|
|
32
|
+
*/
|
|
33
|
+
export declare function phpOpcache(ctx: CommandContext): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Enable OPcache.
|
|
36
|
+
*/
|
|
37
|
+
export declare function phpEnableOpcache(ctx: CommandContext): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Disable OPcache.
|
|
40
|
+
*/
|
|
41
|
+
export declare function phpDisableOpcache(ctx: CommandContext): Promise<void>;
|
|
42
|
+
//# sourceMappingURL=handlers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../../src/commands/php/handlers.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAiGvD;;GAEG;AACH,wBAAsB,OAAO,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAahE;AAED;;GAEG;AACH,wBAAsB,SAAS,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAYlE;AAED;;GAEG;AACH,wBAAsB,eAAe,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAoBxE;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAWzE;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAS5F;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAW5E;AAED;;GAEG;AACH,wBAAsB,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAS/F;AAED;;GAEG;AACH,wBAAsB,UAAU,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAWnE;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAOzE;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAO1E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../../src/commands/php/help.ts"],"names":[],"mappings":"AAEA,wBAAgB,WAAW,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAoIrD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/php/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../src/commands/services/command.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,qBAAqB,6GAQhC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CommandContext } from "../../context.ts";
|
|
2
|
+
/**
|
|
3
|
+
* List services on a server with a derived availability flag.
|
|
4
|
+
*/
|
|
5
|
+
export declare function servicesList(args: string[], ctx: CommandContext): Promise<void>;
|
|
6
|
+
/**
|
|
7
|
+
* Restart a service on a server.
|
|
8
|
+
*/
|
|
9
|
+
export declare function servicesRestart(args: string[], ctx: CommandContext): Promise<void>;
|
|
10
|
+
//# sourceMappingURL=handlers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../../src/commands/services/handlers.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAMvD;;GAEG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAuBrF;AAED;;GAEG;AACH,wBAAsB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAyCxF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../../src/commands/services/help.ts"],"names":[],"mappings":"AAEA,wBAAgB,gBAAgB,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAwD1D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/services/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../src/commands/ssh-keys/command.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../src/commands/ssh-keys/command.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,oBAAoB,6GAS/B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../../src/commands/ssh-keys/help.ts"],"names":[],"mappings":"AAEA,wBAAgB,eAAe,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../../src/commands/ssh-keys/help.ts"],"names":[],"mappings":"AAEA,wBAAgB,eAAe,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAuEzD"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure logic for `forge ssh-keys sync`: parse an authorized_keys file, give each key
|
|
3
|
+
* a stable managed name, and compare the file with the keys on a server.
|
|
4
|
+
*
|
|
5
|
+
* The Forge API does not return public keys, so keys are matched by name. The name
|
|
6
|
+
* ends with a fingerprint of the key, so a changed key gets a new name.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Check the base64 key data of a public key, as OpenSSH does: it must be canonical
|
|
10
|
+
* base64, and the decoded key must start with its own type as a length-prefixed string.
|
|
11
|
+
*/
|
|
12
|
+
export declare function isValidKeyBlob(type: string, blob: string): boolean;
|
|
13
|
+
/** A public key from the file, with the name it gets on Forge. */
|
|
14
|
+
export interface FileKey {
|
|
15
|
+
name: string;
|
|
16
|
+
/** Public key as sent to Forge: "<type> <base64> [comment]". */
|
|
17
|
+
key: string;
|
|
18
|
+
/** Line number in the file (1-based). */
|
|
19
|
+
line: number;
|
|
20
|
+
}
|
|
21
|
+
/** A key that exists on a server. */
|
|
22
|
+
export interface ServerKey {
|
|
23
|
+
id: number;
|
|
24
|
+
name: string;
|
|
25
|
+
user: string;
|
|
26
|
+
}
|
|
27
|
+
export interface SyncPlan {
|
|
28
|
+
/** File keys that are not on the server. */
|
|
29
|
+
add: FileKey[];
|
|
30
|
+
/** Keys of the user on the server that are not in the file. */
|
|
31
|
+
remove: ServerKey[];
|
|
32
|
+
/** File keys that are already on the server. */
|
|
33
|
+
unchanged: FileKey[];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Convert a key comment to a name prefix: lowercase, `[a-z0-9-]` only, "key" when empty.
|
|
37
|
+
*/
|
|
38
|
+
export declare function slugify(comment: string): string;
|
|
39
|
+
/**
|
|
40
|
+
* Managed name of a key: "<slug(comment)>-<first 8 hex chars of the SHA-256 of the key blob>".
|
|
41
|
+
* The blob is the decoded base64 field, as in an OpenSSH fingerprint.
|
|
42
|
+
*/
|
|
43
|
+
export declare function managedKeyName(comment: string, blob: string): string;
|
|
44
|
+
/**
|
|
45
|
+
* Parse an authorized_keys file: one "<type> <base64> [comment]" per line.
|
|
46
|
+
* Blank lines and "#" comments are ignored.
|
|
47
|
+
*
|
|
48
|
+
* @throws ValidationError for a malformed or duplicate key, with its line number.
|
|
49
|
+
*/
|
|
50
|
+
export declare function parseAuthorizedKeys(content: string): FileKey[];
|
|
51
|
+
/**
|
|
52
|
+
* Compare the file keys with the keys on a server, for one user.
|
|
53
|
+
* Keys of other users are ignored.
|
|
54
|
+
*/
|
|
55
|
+
export declare function planSync(fileKeys: FileKey[], serverKeys: ServerKey[], user: string): SyncPlan;
|
|
56
|
+
//# sourceMappingURL=sync-plan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-plan.d.ts","sourceRoot":"","sources":["../../../src/commands/ssh-keys/sync-plan.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAYH;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAUlE;AAED,kEAAkE;AAClE,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,gEAAgE;IAChE,GAAG,EAAE,MAAM,CAAC;IACZ,yCAAyC;IACzC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,qCAAqC;AACrC,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,QAAQ;IACvB,4CAA4C;IAC5C,GAAG,EAAE,OAAO,EAAE,CAAC;IACf,+DAA+D;IAC/D,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,gDAAgD;IAChD,SAAS,EAAE,OAAO,EAAE,CAAC;CACtB;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAO/C;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAGpE;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,EAAE,CAyC9D;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,QAAQ,CAU7F"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../../src/commands/ssh-keys/sync.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AA8KvD;;GAEG;AACH,wBAAsB,WAAW,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAgHpE"}
|
|
@@ -195,6 +195,17 @@ var OutputFormatter = class {
|
|
|
195
195
|
}
|
|
196
196
|
}
|
|
197
197
|
/**
|
|
198
|
+
* Output raw text such as a log. Human and table formats print the text
|
|
199
|
+
* verbatim (a log is not tabular data); JSON wraps it as a JSON string.
|
|
200
|
+
*/
|
|
201
|
+
outputText(text) {
|
|
202
|
+
if (this.format === "json") {
|
|
203
|
+
console.log(JSON.stringify(text));
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
console.log(text);
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
198
209
|
* Output a list with a human-readable one-liner per item and a table for table format.
|
|
199
210
|
* Falls back to JSON for json format.
|
|
200
211
|
*
|
|
@@ -414,14 +425,19 @@ async function runCommand(fn, formatter) {
|
|
|
414
425
|
}
|
|
415
426
|
}
|
|
416
427
|
/**
|
|
417
|
-
*
|
|
428
|
+
* Outputs an error and exits.
|
|
418
429
|
*/
|
|
419
|
-
function
|
|
420
|
-
const error = ValidationError.required(field, [`Usage: ${usage}`]);
|
|
430
|
+
function exitWithError(error, formatter) {
|
|
421
431
|
handleError(error, formatter);
|
|
422
432
|
throw error;
|
|
423
433
|
}
|
|
434
|
+
/**
|
|
435
|
+
* Exits with a validation error for a missing required argument.
|
|
436
|
+
*/
|
|
437
|
+
function exitWithValidationError(field, usage, formatter) {
|
|
438
|
+
exitWithError(ValidationError.required(field, [`Usage: ${usage}`]), formatter);
|
|
439
|
+
}
|
|
424
440
|
//#endregion
|
|
425
|
-
export { isOutputFormat as S,
|
|
441
|
+
export { isOutputFormat as C, isCliError as S, setToken as _, runCommand as a, ConfigError as b, OutputFormatter as c, createConfigStore$1 as d, deleteToken as f, setOrganizationSlug as g, getToken$1 as h, handleError as i, colors as l, getOrganizationSlug as m, exitWithError as n, createContext as o, getConfig as p, exitWithValidationError as r, createTestContext as s, ExitCode as t, setColorEnabled as u, ApiError as v, ValidationError as x, CliError as y };
|
|
426
442
|
|
|
427
|
-
//# sourceMappingURL=error-handler-
|
|
443
|
+
//# sourceMappingURL=error-handler-Adi84RcF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-handler-Adi84RcF.js","names":[],"sources":["../src/types.ts","../src/errors.ts","../src/config.ts","../src/utils/colors.ts","../src/output.ts","../src/context.ts","../src/error-handler.ts"],"sourcesContent":["// CLI-specific types for forge\n\nexport type OutputFormat = \"json\" | \"human\" | \"table\";\n\nexport function isOutputFormat(value: unknown): value is OutputFormat {\n return value === \"json\" || value === \"human\" || value === \"table\";\n}\n\nexport interface CliOptions {\n format?: OutputFormat;\n quiet?: boolean;\n noColor?: boolean;\n}\n","/**\n * Error types for forge.\n *\n * Provides specific error types for different failure scenarios with\n * recovery hints for both humans and AI agents.\n */\n\n/**\n * Base error class for all CLI errors.\n */\nexport abstract class CliError extends Error {\n abstract readonly code: string;\n abstract readonly isRecoverable: boolean;\n\n constructor(\n message: string,\n public readonly hints?: string[],\n public readonly cause?: unknown,\n ) {\n super(message);\n this.name = this.constructor.name;\n\n Error.captureStackTrace?.(this, this.constructor);\n }\n\n toJSON(): Record<string, unknown> {\n return {\n error: this.code,\n name: this.name,\n message: this.message,\n isRecoverable: this.isRecoverable,\n ...(this.hints && this.hints.length > 0 ? { hints: this.hints } : {}),\n ...(this.cause instanceof Error ? { cause: { message: this.cause.message } } : {}),\n };\n }\n\n toFormattedMessage(): string {\n let msg = this.message;\n if (this.hints && this.hints.length > 0) {\n msg += \"\\n\\nHints:\\n\" + this.hints.map((h) => ` • ${h}`).join(\"\\n\");\n }\n return msg;\n }\n}\n\n// ── Config Errors ────────────────────────────────────\n\nexport class ConfigError extends CliError {\n readonly code = \"CONFIG_ERROR\";\n readonly isRecoverable = true;\n\n static missingToken(): ConfigError {\n return new ConfigError(\"API token not configured\", [\n \"Set via CLI flag: --token <token>\",\n \"Set via environment: export FORGE_API_TOKEN=<token>\",\n \"Set via config: forge config set YOUR_TOKEN\",\n ]);\n }\n}\n\n// ── Validation Errors ────────────────────────────────\n\nexport class ValidationError extends CliError {\n readonly code = \"VALIDATION_ERROR\";\n readonly isRecoverable = true;\n\n constructor(\n message: string,\n public readonly field?: string,\n hints?: string[],\n cause?: unknown,\n ) {\n super(message, hints, cause);\n }\n\n override toJSON() {\n return { ...super.toJSON(), field: this.field };\n }\n\n static required(field: string, hints?: string[]): ValidationError {\n return new ValidationError(`${field} is required`, field, hints);\n }\n}\n\n// ── API Errors ───────────────────────────────────────\n\nexport class ApiError extends CliError {\n readonly code = \"API_ERROR\";\n readonly isRecoverable: boolean;\n\n constructor(\n message: string,\n public readonly statusCode?: number,\n hints?: string[],\n cause?: unknown,\n ) {\n super(message, hints ?? getApiErrorHints(statusCode), cause);\n this.isRecoverable = statusCode === undefined || (statusCode >= 500 && statusCode < 600);\n }\n\n override toJSON() {\n return { ...super.toJSON(), statusCode: this.statusCode };\n }\n\n static fromForgeError(error: unknown): ApiError {\n if (error instanceof Error && \"statusCode\" in error) {\n const code = (error as { statusCode: unknown }).statusCode;\n return new ApiError(\n error.message,\n typeof code === \"number\" ? code : undefined,\n undefined,\n error,\n );\n }\n if (error instanceof Error) {\n return new ApiError(error.message, undefined, undefined, error);\n }\n return new ApiError(String(error));\n }\n}\n\nfunction getApiErrorHints(statusCode?: number): string[] {\n if (statusCode === 401) {\n return [\"Check that your API token is valid\", \"Set via: export FORGE_API_TOKEN=<token>\"];\n }\n if (statusCode === 403) {\n return [\"You may not have permission to access this resource\"];\n }\n if (statusCode === 404) {\n return [\n \"The resource may not exist\",\n \"Verify the ID is correct\",\n \"Use the list command to find valid IDs\",\n ];\n }\n if (statusCode === 429) {\n return [\"Too many requests — wait before retrying\"];\n }\n if (statusCode !== undefined && statusCode >= 500) {\n return [\"Server error — try again later\"];\n }\n return [];\n}\n\n// ── Type Guards ──────────────────────────────────────\n\nexport function isCliError(error: unknown): error is CliError {\n return error instanceof CliError;\n}\n","/**\n * Config loading for forge.\n *\n * Resolution priority (highest to lowest):\n * 1. CLI arguments (--token)\n * 2. Environment variable (FORGE_API_TOKEN)\n * 3. Config file (XDG-compliant)\n */\n\nimport { createConfigStore, getToken } from \"@studiometa/forge-api\";\n\nexport interface ForgeCliConfig {\n /** Forge API token */\n apiToken: string | undefined;\n}\n\n/**\n * Resolve config from multiple sources with priority order.\n */\nexport function getConfig(\n cliOptions?: Record<string, string | boolean | string[]>,\n): ForgeCliConfig {\n // 1. CLI argument --token\n const cliToken = cliOptions?.token;\n\n // 2. Environment variable / config file (handled by getToken)\n const storedToken = getToken(createConfigStore());\n\n return {\n apiToken: typeof cliToken === \"string\" ? cliToken : (storedToken ?? undefined),\n };\n}\n\nexport {\n createConfigStore,\n getToken,\n setToken,\n deleteToken,\n getOrganizationSlug,\n setOrganizationSlug,\n} from \"@studiometa/forge-api\";\n","/**\n * ANSI color utilities using native Node.js.\n * Provides terminal colors without external dependencies.\n */\n\n// ANSI escape codes\nconst RESET = \"\\x1b[0m\";\nconst BOLD = \"\\x1b[1m\";\nconst DIM = \"\\x1b[2m\";\n\n// Foreground colors\nconst FG_RED = \"\\x1b[31m\";\nconst FG_GREEN = \"\\x1b[32m\";\nconst FG_YELLOW = \"\\x1b[33m\";\nconst FG_CYAN = \"\\x1b[36m\";\nconst FG_GRAY = \"\\x1b[90m\";\n\n// Colors enabled by default, disabled by NO_COLOR env var\nlet colorEnabled = process.env.NO_COLOR === undefined;\n\nexport function setColorEnabled(enabled: boolean): void {\n colorEnabled = enabled;\n}\n\nexport function isColorEnabled(): boolean {\n return colorEnabled;\n}\n\nfunction colorize(text: string, code: string): string {\n if (!colorEnabled) return text;\n return `${code}${text}${RESET}`;\n}\n\nexport const colors = {\n reset: (text: string) => (colorEnabled ? `${RESET}${text}` : text),\n bold: (text: string) => colorize(text, BOLD),\n dim: (text: string) => colorize(text, DIM),\n red: (text: string) => colorize(text, FG_RED),\n green: (text: string) => colorize(text, FG_GREEN),\n yellow: (text: string) => colorize(text, FG_YELLOW),\n cyan: (text: string) => colorize(text, FG_CYAN),\n gray: (text: string) => colorize(text, FG_GRAY),\n};\n","/* eslint-disable typescript-eslint/no-base-to-string -- generic formatter converts unknown values to strings */\nimport type { OutputFormat } from \"./types.ts\";\n\nimport { colors } from \"./utils/colors.ts\";\n\n/**\n * Output formatter for CLI commands.\n * Supports human-readable, JSON, and table formats.\n */\nexport class OutputFormatter {\n constructor(\n private format: OutputFormat = \"human\",\n private noColor: boolean = false,\n ) {}\n\n /**\n * Returns true when the current format is JSON.\n */\n isJson(): boolean {\n return this.format === \"json\";\n }\n\n /**\n * Output data in the configured format.\n * Use format='json' for AI agents and structured data.\n */\n output(data: unknown): void {\n switch (this.format) {\n case \"json\":\n console.log(JSON.stringify(data, null, 2));\n break;\n case \"table\":\n this.outputTable(data);\n break;\n default:\n console.log(data);\n break;\n }\n }\n\n /**\n * Output raw text such as a log. Human and table formats print the text\n * verbatim (a log is not tabular data); JSON wraps it as a JSON string.\n */\n outputText(text: string): void {\n if (this.format === \"json\") {\n console.log(JSON.stringify(text));\n return;\n }\n console.log(text);\n }\n\n /**\n * Output a list with a human-readable one-liner per item and a table for table format.\n * Falls back to JSON for json format.\n *\n * @param data - Array of items to display\n * @param columns - Ordered list of field names to include in human/table output\n * @param emptyMessage - Message shown when data is empty (human format only)\n * @param lineFormat - Optional custom line formatter for human format\n */\n outputList<T extends object>(\n data: T[],\n columns: (keyof T & string)[],\n emptyMessage: string,\n lineFormat?: (item: T) => string,\n ): void {\n if (this.format === \"json\") {\n console.log(JSON.stringify(data, null, 2));\n return;\n }\n\n if (this.format === \"table\") {\n this.outputTable(data.map((item) => Object.fromEntries(columns.map((c) => [c, item[c]]))));\n return;\n }\n\n // human\n if (data.length === 0) {\n console.log(colors.cyan(emptyMessage));\n return;\n }\n\n if (lineFormat) {\n for (const item of data) {\n console.log(lineFormat(item));\n }\n return;\n }\n\n // Default: padded columns\n const widths = columns.map((col) =>\n Math.max(\n col.length,\n ...data.map((item) => String((item as Record<string, unknown>)[col] ?? \"\").length),\n ),\n );\n for (const item of data) {\n const row = item as Record<string, unknown>;\n const line = columns.map((col, i) => String(row[col] ?? \"\").padEnd(widths[i])).join(\" \");\n console.log(line.trimEnd());\n }\n }\n\n /**\n * Output a single resource in human-readable format.\n * For json format, uses JSON.stringify. For table format, uses a two-column key/value table.\n *\n * @param data - Object to display\n * @param fields - Ordered list of fields to display (defaults to all keys)\n */\n outputOne<T extends object>(data: T, fields?: (keyof T & string)[]): void {\n if (this.format === \"json\") {\n console.log(JSON.stringify(data, null, 2));\n return;\n }\n\n const record = data as Record<string, unknown>;\n const keys = fields ?? (Object.keys(record) as (keyof T & string)[]);\n\n if (this.format === \"table\") {\n const rows = keys.map((k) => ({ field: k, value: String(record[k] ?? \"\") }));\n this.outputTable(rows);\n return;\n }\n\n // human: key: value pairs\n const keyWidth = Math.max(...keys.map((k) => k.length));\n for (const key of keys) {\n const value = record[key];\n const valueStr =\n value !== null && typeof value === \"object\" ? JSON.stringify(value) : String(value ?? \"\");\n console.log(`${colors.cyan(key.padEnd(keyWidth))} ${valueStr}`);\n }\n }\n\n success(message: string): void {\n if (this.format === \"json\") {\n console.log(JSON.stringify({ status: \"success\", message }));\n } else {\n console.log(colors.green(`✓ ${message}`));\n }\n }\n\n error(message: string, details?: unknown): void {\n if (this.format === \"json\") {\n console.error(JSON.stringify({ status: \"error\", message, details }));\n } else {\n console.error(colors.red(`✗ ${message}`));\n if (details !== undefined) {\n console.error(details);\n }\n }\n }\n\n warning(message: string): void {\n if (this.format === \"json\") {\n console.log(JSON.stringify({ status: \"warning\", message }));\n } else {\n console.log(colors.yellow(`⚠ ${message}`));\n }\n }\n\n info(message: string): void {\n if (this.format === \"json\") {\n console.log(JSON.stringify({ status: \"info\", message }));\n } else {\n console.log(colors.cyan(message));\n }\n }\n\n private outputTable(data: unknown): void {\n if (Array.isArray(data) && data.length > 0) {\n const headers = Object.keys(data[0] as Record<string, unknown>);\n const colWidths = headers.map((h) => {\n const maxDataWidth = Math.max(\n ...data.map((row) => String((row as Record<string, unknown>)[h] ?? \"\").length),\n );\n return Math.max(h.length, maxDataWidth);\n });\n\n // Header\n const headerRow = headers.map((h, i) => h.padEnd(colWidths[i])).join(\" | \");\n console.log(headerRow);\n console.log(colWidths.map((w) => \"-\".repeat(w)).join(\"-+-\"));\n\n // Rows\n for (const row of data) {\n const rowStr = headers\n .map((h, i) => String((row as Record<string, unknown>)[h] ?? \"\").padEnd(colWidths[i]))\n .join(\" | \");\n console.log(rowStr);\n }\n }\n }\n}\n","/**\n * CLI execution context with dependency injection.\n *\n * Instead of hidden dependencies in command handlers, this module provides\n * explicit dependency passing for testability and transparency.\n */\n\nimport type { HttpClient } from \"@studiometa/forge-api\";\nimport type { ExecutorContext } from \"@studiometa/forge-core\";\n\nimport { type OutputFormat, isOutputFormat } from \"./types.ts\";\n\nimport { HttpClient as ForgeHttpClient } from \"@studiometa/forge-api\";\nimport { ConfigError } from \"./errors.ts\";\nimport { createConfigStore, getToken, getOrganizationSlug } from \"./config.ts\";\nimport { OutputFormatter } from \"./output.ts\";\n\nexport interface CommandOptions {\n [key: string]: string | boolean | string[] | undefined;\n format?: string;\n f?: string;\n token?: string;\n \"no-color\"?: boolean;\n}\n\n/**\n * Context containing all dependencies needed by command handlers.\n */\nexport interface CommandContext {\n /** Output formatter for the current format */\n readonly formatter: OutputFormatter;\n /** Raw CLI options */\n readonly options: CommandOptions;\n /** Create an ExecutorContext from this command context */\n createExecutorContext(token: string): ExecutorContext;\n /** Resolve the API token or throw ConfigError */\n getToken(): string;\n}\n\n/**\n * Creates a command context from CLI options.\n */\nexport function createContext(options: CommandOptions = {}): CommandContext {\n const rawFormat = options.format ?? options.f ?? \"human\";\n const format: OutputFormat = isOutputFormat(rawFormat) ? rawFormat : \"human\";\n const noColor = options[\"no-color\"] === true;\n const formatter = new OutputFormatter(format, noColor);\n\n return {\n formatter,\n options,\n\n createExecutorContext(token: string): ExecutorContext {\n const client: HttpClient = new ForgeHttpClient({ token });\n const orgSlug =\n (typeof options.org === \"string\" && options.org) ||\n getOrganizationSlug(createConfigStore()) ||\n undefined;\n return { client, organizationSlug: orgSlug };\n },\n\n getToken(): string {\n // 1. CLI arg\n if (typeof options.token === \"string\" && options.token) {\n return options.token;\n }\n // 2. Env var / config file\n const stored = getToken(createConfigStore());\n if (stored) {\n return stored;\n }\n // 3. Not found — throw\n throw ConfigError.missingToken();\n },\n };\n}\n\n/**\n * Creates a test context for unit tests.\n *\n * @example\n * ```typescript\n * const ctx = createTestContext({\n * mockClient: { get: async () => ({ servers: [] }) } as never,\n * });\n * ```\n */\nexport function createTestContext(overrides: {\n options?: CommandOptions;\n formatter?: OutputFormatter;\n token?: string;\n mockClient?: HttpClient;\n}): CommandContext {\n const opts: CommandOptions = overrides.options ?? {\n format: \"json\",\n \"no-color\": true,\n };\n const rawFormat = opts.format ?? \"json\";\n const format: OutputFormat = isOutputFormat(rawFormat) ? rawFormat : \"json\";\n const formatter = overrides.formatter ?? new OutputFormatter(format, true);\n\n return {\n formatter,\n options: opts,\n createExecutorContext(_token: string): ExecutorContext {\n if (!overrides.mockClient) {\n throw new Error(\n \"createTestContext: provide mockClient to use createExecutorContext in tests\",\n );\n }\n return { client: overrides.mockClient, organizationSlug: \"test-org\" };\n },\n getToken(): string {\n if (overrides.token) return overrides.token;\n if (typeof opts.token === \"string\") return opts.token;\n return \"test-token\";\n },\n };\n}\n","/**\n * Centralized error handling for forge.\n */\n\nimport type { OutputFormatter } from \"./output.ts\";\n\nimport { ApiError, CliError, ConfigError, ValidationError, isCliError } from \"./errors.ts\";\n\n/**\n * Exit codes for different error categories.\n */\nexport const ExitCode = {\n SUCCESS: 0,\n GENERAL_ERROR: 1,\n AUTHENTICATION_ERROR: 2,\n VALIDATION_ERROR: 3,\n CONFIG_ERROR: 4,\n NOT_FOUND_ERROR: 5,\n} as const;\n\nexport type ExitCode = (typeof ExitCode)[keyof typeof ExitCode];\n\n/**\n * Determine the appropriate exit code for an error.\n */\nexport function getExitCode(error: unknown): ExitCode {\n if (error instanceof ValidationError) {\n return ExitCode.VALIDATION_ERROR;\n }\n if (error instanceof ApiError) {\n if (error.statusCode === 401) return ExitCode.AUTHENTICATION_ERROR;\n if (error.statusCode === 404) return ExitCode.NOT_FOUND_ERROR;\n }\n if (isCliError(error) && error.code === \"CONFIG_ERROR\") {\n return ExitCode.CONFIG_ERROR;\n }\n return ExitCode.GENERAL_ERROR;\n}\n\n/**\n * Central error handler for all commands.\n */\nexport function handleError(\n error: unknown,\n formatter: OutputFormatter,\n options?: { exit?: boolean },\n): ExitCode {\n const shouldExit = options?.exit ?? true;\n\n let cliError: CliError;\n if (isCliError(error)) {\n cliError = error;\n } else {\n cliError = ApiError.fromForgeError(error);\n }\n\n // Output error in appropriate format\n if (formatter.isJson()) {\n formatter.output(cliError.toJSON());\n } else {\n formatter.error(cliError.toFormattedMessage());\n }\n\n const exitCode = getExitCode(cliError);\n\n if (shouldExit) {\n process.exit(exitCode);\n }\n\n return exitCode;\n}\n\n/**\n * Wraps a command function with automatic error handling.\n */\nexport async function runCommand<T>(\n fn: () => Promise<T>,\n formatter: OutputFormatter,\n): Promise<T | undefined> {\n try {\n return await fn();\n } catch (error) {\n handleError(error, formatter);\n return undefined; // unreachable due to process.exit\n }\n}\n\n/**\n * Outputs an error and exits.\n */\nexport function exitWithError(error: CliError, formatter: OutputFormatter): never {\n handleError(error, formatter);\n // Unreachable in production\n throw error;\n}\n\n/**\n * Exits with a validation error for a missing required argument.\n */\nexport function exitWithValidationError(\n field: string,\n usage: string,\n formatter: OutputFormatter,\n): never {\n exitWithError(ValidationError.required(field, [`Usage: ${usage}`]), formatter);\n}\n\n/**\n * Exits with a config error when token is missing.\n */\nexport function exitWithConfigError(formatter: OutputFormatter): never {\n const error = ConfigError.missingToken();\n handleError(error, formatter);\n throw error;\n}\n"],"mappings":";;AAIA,SAAgB,eAAe,OAAuC;CACpE,OAAO,UAAU,UAAU,UAAU,WAAW,UAAU;AAC5D;;;;;;;;;;;;ACIA,IAAsB,WAAtB,cAAuC,MAAM;CAMzB;CACA;CAHlB,YACE,SACA,OACA,OACA;EACA,MAAM,OAAO;EAHG,KAAA,QAAA;EACA,KAAA,QAAA;EAGhB,KAAK,OAAO,KAAK,YAAY;EAE7B,MAAM,oBAAoB,MAAM,KAAK,WAAW;CAClD;CAEA,SAAkC;EAChC,OAAO;GACL,OAAO,KAAK;GACZ,MAAM,KAAK;GACX,SAAS,KAAK;GACd,eAAe,KAAK;GACpB,GAAI,KAAK,SAAS,KAAK,MAAM,SAAS,IAAI,EAAE,OAAO,KAAK,MAAM,IAAI,CAAC;GACnE,GAAI,KAAK,iBAAiB,QAAQ,EAAE,OAAO,EAAE,SAAS,KAAK,MAAM,QAAQ,EAAE,IAAI,CAAC;EAClF;CACF;CAEA,qBAA6B;EAC3B,IAAI,MAAM,KAAK;EACf,IAAI,KAAK,SAAS,KAAK,MAAM,SAAS,GACpC,OAAO,iBAAiB,KAAK,MAAM,KAAK,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,IAAI;EAErE,OAAO;CACT;AAC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IAAI;CACJ,IAAI,WAAW,KAAK,GAClB,WAAW;MAEX,WAAW,SAAS,eAAe,KAAK;CAI1C,IAAI,UAAU,OAAO,GACnB,UAAU,OAAO,SAAS,OAAO,CAAC;MAElC,UAAU,MAAM,SAAS,mBAAmB,CAAC;CAG/C,MAAM,WAAW,YAAY,QAAQ;CAErC,IAAI,YACF,QAAQ,KAAK,QAAQ;CAGvB,OAAO;AACT;;;;AAKA,eAAsB,WACpB,IACA,WACwB;CACxB,IAAI;EACF,OAAO,MAAM,GAAG;CAClB,SAAS,OAAO;EACd,YAAY,OAAO,SAAS;EAC5B;CACF;AACF;;;;AAKA,SAAgB,cAAc,OAAiB,WAAmC;CAChF,YAAY,OAAO,SAAS;CAE5B,MAAM;AACR;;;;AAKA,SAAgB,wBACd,OACA,OACA,WACO;CACP,cAAc,gBAAgB,SAAS,OAAO,CAAC,UAAU,OAAO,CAAC,GAAG,SAAS;AAC/E"}
|
package/dist/error-handler.d.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Centralized error handling for forge.
|
|
3
3
|
*/
|
|
4
4
|
import type { OutputFormatter } from "./output.ts";
|
|
5
|
+
import { CliError } from "./errors.ts";
|
|
5
6
|
/**
|
|
6
7
|
* Exit codes for different error categories.
|
|
7
8
|
*/
|
|
@@ -28,6 +29,10 @@ export declare function handleError(error: unknown, formatter: OutputFormatter,
|
|
|
28
29
|
* Wraps a command function with automatic error handling.
|
|
29
30
|
*/
|
|
30
31
|
export declare function runCommand<T>(fn: () => Promise<T>, formatter: OutputFormatter): Promise<T | undefined>;
|
|
32
|
+
/**
|
|
33
|
+
* Outputs an error and exits.
|
|
34
|
+
*/
|
|
35
|
+
export declare function exitWithError(error: CliError, formatter: OutputFormatter): never;
|
|
31
36
|
/**
|
|
32
37
|
* Exits with a validation error for a missing required argument.
|
|
33
38
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-handler.d.ts","sourceRoot":"","sources":["../src/error-handler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,mBAAmB,CAAC,SAAS,EAAE,eAAe,GAAG,KAAK,CAIrE"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { S as isCliError, a as runCommand, b as ConfigError, c as OutputFormatter, i as handleError, o as createContext, p as getConfig, s as createTestContext, t as ExitCode, v as ApiError, x as ValidationError, y as CliError } from "./error-handler-Adi84RcF.js";
|
|
2
2
|
export { ApiError, CliError, ConfigError, ExitCode, OutputFormatter, ValidationError, createContext, createTestContext, getConfig, handleError, isCliError, runCommand };
|
package/dist/output.d.ts
CHANGED
|
@@ -16,6 +16,11 @@ export declare class OutputFormatter {
|
|
|
16
16
|
* Use format='json' for AI agents and structured data.
|
|
17
17
|
*/
|
|
18
18
|
output(data: unknown): void;
|
|
19
|
+
/**
|
|
20
|
+
* Output raw text such as a log. Human and table formats print the text
|
|
21
|
+
* verbatim (a log is not tabular data); JSON wraps it as a JSON string.
|
|
22
|
+
*/
|
|
23
|
+
outputText(text: string): void;
|
|
19
24
|
/**
|
|
20
25
|
* Output a list with a human-readable one-liner per item and a table for table format.
|
|
21
26
|
* Falls back to JSON for json format.
|
package/dist/output.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../src/output.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAI/C;;;GAGG;AACH,qBAAa,eAAe;IAExB,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,OAAO;IAFjB,YACU,MAAM,GAAE,YAAsB,EAC9B,OAAO,GAAE,OAAe,EAC9B;IAEJ;;OAEG;IACH,MAAM,IAAI,OAAO,CAEhB;IAED;;;OAGG;IACH,MAAM,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAY1B;IAED;;;;;;;;OAQG;IACH,UAAU,CAAC,CAAC,SAAS,MAAM,EACzB,IAAI,EAAE,CAAC,EAAE,EAC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U,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,GAC/B,IAAI,CAoCN;IAED;;;;;;OAMG;IACH,SAAS,CAAC,CAAC,SAAS,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,EAAE,GAAG,IAAI,CAuBxE;IAED,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAM7B;IAED,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,CAS9C;IAED,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAM7B;IAED,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAM1B;IAED,OAAO,CAAC,WAAW;CAwBpB"}
|
package/dist/utils/args.d.ts
CHANGED
|
@@ -12,4 +12,10 @@ export interface ParsedArgs {
|
|
|
12
12
|
export declare function parseArgs(argv?: string[]): ParsedArgs;
|
|
13
13
|
export declare function getOption(options: Record<string, OptionValue>, names: string[], defaultValue?: string): string | undefined;
|
|
14
14
|
export declare function hasFlag(options: Record<string, OptionValue>, names: string[]): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Whether the arguments ask for the CLI version: a bare `--version` or `-v`
|
|
17
|
+
* with no command. Commands such as `php config` and `services restart` take
|
|
18
|
+
* `--version <value>`, so a bare `--version` after a command is not a version request.
|
|
19
|
+
*/
|
|
20
|
+
export declare function isVersionRequest({ command, options }: ParsedArgs): boolean;
|
|
15
21
|
//# sourceMappingURL=args.d.ts.map
|
package/dist/utils/args.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../../src/utils/args.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,EAAE,CAAC;AACtD,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;AAEzD,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACrC,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB;
|
|
1
|
+
{"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../../src/utils/args.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,EAAE,CAAC;AACtD,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;AAEzD,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACrC,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB;AAqCD,wBAAgB,SAAS,CAAC,IAAI,GAAE,MAAM,EAA0B,GAAG,UAAU,CAwD5E;AAED,wBAAgB,SAAS,CACvB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,EACpC,KAAK,EAAE,MAAM,EAAE,EACf,YAAY,CAAC,EAAE,MAAM,GACpB,MAAM,GAAG,SAAS,CAQpB;AAED,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAEtF;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,UAAU,GAAG,OAAO,CAE1E"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read the content of an update command from a file, stdin or an inline option.
|
|
3
|
+
*/
|
|
4
|
+
import type { CommandOptions } from "../context.ts";
|
|
5
|
+
import type { OutputFormatter } from "../output.ts";
|
|
6
|
+
import type { OptionValue } from "./args.ts";
|
|
7
|
+
export interface ContentSource {
|
|
8
|
+
/** What the content is, in lower case, e.g. "deployment script". */
|
|
9
|
+
label: string;
|
|
10
|
+
/** Usage line shown in validation errors. */
|
|
11
|
+
usage: string;
|
|
12
|
+
formatter: OutputFormatter;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Read content from a file path, or from stdin when the path is "-".
|
|
16
|
+
* Exits with a validation error when the path is missing, the file cannot be read or it is empty.
|
|
17
|
+
*/
|
|
18
|
+
export declare function readContentFile(path: OptionValue | undefined, field: string, source: ContentSource): string;
|
|
19
|
+
/**
|
|
20
|
+
* Read content from exactly one of `--file <path|->` or `--content <string>`.
|
|
21
|
+
* Exits with a validation error when both or none are given, or when the content is empty.
|
|
22
|
+
*/
|
|
23
|
+
export declare function readContentOption(options: CommandOptions, source: ContentSource): string;
|
|
24
|
+
//# sourceMappingURL=content-source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-source.d.ts","sourceRoot":"","sources":["../../src/utils/content-source.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAK7C,MAAM,WAAW,aAAa;IAC5B,oEAAoE;IACpE,KAAK,EAAE,MAAM,CAAC;IACd,6CAA6C;IAC7C,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,eAAe,CAAC;CAC5B;AAYD;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,WAAW,GAAG,SAAS,EAC7B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,aAAa,GACpB,MAAM,CAuBR;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,aAAa,GAAG,MAAM,CA6BxF"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compare local content with the content on Forge for `--check`.
|
|
3
|
+
*/
|
|
4
|
+
import type { OutputFormatter } from "../output.ts";
|
|
5
|
+
/**
|
|
6
|
+
* Normalize CRLF to LF and drop a single trailing newline,
|
|
7
|
+
* so editor and platform differences do not count as drift.
|
|
8
|
+
*/
|
|
9
|
+
export declare function normalizeContent(text: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Build a unified-style line diff from `remote` to `local`, with `context`
|
|
12
|
+
* unchanged lines around each change. Returns an empty string when both
|
|
13
|
+
* are equal after normalization.
|
|
14
|
+
*/
|
|
15
|
+
export declare function unifiedDiff(remote: string, local: string, context?: number): string;
|
|
16
|
+
/**
|
|
17
|
+
* A difference found by `--check`: `text` for human output, `json` for json output.
|
|
18
|
+
*/
|
|
19
|
+
export interface Drift {
|
|
20
|
+
text: string;
|
|
21
|
+
json: unknown;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Print the result of a `--check` and set exit code 1 when the local content differs from Forge.
|
|
25
|
+
* It sets `process.exitCode` and does not call `process.exit`, so a long diff
|
|
26
|
+
* written to a pipe is not cut. JSON output is `{ inSync: true }` or `{ inSync: false, diff }`.
|
|
27
|
+
*/
|
|
28
|
+
export declare function reportDrift(label: string, drift: Drift | null, formatter: OutputFormatter): void;
|
|
29
|
+
/**
|
|
30
|
+
* Check `local` against `remote` as text and report a line diff.
|
|
31
|
+
*/
|
|
32
|
+
export declare function reportTextDrift(label: string, remote: string, local: string, formatter: OutputFormatter): void;
|
|
33
|
+
//# sourceMappingURL=drift.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drift.d.ts","sourceRoot":"","sources":["../../src/utils/drift.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAIpD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGrD;AAeD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,SAAI,GAAG,MAAM,CAsD9E;AAED;;GAEG;AACH,MAAM,WAAW,KAAK;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,OAAO,CAAC;CACf;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI,EAAE,SAAS,EAAE,eAAe,GAAG,IAAI,CAehG;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,eAAe,GACzB,IAAI,CAGN"}
|
package/dist/utils/resolve.d.ts
CHANGED
|
@@ -13,6 +13,14 @@ import type { ExecutorContext } from "@studiometa/forge-core";
|
|
|
13
13
|
* - 2+ matches → ValidationError listing ambiguous matches
|
|
14
14
|
*/
|
|
15
15
|
export declare function resolveServerId(value: string, execCtx: ExecutorContext): Promise<string>;
|
|
16
|
+
/**
|
|
17
|
+
* Resolve a --server value to a numeric server ID string, against a list of servers
|
|
18
|
+
* that is already loaded. Same rules as {@link resolveServerId}, with no API call.
|
|
19
|
+
*/
|
|
20
|
+
export declare function matchServerId(value: string, servers: Array<{
|
|
21
|
+
id: number;
|
|
22
|
+
name: string;
|
|
23
|
+
}>): string;
|
|
16
24
|
/**
|
|
17
25
|
* Resolve a --site value to a numeric site ID string.
|
|
18
26
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../src/utils/resolve.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAG9D;;;;;;;GAOG;AACH,wBAAsB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../src/utils/resolve.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAG9D;;;;;;;GAOG;AACH,wBAAsB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAO9F;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,MAAM,CA4BjG;AAED;;;;;;;GAOG;AACH,wBAAsB,aAAa,CACjC,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,MAAM,CAAC,CA+BjB"}
|