@super-protocol/sp-cli 0.0.2-beta.14 → 0.0.2-beta.16
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.
- package/README.md +20 -20
- package/dist/commands/auth/login.js +1 -1
- package/dist/commands/config/base.js +4 -4
- package/dist/commands/config/list.js +20 -19
- package/dist/constants.d.ts +2 -0
- package/dist/constants.js +2 -0
- package/dist/lib/container.js +1 -1
- package/dist/managers/config-file-manager.d.ts +1 -1
- package/dist/managers/config-file-manager.js +11 -3
- package/dist/services/storage.service.js +16 -9
- package/oclif.manifest.json +2 -2
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ $ npm install -g @super-protocol/sp-cli
|
|
|
21
21
|
$ sp COMMAND
|
|
22
22
|
running command...
|
|
23
23
|
$ sp (--version)
|
|
24
|
-
@super-protocol/sp-cli/0.0.2-beta.
|
|
24
|
+
@super-protocol/sp-cli/0.0.2-beta.16 linux-x64 node-v22.21.1
|
|
25
25
|
$ sp --help [COMMAND]
|
|
26
26
|
USAGE
|
|
27
27
|
$ sp COMMAND
|
|
@@ -65,11 +65,11 @@ DESCRIPTION
|
|
|
65
65
|
Information about current authorized user
|
|
66
66
|
```
|
|
67
67
|
|
|
68
|
-
_See code: [src/commands/account/info.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.2-beta.
|
|
68
|
+
_See code: [src/commands/account/info.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.2-beta.16/src/commands/account/info.ts)_
|
|
69
69
|
|
|
70
70
|
## `sp auth login`
|
|
71
71
|
|
|
72
|
-
Login
|
|
72
|
+
Login. SignUp and SignIn into SuperProtocol
|
|
73
73
|
|
|
74
74
|
```
|
|
75
75
|
USAGE
|
|
@@ -80,7 +80,7 @@ GLOBAL FLAGS
|
|
|
80
80
|
--json Format output as json.
|
|
81
81
|
|
|
82
82
|
DESCRIPTION
|
|
83
|
-
Login
|
|
83
|
+
Login. SignUp and SignIn into SuperProtocol
|
|
84
84
|
|
|
85
85
|
ALIASES
|
|
86
86
|
$ sp login
|
|
@@ -89,7 +89,7 @@ EXAMPLES
|
|
|
89
89
|
$ sp auth login
|
|
90
90
|
```
|
|
91
91
|
|
|
92
|
-
_See code: [src/commands/auth/login.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.2-beta.
|
|
92
|
+
_See code: [src/commands/auth/login.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.2-beta.16/src/commands/auth/login.ts)_
|
|
93
93
|
|
|
94
94
|
## `sp auth me`
|
|
95
95
|
|
|
@@ -102,7 +102,7 @@ GLOBAL FLAGS
|
|
|
102
102
|
--json Format output as json.
|
|
103
103
|
```
|
|
104
104
|
|
|
105
|
-
_See code: [src/commands/auth/me.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.2-beta.
|
|
105
|
+
_See code: [src/commands/auth/me.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.2-beta.16/src/commands/auth/me.ts)_
|
|
106
106
|
|
|
107
107
|
## `sp autocomplete [SHELL]`
|
|
108
108
|
|
|
@@ -163,7 +163,7 @@ EXAMPLES
|
|
|
163
163
|
$ sp config delete - Delete a configuration
|
|
164
164
|
```
|
|
165
165
|
|
|
166
|
-
_See code: [src/commands/config/index.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.2-beta.
|
|
166
|
+
_See code: [src/commands/config/index.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.2-beta.16/src/commands/config/index.ts)_
|
|
167
167
|
|
|
168
168
|
## `sp config add [FILE]`
|
|
169
169
|
|
|
@@ -202,7 +202,7 @@ EXAMPLES
|
|
|
202
202
|
}
|
|
203
203
|
```
|
|
204
204
|
|
|
205
|
-
_See code: [src/commands/config/add.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.2-beta.
|
|
205
|
+
_See code: [src/commands/config/add.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.2-beta.16/src/commands/config/add.ts)_
|
|
206
206
|
|
|
207
207
|
## `sp config create`
|
|
208
208
|
|
|
@@ -229,7 +229,7 @@ EXAMPLES
|
|
|
229
229
|
$ sp config create --name "Production" --url "https://api.dp.superprotocol.com"
|
|
230
230
|
```
|
|
231
231
|
|
|
232
|
-
_See code: [src/commands/config/create.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.2-beta.
|
|
232
|
+
_See code: [src/commands/config/create.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.2-beta.16/src/commands/config/create.ts)_
|
|
233
233
|
|
|
234
234
|
## `sp config delete`
|
|
235
235
|
|
|
@@ -257,7 +257,7 @@ EXAMPLES
|
|
|
257
257
|
$ sp config delete --name "My Config" --force
|
|
258
258
|
```
|
|
259
259
|
|
|
260
|
-
_See code: [src/commands/config/delete.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.2-beta.
|
|
260
|
+
_See code: [src/commands/config/delete.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.2-beta.16/src/commands/config/delete.ts)_
|
|
261
261
|
|
|
262
262
|
## `sp config list`
|
|
263
263
|
|
|
@@ -277,7 +277,7 @@ EXAMPLES
|
|
|
277
277
|
$ sp config list
|
|
278
278
|
```
|
|
279
279
|
|
|
280
|
-
_See code: [src/commands/config/list.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.2-beta.
|
|
280
|
+
_See code: [src/commands/config/list.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.2-beta.16/src/commands/config/list.ts)_
|
|
281
281
|
|
|
282
282
|
## `sp config show`
|
|
283
283
|
|
|
@@ -297,7 +297,7 @@ EXAMPLES
|
|
|
297
297
|
$ sp config show
|
|
298
298
|
```
|
|
299
299
|
|
|
300
|
-
_See code: [src/commands/config/show.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.2-beta.
|
|
300
|
+
_See code: [src/commands/config/show.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.2-beta.16/src/commands/config/show.ts)_
|
|
301
301
|
|
|
302
302
|
## `sp config use`
|
|
303
303
|
|
|
@@ -317,7 +317,7 @@ EXAMPLES
|
|
|
317
317
|
$ sp config use
|
|
318
318
|
```
|
|
319
319
|
|
|
320
|
-
_See code: [src/commands/config/use.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.2-beta.
|
|
320
|
+
_See code: [src/commands/config/use.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.2-beta.16/src/commands/config/use.ts)_
|
|
321
321
|
|
|
322
322
|
## `sp files download RESOURCEFILE LOCALDIRECTORY`
|
|
323
323
|
|
|
@@ -345,7 +345,7 @@ EXAMPLES
|
|
|
345
345
|
$ sp files download ./resource.json ./pathToDownload
|
|
346
346
|
```
|
|
347
347
|
|
|
348
|
-
_See code: [src/commands/files/download.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.2-beta.
|
|
348
|
+
_See code: [src/commands/files/download.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.2-beta.16/src/commands/files/download.ts)_
|
|
349
349
|
|
|
350
350
|
## `sp files upload PATH`
|
|
351
351
|
|
|
@@ -379,7 +379,7 @@ EXAMPLES
|
|
|
379
379
|
$ sp files upload ./file.txt
|
|
380
380
|
```
|
|
381
381
|
|
|
382
|
-
_See code: [src/commands/files/upload.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.2-beta.
|
|
382
|
+
_See code: [src/commands/files/upload.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.2-beta.16/src/commands/files/upload.ts)_
|
|
383
383
|
|
|
384
384
|
## `sp help [COMMAND]`
|
|
385
385
|
|
|
@@ -403,7 +403,7 @@ _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.3
|
|
|
403
403
|
|
|
404
404
|
## `sp login`
|
|
405
405
|
|
|
406
|
-
Login
|
|
406
|
+
Login. SignUp and SignIn into SuperProtocol
|
|
407
407
|
|
|
408
408
|
```
|
|
409
409
|
USAGE
|
|
@@ -414,7 +414,7 @@ GLOBAL FLAGS
|
|
|
414
414
|
--json Format output as json.
|
|
415
415
|
|
|
416
416
|
DESCRIPTION
|
|
417
|
-
Login
|
|
417
|
+
Login. SignUp and SignIn into SuperProtocol
|
|
418
418
|
|
|
419
419
|
ALIASES
|
|
420
420
|
$ sp login
|
|
@@ -450,7 +450,7 @@ EXAMPLES
|
|
|
450
450
|
$ sp storage create --not-default
|
|
451
451
|
```
|
|
452
452
|
|
|
453
|
-
_See code: [src/commands/storage/create.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.2-beta.
|
|
453
|
+
_See code: [src/commands/storage/create.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.2-beta.16/src/commands/storage/create.ts)_
|
|
454
454
|
|
|
455
455
|
## `sp storage select`
|
|
456
456
|
|
|
@@ -476,7 +476,7 @@ EXAMPLES
|
|
|
476
476
|
$ sp storage select --id=2de3e3a4-0000-1111-2222-333344445555
|
|
477
477
|
```
|
|
478
478
|
|
|
479
|
-
_See code: [src/commands/storage/select.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.2-beta.
|
|
479
|
+
_See code: [src/commands/storage/select.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.2-beta.16/src/commands/storage/select.ts)_
|
|
480
480
|
|
|
481
481
|
## `sp storage update`
|
|
482
482
|
|
|
@@ -503,5 +503,5 @@ EXAMPLES
|
|
|
503
503
|
$ sp storage update --id=2de3e3a4-0000-1111-2222-333344445555
|
|
504
504
|
```
|
|
505
505
|
|
|
506
|
-
_See code: [src/commands/storage/update.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.2-beta.
|
|
506
|
+
_See code: [src/commands/storage/update.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.2-beta.16/src/commands/storage/update.ts)_
|
|
507
507
|
<!-- commandsstop -->
|
|
@@ -3,7 +3,7 @@ import { StorageService } from '../../services/storage.service.js';
|
|
|
3
3
|
import { BaseCommand } from '../base.js';
|
|
4
4
|
export default class SpLogin extends BaseCommand {
|
|
5
5
|
static aliases = ['login'];
|
|
6
|
-
static description = 'Login
|
|
6
|
+
static description = 'Login. SignUp and SignIn into SuperProtocol';
|
|
7
7
|
static examples = [
|
|
8
8
|
`<%= config.bin %> <%= command.id %>
|
|
9
9
|
`,
|
|
@@ -25,16 +25,16 @@ export class BaseConfigCommand extends BaseCommand {
|
|
|
25
25
|
this.log(` Provider URL: ${PROVIDER_URL} (using default)`);
|
|
26
26
|
}
|
|
27
27
|
if (configData.auth?.accessKey) {
|
|
28
|
-
this.log(' Authorization:
|
|
28
|
+
this.log(' Authorization: Configured');
|
|
29
29
|
}
|
|
30
30
|
else {
|
|
31
|
-
this.log(' Authorization:
|
|
31
|
+
this.log(' Authorization: Unauthorized');
|
|
32
32
|
}
|
|
33
33
|
if (configData.account?.address) {
|
|
34
|
-
this.log(` Account:
|
|
34
|
+
this.log(` Account: ${configData.account.address}`);
|
|
35
35
|
}
|
|
36
36
|
else {
|
|
37
|
-
this.log(' Account:
|
|
37
|
+
this.log(' Account: Not configured');
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { printTable } from 'console-table-printer';
|
|
2
|
+
import { PROVIDER_URL } from '../../constants.js';
|
|
1
3
|
import { BaseConfigCommand } from './base.js';
|
|
2
4
|
export default class ConfigList extends BaseConfigCommand {
|
|
3
5
|
static description = 'List all configurations';
|
|
@@ -12,28 +14,27 @@ export default class ConfigList extends BaseConfigCommand {
|
|
|
12
14
|
this.log('Create a new configuration with: sp config create --name "Config Name"');
|
|
13
15
|
return;
|
|
14
16
|
}
|
|
15
|
-
|
|
17
|
+
const rows = [];
|
|
16
18
|
for (const config of configs) {
|
|
17
19
|
const marker = config.file === current ? '* ' : ' ';
|
|
18
20
|
const configData = this.configFileManager.getConfigData(config.file);
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
if (configData.account) {
|
|
29
|
-
parts.push(`Account: [OK] ${configData.account.address} `);
|
|
30
|
-
}
|
|
31
|
-
if (parts.length > 0) {
|
|
32
|
-
statusInfo = ` | ${parts.join(', ')}`;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
this.log(`${marker}${config.name}${statusInfo}`);
|
|
36
|
-
this.log(` File: ${config.file}`);
|
|
21
|
+
const row = {
|
|
22
|
+
account: configData?.account?.address ?? '[not found in config file]',
|
|
23
|
+
current: marker,
|
|
24
|
+
file: config.file,
|
|
25
|
+
name: config.name,
|
|
26
|
+
url: configData?.providerUrl ?? PROVIDER_URL,
|
|
27
|
+
};
|
|
28
|
+
rows.push(row);
|
|
37
29
|
}
|
|
30
|
+
printTable(rows, {
|
|
31
|
+
columns: [
|
|
32
|
+
{ name: 'current', title: 'Current' },
|
|
33
|
+
{ name: 'name', title: 'Config name' },
|
|
34
|
+
{ name: 'account', title: 'Account' },
|
|
35
|
+
{ name: 'url', title: 'Provider Url' },
|
|
36
|
+
{ name: 'file', title: 'Configuration File' },
|
|
37
|
+
], title: 'Available configurations',
|
|
38
|
+
});
|
|
38
39
|
}
|
|
39
40
|
}
|
package/dist/constants.d.ts
CHANGED
|
@@ -3,3 +3,5 @@ export declare const DIR_ACCESS_PERMS = 448;
|
|
|
3
3
|
export declare const PROVIDER_URL = "https://api.dp.superprotocol.com";
|
|
4
4
|
export declare const REFRESH_TOKEN_URI = "/api/auth/refresh-access";
|
|
5
5
|
export declare const S3_ENDPOINT = "https://gateway.storjshare.io";
|
|
6
|
+
export declare const DEFAULT_USER_CONFIG_FILE = "default.config.json";
|
|
7
|
+
export declare const DEFAULT_USER_CONFIG_NAME = "Default";
|
package/dist/constants.js
CHANGED
|
@@ -5,3 +5,5 @@ export const DIR_ACCESS_PERMS = 0o700;
|
|
|
5
5
|
export const PROVIDER_URL = 'https://api.dp.superprotocol.com';
|
|
6
6
|
export const REFRESH_TOKEN_URI = '/api/auth/refresh-access';
|
|
7
7
|
export const S3_ENDPOINT = 'https://gateway.storjshare.io';
|
|
8
|
+
export const DEFAULT_USER_CONFIG_FILE = 'default.config.json';
|
|
9
|
+
export const DEFAULT_USER_CONFIG_NAME = 'Default';
|
package/dist/lib/container.js
CHANGED
|
@@ -94,7 +94,7 @@ export class AppContainer {
|
|
|
94
94
|
if (this._configManager) {
|
|
95
95
|
return;
|
|
96
96
|
}
|
|
97
|
-
const configFilePath = this.configFileManager.getCurrentConfigPath();
|
|
97
|
+
const configFilePath = await this.configFileManager.getCurrentConfigPath();
|
|
98
98
|
if (!configFilePath) {
|
|
99
99
|
throw new Error('Config file not found');
|
|
100
100
|
}
|
|
@@ -37,7 +37,7 @@ export declare class ConfigFileManager implements IManager {
|
|
|
37
37
|
name: string;
|
|
38
38
|
}>;
|
|
39
39
|
getCurrentConfigFile(): string | undefined;
|
|
40
|
-
getCurrentConfigPath(): string
|
|
40
|
+
getCurrentConfigPath(): Promise<string>;
|
|
41
41
|
importConfig(sourcePath: string, targetName?: string): Promise<string>;
|
|
42
42
|
init(): Promise<void>;
|
|
43
43
|
removeConfig(configName: string): Promise<void>;
|
|
@@ -4,7 +4,7 @@ import * as fs from 'node:fs';
|
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
import { Value } from 'typebox/value';
|
|
6
6
|
import { cliConfigSchema } from '../config/config.schema.js';
|
|
7
|
-
import { DIR_ACCESS_PERMS, FILE_ACCESS_PERMS } from '../constants.js';
|
|
7
|
+
import { DEFAULT_USER_CONFIG_FILE, DEFAULT_USER_CONFIG_NAME, DIR_ACCESS_PERMS, FILE_ACCESS_PERMS, } from '../constants.js';
|
|
8
8
|
import { getConfigName } from '../utils/helper.js';
|
|
9
9
|
export class ConfigFileManager {
|
|
10
10
|
logger;
|
|
@@ -165,12 +165,20 @@ export class ConfigFileManager {
|
|
|
165
165
|
}
|
|
166
166
|
return this.configs.currentConfig;
|
|
167
167
|
}
|
|
168
|
-
getCurrentConfigPath() {
|
|
168
|
+
async getCurrentConfigPath() {
|
|
169
169
|
if (this.runtimeConfigFile) {
|
|
170
170
|
return this.runtimeConfigFile;
|
|
171
171
|
}
|
|
172
172
|
if (!this.configs.currentConfig) {
|
|
173
|
-
|
|
173
|
+
try {
|
|
174
|
+
await this.createConfig(DEFAULT_USER_CONFIG_FILE, DEFAULT_USER_CONFIG_NAME);
|
|
175
|
+
}
|
|
176
|
+
catch {
|
|
177
|
+
//
|
|
178
|
+
}
|
|
179
|
+
finally {
|
|
180
|
+
await this.setCurrentConfig(DEFAULT_USER_CONFIG_FILE);
|
|
181
|
+
}
|
|
174
182
|
}
|
|
175
183
|
return path.join(this.configsDir, this.configs.currentConfig);
|
|
176
184
|
}
|
|
@@ -69,11 +69,19 @@ export class StorageService {
|
|
|
69
69
|
if (resource.filepath) {
|
|
70
70
|
localPath = joinPaths(localPath, resource.filepath);
|
|
71
71
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
72
|
+
try {
|
|
73
|
+
this.logger.info('Starting download');
|
|
74
|
+
const downloadResult = await download(resource, localPath, {
|
|
75
|
+
encryption: resourceFile.encryption,
|
|
76
|
+
progressCallback: progressCb,
|
|
77
|
+
threads: params.maximumConcurrent,
|
|
78
|
+
});
|
|
79
|
+
this.logger.info(downloadResult, 'Downloaded');
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
this.logger.error({ err: error }, 'Download failed with error');
|
|
83
|
+
throw error;
|
|
84
|
+
}
|
|
77
85
|
}
|
|
78
86
|
async getCentralizedStorage() {
|
|
79
87
|
try {
|
|
@@ -283,6 +291,7 @@ export class StorageService {
|
|
|
283
291
|
localPath = dirname(localPath);
|
|
284
292
|
}
|
|
285
293
|
try {
|
|
294
|
+
this.logger.info('Starting upload');
|
|
286
295
|
const uploadResult = await upload(localPath, {
|
|
287
296
|
credentials: writeCredentials,
|
|
288
297
|
filepath: '',
|
|
@@ -305,10 +314,8 @@ export class StorageService {
|
|
|
305
314
|
this.logger.info(`Resource file was created in ${resourceFilePath}`);
|
|
306
315
|
}
|
|
307
316
|
catch (error) {
|
|
308
|
-
this.logger.error({ err: error }, '
|
|
309
|
-
|
|
310
|
-
const error_ = error instanceof StorageError ? error : new ProviderClientError('Request failed please try again later');
|
|
311
|
-
throw error_;
|
|
317
|
+
this.logger.error({ err: error }, 'Something went wrong with upload');
|
|
318
|
+
throw error;
|
|
312
319
|
}
|
|
313
320
|
}
|
|
314
321
|
}
|
package/oclif.manifest.json
CHANGED
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"login"
|
|
44
44
|
],
|
|
45
45
|
"args": {},
|
|
46
|
-
"description": "Login
|
|
46
|
+
"description": "Login. SignUp and SignIn into SuperProtocol",
|
|
47
47
|
"examples": [
|
|
48
48
|
"<%= config.bin %> <%= command.id %>\n"
|
|
49
49
|
],
|
|
@@ -733,5 +733,5 @@
|
|
|
733
733
|
]
|
|
734
734
|
}
|
|
735
735
|
},
|
|
736
|
-
"version": "0.0.2-beta.
|
|
736
|
+
"version": "0.0.2-beta.16"
|
|
737
737
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@super-protocol/sp-cli",
|
|
3
3
|
"description": "SuperProtocol Command line interface",
|
|
4
|
-
"version": "0.0.2-beta.
|
|
4
|
+
"version": "0.0.2-beta.16",
|
|
5
5
|
"author": "SuperProtocol",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public",
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"@super-protocol/dto-js": "^1.3.0",
|
|
23
23
|
"@super-protocol/provider-client": "^0.1.8",
|
|
24
24
|
"@super-protocol/sp-files-addon": "^0.12.7",
|
|
25
|
+
"console-table-printer": "^2.15.0",
|
|
25
26
|
"cookie": "^1.0.2",
|
|
26
27
|
"jsonwebtoken": "^9.0.2",
|
|
27
28
|
"pino": "^9.14.0",
|