Skip to content

chore: regenerate sdk #178

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 17, 2025
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
2 changes: 1 addition & 1 deletion .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
npm publish
fi
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN_NO_ORG }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to add this secret? or already taken care of? If not aware, Torsten might know

- uses: fnkr/github-action-ghr@v1
env:
GHR_PATH: build/
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Change Log

## 8.2.1

* Added `--with-variables` option to the Sites command for adding/updating environment variables
* Fixed Functions environment variables not being pushed with `--with-variables`
* Removed `awaitPools` when wiping old variables

> **Note:** Storing environment variables in the `vars` attribute of `appwrite.json` is now deprecated due to security risks. Variables are now synced directly from the `.env` file in the root directory of the function’s or site’s folder.

## 8.2.0

* Add `encrypt` attribute support
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
8.2.0
8.2.1
```

### 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
8.2.0
8.2.1
```

## 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/8.2.0/appwrite-cli-win-x64.exe"
$GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/8.2.0/appwrite-cli-win-arm64.exe"
$GITHUB_x64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/8.2.1/appwrite-cli-win-x64.exe"
$GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/8.2.1/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="8.2.0"
GITHUB_LATEST_VERSION="8.2.1"
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': '8.2.0',
'user-agent' : `AppwriteCLI/8.2.0 (${os.type()} ${os.version()}; ${os.arch()})`,
'x-sdk-version': '8.2.1',
'user-agent' : `AppwriteCLI/8.2.1 (${os.type()} ${os.version()}; ${os.arch()})`,
'X-Appwrite-Response-Format' : '1.7.0',
};
}
Expand Down
108 changes: 56 additions & 52 deletions lib/commands/push.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
const fs = require('fs');
const path = require('path');
const { parse: parseDotenv } = require('dotenv');
const chalk = require('chalk');
const inquirer = require("inquirer");
const JSONbig = require("json-bigint")({ storeAsString: false });
Expand All @@ -12,7 +15,7 @@ const { proxyCreateFunctionRule, proxyCreateSiteRule, proxyListRules } = require
const { consoleVariables } = require('./console');
const { sdkForConsole } = require('../sdks')
const { functionsGet, functionsCreate, functionsUpdate, functionsCreateDeployment, functionsGetDeployment, functionsListVariables, functionsDeleteVariable, functionsCreateVariable } = require('./functions');
const { sitesGet, sitesCreate, sitesUpdate, sitesCreateDeployment, sitesGetDeployment, sitesCreateVariable } = require('./sites');
const { sitesGet, sitesCreate, sitesUpdate, sitesCreateDeployment, sitesGetDeployment, sitesCreateVariable, sitesListVariables, sitesDeleteVariable } = require('./sites');
const {
databasesGet,
databasesCreate,
Expand Down Expand Up @@ -149,37 +152,6 @@ const awaitPools = {
iteration + 1
);
},
wipeVariables: async (functionId, iteration = 1) => {
if (iteration > pollMaxDebounces) {
return false;
}

const { total } = await functionsListVariables({
functionId,
queries: ['limit(1)'],
parseOutput: false
});

if (total === 0) {
return true;
}

if (pollMaxDebounces === POLL_DEFAULT_VALUE) {
let steps = Math.max(1, Math.ceil(total / STEP_SIZE));
if (steps > 1 && iteration === 1) {
pollMaxDebounces *= steps;

log('Found a large number of variables, increasing timeout to ' + (pollMaxDebounces * POLL_DEBOUNCE / 1000 / 60) + ' minutes')
}
}

await new Promise(resolve => setTimeout(resolve, POLL_DEBOUNCE));

return await awaitPools.wipeVariables(
functionId,
iteration + 1
);
},
deleteAttributes: async (databaseId, collectionId, attributeKeys, iteration = 1) => {
if (iteration > pollMaxDebounces) {
return false;
Expand Down Expand Up @@ -1047,7 +1019,7 @@ const pushSettings = async () => {
}
}

const pushSite = async({ siteId, async, code } = { returnOnZero: false }) => {
const pushSite = async({ siteId, async, code, withVariables } = { returnOnZero: false }) => {
process.chdir(localConfig.configDirectoryPath)

const siteIds = [];
Expand Down Expand Up @@ -1180,7 +1152,6 @@ const pushSite = async({ siteId, async, code } = { returnOnZero: false }) => {
timeout: site.timeout,
enabled: site.enabled,
logging: site.logging,
vars: JSON.stringify(site.vars),
parseOutput: false
});

Expand Down Expand Up @@ -1213,16 +1184,43 @@ const pushSite = async({ siteId, async, code } = { returnOnZero: false }) => {
}
}

updaterRow.update({ status: 'Creating variables' }).replaceSpinner(SPINNER_ARC);
if (withVariables) {
updaterRow.update({ status: 'Creating variables' }).replaceSpinner(SPINNER_ARC);

await Promise.all((site['vars'] ?? []).map(async variable => {
await sitesCreateVariable({
const { variables } = await paginate(sitesListVariables, {
siteId: site['$id'],
key: variable['key'],
value: variable['value'],
parseOutput: false
});
}));
}, 100, 'variables');

await Promise.all(variables.map(async variable => {
await sitesDeleteVariable({
siteId: site['$id'],
variableId: variable['$id'],
parseOutput: false
});
}));

const envFileLocation = `${site['path']}/.env`;
let envVariables = [];
try {
if (fs.existsSync(envFileLocation)) {
const envObject = parseDotenv(fs.readFileSync(envFileLocation, 'utf8'));
envVariables = Object.entries(envObject || {}).map(([key, value]) => ({ key, value }));
}
} catch (error) {
// Handle parsing errors gracefully
envVariables = [];
}
await Promise.all(envVariables.map(async variable => {
await sitesCreateVariable({
siteId: site['$id'],
key: variable.key,
value: variable.value,
parseOutput: false,
secret: false
});
}));
}

if (code === false) {
successfullyPushed++;
Expand Down Expand Up @@ -1475,7 +1473,6 @@ const pushFunction = async ({ functionId, async, code, withVariables } = { retur
entrypoint: func.entrypoint,
commands: func.commands,
scopes: func.scopes,
vars: JSON.stringify(func.vars),
parseOutput: false
});

Expand Down Expand Up @@ -1524,19 +1521,25 @@ const pushFunction = async ({ functionId, async, code, withVariables } = { retur
});
}));

