fjall 0.102.0 → 2.1.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.
@@ -27,6 +27,8 @@ if (config.environment === "root") {
27
27
  organisationName: "<%= name %>",
28
28
  orgEmail: "<%= email %>"
29
29
  });
30
+
31
+ // For AWS Identity Center permission sets / group memberships in code: aiDocs/guides/identity-center-memberships.md
30
32
  <% if (security === "compliance" || security === "hardened") { -%>
31
33
 
32
34
  const rootIdCtx = organisation.node.tryGetContext("rootId");
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "<%= packageName %>",
3
- "version": "0.102.0",
3
+ "version": "2.1.1",
4
4
  "type": "module",
5
5
  "scripts": {},
6
6
  "devDependencies": {
@@ -9,7 +9,7 @@
9
9
  "typescript": "~6.0.3"
10
10
  },
11
11
  "dependencies": {
12
- "@fjall/components-infrastructure": "^0.102.0",
12
+ "@fjall/components-infrastructure": "^2.1.1",
13
13
  "aws-cdk-lib": "^2.251.0",
14
14
  "constructs": "^10.6.0"
15
15
  }
@@ -0,0 +1,19 @@
1
+ export interface StaleCdkTmpdir {
2
+ readonly path: string;
3
+ readonly sizeBytes: number;
4
+ readonly mtime: Date;
5
+ }
6
+ export interface FindOptions {
7
+ /** Base tmpdir to scan. Defaults to os.tmpdir(); overridden by tests. */
8
+ readonly tmpdirPath?: string;
9
+ /** Minimum age before a dir is reported. Defaults to 24h. */
10
+ readonly maxAgeMs?: number;
11
+ }
12
+ export interface CleanupResult {
13
+ readonly removed: number;
14
+ readonly failed: number;
15
+ readonly bytesReclaimed: number;
16
+ }
17
+ export declare function findStaleCdkTmpdirs(options?: FindOptions): Promise<StaleCdkTmpdir[]>;
18
+ export declare function removeStaleCdkTmpdirs(dirs: readonly StaleCdkTmpdir[]): Promise<CleanupResult>;
19
+ export declare function formatBytes(bytes: number): string;
@@ -0,0 +1 @@
1
+ import{readdir as m,stat as d,rm as y}from"fs/promises";import{tmpdir as g}from"os";import{join as l}from"path";import{logger as w}from"../logger/index.js";const B="cdkTmpdirCleanup";function n(i,t,e={}){w.debug(B,i,{error:t instanceof Error?t.message:String(t),...e})}const D="cdk.out",M=1440*60*1e3;async function u(i){let t=0,e;try{e=await m(i,{withFileTypes:!0})}catch(r){return n("readdir failed",r,{path:i}),0}for(const r of e){const o=l(i,r.name);if(r.isDirectory())t+=await u(o);else if(r.isFile())try{const a=await d(o);t+=a.size}catch(a){n("stat failed",a,{path:o})}}return t}async function F(i={}){const t=i.tmpdirPath??g(),e=i.maxAgeMs??M,r=Date.now()-e;let o;try{o=await m(t)}catch(s){return n("tmpdir readdir failed",s,{root:t}),[]}const a=[];for(const s of o){if(!s.startsWith(D))continue;const c=l(t,s);let f;try{f=await d(c)}catch(h){n("stat failed",h,{path:c});continue}if(!f.isDirectory()||f.mtimeMs>r)continue;const p=await u(c);a.push({path:c,sizeBytes:p,mtime:f.mtime})}return a}async function S(i){let t=0,e=0,r=0;for(const o of i)try{await y(o.path,{recursive:!0,force:!0}),t+=1,r+=o.sizeBytes}catch(a){n("rm failed",a,{path:o.path}),e+=1}return{removed:t,failed:e,bytesReclaimed:r}}function _(i){const t=["B","KB","MB","GB","TB"];let e=i,r=0;for(;e>=1024&&r<t.length-1;)e/=1024,r+=1;return`${e.toFixed(e<10?2:1)} ${t[r]}`}export{F as findStaleCdkTmpdirs,_ as formatBytes,S as removeStaleCdkTmpdirs};