@dx-pkg/mksymlink 1.0.10 → 1.0.14
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/CHANGELOG.md
ADDED
package/README.md
CHANGED
|
@@ -20,27 +20,44 @@ npm install -g @dx-pkg/mksymlink
|
|
|
20
20
|
|
|
21
21
|
## Quick Start
|
|
22
22
|
|
|
23
|
+
### Create symlinks in the current directory (CWD)
|
|
24
|
+
|
|
25
|
+
Generate symlinks from any source directly into your current terminal session's directory.
|
|
26
|
+
|
|
23
27
|
```bash
|
|
24
|
-
#
|
|
25
|
-
mksymlink
|
|
28
|
+
# Explicitly define source and target
|
|
29
|
+
mksymlink -s ~/projects/my-app -t .
|
|
30
|
+
|
|
31
|
+
# Creates: ~/projects/my-app -> ./my-app
|
|
32
|
+
```
|
|
26
33
|
|
|
27
|
-
|
|
34
|
+
```bash
|
|
35
|
+
# Create a symlink of the current folder inside itself (or to a target)
|
|
28
36
|
cd ~/projects/my-app
|
|
29
|
-
mksymlink
|
|
37
|
+
mksymlink -t .
|
|
30
38
|
|
|
31
|
-
# Creates: ~/
|
|
39
|
+
# Creates: ~/projects/my-app -> ~/projects/my-app/my-app
|
|
32
40
|
```
|
|
33
41
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
### `mksymlink` (Quick Mode)
|
|
42
|
+
### Save to a default directory
|
|
37
43
|
|
|
38
|
-
|
|
44
|
+
You can configure a global destination so you don't have to specify the target path every time.
|
|
39
45
|
|
|
40
46
|
```bash
|
|
41
|
-
|
|
47
|
+
# 1. Configure the default symlink destination
|
|
48
|
+
mksymlink config set symlink.defaultDir ~/my-symlinks
|
|
49
|
+
|
|
50
|
+
# 2. Run without arguments to use the default directory (configured at `symlink.defaultDir`)
|
|
51
|
+
cd ~/projects/my-app
|
|
52
|
+
mksymlink
|
|
53
|
+
|
|
54
|
+
# Creates: ~/projects/my-app -> ~/my-symlinks/projects--my-app
|
|
42
55
|
```
|
|
43
56
|
|
|
57
|
+
## CLI Commands
|
|
58
|
+
|
|
59
|
+
### `mksymlink` (alias as `mksymlink create`)
|
|
60
|
+
|
|
44
61
|
### `mksymlink create`
|
|
45
62
|
|
|
46
63
|
Create symlink with full control over source and target.
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dx-pkg/mksymlink",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.14",
|
|
4
4
|
"description": "Create symbolic links across platforms (macOS, Windows)",
|
|
5
|
+
"private": false,
|
|
5
6
|
"type": "commonjs",
|
|
6
7
|
"main": "./src/index.js",
|
|
7
8
|
"types": "./src/index.d.ts",
|
|
@@ -27,7 +28,8 @@
|
|
|
27
28
|
"test:watch": "jest --watch",
|
|
28
29
|
"test:coverage": "jest --coverage",
|
|
29
30
|
"lint": "eslint . --ext .ts",
|
|
30
|
-
"format": "prettier --write \"**/*.{ts,json,md}\""
|
|
31
|
+
"format": "prettier --write \"**/*.{ts,json,md}\"",
|
|
32
|
+
"bin": "node ../../dist/packages/mksymlink/src/commands/index.js"
|
|
31
33
|
},
|
|
32
34
|
"keywords": [
|
|
33
35
|
"symlink",
|
|
@@ -38,7 +40,7 @@
|
|
|
38
40
|
"cli"
|
|
39
41
|
],
|
|
40
42
|
"dependencies": {
|
|
41
|
-
"@dx-pkg/logger": "^1.0.
|
|
43
|
+
"@dx-pkg/logger": "^1.0.3",
|
|
42
44
|
"chalk": "^5.6.2",
|
|
43
45
|
"commander": "^12.0.0"
|
|
44
46
|
},
|
|
@@ -19,5 +19,6 @@ export declare class MkSymlinkCommand implements Command<MkSymlinkCommandOptions
|
|
|
19
19
|
constructor(optionValidator: MkSymlinkOptionValidator, logger: Logger, symlinkManager: SymlinkOperations, options: MkSymlinkCommandOptions, configService?: ConfigService);
|
|
20
20
|
execute(): Promise<void>;
|
|
21
21
|
private resolveOptions;
|
|
22
|
+
private resolveTarget;
|
|
22
23
|
private generateDefaultTarget;
|
|
23
24
|
}
|
|
@@ -51,11 +51,19 @@ class MkSymlinkCommand {
|
|
|
51
51
|
resolveOptions() {
|
|
52
52
|
const currentDir = process.cwd();
|
|
53
53
|
const source = this.options.source || currentDir;
|
|
54
|
-
const target = this.options
|
|
54
|
+
const target = this.resolveTarget(this.options) || this.generateDefaultTarget(currentDir);
|
|
55
55
|
const type = this.options.type || 'junction';
|
|
56
56
|
const force = this.options.force || false;
|
|
57
57
|
return { source, target, type, force };
|
|
58
58
|
}
|
|
59
|
+
resolveTarget(options) {
|
|
60
|
+
if (options.target !== '.' && options.target !== './') {
|
|
61
|
+
return options.target;
|
|
62
|
+
}
|
|
63
|
+
const currentDir = process.cwd();
|
|
64
|
+
const sourceBasename = (0, path_1.basename)(options.source || currentDir);
|
|
65
|
+
return (0, path_1.resolve)(currentDir, sourceBasename);
|
|
66
|
+
}
|
|
59
67
|
generateDefaultTarget(currentDir) {
|
|
60
68
|
const currentBasename = (0, path_1.basename)(currentDir);
|
|
61
69
|
const parentDir = (0, path_1.dirname)(currentDir);
|
package/src/commands/index.js
CHANGED
|
@@ -11,7 +11,7 @@ program
|
|
|
11
11
|
.description('Create symbolic links across platforms (macOS, Windows, Linux)')
|
|
12
12
|
.version(version);
|
|
13
13
|
program
|
|
14
|
-
.command('create')
|
|
14
|
+
.command('create', { isDefault: true })
|
|
15
15
|
.description('Create a symbolic link')
|
|
16
16
|
.option('-s, --source <path>', 'Source path (defaults to current directory)')
|
|
17
17
|
.option('-t, --target <path>', 'Target symlink path (auto-generated if not provided)')
|
|
@@ -28,22 +28,6 @@ program
|
|
|
28
28
|
process.exit(1);
|
|
29
29
|
}
|
|
30
30
|
});
|
|
31
|
-
program
|
|
32
|
-
.command('quick', { isDefault: true })
|
|
33
|
-
.description('Quick symlink creation from current directory (default command)')
|
|
34
|
-
.option('--type <type>', 'Symlink type for Windows: file, dir, junction (default: junction)', 'junction')
|
|
35
|
-
.option('-f, --force', 'Force overwrite existing symlink', true)
|
|
36
|
-
.action(async (options) => {
|
|
37
|
-
try {
|
|
38
|
-
const command = mksymlink_command_factory_1.MkSymlinkCommandFactory.create(options);
|
|
39
|
-
await command.execute();
|
|
40
|
-
process.exit(0);
|
|
41
|
-
}
|
|
42
|
-
catch (error) {
|
|
43
|
-
console.error('Command failed:', error instanceof Error ? error.message : String(error));
|
|
44
|
-
process.exit(1);
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
31
|
const configCmd = program.command('config').description('Manage mksymlink configuration');
|
|
48
32
|
configCmd
|
|
49
33
|
.command('get <key>')
|