-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgh-pages.js
More file actions
72 lines (65 loc) · 2.35 KB
/
Copy pathgh-pages.js
File metadata and controls
72 lines (65 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import { publish } from 'gh-pages';
import { existsSync, rmSync } from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
const repoRoot = path.dirname(fileURLToPath(import.meta.url));
const buildDir = path.join(repoRoot, 'build');
const requiredBuildFiles = [
'compressed-runtime-assets.v1.json',
'wasm-of-js-of-ocaml/browser-native/src/index.js',
'wasm-of-js-of-ocaml/browser-native/src/compiler-worker.js',
'wasm-of-js-of-ocaml/browser-native/runtime/fs/memory-fs.js',
'wasm-of-js-of-ocaml/browser-native-bundle/browser-native-manifest.v1.json',
'wasm-of-js-of-ocaml/browser-native-bundle/browser-native-runtime-pack.v1.bin.gz',
'wasm-of-js-of-ocaml/browser-native-bundle/browser-native-runtime-pack.v1.index.json',
'wasm-of-js-of-ocaml/browser-native-bundle/tools/ocamlc.byte.browser.js.gz',
'wasm-of-js-of-ocaml/browser-native-bundle/tools/js_of_ocaml.bc.browser.js.gz',
'wasm-of-js-of-ocaml/browser-native-bundle/tools/wasm_of_ocaml.bc.browser.js.gz',
'wasm-of-js-of-ocaml/browser-native-bundle/tools/wasm-merge.browser.js.gz',
'wasm-of-js-of-ocaml/browser-native-bundle/tools/wasm-metadce.browser.js.gz',
'wasm-of-js-of-ocaml/browser-native-bundle/tools/wasm-opt.browser.js.gz'
];
const missingBuildFiles = requiredBuildFiles.filter(
(file) => !existsSync(path.join(buildDir, file))
);
if (missingBuildFiles.length > 0) {
console.error(
[
'Refusing to deploy: the OCaml wasm_of_ocaml runtime bundle is missing from build/.',
'Run npm run sync:wasm-of-js-of-ocaml before building, then retry npm run page.',
'Missing files:',
...missingBuildFiles.map((file) => `- ${file}`)
].join('\n')
);
process.exit(1);
}
const redundantBuildDirs = [
// TinyGo is wired to reuse the top-level wasm-rust runtime at /wasm-rust/runtime/.
// Keeping the vendored duplicate pushes the GitHub Pages artifact over the
// practical legacy Pages size limit.
'wasm-tinygo/vendor/wasm-rust-runtime'
];
for (const dir of redundantBuildDirs) {
rmSync(path.join(buildDir, dir), { recursive: true, force: true });
}
publish(
buildDir,
{
branch: 'gh-pages',
repo: 'https://github.com/seo-rii/wasm-idle.git',
nojekyll: true,
user: {
name: 'seo-rii',
email: 'me@seorii.page'
},
dotfiles: true
},
(error) => {
if (error) {
console.error(error);
process.exitCode = 1;
return;
}
console.log('Deploy Complete!');
}
);