-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.js
46 lines (39 loc) · 1.14 KB
/
example.js
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
// #### Import
// remark-usage-ignore-next 2
import {resolve} from 'path';
import stubbedFs from 'mock-fs';
import any from '@travi/any';
import {lift, promptConstants, scaffold, test} from './lib/index.js';
// remark-usage-ignore-next
stubbedFs({node_modules: stubbedFs.load(resolve('node_modules'))});
// #### Execute
const projectRoot = process.cwd();
await scaffold(
{
projectRoot,
projectName: 'foo',
visibility: any.fromList(['Public', 'Private']),
description: any.sentence()
},
{
prompt: async ({id}) => {
const {questionNames, ids} = promptConstants;
const expectedPromptId = ids.GITHUB_DETAILS;
if (expectedPromptId === id) {
return {[questionNames[expectedPromptId].GITHUB_ACCOUNT]: any.word()};
}
throw new Error(`Unknown prompt with ID: ${id}`);
}
}
);
if (await test({projectRoot})) {
await lift({
projectRoot,
vcs: {owner: 'account-name', name: 'repository-name'},
results: {
projectDetails: {homepage: any.url()},
tags: any.listOf(any.word),
nextSteps: any.listOf(() => ({summary: any.sentence(), description: any.sentence()}))
}
});
}