@ts-cloud/core 0.2.6 → 0.2.7
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/index.js +51 -51
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -24246,37 +24246,37 @@ function suggestQuotaIncrease(quotas) {
|
|
|
24246
24246
|
}
|
|
24247
24247
|
// src/utils/cache.ts
|
|
24248
24248
|
import { createHash as createHash2 } from "node:crypto";
|
|
24249
|
-
import
|
|
24250
|
-
import
|
|
24249
|
+
import { existsSync as existsSync4, mkdirSync, readFileSync as readFileSync3, readdirSync as readdirSync3, unlinkSync, writeFileSync as writeFileSync2 } from "node:fs";
|
|
24250
|
+
import { join as join4 } from "node:path";
|
|
24251
24251
|
class FileCache {
|
|
24252
24252
|
cacheDir;
|
|
24253
24253
|
ttl;
|
|
24254
24254
|
constructor(cacheDir, options = {}) {
|
|
24255
24255
|
this.cacheDir = cacheDir;
|
|
24256
24256
|
this.ttl = options.ttl || 24 * 60 * 60 * 1000;
|
|
24257
|
-
if (!
|
|
24258
|
-
|
|
24257
|
+
if (!existsSync4(cacheDir)) {
|
|
24258
|
+
mkdirSync(cacheDir, { recursive: true });
|
|
24259
24259
|
}
|
|
24260
24260
|
}
|
|
24261
24261
|
getCachePath(key) {
|
|
24262
24262
|
const hash2 = createHash2("sha256").update(key).digest("hex");
|
|
24263
|
-
return
|
|
24263
|
+
return join4(this.cacheDir, `${hash2}.json`);
|
|
24264
24264
|
}
|
|
24265
24265
|
get(key) {
|
|
24266
24266
|
const cachePath = this.getCachePath(key);
|
|
24267
|
-
if (!
|
|
24267
|
+
if (!existsSync4(cachePath)) {
|
|
24268
24268
|
return;
|
|
24269
24269
|
}
|
|
24270
24270
|
try {
|
|
24271
|
-
const data =
|
|
24271
|
+
const data = readFileSync3(cachePath, "utf-8");
|
|
24272
24272
|
const entry = JSON.parse(data);
|
|
24273
24273
|
if (Date.now() - entry.timestamp > this.ttl) {
|
|
24274
|
-
|
|
24274
|
+
unlinkSync(cachePath);
|
|
24275
24275
|
return;
|
|
24276
24276
|
}
|
|
24277
24277
|
return entry.value;
|
|
24278
24278
|
} catch {
|
|
24279
|
-
|
|
24279
|
+
unlinkSync(cachePath);
|
|
24280
24280
|
return;
|
|
24281
24281
|
}
|
|
24282
24282
|
}
|
|
@@ -24287,30 +24287,30 @@ class FileCache {
|
|
|
24287
24287
|
timestamp: Date.now(),
|
|
24288
24288
|
hash: hash2
|
|
24289
24289
|
};
|
|
24290
|
-
|
|
24290
|
+
writeFileSync2(cachePath, JSON.stringify(entry), "utf-8");
|
|
24291
24291
|
}
|
|
24292
24292
|
has(key) {
|
|
24293
24293
|
return this.get(key) !== undefined;
|
|
24294
24294
|
}
|
|
24295
24295
|
clear() {
|
|
24296
|
-
const files =
|
|
24296
|
+
const files = readdirSync3(this.cacheDir);
|
|
24297
24297
|
for (const file of files) {
|
|
24298
|
-
|
|
24298
|
+
unlinkSync(join4(this.cacheDir, file));
|
|
24299
24299
|
}
|
|
24300
24300
|
}
|
|
24301
24301
|
prune() {
|
|
24302
|
-
const files =
|
|
24302
|
+
const files = readdirSync3(this.cacheDir);
|
|
24303
24303
|
const now = Date.now();
|
|
24304
24304
|
for (const file of files) {
|
|
24305
|
-
const filePath =
|
|
24305
|
+
const filePath = join4(this.cacheDir, file);
|
|
24306
24306
|
try {
|
|
24307
|
-
const data =
|
|
24307
|
+
const data = readFileSync3(filePath, "utf-8");
|
|
24308
24308
|
const entry = JSON.parse(data);
|
|
24309
24309
|
if (now - entry.timestamp > this.ttl) {
|
|
24310
|
-
|
|
24310
|
+
unlinkSync(filePath);
|
|
24311
24311
|
}
|
|
24312
24312
|
} catch {
|
|
24313
|
-
|
|
24313
|
+
unlinkSync(filePath);
|
|
24314
24314
|
}
|
|
24315
24315
|
}
|
|
24316
24316
|
}
|
|
@@ -24352,14 +24352,14 @@ class TemplateCache {
|
|
|
24352
24352
|
var templateCache = new TemplateCache;
|
|
24353
24353
|
// src/utils/hash.ts
|
|
24354
24354
|
import { createHash as createHash3 } from "node:crypto";
|
|
24355
|
-
import
|
|
24356
|
-
import
|
|
24355
|
+
import { createReadStream, readdirSync as readdirSync4, statSync as statSync2 } from "node:fs";
|
|
24356
|
+
import { join as join5, relative } from "node:path";
|
|
24357
24357
|
async function hashFile(filePath, options = {}) {
|
|
24358
24358
|
const algorithm = options.algorithm || "sha256";
|
|
24359
24359
|
const chunkSize = options.chunkSize || 64 * 1024;
|
|
24360
24360
|
return new Promise((resolve, reject) => {
|
|
24361
24361
|
const hash2 = createHash3(algorithm);
|
|
24362
|
-
const stream =
|
|
24362
|
+
const stream = createReadStream(filePath, { highWaterMark: chunkSize });
|
|
24363
24363
|
stream.on("data", (chunk) => hash2.update(chunk));
|
|
24364
24364
|
stream.on("end", () => resolve(hash2.digest("hex")));
|
|
24365
24365
|
stream.on("error", reject);
|
|
@@ -24381,17 +24381,17 @@ async function hashDirectory(dirPath, options = {}) {
|
|
|
24381
24381
|
];
|
|
24382
24382
|
const files = [];
|
|
24383
24383
|
async function walk(dir) {
|
|
24384
|
-
const entries =
|
|
24384
|
+
const entries = readdirSync4(dir, { withFileTypes: true });
|
|
24385
24385
|
for (const entry of entries) {
|
|
24386
|
-
const fullPath =
|
|
24387
|
-
const relativePath =
|
|
24386
|
+
const fullPath = join5(dir, entry.name);
|
|
24387
|
+
const relativePath = relative(dirPath, fullPath);
|
|
24388
24388
|
if (ignorePatterns.some((pattern) => relativePath.includes(pattern))) {
|
|
24389
24389
|
continue;
|
|
24390
24390
|
}
|
|
24391
24391
|
if (entry.isDirectory()) {
|
|
24392
24392
|
await walk(fullPath);
|
|
24393
24393
|
} else if (entry.isFile()) {
|
|
24394
|
-
const stats =
|
|
24394
|
+
const stats = statSync2(fullPath);
|
|
24395
24395
|
const hash2 = await hashFile(fullPath, options);
|
|
24396
24396
|
files.push({
|
|
24397
24397
|
path: relativePath,
|
|
@@ -24412,7 +24412,7 @@ function hashManifest(fileHashes) {
|
|
|
24412
24412
|
return hashString(content);
|
|
24413
24413
|
}
|
|
24414
24414
|
function quickHash(filePath) {
|
|
24415
|
-
const stats =
|
|
24415
|
+
const stats = statSync2(filePath);
|
|
24416
24416
|
return hashString(`${filePath}:${stats.size}:${stats.mtimeMs}`);
|
|
24417
24417
|
}
|
|
24418
24418
|
function findChangedFiles(oldHashes, newHashes) {
|
|
@@ -24421,16 +24421,16 @@ function findChangedFiles(oldHashes, newHashes) {
|
|
|
24421
24421
|
const added = [];
|
|
24422
24422
|
const modified = [];
|
|
24423
24423
|
const deleted = [];
|
|
24424
|
-
for (const [
|
|
24425
|
-
const oldFile = oldMap.get(
|
|
24424
|
+
for (const [path, newFile] of newMap) {
|
|
24425
|
+
const oldFile = oldMap.get(path);
|
|
24426
24426
|
if (!oldFile) {
|
|
24427
24427
|
added.push(newFile);
|
|
24428
24428
|
} else if (oldFile.hash !== newFile.hash) {
|
|
24429
24429
|
modified.push(newFile);
|
|
24430
24430
|
}
|
|
24431
24431
|
}
|
|
24432
|
-
for (const [
|
|
24433
|
-
if (!newMap.has(
|
|
24432
|
+
for (const [path, oldFile] of oldMap) {
|
|
24433
|
+
if (!newMap.has(path)) {
|
|
24434
24434
|
deleted.push(oldFile);
|
|
24435
24435
|
}
|
|
24436
24436
|
}
|
|
@@ -24443,7 +24443,7 @@ class HashCache {
|
|
|
24443
24443
|
this.cache = new Map;
|
|
24444
24444
|
}
|
|
24445
24445
|
get(filePath) {
|
|
24446
|
-
const stats =
|
|
24446
|
+
const stats = statSync2(filePath);
|
|
24447
24447
|
const cached = this.cache.get(filePath);
|
|
24448
24448
|
if (cached && cached.mtime === stats.mtimeMs && cached.size === stats.size) {
|
|
24449
24449
|
return cached.hash;
|
|
@@ -24451,7 +24451,7 @@ class HashCache {
|
|
|
24451
24451
|
return;
|
|
24452
24452
|
}
|
|
24453
24453
|
set(filePath, hash2) {
|
|
24454
|
-
const stats =
|
|
24454
|
+
const stats = statSync2(filePath);
|
|
24455
24455
|
this.cache.set(filePath, {
|
|
24456
24456
|
hash: hash2,
|
|
24457
24457
|
mtime: stats.mtimeMs,
|
|
@@ -27125,8 +27125,8 @@ class REPL {
|
|
|
27125
27125
|
if (!this.options.historyFile)
|
|
27126
27126
|
return;
|
|
27127
27127
|
try {
|
|
27128
|
-
const
|
|
27129
|
-
const data = await
|
|
27128
|
+
const fs = await import("node:fs/promises");
|
|
27129
|
+
const data = await fs.readFile(this.options.historyFile, "utf-8");
|
|
27130
27130
|
this.history.commands = data.split(`
|
|
27131
27131
|
`).filter((line) => line.trim());
|
|
27132
27132
|
this.historyIndex = this.history.commands.length;
|
|
@@ -27136,8 +27136,8 @@ class REPL {
|
|
|
27136
27136
|
if (!this.options.historyFile)
|
|
27137
27137
|
return;
|
|
27138
27138
|
try {
|
|
27139
|
-
const
|
|
27140
|
-
await
|
|
27139
|
+
const fs = await import("node:fs/promises");
|
|
27140
|
+
await fs.writeFile(this.options.historyFile, this.history.commands.join(`
|
|
27141
27141
|
`));
|
|
27142
27142
|
} catch (error) {
|
|
27143
27143
|
console.error(`Failed to save history: ${error}`);
|
|
@@ -27173,8 +27173,8 @@ class REPLContext {
|
|
|
27173
27173
|
clear() {
|
|
27174
27174
|
this.variables.clear();
|
|
27175
27175
|
}
|
|
27176
|
-
setWorkingDirectory(
|
|
27177
|
-
this.workingDirectory =
|
|
27176
|
+
setWorkingDirectory(path) {
|
|
27177
|
+
this.workingDirectory = path;
|
|
27178
27178
|
}
|
|
27179
27179
|
getWorkingDirectory() {
|
|
27180
27180
|
return this.workingDirectory;
|
|
@@ -27291,9 +27291,9 @@ class CommandHistory {
|
|
|
27291
27291
|
if (!this.persistFile)
|
|
27292
27292
|
return;
|
|
27293
27293
|
try {
|
|
27294
|
-
const
|
|
27294
|
+
const fs = await import("node:fs/promises");
|
|
27295
27295
|
const data = JSON.stringify(this.entries, null, 2);
|
|
27296
|
-
await
|
|
27296
|
+
await fs.writeFile(this.persistFile, data, "utf-8");
|
|
27297
27297
|
} catch (error) {
|
|
27298
27298
|
throw new Error(`Failed to save history: ${error}`);
|
|
27299
27299
|
}
|
|
@@ -27302,8 +27302,8 @@ class CommandHistory {
|
|
|
27302
27302
|
if (!this.persistFile)
|
|
27303
27303
|
return;
|
|
27304
27304
|
try {
|
|
27305
|
-
const
|
|
27306
|
-
const data = await
|
|
27305
|
+
const fs = await import("node:fs/promises");
|
|
27306
|
+
const data = await fs.readFile(this.persistFile, "utf-8");
|
|
27307
27307
|
const parsed = JSON.parse(data);
|
|
27308
27308
|
this.entries = parsed.map((entry) => ({
|
|
27309
27309
|
...entry,
|
|
@@ -30721,14 +30721,14 @@ class CloudTrailManager {
|
|
|
30721
30721
|
if (trail.advancedEventSelectors) {
|
|
30722
30722
|
cf.Properties.AdvancedEventSelectors = trail.advancedEventSelectors.map((selector) => ({
|
|
30723
30723
|
Name: selector.name,
|
|
30724
|
-
FieldSelectors: selector.fieldSelectors.map((
|
|
30725
|
-
Field:
|
|
30726
|
-
...
|
|
30727
|
-
...
|
|
30728
|
-
...
|
|
30729
|
-
...
|
|
30730
|
-
...
|
|
30731
|
-
...
|
|
30724
|
+
FieldSelectors: selector.fieldSelectors.map((fs) => ({
|
|
30725
|
+
Field: fs.field,
|
|
30726
|
+
...fs.equals && { Equals: fs.equals },
|
|
30727
|
+
...fs.startsWith && { StartsWith: fs.startsWith },
|
|
30728
|
+
...fs.endsWith && { EndsWith: fs.endsWith },
|
|
30729
|
+
...fs.notEquals && { NotEquals: fs.notEquals },
|
|
30730
|
+
...fs.notStartsWith && { NotStartsWith: fs.notStartsWith },
|
|
30731
|
+
...fs.notEndsWith && { NotEndsWith: fs.notEndsWith }
|
|
30732
30732
|
}))
|
|
30733
30733
|
}));
|
|
30734
30734
|
}
|
|
@@ -40243,8 +40243,8 @@ The {{appName}} Team`,
|
|
|
40243
40243
|
});
|
|
40244
40244
|
return result;
|
|
40245
40245
|
}
|
|
40246
|
-
static getNestedValue(obj,
|
|
40247
|
-
return
|
|
40246
|
+
static getNestedValue(obj, path) {
|
|
40247
|
+
return path.split(".").reduce((current, key) => current?.[key], obj);
|
|
40248
40248
|
}
|
|
40249
40249
|
static extractVariables(template) {
|
|
40250
40250
|
const variables = new Set;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ts-cloud/core",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Core CloudFormation generation library for ts-cloud",
|
|
6
6
|
"author": "Chris Breuer <chris@stacksjs.com>",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"typecheck": "tsc --noEmit"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@ts-cloud/aws-types": "0.2.
|
|
34
|
+
"@ts-cloud/aws-types": "0.2.7"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"typescript": "^5.9.3"
|