Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change Log

## 10.2.3

* Fix `init tables` command not working
* Improve tablesDB resource syncing during `push tables` command

## 10.2.2

* Fix `logout` command showing duplicate sessions
Expand Down
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
10.2.2
10.2.3
```

### 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
10.2.2
10.2.3
```

## Getting Started
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/10.2.2/appwrite-cli-win-x64.exe"
$GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/10.2.2/appwrite-cli-win-arm64.exe"
$GITHUB_x64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/10.2.3/appwrite-cli-win-x64.exe"
$GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/10.2.3/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="10.2.2"
GITHUB_LATEST_VERSION="10.2.3"
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': '10.2.2',
'user-agent' : `AppwriteCLI/10.2.2 (${os.type()} ${os.version()}; ${os.arch()})`,
'x-sdk-version': '10.2.3',
'user-agent' : `AppwriteCLI/10.2.3 (${os.type()} ${os.version()}; ${os.arch()})`,
'X-Appwrite-Response-Format' : '1.8.0',
};
}
Expand Down
46 changes: 44 additions & 2 deletions lib/commands/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const {
questionsCreateBucket,
questionsCreateMessagingTopic,
questionsCreateCollection,
questionsCreateTable,
questionsInitProject,
questionsInitProjectAutopull,
questionsInitResources,
Expand All @@ -34,10 +35,11 @@ const initResources = async () => {
const actions = {
function: initFunction,
site: initSite,
collection: initCollection,
table: initTable,
bucket: initBucket,
team: initTeam,
message: initTopic
message: initTopic,
collection: initCollection
}

const answers = await inquirer.prompt(questionsInitResources[0]);
Expand Down Expand Up @@ -160,6 +162,40 @@ const initTeam = async () => {
log("Next you can use 'appwrite push team' to deploy the changes.");
};

const initTable = async () => {
const answers = await inquirer.prompt(questionsCreateTable)
const newDatabase = (answers.method ?? '').toLowerCase() !== 'existing';

if (!newDatabase) {
answers.databaseId = answers.database;
answers.databaseName = localConfig.getTablesDB(answers.database).name;
}

const databaseId = answers.databaseId === 'unique()' ? ID.unique() : answers.databaseId;

if (newDatabase || !localConfig.getTablesDB(answers.databaseId)) {
localConfig.addTablesDB({
$id: databaseId,
name: answers.databaseName,
enabled: true
});
}

localConfig.addTable({
$id: answers.id === 'unique()' ? ID.unique() : answers.id,
$permissions: [],
databaseId: databaseId,
name: answers.table,
enabled: true,
rowSecurity: answers.rowSecurity.toLowerCase() === 'yes',
columns: [],
indexes: [],
});

success("Initialing table");
log("Next you can use 'appwrite push table' to deploy the changes.");
};

const initCollection = async () => {
const answers = await inquirer.prompt(questionsCreateCollection)
const newDatabase = (answers.method ?? '').toLowerCase() !== 'existing';
Expand Down Expand Up @@ -557,6 +593,12 @@ init
.description("Init a new Appwrite collection")
.action(actionRunner(initCollection));

init
.command("table")
.alias("tables")
.description("Init a new Appwrite table")
.action(actionRunner(initTable));

init
.command("topic")
.alias("topics")
Expand Down
46 changes: 30 additions & 16 deletions lib/commands/push.js
Original file line number Diff line number Diff line change
Expand Up @@ -837,14 +837,16 @@ const attributesToCreate = async (remoteAttributes, localAttributes, collection,

if (!cliConfig.force) {
if (deleting.length > 0 && !isIndex) {
console.log(`${chalk.red('-------------------------------------------------------')}`);
console.log(`${chalk.red('------------------------------------------------------')}`);
console.log(`${chalk.red('| WARNING: Attribute deletion may cause loss of data |')}`);
console.log(`${chalk.red('-------------------------------------------------------')}`);
console.log(`${chalk.red('------------------------------------------------------')}`);
console.log();
}
if (conflicts.length > 0 && !isIndex) {
console.log(`${chalk.red('---------------------------------------------------------')}`);
console.log(`${chalk.red('--------------------------------------------------------')}`);
console.log(`${chalk.red('| WARNING: Attribute recreation may cause loss of data |')}`);
console.log(`${chalk.red('---------------------------------------------------------')}`);
console.log(`${chalk.red('--------------------------------------------------------')}`);
console.log();
}

if ((await getConfirmation()) !== true) {
Expand Down Expand Up @@ -1725,9 +1727,10 @@ const checkAndApplyTablesDBChanges = async () => {
toDelete.push(remoteDB);
changes.push({
id: remoteDB.$id,
action: chalk.red('deleting'),
key: 'Database',
remote: chalk.red(`${remoteDB.name} (${remoteDB.$id})`),
local: chalk.green('(deleted locally)')
remote: remoteDB.name,
local: '(deleted locally)'
});
}
}
Expand All @@ -1740,9 +1743,10 @@ const checkAndApplyTablesDBChanges = async () => {
toCreate.push(localDB);
changes.push({
id: localDB.$id,
action: chalk.green('creating'),
key: 'Database',
remote: chalk.red('(does not exist)'),
local: chalk.green(`${localDB.name} (${localDB.$id})`)
remote: '(does not exist)',
local: localDB.name
});
} else {
let hasChanges = false;
Expand All @@ -1751,19 +1755,21 @@ const checkAndApplyTablesDBChanges = async () => {
hasChanges = true;
changes.push({
id: localDB.$id,
action: chalk.yellow('updating'),
key: 'Name',
remote: chalk.red(remoteDB.name),
local: chalk.green(localDB.name)
remote: remoteDB.name,
local: localDB.name
});
}

if (remoteDB.enabled !== localDB.enabled) {
hasChanges = true;
changes.push({
id: localDB.$id,
key: 'Enabled?',
remote: chalk.red(remoteDB.enabled),
local: chalk.green(localDB.enabled)
action: chalk.yellow('updating'),
key: 'Enabled',
remote: remoteDB.enabled,
local: localDB.enabled
});
}

Expand All @@ -1774,16 +1780,19 @@ const checkAndApplyTablesDBChanges = async () => {
}

if (changes.length === 0) {
console.log('No changes found in tablesDB resource');
console.log();
return { applied: false, resyncNeeded: false };
}

log('Found changes in tablesDB resources:');
log('Found changes in tablesDB resource:');
drawTable(changes);

if (toDelete.length > 0) {
console.log(`${chalk.red('-------------------------------------------------------------------')}`);
console.log(`${chalk.red('------------------------------------------------------------------')}`);
console.log(`${chalk.red('| WARNING: Database deletion will also delete all related tables |')}`);
console.log(`${chalk.red('-------------------------------------------------------------------')}`);
console.log(`${chalk.red('------------------------------------------------------------------')}`);
console.log();
}

if ((await getConfirmation()) !== true) {
Expand Down Expand Up @@ -1841,6 +1850,10 @@ const checkAndApplyTablesDBChanges = async () => {
}
}

if (toDelete.length === 0){
console.log();
}

return { applied: true, resyncNeeded: needsResync };
};

Expand Down Expand Up @@ -1868,6 +1881,7 @@ const pushTable = async ({ returnOnZero, attempts } = { returnOnZero: false }) =
localConfig.set('tablesDB', validTablesDBs);

success('Configuration resynced successfully.');
console.log();
}

if (cliConfig.all) {
Expand Down
2 changes: 1 addition & 1 deletion lib/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ const parseError = (err) => {
} catch {
}

const version = '10.2.2';
const version = '10.2.3';
const stepsToReproduce = `Running \`appwrite ${cliConfig.reportData.data.args.join(' ')}\``;
const yourEnvironment = `CLI version: ${version}\nOperation System: ${os.type()}\nAppwrite version: ${appwriteVersion}\nIs Cloud: ${isCloud()}`;

Expand Down
69 changes: 68 additions & 1 deletion lib/questions.js
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,73 @@ const questionsCreateCollection = [
{
type: "list",
name: "documentSecurity",
message: "Enable Document-Security for configuring permissions for individual documents",
message: "Enable document security for configuring permissions for individual documents",
choices: ["No", "Yes"]
}
];

const questionsCreateTable = [
{
type: "list",
name: "method",
message: "What database would you like to use for your table?",
choices: ["New", "Existing"],
when: async () => {
return localConfig.getTablesDBs().length !== 0;
}
},
{
type: "search-list",
name: "database",
message: "Choose the table database",
choices: async () => {
const databases = localConfig.getTablesDBs();

let choices = databases.map((database, idx) => {
return {
name: `${database.name} (${database.$id})`,
value: database.$id
}
})

if (choices.length === 0) {
throw new Error("No databases found. Please create one in project console.")
}

return choices;
},
when: (answers) => (answers.method ?? '').toLowerCase() === 'existing'
},
{
type: "input",
name: "databaseName",
message: "What would you like to name your database?",
default: "My Awesome Database",
when: (answers) => (answers.method ?? '').toLowerCase() !== 'existing'
},
{
type: "input",
name: "databaseId",
message: "What ID would you like to have for your database?",
default: "unique()",
when: (answers) => (answers.method ?? '').toLowerCase() !== 'existing'
},
{
type: "input",
name: "table",
message: "What would you like to name your table?",
default: "My Awesome Table"
},
{
type: "input",
name: "id",
message: "What ID would you like to have for your table?",
default: "unique()"
},
{
type: "list",
name: "rowSecurity",
message: "Enable row security for configuring permissions for individual rows",
choices: ["No", "Yes"]
}
];
Expand Down Expand Up @@ -1001,6 +1067,7 @@ module.exports = {
questionsCreateFunctionSelectTemplate,
questionsCreateBucket,
questionsCreateCollection,
questionsCreateTable,
questionsCreateMessagingTopic,
questionsPullFunctions,
questionsPullFunctionsCode,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "10.2.2",
"version": "10.2.3",
"license": "BSD-3-Clause",
"main": "index.js",
"bin": {
Expand Down
6 changes: 3 additions & 3 deletions scoop/appwrite.config.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"$schema": "https://raw.githubusercontent.com/ScoopInstaller/Scoop/master/schema.json",
"version": "10.2.2",
"version": "10.2.3",
"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/10.2.2/appwrite-cli-win-x64.exe",
"url": "https://github.com/appwrite/sdk-for-cli/releases/download/10.2.3/appwrite-cli-win-x64.exe",
"bin": [
[
"appwrite-cli-win-x64.exe",
Expand All @@ -15,7 +15,7 @@
]
},
"arm64": {
"url": "https://github.com/appwrite/sdk-for-cli/releases/download/10.2.2/appwrite-cli-win-arm64.exe",
"url": "https://github.com/appwrite/sdk-for-cli/releases/download/10.2.3/appwrite-cli-win-arm64.exe",
"bin": [
[
"appwrite-cli-win-arm64.exe",
Expand Down