twenty-cli 0.3.5 → 0.4.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/bin/twenty +2 -2
- 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 -24
- data/bin/20 +0 -2
- 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
@@ -2,7 +2,7 @@
|
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
libdir = File.join(__dir__, "..", "lib")
|
5
|
-
require File.join(libdir, "twenty
|
5
|
+
require File.join(libdir, "twenty", "cli", "libexec")
|
6
6
|
|
7
7
|
case ARGV[0]
|
8
8
|
when "up"
|
@@ -24,7 +24,7 @@ when "console"
|
|
24
24
|
wait spawn("console", *ARGV[1..])
|
25
25
|
exit $?.exitstatus
|
26
26
|
else
|
27
|
-
warn "Usage:
|
27
|
+
warn "Usage: twenty COMMAND [OPTIONS]\n\n" \
|
28
28
|
"Commands:\n" \
|
29
29
|
" up Start the twenty web server.\n" \
|
30
30
|
" down Stop the twenty web server.\n" \
|
@@ -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,14 +16,28 @@ 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
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: paint
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.3'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.3'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: test-unit
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,44 +86,42 @@ dependencies:
|
|
72
86
|
requirements:
|
73
87
|
- - "~>"
|
74
88
|
- !ruby/object:Gem::Version
|
75
|
-
version: '1.
|
89
|
+
version: '1.35'
|
76
90
|
type: :development
|
77
91
|
prerelease: false
|
78
92
|
version_requirements: !ruby/object:Gem::Requirement
|
79
93
|
requirements:
|
80
94
|
- - "~>"
|
81
95
|
- !ruby/object:Gem::Version
|
82
|
-
version: '1.
|
83
|
-
description:
|
96
|
+
version: '1.35'
|
97
|
+
description: Command-line interface
|
84
98
|
email:
|
85
99
|
- 0x1eef@protonmail.com
|
86
100
|
executables:
|
87
101
|
- twenty
|
88
|
-
- '20'
|
89
102
|
extensions: []
|
90
103
|
extra_rdoc_files: []
|
91
104
|
files:
|
92
|
-
- "./bin/20"
|
93
105
|
- "./bin/twenty"
|
94
|
-
- "./lib/twenty
|
95
|
-
- "./lib/twenty
|
96
|
-
- "./lib/twenty
|
97
|
-
- "./lib/twenty
|
98
|
-
- "./lib/twenty
|
99
|
-
- "./lib/twenty
|
100
|
-
- "./lib/twenty
|
101
|
-
- "./lib/twenty
|
102
|
-
- "./lib/twenty
|
103
|
-
- "./lib/twenty
|
104
|
-
- "./lib/twenty
|
105
|
-
- "./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"
|
106
119
|
- "./libexec/twenty/connect"
|
107
120
|
- "./libexec/twenty/console"
|
108
121
|
- "./libexec/twenty/disconnect"
|
109
122
|
- "./libexec/twenty/down"
|
110
123
|
- "./libexec/twenty/migrate"
|
111
124
|
- "./libexec/twenty/up"
|
112
|
-
- bin/20
|
113
125
|
- bin/twenty
|
114
126
|
homepage: https://github.com/0x1eef/twenty#readme
|
115
127
|
licenses:
|
@@ -130,8 +142,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
130
142
|
- !ruby/object:Gem::Version
|
131
143
|
version: '0'
|
132
144
|
requirements: []
|
133
|
-
rubygems_version: 3.
|
145
|
+
rubygems_version: 3.5.9
|
134
146
|
signing_key:
|
135
147
|
specification_version: 4
|
136
|
-
summary:
|
148
|
+
summary: Command-line interface
|
137
149
|
test_files: []
|
data/bin/20
DELETED
@@ -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
|