Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## 13.0.0-rc.1

* Migrates codebase from JavaScript to TypeScript

## 12.0.1

Fix type generation for `point`, `lineString` and `polygon` columns
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Once the installation is complete, you can verify the install using

```sh
$ appwrite -v
12.0.1
13.0.0-rc.1
```

### Install using prebuilt binaries
Expand Down Expand Up @@ -60,7 +60,7 @@ $ scoop install https://raw.githubusercontent.com/appwrite/sdk-for-cli/master/sc
Once the installation completes, you can verify your install using
```
$ appwrite -v
12.0.1
13.0.0-rc.1
```

## Getting Started
Expand Down
3 changes: 1 addition & 2 deletions docs/examples/databases/upsert-document.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
appwrite databases upsert-document \
--database-id <DATABASE_ID> \
--collection-id <COLLECTION_ID> \
--document-id <DOCUMENT_ID> \
--data '{ "key": "value" }'
--document-id <DOCUMENT_ID>
Comment on lines 1 to +4
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Add --data parameter to the upsert-document example.

The upsertDocument operation requires a data parameter containing the document attributes to be created or updated. The example must include this parameter with sample JSON data for the command to function correctly:

appwrite databases upsert-document \
    --database-id <DATABASE_ID> \
    --collection-id <COLLECTION_ID> \
    --document-id <DOCUMENT_ID> \
    --data '{"key": "value"}'
🤖 Prompt for AI Agents
In docs/examples/databases/upsert-document.md around lines 1 to 4, the example
command is missing the required --data parameter; update the example to include
a --data argument with sample JSON (e.g., --data '{"key":"value"}') so the
upsert-document command supplies the document attributes needed for
create/update.

147 changes: 0 additions & 147 deletions index.js

This file was deleted.

152 changes: 152 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
#! /usr/bin/env node

/** Required to set max width of the help commands */
const oldWidth = process.stdout.columns;
process.stdout.columns = 100;
/** ---------------------------------------------- */

import program = require('commander');
import chalk = require('chalk');
const { version } = require('../package.json');
import { commandDescriptions, cliConfig } from './lib/parser';
import { client } from './lib/commands/generic';
import { getLatestVersion, compareVersions } from './lib/utils';
import inquirer = require('inquirer');
import { login, logout, whoami, migrate, register } from './lib/commands/generic';
import { init } from './lib/commands/init';
import { types } from './lib/commands/types';
import { pull } from './lib/commands/pull';
import { run } from './lib/commands/run';
import { push, deploy } from './lib/commands/push';
import { update } from './lib/commands/update';
import { account } from './lib/commands/account';
import { console } from './lib/commands/console';
import { databases } from './lib/commands/databases';
import { functions } from './lib/commands/functions';
import { graphql } from './lib/commands/graphql';
import { health } from './lib/commands/health';
import { locale } from './lib/commands/locale';
import { messaging } from './lib/commands/messaging';
import { migrations } from './lib/commands/migrations';
import { project } from './lib/commands/project';
import { projects } from './lib/commands/projects';
import { proxy } from './lib/commands/proxy';
import { sites } from './lib/commands/sites';
import { storage } from './lib/commands/storage';
import { tablesDB } from './lib/commands/tables-db';
import { teams } from './lib/commands/teams';
import { tokens } from './lib/commands/tokens';
import { users } from './lib/commands/users';
import { vcs } from './lib/commands/vcs';

inquirer.registerPrompt('search-list', require('inquirer-search-list'));

/**
* Check for updates and show version information
*/
async function checkVersion(): Promise<void> {
process.stdout.write(chalk.bold(`appwrite version ${version}`) + '\n');

try {
const latestVersion = await getLatestVersion();
const comparison = compareVersions(version, latestVersion);

if (comparison > 0) {
// Current version is older than latest
process.stdout.write(
chalk.yellow(`\n⚠️ A newer version is available: ${chalk.bold(latestVersion)}`) + '\n'
);
process.stdout.write(
chalk.cyan(
`💡 Run '${chalk.bold('appwrite update')}' to update to the latest version.`
) + '\n'
);
} else if (comparison === 0) {
process.stdout.write(chalk.green('\n✅ You are running the latest version!') + '\n');
} else {
// Current version is newer than latest (pre-release/dev)
process.stdout.write(chalk.blue('\n🚀 You are running a pre-release or development version.') + '\n');
}
} catch (error) {
// Silently fail version check, just show current version
process.stdout.write(chalk.gray('\n(Unable to check for updates)') + '\n');
}
}

