import { verifyRelease } from './releaseArtifacts.mjs' import { uploadRelease } from './uploadRelease.mjs' const args = process.argv.slice(2) if (args.some((arg) => !['--upload', '--test-updates'].includes(arg))) throw new Error('Usage: npm run publish:release -- [--test-updates] [--upload]') const testing = args.includes('--test-updates') const release = await verifyRelease(testing ? 'dist/test' : 'dist/release') if (testing && (!new URL(release.feedUrl).pathname.endsWith('/capsule/testfeed/') || (args.includes('--upload') && !new URL(process.env.CAPSULE_UPLOAD_URL).pathname.endsWith('/capsule/testupload/')))) { throw new Error('Test publication requires the separate testfeed and testupload endpoints.') } console.log(`Capsule ${release.version}: ${release.feedUrl}`) if (!args.includes('--upload')) { console.log('Verified. Upload order:') for (const file of release.files) console.log(` ${file.name} (${file.data.length} bytes)`) console.log('No files uploaded. Add --upload with CAPSULE_UPLOAD_URL and CAPSULE_UPLOAD_TOKEN to publish.') } else { // Publish through the TTP Capsule plugin's authenticated chunk upload endpoint. await uploadRelease(release, { uploadUrl: process.env.CAPSULE_UPLOAD_URL, token: process.env.CAPSULE_UPLOAD_TOKEN }) }