Skip to content

Commit 8efcf5d

Browse files
committed
Generate new project with Vite instead of CRA
1 parent 0a77016 commit 8efcf5d

File tree

11 files changed

+107
-149
lines changed

11 files changed

+107
-149
lines changed

.ruby-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.4.5
1+
3.4.7

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## [0.2.0] - 2026-03-19
2+
3+
- Switch to generating the project with Vite instead of CRA
4+
15
## [0.1.0] - 2025-08-22
26

37
- Mark as compatible with Foobara 0.1.0

Gemfile.lock

Lines changed: 50 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,46 @@
11
PATH
22
remote: .
33
specs:
4-
foobara-empty-typescript-react-project-generator (0.1.0)
4+
foobara-empty-typescript-react-project-generator (0.2.0)
55
foobara (>= 0.1.1, < 2.0.0)
66
foobara-files-generator (< 2.0.0)
77

88
GEM
99
remote: https://rubygems.org/
1010
specs:
11+
addressable (2.8.9)
12+
public_suffix (>= 2.0.2, < 8.0)
1113
ast (2.4.3)
12-
bigdecimal (3.2.2)
13-
byebug (12.0.0)
14+
bigdecimal (4.0.1)
15+
byebug (13.0.0)
16+
reline (>= 0.6.0)
1417
coderay (1.1.3)
1518
diff-lcs (1.6.2)
1619
docile (1.4.1)
17-
ffi (1.17.2-x86_64-linux-gnu)
18-
foobara (0.1.1)
20+
ffi (1.17.3-x86_64-linux-gnu)
21+
foobara (0.5.9)
1922
bigdecimal
2023
foobara-lru-cache (< 2.0.0)
2124
foobara-util (< 2.0.0)
2225
inheritable-thread-vars (< 2.0.0)
23-
foobara-files-generator (0.1.0)
26+
foobara-files-generator (0.1.2)
2427
foobara (>= 0.1.1, < 2.0.0)
2528
foobara-lru-cache (1.0.0)
26-
foobara-rubocop-rules (1.0.1)
29+
foobara-rubocop-rules (1.0.12)
2730
rubocop
2831
rubocop-rspec
29-
foobara-spec-helpers (0.0.4)
32+
foobara-spec-helpers (0.1.0)
3033
foobara-util
31-
foobara-util (1.0.2)
32-
formatador (1.2.0)
34+
foobara-util (1.0.8)
35+
formatador (1.2.3)
3336
reline
34-
guard (2.19.1)
37+
guard (2.20.1)
3538
formatador (>= 0.2.4)
3639
listen (>= 2.7, < 4.0)
3740
logger (~> 1.6)
3841
lumberjack (>= 1.0.12, < 2.0)
3942
nenv (~> 0.1)
4043
notiffany (~> 0.0)
41-
ostruct (~> 0.6)
4244
pry (>= 0.13.0)
4345
shellany (~> 0.0)
4446
thor (>= 0.18.1)
@@ -48,77 +50,85 @@ GEM
4850
guard-compat (~> 1.1)
4951
rspec (>= 2.99.0, < 4.0)
5052
inheritable-thread-vars (0.0.3)
51-
io-console (0.8.1)
52-
json (2.13.2)
53+
io-console (0.8.2)
54+
json (2.19.2)
55+
json-schema (6.2.0)
56+
addressable (~> 2.8)
57+
bigdecimal (>= 3.1, < 5)
5358
language_server-protocol (3.17.0.5)
5459
lint_roller (1.1.0)
55-
listen (3.9.0)
60+
listen (3.10.0)
61+
logger
5662
rb-fsevent (~> 0.10, >= 0.10.3)
5763
rb-inotify (~> 0.9, >= 0.9.10)
5864
logger (1.7.0)
59-
lumberjack (1.4.0)
65+
lumberjack (1.4.2)
66+
mcp (0.8.0)
67+
json-schema (>= 4.1)
6068
method_source (1.1.0)
6169
nenv (0.3.0)
6270
notiffany (0.1.3)
6371
nenv (~> 0.1)
6472
shellany (~> 0.0)
65-
ostruct (0.6.3)
6673
parallel (1.27.0)
67-
parser (3.3.9.0)
74+
parser (3.3.10.2)
6875
ast (~> 2.4.1)
6976
racc
70-
prism (1.4.0)
71-
pry (0.15.2)
77+
prism (1.9.0)
78+
pry (0.16.0)
7279
coderay (~> 1.1)
7380
method_source (~> 1.0)
74-
pry-byebug (3.11.0)
75-
byebug (~> 12.0)
76-
pry (>= 0.13, < 0.16)
81+
reline (>= 0.6.0)
82+
pry-byebug (3.12.0)
83+
byebug (~> 13.0)
84+
pry (>= 0.13, < 0.17)
85+
public_suffix (7.0.5)
7786
racc (1.8.1)
7887
rainbow (3.1.1)
79-
rake (13.3.0)
88+
rake (13.3.1)
8089
rb-fsevent (0.11.2)
8190
rb-inotify (0.11.1)
8291
ffi (~> 1.0)
83-
regexp_parser (2.11.2)
84-
reline (0.6.2)
92+
regexp_parser (2.11.3)
93+
reline (0.6.3)
8594
io-console (~> 0.5)
86-
rspec (3.13.1)
95+
rspec (3.13.2)
8796
rspec-core (~> 3.13.0)
8897
rspec-expectations (~> 3.13.0)
8998
rspec-mocks (~> 3.13.0)
90-
rspec-core (3.13.5)
99+
rspec-core (3.13.6)
91100
rspec-support (~> 3.13.0)
92101
rspec-expectations (3.13.5)
93102
diff-lcs (>= 1.2.0, < 2.0)
94103
rspec-support (~> 3.13.0)
95104
rspec-its (2.0.0)
96105
rspec-core (>= 3.13.0)
97106
rspec-expectations (>= 3.13.0)
98-
rspec-mocks (3.13.5)
107+
rspec-mocks (3.13.8)
99108
diff-lcs (>= 1.2.0, < 2.0)
100109
rspec-support (~> 3.13.0)
101-
rspec-support (3.13.5)
102-
rubocop (1.80.0)
110+
rspec-support (3.13.7)
111+
rubocop (1.85.1)
103112
json (~> 2.3)
104113
language_server-protocol (~> 3.17.0.2)
105114
lint_roller (~> 1.1.0)
115+
mcp (~> 0.6)
106116
parallel (~> 1.10)
107117
parser (>= 3.3.0.2)
108118
rainbow (>= 2.2.2, < 4.0)
109119
regexp_parser (>= 2.9.3, < 3.0)
110-
rubocop-ast (>= 1.46.0, < 2.0)
120+
rubocop-ast (>= 1.49.0, < 2.0)
111121
ruby-progressbar (~> 1.7)
112122
unicode-display_width (>= 2.4.0, < 4.0)
113-
rubocop-ast (1.46.0)
123+
rubocop-ast (1.49.1)
114124
parser (>= 3.3.7.2)
115-
prism (~> 1.4)
125+
prism (~> 1.7)
116126
rubocop-rake (0.7.1)
117127
lint_roller (~> 1.1)
118128
rubocop (>= 1.72.1)
119-
rubocop-rspec (3.6.0)
129+
rubocop-rspec (3.9.0)
120130
lint_roller (~> 1.1)
121-
rubocop (~> 1.72, >= 1.72.1)
131+
rubocop (~> 1.81)
122132
ruby-progressbar (1.13.0)
123133
shellany (0.0.1)
124134
simplecov (0.22.0)
@@ -127,10 +137,10 @@ GEM
127137
simplecov_json_formatter (~> 0.1)
128138
simplecov-html (0.13.2)
129139
simplecov_json_formatter (0.1.4)
130-
thor (1.4.0)
131-
unicode-display_width (3.1.5)
132-
unicode-emoji (~> 4.0, >= 4.0.4)
133-
unicode-emoji (4.0.4)
140+
thor (1.5.0)
141+
unicode-display_width (3.2.0)
142+
unicode-emoji (~> 4.1)
143+
unicode-emoji (4.2.0)
134144

