@ourcodecli/symlink
v1.1.2
Published
A CLI tool to create symbolic links
Downloads
65
Readme
Our code CLI - Symlink
- A CLI tool to create symbolic links to files or directories
- Install with
npm i -D @ourcodecli/symlink
Usage
# Create symlink(s) in one or more target directories
our-symlink <sourcePath> <targetPath>,<targetPath>,...
# Rename the symlink in destinations
our-symlink <sourcePath> <targetPath>,<targetPath> --name <name>
our-symlink <sourcePath> <targetPath>,<targetPath> -n <name>
# Replace destination entry if it exists
our-symlink <sourcePath> <targetPath>,<targetPath> --force
our-symlink <sourcePath> <targetPath>,<targetPath> -f
# Load operations from config JSON
our-symlink --config <pathToConfig>
our-symlink -c <pathToConfig>
# Show help and version
our-symlink --help
our-symlink --versionConfig format (--config)
Config file must match OurSymlinkConfig:
export interface SymlinkConfig {
force?: boolean;
sourcePath: string;
targetName?: string;
targetDir: string[];
}
export interface OurSymlinkConfig {
$schema?: string;
symlinks: SymlinkConfig[];
}Example:
{
"symlinks": [
{
"force": true,
"sourcePath": "./packages/shared/src",
"targetName": "shared-lib",
"targetDir": ["./apps/web", "./apps/admin"]
},
{
"sourcePath": "./packages/theme/tokens.json",
"targetDir": ["./apps/web", "./apps/mobile"]
},
{
"force": false,
"sourcePath": "./packages/utils/src",
"targetName": "utils",
"targetDir": ["./apps/web", "./apps/mobile"]
}
]
}JSON Schema available at:
config.schema.json(portable JSON Schema file)src/config-schema.ts(SYMLINK_CONFIG_SCHEMA, used by config validation insrc/symlink.ts)
Notes
- Relative and absolute paths are supported. All paths are normalized from current working directory.
sourcePathcan be a file or directory.targetPathvalues are treated as destination directories. Missing directories are created.forceis optional in config and defaults tofalse.targetNameis optional in config and defaults to the source basename.- Execution continues across multiple targets and reports a final success/failure summary.
- When using
--config, do not pass--nameor--forcein command line (those values come from each config entry). - On Windows, directory links use
junctionfor compatibility.
