@@ -8,6 +8,14 @@ import { createServer } from 'node:net';
|
||||
|
||||
const id = crypto.randomBytes(6).toString('hex');
|
||||
const workspace = path.resolve('C:/laragon/www/compras');
|
||||
const reviewDurationArgs = process.argv.filter(flag => flag.startsWith('--review-minutes='));
|
||||
const reviewDurationMinutes = reviewDurationArgs.length === 0 ? 20 : Number(reviewDurationArgs[0].slice('--review-minutes='.length));
|
||||
if (reviewDurationArgs.length > 1 || !Number.isInteger(reviewDurationMinutes) || reviewDurationMinutes < 1 || reviewDurationMinutes > 60 || (reviewDurationArgs.length > 0 && !process.argv.includes('--native-review'))) throw Error('Native review duration must be one explicit value from1to60minutes');
|
||||
if (process.argv.includes('--legal-reference-preview') && (!process.argv.includes('--integrated-schema') || !process.argv.includes('--frozen-runtime') || !process.argv.some(flag => ['--native-review', '--native-review-http-only'].includes(flag)))) throw Error('Legal preview requires the owned native review with complete pinned private composition');
|
||||
if (process.argv.includes('--private-audit-recovery') && (!process.argv.includes('--integrated-schema') || !process.argv.includes('--frozen-runtime') || process.argv.some(flag => ['--recovery-only', '--race-only', '--native-review', '--native-review-http-only'].includes(flag)))) throw Error('Private audit recovery requires its own complete pinned isolated composition');
|
||||
if (process.argv.includes('--print-pagination-preview') && (!process.argv.includes('--native-review') || !process.argv.includes('--integrated-schema') || !process.argv.includes('--frozen-runtime'))) throw Error('Print pagination requires the owned native preview and complete pinned composition');
|
||||
if (process.argv.includes('--native-office-preview') && (!process.argv.includes('--native-review') || !process.argv.includes('--integrated-schema') || !process.argv.includes('--frozen-runtime') || process.argv.some(flag => ['--print-pagination-preview', '--legal-reference-preview'].includes(flag)))) throw Error('Office preview requires its own complete pinned native QA composition');
|
||||
if (process.argv.includes('--specific-rate-preview') && (!process.argv.includes('--legal-reference-preview') || !process.argv.includes('--native-review'))) throw Error('Specific coefficient preview requires the owned legal native review');
|
||||
if (path.resolve(process.cwd()) !== workspace) throw Error('Compras workspace required');
|
||||
if (process.argv.includes('--integrated-cycles-only') && !process.argv.includes('--integrated-schema')) throw Error('Integrated cycles require the complete isolated schema composition');
|
||||
if (process.argv.includes('--integrated-orders-only') && !process.argv.includes('--integrated-schema')) throw Error('Integrated orders require the complete isolated schema composition');
|
||||
@@ -108,7 +116,10 @@ try {
|
||||
COMMON_BUDGET_PATH: frozenRuntime ? path.join(budgetRoot, 'budget-control') : 'C:/laragon/www/sgf-tempo/packages/budget-control',
|
||||
RQ01_LEDGER_QA_SOURCE: frozenRuntime ? path.join(financeRoot, 'general-ledger') : 'C:/laragon/www/sgf-tempo/packages/general-ledger',
|
||||
RQ01_LEDGER_INTEGRATED_SCHEMA: process.argv.includes('--integrated-schema') ? '1' : '0',
|
||||
RQ01_NATIVE_OFFICE_JOURNEY: process.argv.includes('--native-office-http-only') ? '1' : '0' };
|
||||
RQ01_NATIVE_OFFICE_JOURNEY: process.argv.some(flag => ['--native-office-http-only', '--native-office-preview'].includes(flag)) ? '1' : '0',
|
||||
RQ01_QA_LEGAL_REFERENCE: process.argv.includes('--legal-reference-preview') ? '1' : '0',
|
||||
RQ01_QA_SPECIFIC_RATE: process.argv.includes('--specific-rate-preview') ? '1' : '0',
|
||||
RQ01_QA_PRINT_PAGINATION: process.argv.includes('--print-pagination-preview') ? '1' : '0' };
|
||||
delete environment.COMMON_FINANCE_BUNDLE_ROOT;
|
||||
delete environment.COMMON_FINANCE_BUNDLE_SHA256;
|
||||
if (frozenRuntime) {
|
||||
@@ -116,11 +127,13 @@ try {
|
||||
environment.COMMON_FINANCE_BUNDLE_SHA256 = financePin;
|
||||
}
|
||||
const raceOnly = process.argv.includes('--race-only');
|
||||
const recoveryOnly = process.argv.includes('--recovery-only');
|
||||
const auditRecovery = process.argv.includes('--private-audit-recovery');
|
||||
const recoveryOnly = process.argv.includes('--recovery-only') || auditRecovery;
|
||||
const nativeAuditSchemaOnly = process.argv.includes('--audit-schema-only');
|
||||
const nativeFixtureOnly = process.argv.includes('--native-review-fixture-only');
|
||||
const nativeHttpOnly = process.argv.includes('--native-review-http-only');
|
||||
const nativeOfficeOnly = process.argv.includes('--native-office-http-only');
|
||||
const nativeOfficePreview = process.argv.includes('--native-office-preview');
|
||||
const nativeOfficeOnly = process.argv.includes('--native-office-http-only') || nativeOfficePreview;
|
||||
const nativeReview = process.argv.includes('--native-review') || nativeFixtureOnly || nativeHttpOnly || nativeOfficeOnly || nativeAuditSchemaOnly;
|
||||
const setupOnly = raceOnly || recoveryOnly || nativeReview;
|
||||
const args = setupOnly ? ['artisan', 'migrate', '--force', '--no-interaction'] : process.argv.includes('--integrated-release-journeys') ? ['vendor/bin/pest', '--compact', 'tests/Feature/RequisitionLedgerAccountsTest.php', 'tests/Feature/RequisitionBudgetCyclesTest.php', 'tests/Feature/PurchaseAwardOrderTest.php', 'tests/Feature/ImportLandedCostsTest.php', '--filter=RequisitionBudgetCyclesTest|ImportLandedCostsTest|native office purchase|native partial-order|native consolidated order|native delivery analysis'] : process.argv.includes('--integrated-import-costs-only') ? ['vendor/bin/pest', '--compact', 'tests/Feature/ImportLandedCostsTest.php'] : process.argv.includes('--integrated-orders-only') ? ['vendor/bin/pest', '--compact', 'tests/Feature/PurchaseAwardOrderTest.php', '--filter=native partial-order|native consolidated order|native delivery analysis'] : process.argv.includes('--integrated-cycles-only') ? ['vendor/bin/pest', '--compact', 'tests/Feature/RequisitionBudgetCyclesTest.php'] : process.argv.includes('--office-process-only') ? ['vendor/bin/pest', '--compact', 'tests/Feature/RequisitionLedgerAccountsTest.php', '--filter=native office purchase'] : ['vendor/bin/pest', '--compact', 'tests/Feature/RequisitionLedgerAccountsTest.php', 'tests/Feature/PurchaseAwardOrderTest.php',
|
||||
@@ -137,6 +150,10 @@ try {
|
||||
if (setupOnly) throw Error('Private controllers are focused native Pest regressions');
|
||||
args.splice(0, args.length, 'vendor/bin/pest', '--compact', 'tests/Feature/PurchaseAwardOrderTest.php', '--filter=budget consultations|purchase control preparations');
|
||||
}
|
||||
if (process.argv.includes('--expiry-history-only')) {
|
||||
if (setupOnly || !frozenRuntime || !process.argv.includes('--integrated-schema')) throw Error('Expiry history regression requires the complete pinned isolated composition');
|
||||
args.splice(0, args.length, 'vendor/bin/pest', '--compact', 'tests/Feature/RequisitionBudgetCyclesTest.php', '--filter=native expiry returns the same request');
|
||||
}
|
||||
const result = spawnSync('php', args, {
|
||||
cwd: process.cwd(), windowsHide: true, encoding: 'utf8', maxBuffer: 1024 * 1024, env: environment,
|
||||
});
|
||||
@@ -153,13 +170,15 @@ try {
|
||||
}
|
||||
if (result.status === 0 && recoveryOnly) {
|
||||
const worker = (mode, env, payload = null) => {
|
||||
const args = ['tests/Concurrency/requisition-account-worker.php', env.DB_DATABASE, mode];
|
||||
const args = [auditRecovery ? 'tests/Concurrency/private-audit-recovery-worker.php' : 'tests/Concurrency/requisition-account-worker.php', env.DB_DATABASE, mode];
|
||||
if (payload !== null) args.push(JSON.stringify(payload));
|
||||
const result = spawnSync('php', args, { cwd: workspace, windowsHide: true, encoding: 'utf8', maxBuffer: 1024 * 1024, env });
|
||||
if (result.status !== 0) throw Error('Account recovery worker failed: ' + (result.stderr || result.stdout || '').replaceAll(password, '[private]'));
|
||||
return JSON.parse(result.stdout);
|
||||
};
|
||||
const fixture = worker('prepare-recovery', environment);
|
||||
const recoveryEnvironment = auditRecovery ? { ...environment, SGC_REQUISITION_QA_ROOT: root } : environment;
|
||||
const fixture = worker(auditRecovery ? 'prepare' : 'prepare-recovery', recoveryEnvironment);
|
||||
if (auditRecovery) fs.cpSync(path.join(root, 'audit-source-files'), path.join(root, 'audit-backup-files'), { recursive: true, errorOnExist: true, force: false });
|
||||
const pgCommand = (binary, args, env) => {
|
||||
const result = spawnSync(path.join(pg, binary), args, { windowsHide: true, encoding: 'utf8',
|
||||
env: { ...process.env, PGHOST: '127.0.0.1', PGPORT: '55439', PGUSER: env.DB_USERNAME, PGPASSWORD: env.DB_PASSWORD } });
|
||||
@@ -176,9 +195,16 @@ try {
|
||||
sql(`CREATE DATABASE ${targetDatabase} OWNER ${targetRole};`);
|
||||
restoreDatabase = targetDatabase;
|
||||
sql(`REVOKE ALL ON DATABASE ${targetDatabase} FROM PUBLIC;`);
|
||||
const restoredEnvironment = { ...environment, DB_DATABASE: targetDatabase, DB_USERNAME: targetRole, DB_PASSWORD: restoredPassword };
|
||||
const restoredEnvironment = { ...recoveryEnvironment, DB_DATABASE: targetDatabase, DB_USERNAME: targetRole, DB_PASSWORD: restoredPassword };
|
||||
pgCommand('pg_restore.exe', ['--no-owner', '--no-acl', '--exit-on-error', '--dbname='+targetDatabase, dump], restoredEnvironment);
|
||||
console.log(JSON.stringify(worker('verify-recovery', restoredEnvironment, fixture)));
|
||||
if (auditRecovery) {
|
||||
// All paths are literal children of the guarded newly-created task root.
|
||||
if (path.dirname(path.resolve(root)) !== privateParent || path.basename(root) !== `rq01-ledger-qa-${id}`) throw Error('Audit recovery root refused');
|
||||
fs.renameSync(path.join(root, 'audit-source-files'), path.join(root, 'audit-source-unavailable'));
|
||||
fs.cpSync(path.join(root, 'audit-backup-files'), path.join(root, 'audit-restored-files'), { recursive: true, errorOnExist: true, force: false });
|
||||
}
|
||||
console.log(JSON.stringify({ source_database: database, restored_database: targetDatabase,
|
||||
...worker(auditRecovery ? 'verify' : 'verify-recovery', restoredEnvironment, fixture) }));
|
||||
}
|
||||
if (result.status === 0 && nativeReview) {
|
||||
for (const relative of ['public', 'storage/framework/sessions', 'storage/framework/views', 'storage/framework/cache/data', 'storage/logs', 'storage/app/private']) {
|
||||
@@ -191,10 +217,10 @@ try {
|
||||
if (seed.status !== 0) throw Error('Native review fixture failed: '+(seed.stderr || seed.stdout || '').replaceAll(password, '[private]'));
|
||||
const fixture = JSON.parse(seed.stdout);
|
||||
fs.writeFileSync(path.join(root, 'native-review.json'), JSON.stringify(fixture));
|
||||
const assets = path.join(privateParent, 'sgc-private-audit-help-qa-20261128');
|
||||
const assets = path.join(privateParent, 'sgc-legal-specific-precision-qa-20261128');
|
||||
const manifest = fs.readFileSync(path.join(assets, 'manifest.json'));
|
||||
const manifestHash = crypto.createHash('sha256').update(manifest).digest('hex');
|
||||
if (manifestHash !== 'fa87e37a3626ef75d22b5248dce9a0af2bad68c967e6f99bb64bc426a68f6aaf') throw Error('Unexpected private review manifest');
|
||||
if (manifestHash !== '9d415ba790aa602b36372d310a4eaa3426670fc521f15efb4166d782e170ac8e') throw Error('Unexpected private review manifest');
|
||||
for (const entry of Object.values(JSON.parse(manifest))) {
|
||||
if (!fs.existsSync(path.join(assets, entry.file))) throw Error('Private review asset missing');
|
||||
}
|
||||
@@ -256,7 +282,8 @@ try {
|
||||
return JSON.parse(state.stdout);
|
||||
}, value => console.log(JSON.stringify(value)));
|
||||
console.log(JSON.stringify({ private_native_office_http_verified: true, ...result, private_manifest_sha256: manifestHash }));
|
||||
} else if (nativeHttpOnly) {
|
||||
}
|
||||
if (nativeHttpOnly) {
|
||||
const { verifyNativeReviewHttp } = await import('./requisition-native-http-check.mjs');
|
||||
const pageAssets = ['resources/js/pages/audit/private.tsx', 'resources/js/pages/supply/index.tsx', 'resources/js/pages/purchase-controls/index.tsx', 'resources/js/pages/purchase-controls/orders.tsx', 'resources/js/pages/budgets/index.tsx', 'resources/js/pages/conflicts/index.tsx', 'resources/js/pages/conflicts/show.tsx', 'resources/js/pages/payments/index.tsx', 'resources/js/pages/stock/index.tsx', 'resources/js/pages/stock/operations.tsx', 'resources/js/pages/stock/lots.tsx', 'resources/js/pages/stock/reversals.tsx', 'resources/js/pages/stock/dispositions.tsx', 'resources/js/pages/equipment/index.tsx', 'resources/js/pages/investment/index.tsx', 'resources/js/pages/company/parameters.tsx', 'resources/js/pages/company/index.tsx', 'resources/js/pages/company/setup.tsx', 'resources/js/pages/requisitions/operational-orders.tsx', 'resources/js/pages/requisitions/urgent-stock.tsx']
|
||||
.map(key => JSON.parse(manifest)[key]);
|
||||
@@ -271,10 +298,10 @@ try {
|
||||
},
|
||||
});
|
||||
console.log(JSON.stringify({ private_native_http_verified: true, ...result, private_manifest_sha256: manifestHash }));
|
||||
} else {
|
||||
} else if (!nativeOfficeOnly || nativeOfficePreview) {
|
||||
const stopFile = path.join(root, 'stop-review');
|
||||
console.log(JSON.stringify({ private_native_review_running: true, url, stop_file: stopFile, ...fixture, private_manifest_sha256: manifestHash }));
|
||||
const until = Date.now() + 20 * 60 * 1000;
|
||||
console.log(JSON.stringify({ private_native_review_running: true, url, stop_file: stopFile, review_minutes: reviewDurationMinutes, ...fixture, private_manifest_sha256: manifestHash }));
|
||||
const until = Date.now() + reviewDurationMinutes * 60 * 1000;
|
||||
while (!fs.existsSync(stopFile) && Date.now() < until) {
|
||||
if (reviewServer.exitCode !== null) throw Error('Private native review stopped unexpectedly');
|
||||
await new Promise(resolve => setTimeout(resolve, 200));
|
||||
|
||||
Reference in New Issue
Block a user