Skip to content

Commit

Permalink
New reordering algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanoverna committed Aug 29, 2024
1 parent ec3014c commit 526f568
Show file tree
Hide file tree
Showing 30 changed files with 943 additions and 1,362 deletions.
10 changes: 9 additions & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,13 @@
"formatter": {
"quoteStyle": "single"
}
}
},
"overrides": [
{
"include": ["package.json"],
"formatter": {
"lineWidth": 1
}
}
]
}
52 changes: 26 additions & 26 deletions packages/cli-utils/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/cli-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"access": "public"
},
"dependencies": {
"@datocms/cma-client-node": ">=3.3.1",
"@datocms/cma-client-node": ">=3.3.9",
"@oclif/core": "^1",
"@whatwg-node/fetch": "^0.9.14",
"chalk": "^4",
Expand Down
84 changes: 63 additions & 21 deletions packages/cli/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"@oclif/plugin-warn-if-update-available": "^2.0.4",
"lodash": "^4.17.21",
"mkdirp": "^1.0.4",
"prettier": "^2.7.1",
"prettier": "^3.3.3",
"ts-node": "^10.7.0",
"typescript": "~4.5.0"
},
Expand Down
8 changes: 8 additions & 0 deletions packages/cli/src/utils/environments-diff/fetch-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export async function fetchSchema(client: CmaClient.Client): Promise<Schema> {
workflowsResponse,
itemTypeFiltersResponse,
uploadFiltersResponse,
uploadCollectionsResponse,
] = await Promise.all([
client.site.rawFind({
include: 'item_types,item_types.fields,item_types.fieldsets',
Expand All @@ -20,6 +21,7 @@ export async function fetchSchema(client: CmaClient.Client): Promise<Schema> {
client.workflows.rawList(),
client.itemTypeFilters.rawList(),
client.uploadFilters.rawList(),
client.uploadCollections.rawList(),
]);

const includedResources = siteResponse.included || [];
Expand Down Expand Up @@ -70,6 +72,12 @@ export async function fetchSchema(client: CmaClient.Client): Promise<Schema> {
schemaMenuItem,
]),
),
uploadCollectionsById: Object.fromEntries(
uploadCollectionsResponse.data.map((uploadCollection) => [
uploadCollection.id,
uploadCollection,
]),
),
pluginsById: Object.fromEntries(
pluginsResponse.data.map((plugin) => [plugin.id, plugin]),
),
Expand Down
8 changes: 7 additions & 1 deletion packages/cli/src/utils/environments-diff/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { manageItemTypeFilters } from './resources/manage-item-type-filters';
import { manageMenuItems } from './resources/manage-menu-items';
import { managePlugins } from './resources/manage-plugins';
import { manageSchemaMenuItems } from './resources/manage-schema-menu-items';
import { manageUploadCollections } from './resources/manage-upload-collections';
import { manageUploadFilters } from './resources/manage-upload-filters';
import { manageWorkflows } from './resources/manage-workflows';
import { updateFieldsAndFieldsets } from './resources/update-fields-and-fieldsets';
Expand Down Expand Up @@ -51,10 +52,15 @@ export async function diffEnvironments({
...manageItemTypeFilters(newSchema, oldSchema),
...manageMenuItems(newSchema, oldSchema),
...manageSchemaMenuItems(newSchema, oldSchema),
...manageUploadCollections(newSchema, oldSchema),
...updateRoles(roles, newEnvironmentId, oldEnvironmentId),
];

const options = await resolveConfig(migrationFilePath);

return write(commands, { ...options, format, filepath: migrationFilePath });
return write(commands, {
...options,
format,
filepath: migrationFilePath,
});
}
Loading

0 comments on commit 526f568

Please sign in to comment.