Skip to content

Commit 532794e

Browse files
authored
feat: Command Line SDK update for version 19.2.0 (#304)
* chore: update Command Line SDK to 19.2.0 * chore: update Command Line SDK to 19.2.0
1 parent 9f704c2 commit 532794e

12 files changed

Lines changed: 801 additions & 40 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Change Log
22

3+
## 19.2.0
4+
5+
* Added `completion install` command with completion scripts for zsh, bash, and fish
6+
* Added automatic shell-completion install step to the `install.sh` standalone installer
7+
* Updated Homebrew install and update flow to detect the installed formula and recommend the official `appwrite/appwrite/appwrite` tap when a different one is in use
8+
* Fixed standalone update check to point at the `appwrite/sdk-for-cli` releases feed instead of the legacy `appwrite/appwrite-cli` repo
9+
310
## 19.1.0
411

512
* Added `--where`, `--sort-asc`, `--sort-desc`, `--limit`, `--offset`, `--cursor-after`, and `--cursor-before` flags on list commands across services

README.md

Lines changed: 23 additions & 2 deletions
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-
19.1.0
32+
19.2.0
3333
```
3434

3535
### Install using prebuilt binaries
@@ -49,6 +49,27 @@ $ brew install appwrite/appwrite/appwrite
4949

5050
Homebrew pulls the formula from the [`appwrite/homebrew-appwrite`](https://github.com/appwrite/homebrew-appwrite) tap and downloads the native binary for your platform.
5151

52+
### Shell completion
53+
54+
Install completion for your current shell:
55+
56+
```bash
57+
appwrite completion install
58+
```
59+
60+
You can also generate or install completion scripts manually:
61+
62+
```bash
63+
# zsh
64+
appwrite completion install zsh
65+
# bash
66+
appwrite completion install bash
67+
# fish
68+
appwrite completion install fish
69+
```
70+
71+
For zsh, ensure `~/.zfunc` is in your `fpath` and `compinit` is loaded from your shell config.
72+
5273
### Windows
5374
Via Powershell
5475
```powershell
@@ -62,7 +83,7 @@ $ scoop install https://raw.githubusercontent.com/appwrite/sdk-for-cli/master/sc
6283
Once the installation completes, you can verify your install using
6384
```
6485
$ appwrite -v
65-
19.1.0
86+
19.2.0
6687
```
6788

6889
## Getting Started

cli.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ import {
1818
syncVersionCheckCache,
1919
} from './lib/utils.js';
2020
import inquirerSearchList from 'inquirer-search-list';
21+
import {
22+
createCompletionCommand,
23+
isCompletionCommand,
24+
isCompletionInvocation,
25+
} from './lib/completions.js';
2126

2227
import { client } from './lib/commands/generic.js';
2328
import { login, logout, whoami, migrate, register } from './lib/commands/generic.js';
@@ -55,7 +60,6 @@ import { webhooks } from './lib/commands/services/webhooks.js';
5560
const { version } = packageJson;
5661
inquirer.registerPrompt('search-list', inquirerSearchList);
5762
const VERSION_CHECK_TIMEOUT_MS = 5000;
58-
5963
function writeUpdateAvailableNotice(currentVersion: string, latestVersion: string, toStderr: boolean = false): void {
6064
const stream = toStderr ? process.stderr : process.stdout;
6165

@@ -126,7 +130,9 @@ if (process.argv.includes('-v') || process.argv.includes('--version')) {
126130
})();
127131
} else {
128132
void (async () => {
129-
await maybeShowUpdateNotice();
133+
if (!isCompletionInvocation()) {
134+
await maybeShowUpdateNotice();
135+
}
130136

131137
program
132138
.name('appwrite')
@@ -141,7 +147,13 @@ if (process.argv.includes('-v') || process.argv.includes('--version')) {
141147
.option('-j, --json', 'Output filtered JSON without empty values')
142148
.option('-R, --raw', 'Output full JSON response (secrets still redacted unless --show-secrets is set)')
143149
.option('--show-secrets', 'Display sensitive values like secrets and tokens in output')
144-
.hook('preAction', migrate)
150+
.hook('preAction', async (_thisCommand, actionCommand) => {
151+
if (isCompletionCommand(actionCommand)) {
152+
return;
153+
}
154+
155+
await migrate();
156+
})
145157
.option('-f,--force', 'Flag to confirm all warnings')
146158
.option('-a,--all', 'Flag to push all resources')
147159
.option('--id [id...]', 'Flag to pass a list of ids for a given action')
@@ -214,6 +226,7 @@ if (process.argv.includes('-v') || process.argv.includes('--version')) {
214226
.addCommand(users)
215227
.addCommand(vcs)
216228
.addCommand(webhooks)
229+
.addCommand(createCompletionCommand(program))
217230
.addCommand(client)
218231
.parse(process.argv);
219232

install.ps1

Lines changed: 2 additions & 2 deletions
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/19.1.0/appwrite-cli-win-x64.exe"
17-
$GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/19.1.0/appwrite-cli-win-arm64.exe"
16+
$GITHUB_x64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/19.2.0/appwrite-cli-win-x64.exe"
17+
$GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/19.2.0/appwrite-cli-win-arm64.exe"
1818

1919
$APPWRITE_BINARY_NAME = "appwrite.exe"
2020

install.sh

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ ARCH=""
3737
# Add some color to life
3838
RED='\033[0;31m'
3939
GREEN='\033[0;32m'
40+
YELLOW='\033[0;33m'
4041
NC='\033[0m' # No Color
4142

4243
greeting() {
@@ -55,7 +56,7 @@ EOF
5556
}
5657

5758
getSystemInfo() {
58-
echo "[1/4] Getting System Info ..."
59+
echo "[1/5] Getting System Info ..."
5960

6061
ARCH=$(uname -m)
6162
case $ARCH in
@@ -93,6 +94,10 @@ printSuccess() {
9394
printf "${GREEN}✅ Done ... ${NC}\n\n"
9495
}
9596

97+
printSkipped() {
98+
printf "${YELLOW}ℹ️ $1 ${NC}\n"
99+
}
100+
96101
verifyMacOSCodeSignature() {
97102
if [ "$OS" != "darwin" ]; then
98103
return
@@ -113,9 +118,9 @@ verifyMacOSCodeSignature() {
113118
}
114119

115120
downloadBinary() {
116-
echo "[2/4] Downloading executable for $OS ($ARCH) ..."
121+
echo "[2/5] Downloading executable for $OS ($ARCH) ..."
117122

118-
GITHUB_LATEST_VERSION="19.1.0"
123+
GITHUB_LATEST_VERSION="19.2.0"
119124
GITHUB_FILE="appwrite-cli-${OS}-${ARCH}"
120125
GITHUB_URL="https://github.com/$GITHUB_REPOSITORY_NAME/releases/download/$GITHUB_LATEST_VERSION/$GITHUB_FILE"
121126

@@ -130,7 +135,7 @@ downloadBinary() {
130135
}
131136

132137
install() {
133-
echo "[3/4] Installing ..."
138+
echo "[3/5] Installing ..."
134139

135140
printf "${GREEN}🚧 Setting Permissions ${NC}\n"
136141
chmod +x $APPWRITE_TEMP_NAME
@@ -151,6 +156,22 @@ install() {
151156
printSuccess
152157
}
153158

159+
installCompletions() {
160+
echo "[4/5] Installing shell completions ..."
161+
162+
if $APPWRITE_EXECUTABLE_FILEPATH completion install; then
163+
printSuccess
164+
return
165+
fi
166+
167+
printSkipped "Skipped shell completion installation. To install manually, run:"
168+
echo " $APPWRITE_EXECUTABLE_NAME completion install"
169+
echo " $APPWRITE_EXECUTABLE_NAME completion install zsh"
170+
echo " $APPWRITE_EXECUTABLE_NAME completion install bash"
171+
echo " $APPWRITE_EXECUTABLE_NAME completion install fish"
172+
echo ""
173+
}
174+
154175
cleanup() {
155176
printf "${GREEN}🧹 Cleaning up mess ... ${NC}\n"
156177
rm $APPWRITE_TEMP_NAME
@@ -163,7 +184,7 @@ cleanup() {
163184
}
164185

165186
installCompleted() {
166-
echo "[4/4] Wrapping up installation ... "
187+
echo "[5/5] Wrapping up installation ... "
167188
cleanup
168189
echo "🚀 To get started with Appwrite CLI, please visit https://appwrite.io/docs/command-line"
169190
echo "As first step, you can login to your Appwrite account using 'appwrite login'"
@@ -174,4 +195,5 @@ greeting
174195
getSystemInfo
175196
downloadBinary
176197
install
198+
installCompletions
177199
installCompleted

lib/commands/update.ts

Lines changed: 68 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
getLatestVersionForInstallation,
1212
compareVersions,
1313
getErrorMessage,
14+
getInstalledHomebrewFormula,
1415
} from "../utils.js";
1516
import {
1617
EXECUTABLE_NAME,
@@ -136,6 +137,31 @@ const execCommand = (
136137
});
137138
};
138139

140+
const getHomebrewFormulaForUpdate = (): string => {
141+
return getInstalledHomebrewFormula() ?? HOMEBREW_FORMULA;
142+
};
143+
144+
const getHomebrewFormulaForManualInstructions = (): string => {
145+
if (process.platform === "win32") {
146+
return HOMEBREW_FORMULA;
147+
}
148+
149+
return getHomebrewFormulaForUpdate();
150+
};
151+
152+
const showHomebrewTapRecommendation = (formulaName: string): void => {
153+
if (formulaName === HOMEBREW_FORMULA) {
154+
return;
155+
}
156+
157+
warn(
158+
`Detected ${chalk.bold(formulaName)} from Homebrew. For faster native binaries, we recommend using the official Appwrite tap.`,
159+
);
160+
hint(
161+
`To use the official Appwrite tap, run: brew install ${HOMEBREW_FORMULA}`,
162+
);
163+
};
164+
139165
/**
140166
* Update via npm
141167
*/
@@ -163,9 +189,16 @@ const updateViaNpm = async (): Promise<void> => {
163189
/**
164190
* Update via Homebrew
165191
*/
166-
const updateViaHomebrew = async (): Promise<void> => {
192+
const updateViaHomebrew = async (
193+
formulaName: string = getHomebrewFormulaForUpdate(),
194+
options: { showRecommendation?: boolean } = {},
195+
): Promise<void> => {
167196
try {
168-
await execCommand("brew", ["upgrade", HOMEBREW_FORMULA]);
197+
if (options.showRecommendation ?? true) {
198+
showHomebrewTapRecommendation(formulaName);
199+
}
200+
201+
await execCommand("brew", ["upgrade", formulaName]);
169202
console.log("");
170203
success("Updated to latest version via Homebrew!");
171204
hint(`Run '${EXECUTABLE_NAME} --version' to verify the new version.`);
@@ -184,7 +217,7 @@ const updateViaHomebrew = async (): Promise<void> => {
184217
} else {
185218
console.log("");
186219
error(`Failed to update via Homebrew: ${message}`);
187-
hint(`Try running: brew upgrade ${HOMEBREW_FORMULA}`);
220+
hint(`Try running: brew upgrade ${formulaName}`);
188221
}
189222
}
190223
};
@@ -196,7 +229,7 @@ const updateViaStandaloneBinary = async (
196229
latestVersion: string,
197230
): Promise<void> => {
198231
if (process.platform === "win32") {
199-
showManualInstructions(latestVersion);
232+
showManualInstructions(latestVersion, HOMEBREW_FORMULA);
200233
return;
201234
}
202235

@@ -252,7 +285,10 @@ const updateViaStandaloneBinary = async (
252285
/**
253286
* Show manual update instructions
254287
*/
255-
const showManualInstructions = (latestVersion: string): void => {
288+
const showManualInstructions = (
289+
latestVersion: string,
290+
homebrewFormula: string = getHomebrewFormulaForManualInstructions(),
291+
): void => {
256292
log("Manual update options:");
257293
console.log("");
258294

@@ -261,7 +297,13 @@ const showManualInstructions = (latestVersion: string): void => {
261297
console.log("");
262298

263299
log(`${chalk.bold("Option 2: Homebrew")}`);
264-
console.log(` brew upgrade ${HOMEBREW_FORMULA}`);
300+
console.log(` brew upgrade ${homebrewFormula}`);
301+
if (homebrewFormula !== HOMEBREW_FORMULA) {
302+
console.log("");
303+
hint(
304+
`For faster native binaries from the official Appwrite tap, run: brew install ${HOMEBREW_FORMULA}`,
305+
);
306+
}
265307
console.log("");
266308

267309
if (process.platform !== "win32") {
@@ -347,8 +389,14 @@ interface UpdateOptions {
347389
const updateCli = async ({ manual }: UpdateOptions = {}): Promise<void> => {
348390
try {
349391
const installationMethod = detectInstallationMethod();
350-
const latestVersion =
351-
await getLatestVersionForInstallation(installationMethod);
392+
const homebrewFormula =
393+
installationMethod === "homebrew" ? getHomebrewFormulaForUpdate() : null;
394+
const latestVersion = await getLatestVersionForInstallation(
395+
installationMethod,
396+
{
397+
homebrewFormula: homebrewFormula ?? undefined,
398+
},
399+
);
352400

353401
const comparison = compareVersions(version, latestVersion);
354402

@@ -365,22 +413,28 @@ const updateCli = async ({ manual }: UpdateOptions = {}): Promise<void> => {
365413
return;
366414
}
367415

416+
if (manual) {
417+
showManualInstructions(latestVersion, homebrewFormula ?? undefined);
418+
return;
419+
}
420+
421+
if (homebrewFormula) {
422+
showHomebrewTapRecommendation(homebrewFormula);
423+
}
424+
368425
log(
369426
`Updating from ${chalk.blue(version)} to ${chalk.green(latestVersion)}...`,
370427
);
371428
console.log("");
372429

373-
if (manual) {
374-
showManualInstructions(latestVersion);
375-
return;
376-
}
377-
378430
switch (installationMethod) {
379431
case "npm":
380432
await updateViaNpm();
381433
break;
382434
case "homebrew":
383-
await updateViaHomebrew();
435+
await updateViaHomebrew(homebrewFormula ?? undefined, {
436+
showRecommendation: false,
437+
});
384438
break;
385439
case "standalone":
386440
await updateViaStandaloneBinary(latestVersion);

0 commit comments

Comments
 (0)