Skip to content

Commit c99bde3

Browse files
fix: qa
1 parent 7650f48 commit c99bde3

File tree

18 files changed

+465
-401
lines changed

18 files changed

+465
-401
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Once the installation is complete, you can verify the install using
2929

3030
```sh
3131
$ appwrite -v
32-
6.0.0-rc.1
32+
6.0.0-rc.2
3333
```
3434

3535
### Install using prebuilt binaries
@@ -60,7 +60,7 @@ $ scoop install https://raw.githubusercontent.com/appwrite/sdk-for-cli/master/sc
6060
Once the installation completes, you can verify your install using
6161
```
6262
$ appwrite -v
63-
6.0.0-rc.1
63+
6.0.0-rc.2
6464
```
6565

6666
## Getting Started

index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const { login, logout, whoami, migrate, register } = require("./lib/commands/gen
1515
const { init } = require("./lib/commands/init");
1616
const { pull } = require("./lib/commands/pull");
1717
const { run } = require("./lib/commands/run");
18-
const { push } = require("./lib/commands/push");
18+
const { push, deploy } = require("./lib/commands/push");
1919
const { account } = require("./lib/commands/account");
2020
const { avatars } = require("./lib/commands/avatars");
2121
const { assistant } = require("./lib/commands/assistant");
@@ -77,6 +77,7 @@ program
7777
.addCommand(init)
7878
.addCommand(pull)
7979
.addCommand(push)
80+
.addCommand(deploy)
8081
.addCommand(run)
8182
.addCommand(logout)
8283
.addCommand(account)

install.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
# You can use "View source" of this page to see the full script.
1414

1515
# REPO
16-
$GITHUB_x64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/6.0.0-rc.1/appwrite-cli-win-x64.exe"
17-
$GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/6.0.0-rc.1/appwrite-cli-win-arm64.exe"
16+
$GITHUB_x64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/6.0.0-rc.2/appwrite-cli-win-x64.exe"
17+
$GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/6.0.0-rc.2/appwrite-cli-win-arm64.exe"
1818

1919
$APPWRITE_BINARY_NAME = "appwrite.exe"
2020

install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ printSuccess() {
9797
downloadBinary() {
9898
echo "[2/4] Downloading executable for $OS ($ARCH) ..."
9999

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

lib/client.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ class Client {
1616
'x-sdk-name': 'Command Line',
1717
'x-sdk-platform': 'console',
1818
'x-sdk-language': 'cli',
19-
'x-sdk-version': '6.0.0-rc.1',
20-
'user-agent' : `AppwriteCLI/6.0.0-rc.1 (${os.type()} ${os.version()}; ${os.arch()})`,
19+
'x-sdk-version': '6.0.0-rc.2',
20+
'user-agent' : `AppwriteCLI/6.0.0-rc.2 (${os.type()} ${os.version()}; ${os.arch()})`,
2121
'X-Appwrite-Response-Format' : '1.5.0',
2222
};
2323
}

lib/commands/generic.js

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const { Command } = require("commander");
33
const Client = require("../client");
44
const { sdkForConsole } = require("../sdks");
55
const { globalConfig, localConfig } = require("../config");
6-
const { actionRunner, success, parseBool, commandDescriptions, error, parse, log, drawTable, cliConfig } = require("../parser");
6+
const { actionRunner, success, parseBool, commandDescriptions, error, parse, hint, log, drawTable, cliConfig } = require("../parser");
77
const ID = require("../id");
88
const { questionsLogin, questionsLogout, questionsListFactors, questionsMfaChallenge } = require("../questions");
99
const { accountUpdateMfaChallenge, accountCreateMfaChallenge, accountGet, accountCreateEmailPasswordSession, accountDeleteSession } = require("./account");
@@ -14,8 +14,20 @@ const loginCommand = async ({ email, password, endpoint, mfa, code }) => {
1414
const oldCurrent = globalConfig.getCurrentSession();
1515
let configEndpoint = endpoint ?? DEFAULT_ENDPOINT;
1616

17+
if(globalConfig.getCurrentSession() !== '') {
18+
log('You are currently signed in as ' + globalConfig.getEmail());
19+
20+
if(globalConfig.getSessions().length === 1) {
21+
hint('You can sign in and manage multiple accounts with Appwrite CLI');
22+
}
23+
}
24+
1725
const answers = email && password ? { email, password } : await inquirer.prompt(questionsLogin);
1826

27+
if(!answers.method) {
28+
answers.method = 'login';
29+
}
30+
1931
if (answers.method === 'select') {
2032
const accountId = answers.accountId;
2133

@@ -87,15 +99,15 @@ const loginCommand = async ({ email, password, endpoint, mfa, code }) => {
8799
}
88100
}
89101

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

94106
const whoami = new Command("whoami")
95107
.description(commandDescriptions['whoami'])
96108
.action(actionRunner(async () => {
97109
if (globalConfig.getEndpoint() === '' || globalConfig.getCookie() === '') {
98-
error("No user is signed in. To sign in, run: appwrite login ");
110+
error("No user is signed in. To sign in, run 'appwrite login'");
99111
return;
100112
}
101113

@@ -109,7 +121,7 @@ const whoami = new Command("whoami")
109121
parseOutput: false
110122
});
111123
} catch (error) {
112-
error("No user is signed in. To sign in, run: appwrite login");
124+
error("No user is signed in. To sign in, run 'appwrite login'");
113125
return;
114126
}
115127

lib/commands/init.js

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const { storageCreateBucket } = require("./storage");
99
const { messagingCreateTopic } = require("./messaging");
1010
const { functionsCreate } = require("./functions");
1111
const { databasesCreateCollection } = require("./databases");
12+
const { pullResources } = require("./pull");
1213
const ID = require("../id");
1314
const { localConfig, globalConfig } = require("../config");
1415
const {
@@ -18,10 +19,11 @@ const {
1819
questionsCreateMessagingTopic,
1920
questionsCreateCollection,
2021
questionsInitProject,
22+
questionsInitProjectAutopull,
2123
questionsInitResources,
2224
questionsCreateTeam
2325
} = require("../questions");
24-
const { success, log, error, actionRunner, commandDescriptions } = require("../parser");
26+
const { cliConfig, success, log, hint, error, actionRunner, commandDescriptions } = require("../parser");
2527
const { accountGet } = require("./account");
2628
const { sdkForConsole } = require("../sdks");
2729

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

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

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

107-
log("Next you can use 'appwrite init' to create resources in your project, or use 'appwrite pull' and 'appwite push' to synchronize your project.")
108-
109109
if(answers.start === 'existing') {
110-
log("Since you connected to an existing project, we highly recommend to run 'appwrite pull all' to synchronize all of your existing resources.");
110+
answers = await inquirer.prompt(questionsInitProjectAutopull);
111+
if(answers.autopull) {
112+
cliConfig.all = true;
113+
await pullResources();
114+
} else {
115+
log("You can run 'appwrite pull all' to synchronize all of your existing resources.");
116+
}
111117
}
118+
119+
hint("Next you can use 'appwrite init' to create resources in your project, or use 'appwrite pull' and 'appwrite push' to synchronize your project.")
112120
}
113121

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

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

221-
try {
222-
const res = await fetch(api);
223-
templates.push(...(await res.json()).map((template) => template.name));
224-
225-
selected = await inquirer.prompt(questionsCreateFunctionSelectTemplate(templates))
226-
} catch {
227-
// Not a problem will go with directory pulling
228-
log('Loading templates...');
227+
if(answers.template === 'starter') {
228+
selected = { template: 'starter' };
229+
} else {
230+
try {
231+
const res = await fetch(api);
232+
const templates = [];
233+
templates.push(...(await res.json()).map((template) => template.name));
234+
selected = await inquirer.prompt(questionsCreateFunctionSelectTemplate(templates));
235+
} catch {
236+
// Not a problem will go with directory pulling
237+
log('Loading templates...');
238+
}
229239
}
230240

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

258268
fs.rmSync(path.join(templatesDir, ".git"), { recursive: true });
259269
if (!selected) {
270+
const templates = [];
260271
templates.push(...fs.readdirSync(runtimeDir, { withFileTypes: true })
261272
.filter(item => item.isDirectory() && item.name !== 'starter')
262273
.map(dirent => dirent.name));

0 commit comments

Comments
 (0)