Skip to content
Open
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
24 changes: 14 additions & 10 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
name: Publish Package to npmjs

on:
release:
types: [published]

permissions:
id-token: write
contents: read
Comment on lines +7 to +9
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Fix YAML indentation syntax error.

The permissions block has inconsistent indentation. Line 8 (id-token: write) is missing proper indentation, causing a YAML syntax error that will prevent the workflow from executing.

🔎 Proposed fix
 permissions:
-id-token: write
+  id-token: write
   contents: read
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
permissions:
id-token: write
contents: read
permissions:
id-token: write
contents: read
🧰 Tools
🪛 actionlint (1.7.9)

9-9: could not parse as YAML: mapping values are not allowed in this context

(syntax-check)

🪛 YAMLlint (1.37.1)

[error] 9-9: syntax error: mapping values are not allowed here

(syntax)

🤖 Prompt for AI Agents
In .github/workflows/npm-publish.yml around lines 7 to 9, the permissions block
has incorrect indentation (line 8 'id-token: write' is not indented to align
under permissions), causing a YAML syntax error; fix by indenting the keys under
permissions consistently (make 'id-token: write' and 'contents: read' children
of 'permissions') so the permissions block is valid YAML.


jobs:
build-for-linux-and-windows:
build-and-publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '16.x'
node-version: '22'
registry-url: 'https://registry.npmjs.org'
- name: Setup binfmt with QEMU
run: |
Expand All @@ -22,9 +28,9 @@ jobs:
cd ./ldid
sudo make
sudo make install
- name: Install dependenices and build for Linux and Windows
- name: Install dependencies and build for Linux and Windows
run: |
npm install
npm ci
npm run linux-x64
npm run linux-arm64
npm run windows-x64
Expand All @@ -35,13 +41,11 @@ jobs:
run: |
if ${{ contains(github.event.release.tag_name, '-rc') }}; then
echo "Publishing Release Candidate ${{ github.event.release.tag_name}} to NPM"
npm publish --tag next
npm publish --provenance --access public --tag next
else
echo "Publishing ${{ github.event.release.tag_name}} to NPM"
npm publish
npm publish --provenance --access public
fi
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN_NO_ORG }}
- uses: fnkr/github-action-ghr@v1
env:
GHR_PATH: build/
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules/
build/
.DS_Store
.DS_Store
dist/
206 changes: 105 additions & 101 deletions CHANGELOG.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ Redistribution and use in source and binary forms, with or without modification,

