Skip to content

Commit

Permalink
added new action link action
Browse files Browse the repository at this point in the history
  • Loading branch information
inlife committed Dec 1, 2024
1 parent e75e008 commit 06a5c68
Show file tree
Hide file tree
Showing 6 changed files with 747 additions and 0 deletions.
661 changes: 661 additions & 0 deletions packages/nexrender-action-link/LICENSE

Large diffs are not rendered by default.

35 changes: 35 additions & 0 deletions packages/nexrender-action-link/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const fs = require("fs");
const path = require("path");

module.exports = async (job, settings, { input, output, type = "dir" }, actionType) => {

Check failure on line 4 in packages/nexrender-action-link/index.js

View workflow job for this annotation

GitHub Actions / build (18.x)

'actionType' is defined but never used
if (!input) {
throw new Error("No input path provided");
}

if (!output) {
throw new Error("No output path provided");
}

/* fill absolute/relative paths */
if (!path.isAbsolute(input)) input = path.join(job.workpath, input);
if (!path.isAbsolute(output)) output = path.join(job.workpath, output);

/* create parent directories if needed */
fs.mkdirSync(path.dirname(output), { recursive: true });

/* remove existing link if it exists */
if (fs.existsSync(output)) {
fs.unlinkSync(output);
}

settings.logger.log(`[${job.uid}] creating symbolic link from ${input} to ${output}...`);

/* create symbolic link */
try {
fs.symlinkSync(input, output, type);
} catch (err) {
throw new Error(`Failed to create symbolic link: ${err.message}`);
}

return job;
};
10 changes: 10 additions & 0 deletions packages/nexrender-action-link/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "@nexrender/action-link",
"homepage": "https://www.nexrender.com",
"author": "inlife",
"version": "1.0.0",
"main": "index.js",
"publishConfig": {
"access": "public"
}
}
39 changes: 39 additions & 0 deletions packages/nexrender-action-link/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Action: Link

Create symbolic links between files or directories.

## Information

* `input` required argument, source path for the symbolic link, can be either relative or absolute path
* `output` required argument, destination path where the symbolic link will be created, can be either relative or absolute path
* `type` optional argument, type of symbolic link to create:
* `dir` - Create a directory symbolic link (default)
* `file` - Create a file symbolic link
* `junction` - Create a directory junction (Windows only)

The action will:
1. Create any necessary parent directories for the output path
2. Remove any existing symbolic link at the output path
3. Create a new symbolic link from input to output

Note: Creating symbolic links may require elevated permissions on some systems.

## Usage

```json
{
"actions": {
"prerender": [
{
"module": "@nexrender/action-link",
"input": "source/large-file.mp4",
"output": "assets/linked-file.mp4"
}
]
}
}
```

## License

Please refer to the [LICENSE](LICENSE) file for more information. Unlike the main nexrender project, this plugin is licensed under the AGPL-3.0 license.
1 change: 1 addition & 0 deletions packages/nexrender-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"@nexrender/action-encode": "^1.1.4",
"@nexrender/action-fonts": "^1.51.8",
"@nexrender/action-image": "^1.49.4",
"@nexrender/action-link": "^1.0.0",
"@nexrender/action-mogrt": "^1.0.2",
"@nexrender/action-upload": "^1.0.0",
"@nexrender/action-webhook": "^1.51.3",
Expand Down
1 change: 1 addition & 0 deletions packages/nexrender-core/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ if (process.env.NEXRENDER_REQUIRE_PLUGINS) {
require('@nexrender/action-decompress');
require('@nexrender/action-image');
require('@nexrender/action-fonts');
require('@nexrender/action-link');
require('@nexrender/action-webhook');
require('@nexrender/action-mogrt');

Expand Down

0 comments on commit 06a5c68

Please sign in to comment.