@dx-pkg/mksymlink 1.0.4 → 1.0.7

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 (54) hide show
  1. package/README.md +1 -0
  2. package/package.json +2 -2
  3. package/src/commands/create/mksymlink.command-factory.js +3 -5
  4. package/src/commands/create/mksymlink.command.d.ts +3 -2
  5. package/src/commands/create/mksymlink.command.js +5 -3
  6. package/src/commands/create/mksymlink.option-validator.js +0 -1
  7. package/src/commands/index.js +0 -1
  8. package/src/index.js +0 -1
  9. package/examples/advanced-usage.d.ts +0 -2
  10. package/examples/advanced-usage.js +0 -39
  11. package/examples/basic-usage.d.ts +0 -2
  12. package/examples/basic-usage.js +0 -15
  13. package/examples/config-usage.d.ts +0 -3
  14. package/examples/config-usage.js +0 -65
  15. package/examples/cross-platform.d.ts +0 -2
  16. package/examples/cross-platform.js +0 -41
  17. package/examples/index.d.ts +0 -2
  18. package/examples/index.js +0 -7
  19. package/src/commands/config/config.command-factory.d.ts +0 -5
  20. package/src/commands/config/config.command-factory.js +0 -18
  21. package/src/commands/config/config.command.d.ts +0 -23
  22. package/src/commands/config/config.command.js +0 -94
  23. package/src/commands/config/config.option-validator.d.ts +0 -9
  24. package/src/commands/config/config.option-validator.js +0 -41
  25. package/src/commands/config.command-factory.d.ts +0 -5
  26. package/src/commands/config.command-factory.js +0 -18
  27. package/src/commands/config.command.d.ts +0 -22
  28. package/src/commands/config.command.js +0 -80
  29. package/src/commands/config.option-validator.d.ts +0 -9
  30. package/src/commands/config.option-validator.js +0 -41
  31. package/src/commands/create/mksymlink.command-factory.d.ts +0 -5
  32. package/src/commands/create/mksymlink.option-validator.d.ts +0 -9
  33. package/src/commands/index.d.ts +0 -3
  34. package/src/commands/mksymlink.command-factory.d.ts +0 -5
  35. package/src/commands/mksymlink.command-factory.js +0 -20
  36. package/src/commands/mksymlink.command.d.ts +0 -22
  37. package/src/commands/mksymlink.command.js +0 -68
  38. package/src/commands/mksymlink.option-validator.d.ts +0 -9
  39. package/src/commands/mksymlink.option-validator.js +0 -35
  40. package/src/index.d.ts +0 -12
  41. package/src/services/config.service.d.ts +0 -45
  42. package/src/services/config.service.js +0 -113
  43. package/src/services/os-detector.d.ts +0 -11
  44. package/src/services/os-detector.js +0 -36
  45. package/src/services/platform-detector.d.ts +0 -11
  46. package/src/services/platform-detector.js +0 -36
  47. package/src/services/symlink-error.d.ts +0 -12
  48. package/src/services/symlink-error.js +0 -33
  49. package/src/services/symlink-manager.d.ts +0 -13
  50. package/src/services/symlink-manager.js +0 -115
  51. package/src/services/symlink.service.d.ts +0 -13
  52. package/src/services/symlink.service.js +0 -115
  53. package/src/types/index.d.ts +0 -40
  54. package/src/types/index.js +0 -3
package/README.md CHANGED
@@ -168,6 +168,7 @@ npx mksymlink config set symlink.defaultDir ~/test-symlinks
168
168
  npx mksymlink config list
169
169
  npx mksymlink config get symlink.defaultDir
170
170
  npx mksymlink config unset symlink.defaultDir
171
+ npx mksymlink config info
171
172
 
172
173
  # Create mode
173
174
  npx mksymlink create -s /path/to/source -t /path/to/target
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dx-pkg/mksymlink",
3
- "version": "1.0.4",
3
+ "version": "1.0.7",
4
4
  "description": "Create symbolic links across platforms (macOS, Windows)",
5
5
  "type": "commonjs",
6
6
  "main": "./src/index.js",
@@ -19,7 +19,7 @@
19
19
  "mksymlink": "src/commands/index.js"
20
20
  },
