@coreframe/assets 0.1.9 → 0.1.11

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.
@@ -0,0 +1,26 @@
1
+ import { AssetsConfig } from "@coreframe/config";
2
+ import { ListablePrivateObjectStore } from "@coreframe/object-storage";
3
+
4
+ //#region src/backup.d.ts
5
+ type BackupAssetsOptions = {
6
+ branch: string;
7
+ config?: AssetsConfig;
8
+ cwd?: string;
9
+ env?: NodeJS.ProcessEnv;
10
+ store?: ListablePrivateObjectStore;
11
+ };
12
+ type AssetBackupResult = {
13
+ branch: string;
14
+ bytes: number;
15
+ commit: string;
16
+ objects: number;
17
+ };
18
+ declare function backupAssets({
19
+ branch,
20
+ config,
21
+ cwd,
22
+ env,
23
+ store
24
+ }: BackupAssetsOptions): Promise<AssetBackupResult>;
25
+ //#endregion
26
+ export { AssetBackupResult, BackupAssetsOptions, backupAssets };
package/dist/backup.js ADDED
@@ -0,0 +1 @@
1
+ import{process as e}from"./environment.js";import{resolveAssetsConfig as t}from"./project.js";import{createB2AssetStore as n}from"./storage.js";import{createHash as r}from"node:crypto";import{dirname as i,join as a,posix as o}from"node:path";import s from"nano-spawn";import{mkdir as c,mkdtemp as l,rm as u,stat as d,writeFile as f}from"node:fs/promises";import{tmpdir as p}from"node:os";const m=`coreframe-assets-bucket-backup`;async function h({branch:h,config:_,cwd:v=e.cwd(),env:y=e.env,store:b}){g(h);let x=await t(v,_),S=b??n({config:x,env:y}),C=(await s(`git`,[`rev-parse`,`--show-toplevel`],{cwd:v})).stdout.trim(),w=await l(a(p(),`coreframe-assets-backup-`)),T=a(w,`worktree`),E=!1;try{await s(`git`,[`check-ref-format`,`--branch`,h],{cwd:C}),await s(`git`,[`worktree`,`add`,`-b`,h,T,`HEAD`],{cwd:C}),E=!0;let e=a(T,m);await u(e,{force:!0,recursive:!0});let t={schemaVersion:1,buckets:[]},n=0,l=0;for(let s of new Set([x.sourceBucket,x.publicBucket])){let u=[...await S.list(s)].sort((e,t)=>e.key.localeCompare(t.key)),f={name:s,objects:[]},p=r(`sha256`).update(s).digest(`hex`);for(let t of u){let u=o.join(`buckets`,p,`objects`,r(`sha256`).update(t.key).digest(`hex`).slice(0,2),r(`sha256`).update(t.key).digest(`hex`)),m=a(e,...u.split(`/`));await c(i(m),{recursive:!0}),await S.download(s,t.key,m);let h=(await d(m)).size;if(h!==t.size)throw Error(`Downloaded size for ${s}/${t.key} was ${h}, expected ${t.size}.`);f.objects.push({key:t.key,path:u,size:h}),n+=h,l+=1}t.buckets.push(f)}await c(e,{recursive:!0}),await f(a(e,`manifest.json`),`${JSON.stringify(t,null,2)}\n`),await s(`git`,[`add`,`--all`,`--force`,m],{cwd:T}),await s(`git`,[`-c`,`user.name=Coreframe`,`-c`,`user.email=coreframe@localhost`,`commit`,`--message`,`chore(assets): back up asset buckets`],{cwd:T});let p=(await s(`git`,[`rev-parse`,`HEAD`],{cwd:T})).stdout.trim();return{branch:h,bytes:n,commit:p,objects:l}}finally{E&&await s(`git`,[`worktree`,`remove`,`--force`,T],{cwd:C}).catch(()=>void 0),await u(w,{force:!0,recursive:!0})}}function g(e){if(!e.trim()||e!==e.trim()||e.startsWith(`-`))throw Error(`Asset backup branch must be a non-empty Git branch name.`)}export{h as backupAssets};
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { AssetBuildEntry, AssetBuildResult, AssetCatalog, AssetCatalogEntry, AssetCatalogPack, AssetFile, AssetKind, AssetManifest, AssetManifestEntry, AssetOutput, AssetOutputStatus, AssetProblem, AssetPublishResult, AssetSource, AssetStatus, AssetStatusEntry, AssetVariant, AudioAssetFile, AudioCatalogEntry, AudioManifestEntry, ImageCatalogEntry, ImageManifestEntry, LoadedAssetCatalog, LoadedAssetManifest, LottieAssetFile, LottieCatalogEntry, LottieManifestEntry, PublishedAsset, SvgAssetFile, SvgCatalogEntry, SvgManifestEntry, SvgViewBox, VideoAssetFile, VideoCatalogEntry, VideoManifestEntry } from "./contracts.js";
2
2
  import { assetCatalogEntries, assetCatalogPackNames, assetManifestPath, findCatalogAsset, formatAssetProblems, listAssetManifestPacks, manifestEntryOutputs, readAssetCatalog, readAssetManifest, resolveAssetVariantFile } from "./project.js";
