Skip to content

Commit 6676526

Browse files
committed
fix: build and version
1 parent 4736056 commit 6676526

File tree

8 files changed

+362
-334
lines changed

8 files changed

+362
-334
lines changed

.github/workflows/npm-publish.yml

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ jobs:
1313
registry-url: 'https://registry.npmjs.org'
1414
- name: Setup binfmt with QEMU
1515
run: |
16+
sudo apt update
1617
sudo apt install qemu binfmt-support qemu-user-static
1718
update-binfmts --display
1819
- name: Setup ldid

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Once the installation is complete, you can verify the install using
2929

3030
```sh
3131
$ appwrite -v
32-
6.0.1
32+
6.1.0
3333
```
3434

3535
### Install using prebuilt binaries
@@ -60,7 +60,7 @@ $ scoop install https://raw.githubusercontent.com/appwrite/sdk-for-cli/master/sc
6060
Once the installation completes, you can verify your install using
6161
```
6262
$ appwrite -v
63-
6.0.1
63+
6.1.0
6464
```
6565

6666
## Getting Started

install.ps1

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
# You can use "View source" of this page to see the full script.
1414

1515
# REPO
16-
$GITHUB_x64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/6.0.1/appwrite-cli-win-x64.exe"
17-
$GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/6.0.1/appwrite-cli-win-arm64.exe"
16+
$GITHUB_x64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/6.1.0/appwrite-cli-win-x64.exe"
17+
$GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/6.1.0/appwrite-cli-win-arm64.exe"
1818

1919
$APPWRITE_BINARY_NAME = "appwrite.exe"
2020

