Bluesky app fork with some witchin' additions 馃挮
witchsky.app
bluesky
fork
client
1const path = require('path')
2const fs = require('fs')
3
4const projectRoot = path.join(__dirname, '..')
5const templateFile = path.join(
6 projectRoot,
7 'bskyweb',
8 'templates',
9 'scripts.html',
10)
11
12const manifest = require(
13 path.join(projectRoot, 'web-build/asset-manifest.json'),
14)
15const entrypoints = manifest.entrypoints || []
16
17console.log(`Found ${entrypoints.length} entrypoints`)
18console.log(`Writing ${templateFile}`)
19
20const outputFile = entrypoints
21 .map(name => {
22 const file = path.basename(name)
23 const ext = path.extname(file)
24
25 if (ext === '.js') {
26 return `<script defer="defer" src="{{ staticCDNHost }}/static/js/${file}"></script>`
27 }
28 if (ext === '.css') {
29 return `<link rel="stylesheet" href="{{ staticCDNHost }}/static/css/${file}">`
30 }
31
32 return ''
33 })
34 .join('\n')
35fs.writeFileSync(templateFile, outputFile)
36
37function copyFiles(sourceDir, targetDir) {
38 const srcPath = path.join(projectRoot, sourceDir)
39 if (!fs.existsSync(srcPath)) {
40 console.log(`Skipping ${sourceDir} (does not exist)`)
41 return
42 }
43 const tgtPath = path.join(projectRoot, targetDir)
44 if (!fs.existsSync(tgtPath)) {
45 fs.mkdirSync(tgtPath, {recursive: true})
46 }
47 const files = fs.readdirSync(srcPath)
48 files.forEach(file => {
49 const sourcePath = path.join(srcPath, file)
50 const targetPath = path.join(tgtPath, file)
51 fs.copyFileSync(sourcePath, targetPath)
52 console.log(`Copied ${sourcePath} to ${targetPath}`)
53 })
54}
55
56copyFiles('web-build/static/js', 'bskyweb/static/js')
57copyFiles('web-build/static/css', 'bskyweb/static/css')
58copyFiles('web-build/static/media', 'bskyweb/static/media')