Skip to content

Commit

Permalink
feat: 1.6.x preview
Browse files Browse the repository at this point in the history
  • Loading branch information
TorstenDittmann committed Jul 3, 2024
1 parent dc22eae commit 13312b5
Show file tree
Hide file tree
Showing 52 changed files with 6,984 additions and 2,545 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Appwrite Command Line SDK

![License](https://img.shields.io/github/license/appwrite/sdk-for-cli.svg?style=flat-square)
![Version](https://img.shields.io/badge/api%20version-1.5.6-blue.svg?style=flat-square)
![Version](https://img.shields.io/badge/api%20version-1.5.7-blue.svg?style=flat-square)
[![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite)
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)

**This SDK is compatible with Appwrite server version 1.5.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-cli/releases).**
**This SDK is compatible with Appwrite server version 1.6.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-cli/releases).**

Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Command Line SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)

Expand Down
2 changes: 1 addition & 1 deletion docs/examples/functions/create-build.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
appwrite functions createBuild \
--functionId <FUNCTION_ID> \
--deploymentId <DEPLOYMENT_ID> \
--buildId <BUILD_ID>

1 change: 1 addition & 0 deletions docs/examples/functions/create-execution.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ appwrite functions createExecution \




1 change: 1 addition & 0 deletions docs/examples/functions/create.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ appwrite functions create \




3 changes: 3 additions & 0 deletions docs/examples/functions/delete-execution.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
appwrite functions deleteExecution \
--functionId <FUNCTION_ID> \
--executionId <EXECUTION_ID>
3 changes: 3 additions & 0 deletions docs/examples/functions/update-deployment-build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
appwrite functions updateDeploymentBuild \
--functionId <FUNCTION_ID> \
--deploymentId <DEPLOYMENT_ID>
1 change: 1 addition & 0 deletions docs/examples/functions/update.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ appwrite functions update \




4 changes: 4 additions & 0 deletions docs/examples/projects/create-j-w-t.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
appwrite projects createJWT \
--projectId <PROJECT_ID> \
--scopes one two three \

3 changes: 3 additions & 0 deletions docs/examples/projects/update-mock-numbers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
appwrite projects updateMockNumbers \
--projectId <PROJECT_ID> \
--numbers one two three
3 changes: 3 additions & 0 deletions docs/examples/projects/update-session-alerts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
appwrite projects updateSessionAlerts \
--projectId <PROJECT_ID> \
--alerts false
4 changes: 4 additions & 0 deletions docs/examples/users/create-j-w-t.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
appwrite users createJWT \
--userId <USER_ID> \


4 changes: 4 additions & 0 deletions docs/examples/vcs/get-repository-contents.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
appwrite vcs getRepositoryContents \
--installationId <INSTALLATION_ID> \
--providerRepositoryId <PROVIDER_REPOSITORY_ID> \

41 changes: 34 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ const chalk = require("chalk");
const { version } = require("./package.json");
const { commandDescriptions, cliConfig } = require("./lib/parser");
const { client } = require("./lib/commands/generic");
const { login, logout } = require("./lib/commands/generic");
const inquirer = require("inquirer");
const { login, logout, whoami, migrate, register } = require("./lib/commands/generic");
const { init } = require("./lib/commands/init");
const { deploy } = require("./lib/commands/deploy");
const { pull } = require("./lib/commands/pull");
const { run } = require("./lib/commands/run");
const { push } = require("./lib/commands/push");
const { account } = require("./lib/commands/account");
const { avatars } = require("./lib/commands/avatars");
const { assistant } = require("./lib/commands/assistant");
Expand All @@ -32,25 +35,49 @@ const { teams } = require("./lib/commands/teams");
const { users } = require("./lib/commands/users");
const { vcs } = require("./lib/commands/vcs");

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

program
.description(commandDescriptions['main'])
.configureHelp({
helpWidth: process.stdout.columns || 80,
sortSubcommands: true
})
.version(version, "-v, --version")
.option("--verbose", "Show complete error log")
.option("--json", "Output in JSON format")
.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 list of ids for a giving 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.opts().id;
})
.showSuggestionAfterError()
.addCommand(whoami)
.addCommand(register)
.addCommand(login)
.addCommand(init)
.addCommand(deploy)
.addCommand(pull)
.addCommand(push)
.addCommand(run)
.addCommand(logout)
.addCommand(account)
.addCommand(avatars)
Expand All @@ -72,5 +99,5 @@ program
.addCommand(vcs)
.addCommand(client)
.parse(process.argv);
process.stdout.columns = oldWidth;

process.stdout.columns = oldWidth;
2 changes: 1 addition & 1 deletion install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ function CleanUp {
function InstallCompleted {
Write-Host "[4/4] Finishing Installation ... "
cleanup
Write-Host "🤘 May the force be with you."
Write-Host "To get started with Appwrite CLI, please visit https://appwrite.io/docs/command-line"
Write-Host "As first step, you can login to your Appwrite account using 'appwrite login'"
}


Expand Down
2 changes: 1 addition & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ cleanup() {
installCompleted() {
echo "[4/4] Wrapping up installation ... "
cleanup
printf "🤘 May the force be with you. \n"
echo "🚀 To get started with Appwrite CLI, please visit https://appwrite.io/docs/command-line"
echo "As first step, you can login to your Appwrite account using 'appwrite login'"
}

# Installation Starts here
Expand Down
16 changes: 15 additions & 1 deletion lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ const { fetch, FormData, Agent } = require("undici");
const JSONbig = require("json-bigint")({ storeAsString: false });
const AppwriteException = require("./exception.js");
const { globalConfig } = require("./config.js");
const chalk = require("chalk");

class Client {
CHUNK_SIZE = 5*1024*1024; // 5MB

constructor() {
this.endpoint = 'https://cloud.appwrite.io/v1';
this.headers = {
Expand Down Expand Up @@ -182,6 +183,11 @@ class Client {
},
}),
});

const warnings = response.headers.get('x-appwrite-warning');
if (warnings) {
warnings.split(';').forEach((warning) => console.warn(warning));
}
} catch (error) {
throw new AppwriteException(error.message);
}
Expand All @@ -194,6 +200,14 @@ class Client {
} catch (error) {
throw new AppwriteException(text, response.status, "", text);
}

if (path !== '/account' && json.code === 401 && json.type === 'user_more_factors_required') {
console.log(`${chalk.cyan.bold("ℹ Info")} ${chalk.cyan("Unusable account found, removing...")}`);

const current = globalConfig.getCurrentSession();
globalConfig.setCurrentSession('');
globalConfig.removeSession(current);
}
throw new AppwriteException(json.message, json.code, json.type, json);
}

Expand Down
Loading

0 comments on commit 13312b5

Please sign in to comment.