Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/milestone 4/116 generate button implementation #160

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
source "https://rubygems.org"

gem "rails", "8.0.0.1"
gem "rails", "8.0.1"

gem "acidic_job", "= 1.0.0.rc1"
gem "aasm", "~> 5.5.0"
Expand All @@ -11,7 +11,7 @@ gem "git", "~> 2.3.3"
gem "kamal", "~> 2.4.0", require: false
gem "thruster", "~> 0.1.9", require: false
gem "mission_control-jobs", "~> 1.0.1"
gem "noticed", "~> 2.4.3"
gem "noticed", "~> 2.5.0"
gem "litestream", "~> 0.12.0"
gem "octokit", "~> 9.2.0"
gem "omniauth-github", github: "omniauth/omniauth-github", branch: "master"
Expand All @@ -20,11 +20,11 @@ gem "pagy", "~> 9.3.3"
gem "phlex-rails", "~> 1.2.2"
gem "propshaft", "~> 1.1.0"
gem "puma", ">= 6.5.0"
gem "sentry-ruby", "~> 5.22.0"
gem "sentry-rails", "~> 5.22.0"
gem "sentry-ruby", "~> 5.22.1"
gem "sentry-rails", "~> 5.22.1"
gem "stackprof"
gem "solid_cache", "~> 1.0.6"
gem "solid_cable", "~> 3.0.4"
gem "solid_cable", "~> 3.0.5"
gem "solid_queue", "~> 1.1.0"
gem "sqlite3", "~> 2.4.1"
gem "stimulus-rails"
Expand Down
128 changes: 64 additions & 64 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -20,65 +20,65 @@ GEM
activerecord (>= 7.1)
activesupport (>= 7.1)
railties (>= 7.1)
actioncable (8.0.0.1)
actionpack (= 8.0.0.1)
activesupport (= 8.0.0.1)
actioncable (8.0.1)
actionpack (= 8.0.1)
activesupport (= 8.0.1)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
zeitwerk (~> 2.6)
actionmailbox (8.0.0.1)
actionpack (= 8.0.0.1)
activejob (= 8.0.0.1)
activerecord (= 8.0.0.1)
activestorage (= 8.0.0.1)
activesupport (= 8.0.0.1)
actionmailbox (8.0.1)
actionpack (= 8.0.1)
activejob (= 8.0.1)
activerecord (= 8.0.1)
activestorage (= 8.0.1)
activesupport (= 8.0.1)
mail (>= 2.8.0)
actionmailer (8.0.0.1)
actionpack (= 8.0.0.1)
actionview (= 8.0.0.1)
activejob (= 8.0.0.1)
activesupport (= 8.0.0.1)
actionmailer (8.0.1)
actionpack (= 8.0.1)
actionview (= 8.0.1)
activejob (= 8.0.1)
activesupport (= 8.0.1)
mail (>= 2.8.0)
rails-dom-testing (~> 2.2)
actionpack (8.0.0.1)
actionview (= 8.0.0.1)
activesupport (= 8.0.0.1)
actionpack (8.0.1)
actionview (= 8.0.1)
activesupport (= 8.0.1)
nokogiri (>= 1.8.5)
rack (>= 2.2.4)
rack-session (>= 1.0.1)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
useragent (~> 0.16)
actiontext (8.0.0.1)
actionpack (= 8.0.0.1)
activerecord (= 8.0.0.1)
activestorage (= 8.0.0.1)
activesupport (= 8.0.0.1)
actiontext (8.0.1)
actionpack (= 8.0.1)
activerecord (= 8.0.1)
activestorage (= 8.0.1)
activesupport (= 8.0.1)
globalid (>= 0.6.0)
nokogiri (>= 1.8.5)
actionview (8.0.0.1)
activesupport (= 8.0.0.1)
actionview (8.0.1)
activesupport (= 8.0.1)
builder (~> 3.1)
erubi (~> 1.11)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
activejob (8.0.0.1)
activesupport (= 8.0.0.1)
activejob (8.0.1)
activesupport (= 8.0.1)
globalid (>= 0.3.6)
activemodel (8.0.0.1)
activesupport (= 8.0.0.1)
activerecord (8.0.0.1)
activemodel (= 8.0.0.1)
activesupport (= 8.0.0.1)
activemodel (8.0.1)
activesupport (= 8.0.1)
activerecord (8.0.1)
activemodel (= 8.0.1)
activesupport (= 8.0.1)
timeout (>= 0.4.0)
activestorage (8.0.0.1)
actionpack (= 8.0.0.1)
activejob (= 8.0.0.1)
activerecord (= 8.0.0.1)
activesupport (= 8.0.0.1)
activestorage (8.0.1)
actionpack (= 8.0.1)
activejob (= 8.0.1)
activerecord (= 8.0.1)
activesupport (= 8.0.1)
marcel (~> 1.0)
activesupport (8.0.0.1)
activesupport (8.0.1)
base64
benchmark (>= 0.3)
bigdecimal
Expand Down Expand Up @@ -272,7 +272,7 @@ GEM
bigdecimal (~> 3.1)
net-http (0.6.0)
uri
net-imap (0.5.1)
net-imap (0.5.2)
date
net-protocol
net-pop (0.1.2)
Expand All @@ -299,7 +299,7 @@ GEM
racc (~> 1.4)
nokogiri (1.16.7-x86_64-linux)
racc (~> 1.4)
noticed (2.4.3)
noticed (2.5.0)
rails (>= 6.1.0)
oauth2 (2.0.9)
faraday (>= 0.17.3, < 3.0)
Expand Down Expand Up @@ -362,20 +362,20 @@ GEM
rackup (2.1.0)
rack (>= 3)
webrick (~> 1.8)
rails (8.0.0.1)
actioncable (= 8.0.0.1)
actionmailbox (= 8.0.0.1)
actionmailer (= 8.0.0.1)
actionpack (= 8.0.0.1)
actiontext (= 8.0.0.1)
actionview (= 8.0.0.1)
activejob (= 8.0.0.1)
activemodel (= 8.0.0.1)
activerecord (= 8.0.0.1)
activestorage (= 8.0.0.1)
activesupport (= 8.0.0.1)
rails (8.0.1)
actioncable (= 8.0.1)
actionmailbox (= 8.0.1)
actionmailer (= 8.0.1)
actionpack (= 8.0.1)
actiontext (= 8.0.1)
actionview (= 8.0.1)
activejob (= 8.0.1)
activemodel (= 8.0.1)
activerecord (= 8.0.1)
activestorage (= 8.0.1)
activesupport (= 8.0.1)
bundler (>= 1.15.0)
railties (= 8.0.0.1)
railties (= 8.0.1)
rails-dom-testing (2.2.0)
activesupport (>= 5.0.0)
minitest
Expand All @@ -388,9 +388,9 @@ GEM
rails-html-sanitizer (1.6.0)
loofah (~> 2.21)
nokogiri (~> 1.14)
railties (8.0.0.1)
actionpack (= 8.0.0.1)
activesupport (= 8.0.0.1)
railties (8.0.1)
actionpack (= 8.0.1)
activesupport (= 8.0.1)
irb (~> 1.13)
rackup (>= 1.0.0)
rake (>= 12.2)
Expand Down Expand Up @@ -448,10 +448,10 @@ GEM
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2, < 3.0)
websocket (~> 1.0)
sentry-rails (5.22.0)
sentry-rails (5.22.1)
railties (>= 5.0)
sentry-ruby (~> 5.22.0)
sentry-ruby (5.22.0)
sentry-ruby (~> 5.22.1)
sentry-ruby (5.22.1)
bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2)
simplecov (0.22.0)
Expand All @@ -466,7 +466,7 @@ GEM
snaky_hash (2.0.1)
hashie
version_gem (~> 1.1, >= 1.1.1)
solid_cable (3.0.4)
solid_cable (3.0.5)
actioncable (>= 7.2)
activejob (>= 7.2)
activerecord (>= 7.2)
Expand Down Expand Up @@ -574,7 +574,7 @@ DEPENDENCIES
minio (~> 0.4.0)
mission_control-jobs (~> 1.0.1)
mocha (~> 2.7.1)
noticed (~> 2.4.3)
noticed (~> 2.5.0)
octokit (~> 9.2.0)
omniauth-github!
omniauth-rails_csrf_protection
Expand All @@ -583,15 +583,15 @@ DEPENDENCIES
phlex-rails (~> 1.2.2)
propshaft (~> 1.1.0)
puma (>= 6.5.0)
rails (= 8.0.0.1)
rails (= 8.0.1)
rails-erd (~> 1.7.2)
rubocop-rails-omakase
selenium-webdriver (~> 4.27.0)
sentry-rails (~> 5.22.0)
sentry-ruby (~> 5.22.0)
sentry-rails (~> 5.22.1)
sentry-ruby (~> 5.22.1)
simplecov
simplecov-tailwindcss
solid_cable (~> 3.0.4)
solid_cable (~> 3.0.5)
solid_cache (~> 1.0.6)
solid_queue (~> 1.1.0)
sqlite3 (~> 2.4.1)
Expand Down
23 changes: 23 additions & 0 deletions app/controllers/generated_apps_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,27 @@ class GeneratedAppsController < ApplicationController
def show
@generated_app = GeneratedApp.find(params[:id])
end

