Skip to content

Commit

Permalink
Merge pull request #619 from appwrite/fix-cli
Browse files Browse the repository at this point in the history
fix: cli errors
  • Loading branch information
christyjacob4 authored Feb 21, 2023
2 parents 115f6a9 + 91f05bb commit 898a066
Show file tree
Hide file tree
Showing 8 changed files with 244 additions and 146 deletions.
351 changes: 207 additions & 144 deletions composer.lock

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion templates/cli/index.js.twig
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
#! /usr/bin/env node

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

const program = require("commander");
const chalk = require("chalk");
const { version } = require("./package.json");
Expand All @@ -15,6 +21,10 @@ const { {{ service.name | caseLower }} } = require("./lib/commands/{{ service.na

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")
Expand All @@ -36,4 +46,5 @@ program
{% endfor %}
.addCommand(client)
.parse(process.argv);


process.stdout.columns = oldWidth;
4 changes: 3 additions & 1 deletion templates/cli/lib/commands/command.js.twig
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ const { sdkForProject, sdkForConsole } = require('../sdks')
const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
const { localConfig, globalConfig } = require("../config");

const {{ service.name | caseLower }} = new Command("{{ service.name | caseLower }}").description(commandDescriptions['{{ service.name | caseLower }}'])
const {{ service.name | caseLower }} = new Command("{{ service.name | caseLower }}").description(commandDescriptions['{{ service.name | caseLower }}']).configureHelp({
helpWidth: process.stdout.columns || 80
})

{% for method in service.methods %}
const {{ service.name | caseLower }}{{ method.name | caseUcfirst }} = async ({ {% for parameter in method.parameters.all %}{{ parameter.name | caseCamel | escapeKeyword }}, {% endfor %}parseOutput = true, sdk = undefined{% if 'multipart/form-data' in method.consumes %}, onProgress = () => {}{% endif %}{% if method.type == 'location' %}, destination{% endif %}}) => {
Expand Down
3 changes: 3 additions & 0 deletions templates/cli/lib/commands/deploy.js.twig
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ const awaitPools = {

const deploy = new Command("deploy")
.description(commandDescriptions['deploy'])
.configureHelp({
helpWidth: process.stdout.columns || 80
})
.action(actionRunner(async (_options, command) => {
command.help()
}));
Expand Down
9 changes: 9 additions & 0 deletions templates/cli/lib/commands/generic.js.twig
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ const { accountCreateEmailSession, accountDeleteSession } = require("./account")

const login = new Command("login")
.description(commandDescriptions['login'])
.configureHelp({
helpWidth: process.stdout.columns || 80
})
.action(actionRunner(async () => {
const answers = await inquirer.prompt(questionsLogin)

Expand All @@ -27,6 +30,9 @@ const login = new Command("login")

const logout = new Command("logout")
.description(commandDescriptions['logout'])
.configureHelp({
helpWidth: process.stdout.columns || 80
})
.action(actionRunner(async () => {
let client = await sdkForConsole();

Expand All @@ -43,6 +49,9 @@ const logout = new Command("logout")

const client = new Command("client")
.description(commandDescriptions['client'])
.configureHelp({
helpWidth: process.stdout.columns || 80
})
.option("--selfSigned <value>", "Configure the CLI to use a self-signed certificate ( true or false )", parseBool)
.option("--endpoint <endpoint>", "Set your Appwrite server endpoint")
.option("--projectId <projectId>", "Set your Appwrite project ID")
Expand Down
3 changes: 3 additions & 0 deletions templates/cli/lib/commands/init.js.twig
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ const { success, log, actionRunner, commandDescriptions } = require("../parser")

const init = new Command("init")
.description(commandDescriptions['init'])
.configureHelp({
helpWidth: process.stdout.columns || 80
})
.action(actionRunner(async (_options, command) => {
command.help();
}));
Expand Down
1 change: 1 addition & 0 deletions templates/cli/lib/parser.js.twig
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ const logo = {{ language.params.logo | raw }};

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, query and filter lists of documents.`,
"deploy": `The deploy command provides a convenient wrapper for deploying your functions and collections.`,
Expand Down

0 comments on commit 898a066

Please sign in to comment.