@apillon/cli
Version:
▶◀ Apillon CLI tools ▶◀
91 lines • 4.55 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.createStorageCommands = void 0;
const sdk_1 = require("@apillon/sdk");
const commander_1 = require("commander");
const options_1 = require("../../lib/options");
const utils_1 = require("../../lib/utils");
const ipns_commands_1 = require("./ipns.commands");
const storage_service_1 = require("./storage.service");
function createStorageCommands(cli) {
const storage = cli
.command('storage')
.description('Commands for manipulating buckets and files on Apillon storage.');
(0, ipns_commands_1.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 (0, storage_service_1.createBucket)(this.optsWithGlobals());
});
const listBucketsCommand = storage
.command('list-buckets')
.description('List project buckets')
.action(async function () {
await (0, storage_service_1.listBuckets)(this.optsWithGlobals());
});
(0, options_1.addPaginationOptions)(listBucketsCommand);
const listObjectsCommand = storage
.command('list-objects')
.description('List files and folders in directory')
.requiredOption('-b, --bucket-uuid <uuid>', 'UUID of bucket')
.option('-d, --directory-uuid <string>', 'Directory UUID')
.option('--deleted', 'Include deleted objects')
.action(async function () {
await (0, storage_service_1.listObjects)(this.optsWithGlobals());
});
(0, options_1.addPaginationOptions)(listObjectsCommand);
const listFilesCommand = storage
.command('list-files')
.description('List all files from a bucket')
.requiredOption('-b, --bucket-uuid <uuid>', 'UUID of bucket')
.addOption(new commander_1.Option('-s, --file-status <integer>', 'Filter by file status. Choose from:\n' +
` ${sdk_1.FileStatus.UPLOAD_REQUEST_GENERATED}: Upload request generated\n` +
` ${sdk_1.FileStatus.UPLOADED}: Uploaded\n` +
` ${sdk_1.FileStatus.AVAILABLE_ON_IPFS}: Available on IPFS\n` +
` ${sdk_1.FileStatus.AVAILABLE_ON_IPFS_AND_REPLICATED}: Available on IPFS and replicated\n`).choices((0, utils_1.enumValues)(sdk_1.FileStatus)))
.action(async function () {
await (0, storage_service_1.listFiles)(this.optsWithGlobals());
});
(0, options_1.addPaginationOptions)(listFilesCommand);
storage
.command('upload')
.description('Upload contents of a local folder to bucket')
.argument('<path>', 'path to local folder')
.requiredOption('-b, --bucket-uuid <uuid>', 'UUID of destination bucket')
.option('-w, --wrap', 'Wrap uploaded files to an IPFS directory')
.option('-p, --path <string>', 'Path to upload files to')
.option('--await', 'await file CIDs to be resolved (DEPRECATED - CIDs are now resolved automatically)')
.option('--ignore', 'ignore files from .gitignore file')
.action(async function (path) {
await (0, storage_service_1.uploadFromFolder)(path, this.optsWithGlobals());
});
storage
.command('get-file')
.description('Get file info')
.requiredOption('-b, --bucket-uuid <uuid>', 'UUID of bucket')
.requiredOption('-f, --file-uuid <uuid>', 'UUID or CID of file to get')
.action(async function () {
await (0, storage_service_1.getFile)(this.optsWithGlobals());
});
storage
.command('delete-file')
.description('Mark file for removal from IPFS storage')
.requiredOption('-b, --bucket-uuid <uuid>', 'UUID of bucket')
.requiredOption('-f, --file-uuid <uuid>', 'UUID or CID of file to delete')
.action(async function () {
await (0, storage_service_1.deleteFile)(this.optsWithGlobals());
});
storage
.command('delete-directory')
.description('Delete a directory from a storage bucket')
.requiredOption('-b, --bucket-uuid <uuid>', 'UUID of bucket')
.requiredOption('-d, --directory-uuid <uuid>', 'UUID of directory to delete')
.action(async function () {
await (0, storage_service_1.deleteDirectory)(this.optsWithGlobals());
});
}
exports.createStorageCommands = createStorageCommands;
//# sourceMappingURL=storage.commands.js.map