twenty-cli 0.5.3 → 0.5.5
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/lib/twenty/cli/command/connect.rb +8 -3
- data/lib/twenty/cli/command/console.rb +13 -4
- data/lib/twenty/cli/command/disconnect.rb +7 -3
- data/lib/twenty/cli/command/down.rb +14 -11
- data/lib/twenty/cli/command/hook/require_migration.rb +21 -0
- data/lib/twenty/cli/command/{mixin/rescue_mixin.rb → hook/rescue.rb} +5 -3
- data/lib/twenty/cli/command/hook/sqlite_conn.rb +11 -0
- data/lib/twenty/cli/command/hook.rb +5 -0
- data/lib/twenty/cli/command/migrate.rb +13 -4
- data/lib/twenty/cli/command/mixin/common_option_mixin.rb +1 -1
- data/lib/twenty/cli/command/option/database.rb +13 -0
- data/lib/twenty/cli/command/option.rb +3 -0
- data/lib/twenty/cli/command/up.rb +18 -7
- data/lib/twenty/cli/command.rb +4 -6
- metadata +10 -6
- data/lib/twenty/cli/command/mixin/migration_mixin.rb +0 -19
- data/lib/twenty/cli/command/mixin/sqlite_mixin.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2788338657a1baa50cd9df1dbf6f0ee6cec4670c70e888d0ecf483c2dee42aec
|
4
|
+
data.tar.gz: b1cc4f163fc1a2be7aeb924ab9bbfba5f4769d4d848fe78265b288fb77e14dc3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3db4deea8e6f421c1189d328298f1acf38f2058f33fff6d11b3413c898a674159130252e5131992268871e4a217de19b051e516c76ddc128d27688865a92403
|
7
|
+
data.tar.gz: 2cdd2d036d9d1abb8680abe9b97a904a6608f650093579897f7b00dc3b3dd874971eae85ede66d308371a0d46c1f5362a0f7cb543dc5d997ff092f48c25ba0ca
|
@@ -5,9 +5,13 @@ class Twenty::Command::Connect < Twenty::Command
|
|
5
5
|
description: "Connect a project to twenty"
|
6
6
|
set_option "-p PATH", "--path PATH", "The path to a project", default: nil
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
##
|
9
|
+
# Hooks
|
10
|
+
# Run order:
|
11
|
+
# Rescue -> SQLiteConn -> RequireMigration -> command
|
12
|
+
prepend Hook::RequireMigration
|
13
|
+
prepend Hook::SQLiteConn
|
14
|
+
prepend Hook::Rescue
|
11
15
|
|
12
16
|
def run
|
13
17
|
options = parse_options(argv)
|
@@ -17,6 +21,7 @@ class Twenty::Command::Connect < Twenty::Command
|
|
17
21
|
private
|
18
22
|
|
19
23
|
def run_command(options)
|
24
|
+
require "twenty/server/model"
|
20
25
|
path = File.realpath(options.path ? options.path : Dir.getwd)
|
21
26
|
if File.exist?(path)
|
22
27
|
project = Twenty::Project.create(
|
@@ -3,10 +3,18 @@
|
|
3
3
|
class Twenty::Command::Console < Twenty::Command
|
4
4
|
set_banner usage: "twenty console [OPTIONS]",
|
5
5
|
description: "Start the twenty developer console"
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
|
7
|
+
##
|
8
|
+
# Option(s)
|
9
|
+
include Option::Database
|
10
|
+
|
11
|
+
##
|
12
|
+
# Hooks
|
13
|
+
# Run order:
|
14
|
+
# Rescue -> SQLiteConn -> RequireMigration -> command
|
15
|
+
prepend Hook::RequireMigration
|
16
|
+
prepend Hook::SQLiteConn
|
17
|
+
prepend Hook::Rescue
|
10
18
|
|
11
19
|
def run
|
12
20
|
options = parse_options(argv)
|
@@ -16,6 +24,7 @@ class Twenty::Command::Console < Twenty::Command
|
|
16
24
|
private
|
17
25
|
|
18
26
|
def run_command(options)
|
27
|
+
require "twenty/server/model"
|
19
28
|
require "irb"
|
20
29
|
TOPLEVEL_BINDING.irb
|
21
30
|
end
|
@@ -4,9 +4,12 @@ class Twenty::Command::Disconnect < Twenty::Command
|
|
4
4
|
set_banner usage: "twenty disconnect [OPTIONS]",
|
5
5
|
description: "Disconnect a project from twenty"
|
6
6
|
set_option "-p PATH", "--path PATH", "The path to a project", default: nil
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
|
8
|
+
##
|
9
|
+
# Hooks
|
10
|
+
prepend Hook::RequireMigration
|
11
|
+
prepend Hook::SQLiteConn
|
12
|
+
prepend Hook::Rescue
|
10
13
|
|
11
14
|
def run
|
12
15
|
options = parse_options(argv)
|
@@ -16,6 +19,7 @@ class Twenty::Command::Disconnect < Twenty::Command
|
|
16
19
|
private
|
17
20
|
|
18
21
|
def run_command(options)
|
22
|
+
require "twenty/server/model"
|
19
23
|
path = File.realpath(options.path ? options.path : Dir.getwd)
|
20
24
|
Twenty::Project
|
21
25
|
.where(path:)
|
@@ -3,9 +3,13 @@
|
|
3
3
|
class Twenty::Command::Down < Twenty::Command
|
4
4
|
set_banner usage: "twenty down [OPTIONS]",
|
5
5
|
description: "Stop the twenty web server"
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
|
7
|
+
##
|
8
|
+
# Hooks
|
9
|
+
# Run order:
|
10
|
+
# Rescue -> SQLiteConn -> command
|
11
|
+
prepend Hook::SQLiteConn
|
12
|
+
prepend Hook::Rescue
|
9
13
|
|
10
14
|
def run
|
11
15
|
options = parse_options(argv)
|
@@ -15,19 +19,18 @@ class Twenty::Command::Down < Twenty::Command
|
|
15
19
|
private
|
16
20
|
|
17
21
|
def run_command(options)
|
18
|
-
if File.readable?(
|
19
|
-
|
22
|
+
if File.readable?(pid)
|
23
|
+
pid = Integer(File.binread(pid).gsub(/[^\d]/, ""))
|
24
|
+
Process.kill("SIGINT", pid)
|
20
25
|
else
|
21
|
-
warn "
|
26
|
+
warn "[x] #{pid} is not readable"
|
22
27
|
end
|
23
28
|
rescue Errno::ESRCH
|
24
|
-
warn "
|
25
|
-
|
29
|
+
warn "[x] Process not found"
|
30
|
+
rm(pid)
|
26
31
|
end
|
27
32
|
|
28
33
|
def pid
|
29
|
-
|
30
|
-
.binread(pidfile)
|
31
|
-
.gsub(/[^\d]/, "")
|
34
|
+
Twenty.pid
|
32
35
|
end
|
33
36
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Twenty::Command::Hook
|
4
|
+
module RequireMigration
|
5
|
+
def run_command(...)
|
6
|
+
if pending_migrations?
|
7
|
+
warn "There are pending migrations.\n" \
|
8
|
+
"Run \"twenty migrate\" first.\n"
|
9
|
+
exit(1)
|
10
|
+
else
|
11
|
+
super(...)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def pending_migrations?
|
18
|
+
Twenty::Migration.pending_migrations?
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -1,7 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
module
|
3
|
+
module Twenty::Command::Hook
|
4
|
+
module Rescue
|
5
|
+
FRAME_MAX = 15
|
6
|
+
|
5
7
|
def run(...)
|
6
8
|
super(...)
|
7
9
|
rescue => ex
|
@@ -18,7 +20,7 @@ class Twenty::Command
|
|
18
20
|
private
|
19
21
|
|
20
22
|
def format_backtrace(backtrace)
|
21
|
-
backtrace.last(
|
23
|
+
backtrace.last(FRAME_MAX).map do
|
22
24
|
" #{_1.gsub(Dir.getwd, "")}"
|
23
25
|
end.join("\n")
|
24
26
|
end
|
@@ -3,9 +3,18 @@
|
|
3
3
|
class Twenty::Command::Migrate < Twenty::Command
|
4
4
|
set_banner usage: "twenty migrate [OPTIONS]",
|
5
5
|
description: "Migrate the database"
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
set_option "-t TARGET", "--target TARGET", "The target version", default: nil
|
7
|
+
|
8
|
+
##
|
9
|
+
# Options
|
10
|
+
include Option::Database
|
11
|
+
|
12
|
+
##
|
13
|
+
# Hooks
|
14
|
+
# Run order:
|
15
|
+
# Rescue -> SQLiteConn -> command.
|
16
|
+
prepend Hook::SQLiteConn
|
17
|
+
prepend Hook::Rescue
|
9
18
|
|
10
19
|
def run
|
11
20
|
options = parse_options(argv)
|
@@ -15,6 +24,6 @@ class Twenty::Command::Migrate < Twenty::Command
|
|
15
24
|
private
|
16
25
|
|
17
26
|
def run_command(options)
|
18
|
-
Twenty::Migration.run!
|
27
|
+
Twenty::Migration.run!(target: options.target)
|
19
28
|
end
|
20
29
|
end
|
@@ -16,11 +16,17 @@ class Twenty::Command::Up < Twenty::Command
|
|
16
16
|
"--unix PATH",
|
17
17
|
"Listen on a UNIX socket"
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
19
|
+
##
|
20
|
+
# Option(s)
|
21
|
+
include Option::Database
|
22
|
+
|
23
|
+
##
|
24
|
+
# Hooks
|
25
|
+
# Run order:
|
26
|
+
# Rescue -> SQLiteConn -> RequireMigration -> command
|
27
|
+
prepend Hook::RequireMigration
|
28
|
+
prepend Hook::SQLiteConn
|
29
|
+
prepend Hook::Rescue
|
24
30
|
|
25
31
|
def run
|
26
32
|
options = parse_options(argv)
|
@@ -30,12 +36,17 @@ class Twenty::Command::Up < Twenty::Command
|
|
30
36
|
private
|
31
37
|
|
32
38
|
def run_command(options)
|
33
|
-
|
39
|
+
require "twenty/server/model"
|
40
|
+
File.binwrite(pid, Process.pid.to_s)
|
34
41
|
thr = Twenty::Rack.server(options).start
|
35
42
|
thr.join
|
36
43
|
rescue Interrupt
|
37
44
|
thr.kill
|
38
45
|
ensure
|
39
|
-
FileUtils.rm(
|
46
|
+
FileUtils.rm(pid)
|
47
|
+
end
|
48
|
+
|
49
|
+
def pid
|
50
|
+
Twenty.pid
|
40
51
|
end
|
41
52
|
end
|
data/lib/twenty/cli/command.rb
CHANGED
@@ -4,14 +4,12 @@ require "cmd"
|
|
4
4
|
|
5
5
|
class Twenty::Command < Cmd
|
6
6
|
##
|
7
|
-
#
|
8
|
-
require_relative "command/
|
9
|
-
require_relative "command/
|
10
|
-
require_relative "command/mixin/sqlite_mixin"
|
11
|
-
require_relative "command/mixin/rescue_mixin"
|
7
|
+
# Hooks
|
8
|
+
require_relative "command/option"
|
9
|
+
require_relative "command/hook"
|
12
10
|
|
13
11
|
##
|
14
|
-
#
|
12
|
+
# Commands
|
15
13
|
require_relative "command/up"
|
16
14
|
require_relative "command/down"
|
17
15
|
require_relative "command/connect"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twenty-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- '0x1eef'
|
@@ -94,7 +94,8 @@ dependencies:
|
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '1.35'
|
97
|
-
description:
|
97
|
+
description: Provides the CLI component of twenty. See https://rubygems.org/gems/twenty
|
98
|
+
for context.
|
98
99
|
email:
|
99
100
|
- 0x1eef@protonmail.com
|
100
101
|
executables:
|
@@ -109,11 +110,14 @@ files:
|
|
109
110
|
- "./lib/twenty/cli/command/console.rb"
|
110
111
|
- "./lib/twenty/cli/command/disconnect.rb"
|
111
112
|
- "./lib/twenty/cli/command/down.rb"
|
113
|
+
- "./lib/twenty/cli/command/hook.rb"
|
114
|
+
- "./lib/twenty/cli/command/hook/require_migration.rb"
|
115
|
+
- "./lib/twenty/cli/command/hook/rescue.rb"
|
116
|
+
- "./lib/twenty/cli/command/hook/sqlite_conn.rb"
|
112
117
|
- "./lib/twenty/cli/command/migrate.rb"
|
113
118
|
- "./lib/twenty/cli/command/mixin/common_option_mixin.rb"
|
114
|
-
- "./lib/twenty/cli/command/
|
115
|
-
- "./lib/twenty/cli/command/
|
116
|
-
- "./lib/twenty/cli/command/mixin/sqlite_mixin.rb"
|
119
|
+
- "./lib/twenty/cli/command/option.rb"
|
120
|
+
- "./lib/twenty/cli/command/option/database.rb"
|
117
121
|
- "./lib/twenty/cli/command/up.rb"
|
118
122
|
- "./lib/twenty/cli/libexec.rb"
|
119
123
|
- "./libexec/twenty/connect"
|
@@ -145,5 +149,5 @@ requirements: []
|
|
145
149
|
rubygems_version: 3.5.9
|
146
150
|
signing_key:
|
147
151
|
specification_version: 4
|
148
|
-
summary:
|
152
|
+
summary: Provides the CLI component of twenty
|
149
153
|
test_files: []
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Twenty::Command::MigrationMixin
|
4
|
-
def run_command(...)
|
5
|
-
if pending_migrations?
|
6
|
-
warn "There are pending migrations.\n" \
|
7
|
-
"Run \"twenty migrate\" first.\n"
|
8
|
-
exit(1)
|
9
|
-
else
|
10
|
-
super(...)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
private
|
15
|
-
|
16
|
-
def pending_migrations?
|
17
|
-
Twenty::Migration.pending_migrations?
|
18
|
-
end
|
19
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Twenty::Command::SQLiteMixin
|
4
|
-
def run_command(options)
|
5
|
-
path = options.database || Twenty.default_database
|
6
|
-
Twenty.establish_connection(path:)
|
7
|
-
require "twenty/server/migration"
|
8
|
-
require "twenty/server/model"
|
9
|
-
super(options)
|
10
|
-
end
|
11
|
-
end
|