-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.ts
54 lines (48 loc) · 1.62 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
/* eslint-disable no-console */
import { runCreateCli } from './src/run-create-cli';
import { runCreateInteractiveCli } from './src/run-create-interactive-cli';
import { panic, printHeader } from '../qwik/src/cli/utils/utils';
import { red, yellow } from 'kleur/colors';
import { createAppFacade } from './src/create-app-facade';
export async function runCli() {
printHeader();
checkNodeVersion();
try {
const args = process.argv.slice(2);
if (args.length > 0) {
await runCreateCli(...args);
} else {
// npm create qwik
await runCreateInteractiveCli();
}
} catch (e: any) {
panic(e.message || e);
}
}
function checkNodeVersion() {
const version = process.version;
const [majorVersion, minorVersion] = version.replace('v', '').split('.');
if (Number(majorVersion) < 16) {
console.error(
red(`Qwik requires Node.js 16.8 or higher. You are currently running Node.js ${version}.`)
);
process.exit(1);
} else if (Number(majorVersion) === 16) {
if (Number(minorVersion) < 8) {
console.warn(
yellow(
`Node.js 16.8 or higher is recommended. You are currently running Node.js ${version}.`
)
);
}
} else if (Number(majorVersion) === 18) {
if (Number(minorVersion) < 11) {
console.error(
red(
`Node.js 18.11 or higher is REQUIRED. From Node 18.0.0 to 18.11.0, there is a bug preventing correct behaviour of Qwik. You are currently running Node.js ${version}. https://github.com/QwikDev/qwik/issues/3035`
)
);
}
}
}
export { createAppFacade as createApp, runCreateCli, runCreateInteractiveCli };