appwrite-cli 13.5.0 → 13.6.1
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/CHANGELOG.md +14 -0
- package/README.md +2 -2
- package/cli.ts +7 -5
- package/dist/bundle-win-arm64.mjs +988 -258
- package/dist/cli.cjs +988 -258
- package/dist/index.cjs +183 -112
- package/dist/index.js +183 -112
- package/dist/lib/commands/config-validations.d.ts +1 -1
- package/dist/lib/commands/config-validations.d.ts.map +1 -1
- package/dist/lib/commands/errors.d.ts +4 -4
- package/dist/lib/commands/errors.d.ts.map +1 -1
- package/dist/lib/commands/generate.d.ts.map +1 -1
- package/dist/lib/commands/generators/base.d.ts +5 -0
- package/dist/lib/commands/generators/base.d.ts.map +1 -1
- package/dist/lib/commands/generic.d.ts.map +1 -1
- package/dist/lib/commands/init.d.ts.map +1 -1
- package/dist/lib/commands/run.d.ts.map +1 -1
- package/dist/lib/commands/schema.d.ts.map +1 -1
- package/dist/lib/commands/services/activities.d.ts +3 -0
- package/dist/lib/commands/services/activities.d.ts.map +1 -0
- package/dist/lib/commands/services/backups.d.ts +3 -0
- package/dist/lib/commands/services/backups.d.ts.map +1 -0
- package/dist/lib/commands/types.d.ts.map +1 -1
- package/dist/lib/commands/update.d.ts.map +1 -1
- package/dist/lib/commands/utils/change-approval.d.ts +3 -3
- package/dist/lib/commands/utils/change-approval.d.ts.map +1 -1
- package/dist/lib/commands/utils/database-sync.d.ts.map +1 -1
- package/dist/lib/commands/utils/deployment.d.ts +16 -4
- package/dist/lib/commands/utils/deployment.d.ts.map +1 -1
- package/dist/lib/commands/utils/pools.d.ts.map +1 -1
- package/dist/lib/constants.d.ts +1 -1
- package/dist/lib/emulation/docker.d.ts.map +1 -1
- package/dist/lib/json.d.ts +1 -1
- package/dist/lib/json.d.ts.map +1 -1
- package/dist/lib/paginate.d.ts +5 -6
- package/dist/lib/paginate.d.ts.map +1 -1
- package/dist/lib/parser.d.ts +5 -4
- package/dist/lib/parser.d.ts.map +1 -1
- package/dist/lib/spinner.d.ts +1 -1
- package/dist/lib/spinner.d.ts.map +1 -1
- package/dist/lib/utils.d.ts +6 -1
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/lib/validations.d.ts +1 -1
- package/dist/lib/validations.d.ts.map +1 -1
- package/docs/examples/account/create-key.md +5 -0
- package/docs/examples/account/delete-key.md +4 -0
- package/docs/examples/account/get-key.md +4 -0
- package/docs/examples/account/list-keys.md +3 -0
- package/docs/examples/account/update-key.md +6 -0
- package/docs/examples/activities/get-event.md +4 -0
- package/docs/examples/activities/list-events.md +3 -0
- package/docs/examples/backups/create-archive.md +4 -0
- package/docs/examples/backups/create-policy.md +7 -0
- package/docs/examples/backups/create-restoration.md +5 -0
- package/docs/examples/backups/delete-archive.md +4 -0
- package/docs/examples/backups/delete-policy.md +4 -0
- package/docs/examples/backups/get-archive.md +4 -0
- package/docs/examples/backups/get-policy.md +4 -0
- package/docs/examples/backups/get-restoration.md +4 -0
- package/docs/examples/backups/list-archives.md +3 -0
- package/docs/examples/backups/list-policies.md +3 -0
- package/docs/examples/backups/list-restorations.md +3 -0
- package/docs/examples/backups/update-policy.md +4 -0
- package/eslint.config.js +45 -0
- package/install.ps1 +2 -2
- package/install.sh +1 -1
- package/lib/client.ts +3 -3
- package/lib/commands/config-validations.ts +1 -1
- package/lib/commands/config.ts +2 -2
- package/lib/commands/errors.ts +2 -2
- package/lib/commands/generate.ts +8 -6
- package/lib/commands/generators/base.ts +6 -0
- package/lib/commands/generators/typescript/databases.ts +9 -9
- package/lib/commands/generators/typescript/templates/databases.ts.hbs +16 -16
- package/lib/commands/generic.ts +21 -16
- package/lib/commands/init.ts +147 -61
- package/lib/commands/pull.ts +1 -1
- package/lib/commands/push.ts +19 -19
- package/lib/commands/run.ts +15 -9
- package/lib/commands/schema.ts +1 -3
- package/lib/commands/services/account.ts +234 -0
- package/lib/commands/services/activities.ts +51 -0
- package/lib/commands/services/backups.ts +184 -0
- package/lib/commands/services/health.ts +55 -0
- package/lib/commands/services/projects.ts +1 -1
- package/lib/commands/services/storage.ts +2 -2
- package/lib/commands/types.ts +18 -8
- package/lib/commands/update.ts +24 -16
- package/lib/commands/utils/attributes.ts +6 -6
- package/lib/commands/utils/change-approval.ts +26 -19
- package/lib/commands/utils/database-sync.ts +58 -18
- package/lib/commands/utils/deployment.ts +22 -5
- package/lib/commands/utils/pools.ts +11 -5
- package/lib/config.ts +1 -1
- package/lib/constants.ts +1 -1
- package/lib/emulation/docker.ts +5 -6
- package/lib/emulation/utils.ts +2 -2
- package/lib/json.ts +21 -8
- package/lib/paginate.ts +30 -20
- package/lib/parser.ts +46 -15
- package/lib/questions.ts +38 -38
- package/lib/spinner.ts +5 -1
- package/lib/utils.ts +15 -3
- package/lib/validations.ts +1 -1
- package/package.json +8 -2
- package/scoop/appwrite.config.json +3 -3
- package/dist/lib/commands/services/console.d.ts +0 -3
- package/dist/lib/commands/services/console.d.ts.map +0 -1
- package/docs/examples/console/get-resource.md +0 -5
- package/docs/examples/console/variables.md +0 -3
- package/lib/commands/services/console.ts +0 -49
package/lib/commands/init.ts
CHANGED
|
@@ -31,11 +31,57 @@ import {
|
|
|
31
31
|
} from "../parser.js";
|
|
32
32
|
import { sdkForConsole } from "../sdks.js";
|
|
33
33
|
import { isCloud } from "../utils.js";
|
|
34
|
-
import { Account, UseCases } from "@appwrite.io/console";
|
|
34
|
+
import { Account, UseCases, AppwriteException } from "@appwrite.io/console";
|
|
35
35
|
import { DEFAULT_ENDPOINT, EXECUTABLE_NAME } from "../constants.js";
|
|
36
36
|
|
|
37
|
+
type InitResourceAction = (_options?: unknown) => Promise<void>;
|
|
38
|
+
type ProjectsService = Awaited<ReturnType<typeof getProjectsService>>;
|
|
39
|
+
type ProjectCreateRegion = Parameters<ProjectsService["create"]>[3];
|
|
40
|
+
|
|
41
|
+
interface ExistingProjectSummary {
|
|
42
|
+
$id: string;
|
|
43
|
+
name?: string;
|
|
44
|
+
region?: string;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
interface InitProjectAnswers {
|
|
48
|
+
start: "new" | "existing";
|
|
49
|
+
override?: boolean;
|
|
50
|
+
id?: string;
|
|
51
|
+
project: string | ExistingProjectSummary;
|
|
52
|
+
organization: string;
|
|
53
|
+
region?: ProjectCreateRegion;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
interface InitProjectAutopullAnswer {
|
|
57
|
+
autopull?: boolean;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
interface SiteTemplateFramework {
|
|
61
|
+
providerRootDirectory: string;
|
|
62
|
+
adapter?: string;
|
|
63
|
+
buildRuntime?: string;
|
|
64
|
+
installCommand?: string;
|
|
65
|
+
buildCommand?: string;
|
|
66
|
+
outputDirectory?: string;
|
|
67
|
+
fallbackFile?: string;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
interface SiteTemplateVariable {
|
|
71
|
+
name: string;
|
|
72
|
+
value?: string;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
interface SiteTemplateDetails {
|
|
76
|
+
providerOwner: string;
|
|
77
|
+
providerRepositoryId: string;
|
|
78
|
+
providerVersion: string;
|
|
79
|
+
frameworks: SiteTemplateFramework[];
|
|
80
|
+
variables?: SiteTemplateVariable[];
|
|
81
|
+
}
|
|
82
|
+
|
|
37
83
|
const initResources = async (): Promise<void> => {
|
|
38
|
-
const actions: Record<string,
|
|
84
|
+
const actions: Record<string, InitResourceAction> = {
|
|
39
85
|
function: initFunction,
|
|
40
86
|
site: initSite,
|
|
41
87
|
table: initTable,
|
|
@@ -64,8 +110,6 @@ const initProject = async ({
|
|
|
64
110
|
projectId,
|
|
65
111
|
projectName,
|
|
66
112
|
}: InitProjectOptions = {}): Promise<void> => {
|
|
67
|
-
let response: any = {};
|
|
68
|
-
|
|
69
113
|
try {
|
|
70
114
|
if (globalConfig.getEndpoint() === "" || globalConfig.getCookie() === "") {
|
|
71
115
|
throw new Error(
|
|
@@ -76,14 +120,14 @@ const initProject = async ({
|
|
|
76
120
|
const accountClient = new Account(client);
|
|
77
121
|
|
|
78
122
|
await accountClient.get();
|
|
79
|
-
} catch (
|
|
123
|
+
} catch (_e) {
|
|
80
124
|
error(
|
|
81
125
|
`Error Session not found. Please run '${EXECUTABLE_NAME} login' to create a session`,
|
|
82
126
|
);
|
|
83
127
|
process.exit(1);
|
|
84
128
|
}
|
|
85
129
|
|
|
86
|
-
let answers:
|
|
130
|
+
let answers: InitProjectAnswers;
|
|
87
131
|
|
|
88
132
|
if (!organizationId && !projectId && !projectName) {
|
|
89
133
|
answers = await inquirer.prompt(questionsInitProject);
|
|
@@ -91,26 +135,33 @@ const initProject = async ({
|
|
|
91
135
|
process.exit(1);
|
|
92
136
|
}
|
|
93
137
|
} else {
|
|
94
|
-
|
|
95
|
-
answers.project = {};
|
|
96
|
-
answers.organization = {};
|
|
97
|
-
|
|
98
|
-
answers.organization =
|
|
138
|
+
const selectedOrganization =
|
|
99
139
|
organizationId ??
|
|
100
140
|
(await inquirer.prompt([questionsInitProject[2]])).organization;
|
|
101
|
-
|
|
141
|
+
const selectedProjectName =
|
|
102
142
|
projectName ?? (await inquirer.prompt([questionsInitProject[3]])).project;
|
|
103
|
-
|
|
143
|
+
const selectedProjectId =
|
|
104
144
|
projectId ?? (await inquirer.prompt([questionsInitProject[4]])).id;
|
|
105
145
|
|
|
146
|
+
answers = {
|
|
147
|
+
start: "existing",
|
|
148
|
+
project: selectedProjectId,
|
|
149
|
+
organization: selectedOrganization,
|
|
150
|
+
};
|
|
151
|
+
|
|
106
152
|
try {
|
|
107
153
|
const projectsService = await getProjectsService();
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
answers
|
|
154
|
+
const existingProject: ExistingProjectSummary =
|
|
155
|
+
await projectsService.get(selectedProjectId);
|
|
156
|
+
answers.project = existingProject;
|
|
157
|
+
} catch (e) {
|
|
158
|
+
if (e instanceof AppwriteException && e.code === 404) {
|
|
159
|
+
answers = {
|
|
160
|
+
start: "new",
|
|
161
|
+
id: selectedProjectId,
|
|
162
|
+
project: selectedProjectName,
|
|
163
|
+
organization: selectedOrganization,
|
|
164
|
+
};
|
|
114
165
|
} else {
|
|
115
166
|
throw e;
|
|
116
167
|
}
|
|
@@ -121,10 +172,28 @@ const initProject = async ({
|
|
|
121
172
|
const url = new URL(DEFAULT_ENDPOINT);
|
|
122
173
|
|
|
123
174
|
if (answers.start === "new") {
|
|
175
|
+
let projectIdToCreate;
|
|
176
|
+
let projectNameToCreate;
|
|
177
|
+
|
|
178
|
+
switch (typeof answers.project) {
|
|
179
|
+
case "string":
|
|
180
|
+
projectIdToCreate = answers.id ?? answers.project;
|
|
181
|
+
projectNameToCreate = answers.project;
|
|
182
|
+
break;
|
|
183
|
+
case "object":
|
|
184
|
+
projectIdToCreate = answers.id ?? answers.project.$id;
|
|
185
|
+
projectNameToCreate = answers.project.name ?? answers.project.$id;
|
|
186
|
+
break;
|
|
187
|
+
default:
|
|
188
|
+
projectIdToCreate = answers.id;
|
|
189
|
+
projectNameToCreate = "";
|
|
190
|
+
break;
|
|
191
|
+
}
|
|
192
|
+
|
|
124
193
|
const projectsService = await getProjectsService();
|
|
125
|
-
response = await projectsService.create(
|
|
126
|
-
|
|
127
|
-
|
|
194
|
+
const response = await projectsService.create(
|
|
195
|
+
projectIdToCreate,
|
|
196
|
+
projectNameToCreate,
|
|
128
197
|
answers.organization,
|
|
129
198
|
answers.region,
|
|
130
199
|
);
|
|
@@ -136,10 +205,25 @@ const initProject = async ({
|
|
|
136
205
|
);
|
|
137
206
|
}
|
|
138
207
|
} else {
|
|
139
|
-
|
|
140
|
-
|
|
208
|
+
let selectedProject;
|
|
209
|
+
|
|
210
|
+
switch (typeof answers.project) {
|
|
211
|
+
case "string":
|
|
212
|
+
selectedProject = { $id: answers.project };
|
|
213
|
+
break;
|
|
214
|
+
case "object":
|
|
215
|
+
selectedProject = answers.project;
|
|
216
|
+
break;
|
|
217
|
+
default:
|
|
218
|
+
selectedProject = { $id: "" };
|
|
219
|
+
break;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
localConfig.setProject(selectedProject.$id);
|
|
223
|
+
|
|
224
|
+
if (isCloud() && selectedProject.region) {
|
|
141
225
|
localConfig.setEndpoint(
|
|
142
|
-
`https://${
|
|
226
|
+
`https://${selectedProject.region}.${url.host}${url.pathname}`,
|
|
143
227
|
);
|
|
144
228
|
}
|
|
145
229
|
}
|
|
@@ -149,8 +233,10 @@ const initProject = async ({
|
|
|
149
233
|
);
|
|
150
234
|
|
|
151
235
|
if (answers.start === "existing") {
|
|
152
|
-
|
|
153
|
-
|
|
236
|
+
const autopullAnswers: InitProjectAutopullAnswer = await inquirer.prompt(
|
|
237
|
+
questionsInitProjectAutopull,
|
|
238
|
+
);
|
|
239
|
+
if (autopullAnswers.autopull) {
|
|
154
240
|
cliConfig.all = true;
|
|
155
241
|
cliConfig.force = true;
|
|
156
242
|
await pullResources({
|
|
@@ -322,7 +408,6 @@ const initFunction = async (): Promise<void> => {
|
|
|
322
408
|
fs.mkdirSync(functionDir, { mode: 0o777 });
|
|
323
409
|
fs.mkdirSync(templatesDir, { mode: 0o777 });
|
|
324
410
|
const repo = "https://github.com/appwrite/templates";
|
|
325
|
-
const api = `https://api.github.com/repos/appwrite/templates/contents/${answers.runtime.name}`;
|
|
326
411
|
let selected: { template: string } = { template: "starter" };
|
|
327
412
|
|
|
328
413
|
const sparse = (
|
|
@@ -351,20 +436,21 @@ const initFunction = async (): Promise<void> => {
|
|
|
351
436
|
stdio: "pipe",
|
|
352
437
|
cwd: templatesDir,
|
|
353
438
|
});
|
|
354
|
-
} catch (err
|
|
439
|
+
} catch (err) {
|
|
355
440
|
/* Specialised errors with recommended actions to take */
|
|
356
|
-
|
|
441
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
442
|
+
if (errorMessage.includes("error: unknown option")) {
|
|
357
443
|
throw new Error(
|
|
358
|
-
`${
|
|
444
|
+
`${errorMessage} \n\nSuggestion: Try updating your git to the latest version, then trying to run this command again.`,
|
|
359
445
|
);
|
|
360
446
|
} else if (
|
|
361
|
-
|
|
447
|
+
errorMessage.includes(
|
|
362
448
|
"is not recognized as an internal or external command,",
|
|
363
449
|
) ||
|
|
364
|
-
|
|
450
|
+
errorMessage.includes("command not found")
|
|
365
451
|
) {
|
|
366
452
|
throw new Error(
|
|
367
|
-
`${
|
|
453
|
+
`${errorMessage} \n\nSuggestion: It appears that git is not installed, try installing git then trying to run this command again.`,
|
|
368
454
|
);
|
|
369
455
|
} else {
|
|
370
456
|
throw err;
|
|
@@ -390,9 +476,9 @@ const initFunction = async (): Promise<void> => {
|
|
|
390
476
|
}
|
|
391
477
|
|
|
392
478
|
const copyRecursiveSync = (src: string, dest: string): void => {
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
479
|
+
const exists = fs.existsSync(src);
|
|
480
|
+
const stats = exists && fs.statSync(src);
|
|
481
|
+
const isDirectory = exists && stats && stats.isDirectory();
|
|
396
482
|
if (isDirectory) {
|
|
397
483
|
if (!fs.existsSync(dest)) {
|
|
398
484
|
fs.mkdirSync(dest);
|
|
@@ -424,7 +510,7 @@ const initFunction = async (): Promise<void> => {
|
|
|
424
510
|
newReadmeFile.splice(1, 2);
|
|
425
511
|
fs.writeFileSync(readmePath, newReadmeFile.join("\n"));
|
|
426
512
|
|
|
427
|
-
|
|
513
|
+
const data = {
|
|
428
514
|
$id: functionId,
|
|
429
515
|
name: answers.name,
|
|
430
516
|
runtime: answers.runtime.id,
|
|
@@ -472,7 +558,7 @@ const initSite = async (): Promise<void> => {
|
|
|
472
558
|
);
|
|
473
559
|
}
|
|
474
560
|
|
|
475
|
-
let templateDetails:
|
|
561
|
+
let templateDetails: SiteTemplateDetails;
|
|
476
562
|
try {
|
|
477
563
|
const sitesService = await getSitesService();
|
|
478
564
|
const response = await sitesService.listTemplates(
|
|
@@ -486,16 +572,17 @@ const initSite = async (): Promise<void> => {
|
|
|
486
572
|
);
|
|
487
573
|
}
|
|
488
574
|
templateDetails = response.templates[0];
|
|
489
|
-
} catch (err
|
|
575
|
+
} catch (err) {
|
|
576
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
490
577
|
throw new Error(
|
|
491
|
-
`Failed to fetch template for framework ${answers.framework.key}: ${
|
|
578
|
+
`Failed to fetch template for framework ${answers.framework.key}: ${errorMessage}`,
|
|
492
579
|
);
|
|
493
580
|
}
|
|
494
581
|
|
|
495
582
|
fs.mkdirSync(siteDir, { mode: 0o777 });
|
|
496
583
|
fs.mkdirSync(templatesDir, { mode: 0o777 });
|
|
497
584
|
const repo = `https://github.com/${templateDetails.providerOwner}/${templateDetails.providerRepositoryId}`;
|
|
498
|
-
|
|
585
|
+
const selected = {
|
|
499
586
|
template: templateDetails.frameworks[0].providerRootDirectory,
|
|
500
587
|
};
|
|
501
588
|
|
|
@@ -526,12 +613,12 @@ const initSite = async (): Promise<void> => {
|
|
|
526
613
|
git config remote.origin.tagopt --no-tags
|
|
527
614
|
`.trim();
|
|
528
615
|
}
|
|
529
|
-
|
|
616
|
+
const windowsGitCloneCommands = `
|
|
530
617
|
$tag = (git ls-remote --tags origin "${templateDetails.providerVersion}" | Select-Object -Last 1) -replace '.*refs/tags/', ''
|
|
531
618
|
git fetch --depth=1 origin "refs/tags/$tag"
|
|
532
619
|
git checkout FETCH_HEAD
|
|
533
620
|
`.trim();
|
|
534
|
-
|
|
621
|
+
const unixGitCloneCommands = `
|
|
535
622
|
git fetch --depth=1 origin refs/tags/$(git ls-remote --tags origin "${templateDetails.providerVersion}" | tail -n 1 | awk -F '/' '{print $3}')
|
|
536
623
|
git checkout FETCH_HEAD
|
|
537
624
|
`.trim();
|
|
@@ -551,20 +638,21 @@ const initSite = async (): Promise<void> => {
|
|
|
551
638
|
cwd: templatesDir,
|
|
552
639
|
shell: usedShell,
|
|
553
640
|
});
|
|
554
|
-
} catch (err
|
|
641
|
+
} catch (err) {
|
|
555
642
|
/* Specialised errors with recommended actions to take */
|
|
556
|
-
|
|
643
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
644
|
+
if (errorMessage.includes("error: unknown option")) {
|
|
557
645
|
throw new Error(
|
|
558
|
-
`${
|
|
646
|
+
`${errorMessage} \n\nSuggestion: Try updating your git to the latest version, then trying to run this command again.`,
|
|
559
647
|
);
|
|
560
648
|
} else if (
|
|
561
|
-
|
|
649
|
+
errorMessage.includes(
|
|
562
650
|
"is not recognized as an internal or external command,",
|
|
563
651
|
) ||
|
|
564
|
-
|
|
652
|
+
errorMessage.includes("command not found")
|
|
565
653
|
) {
|
|
566
654
|
throw new Error(
|
|
567
|
-
`${
|
|
655
|
+
`${errorMessage} \n\nSuggestion: It appears that git is not installed, try installing git then trying to run this command again.`,
|
|
568
656
|
);
|
|
569
657
|
} else {
|
|
570
658
|
throw err;
|
|
@@ -590,27 +678,25 @@ const initSite = async (): Promise<void> => {
|
|
|
590
678
|
newReadmeFile.splice(1, 2);
|
|
591
679
|
fs.writeFileSync(readmePath, newReadmeFile.join("\n"));
|
|
592
680
|
|
|
593
|
-
|
|
594
|
-
|
|
681
|
+
const vars: Record<string, string> = {};
|
|
682
|
+
for (const variable of templateDetails.variables ?? []) {
|
|
683
|
+
let value = variable.value ?? "";
|
|
595
684
|
const replacements: Record<string, string> = {
|
|
596
685
|
"{apiEndpoint}": globalConfig.getEndpoint(),
|
|
597
|
-
"{projectId}": localConfig.getProject().projectId,
|
|
598
|
-
"{projectName}": localConfig.getProject().projectName,
|
|
686
|
+
"{projectId}": localConfig.getProject().projectId ?? "",
|
|
687
|
+
"{projectName}": localConfig.getProject().projectName ?? "",
|
|
599
688
|
};
|
|
600
689
|
|
|
601
690
|
for (const placeholder in replacements) {
|
|
602
|
-
if (value
|
|
691
|
+
if (value.includes(placeholder)) {
|
|
603
692
|
value = value.replace(placeholder, replacements[placeholder]);
|
|
604
693
|
}
|
|
605
694
|
}
|
|
606
695
|
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
value: value,
|
|
610
|
-
};
|
|
611
|
-
});
|
|
696
|
+
vars[variable.name] = value;
|
|
697
|
+
}
|
|
612
698
|
|
|
613
|
-
|
|
699
|
+
const data = {
|
|
614
700
|
$id: siteId,
|
|
615
701
|
name: answers.name,
|
|
616
702
|
framework: answers.framework.key,
|
package/lib/commands/pull.ts
CHANGED
package/lib/commands/push.ts
CHANGED
|
@@ -439,7 +439,7 @@ export class Push {
|
|
|
439
439
|
|
|
440
440
|
if (settings.services) {
|
|
441
441
|
this.log("Applying service statuses ...");
|
|
442
|
-
for (
|
|
442
|
+
for (const [service, status] of Object.entries(settings.services)) {
|
|
443
443
|
await projectsService.updateServiceStatus({
|
|
444
444
|
projectId: projectId,
|
|
445
445
|
service: service as ApiService,
|
|
@@ -487,7 +487,7 @@ export class Push {
|
|
|
487
487
|
|
|
488
488
|
if (settings.auth.methods) {
|
|
489
489
|
this.log("Applying auth methods statuses ...");
|
|
490
|
-
for (
|
|
490
|
+
for (const [method, status] of Object.entries(settings.auth.methods)) {
|
|
491
491
|
await projectsService.updateAuthStatus({
|
|
492
492
|
projectId,
|
|
493
493
|
method: method as AuthMethod,
|
|
@@ -861,7 +861,7 @@ export class Push {
|
|
|
861
861
|
([key, value]) => ({ key, value }),
|
|
862
862
|
);
|
|
863
863
|
}
|
|
864
|
-
} catch (
|
|
864
|
+
} catch (_error) {
|
|
865
865
|
envVariables = [];
|
|
866
866
|
}
|
|
867
867
|
await Promise.all(
|
|
@@ -1223,7 +1223,7 @@ export class Push {
|
|
|
1223
1223
|
([key, value]) => ({ key, value }),
|
|
1224
1224
|
);
|
|
1225
1225
|
}
|
|
1226
|
-
} catch (
|
|
1226
|
+
} catch (_error) {
|
|
1227
1227
|
envVariables = [];
|
|
1228
1228
|
}
|
|
1229
1229
|
await Promise.all(
|
|
@@ -1424,7 +1424,7 @@ export class Push {
|
|
|
1424
1424
|
this.projectClient,
|
|
1425
1425
|
);
|
|
1426
1426
|
|
|
1427
|
-
|
|
1427
|
+
const tablesChanged = new Set();
|
|
1428
1428
|
const errors: any[] = [];
|
|
1429
1429
|
|
|
1430
1430
|
// Parallel tables actions
|
|
@@ -1492,7 +1492,7 @@ export class Push {
|
|
|
1492
1492
|
);
|
|
1493
1493
|
|
|
1494
1494
|
// Serialize attribute actions
|
|
1495
|
-
for (
|
|
1495
|
+
for (const table of tables) {
|
|
1496
1496
|
let columns = table.columns;
|
|
1497
1497
|
let indexes = table.indexes;
|
|
1498
1498
|
let hadChanges = false;
|
|
@@ -1843,7 +1843,7 @@ const pushSettings = async (): Promise<void> => {
|
|
|
1843
1843
|
|
|
1844
1844
|
try {
|
|
1845
1845
|
const projectsService = await getProjectsService();
|
|
1846
|
-
|
|
1846
|
+
const response = await projectsService.get(
|
|
1847
1847
|
localConfig.getProject().projectId,
|
|
1848
1848
|
);
|
|
1849
1849
|
|
|
@@ -1880,7 +1880,7 @@ const pushSettings = async (): Promise<void> => {
|
|
|
1880
1880
|
return;
|
|
1881
1881
|
}
|
|
1882
1882
|
}
|
|
1883
|
-
} catch (
|
|
1883
|
+
} catch (_e) {}
|
|
1884
1884
|
|
|
1885
1885
|
try {
|
|
1886
1886
|
log("Pushing project settings ...");
|
|
@@ -1939,7 +1939,7 @@ const pushSite = async ({
|
|
|
1939
1939
|
return;
|
|
1940
1940
|
}
|
|
1941
1941
|
|
|
1942
|
-
|
|
1942
|
+
const sites = siteIds.map((id: string) => {
|
|
1943
1943
|
const sites = localConfig.getSites();
|
|
1944
1944
|
const site = sites.find((s: any) => s.$id === id);
|
|
1945
1945
|
|
|
@@ -1952,7 +1952,7 @@ const pushSite = async ({
|
|
|
1952
1952
|
|
|
1953
1953
|
log("Validating sites ...");
|
|
1954
1954
|
// Validation is done BEFORE pushing so the deployment process can be run in async with progress update
|
|
1955
|
-
for (
|
|
1955
|
+
for (const site of sites) {
|
|
1956
1956
|
if (!site.buildCommand) {
|
|
1957
1957
|
log(`Site ${site.name} is missing build command.`);
|
|
1958
1958
|
const answers = await inquirer.prompt(questionsGetEntrypoint);
|
|
@@ -2081,7 +2081,7 @@ const pushFunction = async ({
|
|
|
2081
2081
|
return;
|
|
2082
2082
|
}
|
|
2083
2083
|
|
|
2084
|
-
|
|
2084
|
+
const functions = functionIds.map((id: string) => {
|
|
2085
2085
|
const functions = localConfig.getFunctions();
|
|
2086
2086
|
const func = functions.find((f: any) => f.$id === id);
|
|
2087
2087
|
|
|
@@ -2093,7 +2093,7 @@ const pushFunction = async ({
|
|
|
2093
2093
|
});
|
|
2094
2094
|
|
|
2095
2095
|
log("Validating functions ...");
|
|
2096
|
-
for (
|
|
2096
|
+
for (const func of functions) {
|
|
2097
2097
|
if (!func.entrypoint) {
|
|
2098
2098
|
log(`Function ${func.name} is missing an entrypoint.`);
|
|
2099
2099
|
const answers = await inquirer.prompt(questionsGetEntrypoint);
|
|
@@ -2258,7 +2258,7 @@ const pushTable = async ({
|
|
|
2258
2258
|
});
|
|
2259
2259
|
}
|
|
2260
2260
|
}
|
|
2261
|
-
} catch (
|
|
2261
|
+
} catch (_e) {
|
|
2262
2262
|
// Skip if database doesn't exist or other errors
|
|
2263
2263
|
}
|
|
2264
2264
|
}
|
|
@@ -2432,7 +2432,7 @@ const pushCollection = async (): Promise<void> => {
|
|
|
2432
2432
|
};
|
|
2433
2433
|
|
|
2434
2434
|
const pushBucket = async (): Promise<void> => {
|
|
2435
|
-
|
|
2435
|
+
const bucketIds: string[] = [];
|
|
2436
2436
|
const configBuckets = localConfig.getBuckets();
|
|
2437
2437
|
|
|
2438
2438
|
if (cliConfig.all) {
|
|
@@ -2455,7 +2455,7 @@ const pushBucket = async (): Promise<void> => {
|
|
|
2455
2455
|
return;
|
|
2456
2456
|
}
|
|
2457
2457
|
|
|
2458
|
-
|
|
2458
|
+
const buckets: any[] = [];
|
|
2459
2459
|
|
|
2460
2460
|
for (const bucketId of bucketIds) {
|
|
2461
2461
|
const idBuckets = configBuckets.filter((b: any) => b.$id === bucketId);
|
|
@@ -2496,7 +2496,7 @@ const pushBucket = async (): Promise<void> => {
|
|
|
2496
2496
|
};
|
|
2497
2497
|
|
|
2498
2498
|
const pushTeam = async (): Promise<void> => {
|
|
2499
|
-
|
|
2499
|
+
const teamIds: string[] = [];
|
|
2500
2500
|
const configTeams = localConfig.getTeams();
|
|
2501
2501
|
|
|
2502
2502
|
if (cliConfig.all) {
|
|
@@ -2519,7 +2519,7 @@ const pushTeam = async (): Promise<void> => {
|
|
|
2519
2519
|
return;
|
|
2520
2520
|
}
|
|
2521
2521
|
|
|
2522
|
-
|
|
2522
|
+
const teams: any[] = [];
|
|
2523
2523
|
|
|
2524
2524
|
for (const teamId of teamIds) {
|
|
2525
2525
|
const idTeams = configTeams.filter((t: any) => t.$id === teamId);
|
|
@@ -2560,7 +2560,7 @@ const pushTeam = async (): Promise<void> => {
|
|
|
2560
2560
|
};
|
|
2561
2561
|
|
|
2562
2562
|
const pushMessagingTopic = async (): Promise<void> => {
|
|
2563
|
-
|
|
2563
|
+
const topicsIds: string[] = [];
|
|
2564
2564
|
const configTopics = localConfig.getMessagingTopics();
|
|
2565
2565
|
|
|
2566
2566
|
if (cliConfig.all) {
|
|
@@ -2583,7 +2583,7 @@ const pushMessagingTopic = async (): Promise<void> => {
|
|
|
2583
2583
|
return;
|
|
2584
2584
|
}
|
|
2585
2585
|
|
|
2586
|
-
|
|
2586
|
+
const topics: any[] = [];
|
|
2587
2587
|
|
|
2588
2588
|
for (const topicId of topicsIds) {
|
|
2589
2589
|
const idTopic = configTopics.filter((b: any) => b.$id === topicId);
|
package/lib/commands/run.ts
CHANGED
|
@@ -3,7 +3,8 @@ import { parse as parseDotenv } from "dotenv";
|
|
|
3
3
|
import chalk from "chalk";
|
|
4
4
|
import ignoreModule from "ignore";
|
|
5
5
|
const ignore: typeof ignoreModule =
|
|
6
|
-
(ignoreModule as
|
|
6
|
+
(ignoreModule as unknown as { default?: typeof ignoreModule }).default ??
|
|
7
|
+
ignoreModule;
|
|
7
8
|
import tar from "tar";
|
|
8
9
|
import fs from "fs";
|
|
9
10
|
import chokidar from "chokidar";
|
|
@@ -24,7 +25,12 @@ import {
|
|
|
24
25
|
commandDescriptions,
|
|
25
26
|
drawTable,
|
|
26
27
|
} from "../parser.js";
|
|
27
|
-
import {
|
|
28
|
+
import {
|
|
29
|
+
systemHasCommand,
|
|
30
|
+
isPortTaken,
|
|
31
|
+
getAllFiles,
|
|
32
|
+
getErrorMessage,
|
|
33
|
+
} from "../utils.js";
|
|
28
34
|
import {
|
|
29
35
|
runtimeNames,
|
|
30
36
|
systemTools,
|
|
@@ -62,7 +68,7 @@ const runFunction = async ({
|
|
|
62
68
|
}
|
|
63
69
|
|
|
64
70
|
const functions = localConfig.getFunctions();
|
|
65
|
-
const func = functions.find((f
|
|
71
|
+
const func = functions.find((f) => f.$id === functionId);
|
|
66
72
|
if (!func) {
|
|
67
73
|
throw new Error("Function '" + functionId + "' not found.");
|
|
68
74
|
}
|
|
@@ -178,14 +184,14 @@ const runFunction = async ({
|
|
|
178
184
|
"variables",
|
|
179
185
|
);
|
|
180
186
|
|
|
181
|
-
remoteVariables.forEach((v
|
|
187
|
+
remoteVariables.forEach((v) => {
|
|
182
188
|
allVariables[v.key] = v.value;
|
|
183
189
|
userVariables[v.key] = v.value;
|
|
184
190
|
});
|
|
185
|
-
} catch (err:
|
|
191
|
+
} catch (err: unknown) {
|
|
186
192
|
warn(
|
|
187
193
|
"Remote variables not fetched. Production environment variables will not be available. Reason: " +
|
|
188
|
-
err
|
|
194
|
+
getErrorMessage(err),
|
|
189
195
|
);
|
|
190
196
|
}
|
|
191
197
|
}
|
|
@@ -214,10 +220,10 @@ const runFunction = async ({
|
|
|
214
220
|
|
|
215
221
|
try {
|
|
216
222
|
await JwtManager.setup(userId, (func.scopes as Scopes[]) ?? []);
|
|
217
|
-
} catch (err:
|
|
223
|
+
} catch (err: unknown) {
|
|
218
224
|
warn(
|
|
219
225
|
"Dynamic API key not generated. Header x-appwrite-key will not be set. Reason: " +
|
|
220
|
-
err
|
|
226
|
+
getErrorMessage(err),
|
|
221
227
|
);
|
|
222
228
|
}
|
|
223
229
|
|
|
@@ -394,7 +400,7 @@ export const run = new Command("run")
|
|
|
394
400
|
helpWidth: process.stdout.columns || 80,
|
|
395
401
|
})
|
|
396
402
|
.action(
|
|
397
|
-
actionRunner(async (_options:
|
|
403
|
+
actionRunner(async (_options: unknown, command: Command) => {
|
|
398
404
|
command.help();
|
|
399
405
|
}),
|
|
400
406
|
);
|
package/lib/commands/schema.ts
CHANGED
|
@@ -4,13 +4,11 @@ import { ConfigSchema } from "./config.js";
|
|
|
4
4
|
import { Pull, PullOptions } from "./pull.js";
|
|
5
5
|
import { Push, PushOptions } from "./push.js";
|
|
6
6
|
import { parseWithBetterErrors } from "./utils/error-formatter.js";
|
|
7
|
-
import
|
|
7
|
+
import { JSONBig } from "../json.js";
|
|
8
8
|
import * as fs from "fs";
|
|
9
9
|
import * as path from "path";
|
|
10
10
|
import { TypeScriptDatabasesGenerator } from "./generators/typescript/databases.js";
|
|
11
11
|
|
|
12
|
-
const JSONBig = JSONbig({ useNativeBigInt: true });
|
|
13
|
-
|
|
14
12
|
export class Schema {
|
|
15
13
|
private pullCommand: Pull;
|
|
16
14
|
private pushCommand: Push;
|