3
3
  import { AddAssetOptions, AssetManifestStatus, AssetWorkflowOptions, BuildAssetsOptions, CheckAssetManifestsOptions, CheckAssetsOptions, PublishAssetsOptions, addAsset, buildAssets, checkAssetManifests, checkAssets, materializeAsset, printAssetResult, publishAssets } from "./workflows.js";
4
- export { AddAssetOptions, type AssetBuildEntry, type AssetBuildResult, type AssetCatalog, type AssetCatalogEntry, type AssetCatalogPack, type AssetFile, type AssetKind, type AssetManifest, type AssetManifestEntry, AssetManifestStatus, type AssetOutput, type AssetOutputStatus, type AssetProblem, type AssetPublishResult, type AssetSource, type AssetStatus, type AssetStatusEntry, type AssetVariant, AssetWorkflowOptions, type AudioAssetFile, type AudioCatalogEntry, type AudioManifestEntry, BuildAssetsOptions, CheckAssetManifestsOptions, CheckAssetsOptions, type ImageCatalogEntry, type ImageManifestEntry, type LoadedAssetCatalog, type LoadedAssetManifest, type LottieAssetFile, type LottieCatalogEntry, type LottieManifestEntry, PublishAssetsOptions, type PublishedAsset, type SvgAssetFile, type SvgCatalogEntry, type SvgManifestEntry, type SvgViewBox, type VideoAssetFile, type VideoCatalogEntry, type VideoManifestEntry, addAsset, assetCatalogEntries, assetCatalogPackNames, assetManifestPath, buildAssets, checkAssetManifests, checkAssets, findCatalogAsset, formatAssetProblems, listAssetManifestPacks, manifestEntryOutputs, materializeAsset, printAssetResult, publishAssets, readAssetCatalog, readAssetManifest, resolveAssetVariantFile };
4
+ import { AssetBackupResult, BackupAssetsOptions, backupAssets } from "./backup.js";
5
+ export { AddAssetOptions, AssetBackupResult, type AssetBuildEntry, type AssetBuildResult, type AssetCatalog, type AssetCatalogEntry, type AssetCatalogPack, type AssetFile, type AssetKind, type AssetManifest, type AssetManifestEntry, AssetManifestStatus, type AssetOutput, type AssetOutputStatus, type AssetProblem, type AssetPublishResult, type AssetSource, type AssetStatus, type AssetStatusEntry, type AssetVariant, AssetWorkflowOptions, type AudioAssetFile, type AudioCatalogEntry, type AudioManifestEntry, BackupAssetsOptions, BuildAssetsOptions, CheckAssetManifestsOptions, CheckAssetsOptions, type ImageCatalogEntry, type ImageManifestEntry, type LoadedAssetCatalog, type LoadedAssetManifest, type LottieAssetFile, type LottieCatalogEntry, type LottieManifestEntry, PublishAssetsOptions, type PublishedAsset, type SvgAssetFile, type SvgCatalogEntry, type SvgManifestEntry, type SvgViewBox, type VideoAssetFile, type VideoCatalogEntry, type VideoManifestEntry, addAsset, assetCatalogEntries, assetCatalogPackNames, assetManifestPath, backupAssets, buildAssets, checkAssetManifests, checkAssets, findCatalogAsset, formatAssetProblems, listAssetManifestPacks, manifestEntryOutputs, materializeAsset, printAssetResult, publishAssets, readAssetCatalog, readAssetManifest, resolveAssetVariantFile };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{assetCatalogEntries as e,assetCatalogPackNames as t,assetManifestPath as n,findCatalogAsset as r,formatAssetProblems as i,listAssetManifestPacks as a,manifestEntryOutputs as o,readAssetCatalog as s,readAssetManifest as c,resolveAssetVariantFile as l}from"./project.js";import{addAsset as u,buildAssets as d,checkAssetManifests as f,checkAssets as p,materializeAsset as m,printAssetResult as h,publishAssets as g}from"./workflows.js";export{u as addAsset,e as assetCatalogEntries,t as assetCatalogPackNames,n as assetManifestPath,d as buildAssets,f as checkAssetManifests,p as checkAssets,r as findCatalogAsset,i as formatAssetProblems,a as listAssetManifestPacks,o as manifestEntryOutputs,m as materializeAsset,h as printAssetResult,g as publishAssets,s as readAssetCatalog,c as readAssetManifest,l as resolveAssetVariantFile};
1
+ import{assetCatalogEntries as e,assetCatalogPackNames as t,assetManifestPath as n,findCatalogAsset as r,formatAssetProblems as i,listAssetManifestPacks as a,manifestEntryOutputs as o,readAssetCatalog as s,readAssetManifest as c,resolveAssetVariantFile as l}from"./project.js";import{addAsset as u,buildAssets as d,checkAssetManifests as f,checkAssets as p,materializeAsset as m,printAssetResult as h,publishAssets as g}from"./workflows.js";import{backupAssets as _}from"./backup.js";export{u as addAsset,e as assetCatalogEntries,t as assetCatalogPackNames,n as assetManifestPath,_ as backupAssets,d as buildAssets,f as checkAssetManifests,p as checkAssets,r as findCatalogAsset,i as formatAssetProblems,a as listAssetManifestPacks,o as manifestEntryOutputs,m as materializeAsset,h as printAssetResult,g as publishAssets,s as readAssetCatalog,c as readAssetManifest,l as resolveAssetVariantFile};
package/dist/storage.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { AssetsConfig } from "@coreframe/config";
2
- import { PrivateObjectStore } from "@coreframe/object-storage";
2
+ import { ListablePrivateObjectStore, PrivateObjectStore } from "@coreframe/object-storage";
3
3
 
4
4
  //#region src/storage.d.ts
5
5
  type AssetObjectStore = PrivateObjectStore;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coreframe/assets",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "description": "Asset processing and object-storage workflows for Coreframe apps",
5
5
  "repository": {
6
6
  "type": "git",
@@ -22,8 +22,8 @@
22
22
  "music-metadata": "^11.14.0",
23
23
  "nano-spawn": "^2.1.0",
24
24
  "saxes": "^6.0.0",
25
- "@coreframe/config": "^0.1.6",
26
- "@coreframe/object-storage": "^0.1.3"
25
+ "@coreframe/object-storage": "^0.1.4",
26
+ "@coreframe/config": "^0.1.8"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@types/node": "^26.1.0",