3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
91 changes: 57 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Appwrite is an open-source backend as a service server that abstract and simplif
The Appwrite CLI is a Node based command line tool to help you interact with the Appwrite API. The CLI is distributed both as an [`npm package`](https://www.npmjs.com/package/appwrite-cli) as well as [pre built binaries](https://github.com/appwrite/sdk-for-cli/releases/latest) for specific operating systems and architectures.

### Install using NPM

---

If you have `npm` installed, it's as easy as running
Expand All @@ -29,88 +30,99 @@ Once the installation is complete, you can verify the install using

```sh
$ appwrite -v
13.0.0-rc.1
13.0.0-rc.2
```

### Install using prebuilt binaries

---

If you do not have `npm` installed, you can always install the prebuilt binaries for your architecture and OS using our convenient installation scripts.

### Linux / MacOS Terminal

```bash
$ wget -q https://appwrite.io/cli/install.sh -O - | /bin/bash
```

### MacOS via [Homebrew](https://brew.sh)

```bash
$ brew install appwrite
$ brew install appwrite
```

### Windows

Via Powershell

```powershell
$ iwr -useb https://appwrite.io/cli/install.ps1 | iex
```

Via [Scoop](https://scoop.sh)

```powershell
$ scoop install https://raw.githubusercontent.com/appwrite/sdk-for-cli/master/scoop/appwrite.config.json
```

Once the installation completes, you can verify your install using

```
$ appwrite -v
13.0.0-rc.1
13.0.0-rc.2
```

## Getting Started
## Getting Started

Before you can use the CLI, you need to login to your Appwrite account.
Before you can use the CLI, you need to login to your Appwrite account.

```sh
$ appwrite login

? Enter your email test@test.com
? Enter your password ********
✓ Success
✓ Success
```
This will also prompt you to enter your Appwrite endpoint ( default: http://localhost/v1 )

* ### Initialising your project
Once logged in, the CLI needs to be initialised before you can use it with your Appwrite project. You can do this with the `appwrite init project` command.
This will also prompt you to enter your Appwrite endpoint ( default: http://localhost/v1 )

- ### Initialising your project
Once logged in, the CLI needs to be initialised before you can use it with your Appwrite project. You can do this with the `appwrite init project` command.

```sh
$ appwrite init project
```

The following prompt will guide you through the setup process. The `init` command also creates an `appwrite.json` file representing your Appwrite project.

The `appwrite.json` file does a lot of things.
* Provides context to the CLI
* Keeps track of all your cloud functions
* Keeps track of all your project's collections
* Helps you deploy your Appwrite project to production and more..
The `appwrite.json` file does a lot of things.

- Provides context to the CLI
- Keeps track of all your cloud functions
- Keeps track of all your project's collections
- Helps you deploy your Appwrite project to production and more..

You can also fetch all the collections in your current project using

```sh
appwrite init collection
```

* ### Creating and deploying cloud functions
- ### Creating and deploying cloud functions

The CLI makes it extremely easy to create and deploy Appwrite's cloud functions. Initialise your new function using

```
$ appwrite init function
? What would you like to name your function? My Awesome Function
? What runtime would you like to use? Node.js (node-15.5)
✓ Success
✓ Success
```

This will create a new function `My Awesome Function` in your current Appwrite project and also create a template function for you to get started.

```sh
$ tree My\ Awesome\ Function
$ tree My\ Awesome\ Function

My Awesome Function
├── README.md
Expand All @@ -121,7 +133,7 @@ My Awesome Function
0 directories, 4 files
```

You can now deploy this function using
You can now deploy this function using

```sh
$ appwrite push function
Expand All @@ -133,50 +145,56 @@ $ appwrite push function

Your function has now been deployed on your Appwrite server! As soon as the build process is finished, you can start executing the function.

* ### Deploying Collections
- ### Deploying Collections

Similarly, you can deploy all your collections to your Appwrite server using
Similarly, you can deploy all your collections to your Appwrite server using

```sh
appwrite push collections
```

> ### Note
>
> By default, requests to domains with self signed SSL certificates (or no certificates) are disabled. If you trust the domain, you can bypass the certificate validation using

```sh
$ appwrite client --selfSigned true
```

## Usage
## Usage

The Appwrite CLI follows the following general syntax.

```sh
$ appwrite [COMMAND] --[OPTIONS]
```

A few sample commands to get you started
A few sample commands to get you started

```sh
$ appwrite users create --userId "unique()" --email hello@appwrite.io --password very_strong_password
$ appwrite users list
$ appwrite users list
```

To create a document you can use the following command
To create a document you can use the following command

```sh
$ appwrite databases create-document --database-id <DATABASE_ID> --collection-id <COLLECTION_ID> --document-id "unique()" --data '{"name": "Walter O Brein"}' --permissions 'read("any")' 'read("team:abc")'
```

### Some Gotchas

- `data` must be a valid JSON string where each key and value are enclosed in double quotes `"` like the example above.
- Some arguments like the `read` and `write` permissions are expected to be arrays. In the Appwrite CLI, array values are passed in using space as a separator like in the example above.

To get information about the different services available, you can use

To get information about the different services available, you can use
```sh
$ appwrite -h
```

To get information about a particular service and the commands available in a service you can use
To get information about a particular service and the commands available in a service you can use

```sh
$ appwrite users // or
$ appwrite users --help // or
Expand All @@ -188,7 +206,7 @@ To get information about a particular command and the parameters it accepts, you

```sh
$ appwrite users list --help
$ appwrite account get --help
$ appwrite account get --help
```

At any point, you can view or reset the CLI configuration using the `client` service.
Expand All @@ -201,48 +219,53 @@ $ appwrite client --reset

## CI mode

The Appwrite CLI can also work in a CI environment. The initialisation of the CLI works a bit differently in CI. In CI, you set your `endpoint`, `projectId` and `API Key` using
The Appwrite CLI can also work in a CI environment. The initialisation of the CLI works a bit differently in CI. In CI, you set your `endpoint`, `projectId` and `API Key` using

```sh
appwrite client --endpoint http://localhost/v1 --projectId <PROJECT_ID> --key <API KEY>
```


## Contribution

This library is auto-generated by Appwrite custom [SDK Generator](https://github.com/appwrite/sdk-generator). To learn more about how you can help us improve this SDK, please check the [contribution guide](https://github.com/appwrite/sdk-generator/blob/master/CONTRIBUTING.md) before sending a pull-request.

To build and test the CLI for development, follow these steps
To build and test the CLI for development, follow these steps

1. Clone the SDK Generator repository and cd into the directory

```sh
$ git clone https://github.com/appwrite/sdk-generator
$ cd sdk-generator
```

2. Ensure Docker is running locally and then install the composer dependencies using
```sh

```sh
$ docker run --rm --interactive --tty --volume "$(pwd)":/app composer install --ignore-platform-reqs --optimize-autoloader --no-plugins --no-scripts --prefer-dist

# Generate the SDKs
$ docker run --rm -v $(pwd):/app -w /app php:8.1-cli php example.php
```

3. Head over to the generated SDK and install the dependencies.

```sh
$ cd examples/cli
$ npm install
$ npm install
```

4. Install the CLI using
4. Install the CLI using

```sh
$ npm install -g .
```

5. You can now use the CLI
5. You can now use the CLI

```sh
$ appwrite -v
```

## License

Please see the [BSD-3-Clause license](https://raw.githubusercontent.com/appwrite/appwrite/master/LICENSE) file for more information.
Loading