source_monitor 0.1.1 → 0.1.2
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/CHANGELOG.md +17 -0
- data/Gemfile.lock +1 -1
- data/README.md +15 -11
- data/config/coverage_baseline.json +350 -107
- data/docs/deployment.md +8 -0
- data/docs/gh-cli-workflow.md +5 -1
- data/docs/setup-validation-log.md +36 -0
- data/docs/setup.md +144 -0
- data/lib/generators/source_monitor/install/install_generator.rb +1 -1
- data/lib/source_monitor/setup/bundle_installer.rb +17 -0
- data/lib/source_monitor/setup/cli.rb +51 -0
- data/lib/source_monitor/setup/dependency_checker.rb +165 -0
- data/lib/source_monitor/setup/detectors.rb +67 -0
- data/lib/source_monitor/setup/gemfile_editor.rb +29 -0
- data/lib/source_monitor/setup/initializer_patcher.rb +59 -0
- data/lib/source_monitor/setup/install_generator.rb +22 -0
- data/lib/source_monitor/setup/migration_installer.rb +40 -0
- data/lib/source_monitor/setup/node_installer.rb +27 -0
- data/lib/source_monitor/setup/prompter.rb +34 -0
- data/lib/source_monitor/setup/requirements.rb +51 -0
- data/lib/source_monitor/setup/shell_runner.rb +14 -0
- data/lib/source_monitor/setup/verification/action_cable_verifier.rb +79 -0
- data/lib/source_monitor/setup/verification/printer.rb +24 -0
- data/lib/source_monitor/setup/verification/result.rb +68 -0
- data/lib/source_monitor/setup/verification/runner.rb +24 -0
- data/lib/source_monitor/setup/verification/solid_queue_verifier.rb +75 -0
- data/lib/source_monitor/setup/verification/telemetry_logger.rb +33 -0
- data/lib/source_monitor/setup/workflow.rb +99 -0
- data/lib/source_monitor/version.rb +1 -1
- data/lib/source_monitor.rb +19 -0
- data/lib/tasks/source_monitor_setup.rake +39 -0
- data/tasks/prd-setup-workflow-streamlining.md +68 -0
- data/tasks/tasks-setup-workflow-streamlining.md +51 -0
- metadata +25 -2
- data/docs/installation.md +0 -144
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
## Relevant Files
|
|
2
|
+
|
|
3
|
+
- `lib/source_monitor/setup` - Entry point for setup orchestration services/Thor commands.
|
|
4
|
+
- `lib/tasks/source_monitor.rake` - Rake interfaces for setup/verification tasks.
|
|
5
|
+
- `bin/source_monitor` - CLI wrapper for invoking setup workflow.
|
|
6
|
+
- `config/initializers/source_monitor.rb` - Installer-generated initializer that may need automated edits.
|
|
7
|
+
- `docs/setup.md` - Developer-facing setup checklist documentation.
|
|
8
|
+
- `test/lib/source_monitor/setup` - Unit tests for setup orchestration services.
|
|
9
|
+
- `test/tasks/source_monitor_setup_test.rb` - Tests covering rake task behavior.
|
|
10
|
+
|
|
11
|
+
### Notes
|
|
12
|
+
|
|
13
|
+
- Add/adjust unit tests alongside new services and rake tasks to keep coverage high.
|
|
14
|
+
- Prefer Thor/Rails generator patterns already used in the engine for consistent prompts.
|
|
15
|
+
|
|
16
|
+
## Instructions for Completing Tasks
|
|
17
|
+
|
|
18
|
+
IMPORTANT: As you complete each task, check it off by changing `- [ ]` to `- [x]`. Update after every sub-task once they are added.
|
|
19
|
+
|
|
20
|
+
## Tasks
|
|
21
|
+
|
|
22
|
+
- [x] 0.0 Create feature branch
|
|
23
|
+
- [x] 0.1 Create and checkout `feature/setup-workflow-streamlining`
|
|
24
|
+
- [ ] 1.0 Build prerequisite detection and dependency helpers
|
|
25
|
+
- [x] 1.1 Design dependency checker interface (Ruby/Rails/Postgres/Node/Solid Queue)
|
|
26
|
+
- [x] 1.2 Implement version detection services with unit tests (TDD)
|
|
27
|
+
- [x] 1.3 Add remediation guidance mapping (error messages) with tests
|
|
28
|
+
- [x] 1.4 Wire helpers into CLI task to block/skip steps appropriately
|
|
29
|
+
- [x] 2.0 Implement guided setup command/workflow
|
|
30
|
+
- [x] 2.1 Scaffold Thor/Rails task entry point with prompts, ensuring specs cover CLI flow
|
|
31
|
+
- [x] 2.2 Automate Gemfile injection + `bundle install` and cover via integration-style tests/mocks
|
|
32
|
+
- [x] 2.3 Automate `npm install` detection/execution with tests for both asset pipeline modes
|
|
33
|
+
- [x] 2.4 Invoke install generator + mount path confirmation, validated by tests against dummy app
|
|
34
|
+
- [x] 2.5 Copy migrations and deduplicate Solid Queue tables with regression tests
|
|
35
|
+
- [x] 2.6 Automate initializer patching (Devise hooks optional) with unit tests covering idempotency
|
|
36
|
+
- [x] 2.7 Provide guided prompts for Devise wiring and ensure tests cover conditional behavior
|
|
37
|
+
- [x] 3.0 Add verification and telemetry tooling
|
|
38
|
+
- [x] 3.1 Implement Solid Queue worker verification service with tests simulating worker availability
|
|
39
|
+
- [x] 3.2 Implement Action Cable adapter verification (Solid Cable default, Redis optional) with tests
|
|
40
|
+
- [x] 3.3 Add reusable `source_monitor:setup:verify` task leveraging verification services with coverage
|
|
41
|
+
- [x] 3.4 Emit structured JSON + human-readable summaries; test serialization and logging
|
|
42
|
+
- [x] 3.5 Optional telemetry output (file/webhook) guarded by feature flag with tests
|
|
43
|
+
- [x] 4.0 Refresh documentation and onboarding assets
|
|
44
|
+
- [x] 4.1 Update `docs/setup.md` to mirror automated workflow, referencing new commands
|
|
45
|
+
- [x] 4.2 Document rollback steps and optional Devise system test template
|
|
46
|
+
- [x] 4.3 Ensure `.ai/tasks.md` references this slice and link to PRD/tasks documents
|
|
47
|
+
- [x] 5.0 Validate workflow end-to-end and define rollout
|
|
48
|
+
- [x] 5.1 Run setup workflow inside fresh Rails dummy app; record findings/logs
|
|
49
|
+
- [x] 5.2 Run workflow inside existing host scenario (dummy app variations); capture diffs
|
|
50
|
+
- [x] 5.3 Execute full test suite (`bin/rails test`, targeted setup tests, linters) and document results
|
|
51
|
+
- [x] 5.4 Draft release notes + rollout checklist (include CI verification task adoption plan)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: source_monitor
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- dchuk
|
|
@@ -351,7 +351,8 @@ files:
|
|
|
351
351
|
- docs/configuration.md
|
|
352
352
|
- docs/deployment.md
|
|
353
353
|
- docs/gh-cli-workflow.md
|
|
354
|
-
- docs/
|
|
354
|
+
- docs/setup-validation-log.md
|
|
355
|
+
- docs/setup.md
|
|
355
356
|
- docs/troubleshooting.md
|
|
356
357
|
- eslint.config.mjs
|
|
357
358
|
- lib/generators/source_monitor/install/install_generator.rb
|
|
@@ -426,11 +427,31 @@ files:
|
|
|
426
427
|
- lib/source_monitor/scraping/state.rb
|
|
427
428
|
- lib/source_monitor/security/authentication.rb
|
|
428
429
|
- lib/source_monitor/security/parameter_sanitizer.rb
|
|
430
|
+
- lib/source_monitor/setup/bundle_installer.rb
|
|
431
|
+
- lib/source_monitor/setup/cli.rb
|
|
432
|
+
- lib/source_monitor/setup/dependency_checker.rb
|
|
433
|
+
- lib/source_monitor/setup/detectors.rb
|
|
434
|
+
- lib/source_monitor/setup/gemfile_editor.rb
|
|
435
|
+
- lib/source_monitor/setup/initializer_patcher.rb
|
|
436
|
+
- lib/source_monitor/setup/install_generator.rb
|
|
437
|
+
- lib/source_monitor/setup/migration_installer.rb
|
|
438
|
+
- lib/source_monitor/setup/node_installer.rb
|
|
439
|
+
- lib/source_monitor/setup/prompter.rb
|
|
440
|
+
- lib/source_monitor/setup/requirements.rb
|
|
441
|
+
- lib/source_monitor/setup/shell_runner.rb
|
|
442
|
+
- lib/source_monitor/setup/verification/action_cable_verifier.rb
|
|
443
|
+
- lib/source_monitor/setup/verification/printer.rb
|
|
444
|
+
- lib/source_monitor/setup/verification/result.rb
|
|
445
|
+
- lib/source_monitor/setup/verification/runner.rb
|
|
446
|
+
- lib/source_monitor/setup/verification/solid_queue_verifier.rb
|
|
447
|
+
- lib/source_monitor/setup/verification/telemetry_logger.rb
|
|
448
|
+
- lib/source_monitor/setup/workflow.rb
|
|
429
449
|
- lib/source_monitor/sources/turbo_stream_presenter.rb
|
|
430
450
|
- lib/source_monitor/turbo_streams/stream_responder.rb
|
|
431
451
|
- lib/source_monitor/version.rb
|
|
432
452
|
- lib/tasks/recover_stalled_fetches.rake
|
|
433
453
|
- lib/tasks/source_monitor_assets.rake
|
|
454
|
+
- lib/tasks/source_monitor_setup.rake
|
|
434
455
|
- lib/tasks/source_monitor_tasks.rake
|
|
435
456
|
- lib/tasks/test_smoke.rake
|
|
436
457
|
- package-lock.json
|
|
@@ -438,6 +459,8 @@ files:
|
|
|
438
459
|
- postcss.config.js
|
|
439
460
|
- source_monitor.gemspec
|
|
440
461
|
- stylelint.config.js
|
|
462
|
+
- tasks/prd-setup-workflow-streamlining.md
|
|
463
|
+
- tasks/tasks-setup-workflow-streamlining.md
|
|
441
464
|
homepage: https://github.com/dchuk/source_monitor
|
|
442
465
|
licenses:
|
|
443
466
|
- MIT
|
data/docs/installation.md
DELETED
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
# Installation Guide
|
|
2
|
-
|
|
3
|
-
SourceMonitor installs like any other Rails engine, but it ships enough infrastructure (background jobs, realtime broadcasting, configuration DSL) that it is worth walking through the full setup. This guide assumes you are adding the engine to an existing Rails 8 host application.
|
|
4
|
-
|
|
5
|
-
## Prerequisites
|
|
6
|
-
|
|
7
|
-
- Ruby 3.4.4 (we recommend [rbenv](https://github.com/rbenv/rbenv) for local development: `rbenv install 3.4.4 && rbenv local 3.4.4`, but asdf, chruby, rvm, or container-managed Ruby all work equally well—choose whatever fits your environment)
|
|
8
|
-
- Rails 8.0.2.1 or newer
|
|
9
|
-
- PostgreSQL 13 or newer (the engine migrations rely on JSONB, SKIP LOCKED, and advisory locks)
|
|
10
|
-
- Node.js 18+ and npm or Yarn for asset linting/builds
|
|
11
|
-
- Solid Queue and Solid Cable gems available (they ship with Rails 8, but make sure they are not removed)
|
|
12
|
-
- Optional: Mission Control Jobs if you plan to surface the dashboard shortcut, Redis if you intend to switch realtime adapters
|
|
13
|
-
|
|
14
|
-
> **Command prefixes:** All commands below are shown without `rbenv exec`. If you use rbenv, prefix `bundle` and `bin/rails` commands with `rbenv exec`. For asdf, no prefix is needed. In Docker/container environments, run commands directly inside the container.
|
|
15
|
-
|
|
16
|
-
## Quick Reference
|
|
17
|
-
|
|
18
|
-
| Step | Command | Purpose |
|
|
19
|
-
| --- | --- | --- |
|
|
20
|
-
| 1 | `gem "source_monitor", github: "dchuk/source_monitor"` | Add the engine to your Gemfile |
|
|
21
|
-
| 2 | `bundle install` | Install Ruby dependencies |
|
|
22
|
-
| 3 | `bin/rails generate source_monitor:install --mount-path=/source_monitor` | Mount the engine and create the initializer |
|
|
23
|
-
| 4 | `bin/rails railties:install:migrations FROM=source_monitor` | Copy engine migrations (idempotent) |
|
|
24
|
-
| 5 | `bin/rails db:migrate` | Apply schema updates, including Solid Queue tables |
|
|
25
|
-
| 6 | `bin/rails solid_queue:start` | Ensure jobs process via Solid Queue |
|
|
26
|
-
| 7 | `bin/jobs --recurring_schedule_file=config/recurring.yml` | Start recurring scheduler (optional but recommended) |
|
|
27
|
-
|
|
28
|
-
## 1. Add the Gem
|
|
29
|
-
|
|
30
|
-
In your host application's `Gemfile`:
|
|
31
|
-
|
|
32
|
-
```ruby
|
|
33
|
-
gem "source_monitor", github: "dchuk/source_monitor"
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
Then install dependencies:
|
|
37
|
-
|
|
38
|
-
```bash
|
|
39
|
-
bundle install
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
If you vendor node tooling for linting/assets in the host app, run `npm install` as well.
|
|
43
|
-
|
|
44
|
-
## 2. Run the Install Generator
|
|
45
|
-
|
|
46
|
-
The generator mounts the engine and drops an initializer stub for you to configure.
|
|
47
|
-
|
|
48
|
-
```bash
|
|
49
|
-
bin/rails generate source_monitor:install --mount-path=/source_monitor
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
Key outputs:
|
|
53
|
-
|
|
54
|
-
- Adds `mount SourceMonitor::Engine, at: "/source_monitor"` to your routes (change the path with `--mount-path`)
|
|
55
|
-
- Creates `config/initializers/source_monitor.rb` with documented configuration defaults
|
|
56
|
-
- The generator is idempotent: re-running it will detect existing mounts/initializers and skip overwriting your customizations
|
|
57
|
-
- Update your navigation or admin layout to link to the mount path so teammates can discover the dashboard.
|
|
58
|
-
|
|
59
|
-
## 3. Copy Engine Migrations
|
|
60
|
-
|
|
61
|
-
SourceMonitor relies on several tables (sources, items, fetch logs, scrape logs, Solid Cable messages, retention helpers) plus an optional Solid Queue schema. Copy them into your host application with:
|
|
62
|
-
|
|
63
|
-
```bash
|
|
64
|
-
bin/rails railties:install:migrations FROM=source_monitor
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
This command is idempotent—re-run it when upgrading to pick up new migrations.
|
|
68
|
-
|
|
69
|
-
## 4. Run Database Migrations
|
|
70
|
-
|
|
71
|
-
Apply the new schema:
|
|
72
|
-
|
|
73
|
-
```bash
|
|
74
|
-
bin/rails db:migrate
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
If you prefer a dedicated database for Solid Queue, run `bin/rails solid_queue:install` beforehand and point the generated config at your queue database. Otherwise the engine-provided migration keeps Solid Queue tables in the primary database.
|
|
78
|
-
|
|
79
|
-
> Tip: Solid Queue tables must be present before you start the dashboard. If your host app already ran `solid_queue:install`, delete the engine-provided migration before running `db:migrate` to avoid duplication.
|
|
80
|
-
|
|
81
|
-
## 5. Wire Action Cable (if needed)
|
|
82
|
-
|
|
83
|
-
SourceMonitor defaults to Solid Cable for realtime. Rails expects `ApplicationCable::Connection` and `ApplicationCable::Channel` to exist in your host app:
|
|
84
|
-
|
|
85
|
-
```ruby
|
|
86
|
-
# app/channels/application_cable/connection.rb
|
|
87
|
-
module ApplicationCable
|
|
88
|
-
class Connection < ActionCable::Connection::Base; end
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
# app/channels/application_cable/channel.rb
|
|
92
|
-
module ApplicationCable
|
|
93
|
-
class Channel < ActionCable::Channel::Base; end
|
|
94
|
-
end
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
Verify `config/cable.yml` allows the adapter you choose. To switch to Redis, update `config/initializers/source_monitor.rb` with `config.realtime.adapter = :redis` and provide `config.realtime.redis_url`.
|
|
98
|
-
|
|
99
|
-
## 6. Configure Background Workers
|
|
100
|
-
|
|
101
|
-
Solid Queue becomes the default Active Job adapter when the host app still uses `:async`. Keep at least one worker process running:
|
|
102
|
-
|
|
103
|
-
```bash
|
|
104
|
-
# long-running process
|
|
105
|
-
bin/rails solid_queue:start
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
SourceMonitor respects explicit queue adapter overrides. If your host sets `config.active_job.queue_adapter` (for example, to `:inline` or `:sidekiq`), the engine leaves that configuration in place.
|
|
109
|
-
|
|
110
|
-
For recurring schedules, add a process that runs the Solid Queue CLI with the engine's schedule file:
|
|
111
|
-
|
|
112
|
-
```bash
|
|
113
|
-
bin/jobs --recurring_schedule_file=config/recurring.yml
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
Set `SOLID_QUEUE_SKIP_RECURRING=true` in environments that manage recurring tasks elsewhere.
|
|
117
|
-
|
|
118
|
-
## 7. Review Configuration Defaults
|
|
119
|
-
|
|
120
|
-
Open `config/initializers/source_monitor.rb` and adjust queue namespaces, HTTP timeouts, scraping adapters, retention limits, authentication hooks, and Mission Control integration to match your environment. The [configuration reference](configuration.md) covers every option with examples.
|
|
121
|
-
|
|
122
|
-
## 8. Verify the Installation
|
|
123
|
-
|
|
124
|
-
1. Start your Rails server: `bin/rails server`
|
|
125
|
-
2. Ensure a Solid Queue worker is running (see step 6)
|
|
126
|
-
3. Visit the mount path (`/source_monitor` by default)
|
|
127
|
-
4. Create a source and trigger `Fetch Now`—watch fetch logs appear and dashboard metrics update
|
|
128
|
-
|
|
129
|
-
If you encounter issues, consult the [troubleshooting guide](troubleshooting.md).
|
|
130
|
-
|
|
131
|
-
## Next Steps
|
|
132
|
-
|
|
133
|
-
- Explore the admin UI and dashboards
|
|
134
|
-
- Integrate custom scraper adapters or item processors via `SourceMonitor.configure`
|
|
135
|
-
- Set up monitoring for the Solid Queue queues using Mission Control or your preferred observability stack
|
|
136
|
-
|
|
137
|
-
## Host Compatibility Matrix
|
|
138
|
-
|
|
139
|
-
| Host Scenario | Status | Notes |
|
|
140
|
-
| --- | --- | --- |
|
|
141
|
-
| Rails 8 full-stack app | ✅ Supported | Default generator flow (mount + initializer) |
|
|
142
|
-
| Rails 8 API-only app (`--api`) | ✅ Supported | Generator mounts engine; ensure you provide a UI entry point if needed |
|
|
143
|
-
| Dedicated Solid Queue database | ✅ Supported | Run `bin/rails solid_queue:install` in the host app before copying SourceMonitor migrations |
|
|
144
|
-
| Redis-backed Action Cable | ✅ Supported | Set `config.realtime.adapter = :redis` and provide `config.realtime.redis_url`; existing `config/cable.yml` entries are preserved |
|