install.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ printSuccess() {
9797
downloadBinary() {
9898
echo "[2/4] Downloading executable for $OS ($ARCH) ..."
9999

100-
GITHUB_LATEST_VERSION="6.0.1"
100+
GITHUB_LATEST_VERSION="6.1.0"
101101
GITHUB_FILE="appwrite-cli-${OS}-${ARCH}"
102102
GITHUB_URL="https://github.com/$GITHUB_REPOSITORY_NAME/releases/download/$GITHUB_LATEST_VERSION/$GITHUB_FILE"
103103

lib/client.js

+110-94
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const os = require('os');
1+
const os = require("os");
22
const https = require("https");
33
const { fetch, FormData, Agent } = require("undici");
44
const JSONbig = require("json-bigint")({ storeAsString: false });
@@ -7,18 +7,18 @@ const { globalConfig } = require("./config.js");
77
const chalk = require("chalk");
88

99
class Client {
10-
CHUNK_SIZE = 5*1024*1024; // 5MB
10+
CHUNK_SIZE = 5 * 1024 * 1024; // 5MB
1111

1212
constructor() {
13-
this.endpoint = 'https://cloud.appwrite.io/v1';
13+
this.endpoint = "https://cloud.appwrite.io/v1";
1414
this.headers = {
15-
'content-type': '',
16-
'x-sdk-name': 'Command Line',
17-
'x-sdk-platform': 'console',
18-
'x-sdk-language': 'cli',
19-
'x-sdk-version': '6.0.1',
20-
'user-agent' : `AppwriteCLI/6.0.1 (${os.type()} ${os.version()}; ${os.arch()})`,
21-
'X-Appwrite-Response-Format' : '1.6.0',
15+
"content-type": "",
16+
"x-sdk-name": "Command Line",
17+
"x-sdk-platform": "console",
18+
"x-sdk-language": "cli",
19+
"x-sdk-version": "6.1.0",
20+
"user-agent": `AppwriteCLI/6.1.0 (${os.type()} ${os.version()}; ${os.arch()})`,
21+
"X-Appwrite-Response-Format": "1.6.0",
2222
};
2323
}
2424

@@ -37,76 +37,76 @@ class Client {
3737
return this;
3838
}
3939

40-
/**
41-
* Set Project
42-
*
43-
* Your project ID
44-
*
45-
* @param {string} project
46-
*
47-
* @return self
48-
*/
49-
setProject(project) {
50-
this.addHeader('X-Appwrite-Project', project);
51-
52-
return this;
53-
}
40+
/**
41+
* Set Project
42+
*
43+
* Your project ID
44+
*
45+
* @param {string} project
46+
*
47+
* @return self
48+
*/
49+
setProject(project) {
50+
this.addHeader("X-Appwrite-Project", project);
5451

55-
/**
56-
* Set Key
57-
*
58-
* Your secret API key
59-
*
60-
* @param {string} key
61-
*
62-
* @return self
63-
*/
64-
setKey(key) {
65-
this.addHeader('X-Appwrite-Key', key);
66-
67-
return this;
68-
}
52+
return this;
53+
}
6954

70-
/**
71-
* Set JWT
72-
*
73-
* Your secret JSON Web Token
74-
*
75-
* @param {string} jwt
76-
*
77-
* @return self
78-
*/
79-
setJWT(jwt) {
80-
this.addHeader('X-Appwrite-JWT', jwt);
81-
82-
return this;
83-
}
55+
/**
56+
* Set Key
57+
*
58+
* Your secret API key
59+
*
60+
* @param {string} key
61+
*
62+
* @return self
63+
*/
64+
setKey(key) {
65+
this.addHeader("X-Appwrite-Key", key);
8466

85-
/**
86-
* Set Locale
87-
*
88-
* @param {string} locale
89-
*
90-
* @return self
91-
*/
92-
setLocale(locale) {
93-
this.addHeader('X-Appwrite-Locale', locale);
94-
95-
return this;
96-
}
67+
return this;
68+
}
9769

98-
/**
99-
* Set Mode
100-
*
101-
* @param {string} mode
102-
*
103-
* @return self
104-
*/
105-
setMode(mode) {
106-
this.addHeader('X-Appwrite-Mode', mode);
107-
108-
return this;
109-
}
70+
/**
71+
* Set JWT
72+
*
73+
* Your secret JSON Web Token
74+
*
75+
* @param {string} jwt
76+
*
77+
* @return self
78+
*/
79+
setJWT(jwt) {
80+
this.addHeader("X-Appwrite-JWT", jwt);
81+
82+
return this;
83+
}
84+
85+
/**
86+
* Set Locale
87+
*
88+
* @param {string} locale
89+
*
90+
* @return self
91+
*/
92+
setLocale(locale) {
93+
this.addHeader("X-Appwrite-Locale", locale);
94+
95+
return this;
96+
}
97+
98+
/**
99+
* Set Mode
100+
*
101+
* @param {string} mode
102+
*
103+
* @return self
104+
*/
105+
setMode(mode) {
106+
this.addHeader("X-Appwrite-Mode", mode);
107+
108+
return this;
109+
}
110110

111111
/**
112112
* Set self signed.
@@ -144,26 +144,34 @@ class Client {
144144
return this;
145145
}
146146

147-
async call(method, path = "", headers = {}, params = {}, responseType = "json") {
148-
headers = {...this.headers, ...headers};
147+
async call(
148+
method,
149+
path = "",
150+
headers = {},
151+
params = {},
152+
responseType = "json"
153+
) {
154+
headers = { ...this.headers, ...headers };
149155
const url = new URL(this.endpoint + path);
150156

151157
let body = undefined;
152158

153159
if (method.toUpperCase() === "GET") {
154160
url.search = new URLSearchParams(Client.flatten(params)).toString();
155-
} else if (headers["content-type"]?.toLowerCase().startsWith("multipart/form-data")) {
161+
} else if (
162+
headers["content-type"]?.toLowerCase().startsWith("multipart/form-data")
163+
) {
156164
delete headers["content-type"];
157165
const formData = new FormData();
158166

159167
const flatParams = Client.flatten(params);
160168

161169
for (const [key, value] of Object.entries(flatParams)) {
162-
if (value && value.type && value.type === "file") {
163-
formData.append(key, value.file, value.filename);
164-
} else {
165-
formData.append(key, value);
166-
}
170+
if (value && value.type && value.type === "file") {
171+
formData.append(key, value.file, value.filename);
172+
} else {
173+
formData.append(key, value);
174+
}
167175
}
168176

169177
body = formData;
@@ -178,15 +186,15 @@ class Client {
178186
headers,
179187
body,
180188
dispatcher: new Agent({
181-
connect: {
182-
rejectUnauthorized: !this.selfSigned,
183-
},
189+
connect: {
190+
rejectUnauthorized: !this.selfSigned,
191+
},
184192
}),
185193
});
186194

187-
const warnings = response.headers.get('x-appwrite-warning');
195+
const warnings = response.headers.get("x-appwrite-warning");
188196
if (warnings) {
189-
warnings.split(';').forEach((warning) => console.warn(warning));
197+
warnings.split(";").forEach((warning) => console.warn(warning));
190198
}
191199
} catch (error) {
192200
throw new AppwriteException(error.message);
@@ -201,11 +209,19 @@ class Client {
201209
throw new AppwriteException(text, response.status, "", text);
202210
}
203211

204-
if (path !== '/account' && json.code === 401 && json.type === 'user_more_factors_required') {
205-
console.log(`${chalk.cyan.bold("ℹ Info")} ${chalk.cyan("Unusable account found, removing...")}`);
212+
if (
213+
path !== "/account" &&
214+
json.code === 401 &&
215+
json.type === "user_more_factors_required"
216+
) {
217+
console.log(
218+
`${chalk.cyan.bold("ℹ Info")} ${chalk.cyan(
219+
"Unusable account found, removing..."
220+
)}`
221+
);
206222

207223
const current = globalConfig.getCurrentSession();
208-
globalConfig.setCurrentSession('');
224+
globalConfig.setCurrentSession("");
209225
globalConfig.removeSession(current);
210226
}
211227
throw new AppwriteException(json.message, json.code, json.type, json);
@@ -231,12 +247,12 @@ class Client {
231247
return json;
232248
}
233249

234-
static flatten(data, prefix = '') {
250+
static flatten(data, prefix = "") {
235251
let output = {};
236252

237253
for (const key in data) {
238254
let value = data[key];
239-
let finalKey = prefix ? prefix + '[' + key +']' : key;
255+
let finalKey = prefix ? prefix + "[" + key + "]" : key;
240256

241257
if (Array.isArray(value)) {
242258
output = Object.assign(output, Client.flatten(value, finalKey)); // @todo: handle name collision here if needed

0 commit comments

Comments
 (0)