@revideo/cli 0.3.3-testing.954 → 0.3.4-alpha.956
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/dist/index.js +1 -1
- package/package.json +4 -4
- package/dist/server.js +0 -89
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ const program = new commander_1.Command();
|
|
|
9
9
|
program
|
|
10
10
|
.name('revideo')
|
|
11
11
|
.description('CLI to interact with the revideo service')
|
|
12
|
-
.version('0.
|
|
12
|
+
.version('0.3.3');
|
|
13
13
|
program
|
|
14
14
|
.command('serve')
|
|
15
15
|
.description('UNSTABLE (still WIP): Start the revideo server in development mode. Watches for changes ' +
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@revideo/cli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4-alpha.956+cdb1fa32",
|
|
4
4
|
"description": "A CLI for revideo",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"author": "revideo",
|
|
@@ -25,13 +25,13 @@
|
|
|
25
25
|
"typescript": "^5.4.3"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@revideo/renderer": "^0.3.
|
|
29
|
-
"@revideo/telemetry": "^0.3.
|
|
28
|
+
"@revideo/renderer": "^0.3.4-alpha.956+cdb1fa32",
|
|
29
|
+
"@revideo/telemetry": "^0.3.4-alpha.956+cdb1fa32",
|
|
30
30
|
"chokidar": "^3.5.3",
|
|
31
31
|
"commander": "^12.0.0",
|
|
32
32
|
"cors": "^2.8.5",
|
|
33
33
|
"express": "^4.19.2",
|
|
34
34
|
"uuid": "^9.0.1"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "cdb1fa3298ddcbc45bf491e1aae41c78e43c1241"
|
|
37
37
|
}
|
package/dist/server.js
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const renderer_1 = require("@revideo/renderer");
|
|
7
|
-
const axios_1 = __importDefault(require("axios"));
|
|
8
|
-
const express_1 = __importDefault(require("express"));
|
|
9
|
-
const fs_1 = require("fs");
|
|
10
|
-
const path_1 = __importDefault(require("path"));
|
|
11
|
-
const uuid_1 = require("uuid");
|
|
12
|
-
const App = (0, express_1.default)();
|
|
13
|
-
const Port = process.env.REVIDEO_PORT || 3000;
|
|
14
|
-
App.use(express_1.default.json());
|
|
15
|
-
App.post('/render', async (req, res) => {
|
|
16
|
-
const { variables, callbackUrl } = req.body;
|
|
17
|
-
if (!callbackUrl) {
|
|
18
|
-
return res.status(400).send('Callback URL is required.');
|
|
19
|
-
}
|
|
20
|
-
const jobId = (0, uuid_1.v4)();
|
|
21
|
-
res.json({ jobId });
|
|
22
|
-
try {
|
|
23
|
-
const tempProjectName = (0, uuid_1.v4)();
|
|
24
|
-
await (0, renderer_1.renderVideo)(process.env.PROJECT_FILE || '', variables, {
|
|
25
|
-
name: tempProjectName,
|
|
26
|
-
});
|
|
27
|
-
const resultFilePath = path_1.default.join(process.cwd(), `output/${tempProjectName}.mp4`);
|
|
28
|
-
const downloadLink = `${req.protocol}://${req.get('host')}/download/${tempProjectName}.mp4`;
|
|
29
|
-
const response = await axios_1.default.post(callbackUrl, {
|
|
30
|
-
jobId,
|
|
31
|
-
status: 'success',
|
|
32
|
-
downloadLink,
|
|
33
|
-
}, {
|
|
34
|
-
headers: {
|
|
35
|
-
// eslint-disable-next-line
|
|
36
|
-
'Content-Type': 'application/json',
|
|
37
|
-
},
|
|
38
|
-
});
|
|
39
|
-
if (response.status !== 200) {
|
|
40
|
-
throw new Error('Callback URL responded with an error');
|
|
41
|
-
}
|
|
42
|
-
scheduleCleanup(resultFilePath);
|
|
43
|
-
}
|
|
44
|
-
catch (error) {
|
|
45
|
-
console.error(error);
|
|
46
|
-
await axios_1.default.post(callbackUrl, {
|
|
47
|
-
jobId,
|
|
48
|
-
status: 'error',
|
|
49
|
-
error: error.message,
|
|
50
|
-
}, {
|
|
51
|
-
headers: {
|
|
52
|
-
// eslint-disable-next-line
|
|
53
|
-
'Content-Type': 'application/json',
|
|
54
|
-
},
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
App.get('/download/:projectName', async (req, res) => {
|
|
59
|
-
const { projectName } = req.params;
|
|
60
|
-
const resultFilePath = path_1.default.join(process.cwd(), `output/${projectName}`);
|
|
61
|
-
try {
|
|
62
|
-
await fs_1.promises.access(resultFilePath);
|
|
63
|
-
res.download(resultFilePath, `${projectName}`, async (err) => {
|
|
64
|
-
if (err) {
|
|
65
|
-
console.error(err);
|
|
66
|
-
res.status(500).send('Error downloading the file.');
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
catch (error) {
|
|
71
|
-
console.error(`File not found ${resultFilePath}:`, error);
|
|
72
|
-
res.status(404).send('File not found.');
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
App.listen(Port, () => {
|
|
76
|
-
console.log(`Server running on port ${Port}`);
|
|
77
|
-
});
|
|
78
|
-
function scheduleCleanup(filePath) {
|
|
79
|
-
// wait 10 minutes before removing file
|
|
80
|
-
setTimeout(async () => {
|
|
81
|
-
try {
|
|
82
|
-
await fs_1.promises.unlink(filePath);
|
|
83
|
-
console.log(`Successfully deleted file: ${filePath}`);
|
|
84
|
-
}
|
|
85
|
-
catch (error) {
|
|
86
|
-
console.error(`Error deleting file ${filePath}: ${error}`);
|
|
87
|
-
}
|
|
88
|
-
}, 10 * 60 * 1000);
|
|
89
|
-
}
|