@editframe/cli 0.11.0-beta.1 → 0.11.0-beta.10
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.d.ts +1 -1
- package/dist/VERSION.js +1 -1
- package/dist/commands/auth.d.ts +2 -2
- package/dist/commands/auth.js +8 -8
- package/dist/operations/syncAssetsDirectory/SubAssetSync.js +3 -0
- package/dist/operations/syncAssetsDirectory/SyncCaption.js +2 -1
- package/dist/operations/syncAssetsDirectory/SyncFragmentIndex.js +3 -5
- package/dist/operations/syncAssetsDirectory/SyncStatus.d.ts +1 -1
- package/dist/operations/syncAssetsDirectory/SyncStatus.js +1 -0
- package/dist/operations/syncAssetsDirectory/SyncTrack.js +3 -5
- package/dist/utils/index.js +10 -4
- package/package.json +5 -5
- package/src/commands/auth.ts +9 -9
- package/src/operations/syncAssetsDirectory/SubAssetSync.ts +4 -0
- package/src/operations/syncAssetsDirectory/SyncCaption.ts +3 -2
- package/src/operations/syncAssetsDirectory/SyncFragmentIndex.ts +4 -6
- package/src/operations/syncAssetsDirectory/SyncStatus.ts +3 -2
- package/src/operations/syncAssetsDirectory/SyncTrack.ts +4 -6
- package/src/utils/index.ts +10 -4
package/dist/VERSION.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.11.0-beta.
|
|
1
|
+
export declare const VERSION = "0.11.0-beta.10";
|
package/dist/VERSION.js
CHANGED
package/dist/commands/auth.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export interface APIOrgResult {
|
|
2
|
-
|
|
2
|
+
apiKeyName: string;
|
|
3
3
|
id: string;
|
|
4
4
|
org_id: string;
|
|
5
5
|
created_at: unknown;
|
|
6
6
|
updated_at: unknown;
|
|
7
|
-
|
|
7
|
+
displayName: string;
|
|
8
8
|
}
|
|
9
9
|
export declare const getApiData: () => Promise<APIOrgResult>;
|
package/dist/commands/auth.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { program } from "commander";
|
|
2
|
-
import ora from "ora";
|
|
3
1
|
import chalk from "chalk";
|
|
2
|
+
import { program } from "commander";
|
|
4
3
|
import debug from "debug";
|
|
4
|
+
import ora from "ora";
|
|
5
5
|
import { getClient } from "../utils/index.js";
|
|
6
6
|
const log = debug("ef:cli:auth");
|
|
7
7
|
const getApiData = async () => {
|
|
8
|
-
const response = await getClient().authenticatedFetch("/api/
|
|
8
|
+
const response = await getClient().authenticatedFetch("/api/v1/organization");
|
|
9
9
|
return response.json();
|
|
10
10
|
};
|
|
11
11
|
const authCommand = program.command("auth").description("Fetch organization data using API token").action(async () => {
|
|
@@ -15,16 +15,16 @@ const authCommand = program.command("auth").description("Fetch organization data
|
|
|
15
15
|
try {
|
|
16
16
|
const apiData = await getApiData();
|
|
17
17
|
spinner.succeed("You are authenticated! 🎉");
|
|
18
|
-
process.stderr.write(chalk.green(`Name: ${apiData.name}
|
|
19
|
-
`));
|
|
20
18
|
process.stderr.write(
|
|
21
|
-
chalk.green(`
|
|
19
|
+
chalk.green(`You're using ${apiData.apiKeyName} API key 🚀
|
|
20
|
+
`)
|
|
21
|
+
);
|
|
22
|
+
process.stderr.write(
|
|
23
|
+
chalk.blue(`Welcome to ${apiData.displayName} organization 🎉
|
|
22
24
|
`)
|
|
23
25
|
);
|
|
24
26
|
} catch (error) {
|
|
25
27
|
spinner.fail("Authentication failed!");
|
|
26
|
-
process.stderr.write(error?.message);
|
|
27
|
-
process.stderr.write("\n");
|
|
28
28
|
log("Error:", error);
|
|
29
29
|
}
|
|
30
30
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import debug from "debug";
|
|
1
2
|
import { SyncCaption } from "./SyncCaption.js";
|
|
2
3
|
import { SyncFragmentIndex } from "./SyncFragmentIndex.js";
|
|
3
4
|
import { SyncImage } from "./SyncImage.js";
|
|
@@ -6,7 +7,9 @@ const trackMatch = /\.track-[\d]+.mp4$/i;
|
|
|
6
7
|
const fragmentIndexMatch = /\.tracks.json$/i;
|
|
7
8
|
const captionsMatch = /\.captions.json$/i;
|
|
8
9
|
const imageMatch = /\.(png|jpe?g|gif|webp)$/i;
|
|
10
|
+
const log = debug("ef:SubAssetSync");
|
|
9
11
|
const getAssetSync = (subAssetPath, md5) => {
|
|
12
|
+
log("getAssetSync", { subAssetPath, md5 });
|
|
10
13
|
if (imageMatch.test(subAssetPath)) {
|
|
11
14
|
return new SyncImage(subAssetPath, md5);
|
|
12
15
|
}
|
|
@@ -2,6 +2,7 @@ import fs from "node:fs/promises";
|
|
|
2
2
|
import { createCaptionFile, uploadCaptionFile } from "@editframe/api";
|
|
3
3
|
import { Readable } from "node:stream";
|
|
4
4
|
import { getClient } from "../../utils/index.js";
|
|
5
|
+
import { basename } from "node:path";
|
|
5
6
|
import { SyncStatus } from "./SyncStatus.js";
|
|
6
7
|
class SyncCaption {
|
|
7
8
|
constructor(path, md5) {
|
|
@@ -22,7 +23,7 @@ class SyncCaption {
|
|
|
22
23
|
async create() {
|
|
23
24
|
this.created = await createCaptionFile(getClient(), {
|
|
24
25
|
md5: this.md5,
|
|
25
|
-
filename: this.path.replace(/\.captions.json$/, ""),
|
|
26
|
+
filename: basename(this.path).replace(/\.captions.json$/, ""),
|
|
26
27
|
byte_size: await this.byteSize()
|
|
27
28
|
});
|
|
28
29
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import fs from "node:fs/promises";
|
|
2
|
-
import { join, dirname } from "node:path";
|
|
2
|
+
import { join, dirname, basename } from "node:path";
|
|
3
3
|
import { Readable } from "node:stream";
|
|
4
4
|
import { createISOBMFFFile, uploadFragmentIndex } from "@editframe/api";
|
|
5
5
|
import { getClient } from "../../utils/index.js";
|
|
@@ -11,9 +11,7 @@ class SyncFragmentIndex {
|
|
|
11
11
|
this.icon = "📋";
|
|
12
12
|
this.label = "fragment index";
|
|
13
13
|
this.syncStatus = new SyncStatus(this.path);
|
|
14
|
-
this.fileSyncStatus = new SyncStatus(
|
|
15
|
-
join(dirname(this.path), "isobmff")
|
|
16
|
-
);
|
|
14
|
+
this.fileSyncStatus = new SyncStatus(join(dirname(this.path), "isobmff"));
|
|
17
15
|
this.created = null;
|
|
18
16
|
}
|
|
19
17
|
async byteSize() {
|
|
@@ -26,7 +24,7 @@ class SyncFragmentIndex {
|
|
|
26
24
|
async create() {
|
|
27
25
|
this.created = await createISOBMFFFile(getClient(), {
|
|
28
26
|
md5: this.md5,
|
|
29
|
-
filename: this.path.replace(/\.tracks.json$/, "")
|
|
27
|
+
filename: basename(this.path).replace(/\.tracks.json$/, "")
|
|
30
28
|
});
|
|
31
29
|
}
|
|
32
30
|
isComplete() {
|
|
@@ -25,8 +25,8 @@ export interface SyncStatusInfo extends z.infer<typeof SyncStatusSchema> {
|
|
|
25
25
|
}
|
|
26
26
|
export declare class SyncStatus {
|
|
27
27
|
private basePath;
|
|
28
|
-
constructor(basePath: string);
|
|
29
28
|
infoPath: string;
|
|
29
|
+
constructor(basePath: string);
|
|
30
30
|
isSynced(): Promise<boolean>;
|
|
31
31
|
readInfo(): Promise<{
|
|
32
32
|
md5: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createReadStream } from "node:fs";
|
|
2
2
|
import fs from "node:fs/promises";
|
|
3
|
-
import { join, dirname } from "node:path";
|
|
3
|
+
import { join, dirname, basename } from "node:path";
|
|
4
4
|
import { createISOBMFFFile, createISOBMFFTrack, uploadISOBMFFTrack } from "@editframe/api";
|
|
5
5
|
import { Probe } from "@editframe/assets";
|
|
6
6
|
import { getClient } from "../../utils/index.js";
|
|
@@ -12,9 +12,7 @@ class SyncTrack {
|
|
|
12
12
|
this.icon = "📼";
|
|
13
13
|
this.label = "track";
|
|
14
14
|
this.syncStatus = new SyncStatus(this.path);
|
|
15
|
-
this.fileSyncStatus = new SyncStatus(
|
|
16
|
-
join(dirname(this.path), "isobmff")
|
|
17
|
-
);
|
|
15
|
+
this.fileSyncStatus = new SyncStatus(join(dirname(this.path), "isobmff"));
|
|
18
16
|
this.created = null;
|
|
19
17
|
this._isoFile = null;
|
|
20
18
|
this._probeResult = null;
|
|
@@ -44,7 +42,7 @@ class SyncTrack {
|
|
|
44
42
|
async prepare() {
|
|
45
43
|
this._isoFile = await createISOBMFFFile(getClient(), {
|
|
46
44
|
md5: this.md5,
|
|
47
|
-
filename: this.path.replace(/\.track-[\d]+.mp4$/, "")
|
|
45
|
+
filename: basename(this.path).replace(/\.track-[\d]+.mp4$/, "")
|
|
48
46
|
});
|
|
49
47
|
this._probeResult = await Probe.probePath(this.path);
|
|
50
48
|
}
|
package/dist/utils/index.js
CHANGED
|
@@ -5,10 +5,16 @@ let client;
|
|
|
5
5
|
const getClient = () => {
|
|
6
6
|
if (!client) {
|
|
7
7
|
const programOpts = program.opts();
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
);
|
|
8
|
+
const token = programOpts.token || process.env.EF_TOKEN;
|
|
9
|
+
const efHost = programOpts.efHost || process.env.EF_HOST;
|
|
10
|
+
console.log("token", token);
|
|
11
|
+
console.log("efHost", efHost);
|
|
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);
|
|
12
18
|
}
|
|
13
19
|
return client;
|
|
14
20
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@editframe/cli",
|
|
3
|
-
"version": "0.11.0-beta.
|
|
3
|
+
"version": "0.11.0-beta.10",
|
|
4
4
|
"description": "Command line interface for EditFrame",
|
|
5
5
|
"bin": {
|
|
6
6
|
"editframe": "./dist/index.js"
|
|
@@ -23,10 +23,10 @@
|
|
|
23
23
|
"vite-tsconfig-paths": "^4.3.2"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@editframe/api": "0.11.0-beta.
|
|
27
|
-
"@editframe/assets": "0.11.0-beta.
|
|
28
|
-
"@editframe/elements": "0.11.0-beta.
|
|
29
|
-
"@editframe/vite-plugin": "0.11.0-beta.
|
|
26
|
+
"@editframe/api": "0.11.0-beta.10",
|
|
27
|
+
"@editframe/assets": "0.11.0-beta.10",
|
|
28
|
+
"@editframe/elements": "0.11.0-beta.10",
|
|
29
|
+
"@editframe/vite-plugin": "0.11.0-beta.10",
|
|
30
30
|
"@inquirer/prompts": "^5.3.8",
|
|
31
31
|
"axios": "^1.6.8",
|
|
32
32
|
"chalk": "^5.3.0",
|
package/src/commands/auth.ts
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { program } from "commander";
|
|
2
|
-
import ora from "ora";
|
|
3
1
|
import chalk from "chalk";
|
|
2
|
+
import { program } from "commander";
|
|
4
3
|
import debug from "debug";
|
|
4
|
+
import ora from "ora";
|
|
5
5
|
|
|
6
6
|
import { getClient } from "../utils/index.ts";
|
|
7
7
|
|
|
8
8
|
const log = debug("ef:cli:auth");
|
|
9
9
|
|
|
10
10
|
export interface APIOrgResult {
|
|
11
|
-
|
|
11
|
+
apiKeyName: string;
|
|
12
12
|
id: string;
|
|
13
13
|
org_id: string;
|
|
14
14
|
created_at: unknown;
|
|
15
15
|
updated_at: unknown;
|
|
16
|
-
|
|
16
|
+
displayName: string;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export const getApiData = async () => {
|
|
20
|
-
const response = await getClient().authenticatedFetch("/api/
|
|
20
|
+
const response = await getClient().authenticatedFetch("/api/v1/organization");
|
|
21
21
|
return response.json() as Promise<APIOrgResult>;
|
|
22
22
|
};
|
|
23
23
|
|
|
@@ -33,14 +33,14 @@ const authCommand = program
|
|
|
33
33
|
try {
|
|
34
34
|
const apiData = await getApiData();
|
|
35
35
|
spinner.succeed("You are authenticated! 🎉");
|
|
36
|
-
process.stderr.write(chalk.green(`Name: ${apiData.name}\n`));
|
|
37
36
|
process.stderr.write(
|
|
38
|
-
chalk.green(`
|
|
37
|
+
chalk.green(`You're using ${apiData.apiKeyName} API key 🚀\n`),
|
|
38
|
+
);
|
|
39
|
+
process.stderr.write(
|
|
40
|
+
chalk.blue(`Welcome to ${apiData.displayName} organization 🎉\n`),
|
|
39
41
|
);
|
|
40
42
|
} catch (error: any) {
|
|
41
43
|
spinner.fail("Authentication failed!");
|
|
42
|
-
process.stderr.write(error?.message);
|
|
43
|
-
process.stderr.write("\n");
|
|
44
44
|
log("Error:", error);
|
|
45
45
|
}
|
|
46
46
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import debug from "debug";
|
|
1
2
|
import type { SyncStatus } from "./SyncStatus.ts";
|
|
2
3
|
|
|
3
4
|
import { SyncCaption } from "./SyncCaption.ts";
|
|
@@ -25,7 +26,10 @@ const fragmentIndexMatch = /\.tracks.json$/i;
|
|
|
25
26
|
const captionsMatch = /\.captions.json$/i;
|
|
26
27
|
const imageMatch = /\.(png|jpe?g|gif|webp)$/i;
|
|
27
28
|
|
|
29
|
+
const log = debug("ef:SubAssetSync");
|
|
30
|
+
|
|
28
31
|
export const getAssetSync = (subAssetPath: string, md5: string) => {
|
|
32
|
+
log("getAssetSync", { subAssetPath, md5 });
|
|
29
33
|
if (imageMatch.test(subAssetPath)) {
|
|
30
34
|
return new SyncImage(subAssetPath, md5);
|
|
31
35
|
}
|
|
@@ -8,9 +8,10 @@ import {
|
|
|
8
8
|
|
|
9
9
|
import { Readable } from "node:stream";
|
|
10
10
|
import { getClient } from "../../utils/index.ts";
|
|
11
|
+
|
|
12
|
+
import { basename } from "node:path";
|
|
11
13
|
import type { SubAssetSync } from "./SubAssetSync.ts";
|
|
12
14
|
import { SyncStatus } from "./SyncStatus.ts";
|
|
13
|
-
|
|
14
15
|
export class SyncCaption implements SubAssetSync<CreateCaptionFileResult> {
|
|
15
16
|
icon = "📝";
|
|
16
17
|
label = "captions";
|
|
@@ -32,7 +33,7 @@ export class SyncCaption implements SubAssetSync<CreateCaptionFileResult> {
|
|
|
32
33
|
async create() {
|
|
33
34
|
this.created = await createCaptionFile(getClient(), {
|
|
34
35
|
md5: this.md5,
|
|
35
|
-
filename: this.path.replace(/\.captions.json$/, ""),
|
|
36
|
+
filename: basename(this.path).replace(/\.captions.json$/, ""),
|
|
36
37
|
byte_size: await this.byteSize(),
|
|
37
38
|
});
|
|
38
39
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import fs from "node:fs/promises";
|
|
2
|
-
import { dirname, join } from "node:path";
|
|
2
|
+
import { basename, dirname, join } from "node:path";
|
|
3
3
|
import { Readable } from "node:stream";
|
|
4
4
|
|
|
5
5
|
import {
|
|
@@ -17,10 +17,8 @@ export class SyncFragmentIndex
|
|
|
17
17
|
{
|
|
18
18
|
icon = "📋";
|
|
19
19
|
label = "fragment index";
|
|
20
|
-
syncStatus
|
|
21
|
-
fileSyncStatus
|
|
22
|
-
join(dirname(this.path), "isobmff"),
|
|
23
|
-
);
|
|
20
|
+
syncStatus = new SyncStatus(this.path);
|
|
21
|
+
fileSyncStatus = new SyncStatus(join(dirname(this.path), "isobmff"));
|
|
24
22
|
created: CreateISOBMFFFileResult | null = null;
|
|
25
23
|
|
|
26
24
|
constructor(
|
|
@@ -39,7 +37,7 @@ export class SyncFragmentIndex
|
|
|
39
37
|
async create() {
|
|
40
38
|
this.created = await createISOBMFFFile(getClient(), {
|
|
41
39
|
md5: this.md5,
|
|
42
|
-
filename: this.path.replace(/\.tracks.json$/, ""),
|
|
40
|
+
filename: basename(this.path).replace(/\.tracks.json$/, ""),
|
|
43
41
|
});
|
|
44
42
|
}
|
|
45
43
|
|
|
@@ -16,15 +16,16 @@ const SyncStatusSchema = z.object({
|
|
|
16
16
|
export interface SyncStatusInfo extends z.infer<typeof SyncStatusSchema> {}
|
|
17
17
|
|
|
18
18
|
export class SyncStatus {
|
|
19
|
-
constructor(private basePath: string) {}
|
|
20
|
-
|
|
21
19
|
infoPath = `${this.basePath}.info`;
|
|
22
20
|
|
|
21
|
+
constructor(private basePath: string) {}
|
|
22
|
+
|
|
23
23
|
async isSynced() {
|
|
24
24
|
const syncInfo = await this.readInfo();
|
|
25
25
|
if (!syncInfo) {
|
|
26
26
|
return false;
|
|
27
27
|
}
|
|
28
|
+
console.log("syncInfo.infoPath", this.infoPath);
|
|
28
29
|
return syncInfo.version === SYNC_VERSION && syncInfo.complete;
|
|
29
30
|
}
|
|
30
31
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createReadStream } from "node:fs";
|
|
2
2
|
import fs from "node:fs/promises";
|
|
3
|
-
import { dirname, join } from "node:path";
|
|
3
|
+
import { basename, dirname, join } from "node:path";
|
|
4
4
|
|
|
5
5
|
import type { z } from "zod";
|
|
6
6
|
|
|
@@ -21,10 +21,8 @@ import { SyncStatus } from "./SyncStatus.ts";
|
|
|
21
21
|
export class SyncTrack implements SubAssetSync<CreateISOBMFFTrackResult> {
|
|
22
22
|
icon = "📼";
|
|
23
23
|
label = "track";
|
|
24
|
-
syncStatus
|
|
25
|
-
fileSyncStatus
|
|
26
|
-
join(dirname(this.path), "isobmff"),
|
|
27
|
-
);
|
|
24
|
+
syncStatus = new SyncStatus(this.path);
|
|
25
|
+
fileSyncStatus = new SyncStatus(join(dirname(this.path), "isobmff"));
|
|
28
26
|
created: CreateISOBMFFTrackResult | null = null;
|
|
29
27
|
|
|
30
28
|
constructor(
|
|
@@ -64,7 +62,7 @@ export class SyncTrack implements SubAssetSync<CreateISOBMFFTrackResult> {
|
|
|
64
62
|
async prepare() {
|
|
65
63
|
this._isoFile = await createISOBMFFFile(getClient(), {
|
|
66
64
|
md5: this.md5,
|
|
67
|
-
filename: this.path.replace(/\.track-[\d]+.mp4$/, ""),
|
|
65
|
+
filename: basename(this.path).replace(/\.track-[\d]+.mp4$/, ""),
|
|
68
66
|
});
|
|
69
67
|
this._probeResult = await Probe.probePath(this.path);
|
|
70
68
|
}
|
package/src/utils/index.ts
CHANGED
|
@@ -7,10 +7,16 @@ let client: Client;
|
|
|
7
7
|
export const getClient = () => {
|
|
8
8
|
if (!client) {
|
|
9
9
|
const programOpts = program.opts();
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
);
|
|
10
|
+
const token = programOpts.token || process.env.EF_TOKEN;
|
|
11
|
+
const efHost = programOpts.efHost || process.env.EF_HOST;
|
|
12
|
+
console.log("token", token);
|
|
13
|
+
console.log("efHost", efHost);
|
|
14
|
+
if (!token) {
|
|
15
|
+
throw new Error(
|
|
16
|
+
"EF_TOKEN must be set or supplied as command line argument",
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
client = new Client(token, efHost);
|
|
14
20
|
}
|
|
15
21
|
return client;
|
|
16
22
|
};
|