3 lines
1.6 KiB
JavaScript
3 lines
1.6 KiB
JavaScript
import fs from 'node:fs';import assert from 'node:assert/strict';import {createRequire} from 'node:module';import {pathToFileURL} from 'node:url';import {transformWithOxc} from 'vite';
|
|
const require=createRequire(import.meta.url);let source=fs.readFileSync('resources/js/WorkspaceNavigation.jsx','utf8').replace("from 'react'",'from '+JSON.stringify(pathToFileURL(require.resolve('react')).href));for(const name of ['billing-menu.js','workshop-menu.js','stock-menu.js','accounting-menu.js'])source=source.replace("from './"+name+"'",'from '+JSON.stringify(pathToFileURL(process.cwd()+'/resources/js/'+name).href));const compiled=await transformWithOxc(source,'WorkspaceNavigation.jsx',{jsx:{runtime:'classic'}}),{navigationGroups}=await import('data:text/javascript;base64,'+Buffer.from(compiled.code).toString('base64'));const has=groups=>groups.some(g=>g.id==='stock'&&g.items.some(i=>i.id==='stock_catalogue'));const checks=[];assert(!has(navigationGroups(()=>true,2)));checks.push('disabled feature no catalogue entry');assert(has(navigationGroups(()=>true,2,{stockCatalogue:true})));checks.push('enabled approved feature explicit stock entry');assert(!has(navigationGroups(p=>p!=='stock.view',2,{stockCatalogue:true})));checks.push('no stock view no catalogue function');const root=JSON.parse(fs.readFileSync('C:/laragon/data/sgf-tempo/run/modular-regression-current.json')).root+'/private/receipt-composition-cc50a276c10c',file=root+'/stock-catalogue-navigation-20261110.json';fs.writeFileSync(file,JSON.stringify({passed:true,checks,business_commands:0,browser_visual_review:false},null,2));console.log(JSON.stringify({passed:true,checks:checks.length,proof:file}));
|