effortless-aws 0.1.0 → 0.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.
package/dist/cli/index.js CHANGED
@@ -70146,7 +70146,6 @@ import * as fs from "fs/promises";
70146
70146
  import * as fsSync from "fs";
70147
70147
  import * as path4 from "path";
70148
70148
  import archiver from "archiver";
70149
- import { nodeFileTrace } from "@vercel/nft";
70150
70149
  var FIXED_DATE = /* @__PURE__ */ new Date(0);
70151
70150
  var getPackageVersion = (pkgPath) => {
70152
70151
  const pkgJsonPath = path4.join(pkgPath, "package.json");
@@ -70163,7 +70162,7 @@ var computeLockfileHash = (projectDir) => Effect_exports.gen(function* () {
70163
70162
  if (prodDeps.length === 0) {
70164
70163
  return yield* Effect_exports.fail(new Error("No production dependencies"));
70165
70164
  }
70166
- const allPackages = collectTransitiveDeps(projectDir, prodDeps);
70165
+ const { packages: allPackages } = collectTransitiveDeps(projectDir, prodDeps);
70167
70166
  const packageVersions = [];
70168
70167
  for (const pkgName of Array.from(allPackages).sort()) {
70169
70168
  const pkgPath = findInPnpmStore(projectDir, pkgName) ?? getPackageRealPath(projectDir, pkgName);
@@ -70189,20 +70188,6 @@ var readProductionDependencies = (projectDir) => Effect_exports.gen(function* ()
70189
70188
  const pkg = JSON.parse(content);
70190
70189
  return Object.keys(pkg.dependencies ?? {});
70191
70190
  });
70192
- var extractPackageName = (filePath) => {
70193
- const nodeModulesIndex = filePath.lastIndexOf("node_modules");
70194
- if (nodeModulesIndex === -1) return null;
70195
- const afterNodeModules = filePath.slice(nodeModulesIndex + "node_modules/".length);
70196
- const parts2 = afterNodeModules.split("/");
70197
- const firstPart = parts2[0];
70198
- if (!firstPart) return null;
70199
- if (firstPart.startsWith("@") && parts2.length >= 2) {
70200
- const secondPart = parts2[1];
70201
- if (!secondPart) return null;
70202
- return `${firstPart}/${secondPart}`;
70203
- }
70204
- return firstPart;
70205
- };
70206
70191
  var getPackageRealPath = (projectDir, pkgName) => {
70207
70192
  const pkgPath = path4.join(projectDir, "node_modules", pkgName);
70208
70193
  if (!fsSync.existsSync(pkgPath)) return null;
@@ -70212,33 +70197,6 @@ var getPackageRealPath = (projectDir, pkgName) => {
70212
70197
  return null;
70213
70198
  }
70214
70199
  };
70215
- var findPackageEntryPoint = (depPath) => {
70216
- const pkgJsonPath = path4.join(depPath, "package.json");
70217
- if (!fsSync.existsSync(pkgJsonPath)) return null;
70218
- try {
70219
- const pkgJson = JSON.parse(fsSync.readFileSync(pkgJsonPath, "utf-8"));
70220
- const candidates = [
70221
- pkgJson.main,
70222
- pkgJson.module,
70223
- pkgJson.exports?.["."]?.require,
70224
- pkgJson.exports?.["."]?.import,
70225
- pkgJson.exports?.["."]?.default,
70226
- typeof pkgJson.exports === "string" ? pkgJson.exports : null,
70227
- "index.js",
70228
- "index.cjs",
70229
- "index.mjs"
70230
- ].filter(Boolean);
70231
- for (const candidate of candidates) {
70232
- const entryPath = path4.join(depPath, candidate);
70233
- if (fsSync.existsSync(entryPath) && fsSync.statSync(entryPath).isFile()) {
70234
- return entryPath;
70235
- }
70236
- }
70237
- return null;
70238
- } catch {
70239
- return null;
70240
- }
70241
- };
70242
70200
  var getPackageDeps = (pkgPath) => {
70243
70201
  const pkgJsonPath = path4.join(pkgPath, "package.json");
70244
70202
  if (!fsSync.existsSync(pkgJsonPath)) return [];
@@ -70273,7 +70231,7 @@ var findInPnpmStore = (projectDir, pkgName) => {
70273
70231
  }
70274
70232
  return null;
70275
70233
  };
70276
- var collectTransitiveDeps = (projectDir, rootDeps, searchPath = path4.join(projectDir, "node_modules"), visited = /* @__PURE__ */ new Set()) => {
70234
+ var collectTransitiveDeps = (projectDir, rootDeps, searchPath = path4.join(projectDir, "node_modules"), visited = /* @__PURE__ */ new Set(), warnings = []) => {
70277
70235
  const rootNodeModules = path4.join(projectDir, "node_modules");
70278
70236
  for (const dep of rootDeps) {
70279
70237
  if (visited.has(dep)) continue;
@@ -70282,7 +70240,8 @@ var collectTransitiveDeps = (projectDir, rootDeps, searchPath = path4.join(proje
70282
70240
  if (fsSync.existsSync(pkgPath)) {
70283
70241
  try {
70284
70242
  realPath2 = fsSync.realpathSync(pkgPath);
70285
- } catch {
70243
+ } catch (err) {
70244
+ warnings.push(`realpathSync failed for "${dep}" at ${pkgPath}: ${err instanceof Error ? err.message : String(err)}`);
70286
70245
  }
70287
70246
  }
70288
70247
  if (!realPath2 && searchPath !== rootNodeModules) {
@@ -70290,52 +70249,50 @@ var collectTransitiveDeps = (projectDir, rootDeps, searchPath = path4.join(proje
70290
70249
  if (fsSync.existsSync(pkgPath)) {
70291
70250
  try {
70292
70251
  realPath2 = fsSync.realpathSync(pkgPath);
70293
- } catch {
70252
+ } catch (err) {
70253
+ warnings.push(`realpathSync failed for "${dep}" at ${pkgPath}: ${err instanceof Error ? err.message : String(err)}`);
70294
70254
  }
70295
70255
  }
70296
70256
  }
70297
70257
  if (!realPath2) {
70298
70258
  realPath2 = findInPnpmStore(projectDir, dep);
70299
70259
  }
70300
- if (!realPath2) continue;
70260
+ if (!realPath2) {
70261
+ warnings.push(`Package "${dep}" not found (searched: ${searchPath}, root node_modules, pnpm store) \u2014 entire subtree skipped`);
70262
+ continue;
70263
+ }
70301
70264
  visited.add(dep);
70302
70265
  const pkgDeps = getPackageDeps(realPath2);
70303
70266
  if (pkgDeps.length > 0) {
70304
70267
  const isScoped = dep.startsWith("@");
70305
70268
  const pkgNodeModules = isScoped ? path4.dirname(path4.dirname(realPath2)) : path4.dirname(realPath2);
70306
- collectTransitiveDeps(projectDir, pkgDeps, pkgNodeModules, visited);
70269
+ collectTransitiveDeps(projectDir, pkgDeps, pkgNodeModules, visited, warnings);
70307
70270
  }
70308
70271
  }
70309
- return visited;
70272
+ return { packages: visited, warnings };
70310
70273
  };
70311
- var collectLayerPackages = async (projectDir, dependencies) => {
70312
- if (dependencies.length === 0) return [];
70313
- const packages = collectTransitiveDeps(projectDir, dependencies);
70314
- const entryPoints = [];
70315
- for (const dep of dependencies) {
70316
- const pkgPath = path4.join(projectDir, "node_modules", dep);
70317
- if (fsSync.existsSync(pkgPath)) {
70318
- const entryPoint = findPackageEntryPoint(pkgPath);
70319
- if (entryPoint) {
70320
- entryPoints.push(entryPoint);
70321
- }
70322
- }
70323
- }
70324
- if (entryPoints.length > 0) {
70325
- try {
70326
- const { fileList } = await nodeFileTrace(entryPoints, {
70327
- base: projectDir
70328
- });
70329
- for (const file6 of fileList) {
70330
- const pkgName = extractPackageName(path4.join(projectDir, file6));
70331
- if (pkgName) {
70332
- packages.add(pkgName);
70274
+ var isAwsRuntime = (pkg) => pkg.startsWith("@aws-sdk/") || pkg.startsWith("@smithy/");
70275
+ var collectLayerPackages = (projectDir, dependencies) => {
70276
+ if (dependencies.length === 0) return { packages: [], warnings: [] };
70277
+ const { packages, warnings } = collectTransitiveDeps(projectDir, dependencies);
70278
+ let changed = true;
70279
+ while (changed) {
70280
+ changed = false;
70281
+ for (const pkg of [...packages]) {
70282
+ if (isAwsRuntime(pkg)) continue;
70283
+ const pkgPath = findPackagePath(projectDir, pkg);
70284
+ if (!pkgPath) continue;
70285
+ const pkgDeps = getPackageDeps(pkgPath);
70286
+ for (const dep of pkgDeps) {
70287
+ if (!packages.has(dep) && !isAwsRuntime(dep)) {
70288
+ packages.add(dep);
70289
+ warnings.push(`Auto-added missing transitive dep: "${dep}" (required by "${pkg}")`);
70290
+ changed = true;
70333
70291
  }
70334
70292
  }
70335
- } catch {
70336
70293
  }
70337
70294
  }
70338
- return Array.from(packages);
70295
+ return { packages: Array.from(packages), warnings };
70339
70296
  };
70340
70297
  var findPackagePath = (projectDir, pkgName) => {
70341
70298
  const rootPath = getPackageRealPath(projectDir, pkgName);
@@ -70414,7 +70371,10 @@ var ensureLayer = (config2) => Effect_exports.gen(function* () {
70414
70371
  yield* Effect_exports.logInfo(`Layer ${layerName} with hash ${hash2} already exists (version ${existing.version})`);
70415
70372
  return existing;
70416
70373
  }
70417
- const allPackages = yield* Effect_exports.promise(() => collectLayerPackages(config2.projectDir, dependencies));
70374
+ const { packages: allPackages, warnings: layerWarnings } = yield* Effect_exports.sync(() => collectLayerPackages(config2.projectDir, dependencies));
70375
+ for (const warning of layerWarnings) {
70376
+ yield* Effect_exports.logWarning(`[layer] ${warning}`);
70377
+ }
70418
70378
  yield* Effect_exports.logInfo(`Creating layer ${layerName} with ${allPackages.length} packages (hash: ${hash2})`);
70419
70379
  yield* Effect_exports.logDebug(`Layer packages: ${allPackages.join(", ")}`);
70420
70380
  const { buffer: layerZip, includedPackages, skippedPackages } = yield* createLayerZip(config2.projectDir, allPackages);
@@ -70720,7 +70680,10 @@ var ensureLayerAndExternal = (input) => Effect_exports.gen(function* () {
70720
70680
  projectDir: input.projectDir
70721
70681
  });
70722
70682
  const prodDeps = layerResult ? yield* readProductionDependencies(input.projectDir) : [];
70723
- const external = prodDeps.length > 0 ? yield* Effect_exports.promise(() => collectLayerPackages(input.projectDir, prodDeps)) : [];
70683
+ const { packages: external, warnings: layerWarnings } = prodDeps.length > 0 ? yield* Effect_exports.sync(() => collectLayerPackages(input.projectDir, prodDeps)) : { packages: [], warnings: [] };
70684
+ for (const warning of layerWarnings) {
70685
+ yield* Effect_exports.logWarning(`[layer] ${warning}`);
70686
+ }
70724
70687
  return {
70725
70688
  layerArn: layerResult?.layerVersionArn,
70726
70689
  external
@@ -71056,7 +71019,10 @@ var prepareLayer = (input) => Effect_exports.gen(function* () {
71056
71019
  )
71057
71020
  );
71058
71021
  const prodDeps = layerResult ? yield* readProductionDependencies(input.projectDir) : [];
71059
- const external = prodDeps.length > 0 ? yield* Effect_exports.promise(() => collectLayerPackages(input.projectDir, prodDeps)) : [];
71022
+ const { packages: external, warnings: layerWarnings } = prodDeps.length > 0 ? yield* Effect_exports.sync(() => collectLayerPackages(input.projectDir, prodDeps)) : { packages: [], warnings: [] };
71023
+ for (const warning of layerWarnings) {
71024
+ yield* Effect_exports.logWarning(`[layer] ${warning}`);
71025
+ }
71060
71026
  yield* Effect_exports.logDebug(`Layer result: ${layerResult ? "exists" : "null"}, external packages: ${external.length}`);
71061
71027
  if (external.length > 0) {
71062
71028
  yield* Effect_exports.logInfo(`Bundling with ${external.length} external packages from layer`);
@@ -71539,7 +71505,10 @@ var buildCommand = Command_exports.make(
71539
71505
  const prodDeps = yield* readProductionDependencies(projectDir).pipe(
71540
71506
  Effect_exports.catchAll(() => Effect_exports.succeed([]))
71541
71507
  );
71542
- const external = prodDeps.length > 0 ? yield* Effect_exports.promise(() => collectLayerPackages(projectDir, prodDeps)) : [];
71508
+ const { packages: external, warnings: layerWarnings } = prodDeps.length > 0 ? yield* Effect_exports.sync(() => collectLayerPackages(projectDir, prodDeps)) : { packages: [], warnings: [] };
71509
+ for (const warning of layerWarnings) {
71510
+ yield* Effect_exports.logWarning(`[layer] ${warning}`);
71511
+ }
71543
71512
  if (external.length > 0) {
71544
71513
  yield* Console_exports.log(`Using ${external.length} external packages (from layer)
71545
71514
  `);
@@ -72055,7 +72024,14 @@ Lockfile hash: ${hash2}`);
72055
72024
  } else {
72056
72025
  yield* Console_exports.log("\nNo lockfile found (package-lock.json, pnpm-lock.yaml, or yarn.lock)");
72057
72026
  }
72058
- const allPackages = yield* Effect_exports.promise(() => collectLayerPackages(projectDir, prodDeps));
72027
+ const { packages: allPackages, warnings: layerWarnings } = yield* Effect_exports.sync(() => collectLayerPackages(projectDir, prodDeps));
72028
+ if (layerWarnings.length > 0) {
72029
+ yield* Console_exports.log(`
72030
+ Warnings (${layerWarnings.length}):`);
72031
+ for (const w of layerWarnings) {
72032
+ yield* Console_exports.log(` \u26A0 ${w}`);
72033
+ }
72034
+ }
72059
72035
  yield* Console_exports.log(`
72060
72036
  Total packages for layer (${allPackages.length}):`);
72061
72037
  if (verbose) {
@@ -72184,7 +72160,14 @@ var layersBuildCommand = Command_exports.make(
72184
72160
  );
72185
72161
  yield* Console_exports.log(`
72186
72162
  Lockfile hash: ${hash2}`);
72187
- const allPackages = yield* Effect_exports.promise(() => collectLayerPackages(projectDir, prodDeps));
72163
+ const { packages: allPackages, warnings: layerWarnings } = yield* Effect_exports.sync(() => collectLayerPackages(projectDir, prodDeps));
72164
+ if (layerWarnings.length > 0) {
72165
+ yield* Console_exports.log(`
72166
+ Warnings (${layerWarnings.length}):`);
72167
+ for (const w of layerWarnings) {
72168
+ yield* Console_exports.log(` \u26A0 ${w}`);
72169
+ }
72170
+ }
72188
72171
  yield* Console_exports.log(`
72189
72172
  Collected ${allPackages.length} packages for layer`);
72190
72173
  if (verbose) {