Skip to content

Commit 05e27a2

Browse files
committed
feat: better messages
1 parent 208a25a commit 05e27a2

2 files changed

Lines changed: 26 additions & 4 deletions

File tree

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "create-oweb",
33
"main": "dist/index.js",
44
"type": "module",
5-
"version": "1.0.0",
5+
"version": "1.0.1",
66
"keywords": [
77
"owebjs",
88
"fastify",
@@ -15,6 +15,7 @@
1515
"files": [
1616
"dist"
1717
],
18+
"bin": "dist/index.js",
1819
"scripts": {
1920
"start": "node . --no-warnings",
2021
"dev": "tsup && pnpm start",

src/index.ts

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/usr/bin/env node
12
import fs from 'node:fs';
23
import path from 'node:path';
34
import * as p from '@clack/prompts';
@@ -68,6 +69,7 @@ const options = await p.group(
6869
p.multiselect({
6970
message: 'Select additional options (use arrow keys/space bar)',
7071
required: false,
72+
initialValues: [],
7173
options: [
7274
{
7375
value: '@fastify/cors',
@@ -116,7 +118,7 @@ if (options.template === 'typescript') {
116118
}
117119
}
118120

119-
p.outro("You're all set! Run the following commands to get started:");
121+
p.outro('🚀 I copied the proper template and made your project ready 😁');
120122

121123
const { uwebsockets, features, package_manager } = options;
122124

@@ -126,9 +128,9 @@ if (!fs.existsSync(cwd)) {
126128

127129
const commands = ['npx degit owebjs/templates/' + options.template + ' --force'];
128130

129-
if (features) {
131+
if (features.length > 0) {
130132
commands.push(
131-
`${package_manager} ${package_manager == 'npm' ? 'install' : 'add'} -D ${features.join(
133+
`${package_manager} ${package_manager == 'yarn' ? 'add' : 'install'} -D ${features.join(
132134
' ',
133135
)}`,
134136
);
@@ -184,3 +186,22 @@ function patch(file: string, string: string) {
184186

185187
fs.writeFileSync(indexFile, fs.readFileSync(indexFile, 'utf-8').replace(file, string));
186188
}
189+
190+
await p
191+
.confirm({
192+
message: 'Do you want to initialize a git repository?',
193+
initialValue: false,
194+
})
195+
.then(async (initGit) => {
196+
if (initGit) {
197+
await execa('git', ['init'], {
198+
cwd: path.relative(process.cwd(), cwd),
199+
});
200+
}
201+
});
202+
203+
console.log(
204+
`✨ Oweb project has been created. Next steps:\n cd ${cwd} \n› ${
205+
package_manager === 'yarn' ? 'yarn' : package_manager
206+
} ${package_manager === 'yarn' ? 'start' : 'run start'}`,
207+
);

0 commit comments

Comments
 (0)