You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

18 line
912 B

  1. import fs from 'node:fs';
  2. import path from 'node:path';
  3. import { call, login, fixture, work } from './scene-editor-closure-live.mjs';
  4. const session = await login('root');
  5. function diff(a,b,p='') {
  6. if(JSON.stringify(a)===JSON.stringify(b))return [];
  7. if(a && b && typeof a==='object'&&typeof b==='object')return [...new Set([...Object.keys(a),...Object.keys(b)])].flatMap(k=>diff(a[k],b[k],`${p}/${k}`));
  8. return [{path:p,before:a,after:b}];
  9. }
  10. try {
  11. for(const [key,original] of Object.entries(fixture().originals)) {
  12. const before=JSON.parse(fs.readFileSync(path.join(work,`original-${key}.json`),'utf8'));
  13. const current=await call(`tran/v1/content/projects/${original.id}`,session.accessToken);
  14. const differences=diff(before,current.data);
  15. console.log(JSON.stringify({key,id:original.id,differences}));
  16. }
  17. } finally {await call('auth/v1/auth/logout',session.accessToken,{}).catch(()=>{});}