def create
cli_flags = [
params[:api_flag],
params[:database_choice],
params[:rails_flags]
].compact.join(" ")

recipe = Recipe.find_or_create_by_cli_flags!(cli_flags, current_user)

@generated_app = current_user.generated_apps.create!(
name: params[:app_name],
recipe: recipe,
ruby_version: recipe.ruby_version,
rails_version: recipe.rails_version,
selected_gems: [], # We'll handle this later with ingredients
configuration_options: {} # We'll handle this later with ingredients
)

AppGeneration::Orchestrator.new(@generated_app).call

redirect_to generated_app_log_entries_path(@generated_app)
end
end
20 changes: 20 additions & 0 deletions app/controllers/github_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
class GithubController < ApplicationController
before_action :authenticate_user!

def check_name
validator = GithubRepositoryNameValidator.new(
params[:name],
current_user.github_username
)
begin
exists = validator.repo_exists?
render json: { available: !exists }
rescue Octokit::Unauthorized, Octokit::Forbidden => e
Rails.logger.error("GitHub authentication error: #{e.message}")
render json: { error: "GitHub authentication failed" }, status: :unauthorized
rescue => e
Rails.logger.error("GitHub validation error: #{e.message}")
render json: { error: "Could not validate repository name" }, status: :unprocessable_entity
end
end
end
47 changes: 0 additions & 47 deletions app/controllers/repositories_controller.rb

