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
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions packages/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,22 @@ apillon hosting get-deployment --website-uuid "123e4567-e89b-12d3-a456-426655440

## Storage Commands


#### `storage create-bucket`

Creates a new storage bucket in your project.

**Options**

- `-n, --name <string>`: Name of the new bucket.
- `-d, --description <string>`: Description of the new bucket (optional).

**Example**

```sh
apillon storage create-bucket --name "Photo bucket" --description "Vacation photos"
```

#### `storage list-buckets`

Lists all storage buckets associated with your project.
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@apillon/cli",
"description": "▶◀ Apillon CLI tools ▶◀",
"version": "1.7.1",
"version": "1.8.0",
"author": "Apillon",
"license": "MIT",
"main": "./dist/index.js",
Expand Down
24 changes: 17 additions & 7 deletions packages/cli/src/modules/storage/storage.commands.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import { FileStatus } from '@apillon/sdk';
import { Command, Option } from 'commander';
import { addPaginationOptions } from '../../lib/options';
import { enumValues } from '../../lib/utils';
import { createIpnsCommands } from './ipns.commands';
import {
createBucket,
deleteDirectory,
deleteFile,
getFile,
listBuckets,
listObjects,
listFiles,
listObjects,
uploadFromFolder,
getFile,
deleteFile,
deleteDirectory,
} from './storage.service';
import { FileStatus } from '@apillon/sdk';
import { enumValues } from '../../lib/utils';
import { createIpnsCommands } from './ipns.commands';

export function createStorageCommands(cli: Command) {
const storage = cli
Expand All @@ -22,6 +23,15 @@ export function createStorageCommands(cli: Command) {

createIpnsCommands(storage);

storage
.command('create-bucket')
.description('Create a new storage bucket')
.requiredOption('-n, --name <name>', 'Name of the bucket')
.option('-d, --description <description>', 'Description of the bucket')
.action(async function () {
await createBucket(this.optsWithGlobals());
});

const listBucketsCommand = storage
.command('list-buckets')
.description('List project buckets')
Expand Down
12 changes: 11 additions & 1 deletion packages/cli/src/modules/storage/storage.service.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
import { Storage, toInteger } from '@apillon/sdk';
import { GlobalOptions } from '../../lib/types';
import { paginate } from '../../lib/options';
import { GlobalOptions } from '../../lib/types';
import { withErrorHandler } from '../../lib/utils';

export async function createBucket(optsWithGlobals: GlobalOptions) {
await withErrorHandler(async () => {
const bucket = await new Storage(optsWithGlobals).createBucket({
name: optsWithGlobals.name,
description: optsWithGlobals.description,
});
console.log('Bucket created successfully');
console.log(bucket.serialize());
});
}
export async function listBuckets(optsWithGlobals: GlobalOptions) {
await withErrorHandler(async () => {
const data = await new Storage(optsWithGlobals).listBuckets(
Expand Down