feat(app-dev): add dry-run preview to dev sync (#21251)
Split out of #21240. Stacked on #21250 (review/merge that first). `yarn twenty dev --once --dry-run` computes the migration plan and prints the diff **without applying anything** (no migration, no app-record update, no SDK generation). Also renders the diff on a normal `dev --once` sync. <img width="646" height="179" alt="image" src="https://github.com/user-attachments/assets/59f3ddcd-2a5b-4b8a-b21a-c659abe16af0" />
This commit is contained in:
@@ -73,13 +73,16 @@ export class ApiService {
|
||||
return this.applicationApi.createDevelopmentApplication(...args);
|
||||
}
|
||||
|
||||
syncApplication(manifest: Manifest): Promise<
|
||||
syncApplication(
|
||||
manifest: Manifest,
|
||||
options?: { dryRun?: boolean },
|
||||
): Promise<
|
||||
ApiResponse<{
|
||||
applicationUniversalIdentifier: string;
|
||||
actions: SyncAction[];
|
||||
}>
|
||||
> {
|
||||
return this.applicationApi.syncApplication(manifest);
|
||||
return this.applicationApi.syncApplication(manifest, options);
|
||||
}
|
||||
|
||||
uninstallApplication(universalIdentifier: string): Promise<ApiResponse> {
|
||||
|
||||
@@ -252,7 +252,10 @@ export class ApplicationApi {
|
||||
}
|
||||
}
|
||||
|
||||
async syncApplication(manifest: Manifest): Promise<
|
||||
async syncApplication(
|
||||
manifest: Manifest,
|
||||
options?: { dryRun?: boolean },
|
||||
): Promise<
|
||||
ApiResponse<{
|
||||
applicationUniversalIdentifier: string;
|
||||
actions: SyncAction[];
|
||||
@@ -260,15 +263,15 @@ export class ApplicationApi {
|
||||
> {
|
||||
try {
|
||||
const mutation = `
|
||||
mutation SyncApplication($manifest: JSON!) {
|
||||
syncApplication(manifest: $manifest) {
|
||||
mutation SyncApplication($manifest: JSON!, $dryRun: Boolean) {
|
||||
syncApplication(manifest: $manifest, dryRun: $dryRun) {
|
||||
applicationUniversalIdentifier
|
||||
actions
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
const variables = { manifest };
|
||||
const variables = { manifest, dryRun: options?.dryRun ?? false };
|
||||
|
||||
const response: AxiosResponse = await this.client.post(
|
||||
'/metadata',
|
||||
|
||||
+6
@@ -10,6 +10,12 @@ describe('formatSyncActionsSummary', () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it('reports no changes when actions are missing from the response', () => {
|
||||
expect(formatSyncActionsSummary(undefined)).toEqual([
|
||||
{ message: 'No metadata changes', status: 'info' },
|
||||
]);
|
||||
});
|
||||
|
||||
it('summarizes created, updated and deleted actions with their identifiers', () => {
|
||||
const events = formatSyncActionsSummary([
|
||||
{
|
||||
|
||||
+7
-5
@@ -24,15 +24,17 @@ const getActionLabel = (action: SyncAction): string => {
|
||||
};
|
||||
|
||||
export const formatSyncActionsSummary = (
|
||||
actions: SyncAction[],
|
||||
actions: SyncAction[] | undefined,
|
||||
): OrchestratorStateStepEvent[] => {
|
||||
if (actions.length === 0) {
|
||||
const definedActions = actions ?? [];
|
||||
|
||||
if (definedActions.length === 0) {
|
||||
return [{ message: 'No metadata changes', status: 'info' }];
|
||||
}
|
||||
|
||||
const counts = { create: 0, update: 0, delete: 0 };
|
||||
|
||||
for (const action of actions) {
|
||||
for (const action of definedActions) {
|
||||
counts[action.type] += 1;
|
||||
}
|
||||
|
||||
@@ -46,7 +48,7 @@ export const formatSyncActionsSummary = (
|
||||
{ message: `Metadata changes: ${summaryParts.join(', ')}`, status: 'info' },
|
||||
];
|
||||
|
||||
const visibleActions = actions.slice(0, MAX_DETAIL_LINES);
|
||||
const visibleActions = definedActions.slice(0, MAX_DETAIL_LINES);
|
||||
|
||||
for (const action of visibleActions) {
|
||||
events.push({
|
||||
@@ -55,7 +57,7 @@ export const formatSyncActionsSummary = (
|
||||
});
|
||||
}
|
||||
|
||||
const hiddenCount = actions.length - visibleActions.length;
|
||||
const hiddenCount = definedActions.length - visibleActions.length;
|
||||
|
||||
if (hiddenCount > 0) {
|
||||
events.push({
|
||||
|
||||
Reference in New Issue
Block a user