Skip to content

Commit e4774cd

Browse files
authored
Merge pull request #53 from dimitrov-d/master
Add create-bucket CLI method
2 parents 8e905c1 + 03b56c4 commit e4774cd

5 files changed

Lines changed: 46 additions & 10 deletions

File tree

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/cli/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,22 @@ apillon hosting get-deployment --website-uuid "123e4567-e89b-12d3-a456-426655440
247247

248248
## Storage Commands
249249

250+
251+
#### `storage create-bucket`
252+
253+
Creates a new storage bucket in your project.
254+
255+
**Options**
256+
257+
- `-n, --name <string>`: Name of the new bucket.
258+
- `-d, --description <string>`: Description of the new bucket (optional).
259+
260+
**Example**
261+
262+
```sh
263+
apillon storage create-bucket --name "Photo bucket" --description "Vacation photos"
264+
```
265+
250266
#### `storage list-buckets`
251267

252268
Lists all storage buckets associated with your project.

packages/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@apillon/cli",
33
"description": "▶◀ Apillon CLI tools ▶◀",
4-
"version": "1.7.1",
4+
"version": "1.8.0",
55
"author": "Apillon",
66
"license": "MIT",
77
"main": "./dist/index.js",

packages/cli/src/modules/storage/storage.commands.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1+
import { FileStatus } from '@apillon/sdk';
12
import { Command, Option } from 'commander';
23
import { addPaginationOptions } from '../../lib/options';
4+
import { enumValues } from '../../lib/utils';
5+
import { createIpnsCommands } from './ipns.commands';
36
import {
7+
createBucket,
8+
deleteDirectory,
9+
deleteFile,
10+
getFile,
411
listBuckets,
5-
listObjects,
612
listFiles,
13+
listObjects,
714
uploadFromFolder,
8-
getFile,
9-
deleteFile,
10-
deleteDirectory,
1115
} from './storage.service';
12-
import { FileStatus } from '@apillon/sdk';
13-
import { enumValues } from '../../lib/utils';
14-
import { createIpnsCommands } from './ipns.commands';
1516

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

2324
createIpnsCommands(storage);
2425

26+
storage
27+
.command('create-bucket')
28+
.description('Create a new storage bucket')
29+
.requiredOption('-n, --name <name>', 'Name of the bucket')
30+
.option('-d, --description <description>', 'Description of the bucket')
31+
.action(async function () {
32+
await createBucket(this.optsWithGlobals());
33+
});
34+
2535
const listBucketsCommand = storage
2636
.command('list-buckets')
2737
.description('List project buckets')

packages/cli/src/modules/storage/storage.service.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
import { Storage, toInteger } from '@apillon/sdk';
2-
import { GlobalOptions } from '../../lib/types';
32
import { paginate } from '../../lib/options';
3+
import { GlobalOptions } from '../../lib/types';
44
import { withErrorHandler } from '../../lib/utils';
55

6+
export async function createBucket(optsWithGlobals: GlobalOptions) {
7+
await withErrorHandler(async () => {
8+
const bucket = await new Storage(optsWithGlobals).createBucket({
9+
name: optsWithGlobals.name,
10+
description: optsWithGlobals.description,
11+
});
12+
console.log('Bucket created successfully');
13+
console.log(bucket.serialize());
14+
});
15+
}
616
export async function listBuckets(optsWithGlobals: GlobalOptions) {
717
await withErrorHandler(async () => {
818
const data = await new Storage(optsWithGlobals).listBuckets(

0 commit comments

Comments
 (0)