appwrite-cli 12.0.0 → 13.0.0-rc.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 +8 -0
- package/README.md +2 -2
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +145 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/client.d.ts +89 -0
- package/dist/lib/client.d.ts.map +1 -0
- package/dist/lib/client.js +227 -0
- package/dist/lib/client.js.map +1 -0
- package/dist/lib/commands/account.d.ts +379 -0
- package/dist/lib/commands/account.d.ts.map +1 -0
- package/dist/lib/commands/account.js +1228 -0
- package/dist/lib/commands/account.js.map +1 -0
- package/dist/lib/commands/console.d.ts +20 -0
- package/dist/lib/commands/console.d.ts.map +1 -0
- package/dist/lib/commands/console.js +78 -0
- package/dist/lib/commands/console.js.map +1 -0
- package/dist/lib/commands/databases.d.ts +732 -0
- package/dist/lib/commands/databases.d.ts.map +1 -0
- package/dist/lib/commands/databases.js +2196 -0
- package/dist/lib/commands/databases.js.map +1 -0
- package/dist/lib/commands/functions.d.ts +310 -0
- package/dist/lib/commands/functions.d.ts.map +1 -0
- package/dist/lib/commands/functions.js +1100 -0
- package/dist/lib/commands/functions.js.map +1 -0
- package/dist/lib/commands/generic.d.ts +17 -0
- package/dist/lib/commands/generic.d.ts.map +1 -0
- package/dist/lib/commands/generic.js +279 -0
- package/dist/lib/commands/generic.js.map +1 -0
- package/dist/lib/commands/graphql.d.ts +19 -0
- package/dist/lib/commands/graphql.d.ts.map +1 -0
- package/dist/lib/commands/graphql.js +77 -0
- package/dist/lib/commands/graphql.js.map +1 -0
- package/dist/lib/commands/health.d.ts +153 -0
- package/dist/lib/commands/health.d.ts.map +1 -0
- package/dist/lib/commands/health.js +464 -0
- package/dist/lib/commands/health.js.map +1 -0
- package/dist/lib/commands/init.d.ts +3 -0
- package/dist/lib/commands/init.d.ts.map +1 -0
- package/dist/lib/commands/init.js +518 -0
- package/dist/lib/commands/init.js.map +1 -0
- package/dist/lib/commands/locale.d.ts +53 -0
- package/dist/lib/commands/locale.d.ts.map +1 -0
- package/dist/lib/commands/locale.js +165 -0
- package/dist/lib/commands/locale.js.map +1 -0
- package/dist/lib/commands/messaging.d.ts +588 -0
- package/dist/lib/commands/messaging.d.ts.map +1 -0
- package/dist/lib/commands/messaging.js +2042 -0
- package/dist/lib/commands/messaging.js.map +1 -0
- package/dist/lib/commands/migrations.d.ts +150 -0
- package/dist/lib/commands/migrations.d.ts.map +1 -0
- package/dist/lib/commands/migrations.js +524 -0
- package/dist/lib/commands/migrations.js.map +1 -0
- package/dist/lib/commands/organizations.d.ts +11 -0
- package/dist/lib/commands/organizations.d.ts.map +1 -0
- package/dist/lib/commands/organizations.js +31 -0
- package/dist/lib/commands/organizations.js.map +1 -0
- package/dist/lib/commands/project.d.ts +53 -0
- package/dist/lib/commands/project.d.ts.map +1 -0
- package/dist/lib/commands/project.js +176 -0
- package/dist/lib/commands/project.js.map +1 -0
- package/dist/lib/commands/projects.d.ts +516 -0
- package/dist/lib/commands/projects.d.ts.map +1 -0
- package/dist/lib/commands/projects.js +1590 -0
- package/dist/lib/commands/projects.js.map +1 -0
- package/dist/lib/commands/proxy.d.ts +71 -0
- package/dist/lib/commands/proxy.d.ts.map +1 -0
- package/dist/lib/commands/proxy.js +240 -0
- package/dist/lib/commands/proxy.js.map +1 -0
- package/dist/lib/commands/pull.d.ts +8 -0
- package/dist/lib/commands/pull.d.ts.map +1 -0
- package/dist/lib/commands/pull.js +455 -0
- package/dist/lib/commands/pull.js.map +1 -0
- package/dist/lib/commands/push.d.ts +4 -0
- package/dist/lib/commands/push.d.ts.map +1 -0
- package/dist/lib/commands/push.js +2154 -0
- package/dist/lib/commands/push.js.map +1 -0
- package/dist/lib/commands/run.d.ts +3 -0
- package/dist/lib/commands/run.d.ts.map +1 -0
- package/dist/lib/commands/run.js +287 -0
- package/dist/lib/commands/run.js.map +1 -0
- package/dist/lib/commands/sites.d.ts +296 -0
- package/dist/lib/commands/sites.d.ts.map +1 -0
- package/dist/lib/commands/sites.js +1046 -0
- package/dist/lib/commands/sites.js.map +1 -0
- package/dist/lib/commands/storage.d.ts +170 -0
- package/dist/lib/commands/storage.d.ts.map +1 -0
- package/dist/lib/commands/storage.js +651 -0
- package/dist/lib/commands/storage.js.map +1 -0
- package/dist/lib/commands/tables-db.d.ts +728 -0
- package/dist/lib/commands/tables-db.d.ts.map +1 -0
- package/dist/lib/commands/tables-db.js +2198 -0
- package/dist/lib/commands/tables-db.js.map +1 -0
- package/dist/lib/commands/teams.d.ts +129 -0
- package/dist/lib/commands/teams.d.ts.map +1 -0
- package/dist/lib/commands/teams.js +403 -0
- package/dist/lib/commands/teams.js.map +1 -0
- package/dist/lib/commands/tokens.d.ts +48 -0
- package/dist/lib/commands/tokens.d.ts.map +1 -0
- package/dist/lib/commands/tokens.js +156 -0
- package/dist/lib/commands/tokens.js.map +1 -0
- package/dist/lib/commands/types.d.ts +3 -0
- package/dist/lib/commands/types.d.ts.map +1 -0
- package/dist/lib/commands/types.js +155 -0
- package/dist/lib/commands/types.js.map +1 -0
- package/dist/lib/commands/update.d.ts +3 -0
- package/dist/lib/commands/update.d.ts.map +1 -0
- package/dist/lib/commands/update.js +202 -0
- package/dist/lib/commands/update.js.map +1 -0
- package/dist/lib/commands/users.d.ts +382 -0
- package/dist/lib/commands/users.d.ts.map +1 -0
- package/dist/lib/commands/users.js +1195 -0
- package/dist/lib/commands/users.js.map +1 -0
- package/dist/lib/commands/vcs.d.ts +92 -0
- package/dist/lib/commands/vcs.d.ts.map +1 -0
- package/dist/lib/commands/vcs.js +276 -0
- package/dist/lib/commands/vcs.js.map +1 -0
- package/dist/lib/config.d.ts +118 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/{lib → dist/lib}/config.js +204 -325
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/emulation/docker.d.ts +15 -0
- package/dist/lib/emulation/docker.d.ts.map +1 -0
- package/dist/lib/emulation/docker.js +220 -0
- package/dist/lib/emulation/docker.js.map +1 -0
- package/dist/lib/emulation/utils.d.ts +29 -0
- package/dist/lib/emulation/utils.d.ts.map +1 -0
- package/dist/lib/emulation/utils.js +168 -0
- package/dist/lib/emulation/utils.js.map +1 -0
- package/dist/lib/exception.d.ts +8 -0
- package/dist/lib/exception.d.ts.map +1 -0
- package/dist/lib/exception.js +16 -0
- package/dist/lib/exception.js.map +1 -0
- package/dist/lib/id.d.ts +7 -0
- package/dist/lib/id.d.ts.map +1 -0
- package/dist/lib/id.js +32 -0
- package/dist/lib/id.js.map +1 -0
- package/dist/lib/paginate.d.ts +10 -0
- package/dist/lib/paginate.d.ts.map +1 -0
- package/{lib → dist/lib}/paginate.js +9 -15
- package/dist/lib/paginate.js.map +1 -0
- package/dist/lib/parser.d.ts +18 -0
- package/dist/lib/parser.d.ts.map +1 -0
- package/dist/lib/parser.js +237 -0
- package/dist/lib/parser.js.map +1 -0
- package/dist/lib/questions.d.ts +59 -0
- package/dist/lib/questions.d.ts.map +1 -0
- package/dist/lib/questions.js +995 -0
- package/dist/lib/questions.js.map +1 -0
- package/dist/lib/sdks.d.ts +4 -0
- package/dist/lib/sdks.d.ts.map +1 -0
- package/dist/lib/sdks.js +51 -0
- package/dist/lib/sdks.js.map +1 -0
- package/dist/lib/spinner.d.ts +28 -0
- package/dist/lib/spinner.d.ts.map +1 -0
- package/{lib → dist/lib}/spinner.js +34 -45
- package/dist/lib/spinner.js.map +1 -0
- package/dist/lib/type-generation/attribute.d.ts +17 -0
- package/dist/lib/type-generation/attribute.d.ts.map +1 -0
- package/dist/lib/type-generation/attribute.js +19 -0
- package/dist/lib/type-generation/attribute.js.map +1 -0
- package/dist/lib/type-generation/languages/csharp.d.ts +7 -0
- package/dist/lib/type-generation/languages/csharp.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/csharp.js +180 -0
- package/dist/lib/type-generation/languages/csharp.js.map +1 -0
- package/dist/lib/type-generation/languages/dart.d.ts +8 -0
- package/dist/lib/type-generation/languages/dart.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/dart.js +197 -0
- package/dist/lib/type-generation/languages/dart.js.map +1 -0
- package/dist/lib/type-generation/languages/java.d.ts +7 -0
- package/dist/lib/type-generation/languages/java.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/java.js +140 -0
- package/dist/lib/type-generation/languages/java.js.map +1 -0
- package/dist/lib/type-generation/languages/javascript.d.ts +9 -0
- package/dist/lib/type-generation/languages/javascript.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/javascript.js +108 -0
- package/dist/lib/type-generation/languages/javascript.js.map +1 -0
- package/dist/lib/type-generation/languages/kotlin.d.ts +7 -0
- package/dist/lib/type-generation/languages/kotlin.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/kotlin.js +95 -0
- package/dist/lib/type-generation/languages/kotlin.js.map +1 -0
- package/dist/lib/type-generation/languages/language.d.ts +43 -0
- package/dist/lib/type-generation/languages/language.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/language.js +82 -0
- package/dist/lib/type-generation/languages/language.js.map +1 -0
- package/dist/lib/type-generation/languages/php.d.ts +7 -0
- package/dist/lib/type-generation/languages/php.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/php.js +116 -0
- package/dist/lib/type-generation/languages/php.js.map +1 -0
- package/dist/lib/type-generation/languages/swift.d.ts +7 -0
- package/dist/lib/type-generation/languages/swift.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/swift.js +179 -0
- package/dist/lib/type-generation/languages/swift.js.map +1 -0
- package/dist/lib/type-generation/languages/typescript.d.ts +9 -0
- package/dist/lib/type-generation/languages/typescript.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/typescript.js +112 -0
- package/dist/lib/type-generation/languages/typescript.js.map +1 -0
- package/dist/lib/types.d.ts +133 -0
- package/dist/lib/types.d.ts.map +1 -0
- package/dist/lib/types.js +3 -0
- package/dist/lib/types.js.map +1 -0
- package/dist/lib/utils.d.ts +15 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/{lib → dist/lib}/utils.js +74 -120
- package/dist/lib/utils.js.map +1 -0
- package/dist/lib/validations.d.ts +2 -0
- package/dist/lib/validations.d.ts.map +1 -0
- package/dist/lib/validations.js +20 -0
- package/dist/lib/validations.js.map +1 -0
- package/docs/examples/databases/upsert-document.md +1 -2
- package/index.ts +152 -0
- package/install.ps1 +2 -5
- package/install.sh +1 -2
- package/lib/client.ts +259 -0
- package/lib/commands/{account.js → account.ts} +410 -664
- package/lib/commands/console.ts +112 -0
- package/lib/commands/{databases.js → databases.ts} +818 -1136
- package/lib/commands/{functions.js → functions.ts} +381 -526
- package/lib/commands/{generic.js → generic.ts} +47 -39
- package/lib/commands/graphql.ts +110 -0
- package/lib/commands/{health.js → health.ts} +168 -284
- package/lib/commands/{init.js → init.ts} +68 -66
- package/lib/commands/{locale.js → locale.ts} +75 -121
- package/lib/commands/{messaging.js → messaging.ts} +699 -937
- package/lib/commands/{migrations.js → migrations.ts} +182 -258
- package/lib/commands/organizations.ts +46 -0
- package/lib/commands/{project.js → project.ts} +75 -111
- package/lib/commands/{projects.js → projects.ts} +587 -843
- package/lib/commands/{proxy.js → proxy.ts} +94 -140
- package/lib/commands/{pull.js → pull.ts} +54 -44
- package/lib/commands/{push.js → push.ts} +235 -191
- package/lib/commands/{run.js → run.ts} +61 -55
- package/lib/commands/{sites.js → sites.ts} +364 -504
- package/lib/commands/{storage.js → storage.ts} +216 -292
- package/lib/commands/{tables-db.js → tables-db.ts} +817 -1126
- package/lib/commands/{teams.js → teams.ts} +162 -236
- package/lib/commands/{tokens.js → tokens.ts} +70 -99
- package/lib/commands/{types.js → types.ts} +37 -35
- package/lib/commands/{update.js → update.ts} +25 -27
- package/lib/commands/{users.js → users.ts} +426 -644
- package/lib/commands/{vcs.js → vcs.ts} +122 -173
- package/lib/config.ts +854 -0
- package/lib/emulation/{docker.js → docker.ts} +39 -38
- package/lib/emulation/utils.ts +193 -0
- package/lib/exception.ts +20 -0
- package/lib/{id.js → id.ts} +5 -5
- package/lib/paginate.ts +63 -0
- package/lib/parser.ts +238 -0
- package/lib/{questions.js → questions.ts} +148 -156
- package/lib/sdks.ts +55 -0
- package/lib/spinner.ts +118 -0
- package/lib/type-generation/attribute.ts +17 -0
- package/lib/type-generation/languages/{csharp.js → csharp.ts} +59 -48
- package/lib/type-generation/languages/{dart.js → dart.ts} +91 -80
- package/lib/type-generation/languages/{java.js → java.ts} +58 -47
- package/lib/type-generation/languages/javascript.ts +111 -0
- package/lib/type-generation/languages/kotlin.ts +96 -0
- package/lib/type-generation/languages/language.ts +119 -0
- package/lib/type-generation/languages/{php.js → php.ts} +55 -48
- package/lib/type-generation/languages/{swift.js → swift.ts} +59 -48
- package/lib/type-generation/languages/typescript.ts +116 -0
- package/lib/types.ts +150 -0
- package/lib/utils.ts +322 -0
- package/lib/validations.ts +17 -0
- package/package.json +21 -12
- package/scoop/appwrite.config.json +3 -3
- package/tsconfig.json +30 -0
- package/index.js +0 -147
- package/lib/client.js +0 -254
- package/lib/commands/console.js +0 -127
- package/lib/commands/graphql.js +0 -126
- package/lib/commands/organizations.js +0 -48
- package/lib/emulation/utils.js +0 -186
- package/lib/exception.js +0 -9
- package/lib/parser.js +0 -250
- package/lib/sdks.js +0 -60
- package/lib/type-generation/attribute.js +0 -16
- package/lib/type-generation/languages/javascript.js +0 -102
- package/lib/type-generation/languages/kotlin.js +0 -85
- package/lib/type-generation/languages/language.js +0 -125
- package/lib/type-generation/languages/typescript.js +0 -107
- package/lib/validations.js +0 -17
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const {
|
|
1
|
+
import fs = require('fs');
|
|
2
|
+
import path = require('path');
|
|
3
|
+
import childProcess = require('child_process');
|
|
4
|
+
import { Command } from 'commander';
|
|
5
|
+
import inquirer from 'inquirer';
|
|
6
|
+
import { projectsCreate, projectsGet } from './projects';
|
|
7
|
+
import { storageCreateBucket } from './storage';
|
|
8
|
+
import { messagingCreateTopic } from './messaging';
|
|
9
|
+
import { functionsCreate } from './functions';
|
|
10
|
+
import { databasesCreateCollection } from './databases';
|
|
11
|
+
import { pullResources } from './pull';
|
|
12
|
+
import ID from '../id';
|
|
13
|
+
import { localConfig, globalConfig } from '../config';
|
|
14
|
+
import {
|
|
16
15
|
questionsCreateFunction,
|
|
17
16
|
questionsCreateFunctionSelectTemplate,
|
|
18
17
|
questionsCreateSite,
|
|
@@ -24,15 +23,15 @@ const {
|
|
|
24
23
|
questionsInitProjectAutopull,
|
|
25
24
|
questionsInitResources,
|
|
26
25
|
questionsCreateTeam
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const initResources = async () => {
|
|
35
|
-
const actions = {
|
|
26
|
+
} from '../questions';
|
|
27
|
+
import { cliConfig, success, log, hint, error, actionRunner, commandDescriptions } from '../parser';
|
|
28
|
+
import { accountGet } from './account';
|
|
29
|
+
import { sitesListTemplates } from './sites';
|
|
30
|
+
import { sdkForConsole } from '../sdks';
|
|
31
|
+
import { isCloud } from '../utils';
|
|
32
|
+
|
|
33
|
+
const initResources = async (): Promise<void> => {
|
|
34
|
+
const actions: Record<string, (options?: any) => Promise<void>> = {
|
|
36
35
|
function: initFunction,
|
|
37
36
|
site: initSite,
|
|
38
37
|
table: initTable,
|
|
@@ -50,8 +49,14 @@ const initResources = async () => {
|
|
|
50
49
|
}
|
|
51
50
|
};
|
|
52
51
|
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
interface InitProjectOptions {
|
|
53
|
+
organizationId?: string;
|
|
54
|
+
projectId?: string;
|
|
55
|
+
projectName?: string;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const initProject = async ({ organizationId, projectId, projectName }: InitProjectOptions = {}): Promise<void> => {
|
|
59
|
+
let response: any = {};
|
|
55
60
|
|
|
56
61
|
try {
|
|
57
62
|
if (globalConfig.getEndpoint() === '' || globalConfig.getCookie() === '') {
|
|
@@ -68,7 +73,7 @@ const initProject = async ({ organizationId, projectId, projectName } = {}) => {
|
|
|
68
73
|
process.exit(1);
|
|
69
74
|
}
|
|
70
75
|
|
|
71
|
-
let answers = {};
|
|
76
|
+
let answers: any = {};
|
|
72
77
|
|
|
73
78
|
if (!organizationId && !projectId && !projectName) {
|
|
74
79
|
answers = await inquirer.prompt(questionsInitProject)
|
|
@@ -86,7 +91,7 @@ const initProject = async ({ organizationId, projectId, projectName } = {}) => {
|
|
|
86
91
|
|
|
87
92
|
try {
|
|
88
93
|
await projectsGet({ projectId, parseOutput: false });
|
|
89
|
-
} catch (e) {
|
|
94
|
+
} catch (e: any) {
|
|
90
95
|
if (e.code === 404) {
|
|
91
96
|
answers.start = 'new';
|
|
92
97
|
answers.id = answers.project;
|
|
@@ -137,7 +142,7 @@ const initProject = async ({ organizationId, projectId, projectName } = {}) => {
|
|
|
137
142
|
hint("Next you can use 'appwrite init' to create resources in your project, or use 'appwrite pull' and 'appwrite push' to synchronize your project.")
|
|
138
143
|
}
|
|
139
144
|
|
|
140
|
-
const initBucket = async () => {
|
|
145
|
+
const initBucket = async (): Promise<void> => {
|
|
141
146
|
const answers = await inquirer.prompt(questionsCreateBucket)
|
|
142
147
|
|
|
143
148
|
localConfig.addBucket({
|
|
@@ -150,7 +155,7 @@ const initBucket = async () => {
|
|
|
150
155
|
log("Next you can use 'appwrite push bucket' to deploy the changes.");
|
|
151
156
|
};
|
|
152
157
|
|
|
153
|
-
const initTeam = async () => {
|
|
158
|
+
const initTeam = async (): Promise<void> => {
|
|
154
159
|
const answers = await inquirer.prompt(questionsCreateTeam)
|
|
155
160
|
|
|
156
161
|
localConfig.addTeam({
|
|
@@ -162,7 +167,7 @@ const initTeam = async () => {
|
|
|
162
167
|
log("Next you can use 'appwrite push team' to deploy the changes.");
|
|
163
168
|
};
|
|
164
169
|
|
|
165
|
-
const initTable = async () => {
|
|
170
|
+
const initTable = async (): Promise<void> => {
|
|
166
171
|
const answers = await inquirer.prompt(questionsCreateTable)
|
|
167
172
|
const newDatabase = (answers.method ?? '').toLowerCase() !== 'existing';
|
|
168
173
|
|
|
@@ -196,7 +201,7 @@ const initTable = async () => {
|
|
|
196
201
|
log("Next you can use 'appwrite push table' to deploy the changes.");
|
|
197
202
|
};
|
|
198
203
|
|
|
199
|
-
const initCollection = async () => {
|
|
204
|
+
const initCollection = async (): Promise<void> => {
|
|
200
205
|
const answers = await inquirer.prompt(questionsCreateCollection)
|
|
201
206
|
const newDatabase = (answers.method ?? '').toLowerCase() !== 'existing';
|
|
202
207
|
|
|
@@ -229,7 +234,7 @@ const initCollection = async () => {
|
|
|
229
234
|
log("Next you can use 'appwrite push collection' to deploy the changes.");
|
|
230
235
|
};
|
|
231
236
|
|
|
232
|
-
const initTopic = async () => {
|
|
237
|
+
const initTopic = async (): Promise<void> => {
|
|
233
238
|
const answers = await inquirer.prompt(questionsCreateMessagingTopic)
|
|
234
239
|
|
|
235
240
|
localConfig.addMessagingTopic({
|
|
@@ -242,7 +247,7 @@ const initTopic = async () => {
|
|
|
242
247
|
log("Next you can use 'appwrite push topic' to deploy the changes.");
|
|
243
248
|
};
|
|
244
249
|
|
|
245
|
-
const initFunction = async () => {
|
|
250
|
+
const initFunction = async (): Promise<void> => {
|
|
246
251
|
process.chdir(localConfig.configDirectoryPath)
|
|
247
252
|
|
|
248
253
|
// TODO: Add CI/CD support (ID, name, runtime)
|
|
@@ -273,11 +278,11 @@ const initFunction = async () => {
|
|
|
273
278
|
log(`Installation command for this runtime not found. You will be asked to configure the install command when you first push the function.`);
|
|
274
279
|
}
|
|
275
280
|
|
|
276
|
-
fs.mkdirSync(functionDir,
|
|
277
|
-
fs.mkdirSync(templatesDir,
|
|
281
|
+
fs.mkdirSync(functionDir, { mode: 0o777 });
|
|
282
|
+
fs.mkdirSync(templatesDir, { mode: 0o777 });
|
|
278
283
|
const repo = "https://github.com/appwrite/templates";
|
|
279
284
|
const api = `https://api.github.com/repos/appwrite/templates/contents/${answers.runtime.name}`
|
|
280
|
-
let selected = { template: 'starter' };
|
|
285
|
+
let selected: { template: string } = { template: 'starter' };
|
|
281
286
|
|
|
282
287
|
const sparse = (selected ? `${answers.runtime.name}/${selected.template}` : answers.runtime.name).toLowerCase();
|
|
283
288
|
|
|
@@ -295,20 +300,20 @@ const initFunction = async () => {
|
|
|
295
300
|
try {
|
|
296
301
|
childProcess.execSync(gitInitCommands, { stdio: 'pipe', cwd: templatesDir });
|
|
297
302
|
childProcess.execSync(gitPullCommands, { stdio: 'pipe', cwd: templatesDir });
|
|
298
|
-
} catch (
|
|
303
|
+
} catch (err: any) {
|
|
299
304
|
/* Specialised errors with recommended actions to take */
|
|
300
|
-
if (
|
|
301
|
-
throw new Error(`${
|
|
302
|
-
} else if (
|
|
303
|
-
throw new Error(`${
|
|
305
|
+
if (err.message.includes('error: unknown option')) {
|
|
306
|
+
throw new Error(`${err.message} \n\nSuggestion: Try updating your git to the latest version, then trying to run this command again.`)
|
|
307
|
+
} else if (err.message.includes('is not recognized as an internal or external command,') || err.message.includes('command not found')) {
|
|
308
|
+
throw new Error(`${err.message} \n\nSuggestion: It appears that git is not installed, try installing git then trying to run this command again.`)
|
|
304
309
|
} else {
|
|
305
|
-
throw
|
|
310
|
+
throw err;
|
|
306
311
|
}
|
|
307
312
|
}
|
|
308
313
|
|
|
309
314
|
fs.rmSync(path.join(templatesDir, ".git"), { recursive: true });
|
|
310
315
|
if (!selected) {
|
|
311
|
-
const templates = [];
|
|
316
|
+
const templates: string[] = [];
|
|
312
317
|
templates.push(...fs.readdirSync(runtimeDir, { withFileTypes: true })
|
|
313
318
|
.filter(item => item.isDirectory() && item.name !== 'starter')
|
|
314
319
|
.map(dirent => dirent.name));
|
|
@@ -319,10 +324,10 @@ const initFunction = async () => {
|
|
|
319
324
|
}
|
|
320
325
|
}
|
|
321
326
|
|
|
322
|
-
const copyRecursiveSync = (src, dest) => {
|
|
327
|
+
const copyRecursiveSync = (src: string, dest: string): void => {
|
|
323
328
|
let exists = fs.existsSync(src);
|
|
324
329
|
let stats = exists && fs.statSync(src);
|
|
325
|
-
let isDirectory = exists && stats.isDirectory();
|
|
330
|
+
let isDirectory = exists && stats && stats.isDirectory();
|
|
326
331
|
if (isDirectory) {
|
|
327
332
|
if (!fs.existsSync(dest)) {
|
|
328
333
|
fs.mkdirSync(dest);
|
|
@@ -369,7 +374,7 @@ const initFunction = async () => {
|
|
|
369
374
|
log("Next you can use 'appwrite run function' to develop a function locally. To deploy the function, use 'appwrite push function'");
|
|
370
375
|
}
|
|
371
376
|
|
|
372
|
-
const initSite = async () => {
|
|
377
|
+
const initSite = async (): Promise<void> => {
|
|
373
378
|
process.chdir(localConfig.configDirectoryPath)
|
|
374
379
|
|
|
375
380
|
const answers = await inquirer.prompt(questionsCreateSite);
|
|
@@ -390,7 +395,7 @@ const initSite = async () => {
|
|
|
390
395
|
throw new Error(`( ${siteName} ) already exists in the current directory. Please choose another name.`);
|
|
391
396
|
}
|
|
392
397
|
|
|
393
|
-
let templateDetails;
|
|
398
|
+
let templateDetails: any;
|
|
394
399
|
try {
|
|
395
400
|
const response = await sitesListTemplates({
|
|
396
401
|
frameworks: [answers.framework.key],
|
|
@@ -402,12 +407,12 @@ const initSite = async () => {
|
|
|
402
407
|
throw new Error(`No starter template found for framework ${answers.framework.key}`);
|
|
403
408
|
}
|
|
404
409
|
templateDetails = response.templates[0];
|
|
405
|
-
} catch (
|
|
406
|
-
throw new Error(`Failed to fetch template for framework ${answers.framework.key}: ${
|
|
410
|
+
} catch (err: any) {
|
|
411
|
+
throw new Error(`Failed to fetch template for framework ${answers.framework.key}: ${err.message}`);
|
|
407
412
|
}
|
|
408
413
|
|
|
409
|
-
fs.mkdirSync(siteDir,
|
|
410
|
-
fs.mkdirSync(templatesDir,
|
|
414
|
+
fs.mkdirSync(siteDir, { mode: 0o777 });
|
|
415
|
+
fs.mkdirSync(templatesDir, { mode: 0o777 });
|
|
411
416
|
const repo = `https://github.com/${templateDetails.providerOwner}/${templateDetails.providerRepositoryId}`;
|
|
412
417
|
let selected = { template: templateDetails.frameworks[0].providerRootDirectory };
|
|
413
418
|
|
|
@@ -451,23 +456,23 @@ const initSite = async () => {
|
|
|
451
456
|
/* Execute the child process but do not print any std output */
|
|
452
457
|
try {
|
|
453
458
|
childProcess.execSync(gitCloneCommands, { stdio: 'pipe', cwd: templatesDir });
|
|
454
|
-
} catch (
|
|
459
|
+
} catch (err: any) {
|
|
455
460
|
/* Specialised errors with recommended actions to take */
|
|
456
|
-
if (
|
|
457
|
-
throw new Error(`${
|
|
458
|
-
} else if (
|
|
459
|
-
throw new Error(`${
|
|
461
|
+
if (err.message.includes('error: unknown option')) {
|
|
462
|
+
throw new Error(`${err.message} \n\nSuggestion: Try updating your git to the latest version, then trying to run this command again.`)
|
|
463
|
+
} else if (err.message.includes('is not recognized as an internal or external command,') || err.message.includes('command not found')) {
|
|
464
|
+
throw new Error(`${err.message} \n\nSuggestion: It appears that git is not installed, try installing git then trying to run this command again.`)
|
|
460
465
|
} else {
|
|
461
|
-
throw
|
|
466
|
+
throw err;
|
|
462
467
|
}
|
|
463
468
|
}
|
|
464
469
|
|
|
465
470
|
fs.rmSync(path.join(templatesDir, ".git"), { recursive: true });
|
|
466
471
|
|
|
467
|
-
const copyRecursiveSync = (src, dest) => {
|
|
472
|
+
const copyRecursiveSync = (src: string, dest: string): void => {
|
|
468
473
|
let exists = fs.existsSync(src);
|
|
469
474
|
let stats = exists && fs.statSync(src);
|
|
470
|
-
let isDirectory = exists && stats.isDirectory();
|
|
475
|
+
let isDirectory = exists && stats && stats.isDirectory();
|
|
471
476
|
if (isDirectory) {
|
|
472
477
|
if (!fs.existsSync(dest)) {
|
|
473
478
|
fs.mkdirSync(dest);
|
|
@@ -491,9 +496,9 @@ const initSite = async () => {
|
|
|
491
496
|
newReadmeFile.splice(1, 2);
|
|
492
497
|
fs.writeFileSync(readmePath, newReadmeFile.join('\n'));
|
|
493
498
|
|
|
494
|
-
let vars = (templateDetails.variables ?? []).map(variable => {
|
|
499
|
+
let vars = (templateDetails.variables ?? []).map((variable: any) => {
|
|
495
500
|
let value = variable.value;
|
|
496
|
-
const replacements = {
|
|
501
|
+
const replacements: Record<string, string> = {
|
|
497
502
|
'{apiEndpoint}': globalConfig.getEndpoint(),
|
|
498
503
|
'{projectId}': localConfig.getProject().projectId,
|
|
499
504
|
'{projectName}': localConfig.getProject().projectName,
|
|
@@ -551,7 +556,7 @@ const initSite = async () => {
|
|
|
551
556
|
log("Next you can use 'appwrite push site' to deploy the changes.");
|
|
552
557
|
};
|
|
553
558
|
|
|
554
|
-
const init = new Command("init")
|
|
559
|
+
export const init = new Command("init")
|
|
555
560
|
.description(commandDescriptions['init'])
|
|
556
561
|
.action(actionRunner(initResources));
|
|
557
562
|
|
|
@@ -605,6 +610,3 @@ init
|
|
|
605
610
|
.description("Init a new Appwrite topic")
|
|
606
611
|
.action(actionRunner(initTopic));
|
|
607
612
|
|
|
608
|
-
module.exports = {
|
|
609
|
-
init,
|
|
610
|
-
};
|
|
@@ -1,31 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
* @param {fs.ReadStream} readStream
|
|
17
|
-
* @returns {ReadableStream}
|
|
18
|
-
*/
|
|
19
|
-
function convertReadStreamToReadableStream(readStream) {
|
|
1
|
+
import fs = require('fs');
|
|
2
|
+
import pathLib = require('path');
|
|
3
|
+
import tar = require('tar');
|
|
4
|
+
import ignore = require('ignore');
|
|
5
|
+
import { promisify } from 'util';
|
|
6
|
+
import Client from '../client';
|
|
7
|
+
import { getAllFiles, showConsoleLink } from '../utils';
|
|
8
|
+
import { Command } from 'commander';
|
|
9
|
+
import { sdkForProject, sdkForConsole } from '../sdks';
|
|
10
|
+
import { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log, warn } from '../parser';
|
|
11
|
+
import { localConfig, globalConfig } from '../config';
|
|
12
|
+
import { File } from 'undici';
|
|
13
|
+
import { ReadableStream } from 'stream/web';
|
|
14
|
+
|
|
15
|
+
function convertReadStreamToReadableStream(readStream: fs.ReadStream): ReadableStream {
|
|
20
16
|
return new ReadableStream({
|
|
21
17
|
start(controller) {
|
|
22
|
-
readStream.on("data", (chunk) => {
|
|
18
|
+
readStream.on("data", (chunk: Buffer) => {
|
|
23
19
|
controller.enqueue(chunk);
|
|
24
20
|
});
|
|
25
21
|
readStream.on("end", () => {
|
|
26
22
|
controller.close();
|
|
27
23
|
});
|
|
28
|
-
readStream.on("error", (err) => {
|
|
24
|
+
readStream.on("error", (err: Error) => {
|
|
29
25
|
controller.error(err);
|
|
30
26
|
});
|
|
31
27
|
},
|
|
@@ -35,21 +31,17 @@ function convertReadStreamToReadableStream(readStream) {
|
|
|
35
31
|
});
|
|
36
32
|
}
|
|
37
33
|
|
|
38
|
-
const locale = new Command("locale").description(commandDescriptions['locale'] ?? '').configureHelp({
|
|
34
|
+
export const locale = new Command("locale").description(commandDescriptions['locale'] ?? '').configureHelp({
|
|
39
35
|
helpWidth: process.stdout.columns || 80
|
|
40
36
|
})
|
|
41
37
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* @param {LocaleGetRequestParams} params
|
|
51
|
-
*/
|
|
52
|
-
const localeGet = async ({parseOutput = true, overrideForCli = false, sdk = undefined}) => {
|
|
38
|
+
interface LocaleGetRequestParams {
|
|
39
|
+
overrideForCli?: boolean;
|
|
40
|
+
parseOutput?: boolean;
|
|
41
|
+
sdk?: Client;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export const localeGet = async ({parseOutput = true, overrideForCli = false, sdk = undefined}: LocaleGetRequestParams): Promise<any> => {
|
|
53
45
|
let client = !sdk ? await sdkForProject() :
|
|
54
46
|
sdk;
|
|
55
47
|
let apiPath = '/locale';
|
|
@@ -67,17 +59,13 @@ const localeGet = async ({parseOutput = true, overrideForCli = false, sdk = unde
|
|
|
67
59
|
return response;
|
|
68
60
|
|
|
69
61
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* @param {LocaleListCodesRequestParams} params
|
|
79
|
-
*/
|
|
80
|
-
const localeListCodes = async ({parseOutput = true, overrideForCli = false, sdk = undefined}) => {
|
|
62
|
+
interface LocaleListCodesRequestParams {
|
|
63
|
+
overrideForCli?: boolean;
|
|
64
|
+
parseOutput?: boolean;
|
|
65
|
+
sdk?: Client;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export const localeListCodes = async ({parseOutput = true, overrideForCli = false, sdk = undefined}: LocaleListCodesRequestParams): Promise<any> => {
|
|
81
69
|
let client = !sdk ? await sdkForProject() :
|
|
82
70
|
sdk;
|
|
83
71
|
let apiPath = '/locale/codes';
|
|
@@ -95,17 +83,13 @@ const localeListCodes = async ({parseOutput = true, overrideForCli = false, sdk
|
|
|
95
83
|
return response;
|
|
96
84
|
|
|
97
85
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* @param {LocaleListContinentsRequestParams} params
|
|
107
|
-
*/
|
|
108
|
-
const localeListContinents = async ({parseOutput = true, overrideForCli = false, sdk = undefined}) => {
|
|
86
|
+
interface LocaleListContinentsRequestParams {
|
|
87
|
+
overrideForCli?: boolean;
|
|
88
|
+
parseOutput?: boolean;
|
|
89
|
+
sdk?: Client;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export const localeListContinents = async ({parseOutput = true, overrideForCli = false, sdk = undefined}: LocaleListContinentsRequestParams): Promise<any> => {
|
|
109
93
|
let client = !sdk ? await sdkForProject() :
|
|
110
94
|
sdk;
|
|
111
95
|
let apiPath = '/locale/continents';
|
|
@@ -123,17 +107,13 @@ const localeListContinents = async ({parseOutput = true, overrideForCli = false,
|
|
|
123
107
|
return response;
|
|
124
108
|
|
|
125
109
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* @param {LocaleListCountriesRequestParams} params
|
|
135
|
-
*/
|
|
136
|
-
const localeListCountries = async ({parseOutput = true, overrideForCli = false, sdk = undefined}) => {
|
|
110
|
+
interface LocaleListCountriesRequestParams {
|
|
111
|
+
overrideForCli?: boolean;
|
|
112
|
+
parseOutput?: boolean;
|
|
113
|
+
sdk?: Client;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export const localeListCountries = async ({parseOutput = true, overrideForCli = false, sdk = undefined}: LocaleListCountriesRequestParams): Promise<any> => {
|
|
137
117
|
let client = !sdk ? await sdkForProject() :
|
|
138
118
|
sdk;
|
|
139
119
|
let apiPath = '/locale/countries';
|
|
@@ -151,17 +131,13 @@ const localeListCountries = async ({parseOutput = true, overrideForCli = false,
|
|
|
151
131
|
return response;
|
|
152
132
|
|
|
153
133
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* @param {LocaleListCountriesEURequestParams} params
|
|
163
|
-
*/
|
|
164
|
-
const localeListCountriesEU = async ({parseOutput = true, overrideForCli = false, sdk = undefined}) => {
|
|
134
|
+
interface LocaleListCountriesEURequestParams {
|
|
135
|
+
overrideForCli?: boolean;
|
|
136
|
+
parseOutput?: boolean;
|
|
137
|
+
sdk?: Client;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export const localeListCountriesEU = async ({parseOutput = true, overrideForCli = false, sdk = undefined}: LocaleListCountriesEURequestParams): Promise<any> => {
|
|
165
141
|
let client = !sdk ? await sdkForProject() :
|
|
166
142
|
sdk;
|
|
167
143
|
let apiPath = '/locale/countries/eu';
|
|
@@ -179,17 +155,13 @@ const localeListCountriesEU = async ({parseOutput = true, overrideForCli = false
|
|
|
179
155
|
return response;
|
|
180
156
|
|
|
181
157
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* @param {LocaleListCountriesPhonesRequestParams} params
|
|
191
|
-
*/
|
|
192
|
-
const localeListCountriesPhones = async ({parseOutput = true, overrideForCli = false, sdk = undefined}) => {
|
|
158
|
+
interface LocaleListCountriesPhonesRequestParams {
|
|
159
|
+
overrideForCli?: boolean;
|
|
160
|
+
parseOutput?: boolean;
|
|
161
|
+
sdk?: Client;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export const localeListCountriesPhones = async ({parseOutput = true, overrideForCli = false, sdk = undefined}: LocaleListCountriesPhonesRequestParams): Promise<any> => {
|
|
193
165
|
let client = !sdk ? await sdkForProject() :
|
|
194
166
|
sdk;
|
|
195
167
|
let apiPath = '/locale/countries/phones';
|
|
@@ -207,17 +179,13 @@ const localeListCountriesPhones = async ({parseOutput = true, overrideForCli = f
|
|
|
207
179
|
return response;
|
|
208
180
|
|
|
209
181
|
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
* @param {LocaleListCurrenciesRequestParams} params
|
|
219
|
-
*/
|
|
220
|
-
const localeListCurrencies = async ({parseOutput = true, overrideForCli = false, sdk = undefined}) => {
|
|
182
|
+
interface LocaleListCurrenciesRequestParams {
|
|
183
|
+
overrideForCli?: boolean;
|
|
184
|
+
parseOutput?: boolean;
|
|
185
|
+
sdk?: Client;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export const localeListCurrencies = async ({parseOutput = true, overrideForCli = false, sdk = undefined}: LocaleListCurrenciesRequestParams): Promise<any> => {
|
|
221
189
|
let client = !sdk ? await sdkForProject() :
|
|
222
190
|
sdk;
|
|
223
191
|
let apiPath = '/locale/currencies';
|
|
@@ -235,17 +203,13 @@ const localeListCurrencies = async ({parseOutput = true, overrideForCli = false,
|
|
|
235
203
|
return response;
|
|
236
204
|
|
|
237
205
|
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
/**
|
|
246
|
-
* @param {LocaleListLanguagesRequestParams} params
|
|
247
|
-
*/
|
|
248
|
-
const localeListLanguages = async ({parseOutput = true, overrideForCli = false, sdk = undefined}) => {
|
|
206
|
+
interface LocaleListLanguagesRequestParams {
|
|
207
|
+
overrideForCli?: boolean;
|
|
208
|
+
parseOutput?: boolean;
|
|
209
|
+
sdk?: Client;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export const localeListLanguages = async ({parseOutput = true, overrideForCli = false, sdk = undefined}: LocaleListLanguagesRequestParams): Promise<any> => {
|
|
249
213
|
let client = !sdk ? await sdkForProject() :
|
|
250
214
|
sdk;
|
|
251
215
|
let apiPath = '/locale/languages';
|
|
@@ -303,14 +267,4 @@ locale
|
|
|
303
267
|
.description(`List of all languages classified by ISO 639-1 including 2-letter code, name in English, and name in the respective language.`)
|
|
304
268
|
.action(actionRunner(localeListLanguages))
|
|
305
269
|
|
|
306
|
-
|
|
307
|
-
locale,
|
|
308
|
-
localeGet,
|
|
309
|
-
localeListCodes,
|
|
310
|
-
localeListContinents,
|
|
311
|
-
localeListCountries,
|
|
312
|
-
localeListCountriesEU,
|
|
313
|
-
localeListCountriesPhones,
|
|
314
|
-
localeListCurrencies,
|
|
315
|
-
localeListLanguages
|
|
316
|
-
};
|
|
270
|
+
|