Skip to content

Commit

Permalink
feat(cli): add EditorConfig files to project template
Browse files Browse the repository at this point in the history
Signed-off-by: Rifa Achrinza <[email protected]>
  • Loading branch information
achrinza committed Nov 19, 2024
1 parent e32c050 commit b6d82f9
Show file tree
Hide file tree
Showing 34 changed files with 261 additions and 1 deletion.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 2
max_line_length = 80
4 changes: 4 additions & 0 deletions docs/site/Application-generator.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ lb4 [app] [options] [<name>]
`--loopbackBuild` : Add @loopback/build module's script set to LoopBack4
application project.

`--editorconfig` : Add EditorConfig config files to the LoopBack4 application
project.

`--vscode`: Add VSCode config files to LoopBack4 application project

`--docker`: Generate Dockerfile and add npm scripts to build/run the project in
Expand Down Expand Up @@ -70,6 +73,7 @@ The tool will prompt you for:
- [`prettier`](https://www.npmjs.com/package/prettier)
- [`mocha`](https://www.npmjs.com/package/mocha)
- [`@loopback/build`](https://www.npmjs.com/package/@loopback/build)
- [`editorconfig`](https://editorconfig.org/)
- [`vscode`](https://code.visualstudio.com/)

### Output
Expand Down
1 change: 1 addition & 0 deletions docs/site/Getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Answer the prompts as follows:
◉ Enable prettier: install prettier to format code conforming to rules
◉ Enable mocha: install mocha to run tests
◉ Enable loopbackBuild: use @loopback/build helpers (e.g. lb-eslint)
◉ Enable editorconfig: add EditorConfig files
◉ Enable vscode: add VSCode config files
◉ Enable docker: include Dockerfile and .dockerignore
◉ Enable repositories: include repository imports and RepositoryMixin
Expand Down
1 change: 1 addition & 0 deletions docs/site/deployment/Deploying_to_ibm_cloud_kubernetes.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ $ lb4 app
◉ Enable prettier: install prettier to format code conforming to rules
◉ Enable mocha: install mocha to run tests
◉ Enable loopbackBuild: use @loopback/build helpers (e.g. lb-eslint)
◉ Enable editorconfig: add EditorConfig files
◉ Enable vscode: add VSCode config files
◉ Enable docker: include Dockerfile and .dockerignore
◉ Enable repositories: include repository imports and RepositoryMixin
Expand Down
1 change: 1 addition & 0 deletions docs/site/tutorials/connectors/Mysql-tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ le all, <i> to invert selection)
◉ Enable prettier: install prettier to format code conforming to rules
◉ Enable mocha: install mocha to run tests
◉ Enable loopbackBuild: use @loopback/build helpers (e.g. lb-eslint)
◉ Enable editorconfig: add EditorConfig files
◉ Enable vscode: add VSCode config files
◉ Enable docker: include Dockerfile and .dockerignore
◉ Enable repositories: include repository imports and RepositoryMixin
Expand Down
1 change: 1 addition & 0 deletions docs/site/tutorials/connectors/Postgresql-tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ le all, <i> to invert selection)
◉ Enable prettier: install prettier to format code conforming to rules
◉ Enable mocha: install mocha to run tests
◉ Enable loopbackBuild: use @loopback/build helpers (e.g. lb-eslint)
◉ Enable editorconfig: add EditorConfig files
◉ Enable vscode: add VSCode config files
◉ Enable docker: include Dockerfile and .dockerignore
◉ Enable repositories: include repository imports and RepositoryMixin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Enable all options besides `docker`, unless you know what you are doing, see
◉ Enable prettier: install prettier to format code conforming to rules
◉ Enable mocha: install mocha to run tests
◉ Enable loopbackBuild: use @loopback/build helpers (e.g. lb-eslint)
◉ Enable editorconfig: add EditorConfig files
◉ Enable vscode: add VSCode config files
❯◯ Enable docker: include Dockerfile and .dockerignore
◉ Enable repositories: include repository imports and RepositoryMixin
Expand Down
1 change: 1 addition & 0 deletions docs/site/tutorials/todo/todo-tutorial-scaffolding.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ $ lb4 app
◉ Enable prettier: install prettier to format code conforming to rules
◉ Enable mocha: install mocha to run tests
◉ Enable loopbackBuild: use @loopback/build helpers (e.g. lb-eslint)
◉ Enable editorconfig: add EditorConfig files
◉ Enable vscode: add VSCode config files
◉ Enable docker: include Dockerfile and .dockerignore
◉ Enable repositories: include repository imports and RepositoryMixin
Expand Down
9 changes: 9 additions & 0 deletions examples/access-control-migration/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 2
max_line_length = 80
9 changes: 9 additions & 0 deletions examples/binding-resolution/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 2
max_line_length = 80
9 changes: 9 additions & 0 deletions examples/context/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 2
max_line_length = 80
9 changes: 9 additions & 0 deletions examples/express-composition/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 2
max_line_length = 80
9 changes: 9 additions & 0 deletions examples/file-transfer/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 2
max_line_length = 80
9 changes: 9 additions & 0 deletions examples/graphql/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 2
max_line_length = 80
9 changes: 9 additions & 0 deletions examples/greeter-extension/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 2
max_line_length = 80
9 changes: 9 additions & 0 deletions examples/greeting-app/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 2
max_line_length = 80
9 changes: 9 additions & 0 deletions examples/hello-world/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 2
max_line_length = 80
9 changes: 9 additions & 0 deletions examples/lb3-application/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 2
max_line_length = 80
9 changes: 9 additions & 0 deletions examples/log-extension/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 2
max_line_length = 80
9 changes: 9 additions & 0 deletions examples/metrics-prometheus/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 2
max_line_length = 80
9 changes: 9 additions & 0 deletions examples/multi-tenancy/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 2
max_line_length = 80
9 changes: 9 additions & 0 deletions examples/passport-login/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 2
max_line_length = 80
9 changes: 9 additions & 0 deletions examples/references-many/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 2
max_line_length = 80
9 changes: 9 additions & 0 deletions examples/rest-crud/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 2
max_line_length = 80
9 changes: 9 additions & 0 deletions examples/rpc-server/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 2
max_line_length = 80
9 changes: 9 additions & 0 deletions examples/soap-calculator/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 2
max_line_length = 80
9 changes: 9 additions & 0 deletions examples/socketio/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 2
max_line_length = 80
9 changes: 9 additions & 0 deletions examples/todo-jwt/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 2
max_line_length = 80
9 changes: 9 additions & 0 deletions examples/todo-list/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 2
max_line_length = 80
9 changes: 9 additions & 0 deletions examples/todo/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 2
max_line_length = 80
9 changes: 9 additions & 0 deletions examples/validation-app/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 2
max_line_length = 80
9 changes: 9 additions & 0 deletions examples/webpack/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 2
max_line_length = 80
9 changes: 9 additions & 0 deletions packages/cli/generators/project/templates/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 2
max_line_length = 80
18 changes: 17 additions & 1 deletion packages/cli/lib/project-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,14 @@ module.exports = class ProjectGenerator extends BaseGenerator {
name: 'loopbackBuild',
description: g.f('use @loopback/build helpers (e.g. lb-eslint)'),
},
{name: 'vscode', description: g.f('add VSCode config files')},
{
name: 'editorconfig',
description: g.f('add EditorConfig files'),
},
{
name: 'vscode',
description: g.f('add VSCode config files'),
},
];
}

Expand Down Expand Up @@ -77,6 +84,11 @@ module.exports = class ProjectGenerator extends BaseGenerator {
description: g.f('Use @loopback/build'),
});

this.option('editorconfig', {
type: Boolean,
description: g.f('Use preconfigured EditorConfig settings'),
});

this.option('vscode', {
type: Boolean,
description: g.f('Use preconfigured VSCode settings'),
Expand Down Expand Up @@ -301,6 +313,10 @@ module.exports = class ProjectGenerator extends BaseGenerator {
this.fs.delete(this.destinationPath('.mocharc.json'));
}

if (!this.projectInfo.editorconfig) {
this.fs.delete(this.destinationPath('.editorconfig'));
}

if (!this.projectInfo.vscode) {
this.fs.delete(this.destinationPath('.vscode'));
}
Expand Down

0 comments on commit b6d82f9

Please sign in to comment.