mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-24 09:38:29 +02:00
Logic for new Environment.base field
This commit is contained in:
@@ -46,7 +46,7 @@ export function migrateImport(contents: string) {
|
||||
parsed.resources.environments = parsed.resources.environments ?? [];
|
||||
parsed.resources.environments.push(baseEnvironment);
|
||||
|
||||
// Delete variables key from workspace
|
||||
// Delete variables key from the workspace
|
||||
delete workspace.variables;
|
||||
|
||||
// Add environmentId to relevant environments
|
||||
@@ -58,6 +58,14 @@ export function migrateImport(contents: string) {
|
||||
}
|
||||
}
|
||||
|
||||
// Migrate v3 to v4
|
||||
for (const environment of parsed.resources.environments ?? []) {
|
||||
if ('environmentId' in environment) {
|
||||
environment.base = environment.environmentId == null;
|
||||
delete environment.environmentId;
|
||||
}
|
||||
}
|
||||
|
||||
return { resources: parsed.resources }; // Should already be in the correct format
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ describe('importer-yaak', () => {
|
||||
}],
|
||||
environments: [{
|
||||
id: 'e_1',
|
||||
environmentId: 'GENERATE_ID::base_env_w_1',
|
||||
base: false,
|
||||
workspaceId: 'w_1',
|
||||
name: 'Production',
|
||||
variables: [{ name: 'E1', value: 'E1!' }],
|
||||
|
||||
Reference in New Issue
Block a user