@editframe/cli 0.8.0-beta.8 → 0.9.0-beta.1

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 CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "0.8.0-beta.8";
1
+ export declare const VERSION = "0.9.0-beta.1";
package/dist/VERSION.js CHANGED
@@ -1,4 +1,4 @@
1
- const VERSION = "0.8.0-beta.8";
1
+ const VERSION = "0.9.0-beta.1";
2
2
  export {
3
3
  VERSION
4
4
  };
@@ -1 +1 @@
1
- export {};
1
+ export declare const buildAssetId: (assetPath: string) => Promise<string>;
@@ -17,34 +17,19 @@ import { getRenderInfo } from "../operations/getRenderInfo.js";
17
17
  import { processRenderInfo } from "../operations/processRenderInfo.js";
18
18
  import { validateVideoResolution } from "../utils/validateVideoResolution.js";
19
19
  import { getFolderSize } from "../utils/getFolderSize.js";
20
- const buildProductionUrl = async (origin, tagName, assetPath) => {
20
+ const buildAssetId = async (assetPath) => {
21
21
  const md5Sum = await md5FilePath(assetPath);
22
22
  const basename = path.basename(assetPath);
23
- switch (tagName) {
24
- case "ef-audio":
25
- case "ef-video": {
26
- return `${origin}/api/video2/isobmff_files/${md5Sum}/${basename}`;
27
- }
28
- case "ef-captions": {
29
- return `${origin}/api/video2/caption_files/${md5Sum}/${basename}`;
30
- }
31
- case "ef-image": {
32
- return `${origin}/api/video2/image_files/${md5Sum}/${basename}`;
33
- }
34
- default: {
35
- return assetPath;
36
- }
37
- }
23
+ return `${md5Sum}:${basename}`;
38
24
  };
39
25
  class V1Builder {
40
- async buildProductionUrl(tagName, assetPath) {
41
- return buildProductionUrl("editframe://", tagName, assetPath);
26
+ async buildAssetId(assetPath) {
27
+ return buildAssetId(assetPath);
42
28
  }
43
29
  }
44
30
  class V2Builder {
45
- async buildProductionUrl(tagName, assetPath) {
46
- const efRenderHost = program.opts().efRenderHost;
47
- return buildProductionUrl(efRenderHost, tagName, assetPath);
31
+ async buildAssetId(assetPath) {
32
+ return buildAssetId(assetPath);
48
33
  }
49
34
  }
50
35
  const strategyBuilders = {
@@ -109,11 +94,8 @@ program.command("render [directory]").description(
109
94
  }
110
95
  const assetPath = path.join(srcDir, src);
111
96
  element.setAttribute(
112
- "src",
113
- await builder.buildProductionUrl(
114
- element.tagName.toLowerCase(),
115
- assetPath
116
- )
97
+ "asset-id",
98
+ await builder.buildAssetId(assetPath)
117
99
  );
118
100
  }
119
101
  await writeFile(path.join(distDir, "index.html"), doc.toString());
@@ -151,3 +133,6 @@ program.command("render [directory]").description(
151
133
  }
152
134
  );
153
135
  });
136
+ export {
137
+ buildAssetId
138
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -119,14 +119,14 @@ const syncAssetDirectory = async (projectDirectory) => {
119
119
  created.id,
120
120
  createReadStream(subAssetPath),
121
121
  Number.parseInt(format.size || "0")
122
- ).catch((error) => {
122
+ ).then(() => {
123
+ reportSuccess(subAsset, "Image has been synced.");
124
+ return syncStatus.markSynced();
125
+ }).catch((error) => {
123
126
  reportError(
124
127
  subAsset,
125
128
  `Error uploading image: ${error.message}`
126
129
  );
127
- }).then(() => {
128
- reportSuccess(subAsset, "Image has been synced.");
129
- return syncStatus.markSynced();
130
130
  });
131
131
  }
132
132
  }
@@ -180,7 +180,7 @@ const syncAssetDirectory = async (projectDirectory) => {
180
180
  createPayload
181
181
  );
