@editframe/cli 0.26.2-beta.0 → 0.26.4-beta.0
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/VERSION.js +1 -1
- package/dist/VERSION.js.map +1 -1
- package/package.json +5 -5
- package/src/commands/auth.ts +0 -46
- package/src/commands/check.ts +0 -129
- package/src/commands/mux.ts +0 -10
- package/src/commands/preview.ts +0 -9
- package/src/commands/process-file.ts +0 -55
- package/src/commands/process.ts +0 -41
- package/src/commands/render.ts +0 -190
- package/src/commands/sync.ts +0 -13
- package/src/commands/test-asset.file +0 -0
- package/src/commands/webhook.ts +0 -76
- package/src/operations/processRenderInfo.ts +0 -40
- package/src/operations/syncAssetsDirectory/SubAssetSync.ts +0 -45
- package/src/operations/syncAssetsDirectory/SyncCaption.test.ts +0 -180
- package/src/operations/syncAssetsDirectory/SyncCaption.ts +0 -87
- package/src/operations/syncAssetsDirectory/SyncFragmentIndex.test.ts +0 -185
- package/src/operations/syncAssetsDirectory/SyncFragmentIndex.ts +0 -101
- package/src/operations/syncAssetsDirectory/SyncImage.test.ts +0 -162
- package/src/operations/syncAssetsDirectory/SyncImage.ts +0 -123
- package/src/operations/syncAssetsDirectory/SyncStatus.ts +0 -50
- package/src/operations/syncAssetsDirectory/SyncTrack.test.ts +0 -265
- package/src/operations/syncAssetsDirectory/SyncTrack.ts +0 -175
- package/src/operations/syncAssetsDirectory/doAssetSync.test.ts +0 -134
- package/src/operations/syncAssetsDirectory/doAssetSync.ts +0 -62
- package/src/operations/syncAssetsDirectory.test.ts +0 -510
- package/src/operations/syncAssetsDirectory.ts +0 -91
- package/src/utils/attachWorkbench.ts +0 -16
- package/src/utils/createReadableStreamFromReadable.ts +0 -113
- package/src/utils/getFolderSize.ts +0 -20
- package/src/utils/index.ts +0 -20
- package/src/utils/launchBrowserAndWaitForSDK.ts +0 -64
- package/src/utils/startDevServer.ts +0 -61
- package/src/utils/startPreviewServer.ts +0 -38
- package/src/utils/validateVideoResolution.ts +0 -36
- package/src/utils/withSpinner.ts +0 -16
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { type Readable, Stream } from "node:stream";
|
|
2
|
-
|
|
3
|
-
export const createReadableStreamFromReadable = (
|
|
4
|
-
source: Readable & { readableHighWaterMark?: number },
|
|
5
|
-
) => {
|
|
6
|
-
const pump = new StreamPump(source);
|
|
7
|
-
const stream = new ReadableStream(pump, pump);
|
|
8
|
-
return stream;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
class StreamPump {
|
|
12
|
-
public highWaterMark: number;
|
|
13
|
-
public accumalatedSize: number;
|
|
14
|
-
private stream: Stream & {
|
|
15
|
-
readableHighWaterMark?: number;
|
|
16
|
-
readable?: boolean;
|
|
17
|
-
resume?: () => void;
|
|
18
|
-
pause?: () => void;
|
|
19
|
-
destroy?: (error?: Error) => void;
|
|
20
|
-
};
|
|
21
|
-
private controller?: ReadableStreamController<Uint8Array>;
|
|
22
|
-
|
|
23
|
-
constructor(
|
|
24
|
-
stream: Stream & {
|
|
25
|
-
readableHighWaterMark?: number;
|
|
26
|
-
readable?: boolean;
|
|
27
|
-
resume?: () => void;
|
|
28
|
-
pause?: () => void;
|
|
29
|
-
destroy?: (error?: Error) => void;
|
|
30
|
-
},
|
|
31
|
-
) {
|
|
32
|
-
this.highWaterMark =
|
|
33
|
-
stream.readableHighWaterMark ||
|
|
34
|
-
new Stream.Readable().readableHighWaterMark;
|
|
35
|
-
this.accumalatedSize = 0;
|
|
36
|
-
this.stream = stream;
|
|
37
|
-
this.enqueue = this.enqueue.bind(this);
|
|
38
|
-
this.error = this.error.bind(this);
|
|
39
|
-
this.close = this.close.bind(this);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
size(chunk: Uint8Array) {
|
|
43
|
-
return chunk?.byteLength || 0;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
start(controller: ReadableStreamController<Uint8Array>) {
|
|
47
|
-
this.controller = controller;
|
|
48
|
-
this.stream.on("data", this.enqueue);
|
|
49
|
-
this.stream.once("error", this.error);
|
|
50
|
-
this.stream.once("end", this.close);
|
|
51
|
-
this.stream.once("close", this.close);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
pull() {
|
|
55
|
-
this.resume();
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
cancel(reason?: Error) {
|
|
59
|
-
if (this.stream.destroy) {
|
|
60
|
-
this.stream.destroy(reason);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
this.stream.off("data", this.enqueue);
|
|
64
|
-
this.stream.off("error", this.error);
|
|
65
|
-
this.stream.off("end", this.close);
|
|
66
|
-
this.stream.off("close", this.close);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
enqueue(chunk: Uint8Array | string) {
|
|
70
|
-
if (this.controller) {
|
|
71
|
-
try {
|
|
72
|
-
const available = (this.controller.desiredSize || 0) - chunk.length;
|
|
73
|
-
this.controller.enqueue(chunk as Uint8Array);
|
|
74
|
-
if (available <= 0) {
|
|
75
|
-
this.pause();
|
|
76
|
-
}
|
|
77
|
-
} catch (_error: any) {
|
|
78
|
-
this.controller.error(
|
|
79
|
-
new Error(
|
|
80
|
-
"Could not create Buffer, chunk must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object",
|
|
81
|
-
),
|
|
82
|
-
);
|
|
83
|
-
this.cancel();
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
pause() {
|
|
89
|
-
if (this.stream.pause) {
|
|
90
|
-
this.stream.pause();
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
resume() {
|
|
95
|
-
if (this.stream.readable && this.stream.resume) {
|
|
96
|
-
this.stream.resume();
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
close() {
|
|
101
|
-
if (this.controller) {
|
|
102
|
-
this.controller.close();
|
|
103
|
-
delete this.controller;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
error(error: Error) {
|
|
108
|
-
if (this.controller) {
|
|
109
|
-
this.controller.error(error);
|
|
110
|
-
delete this.controller;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { promises as fs } from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
|
|
4
|
-
export async function getFolderSize(dir: string): Promise<number> {
|
|
5
|
-
const files = await fs.readdir(dir);
|
|
6
|
-
let size = 0;
|
|
7
|
-
|
|
8
|
-
for (const file of files) {
|
|
9
|
-
const filePath = path.join(dir, file);
|
|
10
|
-
const stats = await fs.stat(filePath);
|
|
11
|
-
|
|
12
|
-
if (stats.isDirectory()) {
|
|
13
|
-
size += await getFolderSize(filePath);
|
|
14
|
-
} else {
|
|
15
|
-
size += stats.size;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
return size;
|
|
20
|
-
}
|
package/src/utils/index.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { program } from "commander";
|
|
2
|
-
import "dotenv/config";
|
|
3
|
-
import { Client } from "@editframe/api";
|
|
4
|
-
|
|
5
|
-
let client: Client;
|
|
6
|
-
|
|
7
|
-
export const getClient = () => {
|
|
8
|
-
if (!client) {
|
|
9
|
-
const programOpts = program.opts();
|
|
10
|
-
const token = programOpts.token || process.env.EF_TOKEN;
|
|
11
|
-
const efHost = programOpts.efHost || process.env.EF_HOST;
|
|
12
|
-
if (!token) {
|
|
13
|
-
throw new Error(
|
|
14
|
-
"EF_TOKEN must be set or supplied as command line argument",
|
|
15
|
-
);
|
|
16
|
-
}
|
|
17
|
-
client = new Client(token, efHost);
|
|
18
|
-
}
|
|
19
|
-
return client;
|
|
20
|
-
};
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
|
-
import debug from "debug";
|
|
3
|
-
import { type Browser, chromium, type Page } from "playwright";
|
|
4
|
-
|
|
5
|
-
import { withSpinner } from "./withSpinner.js";
|
|
6
|
-
|
|
7
|
-
const browserLog = debug("ef:cli::browser");
|
|
8
|
-
|
|
9
|
-
interface LaunchOptions {
|
|
10
|
-
url: string;
|
|
11
|
-
headless?: boolean;
|
|
12
|
-
interactive?: boolean;
|
|
13
|
-
efInteractive?: boolean;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export async function launchBrowserAndWaitForSDK(
|
|
17
|
-
options: LaunchOptions,
|
|
18
|
-
fn: (page: Page) => Promise<void>,
|
|
19
|
-
) {
|
|
20
|
-
const browser = await withSpinner("Launching chrome", async () => {
|
|
21
|
-
return chromium.launch({
|
|
22
|
-
channel: "chrome",
|
|
23
|
-
headless: options.headless ?? true,
|
|
24
|
-
// headless: false,
|
|
25
|
-
devtools: options.interactive === true,
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
const page = await withSpinner("Loading Editframe SDK", async () => {
|
|
30
|
-
const pageOptions: Parameters<Browser["newPage"]>[0] = {};
|
|
31
|
-
if (options.interactive === true) {
|
|
32
|
-
// By default, playwright uses its own viewport, so resizing the browser window
|
|
33
|
-
// doesn't actually change the viewport. And the gui doesn't scale to fit.
|
|
34
|
-
// This is not desirable for interactive mode, so we disable the viewport feature.
|
|
35
|
-
pageOptions.viewport = null;
|
|
36
|
-
}
|
|
37
|
-
const page = await browser.newPage(pageOptions);
|
|
38
|
-
page.on("console", (msg) => {
|
|
39
|
-
browserLog(chalk.blue(`browser (${msg.type()}) |`), msg.text());
|
|
40
|
-
});
|
|
41
|
-
const url =
|
|
42
|
-
options.url + (options.efInteractive ? "" : "?EF_NONINTERACTIVE=1");
|
|
43
|
-
process.stderr.write("\nLoading url: ");
|
|
44
|
-
process.stderr.write(url);
|
|
45
|
-
process.stderr.write("\n");
|
|
46
|
-
await page.goto(url);
|
|
47
|
-
await page.waitForFunction(
|
|
48
|
-
() => {
|
|
49
|
-
return (
|
|
50
|
-
// @ts-expect-error
|
|
51
|
-
window.EF_REGISTERED
|
|
52
|
-
);
|
|
53
|
-
},
|
|
54
|
-
[],
|
|
55
|
-
{ timeout: 10_000 },
|
|
56
|
-
);
|
|
57
|
-
return page;
|
|
58
|
-
});
|
|
59
|
-
await fn(page);
|
|
60
|
-
if (options.interactive !== true) {
|
|
61
|
-
await browser.close();
|
|
62
|
-
process.exit(0);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import { vitePluginEditframe as editframe } from "@editframe/vite-plugin";
|
|
3
|
-
import tailwindcss from "tailwindcss";
|
|
4
|
-
import { createServer, type ViteDevServer } from "vite";
|
|
5
|
-
|
|
6
|
-
import { withSpinner } from "./withSpinner.js";
|
|
7
|
-
|
|
8
|
-
export class DevServer {
|
|
9
|
-
static async start(directory: string) {
|
|
10
|
-
return new DevServer(await startDevServer(directory));
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
constructor(private devServer: ViteDevServer) {}
|
|
14
|
-
|
|
15
|
-
get url() {
|
|
16
|
-
return `http://localhost:${this.devServer.config.server.port}`;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const startDevServer = async (directory: string) => {
|
|
21
|
-
return await withSpinner("Starting vite...", async () => {
|
|
22
|
-
const resolvedDirectory = path.resolve(process.cwd(), directory);
|
|
23
|
-
const cacheRoot = path.join(resolvedDirectory, "assets");
|
|
24
|
-
const devServer = await createServer({
|
|
25
|
-
root: resolvedDirectory,
|
|
26
|
-
css: {
|
|
27
|
-
postcss: {
|
|
28
|
-
plugins: [
|
|
29
|
-
tailwindcss({
|
|
30
|
-
content: [
|
|
31
|
-
path.join(resolvedDirectory, "*.{html,css,js,ts,jsx,tsx}"),
|
|
32
|
-
path.join(resolvedDirectory, "**/*.{html,css,js,ts,jsx,tsx}"),
|
|
33
|
-
],
|
|
34
|
-
}),
|
|
35
|
-
],
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
esbuild: {
|
|
39
|
-
target: "es2022",
|
|
40
|
-
include: /\.(m?[jt]s|[jt]sx)$/,
|
|
41
|
-
exclude: [],
|
|
42
|
-
},
|
|
43
|
-
plugins: [
|
|
44
|
-
editframe({
|
|
45
|
-
root: resolvedDirectory,
|
|
46
|
-
cacheRoot,
|
|
47
|
-
}),
|
|
48
|
-
],
|
|
49
|
-
build: {
|
|
50
|
-
target: "es2022",
|
|
51
|
-
rollupOptions: {
|
|
52
|
-
treeshake: {
|
|
53
|
-
moduleSideEffects: false,
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
});
|
|
58
|
-
await devServer.listen();
|
|
59
|
-
return devServer;
|
|
60
|
-
});
|
|
61
|
-
};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import { vitePluginEditframe as editframe } from "@editframe/vite-plugin";
|
|
3
|
-
import { createServer, type ViteDevServer } from "vite";
|
|
4
|
-
|
|
5
|
-
import { withSpinner } from "./withSpinner.js";
|
|
6
|
-
|
|
7
|
-
export class PreviewServer {
|
|
8
|
-
static async start(directory: string) {
|
|
9
|
-
return new PreviewServer(await startPreviewServer(directory));
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
constructor(private previewServer: ViteDevServer) {}
|
|
13
|
-
|
|
14
|
-
get url() {
|
|
15
|
-
return `http://localhost:${this.previewServer.config.server.port}`;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const startPreviewServer = async (directory: string) => {
|
|
20
|
-
return await withSpinner("Starting vite...", async () => {
|
|
21
|
-
const resolvedDirectory = path.resolve(process.cwd(), directory);
|
|
22
|
-
const cacheRoot = path.join(resolvedDirectory, "assets");
|
|
23
|
-
const devServer = await createServer({
|
|
24
|
-
server: {
|
|
25
|
-
watch: null,
|
|
26
|
-
},
|
|
27
|
-
root: resolvedDirectory,
|
|
28
|
-
plugins: [
|
|
29
|
-
editframe({
|
|
30
|
-
root: resolvedDirectory,
|
|
31
|
-
cacheRoot,
|
|
32
|
-
}),
|
|
33
|
-
],
|
|
34
|
-
});
|
|
35
|
-
await devServer.listen();
|
|
36
|
-
return devServer;
|
|
37
|
-
});
|
|
38
|
-
};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import debug from "debug";
|
|
2
|
-
import ora from "ora";
|
|
3
|
-
import { z } from "zod";
|
|
4
|
-
|
|
5
|
-
const log = debug("ef:cli:validateVideoResolution");
|
|
6
|
-
|
|
7
|
-
type VideoPayload = {
|
|
8
|
-
width: number;
|
|
9
|
-
height: number;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
const schema = z
|
|
13
|
-
.object({
|
|
14
|
-
width: z.number().int(),
|
|
15
|
-
height: z.number().int(),
|
|
16
|
-
})
|
|
17
|
-
.refine((data) => data.width % 2 === 0, {
|
|
18
|
-
message: "Width must be divisible by 2",
|
|
19
|
-
path: ["width"],
|
|
20
|
-
})
|
|
21
|
-
.refine((data) => data.height % 2 === 0, {
|
|
22
|
-
message: "Height must be divisible by 2",
|
|
23
|
-
});
|
|
24
|
-
export const validateVideoResolution = async (rawPayload: VideoPayload) => {
|
|
25
|
-
const spinner = ora("Validating video resolution").start();
|
|
26
|
-
const result = schema.safeParse(rawPayload);
|
|
27
|
-
if (result.success) {
|
|
28
|
-
spinner.succeed("Video resolution is valid");
|
|
29
|
-
return result.data;
|
|
30
|
-
}
|
|
31
|
-
spinner.fail("Invalid video resolution");
|
|
32
|
-
process.stderr.write(result.error?.errors.map((e) => e.message).join("\n"));
|
|
33
|
-
process.stderr.write("\n");
|
|
34
|
-
log("Error:", result.error?.errors.map((e) => e.message).join("\n"));
|
|
35
|
-
process.exit(1);
|
|
36
|
-
};
|
package/src/utils/withSpinner.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import ora from "ora";
|
|
2
|
-
|
|
3
|
-
export const withSpinner = async <T extends any | undefined>(
|
|
4
|
-
label: string,
|
|
5
|
-
fn: () => Promise<T>,
|
|
6
|
-
) => {
|
|
7
|
-
const spinner = ora(label).start();
|
|
8
|
-
try {
|
|
9
|
-
const result = await fn();
|
|
10
|
-
spinner.succeed();
|
|
11
|
-
return result;
|
|
12
|
-
} catch (error) {
|
|
13
|
-
spinner.fail();
|
|
14
|
-
throw error;
|
|
15
|
-
}
|
|
16
|
-
};
|