Skip to content
This repository was archived by the owner on May 29, 2025. It is now read-only.

Commit a5333de

Browse files
committed
Logic for new Environment.base field
1 parent edf65a6 commit a5333de

8 files changed

Lines changed: 26 additions & 43 deletions

File tree

package-lock.json

Lines changed: 11 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@
1919
"workspaces-run": "^1.0.2"
2020
},
2121
"dependencies": {
22-
"@yaakapp/api": "^0.5.0"
22+
"@yaakapp/api": "^0.5.1"
2323
}
2424
}

plugins/importer-insomnia/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ function importEnvironment(e: any, workspaceId: string): ExportResources['enviro
101101
createdAt: e.created ? new Date(e.created).toISOString().replace('Z', '') : undefined,
102102
updatedAt: e.updated ? new Date(e.updated).toISOString().replace('Z', '') : undefined,
103103
workspaceId: convertId(workspaceId),
104-
environmentId: e.parentId === workspaceId ? null : convertId(e.parentId),
104+
base: e.parentId === workspaceId,
105105
model: 'environment',
106106
name: e.name,
107107
variables: Object.entries(e.data).map(([name, value]) => ({

plugins/importer-insomnia/tests/fixtures/basic.output.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"environments": [
44
{
55
"createdAt": "2025-01-13T15:15:43.767",
6-
"environmentId": null,
6+
"base": true,
77
"id": "GENERATE_ID::env_16c0dec5b77c414ae0e419b8f10c3701300c5900",
88
"model": "environment",
99
"name": "Base Environment",
@@ -18,7 +18,7 @@
1818
},
1919
{
2020
"createdAt": "2025-01-13T15:15:58.515",
21-
"environmentId": "GENERATE_ID::env_16c0dec5b77c414ae0e419b8f10c3701300c5900",
21+
"base": false,
2222
"id": "GENERATE_ID::env_799ae3d723ef44af91b4817e5d057e6d",
2323
"model": "environment",
2424
"name": "Production",
@@ -33,7 +33,7 @@
3333
},
3434
{
3535
"createdAt": "2025-01-13T15:16:14.707",
36-
"environmentId": "GENERATE_ID::env_16c0dec5b77c414ae0e419b8f10c3701300c5900",
36+
"base": false,
3737
"id": "GENERATE_ID::env_030fbfdbb274426ebd78e2e6518f8553",
3838
"model": "environment",
3939
"name": "Staging",

plugins/importer-yaak/src/index.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export function migrateImport(contents: string) {
4646
parsed.resources.environments = parsed.resources.environments ?? [];
4747
parsed.resources.environments.push(baseEnvironment);
4848

49-
// Delete variables key from workspace
49+
// Delete variables key from the workspace
5050
delete workspace.variables;
5151

5252
// Add environmentId to relevant environments
@@ -58,6 +58,14 @@ export function migrateImport(contents: string) {
5858
}
5959
}
6060

61+
// Migrate v3 to v4
62+
for (const environment of parsed.resources.environments ?? []) {
63+
if ('environmentId' in environment) {
64+
environment.base = environment.environmentId == null;
65+
delete environment.environmentId;
66+
}
67+
}
68+
6169
return { resources: parsed.resources }; // Should already be in the correct format
6270
}
6371

plugins/importer-yaak/tests/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ describe('importer-yaak', () => {
5353
}],
5454
environments: [{
5555
id: 'e_1',
56-
environmentId: 'GENERATE_ID::base_env_w_1',
56+
base: false,
5757
workspaceId: 'w_1',
5858
name: 'Production',
5959
variables: [{ name: 'E1', value: 'E1!' }],

plugins/template-function-file/package.json

Lines changed: 0 additions & 9 deletions
This file was deleted.

plugins/template-function-file/src/index.ts

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)