This file was deleted.

2 changes: 0 additions & 2 deletions app/helpers/repostitories_helper.rb

This file was deleted.

17 changes: 17 additions & 0 deletions app/javascript/controllers/app_name_preview_controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Controller } from "@hotwired/stimulus"

export default class extends Controller {
static targets = ["input"]
static outlets = ["generated-output"]

connect() {
this.update()
}

update(event) {
const value = event?.target?.value?.trim() || ""
this.generatedOutputOutlet.updateText(value)
this.dispatch("valueChanged", { detail: { value } })
this.dispatch("appNameChanged", { detail: { value } })
}
}
26 changes: 26 additions & 0 deletions app/javascript/controllers/form_values_controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Controller } from "@hotwired/stimulus"

export default class extends Controller {
static targets = ["appName", "apiFlag", "databaseChoice", "railsFlags"]

connect() {
// Initialize values from the command display
this.updateFromDisplay()
}

updateFromDisplay() {
const appNameOutput = document.getElementById("app-name-output")
const apiFlag = document.getElementById("api-flag")
const databaseChoice = document.getElementById("database-choice")
const railsFlags = document.getElementById("rails-flags")

if (appNameOutput) {
this.appNameTarget.value = appNameOutput.textContent.trim()
const event = new Event('input', { bubbles: true })
this.appNameTarget.dispatchEvent(event)
}
if (apiFlag) this.apiFlagTarget.value = apiFlag.textContent.trim()
if (databaseChoice) this.databaseChoiceTarget.value = databaseChoice.textContent.trim()
if (railsFlags) this.railsFlagsTarget.value = railsFlags.textContent.trim()
}
}
Loading
Loading