@dx-pkg/mksymlink 1.0.6 → 1.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.
package/package.json
CHANGED
|
@@ -3,17 +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
|
|
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;
|
|
@@ -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,11 +11,12 @@ 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;
|
|
@@ -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 || '
|
|
55
|
+
const type = this.options.type || 'junction';
|
|
53
56
|
const force = this.options.force || false;
|
|
54
57
|
return { source, target, type, force };
|
|
55
58
|
}
|