Something went wrong. Try again.
Browser extension: detect and subscribe to standard.site publications on ATProto
Something went wrong. Try again.
2.1 kB · 44 lines
JavaScript
123456789101112131415161718192021222324252627282930313233343536373839404142434445import { readFileSync } from 'node:fs'import { join } from 'node:path'
import { describe, expect, it } from 'vitest'
const source = readFileSync(join(import.meta.dirname, 'deploy-site.sh'), 'utf8')
// The deploy cannot be run here (it needs AWS credentials and rewrites a live// distribution), so the ordering that matters is asserted against the source.describe('deploy-site.sh', () => { const at = (needle) => { const index = source.indexOf(needle) expect(index, `deploy-site.sh no longer contains ${needle}`).toBeGreaterThan(-1) return index }
// Injection rewrites built HTML, so it has to happen after the build that // emits it and before the upload that freezes it into a release tree — the // tree is immutable and CloudFront serves it whole. Verification sits // between the two on purpose: what it checks is what ships. it('injects the standard.site link tags between the build and the upload', () => { const inject = at('sequoia inject') expect(inject).toBeGreaterThan(at('run build')) expect(inject).toBeLessThan(at('run verify:dist')) expect(inject).toBeLessThan(at('aws s3 cp')) })
// `git diff-index` answers from the stat info cached in the index, so a file // rewritten with identical content counts as modified — and sync-shots.mjs // rewrites every capture on each run, which suffixed every release -dirty on // a clean tree. The check has to refresh and compare contents. it('decides dirty from tracked file contents, not cached stat info', () => { at('status --porcelain --untracked-files=no') // The comment above that check names diff-index; the code must not. const code = source.split('\n').filter((line) => !line.trim().startsWith('#')) expect(code.join('\n')).not.toContain('diff-index') })
// A partial release tree must never be the one CloudFront is pointed at. it('applies only after every upload', () => { // The first `tofu -chdir=` in the file is inside the no-bucket message. expect(at('apply "$@"')).toBeGreaterThan(at('aws s3 cp')) })})