@go-to-k/cdkd 0.28.1 → 0.28.2

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/README.md CHANGED
@@ -457,8 +457,10 @@ cdkd state show MyStack --json # raw {state, lock} JSON
457
457
 
458
458
  # Orphan one or more RESOURCES from cdkd's state (does NOT delete AWS resources).
459
459
  # Per-resource, mirrors aws-cdk-cli's `cdk orphan --unstable=orphan`.
460
- # Synth-driven — needs --app / cdk.json. Construct paths look like the CDK
461
- # `aws:cdk:path` tag (`<StackName>/<Path/To/Resource>`).
460
+ # Synth-driven — needs --app / cdk.json. Construct paths use CDK's L2-style form
461
+ # (`<StackName>/<Path/To/Construct>`); the synthesized `/Resource` suffix is
462
+ # matched implicitly. Passing an L2 wrapper that contains multiple CFn resources
463
+ # orphans every child under it (matches upstream's prefix-match semantics).
462
464
  cdkd orphan MyStack/MyTable # confirmation prompt (y/N)
463
465
  cdkd orphan MyStack/MyTable --yes
464
466
  cdkd orphan MyStack/MyTable MyStack/MyBucket # multiple resources, same stack
package/dist/cli.js CHANGED
@@ -33391,12 +33391,25 @@ function readCdkPath(resource) {
33391
33391
  function buildCdkPathIndex(template) {
33392
33392
  const index = /* @__PURE__ */ new Map();
33393
33393
  for (const [logicalId, resource] of Object.entries(template.Resources)) {
33394
+ if (resource.Type === "AWS::CDK::Metadata")
33395
+ continue;
33394
33396
  const path = readCdkPath(resource);
33395
33397
  if (path)
33396
33398
  index.set(path, logicalId);
33397
33399
  }
33398
33400
  return index;
33399
33401
  }
33402
+ function resolveCdkPathToLogicalIds(input, index) {
33403
+ const seen = /* @__PURE__ */ new Map();
33404
+ const prefix = `${input}/`;
33405
+ for (const [path, logicalId] of index) {
33406
+ if (path === input || path.startsWith(prefix)) {
33407
+ if (!seen.has(logicalId))
33408
+ seen.set(logicalId, path);
33409
+ }
33410
+ }
33411
+ return [...seen.entries()].map(([logicalId, cdkPath]) => ({ logicalId, cdkPath }));
33412
+ }
33400
33413
 
33401
33414
  // src/analyzer/orphan-rewriter.ts
33402
33415
  var AttributeFetcher = class {
@@ -33952,19 +33965,20 @@ function resolveConstructPaths(paths, stacks) {
33952
33965
  `All construct paths must reference the same stack. Got '${stack.stackName}' and '${candidate.stackName}'. Run 'cdkd orphan' once per stack.`
33953
33966
  );
33954
33967
  }
33955
- const cdkPath = p;
33956
33968
  const index = buildCdkPathIndex(candidate.template);
33957
- const logicalId = index.get(cdkPath);
33958
- if (!logicalId) {
33969
+ const matches = resolveCdkPathToLogicalIds(p, index);
33970
+ if (matches.length === 0) {
33959
33971
  const available = [...index.keys()].sort().join("\n ");
33960
33972
  throw new Error(
33961
- `Construct path '${cdkPath}' not found in template for stack '${candidate.stackName}'.
33973
+ `Construct path '${p}' not found in template for stack '${candidate.stackName}'.
33962
33974
  Available paths:
33963
33975
  ${available}`
33964
33976
  );
33965
33977
  }
33966
- if (!logicalIds.includes(logicalId)) {
33967
- logicalIds.push(logicalId);
33978
+ for (const { logicalId } of matches) {
33979
+ if (!logicalIds.includes(logicalId)) {
33980
+ logicalIds.push(logicalId);
33981
+ }
33968
33982
  }
33969
33983
  }
33970
33984
  if (!stack) {
@@ -35671,7 +35685,7 @@ function reorderArgs(argv) {
35671
35685
  }
35672
35686
  async function main() {
35673
35687
  const program = new Command13();
35674
- program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.28.1");
35688
+ program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.28.2");
35675
35689
  program.addCommand(createBootstrapCommand());
35676
35690
  program.addCommand(createSynthCommand());
35677
35691
  program.addCommand(createListCommand());