appwrite-cli 13.6.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 +4 -0
- package/README.md +2 -2
- package/cli.ts +3 -3
- package/dist/bundle-win-arm64.mjs +336 -212
- package/dist/cli.cjs +336 -212
- package/dist/index.cjs +156 -104
- package/dist/index.js +156 -104
- 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/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/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/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 +15 -7
- 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 +7 -1
- package/scoop/appwrite.config.json +3 -3
package/lib/questions.ts
CHANGED
|
@@ -184,7 +184,7 @@ export const questionsInitProject: Question[] = [
|
|
|
184
184
|
name: "organization",
|
|
185
185
|
message: "Choose your organization",
|
|
186
186
|
choices: async () => {
|
|
187
|
-
|
|
187
|
+
const client = await sdkForConsole(true);
|
|
188
188
|
const { teams } = isCloud()
|
|
189
189
|
? await paginate(
|
|
190
190
|
async (opts: { sdk?: Client } = {}) =>
|
|
@@ -201,7 +201,7 @@ export const questionsInitProject: Question[] = [
|
|
|
201
201
|
"teams",
|
|
202
202
|
);
|
|
203
203
|
|
|
204
|
-
|
|
204
|
+
const choices = teams.map((team: any, _idx: number) => {
|
|
205
205
|
return {
|
|
206
206
|
name: `${team.name} (${team["$id"]})`,
|
|
207
207
|
value: team["$id"],
|
|
@@ -254,7 +254,7 @@ export const questionsInitProject: Question[] = [
|
|
|
254
254
|
queries,
|
|
255
255
|
);
|
|
256
256
|
|
|
257
|
-
|
|
257
|
+
const choices = projects.map((project: any) => {
|
|
258
258
|
return {
|
|
259
259
|
name: `${project.name} (${project["$id"]})`,
|
|
260
260
|
value: {
|
|
@@ -277,13 +277,13 @@ export const questionsInitProject: Question[] = [
|
|
|
277
277
|
name: "region",
|
|
278
278
|
message: `Select your ${SDK_TITLE} Cloud region`,
|
|
279
279
|
choices: async () => {
|
|
280
|
-
|
|
280
|
+
const client = await sdkForConsole(true);
|
|
281
281
|
const endpoint = globalConfig.getEndpoint() || DEFAULT_ENDPOINT;
|
|
282
|
-
|
|
282
|
+
const response = (await client.call(
|
|
283
283
|
"GET",
|
|
284
284
|
new URL(endpoint + "/console/regions"),
|
|
285
285
|
)) as { regions: any[] };
|
|
286
|
-
|
|
286
|
+
const regions = response.regions || [];
|
|
287
287
|
if (!regions.length) {
|
|
288
288
|
throw new Error(
|
|
289
289
|
"No regions found. Please check your network or Appwrite Cloud availability.",
|
|
@@ -438,9 +438,9 @@ export const questionsCreateFunction: Question[] = [
|
|
|
438
438
|
name: "runtime",
|
|
439
439
|
message: "What runtime would you like to use?",
|
|
440
440
|
choices: async () => {
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
441
|
+
const response = await (await getFunctionsService()).listRuntimes();
|
|
442
|
+
const runtimes = response["runtimes"];
|
|
443
|
+
const choices = runtimes.map((runtime: any, _idx: number) => {
|
|
444
444
|
return {
|
|
445
445
|
name: `${runtime.name} (${runtime["$id"]})`,
|
|
446
446
|
value: {
|
|
@@ -460,9 +460,9 @@ export const questionsCreateFunction: Question[] = [
|
|
|
460
460
|
name: "specification",
|
|
461
461
|
message: "What specification would you like to use?",
|
|
462
462
|
choices: async () => {
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
463
|
+
const response = await (await getFunctionsService()).listSpecifications();
|
|
464
|
+
const specifications = response["specifications"];
|
|
465
|
+
const choices = specifications.map((spec: any, _idx: number) => {
|
|
466
466
|
return {
|
|
467
467
|
name: `${spec.cpus} CPU, ${spec.memory}MB RAM`,
|
|
468
468
|
value: spec.slug,
|
|
@@ -548,7 +548,7 @@ export const questionsCreateCollection: Question[] = [
|
|
|
548
548
|
choices: async () => {
|
|
549
549
|
const databases = localConfig.getDatabases();
|
|
550
550
|
|
|
551
|
-
|
|
551
|
+
const choices = databases.map((database: any, _idx: number) => {
|
|
552
552
|
return {
|
|
553
553
|
name: `${database.name} (${database.$id})`,
|
|
554
554
|
value: database.$id,
|
|
@@ -620,7 +620,7 @@ export const questionsCreateTable: Question[] = [
|
|
|
620
620
|
choices: async () => {
|
|
621
621
|
const databases = localConfig.getTablesDBs();
|
|
622
622
|
|
|
623
|
-
|
|
623
|
+
const choices = databases.map((database: any, _idx: number) => {
|
|
624
624
|
return {
|
|
625
625
|
name: `${database.name} (${database.$id})`,
|
|
626
626
|
value: database.$id,
|
|
@@ -697,15 +697,15 @@ export const questionsPullCollection: Question[] = [
|
|
|
697
697
|
message: "From which database would you like to pull collections?",
|
|
698
698
|
validate: (value: any) => validateRequired("collection", value),
|
|
699
699
|
choices: async () => {
|
|
700
|
-
|
|
701
|
-
|
|
700
|
+
const response = await (await getDatabasesService()).list();
|
|
701
|
+
const databases = response["databases"];
|
|
702
702
|
|
|
703
703
|
if (databases.length <= 0) {
|
|
704
704
|
throw new Error(
|
|
705
705
|
"No databases found. Please create one in project console.",
|
|
706
706
|
);
|
|
707
707
|
}
|
|
708
|
-
|
|
708
|
+
const choices = databases.map((database: any, _idx: number) => {
|
|
709
709
|
return {
|
|
710
710
|
name: `${database.name} (${database.$id})`,
|
|
711
711
|
value: database.$id,
|
|
@@ -795,9 +795,9 @@ export const questionGetEndpoint: Question[] = [
|
|
|
795
795
|
if (!value) {
|
|
796
796
|
return "Please enter a valid endpoint.";
|
|
797
797
|
}
|
|
798
|
-
|
|
798
|
+
const client = new Client().setEndpoint(value);
|
|
799
799
|
try {
|
|
800
|
-
|
|
800
|
+
const response = (await client.call(
|
|
801
801
|
"get",
|
|
802
802
|
new URL(value + "/health/version"),
|
|
803
803
|
)) as { version?: string };
|
|
@@ -806,7 +806,7 @@ export const questionGetEndpoint: Question[] = [
|
|
|
806
806
|
} else {
|
|
807
807
|
throw new Error();
|
|
808
808
|
}
|
|
809
|
-
} catch (
|
|
809
|
+
} catch (_error) {
|
|
810
810
|
return "Invalid endpoint or your Appwrite server is not running as expected.";
|
|
811
811
|
}
|
|
812
812
|
},
|
|
@@ -894,9 +894,9 @@ export const questionsPushSites: Question[] = [
|
|
|
894
894
|
validate: (value: any) => validateRequired("site", value),
|
|
895
895
|
when: () => localConfig.getSites().length > 0,
|
|
896
896
|
choices: () => {
|
|
897
|
-
|
|
897
|
+
const sites = localConfig.getSites();
|
|
898
898
|
checkDeployConditions(localConfig);
|
|
899
|
-
|
|
899
|
+
const choices = sites.map((site: any, _idx: number) => {
|
|
900
900
|
return {
|
|
901
901
|
name: `${site.name} (${site.$id})`,
|
|
902
902
|
value: site.$id,
|
|
@@ -915,9 +915,9 @@ export const questionsPushFunctions: Question[] = [
|
|
|
915
915
|
validate: (value: any) => validateRequired("function", value),
|
|
916
916
|
when: () => localConfig.getFunctions().length > 0,
|
|
917
917
|
choices: () => {
|
|
918
|
-
|
|
918
|
+
const functions = localConfig.getFunctions();
|
|
919
919
|
checkDeployConditions(localConfig);
|
|
920
|
-
|
|
920
|
+
const choices = functions.map((func: any, _idx: number) => {
|
|
921
921
|
return {
|
|
922
922
|
name: `${func.name} (${func.$id})`,
|
|
923
923
|
value: func.$id,
|
|
@@ -936,7 +936,7 @@ export const questionsPushCollections: Question[] = [
|
|
|
936
936
|
validate: (value: any) => validateRequired("collection", value),
|
|
937
937
|
when: () => localConfig.getCollections().length > 0,
|
|
938
938
|
choices: () => {
|
|
939
|
-
|
|
939
|
+
const collections = localConfig.getCollections();
|
|
940
940
|
checkDeployConditions(localConfig);
|
|
941
941
|
|
|
942
942
|
return collections.map((collection: any) => {
|
|
@@ -957,7 +957,7 @@ export const questionsPushTables: Question[] = [
|
|
|
957
957
|
validate: (value: any) => validateRequired("table", value),
|
|
958
958
|
when: () => localConfig.getTables().length > 0,
|
|
959
959
|
choices: () => {
|
|
960
|
-
|
|
960
|
+
const tables = localConfig.getTables();
|
|
961
961
|
checkDeployConditions(localConfig);
|
|
962
962
|
|
|
963
963
|
return tables.map((table: any) => {
|
|
@@ -994,7 +994,7 @@ export const questionsPushBuckets: Question[] = [
|
|
|
994
994
|
validate: (value: any) => validateRequired("bucket", value),
|
|
995
995
|
when: () => localConfig.getBuckets().length > 0,
|
|
996
996
|
choices: () => {
|
|
997
|
-
|
|
997
|
+
const buckets = localConfig.getBuckets();
|
|
998
998
|
checkDeployConditions(localConfig);
|
|
999
999
|
|
|
1000
1000
|
return buckets.map((bucket: any) => {
|
|
@@ -1015,7 +1015,7 @@ export const questionsPushMessagingTopics: Question[] = [
|
|
|
1015
1015
|
validate: (value: any) => validateRequired("topics", value),
|
|
1016
1016
|
when: () => localConfig.getMessagingTopics().length > 0,
|
|
1017
1017
|
choices: () => {
|
|
1018
|
-
|
|
1018
|
+
const topics = localConfig.getMessagingTopics();
|
|
1019
1019
|
|
|
1020
1020
|
return topics.map((topic: any) => {
|
|
1021
1021
|
return {
|
|
@@ -1049,7 +1049,7 @@ export const questionsPushTeams: Question[] = [
|
|
|
1049
1049
|
validate: (value: any) => validateRequired("team", value),
|
|
1050
1050
|
when: () => localConfig.getTeams().length > 0,
|
|
1051
1051
|
choices: () => {
|
|
1052
|
-
|
|
1052
|
+
const teams = localConfig.getTeams();
|
|
1053
1053
|
checkDeployConditions(localConfig);
|
|
1054
1054
|
|
|
1055
1055
|
return teams.map((team: any) => {
|
|
@@ -1069,7 +1069,7 @@ export const questionsListFactors: Question[] = [
|
|
|
1069
1069
|
message:
|
|
1070
1070
|
"Your account is protected by multi-factor authentication. Please choose one for verification.",
|
|
1071
1071
|
choices: async () => {
|
|
1072
|
-
|
|
1072
|
+
const client = await sdkForConsole(false);
|
|
1073
1073
|
const accountClient = new Account(client);
|
|
1074
1074
|
const factors = await accountClient.listMfaFactors();
|
|
1075
1075
|
|
|
@@ -1118,13 +1118,13 @@ export const questionsRunFunctions: Question[] = [
|
|
|
1118
1118
|
message: "Which function would you like to develop locally?",
|
|
1119
1119
|
validate: (value: any) => validateRequired("function", value),
|
|
1120
1120
|
choices: () => {
|
|
1121
|
-
|
|
1121
|
+
const functions = localConfig.getFunctions();
|
|
1122
1122
|
if (functions.length === 0) {
|
|
1123
1123
|
throw new Error(
|
|
1124
1124
|
`No functions found. Use '${EXECUTABLE_NAME} pull functions' to synchronize existing one, or use '${EXECUTABLE_NAME} init function' to create a new one.`,
|
|
1125
1125
|
);
|
|
1126
1126
|
}
|
|
1127
|
-
|
|
1127
|
+
const choices = functions.map((func: any, _idx: number) => {
|
|
1128
1128
|
return {
|
|
1129
1129
|
name: `${func.name} (${func.$id})`,
|
|
1130
1130
|
value: func.$id,
|
|
@@ -1153,9 +1153,9 @@ export const questionsCreateSite: Question[] = [
|
|
|
1153
1153
|
name: "framework",
|
|
1154
1154
|
message: "What framework would you like to use?",
|
|
1155
1155
|
choices: async () => {
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1156
|
+
const response = await (await getSitesService()).listFrameworks();
|
|
1157
|
+
const frameworks = response["frameworks"];
|
|
1158
|
+
const choices = frameworks.map((framework: any) => {
|
|
1159
1159
|
return {
|
|
1160
1160
|
name: `${framework.name} (${framework.key})`,
|
|
1161
1161
|
value: framework,
|
|
@@ -1169,9 +1169,9 @@ export const questionsCreateSite: Question[] = [
|
|
|
1169
1169
|
name: "specification",
|
|
1170
1170
|
message: "What specification would you like to use?",
|
|
1171
1171
|
choices: async () => {
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1172
|
+
const response = await (await getSitesService()).listSpecifications();
|
|
1173
|
+
const specifications = response["specifications"];
|
|
1174
|
+
const choices = specifications.map((spec: any) => {
|
|
1175
1175
|
return {
|
|
1176
1176
|
name: `${spec.cpus} CPU, ${spec.memory}MB RAM`,
|
|
1177
1177
|
value: spec.slug,
|
package/lib/spinner.ts
CHANGED
|
@@ -52,7 +52,11 @@ class Spinner {
|
|
|
52
52
|
Spinner.updatesBar.stop();
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
static formatter(
|
|
55
|
+
static formatter(
|
|
56
|
+
_options: unknown,
|
|
57
|
+
_params: unknown,
|
|
58
|
+
payload: SpinnerPayload,
|
|
59
|
+
): string {
|
|
56
60
|
const status = payload.status.padEnd(12);
|
|
57
61
|
const middle = `${payload.resource} (${payload.id})`.padEnd(40);
|
|
58
62
|
|
package/lib/utils.ts
CHANGED
|
@@ -49,6 +49,14 @@ export const createSettingsObject = (project: Models.Project): SettingsType => {
|
|
|
49
49
|
};
|
|
50
50
|
};
|
|
51
51
|
|
|
52
|
+
export const getErrorMessage = (error: unknown): string => {
|
|
53
|
+
if (error instanceof Error) {
|
|
54
|
+
return error.message;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return String(error);
|
|
58
|
+
};
|
|
59
|
+
|
|
52
60
|
/**
|
|
53
61
|
* Get the latest version from npm registry
|
|
54
62
|
*/
|
|
@@ -90,7 +98,7 @@ export function getAllFiles(folder: string): string[] {
|
|
|
90
98
|
let stats: fs.Stats;
|
|
91
99
|
try {
|
|
92
100
|
stats = fs.statSync(pathAbsolute);
|
|
93
|
-
} catch (
|
|
101
|
+
} catch (_error) {
|
|
94
102
|
continue;
|
|
95
103
|
}
|
|
96
104
|
if (stats.isDirectory()) {
|
|
@@ -146,8 +154,12 @@ export function systemHasCommand(command: string): boolean {
|
|
|
146
154
|
return true;
|
|
147
155
|
}
|
|
148
156
|
|
|
149
|
-
|
|
150
|
-
|
|
157
|
+
type DeployLocalConfig = {
|
|
158
|
+
keys: () => string[];
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
export const checkDeployConditions = (localConfig: DeployLocalConfig): void => {
|
|
162
|
+
if (localConfig.keys().length === 0) {
|
|
151
163
|
throw new Error(
|
|
152
164
|
"No appwrite.config.json file found in the current directory. Please run this command again in the folder containing your appwrite.config.json file, or run 'appwrite init project' to link current directory to an Appwrite project.",
|
|
153
165
|
);
|
package/lib/validations.ts
CHANGED
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"type": "module",
|
|
4
4
|
"homepage": "https://appwrite.io/support",
|
|
5
5
|
"description": "Appwrite is an open-source self-hosted backend server that abstracts and simplifies complex and repetitive development tasks behind a very simple REST API",
|
|
6
|
-
"version": "13.6.
|
|
6
|
+
"version": "13.6.1",
|
|
7
7
|
"license": "BSD-3-Clause",
|
|
8
8
|
"main": "dist/index.cjs",
|
|
9
9
|
"module": "dist/index.js",
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"build:lib:esm": "esbuild index.ts --bundle --platform=node --target=node18 --format=esm --loader:.hbs=text --outfile=dist/index.js",
|
|
35
35
|
"build:lib:cjs": "esbuild index.ts --bundle --platform=node --target=node18 --format=cjs --loader:.hbs=text --outfile=dist/index.cjs",
|
|
36
36
|
"build:cli": "esbuild cli.ts --bundle --platform=node --target=node18 --format=cjs --loader:.hbs=text --external:fsevents --outfile=dist/cli.cjs",
|
|
37
|
+
"lint": "eslint .",
|
|
37
38
|
"format": "prettier --write \"**/*.{js,ts,json,md}\"",
|
|
38
39
|
"generate": "tsx scripts/generate-commands.ts",
|
|
39
40
|
"prepublishOnly": "npm run build",
|
|
@@ -65,7 +66,12 @@
|
|
|
65
66
|
"zod": "^4.3.5"
|
|
66
67
|
},
|
|
67
68
|
"devDependencies": {
|
|
69
|
+
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
70
|
+
"@typescript-eslint/parser": "^8.0.0",
|
|
68
71
|
"@types/bun": "^1.3.5",
|
|
72
|
+
"eslint": "^9.0.0",
|
|
73
|
+
"eslint-plugin-unused-imports": "^4.0.0",
|
|
74
|
+
"typescript-eslint": "^8.0.0",
|
|
69
75
|
"@types/cli-progress": "^3.11.5",
|
|
70
76
|
"@types/inquirer": "^8.2.10",
|
|
71
77
|
"@types/json-bigint": "^1.0.4",
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://raw.githubusercontent.com/ScoopInstaller/Scoop/master/schema.json",
|
|
3
|
-
"version": "13.6.
|
|
3
|
+
"version": "13.6.1",
|
|
4
4
|
"description": "The Appwrite CLI is a command-line application that allows you to interact with Appwrite and perform server-side tasks using your terminal.",
|
|
5
5
|
"homepage": "https://github.com/appwrite/sdk-for-cli",
|
|
6
6
|
"license": "BSD-3-Clause",
|
|
7
7
|
"architecture": {
|
|
8
8
|
"64bit": {
|
|
9
|
-
"url": "https://github.com/appwrite/sdk-for-cli/releases/download/13.6.
|
|
9
|
+
"url": "https://github.com/appwrite/sdk-for-cli/releases/download/13.6.1/appwrite-cli-win-x64.exe",
|
|
10
10
|
"bin": [
|
|
11
11
|
[
|
|
12
12
|
"appwrite-cli-win-x64.exe",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
]
|
|
16
16
|
},
|
|
17
17
|
"arm64": {
|
|
18
|
-
"url": "https://github.com/appwrite/sdk-for-cli/releases/download/13.6.
|
|
18
|
+
"url": "https://github.com/appwrite/sdk-for-cli/releases/download/13.6.1/appwrite-cli-win-arm64.exe",
|
|
19
19
|
"bin": [
|
|
20
20
|
[
|
|
21
21
|
"appwrite-cli-win-arm64.exe",
|