21
21
  "scripts": {
22
- "build": "tsc -p tsconfig.json",
22
+ "build": "tsc -p tsconfig.prod.json",
23
23
  "watch": "tsc -p tsconfig.json --watch",
24
24
  "dev": "tsc-watch -b --onSuccess \"npm start\"",
25
25
  "start": "node ../../dist/packages/mksymlink/examples/index.js",
@@ -3,18 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MkSymlinkCommandFactory = void 0;
4
4
  const logger_1 = require("@dx-pkg/logger");
5
5
  const mksymlink_command_1 = require("./mksymlink.command");
6
- const mksymlink_option_validator_1 = require("./mksymlink.option-validator");
7
6
  const symlink_service_1 = require("../../services/symlink.service");
8
7
  const platform_detector_1 = require("../../services/platform-detector");
8
+ const mksymlink_option_validator_1 = require("./mksymlink.option-validator");
9
9
  class MkSymlinkCommandFactory {
10
10
  static create(options) {
11
- const validator = new mksymlink_option_validator_1.MkSymlinkOptionValidator();
12
- validator.validate(options);
11
+ const optionValidator = new mksymlink_option_validator_1.MkSymlinkOptionValidator();
13
12
  const logger = new logger_1.ConsoleLogger();
14
13
  const osDetector = new platform_detector_1.PlatformDetector();
15
14
  const symlinkManager = new symlink_service_1.SymlinkService(logger, osDetector);
16
- return new mksymlink_command_1.MkSymlinkCommand(logger, symlinkManager, options);
15
+ return new mksymlink_command_1.MkSymlinkCommand(optionValidator, logger, symlinkManager, options);
17
16
  }
18
17
  }
19
18
  exports.MkSymlinkCommandFactory = MkSymlinkCommandFactory;
20
- //# sourceMappingURL=mksymlink.command-factory.js.map
@@ -1,6 +1,7 @@
1
1
  import { Logger } from '@dx-pkg/logger';
2
2
  import { Command, WindowsSymlinkType, SymlinkOperations } from '../../types';
3
3
  import { ConfigService } from '../../services/config.service';
4
+ import { MkSymlinkOptionValidator } from './mksymlink.option-validator';
4
5
  export interface MkSymlinkCommandOptions {
5
6
  target?: string;
6
7
  source?: string;
@@ -10,13 +11,13 @@ export interface MkSymlinkCommandOptions {
10
11
  }
11
12
  export declare const SYMLINK_TYPES: readonly WindowsSymlinkType[];
12
13
  export declare class MkSymlinkCommand implements Command<MkSymlinkCommandOptions> {
14
+ private readonly optionValidator;
13
15
  private readonly logger;
14
16
  private readonly symlinkManager;
15
17
  private readonly options;
16
18
  private readonly configService;
17
- constructor(logger: Logger, symlinkManager: SymlinkOperations, options: MkSymlinkCommandOptions, configService?: ConfigService);
19
+ constructor(optionValidator: MkSymlinkOptionValidator, logger: Logger, symlinkManager: SymlinkOperations, options: MkSymlinkCommandOptions, configService?: ConfigService);
18
20
  execute(): Promise<void>;
19
21
  private resolveOptions;
20
22
  private generateDefaultTarget;
21
23
  }
22
- //# sourceMappingURL=mksymlink.command.d.ts.map
@@ -5,17 +5,20 @@ const path_1 = require("path");
5
5
  const config_service_1 = require("../../services/config.service");
6
6
  exports.SYMLINK_TYPES = ['file', 'dir', 'junction'];
7
7
  class MkSymlinkCommand {
8
+ optionValidator;
8
9
  logger;
9
10
  symlinkManager;
10
11
  options;
11
12
  configService;
12
- constructor(logger, symlinkManager, options, configService = new config_service_1.ConfigService()) {
13
+ constructor(optionValidator, logger, symlinkManager, options, configService = new config_service_1.ConfigService()) {
14
+ this.optionValidator = optionValidator;
13
15
  this.logger = logger;
14
16
  this.symlinkManager = symlinkManager;
15
17
  this.options = options;
16
18
  this.configService = configService;
17
19
  }
18
20
  async execute() {
21
+ this.optionValidator.validate(this.options);
19
22
  try {
20
23
  const { source, target, type, force } = this.resolveOptions();
21
24
  this.logger.info('Creating symlink with options:');
@@ -49,7 +52,7 @@ class MkSymlinkCommand {
49
52
  const currentDir = process.cwd();
50
53
  const source = this.options.source || currentDir;
51
54
  const target = this.options.target || this.generateDefaultTarget(currentDir);
52
- const type = this.options.type || 'dir';
55
+ const type = this.options.type || 'junction';
53
56
  const force = this.options.force || false;
54
57
  return { source, target, type, force };
55
58
  }
@@ -65,4 +68,3 @@ class MkSymlinkCommand {
65
68
  }
66
69
  }
67
70
  exports.MkSymlinkCommand = MkSymlinkCommand;
68
- //# sourceMappingURL=mksymlink.command.js.map
@@ -32,4 +32,3 @@ class MkSymlinkOptionValidator {
32
32
  }
33
33
  }
34
34
  exports.MkSymlinkOptionValidator = MkSymlinkOptionValidator;
35
- //# sourceMappingURL=mksymlink.option-validator.js.map
@@ -116,4 +116,3 @@ configCmd
116
116
  }
117
117
  });
118
118
  program.parse(process.argv);
119
- //# sourceMappingURL=index.js.map
package/src/index.js CHANGED
@@ -25,4 +25,3 @@ __exportStar(require("./commands/create/mksymlink.command-factory"), exports);
25
25
  __exportStar(require("./commands/config/config.command"), exports);
26
26
  __exportStar(require("./commands/config/config.option-validator"), exports);
27
27
  __exportStar(require("./commands/config/config.command-factory"), exports);
28
- //# sourceMappingURL=index.js.map
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=advanced-usage.d.ts.map
@@ -1,39 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const src_1 = require("../src");
4
- const logger_1 = require("@dx-pkg/logger");
5
- async function advancedExample() {
6
- console.log('=== Advanced Symlink Manager Usage ===\n');
7
- const logger = new logger_1.ConsoleLogger();
8
- const osDetector = new src_1.PlatformDetector();
9
- const symlinkManager = new src_1.SymlinkService(logger, osDetector);
10
- console.log(`Detected OS: ${osDetector.getPlatform()}\n`);
11
- const source = process.cwd();
12
- const target = '/tmp/advanced-symlink';
13
- console.log('Checking if symlink exists...');
14
- const exists = await symlinkManager.symlinkExists(target);
15
- console.log(`Symlink exists: ${exists}\n`);
16
- if (exists) {
17
- console.log('Removing existing symlink...');
18
- await symlinkManager.removeSymlink(target);
19
- console.log('Removed successfully\n');
20
- }
21
- console.log('Creating new symlink...');
22
- const result = await symlinkManager.createSymlink({
23
- source,
24
- target,
25
- type: osDetector.isWindows() ? 'junction' : 'dir',
26
- force: false,
27
- });
28
- if (result.success) {
29
- console.log('\nSymlink created successfully!');
30
- console.log(` Source: ${result.source}`);
31
- console.log(` Target: ${result.target}`);
32
- }
33
- else {
34
- console.error('\nFailed to create symlink:');
35
- console.error(` ${result.message || result.error?.message}`);
36
- }
37
- }
38
- advancedExample().catch(console.error);
39
- //# sourceMappingURL=advanced-usage.js.map
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=basic-usage.d.ts.map
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const src_1 = require("../src");
4
- const path_1 = require("path");
5
- async function basicExample() {
6
- console.log('=== Basic Symlink Creation ===\n');
7
- const command = src_1.MkSymlinkCommandFactory.create({
8
- source: process.cwd(),
9
- target: (0, path_1.join)(process.cwd(), 'target-symlink'),
10
- type: 'dir',
11
- });
12
- await command.execute();
13
- }
14
- basicExample().catch(console.error);
15
- //# sourceMappingURL=basic-usage.js.map
@@ -1,3 +0,0 @@
1
- declare function configExamples(): Promise<void>;
2
- export { configExamples };
3
- //# sourceMappingURL=config-usage.d.ts.map
@@ -1,65 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.configExamples = configExamples;
4
- const config_command_factory_1 = require("../src/commands/config/config.command-factory");
5
- const path_1 = require("path");
6
- const os_1 = require("os");
7
- async function configExamples() {
8
- console.log('=== Config Command Examples ===\n');
9
- try {
10
- // Example 1: List all configuration
11
- console.log('1. List all configuration:');
12
- const listCommand = config_command_factory_1.ConfigCommandFactory.create({ action: 'list' });
13
- await listCommand.execute();
14
- console.log('');
15
- // Example 2: Set default symlink directory
16
- console.log('2. Set default symlink directory:');
17
- const setCommand = config_command_factory_1.ConfigCommandFactory.create({
18
- action: 'set',
19
- key: 'symlink.defaultDir',
20
- value: (0, path_1.join)((0, os_1.homedir)(), 'symlinks'),
21
- });
22
- await setCommand.execute();
23
- console.log('');
24
- // Example 3: Get a specific config value
25
- console.log('3. Get default symlink directory:');
26
- const getCommand = config_command_factory_1.ConfigCommandFactory.create({
27
- action: 'get',
28
- key: 'symlink.defaultDir',
29
- });
30
- await getCommand.execute();
31
- console.log('');
32
- // Example 4: Set a custom config key
33
- console.log('4. Set a custom config key:');
34
- const setCustomCommand = config_command_factory_1.ConfigCommandFactory.create({
35
- action: 'set',
36
- key: 'user.name',
37
- value: 'John Doe',
38
- });
39
- await setCustomCommand.execute();
40
- console.log('');
41
- // Example 5: List all configuration again (to see changes)
42
- console.log('5. List all configuration (after changes):');
43
- const listCommand2 = config_command_factory_1.ConfigCommandFactory.create({ action: 'list' });
44
- await listCommand2.execute();
45
- console.log('');
46
- // Example 6: Unset a config value
47
- console.log('6. Unset user.name:');
48
- const unsetCommand = config_command_factory_1.ConfigCommandFactory.create({
49
- action: 'unset',
50
- key: 'user.name',
51
- });
52
- await unsetCommand.execute();
53
- console.log('');
54
- // Example 7: List configuration one more time
55
- console.log('7. List configuration (after unset):');
56
- const listCommand3 = config_command_factory_1.ConfigCommandFactory.create({ action: 'list' });
57
- await listCommand3.execute();
58
- console.log('');
59
- console.log('=== Config Examples Completed ===\n');
60
- }
61
- catch (error) {
62
- console.error('Error running config examples:', error);
63
- }
64
- }
65
- //# sourceMappingURL=config-usage.js.map
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=cross-platform.d.ts.map
@@ -1,41 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const src_1 = require("../src");
4
- async function crossPlatformExample() {
5
- console.log('=== Cross-Platform Symlink Example ===\n');
6
- const osDetector = new src_1.PlatformDetector();
7
- const platform = osDetector.getPlatform();
8
- console.log(`Current platform: ${platform}`);
9
- console.log(`Is Windows: ${osDetector.isWindows()}`);
10
- console.log(`Is macOS: ${osDetector.isMacOS()}`);
11
- console.log(`Is Linux: ${osDetector.isLinux()}\n`);
12
- const source = process.cwd();
13
- let target;
14
- let type;
15
- if (osDetector.isWindows()) {
16
- target = 'C:\\temp\\my-symlink';
17
- type = 'junction';
18
- console.log('Using Windows junction for better compatibility\n');
19
- }
20
- else {
21
- target = '/tmp/my-symlink';
22
- type = 'dir';
23
- console.log('Using standard directory symlink\n');
24
- }
25
- const command = src_1.MkSymlinkCommandFactory.create({
26
- source,
27
- target,
28
- type,
29
- force: true,
30
- });
31
- try {
32
- await command.execute();
33
- console.log('\nCross-platform symlink created successfully!');
34
- }
35
- catch (error) {
36
- console.error('\nFailed to create symlink:');
37
- console.error(error);
38
- }
39
- }
40
- crossPlatformExample().catch(console.error);
41
- //# sourceMappingURL=cross-platform.js.map
@@ -1,2 +0,0 @@
1
- import './basic-usage';
2
- //# sourceMappingURL=index.d.ts.map
package/examples/index.js DELETED
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- require("./basic-usage");
4
- // import { configExamples } from './config-usage';
5
- // Uncomment to run config examples:
6
- // configExamples().catch(console.error);
7
- //# sourceMappingURL=index.js.map
@@ -1,5 +0,0 @@
1
- import { ConfigCommand, ConfigCommandOptions } from './config.command';
2
- export declare class ConfigCommandFactory {
3
- static create(options: ConfigCommandOptions): ConfigCommand;
4
- }
5
- //# sourceMappingURL=config.command-factory.d.ts.map
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ConfigCommandFactory = void 0;
4
- const logger_1 = require("@dx-pkg/logger");
5
- const config_command_1 = require("./config.command");
6
- const config_option_validator_1 = require("./config.option-validator");
7
- const config_service_1 = require("../../services/config.service");
8
- class ConfigCommandFactory {
9
- static create(options) {
10
- const validator = new config_option_validator_1.ConfigOptionValidator();
11
- validator.validate(options);
12
- const logger = new logger_1.ConsoleLogger();
13
- const configService = new config_service_1.ConfigService();
14
- return new config_command_1.ConfigCommand(logger, configService, options);
15
- }
16
- }
17
- exports.ConfigCommandFactory = ConfigCommandFactory;
18
- //# sourceMappingURL=config.command-factory.js.map
@@ -1,23 +0,0 @@
1
- import { Logger } from '@dx-pkg/logger';
2
- import { Command } from '../../types';
3
- import { ConfigService } from '../../services/config.service';
4
- export type ConfigAction = 'get' | 'set' | 'unset' | 'list' | 'info';
5
- export interface ConfigCommandOptions {
6
- action: ConfigAction;
7
- key?: string;
8
- value?: string;
9
- [key: string]: unknown;
10
- }
11
- export declare class ConfigCommand implements Command<ConfigCommandOptions> {
12
- private readonly logger;
13
- private readonly configService;
14
- private readonly options;
15
- constructor(logger: Logger, configService: ConfigService, options: ConfigCommandOptions);
16
- execute(): Promise<void>;
17
- private handleGet;
18
- private handleSet;
19
- private handleUnset;
20
- private handleList;
21
- private handleInfo;
22
- }
23
- //# sourceMappingURL=config.command.d.ts.map
@@ -1,94 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ConfigCommand = void 0;
4
- class ConfigCommand {
5
- logger;
6
- configService;
7
- options;
8
- constructor(logger, configService, options) {
9
- this.logger = logger;
10
- this.configService = configService;
11
- this.options = options;
12
- }
13
- async execute() {
14
- try {
15
- const { action, key, value } = this.options;
16
- switch (action) {
17
- case 'get':
18
- await this.handleGet(key);
19
- break;
20
- case 'set':
21
- await this.handleSet(key, value);
22
- break;
23
- case 'unset':
24
- await this.handleUnset(key);
25
- break;
26
- case 'list':
27
- await this.handleList();
28
- break;
29
- case 'info':
30
- await this.handleInfo();
31
- break;
32
- default:
33
- throw new Error(`Unknown config action: ${action}`);
34
- }
35
- }
36
- catch (error) {
37
- this.logger.error(`Config command failed: ${error instanceof Error ? error.message : String(error)}`);
38
- throw error;
39
- }
40
- }
41
- async handleGet(key) {
42
- if (!key) {
43
- throw new Error('Key is required for get action');
44
- }
45
- const value = this.configService.get(key);
46
- if (value === undefined) {
47
- this.logger.warning(`Config key '${key}' not found`);
48
- return;
49
- }
50
- this.logger.info(value);
51
- }
52
- async handleSet(key, value) {
53
- if (!key) {
54
- throw new Error('Key is required for set action');
55
- }
56
- if (!value) {
57
- throw new Error('Value is required for set action');
58
- }
59
- this.configService.set(key, value);
60
- this.logger.success(`Config set: ${key} = ${value}`);
61
- }
62
- async handleUnset(key) {
63
- if (!key) {
64
- throw new Error('Key is required for unset action');
65
- }
66
- this.configService.unset(key);
67
- this.logger.success(`Config unset: ${key}`);
68
- }
69
- async handleList() {
70
- const config = this.configService.list();
71
- const entries = Object.entries(config);
72
- if (entries.length === 0) {
73
- this.logger.info('No configuration found');
74
- return;
75
- }
76
- this.logger.info('Current configuration:');
77
- for (const [key, value] of entries) {
78
- this.logger.info(` ${key} = ${value}`);
79
- }
80
- }
81
- async handleInfo() {
82
- const info = this.configService.getConfigInfo();
83
- this.logger.info('Configuration file information:');
84
- this.logger.info(` Path: ${info.path}`);
85
- this.logger.info(` Exists: ${info.exists ? 'Yes' : 'No'}`);
86
- if (info.exists) {
87
- this.logger.info(` Size: ${info.size} bytes`);
88
- this.logger.info(` Modified: ${info.modified?.toLocaleString()}`);
89
- }
90
- this.logger.info(` Entries: ${info.entries}`);
91
- }
92
- }
93
- exports.ConfigCommand = ConfigCommand;
94
- //# sourceMappingURL=config.command.js.map
@@ -1,9 +0,0 @@
1
- import { CommandOptionsValidator } from '../../types';
2
- import { ConfigCommandOptions } from './config.command';
3
- export declare class ConfigOptionValidator implements CommandOptionsValidator<ConfigCommandOptions> {
4
- validate(options: ConfigCommandOptions): void;
5
- private validateAction;
6
- private validateKey;
7
- private validateValue;
8
- }
9
- //# sourceMappingURL=config.option-validator.d.ts.map
@@ -1,41 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ConfigOptionValidator = void 0;
4
- const symlink_error_1 = require("../../services/symlink-error");
5
- const VALID_ACTIONS = ['get', 'set', 'unset', 'list', 'info'];
6
- class ConfigOptionValidator {
7
- validate(options) {
8
- this.validateAction(options.action);
9
- this.validateKey(options.action, options.key);
10
- this.validateValue(options.action, options.value);
11
- }
12
- validateAction(action) {
13
- if (!VALID_ACTIONS.includes(action)) {
14
- throw new symlink_error_1.SymlinkError(`Invalid config action: ${action}. Must be one of: ${VALID_ACTIONS.join(', ')}`, 'INVALID_CONFIG_ACTION');
15
- }
16
- }
17
- validateKey(action, key) {
18
- if (action === 'list' || action === 'info') {
19
- return; // list and info don't require a key
20
- }
21
- if (!key) {
22
- throw new symlink_error_1.SymlinkError(`Key is required for '${action}' action`, 'MISSING_CONFIG_KEY');
23
- }
24
- if (typeof key !== 'string' || key.trim().length === 0) {
25
- throw new symlink_error_1.SymlinkError(`Invalid config key: ${key}. Key must be a non-empty string.`, 'INVALID_CONFIG_KEY');
26
- }
27
- }
28
- validateValue(action, value) {
29
- if (action !== 'set') {
30
- return; // only 'set' requires a value
31
- }
32
- if (!value) {
33
- throw new symlink_error_1.SymlinkError(`Value is required for 'set' action`, 'MISSING_CONFIG_VALUE');
34
- }
35
- if (typeof value !== 'string') {
36
- throw new symlink_error_1.SymlinkError(`Invalid config value: ${value}. Value must be a string.`, 'INVALID_CONFIG_VALUE');
37
- }
38
- }
39
- }
40
- exports.ConfigOptionValidator = ConfigOptionValidator;
41
- //# sourceMappingURL=config.option-validator.js.map
@@ -1,5 +0,0 @@
1
- import { ConfigCommand, ConfigCommandOptions } from './config.command';
2
- export declare class ConfigCommandFactory {
3
- static create(options: ConfigCommandOptions): ConfigCommand;
4
- }
5
- //# sourceMappingURL=config.command-factory.d.ts.map
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ConfigCommandFactory = void 0;
4
- const logger_1 = require("@dx-tools/logger");
5
- const config_command_1 = require("./config.command");
6
- const config_option_validator_1 = require("./config.option-validator");
7
- const config_service_1 = require("../services/config.service");
8
- class ConfigCommandFactory {
9
- static create(options) {
10
- const validator = new config_option_validator_1.ConfigOptionValidator();
11
- validator.validate(options);
12
- const logger = new logger_1.ConsoleLogger();
13
- const configService = new config_service_1.ConfigService();
14
- return new config_command_1.ConfigCommand(logger, configService, options);
15
- }
16
- }
17
- exports.ConfigCommandFactory = ConfigCommandFactory;
18
- //# sourceMappingURL=config.command-factory.js.map
@@ -1,22 +0,0 @@
1
- import { Logger } from '@dx-pkg/logger';
2
- import { Command } from '../types';
3
- import { ConfigService } from '../services/config.service';
4
- export type ConfigAction = 'get' | 'set' | 'unset' | 'list';
5
- export interface ConfigCommandOptions {
6
- action: ConfigAction;
7
- key?: string;
8
- value?: string;
9
- [key: string]: unknown;
10
- }
11
- export declare class ConfigCommand implements Command<ConfigCommandOptions> {
12
- private readonly logger;
13
- private readonly configService;
14
- private readonly options;
15
- constructor(logger: Logger, configService: ConfigService, options: ConfigCommandOptions);
16
- execute(): Promise<void>;
17
- private handleGet;
18
- private handleSet;
19
- private handleUnset;
20
- private handleList;
21
- }
22
- //# sourceMappingURL=config.command.d.ts.map
@@ -1,80 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ConfigCommand = void 0;
4
- class ConfigCommand {
5
- logger;
6
- configService;
7
- options;
8
- constructor(logger, configService, options) {
9
- this.logger = logger;
10
- this.configService = configService;
11
- this.options = options;
12
- }
13
- async execute() {
14
- try {
15
- const { action, key, value } = this.options;
16
- switch (action) {
17
- case 'get':
18
- await this.handleGet(key);
19
- break;
20
- case 'set':
21
- await this.handleSet(key, value);
22
- break;
23
- case 'unset':
24
- await this.handleUnset(key);
25
- break;
26
- case 'list':
27
- await this.handleList();
28
- break;
29
- default:
30
- throw new Error(`Unknown config action: ${action}`);
31
- }
32
- }
33
- catch (error) {
34
- this.logger.error(`Config command failed: ${error instanceof Error ? error.message : String(error)}`);
35
- throw error;
36
- }
37
- }
38
- async handleGet(key) {
39
- if (!key) {
40
- throw new Error('Key is required for get action');
41
- }
42
- const value = this.configService.get(key);
43
- if (value === undefined) {
44
- this.logger.warning(`Config key '${key}' not found`);
45
- return;
46
- }
47
- this.logger.info(value);
48
- }
49
- async handleSet(key, value) {
50
- if (!key) {
51
- throw new Error('Key is required for set action');
52
- }
53
- if (!value) {
54
- throw new Error('Value is required for set action');
55
- }
56
- this.configService.set(key, value);
57
- this.logger.success(`Config set: ${key} = ${value}`);
58
- }
59
- async handleUnset(key) {
60
- if (!key) {
61
- throw new Error('Key is required for unset action');
62
- }
63
- this.configService.unset(key);
64
- this.logger.success(`Config unset: ${key}`);
65
- }
66
- async handleList() {
67
- const config = this.configService.list();
68
- const entries = Object.entries(config);
69
- if (entries.length === 0) {
70
- this.logger.info('No configuration found');
71
- return;
72
- }
73
- this.logger.info('Current configuration:');
74
- for (const [key, value] of entries) {
75
- this.logger.info(` ${key} = ${value}`);
76
- }
77
- }
78
- }
79
- exports.ConfigCommand = ConfigCommand;
80
- //# sourceMappingURL=config.command.js.map
@@ -1,9 +0,0 @@
1
- import { CommandOptionsValidator } from '../types';
2
- import { ConfigCommandOptions } from './config.command';
3
- export declare class ConfigOptionValidator implements CommandOptionsValidator<ConfigCommandOptions> {
4
- validate(options: ConfigCommandOptions): void;
5
- private validateAction;
6
- private validateKey;
7
- private validateValue;
8
- }
9
- //# sourceMappingURL=config.option-validator.d.ts.map