datacrafts-io-skeleton 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/Gemfile.lock +2 -2
- data/README.md +8 -1
- data/lib/datacrafts_io_skeleton/composer.rb +31 -7
- data/lib/datacrafts_io_skeleton/helpers.rb +23 -0
- data/lib/datacrafts_io_skeleton/rails_creator.rb +6 -12
- data/lib/datacrafts_io_skeleton/react_creator.rb +65 -0
- data/lib/datacrafts_io_skeleton/version.rb +1 -1
- data/renovate.json +5 -0
- data/templates/eslintrc.js +23 -0
- data/templates/prettierrc.json +6 -0
- data/templates/rails.rb +1 -1
- data/templates/rubocop.yml.erb +1 -0
- data/templates/stylelintrc.json +3 -0
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e084eeb831e90582d312d578e13d6b93da910dae08de6e080509f8a1740742c4
|
4
|
+
data.tar.gz: 841209c86906ad895b93e1deea6e22a8b304ab784f28b56d45023db6cb7b0c68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95d4a8e8cfe849f390ab5bd217da9939ab2a2462d8ccc5ac8629fce038a604c35d9fa8c33fc432651c5e6b3cfe10d042f4bdb275f02365beebf0fb1955ed7bf3
|
7
|
+
data.tar.gz: 388886a4e2af257d7fa352e1eeb9fe1838eea19f36be74c4b42fc8755dc055fdbcacabc3915cfb59ec4c845a252b43186ce28b0935fa14aeba853e7f612e2561
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -117,7 +117,7 @@ GEM
|
|
117
117
|
method_source
|
118
118
|
rake (>= 0.8.7)
|
119
119
|
thor (>= 0.20.3, < 2.0)
|
120
|
-
rake (
|
120
|
+
rake (13.0.1)
|
121
121
|
rspec (3.9.0)
|
122
122
|
rspec-core (~> 3.9.0)
|
123
123
|
rspec-expectations (~> 3.9.0)
|
@@ -152,7 +152,7 @@ PLATFORMS
|
|
152
152
|
|
153
153
|
DEPENDENCIES
|
154
154
|
datacrafts-io-skeleton!
|
155
|
-
rake (~>
|
155
|
+
rake (~> 13.0)
|
156
156
|
rspec (~> 3.0)
|
157
157
|
|
158
158
|
BUNDLED WITH
|
data/README.md
CHANGED
@@ -17,6 +17,14 @@ This command will create new rails app with configured rails_helper.rb and .rubo
|
|
17
17
|
$ datacrafts-io-skeleton create APP_NAME
|
18
18
|
$ datacrafts-io-skeleton build APP_NAME
|
19
19
|
$ datacrafts-io-skeleton new APP_NAME
|
20
|
+
|
21
|
+
### With frontend part.
|
22
|
+
|
23
|
+
You can specify `--frontend (-f) FRONTEND_TYPE` option to additionally create frontend application inside `APP_NAME/frontend` directory. Use `-t` option to add typescript support.
|
24
|
+
|
25
|
+
$ datacrafts-io-skeleton create APP_NAME --frontend react -t
|
26
|
+
|
27
|
+
Allowed frontend types include only `react` for now.
|
20
28
|
|
21
29
|
## Development
|
22
30
|
|
@@ -35,4 +43,3 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
35
43
|
## Code of Conduct
|
36
44
|
|
37
45
|
Everyone interacting in the Skeleton project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/datacrafts-io/skeleton/blob/master/CODE_OF_CONDUCT.md).
|
38
|
-
g
|
@@ -1,34 +1,58 @@
|
|
1
1
|
require "thor"
|
2
2
|
require_relative "./version"
|
3
3
|
require_relative "./rails_creator"
|
4
|
+
require_relative "./react_creator"
|
4
5
|
|
5
6
|
module DatacraftsIoSkeleton
|
6
7
|
# Defines all CLI commands, their descriptions, params and aliases.
|
7
8
|
class Composer < Thor
|
9
|
+
FRONTEND_CREATORS = {
|
10
|
+
"react" => ->(app_name, options) { ReactCreator.new(app_name, options).call },
|
11
|
+
nil => proc { |app_name| puts("The frontend is not specified for #{app_name}") }
|
12
|
+
}.freeze
|
13
|
+
ALLOWED_FRONTEND = FRONTEND_CREATORS.keys.freeze
|
14
|
+
|
8
15
|
desc "create APP_NAME", "This will create new rails app."
|
9
16
|
long_desc <<-CREATE_NEW_APP
|
10
|
-
|
11
|
-
|
17
|
+
This command will create new rails app with configured rails_helper.rb and .rubocop.yml files.
|
18
|
+
All major gems are also included.
|
19
|
+
|
20
|
+
You can use this command with next aliases:\n
|
12
21
|
|
13
|
-
|
22
|
+
`datacrafts-io-skeleton create APPNAME`\n
|
23
|
+
`datacrafts-io-skeleton build APPNAME`\n
|
24
|
+
`datacrafts-io-skeleton new APPNAME`\n
|
25
|
+
|
26
|
+
Skip boring start and let's code amazing stuff together.
|
14
27
|
|
15
|
-
`datacrafts-io-skeleton create APPNAME`\n
|
16
|
-
`datacrafts-io-skeleton build APPNAME`\n
|
17
|
-
`datacrafts-io-skeleton new APPNAME`\n
|
18
28
|
CREATE_NEW_APP
|
29
|
+
option :frontend, type: :string, aliases: [:f], desc: <<~DESC.gsub(/\n/, "").squeeze
|
30
|
+
Additionally creates frontend client app, you can choose one type from the list:
|
31
|
+
#{ALLOWED_FRONTEND.compact.join(', ')}.
|
32
|
+
DESC
|
33
|
+
option :typescipt, type: :boolean, aliases: [:t], desc: "Adds typescript support to frontend application."
|
19
34
|
map %w[new build] => :create
|
20
35
|
# Creates new app.
|
21
36
|
#
|
22
37
|
# @param [String] app_name The name of app you are going to create.
|
23
38
|
def create(app_name)
|
39
|
+
say("The specified frontend is not allowed", :red) && return unless specified_frontend_valid?
|
40
|
+
|
24
41
|
DatacraftsIoSkeleton::RailsCreator.new(app_name).call
|
42
|
+
FRONTEND_CREATORS[options[:frontend]].call(app_name, options)
|
25
43
|
end
|
26
44
|
|
27
45
|
desc "version", "Display version"
|
28
46
|
map %w[-v --version] => :version
|
29
47
|
# Informs user about gem version.
|
30
48
|
def version
|
31
|
-
say
|
49
|
+
say("datacrafts-io-skeleton #{DatacraftsIoSkeleton::VERSION}")
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def specified_frontend_valid?
|
55
|
+
ALLOWED_FRONTEND.include?(options[:frontend])
|
32
56
|
end
|
33
57
|
end
|
34
58
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require "thor"
|
2
|
+
|
3
|
+
module DatacraftsIoSkeleton
|
4
|
+
# Shared logic.
|
5
|
+
module Helpers
|
6
|
+
# Defines gem templates folder which you can use to load template to the new app.
|
7
|
+
TEMPLATES_DIR = (File.dirname(__FILE__) + "/../../templates").freeze
|
8
|
+
|
9
|
+
def self.included(klass)
|
10
|
+
klass.class_eval do
|
11
|
+
include Thor::Actions
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def commit(message, app_path=app)
|
16
|
+
run "cd #{app_path} && git add . && git commit -m '#{message}'"
|
17
|
+
end
|
18
|
+
|
19
|
+
def app(path=nil)
|
20
|
+
"#{@app_name}/#{path}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -1,13 +1,10 @@
|
|
1
1
|
require "thor"
|
2
|
+
require_relative "./helpers"
|
2
3
|
|
3
4
|
module DatacraftsIoSkeleton
|
4
5
|
# Responsible for the creation of rails projects.
|
5
6
|
class RailsCreator < Thor
|
6
|
-
include
|
7
|
-
|
8
|
-
# Defines gem templates folder which you can use to load template to the new app.
|
9
|
-
TEMPLATES_DIR = (File.dirname(__FILE__) + "/../../templates").freeze
|
10
|
-
|
7
|
+
include Helpers
|
11
8
|
source_root TEMPLATES_DIR
|
12
9
|
|
13
10
|
no_commands do
|
@@ -28,6 +25,7 @@ module DatacraftsIoSkeleton
|
|
28
25
|
update_spec_config
|
29
26
|
run_rubocop
|
30
27
|
commit_project
|
28
|
+
say("Rails API part has built.", :green)
|
31
29
|
end
|
32
30
|
end
|
33
31
|
|
@@ -51,16 +49,12 @@ module DatacraftsIoSkeleton
|
|
51
49
|
end
|
52
50
|
|
53
51
|
def run_rubocop
|
54
|
-
run "cd #{app} && rubocop -
|
52
|
+
run "cd #{app} && bundle exec rubocop -A"
|
55
53
|
end
|
56
54
|
|
57
55
|
def commit_project
|
58
|
-
append_to_file app(".gitignore"), "/.idea
|
59
|
-
|
60
|
-
end
|
61
|
-
|
62
|
-
def app(path=nil)
|
63
|
-
"#{@app_name}/#{path}"
|
56
|
+
append_to_file app(".gitignore"), "/.idea/"
|
57
|
+
commit("Initial commit.")
|
64
58
|
end
|
65
59
|
end
|
66
60
|
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require "thor"
|
2
|
+
require_relative "./helpers"
|
3
|
+
|
4
|
+
module DatacraftsIoSkeleton
|
5
|
+
# Responsible for the creation of rails projects.
|
6
|
+
class ReactCreator < Thor
|
7
|
+
include Helpers
|
8
|
+
source_root TEMPLATES_DIR
|
9
|
+
|
10
|
+
DEFAULT_FOLDERS = %w[src/tests src/components].freeze
|
11
|
+
|
12
|
+
no_commands do
|
13
|
+
def initialize(app_name, options)
|
14
|
+
super()
|
15
|
+
@app_name = app_name # We use it to commit changes.
|
16
|
+
@front_name = "#{app_name}/frontend"
|
17
|
+
@ts = options[:typescipt]
|
18
|
+
end
|
19
|
+
|
20
|
+
def call
|
21
|
+
empty_directory @front_name
|
22
|
+
inside @front_name do
|
23
|
+
create_react_app
|
24
|
+
create_default_folders
|
25
|
+
end
|
26
|
+
copy_config_files
|
27
|
+
run_linters
|
28
|
+
commit("React frontend app was added.")
|
29
|
+
say("React frontend part has built.", :green)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
no_commands do
|
36
|
+
def create_react_app
|
37
|
+
run "npx create-react-app . #{@ts && '--template typescript'}"
|
38
|
+
run "npm i -s #{react_libs}"
|
39
|
+
run "npm install"
|
40
|
+
end
|
41
|
+
|
42
|
+
def create_default_folders
|
43
|
+
DEFAULT_FOLDERS.each(&method(:empty_directory))
|
44
|
+
end
|
45
|
+
|
46
|
+
def copy_config_files
|
47
|
+
copy_file "eslintrc.js", app("frontend/.eslintrc.js")
|
48
|
+
copy_file "stylelintrc.json", app("frontend/.stylelintrc")
|
49
|
+
copy_file "prettierrc.json", app("frontend/.prettierrc.json")
|
50
|
+
end
|
51
|
+
|
52
|
+
def run_linters
|
53
|
+
run "cd #{app('frontend')} && npx eslint --quiet --fix --ext ts,tsx,js,jsx src"
|
54
|
+
run "cd #{app('frontend')} && npx stylelint --fix **/*.css"
|
55
|
+
end
|
56
|
+
|
57
|
+
def react_libs
|
58
|
+
%w[axios prettier @typescript-eslint/parser @typescript-eslint/eslint-plugin
|
59
|
+
eslint-plugin-react eslint-config-prettier eslint-plugin-prettier
|
60
|
+
stylelint stylelint-config-standard typescript
|
61
|
+
enzyme @testing-library/react msw].join(" ")
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module.exports = {
|
2
|
+
parser: "@typescript-eslint/parser",
|
3
|
+
parserOptions: {
|
4
|
+
ecmaVersion: 2020,
|
5
|
+
sourceType: "module",
|
6
|
+
ecmaFeatures: {
|
7
|
+
jsx: true
|
8
|
+
}
|
9
|
+
},
|
10
|
+
settings: {
|
11
|
+
react: {
|
12
|
+
version: "detect"
|
13
|
+
}
|
14
|
+
},
|
15
|
+
extends: [
|
16
|
+
"plugin:react/recommended",
|
17
|
+
"plugin:@typescript-eslint/recommended",
|
18
|
+
"prettier/@typescript-eslint",
|
19
|
+
"plugin:prettier/recommended"
|
20
|
+
],
|
21
|
+
rules: {
|
22
|
+
},
|
23
|
+
};
|
data/templates/rails.rb
CHANGED
data/templates/rubocop.yml.erb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: datacrafts-io-skeleton
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roman Ovcharov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -76,11 +76,17 @@ files:
|
|
76
76
|
- exe/datacrafts-io-skeleton
|
77
77
|
- lib/datacrafts_io_skeleton.rb
|
78
78
|
- lib/datacrafts_io_skeleton/composer.rb
|
79
|
+
- lib/datacrafts_io_skeleton/helpers.rb
|
79
80
|
- lib/datacrafts_io_skeleton/rails_creator.rb
|
81
|
+
- lib/datacrafts_io_skeleton/react_creator.rb
|
80
82
|
- lib/datacrafts_io_skeleton/version.rb
|
83
|
+
- renovate.json
|
84
|
+
- templates/eslintrc.js
|
85
|
+
- templates/prettierrc.json
|
81
86
|
- templates/rails.rb
|
82
87
|
- templates/rubocop.yml.erb
|
83
88
|
- templates/spec.rb
|
89
|
+
- templates/stylelintrc.json
|
84
90
|
homepage: https://github.com/datacrafts-io/skeleton
|
85
91
|
licenses:
|
86
92
|
- MIT
|