@project-ajax/cli 0.0.14 → 0.0.16
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/dist/api/client.d.ts +0 -2
- package/dist/api/client.d.ts.map +1 -1
- package/dist/commands/auth.d.ts.map +1 -1
- package/dist/commands/auth.impl.d.ts +2 -3
- package/dist/commands/auth.impl.d.ts.map +1 -1
- package/dist/commands/auth.impl.js +65 -101
- package/dist/commands/auth.js +0 -27
- package/dist/commands/deploy.impl.d.ts.map +1 -1
- package/dist/commands/deploy.impl.js +6 -7
- package/dist/commands/exec.impl.js +1 -1
- package/dist/commands/utils/testing.d.ts +20 -5
- package/dist/commands/utils/testing.d.ts.map +1 -1
- package/dist/commands/utils/testing.js +66 -25
- package/dist/config.d.ts +144 -42
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +322 -140
- package/dist/deploy.d.ts +2 -1
- package/dist/deploy.d.ts.map +1 -1
- package/dist/flags.d.ts +2 -3
- package/dist/flags.d.ts.map +1 -1
- package/dist/flags.js +4 -10
- package/dist/handler.d.ts.map +1 -1
- package/dist/handler.js +13 -9
- package/dist/routes.d.ts.map +1 -1
- package/dist/routes.js +2 -3
- package/dist/token.d.ts +35 -0
- package/dist/token.d.ts.map +1 -0
- package/dist/token.js +58 -0
- package/package.json +5 -2
package/dist/config.d.ts
CHANGED
|
@@ -1,63 +1,165 @@
|
|
|
1
|
+
import z from "zod";
|
|
1
2
|
import type { GlobalFlags } from "./flags.js";
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
3
|
+
import { type TokenInfo } from "./token.js";
|
|
4
|
+
export declare const Environment: z.ZodLiteral<"local" | "dev" | "stg" | "prod">;
|
|
5
|
+
export type Environment = z.infer<typeof Environment>;
|
|
6
|
+
declare const SpaceCache: z.ZodObject<{
|
|
7
|
+
version: z.ZodLiteral<"1">;
|
|
8
|
+
spaces: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
9
|
+
id: z.ZodString;
|
|
10
|
+
name: z.ZodString;
|
|
11
|
+
cellId: z.ZodString;
|
|
12
|
+
}, z.z.core.$strip>>;
|
|
13
|
+
}, z.z.core.$strip>;
|
|
14
|
+
export type SpaceCache = z.infer<typeof SpaceCache>;
|
|
15
|
+
declare const LocalConfig: z.ZodObject<{
|
|
16
|
+
version: z.ZodLiteral<"1">;
|
|
17
|
+
environment: z.ZodLiteral<"local" | "dev" | "stg" | "prod">;
|
|
18
|
+
baseURL: z.ZodOptional<z.ZodString>;
|
|
19
|
+
spaceId: z.ZodNullable<z.ZodString>;
|
|
20
|
+
workerId: z.ZodNullable<z.ZodString>;
|
|
21
|
+
}, z.z.core.$strip>;
|
|
22
|
+
export type LocalConfig = z.infer<typeof LocalConfig>;
|
|
23
|
+
export declare class NoSuitableConfigFileError extends Error {
|
|
24
|
+
constructor();
|
|
13
25
|
}
|
|
14
26
|
/**
|
|
15
|
-
* Manages configuration for the
|
|
16
|
-
*
|
|
17
|
-
* Environment variables take precedence over the config file.
|
|
27
|
+
* Manages configuration for the command line interface.
|
|
18
28
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* | WORKERS_TOKEN | token | The token to use for authentication |
|
|
22
|
-
* | WORKERS_ENVIRONMENT | environment | The environment to use |
|
|
23
|
-
* | WORKERS_WORKER_ID | workerId | The worker ID to use |
|
|
24
|
-
* | WORKERS_BASE_URL | baseUrl | The base URL to use |
|
|
29
|
+
* Order of precedence: Command-line flags, environment variables, local config
|
|
30
|
+
* files, where appropriate.
|
|
25
31
|
*/
|
|
26
32
|
export declare class Config {
|
|
27
33
|
#private;
|
|
28
34
|
constructor(opts: {
|
|
29
|
-
|
|
30
|
-
|
|
35
|
+
spaceCachePath: string;
|
|
36
|
+
spaceCache: SpaceCache;
|
|
37
|
+
localConfigPath: string;
|
|
38
|
+
localConfig: LocalConfig;
|
|
39
|
+
environment: Environment;
|
|
40
|
+
baseURL: string;
|
|
41
|
+
spaceId: string | null;
|
|
42
|
+
workerId: string | null;
|
|
43
|
+
token: string | null;
|
|
31
44
|
});
|
|
32
|
-
get
|
|
33
|
-
get
|
|
34
|
-
get
|
|
45
|
+
get environment(): Environment;
|
|
46
|
+
get baseURL(): string;
|
|
47
|
+
get spaceId(): string | null;
|
|
35
48
|
get workerId(): string | null;
|
|
36
|
-
|
|
49
|
+
/**
|
|
50
|
+
* Get the list of cached spaces.
|
|
51
|
+
*
|
|
52
|
+
* @returns An array of cached spaces with id, name, and cellId.
|
|
53
|
+
*/
|
|
54
|
+
getCachedSpaces(): Array<{
|
|
55
|
+
id: string;
|
|
56
|
+
name: string;
|
|
57
|
+
cellId: string;
|
|
58
|
+
}>;
|
|
59
|
+
/**
|
|
60
|
+
* Get the token and token information from the keychain.
|
|
61
|
+
*
|
|
62
|
+
* @returns The token and token information, or null if no token is found.
|
|
63
|
+
*/
|
|
64
|
+
getToken(): Promise<[token: string, tokenInfo: TokenInfo] | null>;
|
|
65
|
+
/**
|
|
66
|
+
* Get the token and token information from the keychain.
|
|
67
|
+
*
|
|
68
|
+
* Throws an error if no token is found.
|
|
69
|
+
*
|
|
70
|
+
* @returns The token and token information.
|
|
71
|
+
*/
|
|
72
|
+
mustGetToken(): Promise<[token: string, tokenInfo: TokenInfo]>;
|
|
73
|
+
/**
|
|
74
|
+
* Log in by updating the local configuration and the space cache, and
|
|
75
|
+
* storing the token in the keychain.
|
|
76
|
+
*
|
|
77
|
+
* @param args The arguments to login.
|
|
78
|
+
* @param args.environment The environment to login to.
|
|
79
|
+
* @param args.token The token to login with.
|
|
80
|
+
* @param args.spaceId The space ID to login to.
|
|
81
|
+
* @param args.spaceName The space name to login to.
|
|
82
|
+
* @param args.cellId The cell ID to login to.
|
|
83
|
+
*/
|
|
84
|
+
login(args: {
|
|
85
|
+
environment: Environment;
|
|
37
86
|
token: string;
|
|
38
87
|
spaceId: string;
|
|
88
|
+
spaceName: string;
|
|
39
89
|
cellId: string;
|
|
40
|
-
}
|
|
90
|
+
}): Promise<void>;
|
|
41
91
|
/**
|
|
42
|
-
*
|
|
92
|
+
* Set the worker ID.
|
|
43
93
|
*
|
|
44
|
-
*
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
94
|
+
* @param workerId The worker ID to set.
|
|
95
|
+
*/
|
|
96
|
+
setWorker(workerId: string): void;
|
|
97
|
+
/**
|
|
98
|
+
* Switch to an existing cached space.
|
|
48
99
|
*
|
|
49
|
-
*
|
|
100
|
+
* This updates the local configuration to use the specified space.
|
|
101
|
+
* The token for this space should already exist in the keychain.
|
|
102
|
+
*
|
|
103
|
+
* @param spaceId The space ID to switch to.
|
|
104
|
+
* @throws Error if the space is not in the cache.
|
|
105
|
+
*/
|
|
106
|
+
switchToSpace(spaceId: string): void;
|
|
107
|
+
/**
|
|
108
|
+
* Resolve the space cache path.
|
|
109
|
+
*
|
|
110
|
+
* @param opts Options for resolving the space cache path.
|
|
111
|
+
* @param opts.filePath The path to the space cache file.
|
|
112
|
+
* @param opts.env The environment variables.
|
|
113
|
+
* @returns The path to the space cache file.
|
|
114
|
+
*/
|
|
115
|
+
static resolveSpaceCachePath(opts: {
|
|
116
|
+
filePath?: string;
|
|
117
|
+
env: NodeJS.ProcessEnv;
|
|
118
|
+
}): string;
|
|
119
|
+
/**
|
|
120
|
+
* Resolve the local config path.
|
|
121
|
+
*
|
|
122
|
+
* @param opts Options for resolving the local config path.
|
|
123
|
+
* @param opts.filePath The path to the local config file.
|
|
124
|
+
* @returns
|
|
125
|
+
*/
|
|
126
|
+
static resolveLocalConfigPath(opts?: {
|
|
127
|
+
filePath?: string;
|
|
128
|
+
}): string;
|
|
129
|
+
/**
|
|
130
|
+
* Load config from space cache and local config files, then resolve them to
|
|
131
|
+
* a final config for this execution of the command line interface.
|
|
132
|
+
*
|
|
133
|
+
* If the local config is v0, it will be upgraded to v1.
|
|
134
|
+
*
|
|
135
|
+
* Overrides:
|
|
136
|
+
*
|
|
137
|
+
* - Environment: WORKERS_ENVIRONMENT or --env flag
|
|
138
|
+
* - Token: WORKERS_TOKEN or --token flag
|
|
139
|
+
* - Base URL: WORKERS_BASE_URL or --base-url flag
|
|
140
|
+
*
|
|
141
|
+
* @param opts The options to load the config from.
|
|
142
|
+
* @param opts.spaceCachePath The path to the space cache file.
|
|
143
|
+
* @param opts.localPath The path to the local config file.
|
|
144
|
+
* @param opts.env The process environment.
|
|
145
|
+
* @param opts.processEnv The process environment.
|
|
146
|
+
* @param opts.flags The global flags.
|
|
147
|
+
* @returns The resolved config.
|
|
50
148
|
*/
|
|
51
|
-
update(config: Partial<ConfigMap>): Promise<void>;
|
|
52
149
|
static load(opts: {
|
|
53
|
-
|
|
54
|
-
|
|
150
|
+
spaceCachePath: string;
|
|
151
|
+
localPath: string;
|
|
152
|
+
env: NodeJS.ProcessEnv;
|
|
55
153
|
flags: GlobalFlags;
|
|
56
|
-
}):
|
|
154
|
+
}): Config;
|
|
155
|
+
/**
|
|
156
|
+
* The empty local config.
|
|
157
|
+
*/
|
|
158
|
+
static get emptyLocalConfig(): LocalConfig;
|
|
159
|
+
/**
|
|
160
|
+
* The empty space cache.
|
|
161
|
+
*/
|
|
162
|
+
static get emptySpaceCache(): SpaceCache;
|
|
57
163
|
}
|
|
58
|
-
export
|
|
59
|
-
spaceId: string;
|
|
60
|
-
userId: string;
|
|
61
|
-
cellId: string;
|
|
62
|
-
};
|
|
164
|
+
export {};
|
|
63
165
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAGA,OAAO,CAAC,MAAM,KAAK,CAAC;AACpB,OAAO,KAAK,EAAE,W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