let result = await awaitPools.wipeVariables(func['$id']);
if (!result) {
updaterRow.fail({ errorMessage: `Variable deletion timed out.` })
return;
const envFileLocation = `${func['path']}/.env`;
let envVariables = [];
try {
if (fs.existsSync(envFileLocation)) {
const envObject = parseDotenv(fs.readFileSync(envFileLocation, 'utf8'));
envVariables = Object.entries(envObject || {}).map(([key, value]) => ({ key, value }));
}
} catch (error) {
// Handle parsing errors gracefully
envVariables = [];
}

// Deploy local variables
await Promise.all((func['vars'] ?? []).map(async variable => {
await Promise.all(envVariables.map(async variable => {
await functionsCreateVariable({
functionId: func['$id'],
key: variable['key'],
value: variable['value'],
parseOutput: false
variableId: ID.unique(),
key: variable.key,
value: variable.value,
parseOutput: false,
secret: false
});
}));
}
Expand Down Expand Up @@ -2065,6 +2068,7 @@ push
.option(`-f, --site-id <site-id>`, `ID of site to run`)
.option(`-A, --async`, `Don't wait for sites deployments status`)
.option("--no-code", "Don't push the site's code")
.option("--with-variables", `Push site variables.`)
.action(actionRunner(pushSite));

push
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 = '8.2.0';
const version = '8.2.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()}`;

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": "8.2.0",
"version": "8.2.1",
"license": "BSD-3-Clause",
"main": "index.js",
"bin": {
Expand Down
6 changes: 3 additions & 3 deletions scoop/appwrite.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": "8.2.0",
"version": "8.2.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/8.2.0/appwrite-cli-win-x64.exe",
"url": "https://github.com/appwrite/sdk-for-cli/releases/download/8.2.1/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/8.2.0/appwrite-cli-win-arm64.exe",
"url": "https://github.com/appwrite/sdk-for-cli/releases/download/8.2.1/appwrite-cli-win-arm64.exe",
"bin": [
[
"appwrite-cli-win-arm64.exe",
Expand Down