@funnelsgrove/cli 0.1.12 → 0.1.13

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.
@@ -15,6 +15,7 @@ export type SourceFile = {
15
15
  path: string;
16
16
  content: string;
17
17
  contentType?: string;
18
+ contentEncoding?: 'base64';
18
19
  };
19
20
  export type ChangedSourceFiles = {
20
21
  currentManifest: SyncManifest;
package/dist/localSync.js CHANGED
@@ -213,7 +213,8 @@ export async function writeSourceFiles(rootDir, files) {
213
213
  const relativePath = assertSafeSyncPath(file.path);
214
214
  const absolutePath = path.join(rootDir, relativePath);
215
215
  await mkdir(path.dirname(absolutePath), { recursive: true });
216
- await writeFile(absolutePath, decodeDataUrl(file.content) || file.content, decodeDataUrl(file.content) ? undefined : 'utf8');
216
+ const decodedContent = decodeBinarySourceContent(file);
217
+ await writeFile(absolutePath, decodedContent || file.content, decodedContent ? undefined : 'utf8');
217
218
  }
218
219
  }
219
220
  async function collectSyncFiles(rootDir, dir) {
@@ -270,3 +271,16 @@ function decodeDataUrl(content) {
270
271
  }
271
272
  return Buffer.from(match[2].replace(/\s+/g, '').replace(/-/g, '+').replace(/_/g, '/'), 'base64');
272
273
  }
274
+ function decodeBase64Content(content) {
275
+ const normalized = content.trim().replace(/\s+/g, '').replace(/-/g, '+').replace(/_/g, '/');
276
+ if (!normalized || !/^[A-Za-z0-9+/=]+$/.test(normalized)) {
277
+ return null;
278
+ }
279
+ return Buffer.from(normalized, 'base64');
280
+ }
281
+ function decodeBinarySourceContent(file) {
282
+ if (file.contentEncoding === 'base64') {
283
+ return decodeBase64Content(file.content);
284
+ }
285
+ return decodeDataUrl(file.content);
286
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@funnelsgrove/cli",
3
- "version": "0.1.12",
3
+ "version": "0.1.13",
4
4
  "description": "FunnelsGrove command-line tools for editing, syncing, and publishing funnels",
5
5
  "type": "module",
6
6
  "bin": {