From 66765260581514ef45adb6be94050866257c0008 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Mon, 14 Oct 2024 17:46:27 +0100 Subject: [PATCH 1/3] fix: build and version --- .github/workflows/npm-publish.yml | 1 + README.md | 4 +- install.ps1 | 4 +- install.sh | 2 +- lib/client.js | 204 +++++++------- lib/parser.js | 431 ++++++++++++++++-------------- package.json | 2 +- scoop/appwrite.json | 48 ++-- 8 files changed, 362 insertions(+), 334 deletions(-) diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index 22d670e..c7eb01f 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -13,6 +13,7 @@ jobs: registry-url: 'https://registry.npmjs.org' - name: Setup binfmt with QEMU run: | + sudo apt update sudo apt install qemu binfmt-support qemu-user-static update-binfmts --display - name: Setup ldid diff --git a/README.md b/README.md index 792899e..4435c8f 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ Once the installation is complete, you can verify the install using ```sh $ appwrite -v -6.0.1 +6.1.0 ``` ### Install using prebuilt binaries @@ -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 -6.0.1 +6.1.0 ``` ## Getting Started diff --git a/install.ps1 b/install.ps1 index 6444c7d..d0245bb 100644 --- a/install.ps1 +++ b/install.ps1 @@ -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/6.0.1/appwrite-cli-win-x64.exe" -$GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/6.0.1/appwrite-cli-win-arm64.exe" +$GITHUB_x64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/6.1.0/appwrite-cli-win-x64.exe" +$GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/6.1.0/appwrite-cli-win-arm64.exe" $APPWRITE_BINARY_NAME = "appwrite.exe" diff --git a/install.sh b/install.sh index ae330ae..2158dc7 100644 --- a/install.sh +++ b/install.sh @@ -97,7 +97,7 @@ printSuccess() { downloadBinary() { echo "[2/4] Downloading executable for $OS ($ARCH) ..." - GITHUB_LATEST_VERSION="6.0.1" + GITHUB_LATEST_VERSION="6.1.0" GITHUB_FILE="appwrite-cli-${OS}-${ARCH}" GITHUB_URL="https://github.com/$GITHUB_REPOSITORY_NAME/releases/download/$GITHUB_LATEST_VERSION/$GITHUB_FILE" diff --git a/lib/client.js b/lib/client.js index a382649..bd055c4 100644 --- a/lib/client.js +++ b/lib/client.js @@ -1,4 +1,4 @@ -const os = require('os'); +const os = require("os"); const https = require("https"); const { fetch, FormData, Agent } = require("undici"); const JSONbig = require("json-bigint")({ storeAsString: false }); @@ -7,18 +7,18 @@ const { globalConfig } = require("./config.js"); const chalk = require("chalk"); class Client { - CHUNK_SIZE = 5*1024*1024; // 5MB + CHUNK_SIZE = 5 * 1024 * 1024; // 5MB constructor() { - this.endpoint = 'https://cloud.appwrite.io/v1'; + this.endpoint = "https://cloud.appwrite.io/v1"; this.headers = { - 'content-type': '', - 'x-sdk-name': 'Command Line', - 'x-sdk-platform': 'console', - 'x-sdk-language': 'cli', - 'x-sdk-version': '6.0.1', - 'user-agent' : `AppwriteCLI/6.0.1 (${os.type()} ${os.version()}; ${os.arch()})`, - 'X-Appwrite-Response-Format' : '1.6.0', + "content-type": "", + "x-sdk-name": "Command Line", + "x-sdk-platform": "console", + "x-sdk-language": "cli", + "x-sdk-version": "6.1.0", + "user-agent": `AppwriteCLI/6.1.0 (${os.type()} ${os.version()}; ${os.arch()})`, + "X-Appwrite-Response-Format": "1.6.0", }; } @@ -37,76 +37,76 @@ class Client { return this; } - /** - * Set Project - * - * Your project ID - * - * @param {string} project - * - * @return self - */ - setProject(project) { - this.addHeader('X-Appwrite-Project', project); - - return this; - } + /** + * Set Project + * + * Your project ID + * + * @param {string} project + * + * @return self + */ + setProject(project) { + this.addHeader("X-Appwrite-Project", project); - /** - * Set Key - * - * Your secret API key - * - * @param {string} key - * - * @return self - */ - setKey(key) { - this.addHeader('X-Appwrite-Key', key); - - return this; - } + return this; + } - /** - * Set JWT - * - * Your secret JSON Web Token - * - * @param {string} jwt - * - * @return self - */ - setJWT(jwt) { - this.addHeader('X-Appwrite-JWT', jwt); - - return this; - } + /** + * Set Key + * + * Your secret API key + * + * @param {string} key + * + * @return self + */ + setKey(key) { + this.addHeader("X-Appwrite-Key", key); - /** - * Set Locale - * - * @param {string} locale - * - * @return self - */ - setLocale(locale) { - this.addHeader('X-Appwrite-Locale', locale); - - return this; - } + return this; + } - /** - * Set Mode - * - * @param {string} mode - * - * @return self - */ - setMode(mode) { - this.addHeader('X-Appwrite-Mode', mode); - - return this; - } + /** + * Set JWT + * + * Your secret JSON Web Token + * + * @param {string} jwt + * + * @return self + */ + setJWT(jwt) { + this.addHeader("X-Appwrite-JWT", jwt); + + return this; + } + + /** + * Set Locale + * + * @param {string} locale + * + * @return self + */ + setLocale(locale) { + this.addHeader("X-Appwrite-Locale", locale); + + return this; + } + + /** + * Set Mode + * + * @param {string} mode + * + * @return self + */ + setMode(mode) { + this.addHeader("X-Appwrite-Mode", mode); + + return this; + } /** * Set self signed. @@ -144,26 +144,34 @@ class Client { return this; } - async call(method, path = "", headers = {}, params = {}, responseType = "json") { - headers = {...this.headers, ...headers}; + async call( + method, + path = "", + headers = {}, + params = {}, + responseType = "json" + ) { + headers = { ...this.headers, ...headers }; const url = new URL(this.endpoint + path); let body = undefined; if (method.toUpperCase() === "GET") { url.search = new URLSearchParams(Client.flatten(params)).toString(); - } else if (headers["content-type"]?.toLowerCase().startsWith("multipart/form-data")) { + } else if ( + headers["content-type"]?.toLowerCase().startsWith("multipart/form-data") + ) { delete headers["content-type"]; const formData = new FormData(); const flatParams = Client.flatten(params); for (const [key, value] of Object.entries(flatParams)) { - if (value && value.type && value.type === "file") { - formData.append(key, value.file, value.filename); - } else { - formData.append(key, value); - } + if (value && value.type && value.type === "file") { + formData.append(key, value.file, value.filename); + } else { + formData.append(key, value); + } } body = formData; @@ -178,15 +186,15 @@ class Client { headers, body, dispatcher: new Agent({ - connect: { - rejectUnauthorized: !this.selfSigned, - }, + connect: { + rejectUnauthorized: !this.selfSigned, + }, }), }); - const warnings = response.headers.get('x-appwrite-warning'); + const warnings = response.headers.get("x-appwrite-warning"); if (warnings) { - warnings.split(';').forEach((warning) => console.warn(warning)); + warnings.split(";").forEach((warning) => console.warn(warning)); } } catch (error) { throw new AppwriteException(error.message); @@ -201,11 +209,19 @@ class Client { 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...")}`); + 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.setCurrentSession(""); globalConfig.removeSession(current); } throw new AppwriteException(json.message, json.code, json.type, json); @@ -231,12 +247,12 @@ class Client { return json; } - static flatten(data, prefix = '') { + static flatten(data, prefix = "") { let output = {}; for (const key in data) { let value = data[key]; - let finalKey = prefix ? prefix + '[' + key +']' : key; + let finalKey = prefix ? prefix + "[" + key + "]" : key; if (Array.isArray(value)) { output = Object.assign(output, Client.flatten(value, finalKey)); // @todo: handle name collision here if needed diff --git a/lib/parser.js b/lib/parser.js index 233d69d..19a2bae 100644 --- a/lib/parser.js +++ b/lib/parser.js @@ -1,244 +1,265 @@ -const chalk = require('chalk'); -const commander = require('commander'); -const Table = require('cli-table3'); -const { description } = require('../package.json'); +const chalk = require("chalk"); +const commander = require("commander"); +const Table = require("cli-table3"); +const { description } = require("../package.json"); const { globalConfig } = require("./config.js"); -const os = require('os'); +const os = require("os"); const Client = require("./client"); const cliConfig = { - verbose: false, - json: false, - force: false, - all: false, - ids: [], - report: false, - reportData: {} + verbose: false, + json: false, + force: false, + all: false, + ids: [], + report: false, + reportData: {}, }; const parse = (data) => { - if (cliConfig.json) { - drawJSON(data); - return; - } + if (cliConfig.json) { + drawJSON(data); + return; + } - for (let key in data) { - if (Array.isArray(data[key])) { - console.log(`${chalk.yellow.bold.underline(key)}`); - if (typeof data[key][0] === 'object') { - drawTable(data[key]); - } else { - drawJSON(data[key]); - } - } else if (typeof data[key] === 'object') { - if (data[key]?.constructor?.name === 'BigNumber') { - console.log(`${chalk.yellow.bold(key)} : ${data[key]}`); - } else { - console.log(`${chalk.yellow.bold.underline(key)}`) - drawTable([data[key]]); - } - } else { - console.log(`${chalk.yellow.bold(key)} : ${data[key]}`); - } + for (let key in data) { + if (Array.isArray(data[key])) { + console.log(`${chalk.yellow.bold.underline(key)}`); + if (typeof data[key][0] === "object") { + drawTable(data[key]); + } else { + drawJSON(data[key]); + } + } else if (typeof data[key] === "object") { + if (data[key]?.constructor?.name === "BigNumber") { + console.log(`${chalk.yellow.bold(key)} : ${data[key]}`); + } else { + console.log(`${chalk.yellow.bold.underline(key)}`); + drawTable([data[key]]); + } + } else { + console.log(`${chalk.yellow.bold(key)} : ${data[key]}`); } -} + } +}; const drawTable = (data) => { - if (data.length == 0) { - console.log("[]") - return; - } + if (data.length == 0) { + console.log("[]"); + return; + } - // Create an object with all the keys in it - let obj = data.reduce((res, item) => ({ ...res, ...item })); - // Get those keys as an array - let keys = Object.keys(obj); - // Create an object with all keys set to the default value '' - let def = keys.reduce((result, key) => { - result[key] = '-' - return result; - }, {}); - // Use object destrucuring to replace all default values with the ones we have - data = data.map((item) => ({ ...def, ...item })); - - let columns = Object.keys(data[0]); - - let table = new Table({ - head: columns.map(c => chalk.cyan.italic.bold(c)), - chars: { - 'top': ' ', - 'top-mid': ' ', - 'top-left': ' ', - 'top-right': ' ', - 'bottom': ' ', - 'bottom-mid': ' ', - 'bottom-left': ' ', - 'bottom-right': ' ', - 'left': ' ', - 'left-mid': ' ', - 'mid': chalk.cyan('─'), - 'mid-mid': chalk.cyan('┼'), - 'right': ' ', - 'right-mid': ' ', - 'middle': chalk.cyan('│') - } - }); - - data.forEach(row => { - let rowValues = []; - for (let key in row) { - if (row[key] === null) { - rowValues.push("-"); - } else if (Array.isArray(row[key])) { - rowValues.push(JSON.stringify(row[key])); - } else if (typeof row[key] === 'object') { - rowValues.push(JSON.stringify(row[key])); - } else { - rowValues.push(row[key]); - } - } - table.push(rowValues); - }); - console.log(table.toString()); -} + // Create an object with all the keys in it + let obj = data.reduce((res, item) => ({ ...res, ...item })); + // Get those keys as an array + let keys = Object.keys(obj); + // Create an object with all keys set to the default value '' + let def = keys.reduce((result, key) => { + result[key] = "-"; + return result; + }, {}); + // Use object destrucuring to replace all default values with the ones we have + data = data.map((item) => ({ ...def, ...item })); + + let columns = Object.keys(data[0]); + + let table = new Table({ + head: columns.map((c) => chalk.cyan.italic.bold(c)), + chars: { + top: " ", + "top-mid": " ", + "top-left": " ", + "top-right": " ", + bottom: " ", + "bottom-mid": " ", + "bottom-left": " ", + "bottom-right": " ", + left: " ", + "left-mid": " ", + mid: chalk.cyan("─"), + "mid-mid": chalk.cyan("┼"), + right: " ", + "right-mid": " ", + middle: chalk.cyan("│"), + }, + }); + + data.forEach((row) => { + let rowValues = []; + for (let key in row) { + if (row[key] === null) { + rowValues.push("-"); + } else if (Array.isArray(row[key])) { + rowValues.push(JSON.stringify(row[key])); + } else if (typeof row[key] === "object") { + rowValues.push(JSON.stringify(row[key])); + } else { + rowValues.push(row[key]); + } + } + table.push(rowValues); + }); + console.log(table.toString()); +}; const drawJSON = (data) => { - console.log(JSON.stringify(data, null, 2)); -} + console.log(JSON.stringify(data, null, 2)); +}; const parseError = (err) => { - if (cliConfig.report) { - (async () => { - let appwriteVersion = 'unknown'; - const endpoint = globalConfig.getEndpoint(); - const isCloud = endpoint.includes('cloud.appwrite.io') ? 'Yes' : 'No'; - - try { - const client = new Client().setEndpoint(endpoint); - const res = await client.call('get', '/health/version'); - appwriteVersion = res.version; - } catch { - } - - const version = '6.0.1'; - const stepsToReproduce = `Running \`appwrite ${cliConfig.reportData.data.args.join(' ')}\``; - const yourEnvironment = `CLI version: ${version}\nOperation System: ${os.type()}\nAppwrite version: ${appwriteVersion}\nIs Cloud: ${isCloud}`; - - const stack = '```\n' + err.stack + '\n```'; - - const githubIssueUrl = new URL('https://github.com/appwrite/appwrite/issues/new'); - githubIssueUrl.searchParams.append('labels', 'bug'); - githubIssueUrl.searchParams.append('template', 'bug.yaml'); - githubIssueUrl.searchParams.append('title', `🐛 Bug Report: ${err.message}`); - githubIssueUrl.searchParams.append('actual-behavior', `CLI Error:\n${stack}`); - githubIssueUrl.searchParams.append('steps-to-reproduce', stepsToReproduce); - githubIssueUrl.searchParams.append('environment', yourEnvironment); - - log(`To report this error you can:\n - Create a support ticket in our Discord server https://appwrite.io/discord \n - Create an issue in our Github\n ${githubIssueUrl.href}\n`); - - - error('\n Stack Trace: \n'); - console.error(err); - process.exit(1); - })() + if (cliConfig.report) { + (async () => { + let appwriteVersion = "unknown"; + const endpoint = globalConfig.getEndpoint(); + const isCloud = endpoint.includes("cloud.appwrite.io") ? "Yes" : "No"; + + try { + const client = new Client().setEndpoint(endpoint); + const res = await client.call("get", "/health/version"); + appwriteVersion = res.version; + } catch {} + + const version = "6.1.0"; + const stepsToReproduce = `Running \`appwrite ${cliConfig.reportData.data.args.join( + " " + )}\``; + const yourEnvironment = `CLI version: ${version}\nOperation System: ${os.type()}\nAppwrite version: ${appwriteVersion}\nIs Cloud: ${isCloud}`; + + const stack = "```\n" + err.stack + "\n```"; + + const githubIssueUrl = new URL( + "https://github.com/appwrite/appwrite/issues/new" + ); + githubIssueUrl.searchParams.append("labels", "bug"); + githubIssueUrl.searchParams.append("template", "bug.yaml"); + githubIssueUrl.searchParams.append( + "title", + `🐛 Bug Report: ${err.message}` + ); + githubIssueUrl.searchParams.append( + "actual-behavior", + `CLI Error:\n${stack}` + ); + githubIssueUrl.searchParams.append( + "steps-to-reproduce", + stepsToReproduce + ); + githubIssueUrl.searchParams.append("environment", yourEnvironment); + + log( + `To report this error you can:\n - Create a support ticket in our Discord server https://appwrite.io/discord \n - Create an issue in our Github\n ${githubIssueUrl.href}\n` + ); + + error("\n Stack Trace: \n"); + console.error(err); + process.exit(1); + })(); + } else { + if (cliConfig.verbose) { + console.error(err); } else { - if (cliConfig.verbose) { - console.error(err); - } else { - log('For detailed error pass the --verbose or --report flag'); - error(err.message); - } - process.exit(1); + log("For detailed error pass the --verbose or --report flag"); + error(err.message); } - -} + process.exit(1); + } +}; const actionRunner = (fn) => { - return (...args) => { - if (cliConfig.all && (Array.isArray(cliConfig.ids) && cliConfig.ids.length !== 0)) { - error(`The '--all' and '--id' flags cannot be used together.`); - process.exit(1); - } - return fn(...args).catch(parseError) - }; -} + return (...args) => { + if ( + cliConfig.all && + Array.isArray(cliConfig.ids) && + cliConfig.ids.length !== 0 + ) { + error(`The '--all' and '--id' flags cannot be used together.`); + process.exit(1); + } + return fn(...args).catch(parseError); + }; +}; const parseInteger = (value) => { - const parsedValue = parseInt(value, 10); - if (isNaN(parsedValue)) { - throw new commander.InvalidArgumentError('Not a number.'); - } - return parsedValue; -} + const parsedValue = parseInt(value, 10); + if (isNaN(parsedValue)) { + throw new commander.InvalidArgumentError("Not a number."); + } + return parsedValue; +}; const parseBool = (value) => { - if (value === 'true') return true; - if (value === 'false') return false; - throw new commander.InvalidArgumentError('Not a boolean.'); -} + if (value === "true") return true; + if (value === "false") return false; + throw new commander.InvalidArgumentError("Not a boolean."); +}; const log = (message) => { - console.log(`${chalk.cyan.bold("ℹ Info:")} ${chalk.cyan(message ?? "")}`); -} + console.log(`${chalk.cyan.bold("ℹ Info:")} ${chalk.cyan(message ?? "")}`); +}; const warn = (message) => { - console.log(`${chalk.yellow.bold("ℹ Warning:")} ${chalk.yellow(message ?? "")}`); -} + console.log( + `${chalk.yellow.bold("ℹ Warning:")} ${chalk.yellow(message ?? "")}` + ); +}; const hint = (message) => { - console.log(`${chalk.cyan.bold("♥ Hint:")} ${chalk.cyan(message ?? "")}`); -} + console.log(`${chalk.cyan.bold("♥ Hint:")} ${chalk.cyan(message ?? "")}`); +}; const success = (message) => { - console.log(`${chalk.green.bold("✓ Success:")} ${chalk.green(message ?? "")}`); -} + console.log( + `${chalk.green.bold("✓ Success:")} ${chalk.green(message ?? "")}` + ); +}; const error = (message) => { - console.error(`${chalk.red.bold("✗ Error:")} ${chalk.red(message ?? "")}`); -} + console.error(`${chalk.red.bold("✗ Error:")} ${chalk.red(message ?? "")}`); +}; -const logo = "\n _ _ _ ___ __ _____\n \/_\\ _ __ _ ____ ___ __(_) |_ ___ \/ __\\ \/ \/ \\_ \\\n \/\/_\\\\| '_ \\| '_ \\ \\ \/\\ \/ \/ '__| | __\/ _ \\ \/ \/ \/ \/ \/ \/\\\/\n \/ _ \\ |_) | |_) \\ V V \/| | | | || __\/ \/ \/___\/ \/___\/\\\/ \/_\n \\_\/ \\_\/ .__\/| .__\/ \\_\/\\_\/ |_| |_|\\__\\___| \\____\/\\____\/\\____\/\n |_| |_|\n\n"; +const logo = + "\n _ _ _ ___ __ _____\n /_\\ _ __ _ ____ ___ __(_) |_ ___ / __\\ / / \\_ \\\n //_\\\\| '_ \\| '_ \\ \\ /\\ / / '__| | __/ _ \\ / / / / / /\\/\n / _ \\ |_) | |_) \\ V V /| | | | || __/ / /___/ /___/\\/ /_\n \\_/ \\_/ .__/| .__/ \\_/\\_/ |_| |_|\\__\\___| \\____/\\____/\\____/\n |_| |_|\n\n"; const commandDescriptions = { - "account": `The account command allows you to authenticate and manage a user account.`, - "graphql": `The graphql command allows you to query and mutate any resource type on your Appwrite server.`, - "avatars": `The avatars command aims to help you complete everyday tasks related to your app image, icons, and avatars.`, - "databases": `The databases command allows you to create structured collections of documents and query and filter lists of documents.`, - "init": `The init command provides a convenient wrapper for creating and initializing projects, functions, collections, buckets, teams, and messaging-topics in Appwrite.`, - "push": `The push command provides a convenient wrapper for pushing your functions, collections, buckets, teams, and messaging-topics.`, - "run": `The run command allows you to run the project locally to allow easy development and quick debugging.`, - "functions": `The functions command allows you to view, create, and manage your Cloud Functions.`, - "health": `The health command allows you to both validate and monitor your Appwrite server's health.`, - "pull": `The pull command helps you pull your Appwrite project, functions, collections, buckets, teams, and messaging-topics`, - "locale": `The locale command allows you to customize your app based on your users' location.`, - "storage": `The storage command allows you to manage your project files.`, - "teams": `The teams command allows you to group users of your project to enable them to share read and write access to your project resources.`, - "users": `The users command allows you to manage your project users.`, - "client": `The client command allows you to configure your CLI`, - "login": `The login command allows you to authenticate and manage a user account.`, - "logout": `The logout command allows you to log out of your Appwrite account.`, - "whoami": `The whomai command gives information about the currently logged-in user.`, - "register": `Outputs the link to create an Appwrite account.`, - "console" : `The console command gives you access to the APIs used by the Appwrite Console.`, - "assistant": `The assistant command allows you to interact with the Appwrite Assistant AI`, - "messaging": `The messaging command allows you to manage topics and targets and send messages.`, - "migrations": `The migrations command allows you to migrate data between services.`, - "vcs": `The vcs command allows you to interact with VCS providers and manage your code repositories.`, - "main": chalk.redBright(`${logo}${description}`), -} + account: `The account command allows you to authenticate and manage a user account.`, + graphql: `The graphql command allows you to query and mutate any resource type on your Appwrite server.`, + avatars: `The avatars command aims to help you complete everyday tasks related to your app image, icons, and avatars.`, + databases: `The databases command allows you to create structured collections of documents and query and filter lists of documents.`, + init: `The init command provides a convenient wrapper for creating and initializing projects, functions, collections, buckets, teams, and messaging-topics in Appwrite.`, + push: `The push command provides a convenient wrapper for pushing your functions, collections, buckets, teams, and messaging-topics.`, + run: `The run command allows you to run the project locally to allow easy development and quick debugging.`, + functions: `The functions command allows you to view, create, and manage your Cloud Functions.`, + health: `The health command allows you to both validate and monitor your Appwrite server's health.`, + pull: `The pull command helps you pull your Appwrite project, functions, collections, buckets, teams, and messaging-topics`, + locale: `The locale command allows you to customize your app based on your users' location.`, + storage: `The storage command allows you to manage your project files.`, + teams: `The teams command allows you to group users of your project to enable them to share read and write access to your project resources.`, + users: `The users command allows you to manage your project users.`, + client: `The client command allows you to configure your CLI`, + login: `The login command allows you to authenticate and manage a user account.`, + logout: `The logout command allows you to log out of your Appwrite account.`, + whoami: `The whomai command gives information about the currently logged-in user.`, + register: `Outputs the link to create an Appwrite account.`, + console: `The console command gives you access to the APIs used by the Appwrite Console.`, + assistant: `The assistant command allows you to interact with the Appwrite Assistant AI`, + messaging: `The messaging command allows you to manage topics and targets and send messages.`, + migrations: `The migrations command allows you to migrate data between services.`, + vcs: `The vcs command allows you to interact with VCS providers and manage your code repositories.`, + main: chalk.redBright(`${logo}${description}`), +}; module.exports = { - drawTable, - parse, - actionRunner, - parseInteger, - parseBool, - log, - warn, - hint, - success, - error, - commandDescriptions, - cliConfig, - drawTable -} + drawTable, + parse, + actionRunner, + parseInteger, + parseBool, + log, + warn, + hint, + success, + error, + commandDescriptions, + cliConfig, + drawTable, +}; diff --git a/package.json b/package.json index f42b92b..6484625 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "appwrite-cli", "homepage": "https://appwrite.io/support", "description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API", - "version": "6.0.1", + "version": "6.1.0", "license": "BSD-3-Clause", "main": "index.js", "bin": { diff --git a/scoop/appwrite.json b/scoop/appwrite.json index 730e70f..5ecb6cd 100644 --- a/scoop/appwrite.json +++ b/scoop/appwrite.json @@ -1,30 +1,20 @@ { - "$schema": "https://raw.githubusercontent.com/ScoopInstaller/Scoop/master/schema.json", - "version": "6.0.1", - "description": "The Appwrite CLI is a command-line application that allows you to interact with Appwrite and perform server-side tasks using your terminal.", - "homepage": "https://github.com/appwrite/sdk-for-cli", - "license": "BSD-3-Clause", - "architecture": { - "64bit": { - "url": "https://github.com/appwrite/sdk-for-cli/releases/download/6.0.1/appwrite-cli-win-x64.exe", - "bin": [ - [ - "appwrite-cli-win-x64.exe", - "appwrite" - ] - ] - }, - "arm64": { - "url": "https://github.com/appwrite/sdk-for-cli/releases/download/6.0.1/appwrite-cli-win-arm64.exe", - "bin": [ - [ - "appwrite-cli-win-arm64.exe", - "appwrite" - ] - ] - } - }, - "checkver": { - "github": "https://github.com/appwrite/sdk-for-cli" - } -} \ No newline at end of file + "$schema": "https://raw.githubusercontent.com/ScoopInstaller/Scoop/master/schema.json", + "version": "6.1.0", + "description": "The Appwrite CLI is a command-line application that allows you to interact with Appwrite and perform server-side tasks using your terminal.", + "homepage": "https://github.com/appwrite/sdk-for-cli", + "license": "BSD-3-Clause", + "architecture": { + "64bit": { + "url": "https://github.com/appwrite/sdk-for-cli/releases/download/6.1.0/appwrite-cli-win-x64.exe", + "bin": [["appwrite-cli-win-x64.exe", "appwrite"]] + }, + "arm64": { + "url": "https://github.com/appwrite/sdk-for-cli/releases/download/6.1.0/appwrite-cli-win-arm64.exe", + "bin": [["appwrite-cli-win-arm64.exe", "appwrite"]] + } + }, + "checkver": { + "github": "https://github.com/appwrite/sdk-for-cli" + } +} From d2e6b680d9cb7c01ed3f6778fd69c6bd1c8d1c4d Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Mon, 14 Oct 2024 17:55:14 +0100 Subject: [PATCH 2/3] Revert "fix: build and version" This reverts commit 66765260581514ef45adb6be94050866257c0008. --- .github/workflows/npm-publish.yml | 1 - README.md | 4 +- install.ps1 | 4 +- install.sh | 2 +- lib/client.js | 204 +++++++------- lib/parser.js | 431 ++++++++++++++---------------- package.json | 2 +- scoop/appwrite.json | 48 ++-- 8 files changed, 334 insertions(+), 362 deletions(-) diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index c7eb01f..22d670e 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -13,7 +13,6 @@ jobs: registry-url: 'https://registry.npmjs.org' - name: Setup binfmt with QEMU run: | - sudo apt update sudo apt install qemu binfmt-support qemu-user-static update-binfmts --display - name: Setup ldid diff --git a/README.md b/README.md index 4435c8f..792899e 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ Once the installation is complete, you can verify the install using ```sh $ appwrite -v -6.1.0 +6.0.1 ``` ### Install using prebuilt binaries @@ -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 -6.1.0 +6.0.1 ``` ## Getting Started diff --git a/install.ps1 b/install.ps1 index d0245bb..6444c7d 100644 --- a/install.ps1 +++ b/install.ps1 @@ -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/6.1.0/appwrite-cli-win-x64.exe" -$GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/6.1.0/appwrite-cli-win-arm64.exe" +$GITHUB_x64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/6.0.1/appwrite-cli-win-x64.exe" +$GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/6.0.1/appwrite-cli-win-arm64.exe" $APPWRITE_BINARY_NAME = "appwrite.exe" diff --git a/install.sh b/install.sh index 2158dc7..ae330ae 100644 --- a/install.sh +++ b/install.sh @@ -97,7 +97,7 @@ printSuccess() { downloadBinary() { echo "[2/4] Downloading executable for $OS ($ARCH) ..." - GITHUB_LATEST_VERSION="6.1.0" + GITHUB_LATEST_VERSION="6.0.1" GITHUB_FILE="appwrite-cli-${OS}-${ARCH}" GITHUB_URL="https://github.com/$GITHUB_REPOSITORY_NAME/releases/download/$GITHUB_LATEST_VERSION/$GITHUB_FILE" diff --git a/lib/client.js b/lib/client.js index bd055c4..a382649 100644 --- a/lib/client.js +++ b/lib/client.js @@ -1,4 +1,4 @@ -const os = require("os"); +const os = require('os'); const https = require("https"); const { fetch, FormData, Agent } = require("undici"); const JSONbig = require("json-bigint")({ storeAsString: false }); @@ -7,18 +7,18 @@ const { globalConfig } = require("./config.js"); const chalk = require("chalk"); class Client { - CHUNK_SIZE = 5 * 1024 * 1024; // 5MB + CHUNK_SIZE = 5*1024*1024; // 5MB constructor() { - this.endpoint = "https://cloud.appwrite.io/v1"; + this.endpoint = 'https://cloud.appwrite.io/v1'; this.headers = { - "content-type": "", - "x-sdk-name": "Command Line", - "x-sdk-platform": "console", - "x-sdk-language": "cli", - "x-sdk-version": "6.1.0", - "user-agent": `AppwriteCLI/6.1.0 (${os.type()} ${os.version()}; ${os.arch()})`, - "X-Appwrite-Response-Format": "1.6.0", + 'content-type': '', + 'x-sdk-name': 'Command Line', + 'x-sdk-platform': 'console', + 'x-sdk-language': 'cli', + 'x-sdk-version': '6.0.1', + 'user-agent' : `AppwriteCLI/6.0.1 (${os.type()} ${os.version()}; ${os.arch()})`, + 'X-Appwrite-Response-Format' : '1.6.0', }; } @@ -37,76 +37,76 @@ class Client { return this; } - /** - * Set Project - * - * Your project ID - * - * @param {string} project - * - * @return self - */ - setProject(project) { - this.addHeader("X-Appwrite-Project", project); - - return this; - } - - /** - * Set Key - * - * Your secret API key - * - * @param {string} key - * - * @return self - */ - setKey(key) { - this.addHeader("X-Appwrite-Key", key); - - return this; - } - - /** - * Set JWT - * - * Your secret JSON Web Token - * - * @param {string} jwt - * - * @return self - */ - setJWT(jwt) { - this.addHeader("X-Appwrite-JWT", jwt); - - return this; - } + /** + * Set Project + * + * Your project ID + * + * @param {string} project + * + * @return self + */ + setProject(project) { + this.addHeader('X-Appwrite-Project', project); + + return this; + } - /** - * Set Locale - * - * @param {string} locale - * - * @return self - */ - setLocale(locale) { - this.addHeader("X-Appwrite-Locale", locale); + /** + * Set Key + * + * Your secret API key + * + * @param {string} key + * + * @return self + */ + setKey(key) { + this.addHeader('X-Appwrite-Key', key); + + return this; + } - return this; - } + /** + * Set JWT + * + * Your secret JSON Web Token + * + * @param {string} jwt + * + * @return self + */ + setJWT(jwt) { + this.addHeader('X-Appwrite-JWT', jwt); + + return this; + } - /** - * Set Mode - * - * @param {string} mode - * - * @return self - */ - setMode(mode) { - this.addHeader("X-Appwrite-Mode", mode); + /** + * Set Locale + * + * @param {string} locale + * + * @return self + */ + setLocale(locale) { + this.addHeader('X-Appwrite-Locale', locale); + + return this; + } - return this; - } + /** + * Set Mode + * + * @param {string} mode + * + * @return self + */ + setMode(mode) { + this.addHeader('X-Appwrite-Mode', mode); + + return this; + } /** * Set self signed. @@ -144,34 +144,26 @@ class Client { return this; } - async call( - method, - path = "", - headers = {}, - params = {}, - responseType = "json" - ) { - headers = { ...this.headers, ...headers }; + async call(method, path = "", headers = {}, params = {}, responseType = "json") { + headers = {...this.headers, ...headers}; const url = new URL(this.endpoint + path); let body = undefined; if (method.toUpperCase() === "GET") { url.search = new URLSearchParams(Client.flatten(params)).toString(); - } else if ( - headers["content-type"]?.toLowerCase().startsWith("multipart/form-data") - ) { + } else if (headers["content-type"]?.toLowerCase().startsWith("multipart/form-data")) { delete headers["content-type"]; const formData = new FormData(); const flatParams = Client.flatten(params); for (const [key, value] of Object.entries(flatParams)) { - if (value && value.type && value.type === "file") { - formData.append(key, value.file, value.filename); - } else { - formData.append(key, value); - } + if (value && value.type && value.type === "file") { + formData.append(key, value.file, value.filename); + } else { + formData.append(key, value); + } } body = formData; @@ -186,15 +178,15 @@ class Client { headers, body, dispatcher: new Agent({ - connect: { - rejectUnauthorized: !this.selfSigned, - }, + connect: { + rejectUnauthorized: !this.selfSigned, + }, }), }); - const warnings = response.headers.get("x-appwrite-warning"); + const warnings = response.headers.get('x-appwrite-warning'); if (warnings) { - warnings.split(";").forEach((warning) => console.warn(warning)); + warnings.split(';').forEach((warning) => console.warn(warning)); } } catch (error) { throw new AppwriteException(error.message); @@ -209,19 +201,11 @@ class Client { 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..." - )}` - ); + 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.setCurrentSession(''); globalConfig.removeSession(current); } throw new AppwriteException(json.message, json.code, json.type, json); @@ -247,12 +231,12 @@ class Client { return json; } - static flatten(data, prefix = "") { + static flatten(data, prefix = '') { let output = {}; for (const key in data) { let value = data[key]; - let finalKey = prefix ? prefix + "[" + key + "]" : key; + let finalKey = prefix ? prefix + '[' + key +']' : key; if (Array.isArray(value)) { output = Object.assign(output, Client.flatten(value, finalKey)); // @todo: handle name collision here if needed diff --git a/lib/parser.js b/lib/parser.js index 19a2bae..233d69d 100644 --- a/lib/parser.js +++ b/lib/parser.js @@ -1,265 +1,244 @@ -const chalk = require("chalk"); -const commander = require("commander"); -const Table = require("cli-table3"); -const { description } = require("../package.json"); +const chalk = require('chalk'); +const commander = require('commander'); +const Table = require('cli-table3'); +const { description } = require('../package.json'); const { globalConfig } = require("./config.js"); -const os = require("os"); +const os = require('os'); const Client = require("./client"); const cliConfig = { - verbose: false, - json: false, - force: false, - all: false, - ids: [], - report: false, - reportData: {}, + verbose: false, + json: false, + force: false, + all: false, + ids: [], + report: false, + reportData: {} }; const parse = (data) => { - if (cliConfig.json) { - drawJSON(data); - return; - } + if (cliConfig.json) { + drawJSON(data); + return; + } - for (let key in data) { - if (Array.isArray(data[key])) { - console.log(`${chalk.yellow.bold.underline(key)}`); - if (typeof data[key][0] === "object") { - drawTable(data[key]); - } else { - drawJSON(data[key]); - } - } else if (typeof data[key] === "object") { - if (data[key]?.constructor?.name === "BigNumber") { - console.log(`${chalk.yellow.bold(key)} : ${data[key]}`); - } else { - console.log(`${chalk.yellow.bold.underline(key)}`); - drawTable([data[key]]); - } - } else { - console.log(`${chalk.yellow.bold(key)} : ${data[key]}`); + for (let key in data) { + if (Array.isArray(data[key])) { + console.log(`${chalk.yellow.bold.underline(key)}`); + if (typeof data[key][0] === 'object') { + drawTable(data[key]); + } else { + drawJSON(data[key]); + } + } else if (typeof data[key] === 'object') { + if (data[key]?.constructor?.name === 'BigNumber') { + console.log(`${chalk.yellow.bold(key)} : ${data[key]}`); + } else { + console.log(`${chalk.yellow.bold.underline(key)}`) + drawTable([data[key]]); + } + } else { + console.log(`${chalk.yellow.bold(key)} : ${data[key]}`); + } } - } -}; +} const drawTable = (data) => { - if (data.length == 0) { - console.log("[]"); - return; - } - - // Create an object with all the keys in it - let obj = data.reduce((res, item) => ({ ...res, ...item })); - // Get those keys as an array - let keys = Object.keys(obj); - // Create an object with all keys set to the default value '' - let def = keys.reduce((result, key) => { - result[key] = "-"; - return result; - }, {}); - // Use object destrucuring to replace all default values with the ones we have - data = data.map((item) => ({ ...def, ...item })); - - let columns = Object.keys(data[0]); - - let table = new Table({ - head: columns.map((c) => chalk.cyan.italic.bold(c)), - chars: { - top: " ", - "top-mid": " ", - "top-left": " ", - "top-right": " ", - bottom: " ", - "bottom-mid": " ", - "bottom-left": " ", - "bottom-right": " ", - left: " ", - "left-mid": " ", - mid: chalk.cyan("─"), - "mid-mid": chalk.cyan("┼"), - right: " ", - "right-mid": " ", - middle: chalk.cyan("│"), - }, - }); - - data.forEach((row) => { - let rowValues = []; - for (let key in row) { - if (row[key] === null) { - rowValues.push("-"); - } else if (Array.isArray(row[key])) { - rowValues.push(JSON.stringify(row[key])); - } else if (typeof row[key] === "object") { - rowValues.push(JSON.stringify(row[key])); - } else { - rowValues.push(row[key]); - } + if (data.length == 0) { + console.log("[]") + return; } - table.push(rowValues); - }); - console.log(table.toString()); -}; + + // Create an object with all the keys in it + let obj = data.reduce((res, item) => ({ ...res, ...item })); + // Get those keys as an array + let keys = Object.keys(obj); + // Create an object with all keys set to the default value '' + let def = keys.reduce((result, key) => { + result[key] = '-' + return result; + }, {}); + // Use object destrucuring to replace all default values with the ones we have + data = data.map((item) => ({ ...def, ...item })); + + let columns = Object.keys(data[0]); + + let table = new Table({ + head: columns.map(c => chalk.cyan.italic.bold(c)), + chars: { + 'top': ' ', + 'top-mid': ' ', + 'top-left': ' ', + 'top-right': ' ', + 'bottom': ' ', + 'bottom-mid': ' ', + 'bottom-left': ' ', + 'bottom-right': ' ', + 'left': ' ', + 'left-mid': ' ', + 'mid': chalk.cyan('─'), + 'mid-mid': chalk.cyan('┼'), + 'right': ' ', + 'right-mid': ' ', + 'middle': chalk.cyan('│') + } + }); + + data.forEach(row => { + let rowValues = []; + for (let key in row) { + if (row[key] === null) { + rowValues.push("-"); + } else if (Array.isArray(row[key])) { + rowValues.push(JSON.stringify(row[key])); + } else if (typeof row[key] === 'object') { + rowValues.push(JSON.stringify(row[key])); + } else { + rowValues.push(row[key]); + } + } + table.push(rowValues); + }); + console.log(table.toString()); +} const drawJSON = (data) => { - console.log(JSON.stringify(data, null, 2)); -}; + console.log(JSON.stringify(data, null, 2)); +} const parseError = (err) => { - if (cliConfig.report) { - (async () => { - let appwriteVersion = "unknown"; - const endpoint = globalConfig.getEndpoint(); - const isCloud = endpoint.includes("cloud.appwrite.io") ? "Yes" : "No"; - - try { - const client = new Client().setEndpoint(endpoint); - const res = await client.call("get", "/health/version"); - appwriteVersion = res.version; - } catch {} - - const version = "6.1.0"; - const stepsToReproduce = `Running \`appwrite ${cliConfig.reportData.data.args.join( - " " - )}\``; - const yourEnvironment = `CLI version: ${version}\nOperation System: ${os.type()}\nAppwrite version: ${appwriteVersion}\nIs Cloud: ${isCloud}`; - - const stack = "```\n" + err.stack + "\n```"; - - const githubIssueUrl = new URL( - "https://github.com/appwrite/appwrite/issues/new" - ); - githubIssueUrl.searchParams.append("labels", "bug"); - githubIssueUrl.searchParams.append("template", "bug.yaml"); - githubIssueUrl.searchParams.append( - "title", - `🐛 Bug Report: ${err.message}` - ); - githubIssueUrl.searchParams.append( - "actual-behavior", - `CLI Error:\n${stack}` - ); - githubIssueUrl.searchParams.append( - "steps-to-reproduce", - stepsToReproduce - ); - githubIssueUrl.searchParams.append("environment", yourEnvironment); - - log( - `To report this error you can:\n - Create a support ticket in our Discord server https://appwrite.io/discord \n - Create an issue in our Github\n ${githubIssueUrl.href}\n` - ); - - error("\n Stack Trace: \n"); - console.error(err); - process.exit(1); - })(); - } else { - if (cliConfig.verbose) { - console.error(err); + if (cliConfig.report) { + (async () => { + let appwriteVersion = 'unknown'; + const endpoint = globalConfig.getEndpoint(); + const isCloud = endpoint.includes('cloud.appwrite.io') ? 'Yes' : 'No'; + + try { + const client = new Client().setEndpoint(endpoint); + const res = await client.call('get', '/health/version'); + appwriteVersion = res.version; + } catch { + } + + const version = '6.0.1'; + const stepsToReproduce = `Running \`appwrite ${cliConfig.reportData.data.args.join(' ')}\``; + const yourEnvironment = `CLI version: ${version}\nOperation System: ${os.type()}\nAppwrite version: ${appwriteVersion}\nIs Cloud: ${isCloud}`; + + const stack = '```\n' + err.stack + '\n```'; + + const githubIssueUrl = new URL('https://github.com/appwrite/appwrite/issues/new'); + githubIssueUrl.searchParams.append('labels', 'bug'); + githubIssueUrl.searchParams.append('template', 'bug.yaml'); + githubIssueUrl.searchParams.append('title', `🐛 Bug Report: ${err.message}`); + githubIssueUrl.searchParams.append('actual-behavior', `CLI Error:\n${stack}`); + githubIssueUrl.searchParams.append('steps-to-reproduce', stepsToReproduce); + githubIssueUrl.searchParams.append('environment', yourEnvironment); + + log(`To report this error you can:\n - Create a support ticket in our Discord server https://appwrite.io/discord \n - Create an issue in our Github\n ${githubIssueUrl.href}\n`); + + + error('\n Stack Trace: \n'); + console.error(err); + process.exit(1); + })() } else { - log("For detailed error pass the --verbose or --report flag"); - error(err.message); + if (cliConfig.verbose) { + console.error(err); + } else { + log('For detailed error pass the --verbose or --report flag'); + error(err.message); + } + process.exit(1); } - process.exit(1); - } -}; + +} const actionRunner = (fn) => { - return (...args) => { - if ( - cliConfig.all && - Array.isArray(cliConfig.ids) && - cliConfig.ids.length !== 0 - ) { - error(`The '--all' and '--id' flags cannot be used together.`); - process.exit(1); - } - return fn(...args).catch(parseError); - }; -}; + return (...args) => { + if (cliConfig.all && (Array.isArray(cliConfig.ids) && cliConfig.ids.length !== 0)) { + error(`The '--all' and '--id' flags cannot be used together.`); + process.exit(1); + } + return fn(...args).catch(parseError) + }; +} const parseInteger = (value) => { - const parsedValue = parseInt(value, 10); - if (isNaN(parsedValue)) { - throw new commander.InvalidArgumentError("Not a number."); - } - return parsedValue; -}; + const parsedValue = parseInt(value, 10); + if (isNaN(parsedValue)) { + throw new commander.InvalidArgumentError('Not a number.'); + } + return parsedValue; +} const parseBool = (value) => { - if (value === "true") return true; - if (value === "false") return false; - throw new commander.InvalidArgumentError("Not a boolean."); -}; + if (value === 'true') return true; + if (value === 'false') return false; + throw new commander.InvalidArgumentError('Not a boolean.'); +} const log = (message) => { - console.log(`${chalk.cyan.bold("ℹ Info:")} ${chalk.cyan(message ?? "")}`); -}; + console.log(`${chalk.cyan.bold("ℹ Info:")} ${chalk.cyan(message ?? "")}`); +} const warn = (message) => { - console.log( - `${chalk.yellow.bold("ℹ Warning:")} ${chalk.yellow(message ?? "")}` - ); -}; + console.log(`${chalk.yellow.bold("ℹ Warning:")} ${chalk.yellow(message ?? "")}`); +} const hint = (message) => { - console.log(`${chalk.cyan.bold("♥ Hint:")} ${chalk.cyan(message ?? "")}`); -}; + console.log(`${chalk.cyan.bold("♥ Hint:")} ${chalk.cyan(message ?? "")}`); +} const success = (message) => { - console.log( - `${chalk.green.bold("✓ Success:")} ${chalk.green(message ?? "")}` - ); -}; + console.log(`${chalk.green.bold("✓ Success:")} ${chalk.green(message ?? "")}`); +} const error = (message) => { - console.error(`${chalk.red.bold("✗ Error:")} ${chalk.red(message ?? "")}`); -}; + console.error(`${chalk.red.bold("✗ Error:")} ${chalk.red(message ?? "")}`); +} -const logo = - "\n _ _ _ ___ __ _____\n /_\\ _ __ _ ____ ___ __(_) |_ ___ / __\\ / / \\_ \\\n //_\\\\| '_ \\| '_ \\ \\ /\\ / / '__| | __/ _ \\ / / / / / /\\/\n / _ \\ |_) | |_) \\ V V /| | | | || __/ / /___/ /___/\\/ /_\n \\_/ \\_/ .__/| .__/ \\_/\\_/ |_| |_|\\__\\___| \\____/\\____/\\____/\n |_| |_|\n\n"; +const logo = "\n _ _ _ ___ __ _____\n \/_\\ _ __ _ ____ ___ __(_) |_ ___ \/ __\\ \/ \/ \\_ \\\n \/\/_\\\\| '_ \\| '_ \\ \\ \/\\ \/ \/ '__| | __\/ _ \\ \/ \/ \/ \/ \/ \/\\\/\n \/ _ \\ |_) | |_) \\ V V \/| | | | || __\/ \/ \/___\/ \/___\/\\\/ \/_\n \\_\/ \\_\/ .__\/| .__\/ \\_\/\\_\/ |_| |_|\\__\\___| \\____\/\\____\/\\____\/\n |_| |_|\n\n"; const commandDescriptions = { - account: `The account command allows you to authenticate and manage a user account.`, - graphql: `The graphql command allows you to query and mutate any resource type on your Appwrite server.`, - avatars: `The avatars command aims to help you complete everyday tasks related to your app image, icons, and avatars.`, - databases: `The databases command allows you to create structured collections of documents and query and filter lists of documents.`, - init: `The init command provides a convenient wrapper for creating and initializing projects, functions, collections, buckets, teams, and messaging-topics in Appwrite.`, - push: `The push command provides a convenient wrapper for pushing your functions, collections, buckets, teams, and messaging-topics.`, - run: `The run command allows you to run the project locally to allow easy development and quick debugging.`, - functions: `The functions command allows you to view, create, and manage your Cloud Functions.`, - health: `The health command allows you to both validate and monitor your Appwrite server's health.`, - pull: `The pull command helps you pull your Appwrite project, functions, collections, buckets, teams, and messaging-topics`, - locale: `The locale command allows you to customize your app based on your users' location.`, - storage: `The storage command allows you to manage your project files.`, - teams: `The teams command allows you to group users of your project to enable them to share read and write access to your project resources.`, - users: `The users command allows you to manage your project users.`, - client: `The client command allows you to configure your CLI`, - login: `The login command allows you to authenticate and manage a user account.`, - logout: `The logout command allows you to log out of your Appwrite account.`, - whoami: `The whomai command gives information about the currently logged-in user.`, - register: `Outputs the link to create an Appwrite account.`, - console: `The console command gives you access to the APIs used by the Appwrite Console.`, - assistant: `The assistant command allows you to interact with the Appwrite Assistant AI`, - messaging: `The messaging command allows you to manage topics and targets and send messages.`, - migrations: `The migrations command allows you to migrate data between services.`, - vcs: `The vcs command allows you to interact with VCS providers and manage your code repositories.`, - main: chalk.redBright(`${logo}${description}`), -}; + "account": `The account command allows you to authenticate and manage a user account.`, + "graphql": `The graphql command allows you to query and mutate any resource type on your Appwrite server.`, + "avatars": `The avatars command aims to help you complete everyday tasks related to your app image, icons, and avatars.`, + "databases": `The databases command allows you to create structured collections of documents and query and filter lists of documents.`, + "init": `The init command provides a convenient wrapper for creating and initializing projects, functions, collections, buckets, teams, and messaging-topics in Appwrite.`, + "push": `The push command provides a convenient wrapper for pushing your functions, collections, buckets, teams, and messaging-topics.`, + "run": `The run command allows you to run the project locally to allow easy development and quick debugging.`, + "functions": `The functions command allows you to view, create, and manage your Cloud Functions.`, + "health": `The health command allows you to both validate and monitor your Appwrite server's health.`, + "pull": `The pull command helps you pull your Appwrite project, functions, collections, buckets, teams, and messaging-topics`, + "locale": `The locale command allows you to customize your app based on your users' location.`, + "storage": `The storage command allows you to manage your project files.`, + "teams": `The teams command allows you to group users of your project to enable them to share read and write access to your project resources.`, + "users": `The users command allows you to manage your project users.`, + "client": `The client command allows you to configure your CLI`, + "login": `The login command allows you to authenticate and manage a user account.`, + "logout": `The logout command allows you to log out of your Appwrite account.`, + "whoami": `The whomai command gives information about the currently logged-in user.`, + "register": `Outputs the link to create an Appwrite account.`, + "console" : `The console command gives you access to the APIs used by the Appwrite Console.`, + "assistant": `The assistant command allows you to interact with the Appwrite Assistant AI`, + "messaging": `The messaging command allows you to manage topics and targets and send messages.`, + "migrations": `The migrations command allows you to migrate data between services.`, + "vcs": `The vcs command allows you to interact with VCS providers and manage your code repositories.`, + "main": chalk.redBright(`${logo}${description}`), +} module.exports = { - drawTable, - parse, - actionRunner, - parseInteger, - parseBool, - log, - warn, - hint, - success, - error, - commandDescriptions, - cliConfig, - drawTable, -}; + drawTable, + parse, + actionRunner, + parseInteger, + parseBool, + log, + warn, + hint, + success, + error, + commandDescriptions, + cliConfig, + drawTable +} diff --git a/package.json b/package.json index 6484625..f42b92b 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "appwrite-cli", "homepage": "https://appwrite.io/support", "description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API", - "version": "6.1.0", + "version": "6.0.1", "license": "BSD-3-Clause", "main": "index.js", "bin": { diff --git a/scoop/appwrite.json b/scoop/appwrite.json index 5ecb6cd..730e70f 100644 --- a/scoop/appwrite.json +++ b/scoop/appwrite.json @@ -1,20 +1,30 @@ { - "$schema": "https://raw.githubusercontent.com/ScoopInstaller/Scoop/master/schema.json", - "version": "6.1.0", - "description": "The Appwrite CLI is a command-line application that allows you to interact with Appwrite and perform server-side tasks using your terminal.", - "homepage": "https://github.com/appwrite/sdk-for-cli", - "license": "BSD-3-Clause", - "architecture": { - "64bit": { - "url": "https://github.com/appwrite/sdk-for-cli/releases/download/6.1.0/appwrite-cli-win-x64.exe", - "bin": [["appwrite-cli-win-x64.exe", "appwrite"]] - }, - "arm64": { - "url": "https://github.com/appwrite/sdk-for-cli/releases/download/6.1.0/appwrite-cli-win-arm64.exe", - "bin": [["appwrite-cli-win-arm64.exe", "appwrite"]] - } - }, - "checkver": { - "github": "https://github.com/appwrite/sdk-for-cli" - } -} + "$schema": "https://raw.githubusercontent.com/ScoopInstaller/Scoop/master/schema.json", + "version": "6.0.1", + "description": "The Appwrite CLI is a command-line application that allows you to interact with Appwrite and perform server-side tasks using your terminal.", + "homepage": "https://github.com/appwrite/sdk-for-cli", + "license": "BSD-3-Clause", + "architecture": { + "64bit": { + "url": "https://github.com/appwrite/sdk-for-cli/releases/download/6.0.1/appwrite-cli-win-x64.exe", + "bin": [ + [ + "appwrite-cli-win-x64.exe", + "appwrite" + ] + ] + }, + "arm64": { + "url": "https://github.com/appwrite/sdk-for-cli/releases/download/6.0.1/appwrite-cli-win-arm64.exe", + "bin": [ + [ + "appwrite-cli-win-arm64.exe", + "appwrite" + ] + ] + } + }, + "checkver": { + "github": "https://github.com/appwrite/sdk-for-cli" + } +} \ No newline at end of file From 1c5079b3022ba471a8521322da402a1b14630ab2 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Mon, 14 Oct 2024 17:58:09 +0100 Subject: [PATCH 3/3] fix: build and version --- .github/workflows/npm-publish.yml | 1 + README.md | 4 ++-- install.ps1 | 4 ++-- install.sh | 2 +- lib/client.js | 4 ++-- lib/parser.js | 2 +- package.json | 2 +- scoop/appwrite.json | 6 +++--- 8 files changed, 13 insertions(+), 12 deletions(-) diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index 22d670e..c7eb01f 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -13,6 +13,7 @@ jobs: registry-url: 'https://registry.npmjs.org' - name: Setup binfmt with QEMU run: | + sudo apt update sudo apt install qemu binfmt-support qemu-user-static update-binfmts --display - name: Setup ldid diff --git a/README.md b/README.md index 792899e..4435c8f 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ Once the installation is complete, you can verify the install using ```sh $ appwrite -v -6.0.1 +6.1.0 ``` ### Install using prebuilt binaries @@ -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 -6.0.1 +6.1.0 ``` ## Getting Started diff --git a/install.ps1 b/install.ps1 index 6444c7d..d0245bb 100644 --- a/install.ps1 +++ b/install.ps1 @@ -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/6.0.1/appwrite-cli-win-x64.exe" -$GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/6.0.1/appwrite-cli-win-arm64.exe" +$GITHUB_x64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/6.1.0/appwrite-cli-win-x64.exe" +$GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/6.1.0/appwrite-cli-win-arm64.exe" $APPWRITE_BINARY_NAME = "appwrite.exe" diff --git a/install.sh b/install.sh index ae330ae..2158dc7 100644 --- a/install.sh +++ b/install.sh @@ -97,7 +97,7 @@ printSuccess() { downloadBinary() { echo "[2/4] Downloading executable for $OS ($ARCH) ..." - GITHUB_LATEST_VERSION="6.0.1" + GITHUB_LATEST_VERSION="6.1.0" GITHUB_FILE="appwrite-cli-${OS}-${ARCH}" GITHUB_URL="https://github.com/$GITHUB_REPOSITORY_NAME/releases/download/$GITHUB_LATEST_VERSION/$GITHUB_FILE" diff --git a/lib/client.js b/lib/client.js index a382649..9a39a56 100644 --- a/lib/client.js +++ b/lib/client.js @@ -16,8 +16,8 @@ class Client { 'x-sdk-name': 'Command Line', 'x-sdk-platform': 'console', 'x-sdk-language': 'cli', - 'x-sdk-version': '6.0.1', - 'user-agent' : `AppwriteCLI/6.0.1 (${os.type()} ${os.version()}; ${os.arch()})`, + 'x-sdk-version': '6.1.0', + 'user-agent' : `AppwriteCLI/6.1.0 (${os.type()} ${os.version()}; ${os.arch()})`, 'X-Appwrite-Response-Format' : '1.6.0', }; } diff --git a/lib/parser.js b/lib/parser.js index 233d69d..a6a0182 100644 --- a/lib/parser.js +++ b/lib/parser.js @@ -120,7 +120,7 @@ const parseError = (err) => { } catch { } - const version = '6.0.1'; + const version = '6.1.0'; const stepsToReproduce = `Running \`appwrite ${cliConfig.reportData.data.args.join(' ')}\``; const yourEnvironment = `CLI version: ${version}\nOperation System: ${os.type()}\nAppwrite version: ${appwriteVersion}\nIs Cloud: ${isCloud}`; diff --git a/package.json b/package.json index f42b92b..6484625 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "appwrite-cli", "homepage": "https://appwrite.io/support", "description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API", - "version": "6.0.1", + "version": "6.1.0", "license": "BSD-3-Clause", "main": "index.js", "bin": { diff --git a/scoop/appwrite.json b/scoop/appwrite.json index 730e70f..bd73b6d 100644 --- a/scoop/appwrite.json +++ b/scoop/appwrite.json @@ -1,12 +1,12 @@ { "$schema": "https://raw.githubusercontent.com/ScoopInstaller/Scoop/master/schema.json", - "version": "6.0.1", + "version": "6.1.0", "description": "The Appwrite CLI is a command-line application that allows you to interact with Appwrite and perform server-side tasks using your terminal.", "homepage": "https://github.com/appwrite/sdk-for-cli", "license": "BSD-3-Clause", "architecture": { "64bit": { - "url": "https://github.com/appwrite/sdk-for-cli/releases/download/6.0.1/appwrite-cli-win-x64.exe", + "url": "https://github.com/appwrite/sdk-for-cli/releases/download/6.1.0/appwrite-cli-win-x64.exe", "bin": [ [ "appwrite-cli-win-x64.exe", @@ -15,7 +15,7 @@ ] }, "arm64": { - "url": "https://github.com/appwrite/sdk-for-cli/releases/download/6.0.1/appwrite-cli-win-arm64.exe", + "url": "https://github.com/appwrite/sdk-for-cli/releases/download/6.1.0/appwrite-cli-win-arm64.exe", "bin": [ [ "appwrite-cli-win-arm64.exe",