Skip to content

Commit

Permalink
fix: qa
Browse files Browse the repository at this point in the history
  • Loading branch information
TorstenDittmann committed Jul 8, 2024
1 parent 7650f48 commit c99bde3
Show file tree
Hide file tree
Showing 18 changed files with 465 additions and 401 deletions.
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
6.0.0-rc.1
6.0.0-rc.2
```

### 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
6.0.0-rc.1
6.0.0-rc.2
```

## Getting Started
Expand Down
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const { login, logout, whoami, migrate, register } = require("./lib/commands/gen
const { init } = require("./lib/commands/init");
const { pull } = require("./lib/commands/pull");
const { run } = require("./lib/commands/run");
const { push } = require("./lib/commands/push");
const { push, deploy } = require("./lib/commands/push");
const { account } = require("./lib/commands/account");
const { avatars } = require("./lib/commands/avatars");
const { assistant } = require("./lib/commands/assistant");
Expand Down Expand Up @@ -77,6 +77,7 @@ program
.addCommand(init)
.addCommand(pull)
.addCommand(push)
.addCommand(deploy)
.addCommand(run)
.addCommand(logout)
.addCommand(account)
Expand Down
4 changes: 2 additions & 2 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/6.0.0-rc.1/appwrite-cli-win-x64.exe"
$GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/6.0.0-rc.1/appwrite-cli-win-arm64.exe"
$GITHUB_x64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/6.0.0-rc.2/appwrite-cli-win-x64.exe"
$GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/6.0.0-rc.2/appwrite-cli-win-arm64.exe"

$APPWRITE_BINARY_NAME = "appwrite.exe"

Expand Down
2 changes: 1 addition & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ printSuccess() {
downloadBinary() {
echo "[2/4] Downloading executable for $OS ($ARCH) ..."

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

Expand Down
4 changes: 2 additions & 2 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class Client {
'x-sdk-name': 'Command Line',
'x-sdk-platform': 'console',
'x-sdk-language': 'cli',
'x-sdk-version': '6.0.0-rc.1',
'user-agent' : `AppwriteCLI/6.0.0-rc.1 (${os.type()} ${os.version()}; ${os.arch()})`,
'x-sdk-version': '6.0.0-rc.2',
'user-agent' : `AppwriteCLI/6.0.0-rc.2 (${os.type()} ${os.version()}; ${os.arch()})`,
'X-Appwrite-Response-Format' : '1.5.0',
};
}
Expand Down
22 changes: 17 additions & 5 deletions lib/commands/generic.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const { Command } = require("commander");
const Client = require("../client");
const { sdkForConsole } = require("../sdks");
const { globalConfig, localConfig } = require("../config");
const { actionRunner, success, parseBool, commandDescriptions, error, parse, log, drawTable, cliConfig } = require("../parser");
const { actionRunner, success, parseBool, commandDescriptions, error, parse, hint, log, drawTable, cliConfig } = require("../parser");
const ID = require("../id");
const { questionsLogin, questionsLogout, questionsListFactors, questionsMfaChallenge } = require("../questions");
const { accountUpdateMfaChallenge, accountCreateMfaChallenge, accountGet, accountCreateEmailPasswordSession, accountDeleteSession } = require("./account");
Expand All @@ -14,8 +14,20 @@ const loginCommand = async ({ email, password, endpoint, mfa, code }) => {
const oldCurrent = globalConfig.getCurrentSession();
let configEndpoint = endpoint ?? DEFAULT_ENDPOINT;

if(globalConfig.getCurrentSession() !== '') {
log('You are currently signed in as ' + globalConfig.getEmail());

if(globalConfig.getSessions().length === 1) {
hint('You can sign in and manage multiple accounts with Appwrite CLI');
}
}

const answers = email && password ? { email, password } : await inquirer.prompt(questionsLogin);

if(!answers.method) {
answers.method = 'login';
}

if (answers.method === 'select') {
const accountId = answers.accountId;

Expand Down Expand Up @@ -87,15 +99,15 @@ const loginCommand = async ({ email, password, endpoint, mfa, code }) => {
}
}

success("Signed in as user with ID: " + account.$id);
log("Next you can create or link to your project using 'appwrite init project'");
success("Successfully signed in as " + account.email);
hint("Next you can create or link to your project using 'appwrite init project'");
};

const whoami = new Command("whoami")
.description(commandDescriptions['whoami'])
.action(actionRunner(async () => {
if (globalConfig.getEndpoint() === '' || globalConfig.getCookie() === '') {
error("No user is signed in. To sign in, run: appwrite login ");
error("No user is signed in. To sign in, run 'appwrite login'");
return;
}

Expand All @@ -109,7 +121,7 @@ const whoami = new Command("whoami")
parseOutput: false
});
} catch (error) {
error("No user is signed in. To sign in, run: appwrite login");
error("No user is signed in. To sign in, run 'appwrite login'");
return;
}

Expand Down
41 changes: 26 additions & 15 deletions lib/commands/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const { storageCreateBucket } = require("./storage");
const { messagingCreateTopic } = require("./messaging");
const { functionsCreate } = require("./functions");
const { databasesCreateCollection } = require("./databases");
const { pullResources } = require("./pull");
const ID = require("../id");
const { localConfig, globalConfig } = require("../config");
const {
Expand All @@ -18,10 +19,11 @@ const {
questionsCreateMessagingTopic,
questionsCreateCollection,
questionsInitProject,
questionsInitProjectAutopull,
questionsInitResources,
questionsCreateTeam
} = require("../questions");
const { success, log, error, actionRunner, commandDescriptions } = require("../parser");
const { cliConfig, success, log, hint, error, actionRunner, commandDescriptions } = require("../parser");
const { accountGet } = require("./account");
const { sdkForConsole } = require("../sdks");

Expand Down Expand Up @@ -56,7 +58,7 @@ const initProject = async ({ organizationId, projectId, projectName } = {}) => {
sdk: client
});
} catch (e) {
error('Error Session not found. Please run `appwrite login` to create a session');
error("Error Session not found. Please run 'appwrite login' to create a session");
process.exit(1);
}

Expand Down Expand Up @@ -104,11 +106,17 @@ const initProject = async ({ organizationId, projectId, projectName } = {}) => {

success(`Project successfully ${answers.start === 'existing' ? 'linked' : 'created'}. Details are now stored in appwrite.json file.`);

log("Next you can use 'appwrite init' to create resources in your project, or use 'appwrite pull' and 'appwite push' to synchronize your project.")

if(answers.start === 'existing') {
log("Since you connected to an existing project, we highly recommend to run 'appwrite pull all' to synchronize all of your existing resources.");
answers = await inquirer.prompt(questionsInitProjectAutopull);
if(answers.autopull) {
cliConfig.all = true;
await pullResources();
} else {
log("You can run 'appwrite pull all' to synchronize all of your existing resources.");
}
}

hint("Next you can use 'appwrite init' to create resources in your project, or use 'appwrite pull' and 'appwrite push' to synchronize your project.")
}

const initBucket = async () => {
Expand Down Expand Up @@ -210,22 +218,24 @@ const initFunction = async () => {
log(`Installation command for this runtime not found. You will be asked to configure the install command when you first push the function.`);
}


fs.mkdirSync(functionDir, "777");
fs.mkdirSync(templatesDir, "777");
const repo = "https://github.com/appwrite/templates";
const api = `https://api.github.com/repos/appwrite/templates/contents/${answers.runtime.name}`
const templates = ['starter'];
let selected = undefined;

try {
const res = await fetch(api);
templates.push(...(await res.json()).map((template) => template.name));

selected = await inquirer.prompt(questionsCreateFunctionSelectTemplate(templates))
} catch {
// Not a problem will go with directory pulling
log('Loading templates...');
if(answers.template === 'starter') {
selected = { template: 'starter' };
} else {
try {
const res = await fetch(api);
const templates = [];
templates.push(...(await res.json()).map((template) => template.name));
selected = await inquirer.prompt(questionsCreateFunctionSelectTemplate(templates));
} catch {
// Not a problem will go with directory pulling
log('Loading templates...');
}
}

const sparse = (selected ? `${answers.runtime.name}/${selected.template}` : answers.runtime.name).toLowerCase();
Expand Down Expand Up @@ -257,6 +267,7 @@ const initFunction = async () => {

fs.rmSync(path.join(templatesDir, ".git"), { recursive: true });
if (!selected) {
const templates = [];
templates.push(...fs.readdirSync(runtimeDir, { withFileTypes: true })
.filter(item => item.isDirectory() && item.name !== 'starter')
.map(dirent => dirent.name));
Expand Down
Loading

0 comments on commit c99bde3

Please sign in to comment.