@super-protocol/sp-cli 0.0.6 → 0.0.8

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.
Files changed (92) hide show
  1. package/README.md +116 -234
  2. package/dist/commands/account/base.d.ts +19 -0
  3. package/dist/commands/account/base.js +42 -0
  4. package/dist/commands/account/forget.d.ts +14 -0
  5. package/dist/commands/account/forget.js +49 -0
  6. package/dist/commands/account/get-sppi.d.ts +2 -2
  7. package/dist/commands/account/get-sppi.js +8 -13
  8. package/dist/commands/account/info.d.ts +5 -2
  9. package/dist/commands/account/info.js +53 -3
  10. package/dist/commands/account/list.d.ts +9 -0
  11. package/dist/commands/{config → account}/list.js +16 -9
  12. package/dist/commands/account/login.d.ts +35 -0
  13. package/dist/commands/account/login.js +249 -0
  14. package/dist/commands/account/switch.d.ts +12 -0
  15. package/dist/commands/account/switch.js +40 -0
  16. package/dist/commands/base.d.ts +4 -3
  17. package/dist/commands/base.js +99 -13
  18. package/dist/commands/files/download.js +13 -5
  19. package/dist/commands/files/upload.js +11 -7
  20. package/dist/commands/storage/base.d.ts +2 -2
  21. package/dist/commands/storage/base.js +11 -11
  22. package/dist/commands/storage/create.js +1 -1
  23. package/dist/commands/storage/select.js +6 -8
  24. package/dist/commands/storage/show.js +2 -4
  25. package/dist/commands/storage/update.js +39 -22
  26. package/dist/commands/workflows/extend-lease.d.ts +1 -1
  27. package/dist/commands/workflows/extend-lease.js +21 -13
  28. package/dist/config/config-file.schema.d.ts +1 -2
  29. package/dist/config/config-file.schema.js +0 -1
  30. package/dist/config/config.schema.d.ts +1 -1
  31. package/dist/errors.d.ts +2 -0
  32. package/dist/errors.js +2 -0
  33. package/dist/hooks/finally/shutdown-blockchain.d.ts +1 -1
  34. package/dist/hooks/finally/shutdown-blockchain.js +1 -1
  35. package/dist/hooks/finally/unlock-config.d.ts +3 -0
  36. package/dist/hooks/finally/unlock-config.js +5 -0
  37. package/dist/hooks/init/init-container.d.ts +1 -1
  38. package/dist/hooks/init/init-container.js +2 -3
  39. package/dist/hooks/init/lock-config.d.ts +3 -0
  40. package/dist/hooks/init/lock-config.js +19 -0
  41. package/dist/hooks/prerun/auth.d.ts +3 -0
  42. package/dist/hooks/prerun/auth.js +70 -0
  43. package/dist/index.d.ts +1 -1
  44. package/dist/index.js +1 -1
  45. package/dist/interfaces/account-manager.interface.d.ts +1 -1
  46. package/dist/interfaces/config-manager.interface.d.ts +2 -2
  47. package/dist/lib/cli-instance-lock.d.ts +2 -0
  48. package/dist/lib/cli-instance-lock.js +37 -0
  49. package/dist/lib/container.d.ts +6 -4
  50. package/dist/lib/container.js +108 -38
  51. package/dist/logger.d.ts +1 -1
  52. package/dist/logger.js +4 -1
  53. package/dist/managers/account-manager.d.ts +7 -8
  54. package/dist/managers/account-manager.js +20 -45
  55. package/dist/managers/config-file-manager.d.ts +6 -7
  56. package/dist/managers/config-file-manager.js +35 -32
  57. package/dist/managers/config-manager.d.ts +5 -5
  58. package/dist/managers/config-manager.js +5 -2
  59. package/dist/middlewares/auth-middleware.d.ts +1 -1
  60. package/dist/services/auth.service.d.ts +10 -15
  61. package/dist/services/auth.service.js +71 -5
  62. package/dist/services/storage.service.d.ts +3 -3
  63. package/dist/services/storage.service.js +46 -19
  64. package/dist/utils/helper.d.ts +1 -0
  65. package/dist/utils/helper.js +15 -1
  66. package/dist/utils/prompt-flags.d.ts +20 -0
  67. package/dist/utils/prompt-flags.js +121 -0
  68. package/dist/utils/prompt.service.d.ts +16 -0
  69. package/dist/utils/prompt.service.js +75 -0
  70. package/dist/utils/tty.d.ts +1 -0
  71. package/dist/utils/tty.js +3 -0
  72. package/oclif.manifest.json +206 -242
  73. package/package.json +17 -24
  74. package/dist/commands/auth/login.d.ts +0 -12
  75. package/dist/commands/auth/login.js +0 -50
  76. package/dist/commands/auth/me.d.ts +0 -5
  77. package/dist/commands/auth/me.js +0 -16
  78. package/dist/commands/config/add.d.ts +0 -13
  79. package/dist/commands/config/add.js +0 -73
  80. package/dist/commands/config/base.d.ts +0 -16
  81. package/dist/commands/config/base.js +0 -78
  82. package/dist/commands/config/create.d.ts +0 -11
  83. package/dist/commands/config/create.js +0 -41
  84. package/dist/commands/config/delete.d.ts +0 -10
  85. package/dist/commands/config/delete.js +0 -25
  86. package/dist/commands/config/index.d.ts +0 -6
  87. package/dist/commands/config/index.js +0 -22
  88. package/dist/commands/config/list.d.ts +0 -6
  89. package/dist/commands/config/show.d.ts +0 -6
  90. package/dist/commands/config/show.js +0 -10
  91. package/dist/commands/config/use.d.ts +0 -6
  92. package/dist/commands/config/use.js +0 -27
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.6",
4
+ "version": "0.0.8",
5
5
  "author": "SuperProtocol",