182
182
  if (createdTrack) {
183
- if (createdTrack.next_byte === createdTrack.byte_size - 1) {
183
+ if (createdTrack.next_byte === createdTrack.byte_size) {
184
184
  reportInfo(subAsset, "✔ Track has already been synced.");
185
185
  await syncStatus.markSynced();
186
186
  } else {
@@ -190,14 +190,14 @@ const syncAssetDirectory = async (projectDirectory) => {
190
190
  Number(trackId),
191
191
  createReadStream(subAssetPath),
192
192
  createdTrack.byte_size
193
- ).catch((error) => {
193
+ ).then(() => {
194
+ reportSuccess(subAsset, "Track has been synced.");
195
+ return syncStatus.markSynced();
196
+ }).catch((error) => {
194
197
  reportError(
195
198
  subAsset,
196
199
  `Error uploading track: ${error.message}`
197
200
  );
198
- }).then(() => {
199
- reportSuccess(subAsset, "Track has been synced.");
200
- return syncStatus.markSynced();
201
201
  });
202
202
  }
203
203
  }
@@ -222,14 +222,14 @@ const syncAssetDirectory = async (projectDirectory) => {
222
222
  asset,
223
223
  readStream,
224
224
  stats.size
225
- ).catch((error) => {
225
+ ).then(() => {
226
+ reportSuccess(subAsset, "Fragment index has been synced.");
227
+ return syncStatus.markSynced();
228
+ }).catch((error) => {
226
229
  reportError(
227
230
  subAsset,
228
231
  `Error uploading fragment index: ${error.message}`
229
232
  );
230
- }).then(() => {
231
- reportSuccess(subAsset, "Fragment index has been synced.");
232
- return syncStatus.markSynced();
233
233
  });
234
234
  }
235
235
  } else {
@@ -260,14 +260,14 @@ const syncAssetDirectory = async (projectDirectory) => {
260
260
  asset,
261
261
  readStream,
262
262
  stats.size
263
- ).catch((error) => {
263
+ ).then(() => {
264
+ reportSuccess(subAsset, "Captions have been synced.");
265
+ return syncStatus.markSynced();
266
+ }).catch((error) => {
264
267
  reportError(
265
268
  subAsset,
266
269
  `Error uploading captions: ${error.message}`
267
270
  );
268
- }).then(() => {
269
- reportSuccess(subAsset, "Captions have been synced.");
270
- return syncStatus.markSynced();
271
271
  });
272
272
  }
273
273
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@editframe/cli",
3
- "version": "0.8.0-beta.8",
3
+ "version": "0.9.0-beta.1",
4
4
  "description": "Command line interface for EditFrame",
5
5
  "bin": {
6
6
  "editframe": "./dist/index.js"
@@ -23,10 +23,11 @@
23
23
  "vite-tsconfig-paths": "^4.3.2"
24
24
  },
25
25
  "dependencies": {
26
- "@editframe/api": "0.8.0-beta.8",
27
- "@editframe/assets": "0.8.0-beta.8",
28
- "@editframe/elements": "0.8.0-beta.8",
29
- "@editframe/vite-plugin": "0.8.0-beta.8",
26
+ "@editframe/api": "0.9.0-beta.1",
27
+ "@editframe/assets": "0.9.0-beta.1",
28
+ "@editframe/elements": "0.9.0-beta.1",
29
+ "@editframe/vite-plugin": "0.9.0-beta.1",
30
+ "@inquirer/prompts": "^5.3.8",
30
31
  "axios": "^1.6.8",
31
32
  "chalk": "^5.3.0",
32
33
  "commander": "^12.0.0",
@@ -0,0 +1,34 @@
1
+ // @vitest-environment node
2
+ import { join } from "node:path";
3
+ import { describe, expect, test } from "vitest";
4
+ import { buildAssetId } from "./render.ts";
5
+
6
+ const testAssetPath = join(__dirname, "test-asset.file");
7
+
8
+ describe("render", () => {
9
+ describe("buildProductionUrl", () => {
10
+ test("builds urls for ef-audio", async () => {
11
+ await expect(buildAssetId(testAssetPath)).resolves.toBe(
12
+ "d41d8cd9-8f00-b204-e980-0998ecf8427e:test-asset.file",
13
+ );
14
+ });
15
+
16
+ test("builds urls for ef-video", async () => {
17
+ await expect(buildAssetId(testAssetPath)).resolves.toBe(
18
+ "d41d8cd9-8f00-b204-e980-0998ecf8427e:test-asset.file",
19
+ );
20
+ });
21
+
22
+ test("builds urls for ef-captions", async () => {
23
+ await expect(buildAssetId(testAssetPath)).resolves.toBe(
24
+ "d41d8cd9-8f00-b204-e980-0998ecf8427e:test-asset.file",
25
+ );
26
+ });
27
+
28
+ test("builds urls for ef-image", async () => {
29
+ await expect(buildAssetId(testAssetPath)).resolves.toBe(
30
+ "d41d8cd9-8f00-b204-e980-0998ecf8427e:test-asset.file",
31
+ );
32
+ });
33
+ });
34
+ });
@@ -22,45 +22,26 @@ import { validateVideoResolution } from "../utils/validateVideoResolution.ts";
22
22
  import { getFolderSize } from "../utils/getFolderSize.ts";
23
23
 
24
24
  interface StrategyBuilder {
25
- buildProductionUrl: (tagName: string, assetPath: string) => Promise<string>;
25
+ buildAssetId: (assetPath: string) => Promise<string>;
26
26
  }
27
27
 
28
- const buildProductionUrl = async (
29
- origin: string,
30
- tagName: string,
31
- assetPath: string,
32
- ) => {
28
+ export const buildAssetId = async (assetPath: string) => {
33
29
  const md5Sum = await md5FilePath(assetPath);
34
30
 
35
31
  const basename = path.basename(assetPath);
36
32
 
37
- switch (tagName) {
38
- case "ef-audio":
39
- case "ef-video": {
40
- return `${origin}/api/video2/isobmff_files/${md5Sum}/${basename}`;
41
- }
42
- case "ef-captions": {
43
- return `${origin}/api/video2/caption_files/${md5Sum}/${basename}`;
44
- }
45
- case "ef-image": {
46
- return `${origin}/api/video2/image_files/${md5Sum}/${basename}`;
47
- }
48
- default: {
49
- return assetPath;
50
- }
51
- }
33
+ return `${md5Sum}:${basename}`;
52
34
  };
53
35
 
54
36
  class V1Builder implements StrategyBuilder {
55
- async buildProductionUrl(tagName: string, assetPath: string) {
56
- return buildProductionUrl("editframe://", tagName, assetPath);
37
+ async buildAssetId(assetPath: string) {
38
+ return buildAssetId(assetPath);
57
39
  }
58
40
  }
59
41
 
60
42
  class V2Builder implements StrategyBuilder {
61
- async buildProductionUrl(tagName: string, assetPath: string) {
62
- const efRenderHost = program.opts().efRenderHost;
63
- return buildProductionUrl(efRenderHost, tagName, assetPath);
43
+ async buildAssetId(assetPath: string) {
44
+ return buildAssetId(assetPath);
64
45
  }
65
46
  }
66
47
 
@@ -138,11 +119,8 @@ program
138
119
  const assetPath = path.join(srcDir, src);
139
120
 
140
121
  element.setAttribute(
141
- "src",
142
- await builder.buildProductionUrl(
143
- element.tagName.toLowerCase(),
144
- assetPath,
145
- ),
122
+ "asset-id",
123
+ await builder.buildAssetId(assetPath),
146
124
  );
147
125
  }
148
126
 
File without changes
@@ -153,15 +153,15 @@ export const syncAssetDirectory = async (
153
153
  createReadStream(subAssetPath),
154
154
  Number.parseInt(format.size || "0"),
155
155
  )
156
+ .then(() => {
157
+ reportSuccess(subAsset, "Image has been synced.");
158
+ return syncStatus.markSynced();
159
+ })
156
160
  .catch((error) => {
157
161
  reportError(
158
162
  subAsset,
159
163
  `Error uploading image: ${error.message}`,
160
164
  );
161
- })
162
- .then(() => {
163
- reportSuccess(subAsset, "Image has been synced.");
164
- return syncStatus.markSynced();
165
165
  });
166
166
  }
167
167
  }
@@ -227,7 +227,7 @@ export const syncAssetDirectory = async (
227
227
  );
228
228
 
229
229
  if (createdTrack) {
230
- if (createdTrack.next_byte === createdTrack.byte_size - 1) {
230
+ if (createdTrack.next_byte === createdTrack.byte_size) {
231
231
  reportInfo(subAsset, "✔ Track has already been synced.");
232
232
  await syncStatus.markSynced();
233
233
  } else {
@@ -238,15 +238,15 @@ export const syncAssetDirectory = async (
238
238
  createReadStream(subAssetPath),
239
239
  createdTrack.byte_size,
240
240
  )
241
+ .then(() => {
242
+ reportSuccess(subAsset, "Track has been synced.");
243
+ return syncStatus.markSynced();
244
+ })
241
245
  .catch((error) => {
242
246
  reportError(
243
247
  subAsset,
244
248
  `Error uploading track: ${error.message}`,
245
249
  );
246
- })
247
- .then(() => {
248
- reportSuccess(subAsset, "Track has been synced.");
249
- return syncStatus.markSynced();
250
250
  });
251
251
  }
252
252
  }
@@ -273,15 +273,15 @@ export const syncAssetDirectory = async (
273
273
  readStream,
274
274
  stats.size,
275
275
  )
276
+ .then(() => {
277
+ reportSuccess(subAsset, "Fragment index has been synced.");
278
+ return syncStatus.markSynced();
279
+ })
276
280
  .catch((error) => {
277
281
  reportError(
278
282
  subAsset,
279
283
  `Error uploading fragment index: ${error.message}`,
280
284
  );
281
- })
282
- .then(() => {
283
- reportSuccess(subAsset, "Fragment index has been synced.");
284
- return syncStatus.markSynced();
285
285
  });
286
286
  }
287
287
  } else {
@@ -313,15 +313,15 @@ export const syncAssetDirectory = async (
313
313
  readStream,
314
314
  stats.size,
315
315
  )
316
+ .then(() => {
317
+ reportSuccess(subAsset, "Captions have been synced.");
318
+ return syncStatus.markSynced();
319
+ })
316
320
  .catch((error) => {
317
321
  reportError(
318
322
  subAsset,
319
323
  `Error uploading captions: ${error.message}`,
320
324
  );
321
- })
322
- .then(() => {
323
- reportSuccess(subAsset, "Captions have been synced.");
324
- return syncStatus.markSynced();
325
325
  });
326
326
  }
327
327
  } else {