135145
PLATFORMS
136146
x86_64-linux

spec/foobara/generators/generate_empty_typescript_react_project_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313
it "generates a empty_typescript_react_project" do
1414
expect(outcome).to be_success
1515

16-
expect(result.keys).to contain_exactly(".env", ".eslintrc.js", ".github/workflows/tests.yml", "tsconfig.json")
16+
expect(result.keys).to contain_exactly(".env", "eslint.config.js", ".github/workflows/tests.yml")
1717
end
1818
end

spec/foobara/generators/write_empty_typescript_react_project_to_disk_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
it "contains base files" do
3232
expect(outcome).to be_success
3333

34-
expect(File.exist?("#{output_directory}/#{project_dir}/.eslintrc.js")).to be(true)
3534
expect(File.exist?("#{output_directory}/#{project_dir}/.github/workflows/tests.yml")).to be(true)
3635
end
3736
end

src/write_empty_typescript_react_project_to_disk.rb

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,18 @@ def generate_file_contents
5454
end
5555

5656
def run_pre_generation_tasks
57-
run_npx_create_react_app
58-
add_necessary_dev_dependencies_for_eslint
59-
fix_uncorrectable_lint_violations
57+
run_npm_create_vite
58+
npm_install
6059
eslint_fix
6160
git_init
6261
git_add_all
63-
git_commit_lint_fixes
62+
git_commit_initial_setup
6463
end
6564

