consolle 0.2.6
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 +7 -0
- data/.github/workflows/test.yml +52 -0
- data/.gitignore +6 -0
- data/.mise.toml +9 -0
- data/.rspec +4 -0
- data/.version +1 -0
- data/CHANGELOG.md +29 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +39 -0
- data/LICENSE +9 -0
- data/README.md +190 -0
- data/bin/cone +6 -0
- data/bin/consolle +6 -0
- data/consolle.gemspec +40 -0
- data/lib/consolle/adapters/rails_console.rb +295 -0
- data/lib/consolle/cli.rb +718 -0
- data/lib/consolle/server/console_socket_server.rb +201 -0
- data/lib/consolle/server/console_supervisor.rb +556 -0
- data/lib/consolle/server/request_broker.rb +247 -0
- data/lib/consolle/version.rb +5 -0
- data/lib/consolle.rb +13 -0
- data/mise/release.sh +120 -0
- data/rule.ko.md +117 -0
- data/rule.md +117 -0
- metadata +115 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 3fdeb782267d3cb951cd1e8fece86486dc48eaf1c2e686e782b256e0dc60745e
|
|
4
|
+
data.tar.gz: d078d1aad3ca4bc063aa5ef15d67f0c66273e30a64ea822dd4a4122c173938f7
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 4afbcd6b93ea353b556000ef601acefcfd0bd0e4f76fc89053c2a20c3b72ccddd4a95ee5073f61420a310011fc2cd6df44ccbb17ee319d777645f5d97fb673e6
|
|
7
|
+
data.tar.gz: '069a0849b85439b2b9314c2e165ddba1486f86db8b30f13b4346bd137b5607799978c81a78182e6a7f1b956c061763b075a12068fd626445772f9524a6705a4a'
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
name: Test
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ main, master ]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [ main, master ]
|
|
8
|
+
workflow_dispatch:
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
test:
|
|
12
|
+
name: Ruby ${{ matrix.ruby }} on ${{ matrix.os }}
|
|
13
|
+
runs-on: ${{ matrix.os }}
|
|
14
|
+
continue-on-error: ${{ matrix.experimental }}
|
|
15
|
+
|
|
16
|
+
strategy:
|
|
17
|
+
fail-fast: false
|
|
18
|
+
matrix:
|
|
19
|
+
os: [ubuntu-latest, macos-latest]
|
|
20
|
+
ruby: ['3.1', '3.2', '3.3', '3.4']
|
|
21
|
+
experimental: [false]
|
|
22
|
+
include:
|
|
23
|
+
# Test on Windows with each Ruby version
|
|
24
|
+
- os: windows-latest
|
|
25
|
+
ruby: '3.1'
|
|
26
|
+
experimental: true
|
|
27
|
+
- os: windows-latest
|
|
28
|
+
ruby: '3.2'
|
|
29
|
+
experimental: true
|
|
30
|
+
- os: windows-latest
|
|
31
|
+
ruby: '3.3'
|
|
32
|
+
experimental: true
|
|
33
|
+
- os: windows-latest
|
|
34
|
+
ruby: '3.4'
|
|
35
|
+
experimental: true
|
|
36
|
+
# Test with Ruby head on Ubuntu
|
|
37
|
+
- os: ubuntu-latest
|
|
38
|
+
ruby: 'head'
|
|
39
|
+
experimental: true
|
|
40
|
+
|
|
41
|
+
steps:
|
|
42
|
+
- uses: actions/checkout@v4
|
|
43
|
+
|
|
44
|
+
- name: Set up Ruby
|
|
45
|
+
uses: ruby/setup-ruby@v1
|
|
46
|
+
with:
|
|
47
|
+
ruby-version: ${{ matrix.ruby }}
|
|
48
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems
|
|
49
|
+
|
|
50
|
+
- name: Run tests
|
|
51
|
+
run: bundle exec rspec --format documentation
|
|
52
|
+
continue-on-error: ${{ matrix.experimental }}
|
data/.gitignore
ADDED
data/.mise.toml
ADDED
data/.rspec
ADDED
data/.version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.2.6
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.2.5] - 2025-01-24
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
- Handle UTF-8 encoding for strings tagged as ASCII-8BIT when processing multibyte characters
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
- Minimum Ruby version requirement changed from 3.0.0 to 3.1.0
|
|
15
|
+
- Updated gemspec metadata for RubyGems.org publishing
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
- bin/consolle executable for gem exec support
|
|
19
|
+
- MIT License file
|
|
20
|
+
- GitHub Actions CI workflow for testing across multiple Ruby versions and platforms
|
|
21
|
+
- Release script for automated versioning and publishing
|
|
22
|
+
|
|
23
|
+
## [0.2.4] - 2025-01-23
|
|
24
|
+
|
|
25
|
+
### Added
|
|
26
|
+
- Initial release with PTY-based Rails console management
|
|
27
|
+
- Multi-session support
|
|
28
|
+
- Socket-based communication
|
|
29
|
+
- Automatic console restart on failure
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
consolle (0.2.6)
|
|
5
|
+
logger (~> 1.0)
|
|
6
|
+
thor (~> 1.0)
|
|
7
|
+
|
|
8
|
+
GEM
|
|
9
|
+
remote: https://rubygems.org/
|
|
10
|
+
specs:
|
|
11
|
+
base64 (0.3.0)
|
|
12
|
+
diff-lcs (1.6.2)
|
|
13
|
+
logger (1.7.0)
|
|
14
|
+
rspec (3.13.1)
|
|
15
|
+
rspec-core (~> 3.13.0)
|
|
16
|
+
rspec-expectations (~> 3.13.0)
|
|
17
|
+
rspec-mocks (~> 3.13.0)
|
|
18
|
+
rspec-core (3.13.5)
|
|
19
|
+
rspec-support (~> 3.13.0)
|
|
20
|
+
rspec-expectations (3.13.5)
|
|
21
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
22
|
+
rspec-support (~> 3.13.0)
|
|
23
|
+
rspec-mocks (3.13.5)
|
|
24
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
25
|
+
rspec-support (~> 3.13.0)
|
|
26
|
+
rspec-support (3.13.4)
|
|
27
|
+
thor (1.3.2)
|
|
28
|
+
|
|
29
|
+
PLATFORMS
|
|
30
|
+
arm64-darwin-24
|
|
31
|
+
ruby
|
|
32
|
+
|
|
33
|
+
DEPENDENCIES
|
|
34
|
+
base64 (~> 0.2)
|
|
35
|
+
consolle!
|
|
36
|
+
rspec (~> 3.0)
|
|
37
|
+
|
|
38
|
+
BUNDLED WITH
|
|
39
|
+
2.6.9
|
data/LICENSE
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright 2025 nacyot
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
# Consolle
|
|
2
|
+
|
|
3
|
+
Consolle is a library that manages Rails console through PTY (Pseudo-Terminal). Moving away from the traditional eval-based execution method, it manages the actual Rails console process as a subprocess to provide a more stable and secure execution environment.
|
|
4
|
+
|
|
5
|
+
## Key Features
|
|
6
|
+
|
|
7
|
+
- **PTY-based Rails Console Management**: Manages the actual Rails console process through PTY
|
|
8
|
+
- **Socket Server Architecture**: Stable client-server communication through Unix socket
|
|
9
|
+
- **Automatic Restart (Watchdog)**: Automatic recovery on process failure
|
|
10
|
+
- **Environment-specific Execution**: Supports Rails environments (development, test, production)
|
|
11
|
+
- **Timeout Handling**: Automatic termination of infinite loops and long-running code
|
|
12
|
+
- **Log Management**: Automatic management of execution history and session logs
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
### 1. Install the Library
|
|
17
|
+
```bash
|
|
18
|
+
# From Rails project root
|
|
19
|
+
gem install consolle
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### 2. Rails Project Configuration
|
|
23
|
+
```bash
|
|
24
|
+
# Add to Gemfile
|
|
25
|
+
gem 'consolle'
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
### Basic Usage
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
# Start Rails console server
|
|
34
|
+
cone start
|
|
35
|
+
|
|
36
|
+
# Check status
|
|
37
|
+
cone status
|
|
38
|
+
|
|
39
|
+
# Execute code
|
|
40
|
+
cone exec "User.count"
|
|
41
|
+
cone -m "2 + 2"
|
|
42
|
+
|
|
43
|
+
# Stop server
|
|
44
|
+
cone stop
|
|
45
|
+
|
|
46
|
+
# Restart server
|
|
47
|
+
cone restart
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Advanced Usage
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
# Start with specific environment
|
|
54
|
+
cone start -e test
|
|
55
|
+
|
|
56
|
+
# Restart with environment change
|
|
57
|
+
cone restart -e production
|
|
58
|
+
|
|
59
|
+
# Force full server restart
|
|
60
|
+
cone restart --force
|
|
61
|
+
|
|
62
|
+
# Set timeout
|
|
63
|
+
cone exec "sleep 10" --timeout 5
|
|
64
|
+
|
|
65
|
+
# Verbose log output
|
|
66
|
+
cone -v exec "User.all"
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Architecture
|
|
70
|
+
|
|
71
|
+
Consolle consists of the following structure:
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
┌─────────────────────┐
|
|
75
|
+
│ CLI Tool │
|
|
76
|
+
│ (cone) │
|
|
77
|
+
└─────────┬───────────┘
|
|
78
|
+
│ Unix Socket
|
|
79
|
+
│
|
|
80
|
+
┌─────────▼───────────┐
|
|
81
|
+
│ ConsoleSocketServer│
|
|
82
|
+
│ (Socket Listener) │
|
|
83
|
+
└─────────┬───────────┘
|
|
84
|
+
│
|
|
85
|
+
┌─────────▼───────────┐
|
|
86
|
+
│ RequestBroker │
|
|
87
|
+
│ (Serial Queue) │
|
|
88
|
+
└─────────┬───────────┘
|
|
89
|
+
│
|
|
90
|
+
┌─────────▼───────────┐
|
|
91
|
+
│ ConsoleSupervisor │
|
|
92
|
+
│ (PTY Manager) │
|
|
93
|
+
└─────────┬───────────┘
|
|
94
|
+
│ PTY
|
|
95
|
+
│
|
|
96
|
+
┌─────────▼───────────┐
|
|
97
|
+
│ Rails Console │
|
|
98
|
+
│ (Subprocess) │
|
|
99
|
+
└─────────────────────┘
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Key Components
|
|
103
|
+
|
|
104
|
+
### CLI (Command Line Interface)
|
|
105
|
+
- `cone start`: Start Rails console server
|
|
106
|
+
- `cone stop`: Stop Rails console server
|
|
107
|
+
- `cone restart`: Restart Rails console server
|
|
108
|
+
- `cone status`: Check server status
|
|
109
|
+
- `cone exec`: Execute code
|
|
110
|
+
- `cone version`: Version information
|
|
111
|
+
|
|
112
|
+
### Server Components
|
|
113
|
+
|
|
114
|
+
#### ConsoleSocketServer
|
|
115
|
+
- Manages client connections through Unix socket
|
|
116
|
+
- Handles requests/responses through JSON protocol
|
|
117
|
+
- Supports multiple client connections
|
|
118
|
+
|
|
119
|
+
#### ConsoleSupervisor
|
|
120
|
+
- Manages Rails console process through PTY
|
|
121
|
+
- Automatic restart (Watchdog) feature
|
|
122
|
+
- Environment variable settings and IRB automation configuration
|
|
123
|
+
- Timeout handling and Ctrl-C support
|
|
124
|
+
|
|
125
|
+
#### RequestBroker
|
|
126
|
+
- Ensures request order through serial queue
|
|
127
|
+
- Prevents concurrent execution and safe multi-client handling
|
|
128
|
+
- Asynchronous response handling through Future pattern
|
|
129
|
+
|
|
130
|
+
## Environment Configuration
|
|
131
|
+
|
|
132
|
+
Consolle automatically sets the following environment variables when running Rails console:
|
|
133
|
+
|
|
134
|
+
```ruby
|
|
135
|
+
env = {
|
|
136
|
+
"RAILS_ENV" => rails_env,
|
|
137
|
+
"IRBRC" => "skip", # Skip IRB configuration file
|
|
138
|
+
"PAGER" => "cat", # Immediate output
|
|
139
|
+
"NO_PAGER" => "1", # Disable pager
|
|
140
|
+
"TERM" => "dumb", # Simple terminal setting
|
|
141
|
+
"FORCE_COLOR" => "0", # Disable colors
|
|
142
|
+
"NO_COLOR" => "1", # Completely disable color output
|
|
143
|
+
"COLUMNS" => "120", # Fixed column count
|
|
144
|
+
"LINES" => "24" # Fixed line count
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## File Locations
|
|
149
|
+
|
|
150
|
+
- **Socket file**: `{Rails.root}/tmp/cone/cone.socket`
|
|
151
|
+
- **PID file**: `{Rails.root}/tmp/cone/cone.pid`
|
|
152
|
+
- **Log file**: `{Rails.root}/tmp/cone/cone.log`
|
|
153
|
+
- **Session file**: `{Rails.root}/tmp/cone/session.json`
|
|
154
|
+
- **User session logs**: `~/.cone/sessions/{project_hash}/session_YYYYMMDD_pid{pid}.log`
|
|
155
|
+
|
|
156
|
+
## Development Guide
|
|
157
|
+
|
|
158
|
+
### Running Tests
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
# From library directory
|
|
162
|
+
cd lib/consolle
|
|
163
|
+
bundle install
|
|
164
|
+
bundle exec rspec
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### Debugging
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
# Verbose log output
|
|
171
|
+
cone -v exec "your_code"
|
|
172
|
+
|
|
173
|
+
# Check server logs
|
|
174
|
+
tail -f tmp/cone/cone.log
|
|
175
|
+
|
|
176
|
+
# Check session logs
|
|
177
|
+
ls ~/.cone/sessions/
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## Limitations
|
|
181
|
+
|
|
182
|
+
- Only available in Rails projects
|
|
183
|
+
- Only works on Unix-like systems (PTY dependency)
|
|
184
|
+
- Only one console server can run per Rails project
|
|
185
|
+
|
|
186
|
+
## Version Information
|
|
187
|
+
|
|
188
|
+
- **Current version**: 0.1.0
|
|
189
|
+
- **Ruby version**: 3.0 or higher
|
|
190
|
+
- **Rails version**: 7.0 or higher
|
data/bin/cone
ADDED
data/bin/consolle
ADDED
data/consolle.gemspec
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "lib/consolle/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = "consolle"
|
|
7
|
+
spec.version = Consolle::VERSION
|
|
8
|
+
spec.authors = ["nacyot"]
|
|
9
|
+
spec.email = ["propellerheaven@gmail.com"]
|
|
10
|
+
|
|
11
|
+
spec.summary = "PTY-based Rails console management library"
|
|
12
|
+
spec.description = "Consolle is a library that manages Rails console through PTY (Pseudo-Terminal). Moving away from the traditional eval-based execution method, it manages the actual Rails console process as a subprocess to provide a more stable and secure execution environment."
|
|
13
|
+
spec.homepage = "https://github.com/nacyot/consolle"
|
|
14
|
+
spec.required_ruby_version = ">= 3.1.0"
|
|
15
|
+
spec.license = "MIT"
|
|
16
|
+
|
|
17
|
+
spec.metadata = {
|
|
18
|
+
"homepage_uri" => spec.homepage,
|
|
19
|
+
"source_code_uri" => "https://github.com/nacyot/consolle",
|
|
20
|
+
"changelog_uri" => "https://github.com/nacyot/consolle/blob/main/CHANGELOG.md",
|
|
21
|
+
"bug_tracker_uri" => "https://github.com/nacyot/consolle/issues",
|
|
22
|
+
"rubygems_mfa_required" => "true"
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
# Specify which files should be added to the gem when it is released.
|
|
26
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
27
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
28
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
|
29
|
+
end
|
|
30
|
+
spec.bindir = "bin"
|
|
31
|
+
spec.executables = spec.files.grep(%r{\Abin/}) { |f| File.basename(f) }
|
|
32
|
+
spec.require_paths = ["lib"]
|
|
33
|
+
|
|
34
|
+
# Runtime dependencies
|
|
35
|
+
spec.add_dependency "thor", "~> 1.0"
|
|
36
|
+
spec.add_dependency "logger", "~> 1.0"
|
|
37
|
+
|
|
38
|
+
# Development dependencies
|
|
39
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
|
40
|
+
end
|