@fjall/util 2.4.8 → 2.5.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/.minified CHANGED
@@ -1 +1 @@
1
- 57 files minified at 2026-05-27T22:11:13.816Z
1
+ 57 files minified at 2026-05-29T04:05:00.235Z
@@ -1 +1 @@
1
- import{readFile as l,writeFile as m,unlink as h,rename as g,mkdir as M}from"fs/promises";import{readFileSync as y}from"fs";import{dirname as F,join as f}from"path";import{logger as s}from"../logger.js";import{fileExists as w}from"../fsHelpers.js";import{getErrorMessage as u}from"../errorUtils.js";import{recordToConstructMap as S}from"../constructMap.js";import{DockerBuildSchema as x,FjallManifestSchema as k,FJALL_MANIFEST_FILENAME as d,MANIFEST_SCHEMA_VERSION as A}from"./schemas.js";function p(e){return f(e,d)}async function E(e){const t=p(e);if(!await w(t))return null;try{const r=await l(t,"utf-8"),n=JSON.parse(r),a=k.safeParse(n);return a.success||s.debug("FjallManifest","Manifest validation failed",{path:t,errors:a.error.issues.map(i=>`${i.path.join(".")}: ${i.message}`)}),a.success?a.data:null}catch(r){return s.debug("FjallManifest","Failed to read manifest file",{path:t,error:u(r)}),null}}async function T(e,t){const r=p(e),n=`${r}.${Date.now()}.tmp`;await M(F(r),{recursive:!0});try{await m(n,JSON.stringify(t,null,2),"utf-8"),await g(n,r)}catch(a){try{await h(n)}catch(i){s.debug("FjallManifest","Temp file cleanup failed (non-fatal)",{path:n,error:u(i)})}throw a}}function _(e){return{version:A,generatedAt:new Date().toISOString(),appName:e,services:[],lambdas:[],stacks:{}}}async function $(e){const t=await E(e);return t?.resourceMap?S(t.resourceMap):new Map}function o(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function j(e){if(!o(e)||typeof e.path!="string"||e.path.length===0)return;const t=typeof e.context=="string"&&e.context.length>0?e.context:void 0,r=typeof e.target=="string"&&e.target.length>0?e.target:void 0,n={path:e.path,...t!==void 0&&{context:t},...r!==void 0&&{target:r}},a=x.safeParse(n);return a.success?a.data:void 0}function L(e){const t=f(e,d);let r;try{r=y(t,"utf-8")}catch{return s.debug("FjallManifest","Manifest file not readable \u2014 no Docker services extracted",{path:t}),[]}let n;try{n=JSON.parse(r)}catch{return s.debug("FjallManifest","Manifest is not valid JSON \u2014 no Docker services extracted",{path:t}),[]}if(!o(n)||!Array.isArray(n.services))return[];const a=[];for(const i of n.services){if(!o(i)||typeof i.name!="string")continue;const c=j(i.docker);c!==void 0&&a.push({name:i.name,docker:c})}return a}export{_ as createEmptyManifest,p as getManifestFilePath,L as parseDockerServicesFromManifest,$ as readConstructMap,E as readManifestFile,T as writeManifestFile};
1
+ import{readFile as l,writeFile as m,unlink as g,rename as h,mkdir as y}from"fs/promises";import{readFileSync as M}from"fs";import{dirname as F,join as f}from"path";import{logger as s}from"../logger.js";import{fileExists as S}from"../fsHelpers.js";import{getErrorMessage as d}from"../errorUtils.js";import{recordToConstructMap as b}from"../constructMap.js";import{DockerBuildSchema as w,FjallManifestSchema as A,FJALL_MANIFEST_FILENAME as u,MANIFEST_SCHEMA_VERSION as x}from"./schemas.js";function p(e){return f(e,u)}async function j(e){const t=p(e);if(!await S(t))return null;try{const n=await l(t,"utf-8"),r=JSON.parse(n),a=A.safeParse(r);return a.success||s.debug("FjallManifest","Manifest validation failed",{path:t,errors:a.error.issues.map(i=>`${i.path.join(".")}: ${i.message}`)}),a.success?a.data:null}catch(n){return s.debug("FjallManifest","Failed to read manifest file",{path:t,error:d(n)}),null}}async function _(e,t){const n=p(e),r=`${n}.${Date.now()}.tmp`;await y(F(n),{recursive:!0});try{await m(r,JSON.stringify(t,null,2),"utf-8"),await h(r,n)}catch(a){try{await g(r)}catch(i){s.debug("FjallManifest","Temp file cleanup failed (non-fatal)",{path:r,error:d(i)})}throw a}}function $(e){return{version:x,generatedAt:new Date().toISOString(),appName:e,services:[],lambdas:[],stacks:{}}}async function L(e){const t=await j(e);return t?.resourceMap?b(t.resourceMap):new Map}function o(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function k(e){return o(e)&&Object.values(e).every(t=>typeof t=="string")}function E(e){if(!o(e)||typeof e.path!="string"||e.path.length===0)return;const t=typeof e.context=="string"&&e.context.length>0?e.context:void 0,n=typeof e.target=="string"&&e.target.length>0?e.target:void 0,r=k(e.buildArgs)&&Object.keys(e.buildArgs).length>0?e.buildArgs:void 0,a={path:e.path,...t!==void 0&&{context:t},...n!==void 0&&{target:n},...r!==void 0&&{buildArgs:r}},i=w.safeParse(a);return i.success?i.data:void 0}function R(e){const t=f(e,u);let n;try{n=M(t,"utf-8")}catch{return s.debug("FjallManifest","Manifest file not readable \u2014 no Docker services extracted",{path:t}),[]}let r;try{r=JSON.parse(n)}catch{return s.debug("FjallManifest","Manifest is not valid JSON \u2014 no Docker services extracted",{path:t}),[]}if(!o(r)||!Array.isArray(r.services))return[];const a=[];for(const i of r.services){if(!o(i)||typeof i.name!="string")continue;const c=E(i.docker);c!==void 0&&a.push({name:i.name,docker:c})}return a}export{$ as createEmptyManifest,p as getManifestFilePath,R as parseDockerServicesFromManifest,L as readConstructMap,j as readManifestFile,_ as writeManifestFile};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fjall/util",
3
- "version": "2.4.8",
3
+ "version": "2.5.0",
4
4
  "description": "Common utility methods",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -117,5 +117,5 @@
117
117
  "engines": {
118
118
  "node": ">=22.0.0"
119
119
  },
120
- "gitHead": "a1e1f954e39ecbe0360ac6124dba4146aa747f36"
120
+ "gitHead": "5c8f0e004f5520c692f2ee2063c3558c2451f2cf"
121
121
  }