d-drive-cli 1.3.0 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ export declare function copyCommand(remotePath: string): Promise<void>;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.copyCommand = copyCommand;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ const ora_1 = __importDefault(require("ora"));
9
+ const api_1 = require("../api");
10
+ async function copyCommand(remotePath) {
11
+ const spinner = (0, ora_1.default)('Finding file...').start();
12
+ try {
13
+ const api = (0, api_1.createApiClient)();
14
+ // Find file by path
15
+ const filesResponse = await api.get('/files', { params: { path: remotePath } });
16
+ const files = filesResponse.data;
17
+ if (files.length === 0) {
18
+ spinner.fail(chalk_1.default.red(`File not found: ${remotePath}`));
19
+ process.exit(1);
20
+ }
21
+ const file = files[0];
22
+ spinner.text = 'Creating copy...';
23
+ const resp = await api.post(`/files/${file.id}/copy`);
24
+ spinner.succeed(chalk_1.default.green('Copy created'));
25
+ const created = resp.data;
26
+ console.log(chalk_1.default.gray(`Created: ${created.path || `/${created.name}`}`));
27
+ }
28
+ catch (error) {
29
+ spinner.fail(chalk_1.default.red('Copy failed'));
30
+ console.error(chalk_1.default.red(error.response?.data?.error || error.message));
31
+ process.exit(1);
32
+ }
33
+ }
package/dist/index.js CHANGED
@@ -11,11 +11,13 @@ const upload_1 = require("./commands/upload");
11
11
  const download_1 = require("./commands/download");
12
12
  const list_1 = require("./commands/list");
13
13
  const delete_1 = require("./commands/delete");
14
+ const copy_1 = require("./commands/copy");
15
+ const pkg = require('../package.json');
14
16
  const program = new commander_1.Command();
15
17
  program
16
18
  .name('d-drive')
17
19
  .description('D-Drive CLI - Discord-based cloud storage for developers')
18
- .version('1.0.0');
20
+ .version(pkg.version || '0.0.0');
19
21
  // Config command
20
22
  program
21
23
  .command('config')
@@ -52,6 +54,11 @@ program
52
54
  .option('-r, --recursive', 'Delete directory recursively')
53
55
  .option('-f, --force', 'Force deletion without confirmation')
54
56
  .action(delete_1.deleteCommand);
57
+ // Copy command
58
+ program
59
+ .command('copy <path>')
60
+ .description('Make a copy of a file in-place (auto-numbered)')
61
+ .action(copy_1.copyCommand);
55
62
  // Help command
56
63
  program.on('--help', () => {
57
64
  console.log('');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "d-drive-cli",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "description": "D-Drive CLI tool for developers",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -0,0 +1,32 @@
1
+ import chalk from 'chalk';
2
+ import ora from 'ora';
3
+ import { createApiClient } from '../api';
4
+
5
+ export async function copyCommand(remotePath: string) {
6
+ const spinner = ora('Finding file...').start();
7
+
8
+ try {
9
+ const api = createApiClient();
10
+
11
+ // Find file by path
12
+ const filesResponse = await api.get('/files', { params: { path: remotePath } });
13
+ const files = filesResponse.data;
14
+ if (files.length === 0) {
15
+ spinner.fail(chalk.red(`File not found: ${remotePath}`));
16
+ process.exit(1);
17
+ }
18
+
19
+ const file = files[0];
20
+ spinner.text = 'Creating copy...';
21
+
22
+ const resp = await api.post(`/files/${file.id}/copy`);
23
+
24
+ spinner.succeed(chalk.green('Copy created'));
25
+ const created = resp.data;
26
+ console.log(chalk.gray(`Created: ${created.path || `/${created.name}`}`));
27
+ } catch (error: any) {
28
+ spinner.fail(chalk.red('Copy failed'));
29
+ console.error(chalk.red(error.response?.data?.error || error.message));
30
+ process.exit(1);
31
+ }
32
+ }
package/src/index.ts CHANGED
@@ -7,13 +7,15 @@ import { uploadCommand } from './commands/upload';
7
7
  import { downloadCommand } from './commands/download';
8
8
  import { listCommand } from './commands/list';
9
9
  import { deleteCommand } from './commands/delete';
10
+ import { copyCommand } from './commands/copy';
11
+ const pkg = require('../package.json');
10
12
 
11
13
  const program = new Command();
12
14
 
13
15
  program
14
16
  .name('d-drive')
15
17
  .description('D-Drive CLI - Discord-based cloud storage for developers')
16
- .version('1.0.0');
18
+ .version(pkg.version || '0.0.0');
17
19
 
18
20
  // Config command
19
21
  program
@@ -56,6 +58,12 @@ program
56
58
  .option('-f, --force', 'Force deletion without confirmation')
57
59
  .action(deleteCommand);
58
60
 
61
+ // Copy command
62
+ program
63
+ .command('copy <path>')
64
+ .description('Make a copy of a file in-place (auto-numbered)')
65
+ .action(copyCommand);
66
+
59
67
  // Help command
60
68
  program.on('--help', () => {
61
69
  console.log('');