mogu 0.3.2 → 0.6.0
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/.devcontainer/devcontainer.json +39 -0
- data/.devcontainer/docker-compose.yml +38 -0
- data/.gitignore +2 -0
- data/README.md +10 -3
- data/{docker-compose.yml → compose.yaml} +0 -4
- data/lib/mogu/cli.rb +11 -13
- data/lib/mogu/prompt.rb +64 -47
- data/lib/mogu/template.rb +15 -6
- data/lib/mogu/version.rb +1 -1
- data/mogu.gemspec +1 -0
- metadata +20 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5043094005d94e801e049d1a6a03689deee2ded40a10703feb2b1dbb5cda5df0
|
4
|
+
data.tar.gz: 3bc7f43bc271f0a32bbd3cf282020e6dbae6c6970975d3569ca796b379ea0757
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07de320e8f7c9c8fdb96f85c78b69a8089711474f0727648701906d2f8e4dcf8959136a063058e835999e2541008c3577a18fee4a1db62a8b148eb3855ca874e
|
7
|
+
data.tar.gz: 00a5c8bd2bba6b3ad8c75b6df01f0f9088d9ea10807b8798a7d043d5e2553eaee40295ff17405cd5bdf2349c5c549e35ed7c9e12f959b79e37d035d8d912beff
|
@@ -0,0 +1,39 @@
|
|
1
|
+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
|
2
|
+
// https://github.com/microsoft/vscode-dev-containers/tree/v0.231.2/containers/docker-existing-docker-compose
|
3
|
+
// If you want to run as a non-root user in the container, see .devcontainer/docker-compose.yml.
|
4
|
+
{
|
5
|
+
"name": "Existing Docker Compose (Extend)",
|
6
|
+
|
7
|
+
// Update the 'dockerComposeFile' list if you have more compose files or use different names.
|
8
|
+
// The .devcontainer/docker-compose.yml file contains any overrides you need/want to make.
|
9
|
+
"dockerComposeFile": ["../compose.yaml", "docker-compose.yml"],
|
10
|
+
|
11
|
+
// The 'service' property is the name of the service for the container that VS Code should
|
12
|
+
// use. Update this value and .devcontainer/docker-compose.yml to the real service name.
|
13
|
+
"service": "ruby",
|
14
|
+
|
15
|
+
// The optional 'workspaceFolder' property is the path VS Code should open by default when
|
16
|
+
// connected. This is typically a file mount in .devcontainer/docker-compose.yml
|
17
|
+
"workspaceFolder": "/workspace",
|
18
|
+
|
19
|
+
// Set *default* container specific settings.json values on container create.
|
20
|
+
"settings": {},
|
21
|
+
|
22
|
+
// Add the IDs of extensions you want installed when the container is created.
|
23
|
+
"extensions": ["castwide.solargraph"]
|
24
|
+
|
25
|
+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
26
|
+
// "forwardPorts": [],
|
27
|
+
|
28
|
+
// Uncomment the next line if you want start specific services in your Docker Compose config.
|
29
|
+
// "runServices": [],
|
30
|
+
|
31
|
+
// Uncomment the next line if you want to keep your containers running after VS Code shuts down.
|
32
|
+
// "shutdownAction": "none",
|
33
|
+
|
34
|
+
// Uncomment the next line to run commands after the container is created - for example installing curl.
|
35
|
+
// "postCreateCommand": "apt-get update && apt-get install -y curl",
|
36
|
+
|
37
|
+
// Uncomment to connect as a non-root user if you've added one. See https://aka.ms/vscode-remote/containers/non-root.
|
38
|
+
// "remoteUser": "vscode"
|
39
|
+
}
|
@@ -0,0 +1,38 @@
|
|
1
|
+
version: '3.8'
|
2
|
+
services:
|
3
|
+
# Update this to the name of the service you want to work with in your docker-compose.yml file
|
4
|
+
ruby:
|
5
|
+
# If you want add a non-root user to your Dockerfile, you can use the "remoteUser"
|
6
|
+
# property in devcontainer.json to cause VS Code its sub-processes (terminals, tasks,
|
7
|
+
# debugging) to execute as the user. Uncomment the next line if you want the entire
|
8
|
+
# container to run as this user instead. Note that, on Linux, you may need to
|
9
|
+
# ensure the UID and GID of the container user you create matches your local user.
|
10
|
+
# See https://aka.ms/vscode-remote/containers/non-root for details.
|
11
|
+
#
|
12
|
+
# user: vscode
|
13
|
+
|
14
|
+
# Uncomment if you want to override the service's Dockerfile to one in the .devcontainer
|
15
|
+
# folder. Note that the path of the Dockerfile and context is relative to the *primary*
|
16
|
+
# docker-compose.yml file (the first in the devcontainer.json "dockerComposeFile"
|
17
|
+
# array). The sample below assumes your primary file is in the root of your project.
|
18
|
+
#
|
19
|
+
# build:
|
20
|
+
# context: .
|
21
|
+
# dockerfile: .devcontainer/Dockerfile
|
22
|
+
|
23
|
+
volumes:
|
24
|
+
# Update this to wherever you want VS Code to mount the folder of your project
|
25
|
+
- .:/workspace:cached
|
26
|
+
|
27
|
+
# Uncomment the next line to use Docker from inside the container. See https://aka.ms/vscode-remote/samples/docker-from-docker-compose for details.
|
28
|
+
# - /var/run/docker.sock:/var/run/docker.sock
|
29
|
+
|
30
|
+
# Uncomment the next four lines if you will use a ptrace-based debugger like C++, Go, and Rust.
|
31
|
+
# cap_add:
|
32
|
+
# - SYS_PTRACE
|
33
|
+
# security_opt:
|
34
|
+
# - seccomp:unconfined
|
35
|
+
|
36
|
+
# Overrides default command so things don't shut down after the process ends.
|
37
|
+
command: /bin/sh -c "while sleep 1000; do :; done"
|
38
|
+
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -8,7 +8,11 @@ CLI to create rails projects interactively.
|
|
8
8
|
|
9
9
|
## Features
|
10
10
|
|
11
|
-
- Support
|
11
|
+
- Support in selecting rails new options
|
12
|
+
- database
|
13
|
+
- javascript
|
14
|
+
- css
|
15
|
+
- Support in adding gems
|
12
16
|
|
13
17
|
## Installation
|
14
18
|
|
@@ -25,9 +29,11 @@ mogu
|
|
25
29
|
```bash
|
26
30
|
Please input app path
|
27
31
|
|
32
|
+
Do you want api mode? (y/N)
|
33
|
+
|
28
34
|
Choose customizes
|
29
|
-
> ⬡ database
|
30
|
-
⬡ javascript
|
35
|
+
> ⬡ database (Default: sqlite3)
|
36
|
+
⬡ javascript (Default: importmap)
|
31
37
|
⬡ css
|
32
38
|
⬡ gems
|
33
39
|
|
@@ -52,6 +58,7 @@ Choose css
|
|
52
58
|
|
53
59
|
Choose gems
|
54
60
|
> ⬡ brakeman
|
61
|
+
⬡ solargraph
|
55
62
|
⬡ rspec
|
56
63
|
⬡ rubocop
|
57
64
|
```
|
data/lib/mogu/cli.rb
CHANGED
@@ -1,23 +1,21 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'optparse'
|
4
3
|
require 'rails/command'
|
4
|
+
require 'thor'
|
5
5
|
|
6
6
|
module Mogu
|
7
|
-
class CLI
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
class CLI < Thor
|
8
|
+
desc 'new', 'Create rails projects interactively'
|
9
|
+
def new
|
10
|
+
prompt = Mogu::Prompt.new
|
11
|
+
prompt.run
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
else
|
15
|
-
prompt = Mogu::Prompt.new
|
16
|
-
prompt.run
|
13
|
+
Rails::Command.invoke :application, ['new', *prompt.to_opt]
|
14
|
+
end
|
17
15
|
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
desc 'version', 'Display mogu version'
|
17
|
+
def version
|
18
|
+
puts Mogu::VERSION
|
21
19
|
end
|
22
20
|
end
|
23
21
|
end
|
data/lib/mogu/prompt.rb
CHANGED
@@ -4,107 +4,124 @@ require 'tty-prompt'
|
|
4
4
|
|
5
5
|
module Mogu
|
6
6
|
class Prompt
|
7
|
-
|
7
|
+
Result = Struct.new(
|
8
|
+
:app_path,
|
9
|
+
:is_api,
|
10
|
+
:customizes,
|
11
|
+
:database,
|
12
|
+
:javascript,
|
13
|
+
:css,
|
14
|
+
:gems,
|
15
|
+
:template,
|
16
|
+
keyword_init: true
|
17
|
+
)
|
8
18
|
|
9
19
|
def initialize
|
10
20
|
@prompt = TTY::Prompt.new
|
11
21
|
|
12
|
-
result =
|
13
|
-
|
22
|
+
@result = Result.new(
|
23
|
+
app_path: '',
|
24
|
+
is_api: false,
|
25
|
+
customizes: [],
|
26
|
+
database: '',
|
27
|
+
javascript: '',
|
28
|
+
css: '',
|
29
|
+
gems: [],
|
30
|
+
template: nil
|
31
|
+
)
|
14
32
|
end
|
15
33
|
|
16
34
|
def run
|
17
|
-
result.app_path =
|
18
|
-
result.
|
19
|
-
|
20
|
-
|
21
|
-
result.
|
22
|
-
result.
|
23
|
-
result.
|
24
|
-
result.
|
35
|
+
@result.app_path = @prompt.ask 'Please input app path', required: true
|
36
|
+
@result.is_api = @prompt.yes? 'Do you want api mode?', default: false
|
37
|
+
@result.customizes = customizes
|
38
|
+
|
39
|
+
@result.database = database if database?
|
40
|
+
@result.javascript = javascript if javascript?
|
41
|
+
@result.css = css if css?
|
42
|
+
@result.gems = gems if gems?
|
43
|
+
@result.template = Mogu::Template.create @result.gems if template?
|
25
44
|
end
|
26
45
|
|
27
46
|
def to_opt
|
28
|
-
[
|
29
|
-
|
30
|
-
|
31
|
-
|
47
|
+
[
|
48
|
+
@result.app_path,
|
49
|
+
@result.is_api ? ['--api'] : [],
|
50
|
+
database? ? ['-d', @result.database] : [],
|
51
|
+
javascript? ? ['-j', @result.javascript] : [],
|
52
|
+
css? ? ['-c', @result.css] : [],
|
32
53
|
rspec? ? %w[-T] : [],
|
33
|
-
template? ? ['-m', result.template.
|
54
|
+
template? ? ['-m', @result.template.path] : []
|
34
55
|
].flatten
|
35
56
|
end
|
36
57
|
|
37
58
|
private
|
38
59
|
|
39
60
|
def database?
|
40
|
-
result.customizes.include? 'database'
|
61
|
+
@result.customizes.include? 'database'
|
41
62
|
end
|
42
63
|
|
43
64
|
def javascript?
|
44
|
-
result.customizes.include? 'javascript'
|
65
|
+
@result.customizes.include? 'javascript'
|
45
66
|
end
|
46
67
|
|
47
68
|
def css?
|
48
|
-
result.customizes.include? 'css'
|
69
|
+
@result.customizes.include? 'css'
|
49
70
|
end
|
50
71
|
|
51
72
|
def gems?
|
52
|
-
result.customizes.include? 'gems'
|
53
|
-
end
|
54
|
-
|
55
|
-
def brakeman?
|
56
|
-
result.gems.include? 'brakeman'
|
73
|
+
@result.customizes.include? 'gems'
|
57
74
|
end
|
58
75
|
|
59
76
|
def rspec?
|
60
|
-
result.gems.include? 'rspec'
|
61
|
-
end
|
62
|
-
|
63
|
-
def rubocop?
|
64
|
-
result.gems.include? 'rubocop'
|
77
|
+
@result.gems.include? 'rspec'
|
65
78
|
end
|
66
79
|
|
67
80
|
def template?
|
68
|
-
|
69
|
-
end
|
70
|
-
|
71
|
-
def app_path
|
72
|
-
prompt.ask 'Please input app path', required: true
|
81
|
+
@result.gems.any?
|
73
82
|
end
|
74
83
|
|
75
84
|
def css
|
76
85
|
choices = %w[tailwind bootstrap bulma postcss sass]
|
77
86
|
|
78
|
-
prompt.select 'Choose css', choices
|
87
|
+
@prompt.select 'Choose css', choices
|
79
88
|
end
|
80
89
|
|
81
90
|
def customizes
|
82
|
-
choices =
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
91
|
+
choices =
|
92
|
+
if @result.is_api
|
93
|
+
[
|
94
|
+
{ name: 'database (Default: sqlite3)', value: 'database' },
|
95
|
+
{ name: 'gems', value: 'gems' }
|
96
|
+
]
|
97
|
+
else
|
98
|
+
[
|
99
|
+
{ name: 'database (Default: sqlite3)', value: 'database' },
|
100
|
+
{ name: 'javascript (Default: importmap)', value: 'javascript' },
|
101
|
+
{ name: 'css', value: 'css' },
|
102
|
+
{ name: 'gems', value: 'gems' }
|
103
|
+
]
|
104
|
+
end
|
105
|
+
|
106
|
+
@prompt.multi_select 'Choose customizes', choices
|
90
107
|
end
|
91
108
|
|
92
109
|
def database
|
93
110
|
choices = %w[sqlite3 mysql postgresql oracle sqlserver jdbcmysql jdbcsqlite3 jdbcpostgresql jdbc]
|
94
111
|
|
95
|
-
prompt.select 'Choose database', choices
|
112
|
+
@prompt.select 'Choose database', choices
|
96
113
|
end
|
97
114
|
|
98
115
|
def gems
|
99
|
-
choices = %w[brakeman rspec rubocop]
|
116
|
+
choices = %w[brakeman solargraph rspec rubocop]
|
100
117
|
|
101
|
-
prompt.multi_select 'Choose gems', choices
|
118
|
+
@prompt.multi_select 'Choose gems', choices
|
102
119
|
end
|
103
120
|
|
104
121
|
def javascript
|
105
122
|
choices = %w[importmap webpack esbuild rollup]
|
106
123
|
|
107
|
-
prompt.select 'Choose javascript', choices
|
124
|
+
@prompt.select 'Choose javascript', choices
|
108
125
|
end
|
109
126
|
end
|
110
127
|
end
|
data/lib/mogu/template.rb
CHANGED
@@ -4,8 +4,6 @@ require 'tempfile'
|
|
4
4
|
|
5
5
|
module Mogu
|
6
6
|
class Template
|
7
|
-
attr_reader :file
|
8
|
-
|
9
7
|
class << self
|
10
8
|
def create(gems)
|
11
9
|
template = new
|
@@ -19,12 +17,17 @@ module Mogu
|
|
19
17
|
@file = Tempfile.new
|
20
18
|
end
|
21
19
|
|
20
|
+
def path
|
21
|
+
@file.path
|
22
|
+
end
|
23
|
+
|
22
24
|
def write(gems)
|
23
|
-
file.write brakeman_code if gems.include? 'brakeman'
|
24
|
-
file.write
|
25
|
-
file.write
|
25
|
+
@file.write brakeman_code if gems.include? 'brakeman'
|
26
|
+
@file.write solargraph_code if gems.include? 'solargraph'
|
27
|
+
@file.write rspec_code if gems.include? 'rspec'
|
28
|
+
@file.write rubocop_code if gems.include? 'rubocop'
|
26
29
|
|
27
|
-
file.rewind
|
30
|
+
@file.rewind
|
28
31
|
end
|
29
32
|
|
30
33
|
private
|
@@ -35,6 +38,12 @@ module Mogu
|
|
35
38
|
CODE
|
36
39
|
end
|
37
40
|
|
41
|
+
def solargraph_code
|
42
|
+
<<~CODE
|
43
|
+
gem 'solargraph', group: :development
|
44
|
+
CODE
|
45
|
+
end
|
46
|
+
|
38
47
|
def rspec_code
|
39
48
|
<<~CODE
|
40
49
|
gem 'factory_bot_rails', group: %i[development test]
|
data/lib/mogu/version.rb
CHANGED
data/mogu.gemspec
CHANGED
@@ -33,6 +33,7 @@ Gem::Specification.new do |spec|
|
|
33
33
|
|
34
34
|
# Uncomment to register a new dependency of your gem
|
35
35
|
spec.add_dependency 'railties', '~> 7.0'
|
36
|
+
spec.add_dependency 'thor', '~> 1.0'
|
36
37
|
spec.add_dependency 'tty-prompt', '~> 0.23'
|
37
38
|
|
38
39
|
# For more information and examples about making a new gem, checkout our
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mogu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- MoguraStore
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-03
|
11
|
+
date: 2022-04-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '7.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: thor
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: tty-prompt
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -46,6 +60,8 @@ executables:
|
|
46
60
|
extensions: []
|
47
61
|
extra_rdoc_files: []
|
48
62
|
files:
|
63
|
+
- ".devcontainer/devcontainer.json"
|
64
|
+
- ".devcontainer/docker-compose.yml"
|
49
65
|
- ".github/workflows/ci.yml"
|
50
66
|
- ".gitignore"
|
51
67
|
- ".rspec"
|
@@ -57,7 +73,7 @@ files:
|
|
57
73
|
- Rakefile
|
58
74
|
- bin/console
|
59
75
|
- bin/setup
|
60
|
-
-
|
76
|
+
- compose.yaml
|
61
77
|
- exe/mogu
|
62
78
|
- lib/mogu.rb
|
63
79
|
- lib/mogu/cli.rb
|
@@ -87,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
87
103
|
- !ruby/object:Gem::Version
|
88
104
|
version: '0'
|
89
105
|
requirements: []
|
90
|
-
rubygems_version: 3.
|
106
|
+
rubygems_version: 3.3.7
|
91
107
|
signing_key:
|
92
108
|
specification_version: 4
|
93
109
|
summary: CLI to create rails projects interactively.
|