Something went wrong. Try again.
move github sites
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465import { test } from 'node:test'import assert from 'node:assert/strict'import { detect, verdict } from '../src/detect.mjs'
const site = (paths, extra = {}) => ({ pages: { url: 'https://example.github.io/x/' }, branch: 'main', sourcePath: '/', live: { ok: true, status: 200 }, detect: detect(paths), ...extra,})
test('plain index.html with no build is automatic', () => { assert.equal(verdict(site(['index.html', 'style.css'])).effort, 'automatic')})
test('index.html beside a generator config is a build entry, not the page', () => { const v = verdict(site(['index.html', 'vite.config.js', 'src/main.js'])) assert.equal(v.effort, 'needs-build') assert.equal(v.deploy, null) assert.match(v.blockers[0], /Vite/)})
test('index.html under Jekyll templating needs a build', () => { const v = verdict(site(['index.html', '_layouts/default.html'])) assert.equal(v.effort, 'needs-build') assert.match(v.blockers[0], /Jekyll/)})
test('.nojekyll means Jekyll files are served as they are', () => { const v = verdict(site(['index.html', '_config.yml', '.nojekyll'])) assert.equal(v.effort, 'automatic')})
test('a GitHub Actions publish makes the source index.html suspect', () => { const v = verdict(site(['index.html'], { buildType: 'workflow' })) assert.equal(v.effort, 'needs-build')})
test('committed build output wins over a build-entry index.html', () => { const v = verdict(site(['index.html', 'vite.config.js', 'dist/index.html'])) assert.equal(v.effort, 'automatic') assert.equal(v.deploy.dir, '/dist')})
test('an unreadable tree is unknown, not dead', () => { const s = site([], { live: { ok: false, status: 404 } }) s.detect.treeError = '403' const v = verdict(s) assert.equal(v.effort, 'unknown') assert.match(v.blockers[0], /403/)})
test('a truncated tree with nothing found is unknown, not dead', () => { const s = site(['README.md', '.nojekyll'], { live: { ok: false, status: 404 } }) s.detect.truncated = true assert.equal(verdict(s).effort, 'unknown')})
test('an unreachable site with a complete empty tree is still dead', () => { const s = site(['README.md', '.nojekyll'], { live: { ok: false, status: 404 } }) assert.equal(verdict(s).effort, 'dead')})