@runium/cli 0.0.3 → 0.0.4

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 (106) hide show
  1. package/{lib/commands → commands}/index.js +0 -0
  2. package/{lib/constants → constants}/index.js +0 -0
  3. package/{lib/macros → macros}/index.js +0 -0
  4. package/package.json +6 -31
  5. package/{lib/services → services}/index.js +0 -0
  6. package/{lib/utils → utils}/index.js +0 -0
  7. package/{lib/validation → validation}/index.js +0 -0
  8. package/.eslintrc.json +0 -31
  9. package/.prettierrc.json +0 -10
  10. package/README.md +0 -3
  11. package/build.js +0 -125
  12. package/lib/package.json +0 -22
  13. package/src/app.ts +0 -190
  14. package/src/commands/index.ts +0 -2
  15. package/src/commands/plugin/plugin-add.ts +0 -48
  16. package/src/commands/plugin/plugin-command.ts +0 -36
  17. package/src/commands/plugin/plugin-disable.ts +0 -46
  18. package/src/commands/plugin/plugin-enable.ts +0 -50
  19. package/src/commands/plugin/plugin-list.ts +0 -61
  20. package/src/commands/plugin/plugin-remove.ts +0 -42
  21. package/src/commands/plugin/plugin.ts +0 -36
  22. package/src/commands/project/project-add.ts +0 -64
  23. package/src/commands/project/project-command.ts +0 -43
  24. package/src/commands/project/project-list.ts +0 -32
  25. package/src/commands/project/project-remove.ts +0 -41
  26. package/src/commands/project/project-start.ts +0 -158
  27. package/src/commands/project/project-state-command.ts +0 -53
  28. package/src/commands/project/project-status.ts +0 -116
  29. package/src/commands/project/project-stop.ts +0 -59
  30. package/src/commands/project/project-validate.ts +0 -56
  31. package/src/commands/project/project.ts +0 -40
  32. package/src/commands/runium-command.ts +0 -52
  33. package/src/constants/error-code.ts +0 -28
  34. package/src/constants/index.ts +0 -1
  35. package/src/global.d.ts +0 -6
  36. package/src/index.ts +0 -24
  37. package/src/macros/conditional.ts +0 -31
  38. package/src/macros/date.ts +0 -15
  39. package/src/macros/empty.ts +0 -6
  40. package/src/macros/env.ts +0 -8
  41. package/src/macros/index.ts +0 -17
  42. package/src/macros/path.ts +0 -24
  43. package/src/services/command.ts +0 -171
  44. package/src/services/config.ts +0 -119
  45. package/src/services/file.ts +0 -272
  46. package/src/services/index.ts +0 -9
  47. package/src/services/output.ts +0 -205
  48. package/src/services/plugin-context.ts +0 -140
  49. package/src/services/plugin.ts +0 -248
  50. package/src/services/profile.ts +0 -199
  51. package/src/services/project.ts +0 -142
  52. package/src/services/shutdown.ts +0 -147
  53. package/src/utils/convert-path-to-valid-file-name.ts +0 -39
  54. package/src/utils/debounce.ts +0 -23
  55. package/src/utils/format-timestamp.ts +0 -17
  56. package/src/utils/get-version.ts +0 -13
  57. package/src/utils/index.ts +0 -4
  58. package/src/validation/create-validator.ts +0 -27
  59. package/src/validation/get-config-schema.ts +0 -59
  60. package/src/validation/get-error-messages.ts +0 -35
  61. package/src/validation/get-plugin-schema.ts +0 -137
  62. package/src/validation/index.ts +0 -4
  63. package/tsconfig.json +0 -38
  64. /package/{lib/app.js → app.js} +0 -0
  65. /package/{lib/commands → commands}/plugin/plugin-add.js +0 -0
  66. /package/{lib/commands → commands}/plugin/plugin-command.js +0 -0
  67. /package/{lib/commands → commands}/plugin/plugin-disable.js +0 -0
  68. /package/{lib/commands → commands}/plugin/plugin-enable.js +0 -0
  69. /package/{lib/commands → commands}/plugin/plugin-list.js +0 -0
  70. /package/{lib/commands → commands}/plugin/plugin-remove.js +0 -0
  71. /package/{lib/commands → commands}/plugin/plugin.js +0 -0
  72. /package/{lib/commands → commands}/project/project-add.js +0 -0
  73. /package/{lib/commands → commands}/project/project-command.js +0 -0
  74. /package/{lib/commands → commands}/project/project-list.js +0 -0
  75. /package/{lib/commands → commands}/project/project-remove.js +0 -0
  76. /package/{lib/commands → commands}/project/project-start.js +0 -0
  77. /package/{lib/commands → commands}/project/project-state-command.js +0 -0
  78. /package/{lib/commands → commands}/project/project-status.js +0 -0
  79. /package/{lib/commands → commands}/project/project-stop.js +0 -0
  80. /package/{lib/commands → commands}/project/project-validate.js +0 -0
  81. /package/{lib/commands → commands}/project/project.js +0 -0
  82. /package/{lib/commands → commands}/runium-command.js +0 -0
  83. /package/{lib/constants → constants}/error-code.js +0 -0
  84. /package/{lib/index.js → index.js} +0 -0
  85. /package/{lib/macros → macros}/conditional.js +0 -0
  86. /package/{lib/macros → macros}/date.js +0 -0
  87. /package/{lib/macros → macros}/empty.js +0 -0
  88. /package/{lib/macros → macros}/env.js +0 -0
  89. /package/{lib/macros → macros}/path.js +0 -0
  90. /package/{lib/services → services}/command.js +0 -0
  91. /package/{lib/services → services}/config.js +0 -0
  92. /package/{lib/services → services}/file.js +0 -0
  93. /package/{lib/services → services}/output.js +0 -0
  94. /package/{lib/services → services}/plugin-context.js +0 -0
  95. /package/{lib/services → services}/plugin.js +0 -0
  96. /package/{lib/services → services}/profile.js +0 -0
  97. /package/{lib/services → services}/project.js +0 -0
  98. /package/{lib/services → services}/shutdown.js +0 -0
  99. /package/{lib/utils → utils}/convert-path-to-valid-file-name.js +0 -0
  100. /package/{lib/utils → utils}/debounce.js +0 -0
  101. /package/{lib/utils → utils}/format-timestamp.js +0 -0
  102. /package/{lib/utils → utils}/get-version.js +0 -0
  103. /package/{lib/validation → validation}/create-validator.js +0 -0
  104. /package/{lib/validation → validation}/get-config-schema.js +0 -0
  105. /package/{lib/validation → validation}/get-error-messages.js +0 -0
  106. /package/{lib/validation → validation}/get-plugin-schema.js +0 -0
