Skip to content

Commit ec8bf51

Browse files
committed
start xata scratch branches with scale to zero defaults configured (#2642)
Synced from monorepo@53a39361272989dcb3b4d17cdf608fe44d204198
1 parent 048a7d2 commit ec8bf51

4 files changed

Lines changed: 13 additions & 22 deletions

File tree

.sync-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
f9018a360671ac4b5d35de8035ddabd7127ca332
1+
53a39361272989dcb3b4d17cdf608fe44d204198

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@
3737
"zod": "4.4.3",
3838
"zod-config": "1.4.0",
3939
"@xata.io/ai": "0.1.0",
40-
"@xata.io/config": "0.0.1",
41-
"@xata.io/pgroll": "0.9.0",
4240
"@xata.io/lang": "0.0.1",
41+
"@xata.io/pgroll": "0.9.0",
4342
"@xata.io/pgstream": "0.2.0",
4443
"@xata.io/sql": "0.1.4",
45-
"@xata.io/api": "0.1.1",
46-
"@xata.io/utils": "0.1.0",
44+
"@xata.io/test-utils": "0.0.1",
4745
"@xata.io/tsconfig": "0.0.1",
48-
"@xata.io/test-utils": "0.0.1"
46+
"@xata.io/config": "0.0.1",
47+
"@xata.io/utils": "0.1.0",
48+
"@xata.io/api": "0.1.1"
4949
},
5050
"scripts": {
5151
"dev": "bun src/bin/cli.ts",

src/commands/scratch.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ type Flags = {
1818
};
1919

2020
const SIGNAL_CLEANUP_TIMEOUT_MS = 10 * 1000;
21+
const SCRATCH_SCALE_TO_ZERO = {
22+
enabled: true,
23+
inactivityPeriodMinutes: 10
24+
} as const;
2125

2226
type ScratchBranch = {
2327
id: string;
@@ -248,10 +252,6 @@ export async function implementation(this: LocalContext, flags: Flags, ...comman
248252
this.process.exit(1);
249253
}
250254

251-
const project = await this.api.projects.getProject({
252-
pathParams: { organizationID: organizationId, projectID: projectId }
253-
});
254-
255255
const runId = randomUUID();
256256
const branchName = `scratch-${runId}`;
257257
let scratchBranch: ScratchBranch | undefined;
@@ -329,8 +329,8 @@ export async function implementation(this: LocalContext, flags: Flags, ...comman
329329
projectId,
330330
parentBranchId,
331331
branchName,
332-
project.configuration.scaleToZero.childBranches.enabled,
333-
project.configuration.scaleToZero.childBranches.inactivityPeriodMinutes
332+
SCRATCH_SCALE_TO_ZERO.enabled,
333+
SCRATCH_SCALE_TO_ZERO.inactivityPeriodMinutes
334334
);
335335
const createdScratchBranch = await createBranchPromise;
336336
scratchBranch = createdScratchBranch;

src/commands/scratch.unit.test.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,6 @@ function buildContext() {
4040

4141
const context = {
4242
api: {
43-
projects: {
44-
getProject: mock(async () => ({
45-
configuration: {
46-
scaleToZero: {
47-
childBranches: { enabled: true, inactivityPeriodMinutes: 15 }
48-
}
49-
}
50-
}))
51-
},
5243
branches: {
5344
createBranch,
5445
describeBranch,
@@ -91,7 +82,7 @@ describe('scratch command', () => {
9182
body: {
9283
mode: 'inherit',
9384
parentID: 'source-branch-id',
94-
scaleToZero: { enabled: true, inactivityPeriodMinutes: 15 }
85+
scaleToZero: { enabled: true, inactivityPeriodMinutes: 10 }
9586
}
9687
});
9788
expect(createBranch.mock.calls[0]?.[0].body.name).toStartWith('scratch-');

0 commit comments

Comments
 (0)