// Intercept version flag before Commander.js processes it
if (process.argv.includes('-v') || process.argv.includes('--version')) {
(async () => {
await checkVersion();
process.exit(0);
})();
} else {
program
.description(commandDescriptions['main'])
.configureHelp({
helpWidth: process.stdout.columns || 80,
sortSubcommands: true,
})
.helpOption('-h, --help', 'Display help for command')
.version(version, '-v, --version', 'Output the version number')
.option('-V, --verbose', 'Show complete error log')
.option('-j, --json', 'Output in JSON format')
.hook('preAction', migrate)
.option('-f,--force', 'Flag to confirm all warnings')
.option('-a,--all', 'Flag to push all resources')
.option('--id [id...]', 'Flag to pass a list of ids for a given action')
.option('--report', 'Enable reporting in case of CLI errors')
.on('option:json', () => {
cliConfig.json = true;
})
.on('option:verbose', () => {
cliConfig.verbose = true;
})
.on('option:report', function () {
cliConfig.report = true;
cliConfig.reportData = { data: this };
})
.on('option:force', () => {
cliConfig.force = true;
})
.on('option:all', () => {
cliConfig.all = true;
})
.on('option:id', function () {
cliConfig.ids = (this as any).opts().id;
})
.showSuggestionAfterError()
.addCommand(whoami)
.addCommand(register)
.addCommand(login)
.addCommand(init)
.addCommand(pull)
.addCommand(push)
.addCommand(types)
.addCommand(deploy)
.addCommand(run)
.addCommand(update)
.addCommand(logout)
.addCommand(account)
.addCommand(console)
.addCommand(databases)
.addCommand(functions)
.addCommand(graphql)
.addCommand(health)
.addCommand(locale)
.addCommand(messaging)
.addCommand(migrations)
.addCommand(project)
.addCommand(projects)
.addCommand(proxy)
.addCommand(sites)
.addCommand(storage)
.addCommand(tablesDB)
.addCommand(teams)
.addCommand(tokens)
.addCommand(users)
.addCommand(vcs)
.addCommand(client)
.parse(process.argv);

process.stdout.columns = oldWidth;
}
7 changes: 2 additions & 5 deletions install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
# You can use "View source" of this page to see the full script.

# REPO
$GITHUB_x64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/12.0.1/appwrite-cli-win-x64.exe"
$GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/12.0.1/appwrite-cli-win-arm64.exe"
$GITHUB_x64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/13.0.0-rc.1/appwrite-cli-win-x64.exe"
$GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/13.0.0-rc.1/appwrite-cli-win-arm64.exe"

$APPWRITE_BINARY_NAME = "appwrite.exe"

Expand All @@ -41,7 +41,6 @@ function Greeting {
Write-Host "Welcome to the Appwrite CLI install shield."
}


function CheckSystemInfo {
Write-Host "[1/4] Getting System Info ..."
if ((Get-ExecutionPolicy) -gt 'RemoteSigned' -or (Get-ExecutionPolicy) -eq 'ByPass') {
Expand All @@ -66,7 +65,6 @@ function DownloadBinary {
Move-Item $APPWRITE_DOWNLOAD_DIR $APPWRITE_INSTALL_PATH
}


function Install {
Write-Host "[3/4] Starting installation ..."

Expand All @@ -89,7 +87,6 @@ function InstallCompleted {
Write-Host "As first step, you can login to your Appwrite account using 'appwrite login'"
}


Greeting
CheckSystemInfo
DownloadBinary
Expand Down
3 changes: 1 addition & 2 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color


greeting() {
echo -e "${RED}"
cat << "EOF"
Expand Down Expand Up @@ -97,7 +96,7 @@ printSuccess() {
downloadBinary() {
echo "[2/4] Downloading executable for $OS ($ARCH) ..."

GITHUB_LATEST_VERSION="12.0.1"
GITHUB_LATEST_VERSION="13.0.0-rc.1"
GITHUB_FILE="appwrite-cli-${OS}-${ARCH}"
GITHUB_URL="https://github.com/$GITHUB_REPOSITORY_NAME/releases/download/$GITHUB_LATEST_VERSION/$GITHUB_FILE"

Expand Down
Loading