twenty-cli 0.3.4 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/twenty +1 -1
- data/lib/{twenty-cli → twenty/cli}/command/connect.rb +4 -3
- data/lib/{twenty-cli → twenty/cli}/command/console.rb +2 -1
- data/lib/{twenty-cli → twenty/cli}/command/disconnect.rb +6 -2
- data/lib/twenty/cli/command/down.rb +33 -0
- data/lib/{twenty-cli → twenty/cli}/command/migrate.rb +2 -1
- data/lib/{twenty-cli → twenty/cli}/command/mixin/common_option_mixin.rb +2 -0
- data/lib/twenty/cli/command/mixin/rescue_mixin.rb +26 -0
- data/lib/{twenty-cli → twenty/cli}/command/mixin/sqlite_mixin.rb +4 -0
- data/lib/twenty/cli/command/up.rb +41 -0
- data/lib/{twenty-cli → twenty/cli}/command.rb +1 -0
- data/lib/{twenty-cli → twenty/cli}/libexec.rb +1 -1
- data/lib/twenty/cli.rb +8 -0
- data/libexec/twenty/connect +1 -1
- data/libexec/twenty/console +1 -1
- data/libexec/twenty/disconnect +1 -1
- data/libexec/twenty/down +1 -1
- data/libexec/twenty/migrate +1 -1
- data/libexec/twenty/up +1 -1
- metadata +36 -35
- data/lib/twenty-cli/command/down.rb +0 -18
- data/lib/twenty-cli/command/up.rb +0 -22
- data/lib/twenty-cli.rb +0 -8
- /data/lib/{twenty-cli → twenty/cli}/command/mixin/migration_mixin.rb +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d9a6a045f05746636ba95a807ef653ad26f003c36981f6f3830d95818d4781a
|
4
|
+
data.tar.gz: 55db9d8d8d9c1e63abf36d52e1ab018133fc6778b40145cb8f1b98c3667feb80
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b450d2e1c1074682dbf2fe35f9c2fea183ccdfea42f19bd04b55a8373017e62c8c3553bf17c882d8832a49c5b217b98f4e9f2e7dbce034d533a43ddfd85f916b
|
7
|
+
data.tar.gz: d066ed882a336f8415a9ea6657194cb3a79be75da24075c29c099570464b07fb4810204719a8373c1d8ad1593161482d1fb594b5811d123c00ece8319e7a85c6
|
data/bin/twenty
CHANGED
@@ -5,18 +5,19 @@ class Twenty::Command::Connect < Twenty::Command
|
|
5
5
|
description: "Connect a project to twenty"
|
6
6
|
prepend Twenty::Command::MigrationMixin
|
7
7
|
prepend Twenty::Command::SQLiteMixin
|
8
|
+
prepend Twenty::Command::RescueMixin
|
8
9
|
|
9
10
|
def run
|
10
11
|
options = parse_options(argv)
|
11
|
-
|
12
|
+
run_command(options)
|
12
13
|
end
|
13
14
|
|
14
15
|
private
|
15
16
|
|
16
17
|
def run_command(options)
|
17
|
-
Twenty::Project.
|
18
|
+
Twenty::Project.create(
|
18
19
|
name: File.basename(Dir.getwd),
|
19
20
|
path: Dir.getwd
|
20
|
-
)
|
21
|
+
)
|
21
22
|
end
|
22
23
|
end
|
@@ -6,10 +6,11 @@ class Twenty::Command::Console < Twenty::Command
|
|
6
6
|
include CommonOptionMixin
|
7
7
|
prepend Twenty::Command::MigrationMixin
|
8
8
|
prepend Twenty::Command::SQLiteMixin
|
9
|
+
prepend Twenty::Command::RescueMixin
|
9
10
|
|
10
11
|
def run
|
11
12
|
options = parse_options(argv)
|
12
|
-
|
13
|
+
run_command(options)
|
13
14
|
end
|
14
15
|
|
15
16
|
private
|
@@ -5,15 +5,19 @@ class Twenty::Command::Disconnect < Twenty::Command
|
|
5
5
|
description: "Disconnect a project from twenty"
|
6
6
|
prepend Twenty::Command::MigrationMixin
|
7
7
|
prepend Twenty::Command::SQLiteMixin
|
8
|
+
prepend Twenty::Command::RescueMixin
|
8
9
|
|
9
10
|
def run
|
10
11
|
options = parse_options(argv)
|
11
|
-
|
12
|
+
run_command(options)
|
12
13
|
end
|
13
14
|
|
14
15
|
private
|
15
16
|
|
16
17
|
def run_command(options)
|
17
|
-
|
18
|
+
Twenty::Project
|
19
|
+
.where(path: Dir.getwd)
|
20
|
+
.first!
|
21
|
+
.destroy
|
18
22
|
end
|
19
23
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Twenty::Command::Down < Twenty::Command
|
4
|
+
set_banner usage: "twenty down [OPTIONS]",
|
5
|
+
description: "Stop the twenty web server"
|
6
|
+
include Twenty::Path
|
7
|
+
prepend Twenty::Command::SQLiteMixin
|
8
|
+
prepend Twenty::Command::RescueMixin
|
9
|
+
|
10
|
+
def run
|
11
|
+
options = parse_options(argv)
|
12
|
+
run_command(options)
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def run_command(options)
|
18
|
+
if File.readable?(pidfile)
|
19
|
+
Process.kill("SIGINT", Integer(pid))
|
20
|
+
else
|
21
|
+
warn "PID file is not readable."
|
22
|
+
end
|
23
|
+
rescue Errno::ESRCH
|
24
|
+
warn "No such process."
|
25
|
+
FileUtils.rm(pidfile)
|
26
|
+
end
|
27
|
+
|
28
|
+
def pid
|
29
|
+
@pid ||= File
|
30
|
+
.binread(pidfile)
|
31
|
+
.gsub(/[^\d]/, "")
|
32
|
+
end
|
33
|
+
end
|
@@ -5,10 +5,11 @@ class Twenty::Command::Migrate < Twenty::Command
|
|
5
5
|
description: "Migrate the database"
|
6
6
|
include CommonOptionMixin
|
7
7
|
prepend Twenty::Command::SQLiteMixin
|
8
|
+
prepend Twenty::Command::RescueMixin
|
8
9
|
|
9
10
|
def run
|
10
11
|
options = parse_options(argv)
|
11
|
-
|
12
|
+
run_command(options)
|
12
13
|
end
|
13
14
|
|
14
15
|
private
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Twenty::Command
|
4
|
+
module RescueMixin
|
5
|
+
def run(...)
|
6
|
+
super(...)
|
7
|
+
rescue => ex
|
8
|
+
require "paint"
|
9
|
+
$stderr.print "\n",
|
10
|
+
" ", Paint[" Exception ", :white, :red, :bold], "\n",
|
11
|
+
" ", Paint[ex.class.to_s, :bold], "\n",
|
12
|
+
" ", ex.message, "\n\n",
|
13
|
+
" ", Paint[" Backtrace ", :white, :blue, :bold], "\n",
|
14
|
+
format_backtrace(ex.backtrace), "\n",
|
15
|
+
"\n"
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def format_backtrace(backtrace)
|
21
|
+
backtrace.last(5).map do
|
22
|
+
" #{_1.gsub(Dir.getwd, "")}"
|
23
|
+
end.join("\n")
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -1,7 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Twenty::Command::SQLiteMixin
|
2
4
|
def run_command(options)
|
3
5
|
path = options.database || Twenty.default_database
|
4
6
|
Twenty.establish_connection(path:)
|
7
|
+
require "twenty/server/migration"
|
8
|
+
require "twenty/server/model"
|
5
9
|
super(options)
|
6
10
|
end
|
7
11
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Twenty::Command::Up < Twenty::Command
|
4
|
+
set_banner usage: "twenty up [OPTIONS]",
|
5
|
+
description: "Start the twenty web server"
|
6
|
+
set_option "-b ADDR",
|
7
|
+
"--bind ADDR",
|
8
|
+
"An address to bind to (default: 127.0.0.1)",
|
9
|
+
default: "127.0.0.1"
|
10
|
+
set_option "-p PORT",
|
11
|
+
"--port PORT",
|
12
|
+
"A port to listen on (default: 2020)",
|
13
|
+
default: 2020,
|
14
|
+
as: Integer
|
15
|
+
set_option "-u PATH",
|
16
|
+
"--unix PATH",
|
17
|
+
"Listen on a UNIX socket"
|
18
|
+
|
19
|
+
include CommonOptionMixin
|
20
|
+
include Twenty::Path
|
21
|
+
prepend Twenty::Command::MigrationMixin
|
22
|
+
prepend Twenty::Command::SQLiteMixin
|
23
|
+
prepend Twenty::Command::RescueMixin
|
24
|
+
|
25
|
+
def run
|
26
|
+
options = parse_options(argv)
|
27
|
+
run_command(options)
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def run_command(options)
|
33
|
+
File.binwrite(pidfile, Process.pid.to_s)
|
34
|
+
thr = Twenty::Rack.server(options).start
|
35
|
+
thr.join
|
36
|
+
rescue Interrupt
|
37
|
+
thr.kill
|
38
|
+
ensure
|
39
|
+
FileUtils.rm(pidfile)
|
40
|
+
end
|
41
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
def spawn(exec, *)
|
4
|
-
libexec_dir = File.realpath(File.join(__dir__, "..", "..", "libexec", "twenty"))
|
4
|
+
libexec_dir = File.realpath(File.join(__dir__, "..", "..", "..", "libexec", "twenty"))
|
5
5
|
Process.spawn(File.join(libexec_dir, exec), *)
|
6
6
|
end
|
7
7
|
|
data/lib/twenty/cli.rb
ADDED
data/libexec/twenty/connect
CHANGED
data/libexec/twenty/console
CHANGED
data/libexec/twenty/disconnect
CHANGED
data/libexec/twenty/down
CHANGED
data/libexec/twenty/migrate
CHANGED
data/libexec/twenty/up
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twenty-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- '0x1eef'
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cmd.rb
|
@@ -16,85 +16,85 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0.
|
19
|
+
version: '0.5'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0.
|
26
|
+
version: '0.5'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: paint
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 3
|
34
|
-
type: :
|
33
|
+
version: '2.3'
|
34
|
+
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 3
|
40
|
+
version: '2.3'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: test-unit
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 3.5.7
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 3.5.7
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: yard
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '0.9'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '0.9'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: redcarpet
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '3.5'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '3.5'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: standard
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '1.35'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
97
|
-
description:
|
96
|
+
version: '1.35'
|
97
|
+
description: Command-line interface
|
98
98
|
email:
|
99
99
|
- 0x1eef@protonmail.com
|
100
100
|
executables:
|
@@ -103,18 +103,19 @@ extensions: []
|
|
103
103
|
extra_rdoc_files: []
|
104
104
|
files:
|
105
105
|
- "./bin/twenty"
|
106
|
-
- "./lib/twenty
|
107
|
-
- "./lib/twenty
|
108
|
-
- "./lib/twenty
|
109
|
-
- "./lib/twenty
|
110
|
-
- "./lib/twenty
|
111
|
-
- "./lib/twenty
|
112
|
-
- "./lib/twenty
|
113
|
-
- "./lib/twenty
|
114
|
-
- "./lib/twenty
|
115
|
-
- "./lib/twenty
|
116
|
-
- "./lib/twenty
|
117
|
-
- "./lib/twenty
|
106
|
+
- "./lib/twenty/cli.rb"
|
107
|
+
- "./lib/twenty/cli/command.rb"
|
108
|
+
- "./lib/twenty/cli/command/connect.rb"
|
109
|
+
- "./lib/twenty/cli/command/console.rb"
|
110
|
+
- "./lib/twenty/cli/command/disconnect.rb"
|
111
|
+
- "./lib/twenty/cli/command/down.rb"
|
112
|
+
- "./lib/twenty/cli/command/migrate.rb"
|
113
|
+
- "./lib/twenty/cli/command/mixin/common_option_mixin.rb"
|
114
|
+
- "./lib/twenty/cli/command/mixin/migration_mixin.rb"
|
115
|
+
- "./lib/twenty/cli/command/mixin/rescue_mixin.rb"
|
116
|
+
- "./lib/twenty/cli/command/mixin/sqlite_mixin.rb"
|
117
|
+
- "./lib/twenty/cli/command/up.rb"
|
118
|
+
- "./lib/twenty/cli/libexec.rb"
|
118
119
|
- "./libexec/twenty/connect"
|
119
120
|
- "./libexec/twenty/console"
|
120
121
|
- "./libexec/twenty/disconnect"
|
@@ -141,8 +142,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
141
142
|
- !ruby/object:Gem::Version
|
142
143
|
version: '0'
|
143
144
|
requirements: []
|
144
|
-
rubygems_version: 3.
|
145
|
+
rubygems_version: 3.5.9
|
145
146
|
signing_key:
|
146
147
|
specification_version: 4
|
147
|
-
summary:
|
148
|
+
summary: Command-line interface
|
148
149
|
test_files: []
|
@@ -1,18 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class Twenty::Command::Down < Twenty::Command
|
4
|
-
set_banner usage: "twenty down [OPTIONS]",
|
5
|
-
description: "Stop the twenty web server"
|
6
|
-
prepend Twenty::Command::SQLiteMixin
|
7
|
-
|
8
|
-
def run
|
9
|
-
options = parse_options(argv)
|
10
|
-
options.help ? show_help : run_command(options)
|
11
|
-
end
|
12
|
-
|
13
|
-
private
|
14
|
-
|
15
|
-
def run_command(options)
|
16
|
-
warn "[twenty] down..."
|
17
|
-
end
|
18
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class Twenty::Command::Up < Twenty::Command
|
4
|
-
set_banner usage: "twenty up [OPTIONS]",
|
5
|
-
description: "Start the twenty web server"
|
6
|
-
include CommonOptionMixin
|
7
|
-
prepend Twenty::Command::MigrationMixin
|
8
|
-
prepend Twenty::Command::SQLiteMixin
|
9
|
-
|
10
|
-
def run
|
11
|
-
options = parse_options(argv)
|
12
|
-
options.help ? show_help : run_command(options)
|
13
|
-
end
|
14
|
-
|
15
|
-
private
|
16
|
-
|
17
|
-
def run_command(options)
|
18
|
-
server = Twenty::Servlet.server
|
19
|
-
trap(:SIGINT) { server.shutdown }
|
20
|
-
server.start
|
21
|
-
end
|
22
|
-
end
|
data/lib/twenty-cli.rb
DELETED
File without changes
|