-
Notifications
You must be signed in to change notification settings - Fork 2
/
plopfile.mjs
51 lines (44 loc) · 1.5 KB
/
plopfile.mjs
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 * as url from 'node:url'
import * as path from 'node:path'
import { plopDir } from './packages/plop-dir/dist/esm/index.mjs'
// eslint-disable-next-line @typescript-eslint/naming-convention, no-underscore-dangle
const __dirname = path.dirname(url.fileURLToPath(import.meta.url))
const libNamePrompt = {
name: 'libName',
message: 'Name of the lib (e.g. my-lib)',
}
const scopeNamePrompt = {
name: 'scopeName',
message: 'Optional registry scope name (e.g. @aacc)',
suffix: ' Enter to skip',
// TODO: Investigate why this is not working
// transformer: (input) => (!input || input.endsWith('/') ? input : `${input}/`),
}
const outputDirPrompt = {
name: 'outputDir',
message: 'Optional outputDir override',
suffix: ' Enter to use default "packages" dir',
default: 'packages',
}
/** @param {import('plop').NodePlopAPI} plop */
// eslint-disable-next-line import/no-default-export
export default async function run(plop) {
plop.setGenerator(
'rollup-babel-ts',
await plopDir({
plop,
templateDir: path.join(__dirname, './templates/rollup-babel-ts'),
outputDir: path.join(__dirname, '{{kebabCase outputDir}}'),
prompts: [libNamePrompt, scopeNamePrompt, outputDirPrompt],
}),
)
plop.setGenerator(
'rollup-babel-tsx',
await plopDir({
plop,
templateDir: path.join(__dirname, './templates/rollup-babel-tsx'),
outputDir: path.join(__dirname, '{{kebabCase outputDir}}'),
prompts: [libNamePrompt, scopeNamePrompt, outputDirPrompt],
}),
)
}