Skip to content

Commit c3d6858

Browse files
authored
tools: remove the src subdir from projects, created by v new (#24236)
1 parent e972860 commit c3d6858

4 files changed

Lines changed: 27 additions & 27 deletions

File tree

‎cmd/tools/vcreate/project_model_bin.v‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import os
55
fn (mut c Create) set_bin_project_files() {
66
base := if c.new_dir { c.name } else { '' }
77
c.files << ProjectFiles{
8-
path: os.join_path(base, 'src', 'main.v')
8+
path: os.join_path(base, 'main.v')
99
content: "module main
1010
1111
fn main() {

‎cmd/tools/vcreate/project_model_lib.v‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import os
55
fn (mut c Create) set_lib_project_files() {
66
base := if c.new_dir { c.name } else { '' }
77
c.files << ProjectFiles{
8-
path: os.join_path(base, 'src', c.name + '.v')
8+
path: os.join_path(base, c.name + '.v')
99
content: 'module ${c.name}
1010
1111
// square calculates the second power of `x`

‎cmd/tools/vcreate/project_model_web.v‎

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import os { join_path }
55
fn (mut c Create) set_web_project_files() {
66
base := if c.new_dir { c.name } else { '' }
77
c.files << ProjectFiles{
8-
path: join_path(base, 'src', 'databases', 'config_databases_sqlite.v')
8+
path: join_path(base, 'databases', 'config_databases_sqlite.v')
99
content: "module databases
1010
1111
import db.sqlite // can change to 'db.mysql', 'db.pg'
@@ -17,14 +17,14 @@ pub fn create_db_connection() !sqlite.DB {
1717
"
1818
}
1919
c.files << ProjectFiles{
20-
path: join_path(base, 'src', 'templates', 'header_component.html')
20+
path: join_path(base, 'templates', 'header_component.html')
2121
content: "<nav>
2222
<div class='nav-wrapper'>
2323
<a href='javascript:window.history.back();' class='left'>
2424
<i class='material-icons'>arrow_back_ios_new</i>
2525
</a>
2626
<a href='/'>
27-
<img src='src/assets/veasel.png' alt='logo' style='max-height: 100%' />
27+
<img src='assets/veasel.png' alt='logo' style='max-height: 100%' />
2828
</a>
2929
<ul id='nav-mobile' class='right'>
3030
<li><a href='https://github.com/vlang/v'>github</a></li>
@@ -36,7 +36,7 @@ pub fn create_db_connection() !sqlite.DB {
3636
"
3737
}
3838
c.files << ProjectFiles{
39-
path: join_path(base, 'src', 'templates', 'products.css')
39+
path: join_path(base, 'templates', 'products.css')
4040
content: 'h1.title {
4141
font-family: Arial, Helvetica, sans-serif;
4242
color: #3b7bbf;
@@ -50,7 +50,7 @@ div.products-table {
5050
}'
5151
}
5252
c.files << ProjectFiles{
53-
path: join_path(base, 'src', 'templates', 'products.html')
53+
path: join_path(base, 'templates', 'products.html')
5454
content: "<!DOCTYPE html>
5555
<html>
5656
<head>
@@ -67,7 +67,7 @@ div.products-table {
6767
<link href='https://fonts.googleapis.com/icon?family=Material+Icons' rel='stylesheet'>
6868
6969
<title>Login</title>
70-
@css 'src/templates/products.css'
70+
@css 'templates/products.css'
7171
</head>
7272
<body>
7373
<div>@include 'header_component.html'</div>
@@ -147,7 +147,7 @@ div.products-table {
147147
</html>"
148148
}
149149
c.files << ProjectFiles{
150-
path: join_path(base, 'src', 'auth_controllers.v')
150+
path: join_path(base, 'auth_controllers.v')
151151
content: "module main
152152
153153
import vweb
@@ -164,7 +164,7 @@ pub fn (mut app App) controller_auth(username string, password string) vweb.Resu
164164
"
165165
}
166166
c.files << ProjectFiles{
167-
path: join_path(base, 'src', 'auth_dto.v')
167+
path: join_path(base, 'auth_dto.v')
168168
content: 'module main
169169
170170
struct AuthRequestDto {
@@ -174,7 +174,7 @@ struct AuthRequestDto {
174174
'
175175
}
176176
c.files << ProjectFiles{
177-
path: join_path(base, 'src', 'auth_services.v')
177+
path: join_path(base, 'auth_services.v')
178178
content: "module main
179179
180180
import crypto.hmac
@@ -269,7 +269,7 @@ fn auth_verify(token string) bool {
269269
"
270270
}
271271
c.files << ProjectFiles{
272-
path: join_path(base, 'src', 'index.html')
272+
path: join_path(base, 'index.html')
273273
content: "<!DOCTYPE html>
274274
<html>
275275
<head>
@@ -348,7 +348,7 @@ fn auth_verify(token string) bool {
348348
"
349349
}
350350
c.files << ProjectFiles{
351-
path: join_path(base, 'src', 'main.v')
351+
path: join_path(base, 'main.v')
352352
content: "module main
353353
354354
import vweb
@@ -376,7 +376,7 @@ fn main() {
376376
db.close() or { panic(err) }
377377
378378
mut app := &App{}
379-
app.serve_static('/favicon.ico', 'src/assets/favicon.ico')
379+
app.serve_static('/favicon.ico', 'assets/favicon.ico')
380380
// makes all static files available.
381381
app.mount_static_folder_at(os.resource_abs_path('.'), '/')
382382
@@ -391,7 +391,7 @@ pub fn (mut app App) index() vweb.Result {
391391
"
392392
}
393393
c.files << ProjectFiles{
394-
path: join_path(base, 'src', 'product_controller.v')
394+
path: join_path(base, 'product_controller.v')
395395
content: "module main
396396
397397
import vweb
@@ -457,7 +457,7 @@ pub fn (mut app App) controller_create_product(product_name string) vweb.Result
457457
"
458458
}
459459
c.files << ProjectFiles{
460-
path: join_path(base, 'src', 'product_entities.v')
460+
path: join_path(base, 'product_entities.v')
461461
content: "module main
462462
463463
@[table: 'products']
@@ -470,7 +470,7 @@ struct Product {
470470
"
471471
}
472472
c.files << ProjectFiles{
473-
path: join_path(base, 'src', 'product_service.v')
473+
path: join_path(base, 'product_service.v')
474474
content: "module main
475475
476476
import databases
@@ -517,7 +517,7 @@ fn (mut app App) service_get_all_products_from(user_id int) ![]Product {
517517
"
518518
}
519519
c.files << ProjectFiles{
520-
path: join_path(base, 'src', 'product_view_api.v')
520+
path: join_path(base, 'product_view_api.v')
521521
content: "module main
522522
523523
import json
@@ -556,7 +556,7 @@ pub fn get_product(token string) ![]User {
556556
"
557557
}
558558
c.files << ProjectFiles{
559-
path: join_path(base, 'src', 'product_view.v')
559+
path: join_path(base, 'product_view.v')
560560
content: "module main
561561
562562
import vweb
@@ -578,7 +578,7 @@ pub fn (mut app App) products() !vweb.Result {
578578
"
579579
}
580580
c.files << ProjectFiles{
581-
path: join_path(base, 'src', 'user_controllers.v')
581+
path: join_path(base, 'user_controllers.v')
582582
content: "module main
583583
584584
import vweb
@@ -648,7 +648,7 @@ pub fn (mut app App) controller_create_user(username string, password string) vw
648648
"
649649
}
650650
c.files << ProjectFiles{
651-
path: join_path(base, 'src', 'user_entities.v')
651+
path: join_path(base, 'user_entities.v')
652652
content: "module main
653653
654654
@[table: 'users']
@@ -663,7 +663,7 @@ mut:
663663
"
664664
}
665665
c.files << ProjectFiles{
666-
path: join_path(base, 'src', 'user_services.v')
666+
path: join_path(base, 'user_services.v')
667667
content: "module main
668668
669669
import crypto.bcrypt
@@ -732,7 +732,7 @@ fn (mut app App) service_get_user(id int) !User {
732732
"
733733
}
734734
c.files << ProjectFiles{
735-
path: join_path(base, 'src', 'user_view_api.v')
735+
path: join_path(base, 'user_view_api.v')
736736
content: "module main
737737
738738
import json

‎cmd/tools/vcreate/vcreate_init_test.v‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ fn init_and_check() ! {
2424
os.chdir(test_path)!
2525

2626
// Keep track of the last modified time of the main file to ensure it is not modified if it already exists.
27-
main_exists := os.exists('src/main.v')
28-
main_last_modified := if main_exists { os.file_last_mod_unix('src/main.v') } else { 0 }
27+
main_exists := os.exists('main.v')
28+
main_last_modified := if main_exists { os.file_last_mod_unix('main.v') } else { 0 }
2929

3030
// Initialize project.
3131
os.execute_or_exit('${expect_exe} ${os.join_path(expect_tests_path, 'init.expect')} ${vroot}')
@@ -34,9 +34,9 @@ fn init_and_check() ! {
3434
assert x.output.trim_space() == 'Hello World!'
3535

3636
if main_exists {
37-
assert main_last_modified == os.file_last_mod_unix('src/main.v')
37+
assert main_last_modified == os.file_last_mod_unix('main.v')
3838
} else {
39-
assert os.read_file('src/main.v')! == [
39+
assert os.read_file('main.v')! == [
4040
'module main\n',
4141
'fn main() {',
4242
" println('Hello World!')",

0 commit comments

Comments
 (0)