move rrvideo to monorepo (#1181)
* first commit * rrvideo v0.1.0 First version of rrvideo. 1. Use as a Node.JS lib. 2. Use as a CLI. Features are implemented via puppeteer, ffmpeg and rrweb-player. * add readme * update publish script * add node env in cli file and change package.json bin to same like README (#4) Co-authored-by: Xu Yinjie <xuyinjie@xiaobangtouzi.com> * release 0.2.0 * fix #6 avoid assign undefined to config * Fix: Solve the inconsistency between rrvideo and the real recorded page rendering when rendering the page with a headless browser (https://github.com/rrweb-io/rrvideo/pull/26) Author: xujiujiu <906784584@qq.com> --------- Co-authored-by: xujiujiu <906784584@qq.com> * refactor rrvideo 1. refactor code 2. change monorepo config 3. remove separate TS dependencies * add changeset * fix: eslint errors --------- Co-authored-by: Yanzhen Yu <yanzhen@smartx.com> Co-authored-by: xyj <593500664@qq.com> Co-authored-by: Xu Yinjie <xuyinjie@xiaobangtouzi.com> Co-authored-by: xujiujiu <906784584@qq.com>
This commit is contained in:
39
packages/rrvideo/src/cli.ts
Normal file
39
packages/rrvideo/src/cli.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env node
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import minimist from 'minimist';
|
||||
import type { RRwebPlayerOptions } from 'rrweb-player';
|
||||
import { transformToVideo } from './index';
|
||||
|
||||
const argv = minimist(process.argv.slice(2));
|
||||
|
||||
if (!argv.input) {
|
||||
throw new Error('please pass --input to your rrweb events file');
|
||||
}
|
||||
|
||||
let config = {};
|
||||
|
||||
if (argv.config) {
|
||||
const configPathStr = argv.config as string;
|
||||
const configPath = path.isAbsolute(configPathStr)
|
||||
? configPathStr
|
||||
: path.resolve(process.cwd(), configPathStr);
|
||||
config = JSON.parse(fs.readFileSync(configPath, 'utf-8')) as Omit<
|
||||
RRwebPlayerOptions['props'],
|
||||
'events'
|
||||
>;
|
||||
}
|
||||
|
||||
transformToVideo({
|
||||
input: argv.input as string,
|
||||
output: argv.output as string,
|
||||
rrwebPlayer: config,
|
||||
})
|
||||
.then((file) => {
|
||||
console.log(`Successfully transformed into "${file}".`);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log('Failed to transform this session.');
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
});
|
||||
Reference in New Issue
Block a user