-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsmith.ts
More file actions
51 lines (44 loc) · 1.49 KB
/
smith.ts
File metadata and controls
51 lines (44 loc) · 1.49 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
import { readFileSync, writeFileSync } from 'node:fs'
import { dirname, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
import layouts from '@metalsmith/layouts'
import { blueprint, getHandlebarsPartials } from '@seamapi/smith'
import * as types from '@seamapi/types/connect'
import { deleteAsync } from 'del'
import Metalsmith from 'metalsmith'
import { connect, helpers } from './lib/index.js'
const rootDir = dirname(fileURLToPath(import.meta.url))
const projectDir = resolve(rootDir, '..')
// Copy route-types.ts from @seamapi/types into the source tree so consumers
// do not need @seamapi/types as a peer dependency.
const routeTypesSrc = resolve(
projectDir,
'node_modules/@seamapi/types/src/lib/seam/connect/route-types.ts',
)
const routeTypesDest = resolve(
projectDir,
'src/lib/seam/connect/route-types.ts',
)
const header = `// This file is auto-generated during codegen from @seamapi/types.\n// Do not edit manually.\n\n`
writeFileSync(routeTypesDest, header + readFileSync(routeTypesSrc, 'utf-8'))
await Promise.all([deleteAsync('./src/lib/seam/connect/routes')])
const partials = await getHandlebarsPartials(`${rootDir}/layouts/partials`)
Metalsmith(rootDir)
.source('./content')
.destination('../')
.clean(false)
.use(blueprint({ types }))
.use(connect)
.use(
layouts({
default: 'default.hbs',
engineOptions: {
noEscape: true,
helpers,
partials,
},
}),
)
.build((err) => {
if (err != null) throw err
})