/
publish.ts
31 lines (29 loc) · 1.07 KB
/
publish.ts
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
// custom script for https://deno.land/x/publish
import { defaultReactVersion } from './shared/constants.ts'
export async function prepublish(version: string) {
const p = Deno.run({
cmd: ['deno', 'run', '-A', 'build.ts'],
cwd: './compiler',
stdout: 'inherit',
stderr: 'inherit',
})
const { success } = await p.status()
if (success) {
const data = await Deno.readTextFile('./import_map.json')
const importMap = JSON.parse(data)
Object.assign(importMap.imports, {
'aleph/': `https://deno.land/x/aleph@v${version}/`,
'framework': `https://deno.land/x/aleph@v${version}/framework/core/mod.ts`,
'framework/react': `https://deno.land/x/aleph@v${version}/framework/react/mod.ts`,
'react': `https://esm.sh/react@${defaultReactVersion}`,
'react-dom': `https://esm.sh/react-dom@${defaultReactVersion}`,
'react-dom/server': `https://esm.sh/react-dom@${defaultReactVersion}/server`
})
await Deno.writeTextFile(
'./import_map.json',
JSON.stringify(importMap, undefined, 2)
)
}
p.close()
return success
}