forked from borekDigital/create-client-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerateConfigFiles.ts
77 lines (60 loc) · 2 KB
/
generateConfigFiles.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
65
66
67
68
69
70
71
72
73
74
75
76
77
import { urlJoin } from 'https://deno.land/x/url_join/mod.ts';
import { exec } from 'https://cdn.depjs.com/exec/mod.ts'
const libDir = 'lib'
const libTemplateDir = urlJoin(libDir, 'template')
const libNuxtDir = urlJoin(libTemplateDir, 'frameworks/nuxt')
const templatePathNuxtConfig = urlJoin(libNuxtDir, 'nuxt.config.ejs')
const outputPathNuxtConfig = urlJoin(libNuxtDir, 'nuxt.config.ts')
const templatePathTsConfig = urlJoin(libNuxtDir, 'tsconfig.ejs')
const outputPathTsConfig = urlJoin(libNuxtDir, 'tsconfig.json')
const readNuxtConfigTemplate = Deno.run({
cmd: [
'deno',
'run',
'--allow-read',
'./readConfigTemplate.ts',
templatePathNuxtConfig
],
stdout: 'piped',
stderr: 'piped',
});
const readTsConfigTemplate = Deno.run({
cmd: [
'deno',
'run',
'--allow-read',
'./readConfigTemplate.ts',
templatePathTsConfig
],
stdout: 'piped',
stderr: 'piped',
});
// nuxt.config
const statusNuxtConfig = await readNuxtConfigTemplate.status();
if (statusNuxtConfig.code === 0) {
const rawOutput = await readNuxtConfigTemplate.output();
const string = new TextDecoder().decode(rawOutput)
await Deno.writeTextFile(outputPathNuxtConfig, string);
// await exec({
// cmd: ['yarn', 'lint:fix'],
// cwd: `./${libNuxtDir}`,
// })
console.log(`\n🎉 Successfully created ${outputPathNuxtConfig}\n`)
} else {
const rawError = await readNuxtConfigTemplate.stderrOutput();
const errorString = new TextDecoder().decode(rawError);
console.log(errorString);
}
// tsconfig
const statusTsConfig = await readTsConfigTemplate.status();
if (statusTsConfig.code === 0) {
const rawOutput = await readTsConfigTemplate.output();
const string = new TextDecoder().decode(rawOutput)
await Deno.writeTextFile(outputPathTsConfig, string);
console.log(`\n🥳 Successfully created ${outputPathTsConfig}\n`)
} else {
const rawError = await readTsConfigTemplate.stderrOutput();
const errorString = new TextDecoder().decode(rawError);
console.log(errorString);
}
Deno.exit();