-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.ts
64 lines (55 loc) · 2.15 KB
/
index.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
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
#!/usr/bin/env node
import kleur from 'kleur';
import { checkComponentExistence } from './src/checkComponentExistence';
import { setPath } from './src/setPath';
import { setConfig } from './src/setConfig';
import { setProject } from './src/setProject';
import { initialize } from './src/initialize';
import { checkConfig } from './src/checkConfig';
import { buildComponent } from './src/buildComponent';
import { processCommandLineFlags } from './src/processCommandLineFlags';
import { getModuleRootPath } from './src/getModuleRootPath';
import { setComponentTemplate } from './src/setComponentTemplate';
import { parseDestinationPath } from './src/parseDestinationPath';
(async () => {
try {
const root = process.cwd();
const moduleRoot = getModuleRootPath();
const commandLineFlags = processCommandLineFlags();
await initialize({ root, moduleRoot, commandLineFlags });
let config = await setConfig({ root });
await checkConfig({ config });
const { config: newConfig, templateName } = await setComponentTemplate({ commandLineFlags, config });
config = newConfig;
const parsedPath = await parseDestinationPath({
root,
commandLineFlags,
config
});
const project = await setProject({ project: parsedPath.project, root, commandLineFlags, config, templateName });
const { componentNames, resultPath, projectRootPath } = await setPath({
root,
commandLineFlags,
config,
project,
templateName,
resultPathInput: parsedPath.resultPath,
projectRootPathInput: parsedPath.projectRootPath
});
await checkComponentExistence({ componentNames, commandLineFlags, resultPath, projectRootPath, config });
await buildComponent({
root,
moduleRoot,
commandLineFlags,
config,
project,
templateName,
componentNames,
resultPath,
projectRootPath
});
} catch (e) {
console.error(kleur.red('Unexpected error'), e);
process.exit();
}
})();