@revideo/cli 0.4.7-two.1024 → 0.4.8-alpha.1032
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/dist/server/download.js +22 -26
- package/dist/server/index.js +20 -22
- package/dist/server/player.js +80 -106
- package/dist/server/render.js +123 -138
- package/dist/utils.js +14 -13
- package/package.json +4 -4
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.4.
|
|
12
|
+
.version('0.4.7');
|
|
13
13
|
program
|
|
14
14
|
.command('serve')
|
|
15
15
|
.description('UNSTABLE (still WIP): Start the revideo server in development mode. Watches for changes ' +
|
package/dist/server/download.js
CHANGED
|
@@ -1,30 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
var __importDefault =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
};
|
|
7
|
-
Object.defineProperty(exports, '__esModule', {value: true});
|
|
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 });
|
|
8
6
|
exports.download = void 0;
|
|
9
|
-
const fs_1 = require(
|
|
10
|
-
const path_1 = __importDefault(require(
|
|
7
|
+
const fs_1 = require("fs");
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
11
9
|
async function download(req, res) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
res.status(404).send('File not found.');
|
|
28
|
-
}
|
|
10
|
+
const { projectName } = req.params;
|
|
11
|
+
const resultFilePath = path_1.default.join(process.cwd(), `output/${projectName}`);
|
|
12
|
+
try {
|
|
13
|
+
await fs_1.promises.access(resultFilePath);
|
|
14
|
+
res.download(resultFilePath, `${projectName}`, async (err) => {
|
|
15
|
+
if (err) {
|
|
16
|
+
console.error(err);
|
|
17
|
+
res.status(500).send('Error downloading the file.');
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
console.error(`File not found ${resultFilePath}:`, error);
|
|
23
|
+
res.status(404).send('File not found.');
|
|
24
|
+
}
|
|
29
25
|
}
|
|
30
26
|
exports.download = download;
|
package/dist/server/index.js
CHANGED
|
@@ -1,26 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
var __importDefault =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
};
|
|
7
|
-
Object.defineProperty(exports, '__esModule', {value: true});
|
|
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 });
|
|
8
6
|
exports.createServer = void 0;
|
|
9
|
-
const cors_1 = __importDefault(require(
|
|
10
|
-
const express_1 = __importDefault(require(
|
|
11
|
-
const download_1 = require(
|
|
12
|
-
const player_1 = require(
|
|
13
|
-
const render_1 = require(
|
|
7
|
+
const cors_1 = __importDefault(require("cors"));
|
|
8
|
+
const express_1 = __importDefault(require("express"));
|
|
9
|
+
const download_1 = require("./download");
|
|
10
|
+
const player_1 = require("./player");
|
|
11
|
+
const render_1 = require("./render");
|
|
14
12
|
function createServer(hotReloadDir) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
13
|
+
const app = (0, express_1.default)();
|
|
14
|
+
app.use(express_1.default.json({ limit: '50mb' }));
|
|
15
|
+
app.use((0, cors_1.default)());
|
|
16
|
+
app.post('/render', render_1.render);
|
|
17
|
+
app.get('/download/:projectName', download_1.download);
|
|
18
|
+
app.get('/player/*', player_1.player);
|
|
19
|
+
if (hotReloadDir) {
|
|
20
|
+
(0, player_1.createHotReloader)(hotReloadDir);
|
|
21
|
+
}
|
|
22
|
+
return app;
|
|
25
23
|
}
|
|
26
24
|
exports.createServer = createServer;
|
package/dist/server/player.js
CHANGED
|
@@ -1,54 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
var __importDefault =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
};
|
|
7
|
-
Object.defineProperty(exports, '__esModule', {value: true});
|
|
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 });
|
|
8
6
|
exports.player = exports.createHotReloader = exports.buildProject = void 0;
|
|
9
|
-
const vite_plugin_1 = __importDefault(require(
|
|
10
|
-
const chokidar_1 = require(
|
|
11
|
-
const fs_1 = require(
|
|
12
|
-
const vite_1 = require(
|
|
7
|
+
const vite_plugin_1 = __importDefault(require("@revideo/vite-plugin"));
|
|
8
|
+
const chokidar_1 = require("chokidar");
|
|
9
|
+
const fs_1 = require("fs");
|
|
10
|
+
const vite_1 = require("vite");
|
|
13
11
|
const YELLOW_DOT = '\u001b[33m•\u001b[0m';
|
|
14
12
|
const GREEN_CHECK = '\u001b[32m✔\u001b[0m';
|
|
15
13
|
const RED_CROSS = '\u001b[31m✘\u001b[0m';
|
|
16
|
-
const fileNotFoundMessage = filePath =>
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
padding,
|
|
21
|
-
' ',
|
|
22
|
-
) + '\n';
|
|
23
|
-
const fileChangedMessage = filePath =>
|
|
24
|
-
`${YELLOW_DOT} File ${filePath} has changed. Rebuilding...`;
|
|
25
|
-
const successMessage = (time, padding) =>
|
|
26
|
-
`\r${GREEN_CHECK} Project built successfully. ${time}ms`.padEnd(
|
|
27
|
-
padding,
|
|
28
|
-
' ',
|
|
29
|
-
) + '\n';
|
|
14
|
+
const fileNotFoundMessage = (filePath) => `${YELLOW_DOT} File ${filePath} not found. Building project...`;
|
|
15
|
+
const fileNotFoundAfterBuildingMessage = (filePath, padding) => `\r${RED_CROSS} File ${filePath} still not found after building project...`.padEnd(padding, ' ') + '\n';
|
|
16
|
+
const fileChangedMessage = (filePath) => `${YELLOW_DOT} File ${filePath} has changed. Rebuilding...`;
|
|
17
|
+
const successMessage = (time, padding) => `\r${GREEN_CHECK} Project built successfully. ${time}ms`.padEnd(padding, ' ') + '\n';
|
|
30
18
|
async function buildProject() {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
19
|
+
try {
|
|
20
|
+
await (0, vite_1.build)({
|
|
21
|
+
configFile: false,
|
|
22
|
+
plugins: [(0, vite_plugin_1.default)({ project: process.env.PROJECT_FILE })],
|
|
23
|
+
build: {
|
|
24
|
+
outDir: 'dist',
|
|
25
|
+
rollupOptions: {
|
|
26
|
+
output: {
|
|
27
|
+
entryFileNames: '[name].js',
|
|
28
|
+
chunkFileNames: '[name].js',
|
|
29
|
+
assetFileNames: '[name].[ext]',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
console.error('Error building project:', error);
|
|
37
|
+
throw error;
|
|
38
|
+
}
|
|
52
39
|
}
|
|
53
40
|
exports.buildProject = buildProject;
|
|
54
41
|
/**
|
|
@@ -56,69 +43,56 @@ exports.buildProject = buildProject;
|
|
|
56
43
|
* @param dir - Directory to watch for changes.
|
|
57
44
|
*/
|
|
58
45
|
async function createHotReloader(dir) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
});
|
|
46
|
+
const watcher = (0, chokidar_1.watch)(dir, {
|
|
47
|
+
ignored: ['**/*.meta'],
|
|
48
|
+
});
|
|
49
|
+
watcher.on('change', async (path) => {
|
|
50
|
+
const rebuildingMessage = fileChangedMessage(path);
|
|
51
|
+
process.stdout.write(rebuildingMessage);
|
|
52
|
+
const start = Date.now();
|
|
53
|
+
try {
|
|
54
|
+
await buildProject();
|
|
55
|
+
process.stdout.write(successMessage(Date.now() - start, rebuildingMessage.length + 1));
|
|
56
|
+
}
|
|
57
|
+
catch (e) {
|
|
58
|
+
// TODO: Add more detailed error message
|
|
59
|
+
console.error('Error building project. Try to run `npm run build` manually and check for errors.');
|
|
60
|
+
}
|
|
61
|
+
});
|
|
78
62
|
}
|
|
79
63
|
exports.createHotReloader = createHotReloader;
|
|
80
64
|
async function player(req, res) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
65
|
+
let path = `./dist/${req.params[0]}`;
|
|
66
|
+
if (req.params[0] === 'project.js') {
|
|
67
|
+
const playerFileName = (process.env.PROJECT_FILE ?? '')
|
|
68
|
+
.split('/')
|
|
69
|
+
.pop()
|
|
70
|
+
?.replace('.ts', '.js');
|
|
71
|
+
path = `./dist/${playerFileName}`;
|
|
72
|
+
}
|
|
73
|
+
let buildTime = undefined;
|
|
74
|
+
let error = false;
|
|
75
|
+
// Check if the file exists and build the project if it doesn't.
|
|
76
|
+
await fs_1.promises.access(path).catch(async () => {
|
|
77
|
+
buildTime = Date.now();
|
|
78
|
+
process.stdout.write(fileNotFoundMessage(path));
|
|
79
|
+
await buildProject().catch(() => {
|
|
80
|
+
res.status(500).send('Error building project');
|
|
81
|
+
});
|
|
97
82
|
});
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
// If we built the project, update the log message.
|
|
114
|
-
if (buildTime) {
|
|
115
|
-
process.stdout.write(
|
|
116
|
-
successMessage(
|
|
117
|
-
Date.now() - buildTime,
|
|
118
|
-
fileNotFoundMessage(path).length + 1,
|
|
119
|
-
),
|
|
120
|
-
);
|
|
121
|
-
}
|
|
122
|
-
return res.sendFile(path, {root: './'});
|
|
83
|
+
// If the file still doesn't exist, send an error response.
|
|
84
|
+
await fs_1.promises.access(path).catch(() => {
|
|
85
|
+
process.stdout.write(fileNotFoundAfterBuildingMessage(path, fileNotFoundMessage(path).length + 1));
|
|
86
|
+
res.status(404).send(`File ${path} not found`);
|
|
87
|
+
error = true;
|
|
88
|
+
});
|
|
89
|
+
if (error) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
// If we built the project, update the log message.
|
|
93
|
+
if (buildTime) {
|
|
94
|
+
process.stdout.write(successMessage(Date.now() - buildTime, fileNotFoundMessage(path).length + 1));
|
|
95
|
+
}
|
|
96
|
+
return res.sendFile(path, { root: './' });
|
|
123
97
|
}
|
|
124
98
|
exports.player = player;
|
package/dist/server/render.js
CHANGED
|
@@ -1,149 +1,134 @@
|
|
|
1
|
-
|
|
2
|
-
var __importDefault =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
};
|
|
7
|
-
Object.defineProperty(exports, '__esModule', {value: true});
|
|
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 });
|
|
8
6
|
exports.render = void 0;
|
|
9
|
-
const renderer_1 = require(
|
|
10
|
-
const axios_1 = __importDefault(require(
|
|
11
|
-
const path_1 = __importDefault(require(
|
|
12
|
-
const uuid_1 = require(
|
|
13
|
-
const utils_1 = require(
|
|
7
|
+
const renderer_1 = require("@revideo/renderer");
|
|
8
|
+
const axios_1 = __importDefault(require("axios"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const uuid_1 = require("uuid");
|
|
11
|
+
const utils_1 = require("../utils");
|
|
14
12
|
async function render(req, res) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
const { callbackUrl } = req.body;
|
|
14
|
+
if (callbackUrl) {
|
|
15
|
+
await renderWithCallback(req, res);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
await renderWithoutCallback(req, res);
|
|
19
|
+
}
|
|
21
20
|
}
|
|
22
21
|
exports.render = render;
|
|
23
22
|
async function renderWithCallback(req, res) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
23
|
+
// TODO: validate request body
|
|
24
|
+
const { variables, callbackUrl, settings } = req.body;
|
|
25
|
+
const tempProjectName = (0, uuid_1.v4)();
|
|
26
|
+
const outputFileName = `${tempProjectName}.mp4`;
|
|
27
|
+
res.json({ tempProjectName });
|
|
28
|
+
try {
|
|
29
|
+
await (0, renderer_1.renderVideo)({
|
|
30
|
+
projectFile: process.env.PROJECT_FILE || '',
|
|
31
|
+
variables,
|
|
32
|
+
settings: {
|
|
33
|
+
...settings,
|
|
34
|
+
outFile: outputFileName,
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
const resultFilePath = path_1.default.join(process.cwd(), `output/${outputFileName}`);
|
|
38
|
+
const downloadLink = `${req.protocol}://${req.get('host')}/download/${outputFileName}`;
|
|
39
|
+
const response = await axios_1.default.post(callbackUrl, {
|
|
40
|
+
tempProjectName,
|
|
41
|
+
status: 'success',
|
|
42
|
+
downloadLink,
|
|
43
|
+
}, {
|
|
44
|
+
headers: {
|
|
45
|
+
// eslint-disable-next-line
|
|
46
|
+
'Content-Type': 'application/json',
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
if (response.status !== 200) {
|
|
50
|
+
throw new Error('Callback URL responded with an error');
|
|
51
|
+
}
|
|
52
|
+
(0, utils_1.scheduleCleanup)(resultFilePath);
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
console.error(error);
|
|
56
|
+
await axios_1.default.post(callbackUrl, {
|
|
57
|
+
tempProjectName,
|
|
58
|
+
status: 'error',
|
|
59
|
+
error: error.message,
|
|
60
|
+
}, {
|
|
61
|
+
headers: {
|
|
62
|
+
// eslint-disable-next-line
|
|
63
|
+
'Content-Type': 'application/json',
|
|
64
|
+
},
|
|
65
|
+
});
|
|
59
66
|
}
|
|
60
|
-
(0, utils_1.scheduleCleanup)(resultFilePath);
|
|
61
|
-
} catch (error) {
|
|
62
|
-
console.error(error);
|
|
63
|
-
await axios_1.default.post(
|
|
64
|
-
callbackUrl,
|
|
65
|
-
{
|
|
66
|
-
tempProjectName,
|
|
67
|
-
status: 'error',
|
|
68
|
-
error: error.message,
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
headers: {
|
|
72
|
-
// eslint-disable-next-line
|
|
73
|
-
'Content-Type': 'application/json',
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
67
|
}
|
|
79
68
|
async function renderWithoutCallback(req, res) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
res.write(`event: error\n`);
|
|
120
|
-
res.write(
|
|
121
|
-
`data: ${JSON.stringify({status: 'error', message: error.message})}\n\n`,
|
|
122
|
-
);
|
|
123
|
-
res.end();
|
|
69
|
+
// TODO: validate request body
|
|
70
|
+
const { variables, streamProgress, settings } = req.body;
|
|
71
|
+
const tempProjectName = `${(0, uuid_1.v4)()}.mp4`;
|
|
72
|
+
const resultFilePath = path_1.default.join(process.cwd(), `output/${tempProjectName}`);
|
|
73
|
+
if (streamProgress) {
|
|
74
|
+
res.writeHead(200, {
|
|
75
|
+
// eslint-disable-next-line
|
|
76
|
+
'Content-Type': 'text/event-stream',
|
|
77
|
+
// eslint-disable-next-line
|
|
78
|
+
'Cache-Control': 'no-cache',
|
|
79
|
+
// eslint-disable-next-line
|
|
80
|
+
Connection: 'keep-alive',
|
|
81
|
+
});
|
|
82
|
+
const sendProgress = (worker, progress) => {
|
|
83
|
+
res.write(`event: progress\n`);
|
|
84
|
+
res.write(`data: ${JSON.stringify({ worker, progress })}\n\n`);
|
|
85
|
+
};
|
|
86
|
+
try {
|
|
87
|
+
await (0, renderer_1.renderVideo)({
|
|
88
|
+
projectFile: process.env.PROJECT_FILE || '',
|
|
89
|
+
variables,
|
|
90
|
+
settings: {
|
|
91
|
+
...settings,
|
|
92
|
+
outFile: tempProjectName,
|
|
93
|
+
progressCallback: sendProgress,
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
const downloadLink = `${req.protocol}://${req.get('host')}/download/${tempProjectName}`;
|
|
97
|
+
res.write(`event: completed\n`);
|
|
98
|
+
res.write(`data: ${JSON.stringify({ status: 'success', downloadLink })}\n\n`);
|
|
99
|
+
res.end();
|
|
100
|
+
(0, utils_1.scheduleCleanup)(resultFilePath);
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
console.error(error);
|
|
104
|
+
res.write(`event: error\n`);
|
|
105
|
+
res.write(`data: ${JSON.stringify({ status: 'error', message: error.message })}\n\n`);
|
|
106
|
+
res.end();
|
|
107
|
+
}
|
|
124
108
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
109
|
+
else {
|
|
110
|
+
try {
|
|
111
|
+
await (0, renderer_1.renderVideo)({
|
|
112
|
+
projectFile: process.env.PROJECT_FILE || '',
|
|
113
|
+
variables,
|
|
114
|
+
settings: {
|
|
115
|
+
...settings,
|
|
116
|
+
outFile: tempProjectName,
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
const downloadLink = `${req.protocol}://${req.get('host')}/download/${tempProjectName}`;
|
|
120
|
+
res.json({
|
|
121
|
+
status: 'success',
|
|
122
|
+
downloadLink: downloadLink,
|
|
123
|
+
});
|
|
124
|
+
(0, utils_1.scheduleCleanup)(resultFilePath);
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
console.error(error);
|
|
128
|
+
res.status(500).json({
|
|
129
|
+
status: 'error',
|
|
130
|
+
message: error.message,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
147
133
|
}
|
|
148
|
-
}
|
|
149
134
|
}
|
package/dist/utils.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.scheduleCleanup = void 0;
|
|
4
|
-
const fs_1 = require(
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
5
|
function scheduleCleanup(filePath) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
6
|
+
const clean = async () => {
|
|
7
|
+
try {
|
|
8
|
+
await fs_1.promises.unlink(filePath);
|
|
9
|
+
console.log(`Successfully deleted file: ${filePath}`);
|
|
10
|
+
}
|
|
11
|
+
catch (error) {
|
|
12
|
+
console.error(`Error deleting file ${filePath}: ${error}`);
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
// Wait 10 minutes before removing file.
|
|
16
|
+
setTimeout(clean, 10 * 60 * 1000);
|
|
16
17
|
}
|
|
17
18
|
exports.scheduleCleanup = scheduleCleanup;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@revideo/cli",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.8-alpha.1032+c87f8411",
|
|
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.4.
|
|
29
|
-
"@revideo/telemetry": "^0.4.
|
|
28
|
+
"@revideo/renderer": "^0.4.8-alpha.1032+c87f8411",
|
|
29
|
+
"@revideo/telemetry": "^0.4.8-alpha.1032+c87f8411",
|
|
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": "c87f841121fcdf09215d782516482ee0090ca11a"
|
|
37
37
|
}
|