Skip to content

Commit 830fcd8

Browse files
committed
Tidy ups
1 parent 68bb6af commit 830fcd8

File tree

14 files changed

+215
-208
lines changed

14 files changed

+215
-208
lines changed

.prettierignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
package.json
1+
package.json
2+
*.hbs

build.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ const pkg = JSON.parse(await readFile('package.json', 'utf-8'));
2525
delete pkg.devDependencies;
2626
delete pkg.scripts;
2727
delete pkg.private;
28-
pkg.bin['create-tinybase'] = './cli.js';
28+
pkg.bin['create-tinybase'] = 'cli.js';
29+
pkg.files = ['cli.js', 'templates'];
2930
await writeFile('dist/package.json', JSON.stringify(pkg, null, 2));
3031

3132
console.log('✅ Built and minified CLI');

package-lock.json

Lines changed: 33 additions & 43 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
{
22
"name": "create-tinybase",
3-
"version": "0.1.0",
3+
"version": "0.1.4",
44
"author": "jamesgpearce",
5-
"repository": "github:tinyplex/tinybase",
5+
"repository": {
6+
"type": "git",
7+
"url": "git+https://github.com/tinyplex/tinybase.git"
8+
},
69
"license": "MIT",
710
"homepage": "https://tinybase.org",
811
"description": "The CLI to build a new app using TinyBase, a reactive data store and sync engine.",
@@ -47,4 +50,4 @@
4750
"typescript-eslint": "^8.51.0",
4851
"vitest": "^4.0.16"
4952
}
50-
}
53+
}

src/cli.ts

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,6 @@ import {fileURLToPath} from 'url';
55

66
const __dirname = dirname(fileURLToPath(import.meta.url));
77

8-
type Language = 'typescript' | 'javascript';
9-
type Framework = 'react' | 'vanilla';
10-
11-
interface TinyBaseAnswers {
12-
projectName: string;
13-
language: Language;
14-
framework: Framework;
15-
prettier: boolean;
16-
eslint: boolean;
17-
}
18-
198
const config = {
209
welcomeMessage: '🎉 Welcome to TinyBase!\n',
2110

@@ -62,13 +51,18 @@ const config = {
6251
},
6352
],
6453

65-
createContext: (answers: TinyBaseAnswers) => {
66-
const typescript = answers.language === 'typescript';
67-
const react = answers.framework === 'react';
54+
createContext: (answers: Record<string, unknown>) => {
55+
const {projectName, language, framework, prettier, eslint} = answers;
56+
const typescript = language === 'typescript';
57+
const react = framework === 'react';
6858
const ext = typescript ? (react ? 'tsx' : 'ts') : react ? 'jsx' : 'js';
6959

7060
return {
71-
...answers,
61+
projectName,
62+
language,
63+
framework,
64+
prettier,
65+
eslint,
7266
typescript,
7367
react,
7468
ext,
@@ -89,22 +83,27 @@ const config = {
8983
{
9084
template: 'base/package.json.hbs',
9185
output: 'package.json',
86+
prettier: true,
9287
},
9388
{
9489
template: 'base/index.html.hbs',
9590
output: 'index.html',
91+
prettier: true,
9692
},
9793
{
9894
template: 'base/README.md.hbs',
9995
output: 'README.md',
96+
prettier: true,
10097
},
10198
{
10299
template: 'src/index.css.hbs',
103100
output: 'src/index.css',
101+
prettier: true,
104102
},
105103
{
106104
template: 'src/index.tsx.hbs',
107105
output: `src/index.${ext}`,
106+
prettier: true,
108107
transpile: true,
109108
},
110109
];
@@ -113,13 +112,15 @@ const config = {
113112
files.push({
114113
template: 'base/.prettierrc.hbs',
115114
output: '.prettierrc',
115+
prettier: true,
116116
});
117117
}
118118

119119
if (eslint) {
120120
files.push({
121121
template: 'base/eslint.config.js.hbs',
122122
output: 'eslint.config.js',
123+
prettier: true,
123124
});
124125
}
125126

@@ -128,11 +129,13 @@ const config = {
128129
{
129130
template: 'src/App.tsx.hbs',
130131
output: `src/App.${ext}`,
132+
prettier: true,
131133
transpile: true,
132134
},
133135
{
134136
template: 'base/vite.config.js.hbs',
135137
output: 'vite.config.js',
138+
prettier: true,
136139
},
137140
);
138141
}
@@ -142,18 +145,20 @@ const config = {
142145
{
143146
template: 'base/tsconfig.json.hbs',
144147
output: 'tsconfig.json',
148+
prettier: true,
145149
},
146150
{
147151
template: 'base/tsconfig.node.json.hbs',
148152
output: 'tsconfig.node.json',
153+
prettier: true,
149154
},
150155
);
151156
}
152157

153158
return files;
154159
},
155160

156-
templateRoot: join(__dirname, '../templates'),
161+
templateRoot: join(__dirname, 'templates'),
157162

158163
onSuccess: (projectName: string) => {
159164
console.log(`Next steps:`);

templates/base/.prettierrc.hbs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"bracketSpacing": false,
3-
"singleQuote": true,
4-
"trailingComma": "all"
5-
}
2+
"bracketSpacing": false,
3+
"singleQuote": true,
4+
"trailingComma": "all"
5+
}

templates/base/README.md.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ npm run dev
1212
## Learn More
1313

1414
- [TinyBase Documentation](https://tinybase.org)
15-
- [TinyBase Examples](https://tinybase.org/demos/)
15+
- [TinyBase Examples](https://tinybase.org/demos/)

templates/base/eslint.config.js.hbs

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,32 @@
77
{{/if}}
88

99
export default [
10-
{{#if typescript}}
11-
...tseslint.configs.recommended,
12-
{{else}}
13-
{
14-
rules: {
15-
'no-unused-vars': 'warn',
16-
'no-undef': 'error',
17-
},
18-
},
19-
{{/if}}
10+
{{#if typescript}}
11+
...tseslint.configs.recommended,
12+
{{else}}
13+
{
14+
rules: {
15+
'no-unused-vars': 'warn',
16+
'no-undef': 'error',
17+
},
18+
},
19+
{{/if}}
2020

21-
{{#if react}}
22-
pluginReact.configs.flat.recommended,
23-
{
24-
plugins: {
25-
'react-hooks': pluginReactHooks,
26-
},
27-
rules: {
28-
...pluginReactHooks.configs.recommended.rules,
29-
'react/react-in-jsx-scope': 'off',
30-
},
31-
settings: {
32-
react: {
33-
version: 'detect',
34-
},
35-
},
36-
},
37-
{{/if}}
38-
];
21+
{{#if react}}
22+
pluginReact.configs.flat.recommended,
23+
{
24+
plugins: {
25+
'react-hooks': pluginReactHooks,
26+
},
27+
rules: {
28+
...pluginReactHooks.configs.recommended.rules,
29+
'react/react-in-jsx-scope': 'off',
30+
},
31+
settings: {
32+
react: {
33+
version: 'detect',
34+
},
35+
},
36+
},
37+
{{/if}}
38+
];

0 commit comments

Comments
 (0)