8000 fix(core): stage scope not being adopted (#469) · sam-goodwin/alchemy@b949aad · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Commit b949aad

Browse files
authored
fix(core): stage scope not being adopted (#469)< 8000 /div>
1 parent b6adb96 commit b949aad

File tree

5 files changed

+23
-10
lines changed

5 files changed

+23
-10
lines changed

alchemy/src/apply.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,8 @@ async function _apply<Out extends Resource>(
238238
}
239239
if (!quiet) {
240240
logger.task(resource[ResourceFQN], {
241-
prefix: phase === "create" ? "created" : "updated",
241+
prefix:
242+
phase === "create" ? "created" : isReplaced ? "replaced" : "updated",
242243
prefixColor: "greenBright",
243244
resource: formatFQN(resource[ResourceFQN]),
244245
message: `${phase === "create" ? "Created" : isReplaced ? "Replaced" : "Updated"} Resource`,

alchemy/src/destroy.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,12 @@ export async function destroy<Type extends string>(
9595
try {
9696
if (!quiet) {
9797
logger.task(instance[ResourceFQN], {
98-
prefix: "deleting",
99-
prefixColor: "redBright",
98+
prefix: options?.replace ? "cleanup" : "deleting",
99+
prefixColor: options?.replace ? "magenta" : "redBright",
100100
resource: formatFQN(instance[ResourceFQN]),
101-
message: "Deleting Resource...",
101+
message: options?.replace
102+
? "Cleaning Up Old Resource..."
103+
: "Deleting Resource...",
102104
});
103105
}
104106

@@ -170,10 +172,12 @@ export async function destroy<Type extends string>(
170172

171173
if (!quiet) {
172174
logger.task(instance[ResourceFQN], {
173-
prefix: "deleted",
175+
prefix: options?.replace ? "cleaned" : "deleted",
174176
prefixColor: "greenBright",
175177
resource: formatFQN(instance[ResourceFQN]),
176-
message: "Deleted Resource",
178+
message: options?.replace
179+
? "Old Resource Cleanup Complete"
180+
: "Deleted Resource",
177181
status: "success",
178182
});
179183
}

alchemy/src/scope.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,15 @@ export class Scope {
338338

339339
const orphans = await Promise.all(
340340
orphanIds.map(async (id) => (await this.state.get(id))!.output),
341+
).then((orphans) =>
342+
orphans.filter(
343+
(orphan) =>
344+
//we never want to mark the stage scope as an orphan
345+
!(
346+
orphan[ResourceKind] === "alchemy::Scope" &&
347+
orphan[ResourceFQN] === this.root.fqn(this.stage)
348+
),
349+
),
341350
);
342351
await destroyAll(orphans, {
343352
quiet: this.quiet,

alchemy/test/cloudflare/route.test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -617,9 +617,7 @@ describe("Route Resource", () => {
617617
],
618618
});
619619

620-
await expect(workerPromise).rejects.toThrow(
621-
/Duplicate route patterns found/,
622-
);
620+
await expect(workerPromise).rejects.toThrow(/Duplicate Route found: /);
623621
} finally {
624622
await destroy(scope);
625623
// Worker should not exist since creation failed

alchemy/test/cloudflare/zone.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ describe("Zone Resource", () => {
172172
expect(zone.name).toEqual(lookupTestDomain);
173173

174174
// Use getZoneByDomain to look up the zone we just created
175-
const foundZone = await getZoneByDomain(lookupTestDomain);
175+
const foundZone = await getZoneByDomain(api, lookupTestDomain);
176176

177177
// Verify the lookup returned the correct zone
178178
expect(foundZone).toBeTruthy();
@@ -186,6 +186,7 @@ describe("Zone Resource", () => {
186186

187187
// Test lookup of non-existent domain
188188
const nonExistentZone = await getZoneByDomain(
189+
api,
189190
`${BRANCH_PREFIX}-non-existent.dev`,
190191
);
191192
expect(nonExistentZone).toBeNull();

0 commit comments

Comments
 (0)
0