6
6
  "publishConfig": {
7
7
  "access": "public",
@@ -19,35 +19,33 @@
19
19
  "@oclif/plugin-help": "^6.2.33",
20
20
  "@oclif/plugin-warn-if-update-available": "^3.1.50",
21
21
  "@sinclair/typebox": "^0.33.22",
22
+ "@super-protocol/dto-js": "^1.3.2",
22
23
  "@super-protocol/provider-client": "^0.1.9",
23
24
  "@super-protocol/sdk-js": "^3.17.1",
24
- "@super-protocol/dto-js": "^1.3.2",
25
25
  "@super-protocol/sp-files-addon": "^0.13.2",
26
26
  "console-table-printer": "^2.15.0",
27
27
  "cookie": "^1.0.2",
28
28
  "jsonwebtoken": "^9.0.2",
29
29
  "pino": "^9.14.0",
30
30
  "pino-pretty": "^13.1.2",
31
+ "proper-lockfile": "^4.1.2",
31
32
  "tough-cookie": "^6.0.0",
32
33
  "typebox": "^1.0.55",
33
34
  "typescript-retry-decorator": "^2.4.2",
34
35
  "viem": "^2.38.3"
35
36
  },
36
37
  "devDependencies": {
37
- "@eslint/compat": "^1.4.0",
38
- "@oclif/prettier-config": "^0.2.1",
38
+ "@biomejs/biome": "^1.9.4",
39
39
  "@oclif/test": "^4.1.14",
40
40
  "@types/chai": "^4.3.20",
41
41
  "@types/jsonwebtoken": "^9.0.10",
42
42
  "@types/mocha": "^10.0.10",
43
43
  "@types/node": "^20.19.20",
44
+ "@types/proper-lockfile": "^4.1.4",
44
45
  "chai": "^4.5.0",
45
- "eslint": "^9.37.0",
46
- "eslint-config-oclif": "^6.0.110",
47
- "eslint-config-prettier": "^10.1.8",
46
+ "husky": "^9.1.7",
48
47
  "mocha": "^10.8.2",
49
48
  "oclif": "^4.22.32",
50
- "prettier": "^3.6.2",
51
49
  "shx": "^0.3.3",
52
50
  "tsx": "4.20.6",
53
51
  "typescript": "^5.9.3"
@@ -55,23 +53,15 @@
55
53
  "engines": {
56
54
  "node": ">=22.0.0"
57
55
  },
58
- "files": [
59
- "./bin",
60
- "./dist",
61
- "./oclif.manifest.json"
62
- ],
56
+ "files": ["./bin", "./dist", "./oclif.manifest.json"],
63
57
  "homepage": "https://github.com/Super-Protocol/sp-cli",
64
- "keywords": [
65
- "oclif"
66
- ],
58
+ "keywords": ["oclif"],
67
59
  "license": "BSL-1.0",
68
60
  "main": "dist/index.js",
69
61
  "type": "module",
70
62
  "oclif": {
71
63
  "bin": "sp",
72
- "binAliases": [
73
- "spcli"
74
- ],
64
+ "binAliases": ["spcli"],
75
65
  "dirname": "sp",
76
66
  "commands": {
77
67
  "strategy": "pattern",
@@ -101,8 +91,9 @@
101
91
  "identifier": "com.super-protocol.cli"
102
92
  },
103
93
  "hooks": {
104
- "init": "./dist/hooks/init/init-container",
105
- "finally": "./dist/hooks/finally/shutdown-blockchain"
94
+ "init": ["./dist/hooks/init/init-container", "./dist/hooks/init/lock-config"],
95
+ "prerun": "./dist/hooks/prerun/auth",
96
+ "finally": ["./dist/hooks/finally/shutdown-blockchain", "./dist/hooks/finally/unlock-config"]
106
97
  }
107
98
  },
108
99
  "repository": "git+ssh://git@github.com/Super-Protocol/sp-cli.git",
@@ -114,8 +105,9 @@
114
105
  "start:prod": "./bin/run.js",
115
106
  "generate:command": "oclif generate command",
116
107
  "generate:hook": "oclif generate hook",
117
- "lint": "eslint \"{src,test}/**/*.ts\"",
118
- "lint:fix": "eslint \"{src,test}/**/*.ts\" --fix",
108
+ "lint": "biome check",
109
+ "lint:ci": "biome ci",
110
+ "lint:fix": "biome check --write",
119
111
  "postpack": "shx rm -f oclif.manifest.json",
120
112
  "posttest": "npm run lint",
121
113
  "prepack": "oclif manifest && oclif readme",
@@ -134,7 +126,8 @@
134
126
  "ci:installer:win": "npm exec oclif -- pack win",
135
127
  "ci:installer:deb": "npm exec oclif -- pack deb",
136
128
  "ci:installer:macos": "npm exec oclif -- pack macos",
137
- "ci:pack:all": "npm exec oclif -- pack tarballs --no-xz --targets=win32-x64,win32-arm64,linux-x64,linux-arm64,darwin-x64,darwin-arm64"
129
+ "ci:pack:all": "npm exec oclif -- pack tarballs --no-xz --targets=win32-x64,win32-arm64,linux-x64,linux-arm64,darwin-x64,darwin-arm64",
130
+ "prepare": "husky"
138
131
  },