File without changes
File without changes
File without changes
package/package.json CHANGED
@@ -1,47 +1,22 @@
1
1
  {
2
2
  "name": "@runium/cli",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "Runium CLI",
5
5
  "author": "TheBeastApp",
6
6
  "license": "MIT",
7
7
  "type": "module",
8
- "module": "./lib/index.js",
9
8
  "bin": {
10
- "runium": "./lib/index.js"
9
+ "runium": "./index.js"
11
10
  },
12
- "scripts": {
13
- "build": "rimraf ./lib && node build.js && tsc-alias",
14
- "build:tsc": "rimraf ./lib && tsc",
15
- "start": "node lib/index.js",
16
- "lint": "eslint ./src --ext .ts",
17
- "lint:fix": "eslint ./src --ext .ts --fix",
18
- "format": "prettier --write \"src/**/*.ts\""
11
+ "engines": {
12
+ "node": ">=20.12.0"
19
13
  },
14
+ "module": "./index.js",
20
15
  "dependencies": {
21
16
  "@runium/core": "^0.0.8",
22
17
  "@segment/ajv-human-errors": "^2.15.0",
23
18
  "commander": "^14.0.2",
24
19
  "reflect-metadata": "^0.2.2",
25
20
  "typedi": "^0.10.0"
26
- },
27
- "devDependencies": {
28
- "@runium/types-core": "^0.0.8",
29
- "@types/node": "^22.18.0",
30
- "@typescript-eslint/eslint-plugin": "^7.0.0",
31
- "@typescript-eslint/parser": "^7.0.0",
32
- "ajv": "^8.17.1",
33
- "esbuild": "^0.25.11",
34
- "esbuild-decorators": "^1.0.0",
35
- "eslint": "^8.56.0",
36
- "eslint-config-prettier": "^9.1.0",
37
- "eslint-plugin-prettier": "^5.1.3",
38
- "prettier": "^3.2.5",
39
- "rimraf": "^6.1.0",
40
- "ts-node": "^10.9.2",
41
- "tsc-alias": "^1.8.16",
42
- "typescript": "^5.3.3"
43
- },
44
- "engines": {
45
- "node": ">=20.12.0"
46
21
  }
47
- }
22
+ }
File without changes
File without changes
File without changes
package/.eslintrc.json DELETED
@@ -1,31 +0,0 @@
1
- {
2
- "env": {
3
- "node": true,
4
- "es2022": true
5
- },
6
- "extends": [
7
- "eslint:recommended",
8
- "plugin:@typescript-eslint/recommended",
9
- "plugin:prettier/recommended"
10
- ],
11
- "parser": "@typescript-eslint/parser",
12
- "parserOptions": {
13
- "ecmaVersion": 2022,
14
- "sourceType": "module"
15
- },
16
- "plugins": ["@typescript-eslint", "prettier"],
17
- "rules": {
18
- "prettier/prettier": "error",
19
- "@typescript-eslint/no-unused-vars": [
20
- "error",
21
- {
22
- "argsIgnorePattern": "^_",
23
- "varsIgnorePattern": "^_"
24
- }
25
- ],
26
- "@typescript-eslint/no-explicit-any": "warn",
27
- "no-console": "warn",
28
- "@typescript-eslint/ban-ts-ignore": "off"
29
- },
30
- "ignorePatterns": ["dist/", "node_modules/"]
31
- }
package/.prettierrc.json DELETED
@@ -1,10 +0,0 @@
1
- {
2
- "semi": true,
3
- "trailingComma": "es5",
4
- "singleQuote": true,
5
- "printWidth": 80,
6
- "tabWidth": 2,
7
- "useTabs": false,
8
- "endOfLine": "lf",
9
- "arrowParens": "avoid"
10
- }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # @runium/cli
2
-
3
- Runium CLI
package/build.js DELETED
@@ -1,125 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import {
4
- chmodSync,
5
- existsSync,
6
- mkdirSync,
7
- readFileSync,
8
- writeFileSync,
9
- readdirSync,
10
- unlinkSync,
11
- } from 'node:fs';
12
- import { resolve } from 'node:path';
13
- import { build } from 'esbuild';
14
- import { esbuildDecorators } from 'esbuild-decorators';
15
-
16
- const buildConfig = {
17
- entryPoints: ['src/**/*.ts'],
18
- bundle: false,
19
- platform: 'node',
20
- target: 'esnext',
21
- format: 'esm',
22
- outdir: 'lib',
23
- sourcemap: false,
24
- minify: true,
25
- treeShaking: false,
26
- plugins: [
27
- esbuildDecorators({
28
- experimentalDecorators: true,
29
- emitDecoratorMetadata: true,
30
- customDecoratorHandler: undefined,
31
- }),
32
- ],
33
- metafile: true,
34
- logLevel: 'info',
35
-
36
- };
37
-
38
-
39
- async function buildProject() {
40
- try {
41
- console.log('🔨 Building project with esbuild...');
42
-
43
- const libDir = 'lib';
44
- if (!existsSync(libDir)) {
45
- mkdirSync(libDir, { recursive: true });
46
- }
47
-
48
- const result = await build(buildConfig);
49
-
50
- // Delete .d.js files from the output directory
51
- console.log('🧹 Cleaning up .d.js files...');
52
- deleteDtsFiles(libDir);
53
-
54
- if (process.platform !== 'win32') {
55
- try {
56
- chmodSync('lib/index.js', '755');
57
- console.log('🔐 Made lib/index.js executable');
58
- } catch (error) {
59
- console.warn('⚠️ Could not make file executable:', error.message);
60
- }
61
- }
62
-
63
- console.log('🔨 Processing package.json...');
64
- await processPackageJson();
65
-
66
- console.log('✅ Build completed successfully!');
67
-
68
- // Print build stats if in development mode
69
- if (result.metafile) {
70
- console.log('\n📊 Build statistics:');
71
- const outputs = result.metafile.outputs;
72
- for (const [file, info] of Object.entries(outputs)) {
73
- console.log(` ${file}: ${(info.bytes / 1024).toFixed(2)} KB`);
74
- }
75
- }
76
- } catch (error) {
77
- console.error('❌ Build failed:', error);
78
- process.exit(1);
79
- }
80
- }
81
-
82
- async function processPackageJson() {
83
- let originalPackageJson = readFileSync('./package.json', {
84
- encoding: 'utf-8',
85
- });
86
-
87
- let packageJson = JSON.parse(originalPackageJson);
88
- const { dependencies } = packageJson;
89
-
90
- delete packageJson.dependencies;
91
- delete packageJson.devDependencies;
92
- delete packageJson.scripts;
93
- delete packageJson.module;
94
- delete packageJson.main;
95
-
96
- console.log('✅ Processed package.json', packageJson);
97
-
98
- packageJson = Object.assign(packageJson, {
99
- module: './index.js',
100
- bin: {
101
- runium: './index.js',
102
- },
103
- dependencies,
104
- });
105
-
106
- writeFileSync(
107
- resolve(import.meta.dirname, 'lib', 'package.json'),
108
- JSON.stringify(packageJson, null, 2)
109
- );
110
- }
111
-
112
- function deleteDtsFiles(dir) {
113
- const files = readdirSync(dir, { withFileTypes: true });
114
- for (const file of files) {
115
- const fullPath = resolve(dir, file.name);
116
- if (file.isDirectory()) {
117
- deleteDtsFiles(fullPath);
118
- } else if (file.name.endsWith('.d.js')) {
119
- unlinkSync(fullPath);
120
- console.log(`🗑️ Deleted ${fullPath}`);
121
- }
122
- }
123
- }
124
-
125
- buildProject();
package/lib/package.json DELETED
@@ -1,22 +0,0 @@
1
- {
2
- "name": "@runium/cli",
3
- "version": "0.0.3",
4
- "description": "Runium CLI",
5
- "author": "TheBeastApp",
6
- "license": "MIT",
7
- "type": "module",
8
- "bin": {
9
- "runium": "./index.js"
10
- },
11
- "engines": {
12
- "node": ">=20.12.0"
13
- },
14
- "module": "./index.js",
15
- "dependencies": {
16
- "@runium/core": "^0.0.8",
17
- "@segment/ajv-human-errors": "^2.15.0",
18
- "commander": "^14.0.2",
19
- "reflect-metadata": "^0.2.2",
20
- "typedi": "^0.10.0"
21
- }
22
- }
package/src/app.ts DELETED
@@ -1,190 +0,0 @@
1
- import { existsSync } from 'node:fs';
2
- import { resolve } from 'node:path';
3
- import { Command } from 'commander';
4
- import { Container } from 'typedi';
5
- import { RuniumError } from '@runium/core';
6
- import * as commands from '@commands';
7
- import {
8
- CommandService,
9
- ConfigService,
10
- ProfileService,
11
- PluginService,
12
- ShutdownService,
13
- OutputService,
14
- OutputLevel,
15
- PluginContextService,
16
- } from '@services';
17
- import { getVersion } from '@utils';
18
-
19
- const RUNIUM_DESCRIPTION = `╔═══════════════════════╗
20
- ║ ╔═╗ ╦ ╦ ╔╗╔ ╦ ╦ ╦ ╔╦╗ ║
21
- ║ ╠╦╝ ║ ║ ║║║ ║ ║ ║ ║║║ ║
22
- ║ ╩╚═ ╚═╝ ╝╚╝ ╩ ╚═╝ ╩ ╩ ║
23
- ╚═══════════════════════╝
24
- One Tool to Run Them All!`;
25
-
26
- export class RuniumCliApp {
27
- private readonly program: Command;
28
-
29
- private commandService: CommandService;
30
- private configService: ConfigService;
31
- private profileService: ProfileService;
32
- private pluginService: PluginService;
33
- private shutdownService: ShutdownService;
34
- private outputService: OutputService;
35
- private pluginContextService: PluginContextService;
36
-
37
- constructor() {
38
- this.program = new Command('runium');
39
- this.configService = Container.get(ConfigService);
40
- this.profileService = Container.get(ProfileService);
41
- this.pluginService = Container.get(PluginService);
42
- this.shutdownService = Container.get(ShutdownService);
43
- this.outputService = Container.get(OutputService);
44
- this.pluginContextService = Container.get(PluginContextService);
45
- this.commandService = Container.get(CommandService);
46
- }
47
-
48
- /**
49
- * Start the application
50
- */
51
- async start(): Promise<Command> {
52
- await this.configService.init().catch(error => {
53
- this.initOutput();
54
- throw error;
55
- });
56
- await this.shutdownService.init();
57
- await this.profileService.init();
58
- await this.pluginContextService.init();
59
-
60
- this.initOutput();
61
- this.initEnv();
62
-
63
- await this.loadPlugins();
64
- await this.initProgram();
65
- await this.initPlugins();
66
-
67
- return this.program.parseAsync();
68
- }
69
-
70
- /**
71
- * Load plugins
72
- */
73
- private async loadPlugins(): Promise<void> {
74
- const plugins = this.profileService.getPlugins();
75
- for (const plugin of plugins) {
76
- if (plugin.disabled !== true) {
77
- try {
78
- const pluginPath = this.pluginService.resolvePath(
79
- plugin.path,
80
- plugin.file
81
- );
82
- await this.pluginService.loadPlugin(pluginPath, plugin.options);
83
- } catch (error) {
84
- this.outputService.error(`Failed to load plugin "${plugin.name}"`);
85
- const { code, message, payload } = error as RuniumError;
86
- this.outputService.debug('Error details:', {
87
- message,
88
- code,
89
- payload,
90
- });
91
- }
92
- }
93
- }
94
- }
95
-
96
- /**
97
- * Initialize the program
98
- */
99
- private async initProgram(): Promise<void> {
100
- const program = this.program;
101
-
102
- program.option('-D, --debug', 'enable debug mode');
103
- program.option('-E, --env [paths...]', 'load env files');
104
- program.version(getVersion());
105
- program.description(RUNIUM_DESCRIPTION);
106
-
107
- program.on('option:debug', () => {
108
- this.setDebugMode();
109
- });
110
-
111
- program.on('option:env', path => {
112
- this.loadEnvFiles([path]);
113
- });
114
-
115
- Object.values(commands).forEach(CommandConstructor => {
116
- this.commandService.registerCommand(CommandConstructor, program);
117
- });
118
- }
119
-
120
- /**
121
- * Initialize the output
122
- */
123
- private initOutput(): void {
124
- const output = this.configService.get('output');
125
- if (
126
- output.debug ||
127
- process.argv.includes('-D') ||
128
- process.argv.includes('--debug')
129
- ) {
130
- this.setDebugMode();
131
- }
132
- }
133
-
134
- /**
135
- * Set debug mode
136
- */
137
- private setDebugMode(): void {
138
- if (this.outputService.getLevel() !== OutputLevel.DEBUG) {
139
- this.outputService.setLevel(OutputLevel.DEBUG);
140
- this.outputService.debug('Debug mode enabled');
141
- }
142
- }
143
-
144
- /**
145
- * Initialize the environment
146
- */
147
- private initEnv(): void {
148
- const env = this.configService.get('env');
149
- if (env.path.length > 0) {
150
- this.loadEnvFiles(env.path);
151
- }
152
- }
153
-
154
- /**
155
- * Set environment variables
156
- * @param path
157
- */
158
- private loadEnvFiles(path: string[]): void {
159
- for (const p of path) {
160
- const envPath = resolve((p && p.trim()) || '.env');
161
- if (existsSync(envPath)) {
162
- process.loadEnvFile(envPath);
163
- } else {
164
- this.outputService.error(`Env file "${envPath}" not found`);
165
- }
166
- }
167
- }
168
-
169
- /**
170
- * Initialize plugins
171
- */
172
- private async initPlugins(): Promise<void> {
173
- const plugins = this.pluginService.getAllPlugins();
174
- for (const plugin of plugins) {
175
- const commands = plugin.app?.commands;
176
- if (commands) {
177
- for (const command of commands) {
178
- this.commandService.registerCommand(
179
- command,
180
- this.program,
181
- plugin.name
182
- );
183
- }
184
- }
185
- }
186
- await this.pluginService.runHook('app.afterInit', {
187
- profilePath: this.configService.get('profile').path,
188
- });
189
- }
190
- }
@@ -1,2 +0,0 @@
1
- export { PluginCommand } from '@commands/plugin/plugin.js';
2
- export { ProjectCommand } from '@commands/project/project.js';
@@ -1,48 +0,0 @@
1
- import { RuniumError } from '@runium/core';
2
- import { ErrorCode } from '@constants';
3
- import { PluginCommand } from './plugin-command.js';
4
- /**
5
- * Plugin add command
6
- */
7
- export class PluginAddCommand extends PluginCommand {
8
- /**
9
- * Config command
10
- */
11
- protected config(): void {
12
- this.command
13
- .name('add')
14
- .description('add plugin')
15
- .option('-f, --file', 'use file path instead of plugin package name')
16
- .argument('<plugin>', 'plugin package name or absolute file path');
17
- }
18
-
19
- /**
20
- * Handle command
21
- * @param path
22
- * @param file
23
- */
24
- protected async handle(
25
- path: string,
26
- { file: isFile }: { file: boolean }
27
- ): Promise<void> {
28
- const pluginPath = this.pluginService.resolvePath(path, isFile);
29
- const name = await this.pluginService.loadPlugin(pluginPath, {});
30
- const plugin = this.pluginService.getPluginByName(name);
31
- if (plugin) {
32
- await this.profileService.addPlugin({
33
- name,
34
- path: isFile ? pluginPath : path,
35
- file: isFile,
36
- disabled: false,
37
- options: plugin.options ?? {},
38
- });
39
- this.outputService.success(`Plugin "%s" successfully added`, name);
40
- } else {
41
- throw new RuniumError(
42
- `Failed to add plugin "${path}"`,
43
- ErrorCode.PLUGIN_NOT_FOUND,
44
- { name, path }
45
- );
46
- }
47
- }
48
- }
@@ -1,36 +0,0 @@
1
- import { Command } from 'commander';
2
- import { Container } from 'typedi';
3
- import { RuniumError } from '@runium/core';
4
- import { RuniumCommand } from '@commands/runium-command.js';
5
- import { ErrorCode } from '@constants';
6
- import { PluginService, ProfileService, ProfilePlugin } from '@services';
7
-
8
- /**
9
- * Base plugin command
10
- */
11
- export abstract class PluginCommand extends RuniumCommand {
12
- protected pluginService: PluginService;
13
- protected profileService: ProfileService;
14
-
15
- constructor(parent: Command) {
16
- super(parent);
17
- this.pluginService = Container.get(PluginService);
18
- this.profileService = Container.get(ProfileService);
19
- }
20
-
21
- /**
22
- * Ensure plugin exists
23
- * @param name
24
- */
25
- protected ensureProfilePlugin(name: string): ProfilePlugin {
26
- const plugin = this.profileService.getPluginByName(name);
27
- if (!plugin) {
28
- throw new RuniumError(
29
- `Plugin "${name}" not found`,
30
- ErrorCode.PLUGIN_NOT_FOUND,
31
- { name }
32
- );
33
- }
34
- return plugin;
35
- }
36
- }
@@ -1,46 +0,0 @@
1
- import { PluginCommand } from './plugin-command.js';
2
-
3
- /**
4
- * Plugin disable command
5
- */
6
- export class PluginDisableCommand extends PluginCommand {
7
- /**
8
- * Config command
9
- */
10
- protected config(): void {
11
- this.command
12
- .name('disable')
13
- .description('disable plugin')
14
- .option('-a, --all', 'disable all plugins')
15
- .argument('[name...]', 'plugin names');
16
- }
17
-
18
- /**
19
- * Handle command
20
- * @param names
21
- * @param all
22
- */
23
- protected async handle(
24
- names: string[],
25
- { all }: { all: boolean }
26
- ): Promise<void> {
27
- if (names.length === 0 && !all) {
28
- this.outputService.warn('No plugins specified to disable');
29
- return;
30
- }
31
- if (all) {
32
- names = this.profileService.getPlugins().map(p => p.name);
33
- }
34
-
35
- for (const name of names) {
36
- const plugin = this.ensureProfilePlugin(name);
37
- if (plugin.disabled) {
38
- this.outputService.info(`Plugin "%s" is already disabled`, name);
39
- continue;
40
- }
41
- await this.profileService.updatePlugin(name, { disabled: true });
42
- await this.pluginService.unloadPlugin(name);
43
- this.outputService.success(`Plugin "%s" successfully disabled`, name);
44
- }
45
- }
46
- }
@@ -1,50 +0,0 @@
1
- import { PluginCommand } from './plugin-command.js';
2
-
3
- /**
4
- * Plugin enable command
5
- */
6
- export class PluginEnableCommand extends PluginCommand {
7
- /**
8
- * Config command
9
- */
10
- protected config(): void {
11
- this.command
12
- .name('enable')
13
- .description('enable plugin')
14
- .option('-a, --all', 'enable all plugins')
15
- .argument('[name...]', 'plugin names');
16
- }
17
-
18
- /**
19
- * Handle command
20
- * @param names
21
- * @param all
22
- */
23
- protected async handle(
24
- names: string[],
25
- { all }: { all: boolean }
26
- ): Promise<void> {
27
- if (names.length === 0 && !all) {
28
- this.outputService.warn('No plugins specified to enable');
29
- return;
30
- }
31
- if (all) {
32
- names = this.profileService.getPlugins().map(p => p.name);
33
- }
34
-
35
- for (const name of names) {
36
- const plugin = this.ensureProfilePlugin(name);
37
- if (!plugin.disabled) {
38
- this.outputService.info(`Plugin "%s" is already enabled`, name);
39
- continue;
40
- }
41
- await this.profileService.updatePlugin(name, { disabled: false });
42
- const pluginPath = this.pluginService.resolvePath(
43
- plugin.path,
44
- plugin.file
45
- );
46
- await this.pluginService.loadPlugin(pluginPath, plugin.options);
47
- this.outputService.success(`Plugin "%s" successfully enabled`, name);
48
- }
49
- }
50
- }