66-
def run_npx_create_react_app
67-
puts "created empty project with create-react-app..."
65+
def run_npm_create_vite
66+
puts "creating empty project with Vite..."
6867

69-
cmd = "npx create-react-app --template typescript #{empty_typescript_react_project_config.project_dir}"
68+
cmd = "npm create vite@latest #{empty_typescript_react_project_config.project_dir} -- --template react-ts"
7069

7170
FileUtils.mkdir_p output_parent_directory
7271

@@ -75,16 +74,10 @@ def run_npx_create_react_app
7574
end
7675
end
7776

78-
def add_necessary_dev_dependencies_for_eslint
79-
puts "adding dependencies needed for linter to actually work..."
77+
def npm_install
78+
puts "installing dependencies..."
8079

81-
cmd = "npm install --save-dev " \
82-
"@babel/plugin-proposal-private-property-in-object@^7.21.11 " \
83-
"@eslint/create-config@^0.4.6 " \
84-
"eslint-config-standard-with-typescript@^37.0.0 " \
85-
"eslint-plugin-n@^16.5.0 " \
86-
"eslint-plugin-promise@^6.1.1 " \
87-
"typescript@^4.0.0 "
80+
cmd = "npm install"
8881

8982
Dir.chdir project_directory do
9083
run_cmd_and_write_output(cmd)
@@ -104,18 +97,10 @@ def run_post_generation_tasks
10497
end
10598
end
10699

107-
def fix_uncorrectable_lint_violations
108-
Dir.chdir(project_directory) do
109-
web_vitals_contents = File.read("src/reportWebVitals.ts")
110-
web_vitals_contents.gsub!("if (onPerfEntry && ", "if (onPerfEntry != null && ")
111-
File.write("src/reportWebVitals.ts", web_vitals_contents)
112-
end
113-
end
114-
115100
def eslint_fix
116101
puts "linting..."
117102

118-
cmd = "npx eslint 'src/**/*.{js,jsx,ts,tsx}' --fix"
103+
cmd = "npx eslint . --fix"
119104
Dir.chdir project_directory do
120105
run_cmd_and_write_output(cmd)
121106
end
@@ -137,8 +122,8 @@ def git_add_all
137122
end
138123
end
139124

140-
def git_commit_lint_fixes
141-
cmd = "git commit -m 'Make project work with eslint and eslint --fix everything'"
125+
def git_commit_initial_setup
126+
cmd = "git commit -m 'Initial Vite project with react-ts template'"
142127

143128
Dir.chdir project_directory do
144129
run_cmd_and_write_output(cmd, raise_if_fails: false)

templates/.eslintrc.js

Lines changed: 0 additions & 45 deletions
This file was deleted.

templates/.github/workflows/tests.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,17 @@ on: push
33
jobs:
44
tests:
55
runs-on: ubuntu-latest
6-
name: run test suite
6+
name: build and lint
77
steps:
8-
- uses: actions/checkout@v2
8+
- uses: actions/checkout@v4
99
- name: Use Node.js
1010
if: always()
11-
uses: actions/setup-node@v2
11+
uses: actions/setup-node@v4
1212
with:
13-
# how to grab this from .nvmrc??
14-
node-version: "20.9"
13+
node-version: "20"
1514
- name: Install dependencies
1615
run: npm install
17-
- name: Run test
18-
run: npm run test
16+
- name: Lint
17+
run: npm run lint
18+
- name: Build
19+
run: npm run build

templates/eslint.config.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import js from '@eslint/js'
2+
import globals from 'globals'
3+
import reactHooks from 'eslint-plugin-react-hooks'
4+
import reactRefresh from 'eslint-plugin-react-refresh'
5+
import tseslint from 'typescript-eslint'
6+
import { defineConfig, globalIgnores } from 'eslint/config'
7+
8+
export default defineConfig([
9+
globalIgnores(['dist']),
10+
{
11+
files: ['**/*.{ts,tsx}'],
12+
extends: [
13+
js.configs.recommended,
14+
tseslint.configs.recommended,
15+
reactHooks.configs.flat.recommended,
16+
reactRefresh.configs.vite,
17+
],
18+
languageOptions: {
19+
ecmaVersion: 2020,
20+
globals: globals.browser,
21+
},
22+
},
23+
{
24+
files: ['src/domains/**/*.{ts,tsx}'],
25+
rules: {
26+
'@typescript-eslint/no-explicit-any': 'off',
27+
'@typescript-eslint/prefer-as-const': 'off',
28+
},
29+
},
30+
])

0 commit comments

Comments
 (0)