139
132
  "types": "dist/index.d.ts"
140
133
  }
@@ -1,12 +0,0 @@
1
- import { BaseCommand } from '../base.js';
2
- export default class SpLogin extends BaseCommand<typeof SpLogin> {
3
- static aliases: string[];
4
- static description: string;
5
- static examples: string[];
6
- checkStorage(): Promise<void>;
7
- init(): Promise<void>;
8
- run(): Promise<{
9
- account: string;
10
- success: boolean;
11
- }>;
12
- }
@@ -1,50 +0,0 @@
1
- import { AuthService } from '../../services/auth.service.js';
2
- import { StorageService } from '../../services/storage.service.js';
3
- import { BaseCommand } from '../base.js';
4
- export default class SpLogin extends BaseCommand {
5
- static aliases = ['login'];
6
- static description = 'Login to SuperProtocol (sign up or sign in).';
7
- static examples = [
8
- `<%= config.bin %> <%= command.id %>
9
- `,
10
- ];
11
- async checkStorage() {
12
- await this.container.initProviderClient({ enableAuth: true, enableCookies: true, rebuild: true }).build();
13
- const { providerClient } = this.container;
14
- const storageService = new StorageService(providerClient, this.logger);
15
- if (!await storageService.hasStorage()) {
16
- this.logger.info('Requesting default storage');
17
- const { id, isCentralized, storageType } = await storageService.getCentralizedStorage();
18
- this.logger.info({ id, isCentralized, storageType }, 'Requested new storage');
19
- await storageService.saveStorage(id);
20
- }
21
- }
22
- async init() {
23
- await super.init();
24
- await this.container
25
- .initConfigManager()
26
- .initAccountManager()
27
- .initProviderClient({ enableAuth: false, enableCookies: true })
28
- .build();
29
- }
30
- async run() {
31
- const { accountManager, configManager, providerClient } = this.container;
32
- const authService = new AuthService(accountManager, configManager, providerClient, this.logger);
33
- try {
34
- await authService.auth();
35
- }
36
- catch (error) {
37
- this.error(error, { exit: 1 });
38
- }
39
- try {
40
- await this.checkStorage();
41
- }
42
- catch (error) {
43
- this.logger.error({ err: error }, 'Storage initialization failed');
44
- this.warn('Storage initialization failed. You can set up storage later using "sp storage create" or "sp storage select".');
45
- }
46
- const account = accountManager.getAddress();
47
- this.log(`Logged in with account ${account}`);
48
- return { account, success: true };
49
- }
50
- }
@@ -1,5 +0,0 @@
1
- import { BaseCommand } from '../base.js';
2
- export default class Me extends BaseCommand<typeof Me> {
3
- init(): Promise<void>;
4
- run(): Promise<void>;
5
- }
@@ -1,16 +0,0 @@
1
- import { BaseCommand } from '../base.js';
2
- export default class Me extends BaseCommand {
3
- async init() {
4
- await super.init();
5
- await this.container.initProviderClient().build();
6
- }
7
- async run() {
8
- const { providerClient } = this.container;
9
- const { data, error } = await providerClient.GET('/api/auth/me');
10
- if (error) {
11
- this.error(error.message);
12
- }
13
- this.log('Requested me');
14
- this.logJson(data);
15
- }
16
- }
@@ -1,13 +0,0 @@
1
- import { BaseConfigCommand } from './base.js';
2
- export default class ConfigAdd extends BaseConfigCommand<typeof ConfigAdd> {
3
- static args: {
4
- file: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
5
- };
6
- static description: string;
7
- static examples: string[];
8
- static flags: {
9
- name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
- yes: import("@oclif/core/interfaces").BooleanFlag<boolean>;
11
- };
12
- run(): Promise<void>;
13
- }
@@ -1,73 +0,0 @@
1
- import { Args, Flags } from '@oclif/core';
2
- import { existsSync } from 'node:fs';
3
- import path from 'node:path';
4
- import { BaseConfigCommand } from './base.js';
5
- export default class ConfigAdd extends BaseConfigCommand {
6
- static args = {
7
- file: Args.string({
8
- description: 'Configuration file path to import',
9
- required: false,
10
- }),
11
- };
12
- static description = 'Import a configuration from a file';
13
- static examples = [
14
- '<%= config.bin %> <%= command.id %> ./my-config.json',
15
- '<%= config.bin %> <%= command.id %> ./my-config.json --name "Imported"',
16
- `Configuration files must follow this schema:
17
-
18
- {
19
- "providerUrl": "https://api.dp.superprotocol.com",
20
- "name": "Some name",
21
- "account": {
22
- "address": "0x111222333444555....",
23
- "privateKey": "0x000011122233344555..."
24
- }
25
- }`,
26
- ];
27
- static flags = {
28
- name: Flags.string({
29
- char: 'n',
30
- description: 'Custom name for the imported configuration',
31
- }),
32
- yes: Flags.boolean({
33
- char: 'y',
34
- default: false,
35
- description: 'Automatically switch to imported configuration',
36
- }),
37
- };
38
- async run() {
39
- const { cwdDir } = this.container;
40
- let filePath = this.args.file;
41
- if (!filePath) {
42
- filePath = await this.inputPrompt({
43
- message: 'Enter path to configuration file:',
44
- validate(value) {
45
- if (!value)
46
- return 'File path is required';
47
- const testPath = path.isAbsolute(value) ? value : path.join(cwdDir, value);
48
- if (!existsSync(testPath)) {
49
- return 'File does not exist';
50
- }
51
- },
52
- });
53
- }
54
- const absolutePath = path.isAbsolute(filePath)
55
- ? filePath
56
- : path.join(cwdDir, filePath);
57
- if (!existsSync(absolutePath)) {
58
- this.error('File does not exist');
59
- }
60
- try {
61
- const importedFileName = await this.configFileManager.importConfig(absolutePath, this.flags.name);
62
- const configs = this.configFileManager.getConfigsWithNames();
63
- const importedConfig = configs.find(c => c.file === importedFileName);
64
- const displayName = importedConfig?.name || importedFileName;
65
- this.log(`Successfully imported configuration: ${displayName}`);
66
- this.log(`Configuration file: ${importedFileName}`);
67
- await this.switchToNewConfig(importedFileName, displayName, this.flags.yes);
68
- }
69
- catch (error) {
70
- this.error(`Failed to import configuration: ${error instanceof Error ? error.message : String(error)}`);
71
- }
72
- }
73
- }
@@ -1,16 +0,0 @@
1
- import type { Command } from '@oclif/core';
2
- import { select, text } from '@clack/prompts';
3
- import type { ConfigFileManager } from '../../managers/config-file-manager.js';
4
- import { BaseCommand } from '../base.js';
5
- type TextOptions = Parameters<typeof text>[0];
6
- type SelectOptions<T> = Parameters<typeof select<T>>[0];
7
- export declare abstract class BaseConfigCommand<T extends typeof Command> extends BaseCommand<T> {
8
- static baseFlags: {};
9
- protected configFileManager: ConfigFileManager;
10
- protected displayCurrentConfig(): void;
11
- init(): Promise<void>;
12
- protected inputPrompt(options: TextOptions): Promise<string>;
13
- protected selectPrompt<Value>(options: SelectOptions<Value>): Promise<Value>;
14
- protected switchToNewConfig(configFile: string, displayName: string, yes: boolean): Promise<void>;
15
- }
16
- export {};
@@ -1,78 +0,0 @@
1
- import { select, text } from '@clack/prompts';
2
- import { PROVIDER_URL } from '../../constants.js';
3
- import { BaseCommand } from '../base.js';
4
- export class BaseConfigCommand extends BaseCommand {
5
- static baseFlags = {};
6
- configFileManager;
7
- displayCurrentConfig() {
8
- const current = this.configFileManager.getCurrentConfigFile();
9
- const configDir = this.configFileManager.getConfigDir();
10
- if (current) {
11
- const configs = this.configFileManager.getConfigsWithNames();
12
- const currentConfig = configs.find(c => c.file === current);
13
- const displayName = currentConfig?.name || current;
14
- const configData = this.configFileManager.getConfigData(current);
15
- this.log(`Current configuration: ${displayName}`);
16
- this.log(`Configuration file: ${current}`);
17
- this.log(`Configuration directory: ${configDir}`);
18
- if (configData) {
19
- this.log('');
20
- this.log('Configuration details:');
21
- if (configData.providerUrl) {
22
- this.log(` Provider URL: ${configData.providerUrl}`);
23
- }
24
- else {
25
- this.log(` Provider URL: ${PROVIDER_URL} (using default)`);
26
- }
27
- if (configData.auth?.accessKey) {
28
- this.log(' Authorization: Configured');
29
- }
30
- else {
31
- this.log(' Authorization: Unauthorized');
32
- }
33
- if (configData.account?.address) {
34
- this.log(` Account: ${configData.account.address}`);
35
- }
36
- else {
37
- this.log(' Account: Not configured');
38
- }
39
- }
40
- }
41
- else {
42
- this.log('No configuration is currently set');
43
- this.log(`Configuration directory: ${configDir}`);
44
- this.log('Create a new configuration with: sp config create --name "Config Name"');
45
- }
46
- }
47
- async init() {
48
- await super.init();
49
- await this.container.initConfigFileManager().build();
50
- this.configFileManager = this.container.configFileManager;
51
- }
52
- async inputPrompt(options) {
53
- const result = await text(options);
54
- return this.ensurePromptValue(result);
55
- }
56
- async selectPrompt(options) {
57
- const result = await select(options);
58
- return this.ensurePromptValue(result);
59
- }
60
- async switchToNewConfig(configFile, displayName, yes) {
61
- const shouldSwitch = yes || await this.selectPrompt({
62
- message: 'Switch to this configuration now?',
63
- options: [
64
- { label: 'Yes', value: true },
65
- { label: 'No', value: false },
66
- ],
67
- });
68
- if (shouldSwitch) {
69
- await this.configFileManager.setCurrentConfig(configFile);
70
- this.log(`Switched to configuration: ${displayName}`);
71
- await this.container
72
- .initConfigFileManager(true)
73
- .initConfigManager(true)
74
- .initAccountManager(true)
75
- .build();
76
- }
77
- }
78
- }
@@ -1,11 +0,0 @@
1
- import { BaseConfigCommand } from './base.js';
2
- export default class ConfigCreate extends BaseConfigCommand<typeof ConfigCreate> {
3
- static description: string;
4
- static examples: string[];
5
- static flags: {
6
- name: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
7
- url: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
- yes: import("@oclif/core/interfaces").BooleanFlag<boolean>;
9
- };
10
- run(): Promise<void>;
11
- }
@@ -1,41 +0,0 @@
1
- import { Flags } from '@oclif/core';
2
- import { getConfigName } from '../../utils/helper.js';
3
- import { BaseConfigCommand } from './base.js';
4
- export default class ConfigCreate extends BaseConfigCommand {
5
- static description = 'Create a new configuration';
6
- static examples = [
7
- '<%= config.bin %> <%= command.id %> --name "My Config"',
8
- '<%= config.bin %> <%= command.id %> --name "Production" --url "https://api.dp.superprotocol.com"',
9
- ];
10
- static flags = {
11
- name: Flags.string({
12
- char: 'n',
13
- description: 'Configuration name',
14
- required: true,
15
- }),
16
- url: Flags.string({
17
- char: 'u',
18
- description: 'Provider base URL',
19
- }),
20
- yes: Flags.boolean({
21
- char: 'y',
22
- description: 'Switch to new config',
23
- }),
24
- };
25
- async run() {
26
- const { name, url, yes } = this.flags;
27
- const fileName = getConfigName(name);
28
- try {
29
- await this.configFileManager.createConfig(fileName, name, url);
30
- this.log(`Created new configuration: ${name}`);
31
- this.log(`Configuration file: ${fileName}`);
32
- if (url) {
33
- this.log(`Provider URL: ${url}`);
34
- }
35
- await this.switchToNewConfig(fileName, name, yes);
36
- }
37
- catch (error) {
38
- this.error(`Failed to create configuration: ${error instanceof Error ? error.message : String(error)}`);
39
- }
40
- }
41
- }
@@ -1,10 +0,0 @@
1
- import { BaseConfigCommand } from './base.js';
2
- export default class ConfigDelete extends BaseConfigCommand<typeof ConfigDelete> {
3
- static description: string;
4
- static examples: string[];
5
- static flags: {
6
- force: import("@oclif/core/interfaces").BooleanFlag<boolean>;
7
- name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
- };
9
- run(): Promise<void>;
10
- }
@@ -1,25 +0,0 @@
1
- import { Flags } from '@oclif/core';
2
- import { BaseConfigCommand } from './base.js';
3
- export default class ConfigDelete extends BaseConfigCommand {
4
- static description = 'Delete a configuration file';
5
- static examples = [
6
- '<%= config.bin %> <%= command.id %>',
7
- '<%= config.bin %> <%= command.id %> --name "My Config"',
8
- '<%= config.bin %> <%= command.id %> --name "My Config" --force',
9
- ];
10
- static flags = {
11
- force: Flags.boolean({
12
- char: 'f',
13
- default: false,
14
- description: 'Force deletion without confirmation',
15
- }),
16
- name: Flags.string({
17
- char: 'n',
18
- description: 'Configuration name to delete',
19
- }),
20
- };
21
- async run() {
22
- const { force, name } = this.flags;
23
- await this.configFileManager.deleteConfigByName(name, force);
24
- }
25
- }
@@ -1,6 +0,0 @@
1
- import { BaseConfigCommand } from './base.js';
2
- export default class Config extends BaseConfigCommand<typeof Config> {
3
- static description: string;
4
- static examples: string[];
5
- run(): Promise<void>;
6
- }
@@ -1,22 +0,0 @@
1
- import { BaseConfigCommand } from './base.js';
2
- export default class Config extends BaseConfigCommand {
3
- static description = 'Manage configuration configs';
4
- static examples = [
5
- '<%= config.bin %> <%= command.id %> show - Show current configuration details',
6
- '<%= config.bin %> <%= command.id %> list - List all configurations',
7
- '<%= config.bin %> <%= command.id %> use - Switch to a configuration',
8
- '<%= config.bin %> <%= command.id %> create --name "My Config" - Create new configuration',
9
- '<%= config.bin %> <%= command.id %> add ./config.json - Import configuration from file',
10
- '<%= config.bin %> <%= command.id %> delete - Delete a configuration',
11
- ];
12
- async run() {
13
- this.displayCurrentConfig();
14
- this.log('\nAvailable commands:');
15
- this.log(' sp config show - Show current configuration');
16
- this.log(' sp config list - List all configurations');
17
- this.log(' sp config use - Switch configuration');
18
- this.log(' sp config create - Create new configuration');
19
- this.log(' sp config add - Import configuration');
20
- this.log(' sp config delete - Delete configuration');
21
- }
22
- }
@@ -1,6 +0,0 @@
1
- import { BaseConfigCommand } from './base.js';
2
- export default class ConfigList extends BaseConfigCommand<typeof ConfigList> {
3
- static description: string;
4
- static examples: string[];
5
- run(): Promise<void>;
6
- }
@@ -1,6 +0,0 @@
1
- import { BaseConfigCommand } from './base.js';
2
- export default class ConfigShow extends BaseConfigCommand<typeof ConfigShow> {
3
- static description: string;
4
- static examples: string[];
5
- run(): Promise<void>;
6
- }
@@ -1,10 +0,0 @@
1
- import { BaseConfigCommand } from './base.js';
2
- export default class ConfigShow extends BaseConfigCommand {
3
- static description = 'Show current configuration';
4
- static examples = [
5
- '<%= config.bin %> <%= command.id %>',
6
- ];
7
- async run() {
8
- this.displayCurrentConfig();
9
- }
10
- }
@@ -1,6 +0,0 @@
1
- import { BaseConfigCommand } from './base.js';
2
- export default class ConfigUse extends BaseConfigCommand<typeof ConfigUse> {
3
- static description: string;
4
- static examples: string[];
5
- run(): Promise<void>;
6
- }
@@ -1,27 +0,0 @@
1
- import { BaseConfigCommand } from './base.js';
2
- export default class ConfigUse extends BaseConfigCommand {
3
- static description = 'Switch to a different configuration file';
4
- static examples = [
5
- '<%= config.bin %> <%= command.id %>',
6
- ];
7
- async run() {
8
- const configs = this.configFileManager.getConfigsWithNames();
9
- const currentConfig = this.configFileManager.getCurrentConfigFile();
10
- if (configs.length === 0) {
11
- this.log('No configurations found');
12
- this.log('Create a new configuration with: sp config create --name "Config Name"');
13
- return;
14
- }
15
- const selected = await this.selectPrompt({
16
- initialValue: currentConfig,
17
- message: 'Select a configuration:',
18
- options: configs.map(config => ({
19
- label: config.name ?? config.file,
20
- value: config.file,
21
- })),
22
- });
23
- await this.configFileManager.setCurrentConfig(selected);
24
- const selectedConfig = configs.find(c => c.file === selected);
25
- this.log(`Switched to configuration: ${selectedConfig?.name || selected}`);
26
- }
27
- }