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

FI-2266: inferno new generator #408

Merged
merged 61 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from 60 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
b2af2fd
skeleton new thor command
Shaumik-Ashraf Nov 8, 2023
b5e5fe1
add positional argument to new generator
Shaumik-Ashraf Nov 8, 2023
8c44974
add dry-inflections dep and naming helper methods
Shaumik-Ashraf Nov 8, 2023
261d4fb
github clone based implementation
Shaumik-Ashraf Nov 10, 2023
f733014
restructure to use erb templating implementation
Shaumik-Ashraf Nov 10, 2023
40e677b
append .erb
Shaumik-Ashraf Nov 10, 2023
e988af6
use .tt suffix because it is built into thor
Shaumik-Ashraf Nov 10, 2023
a504c5a
implementing erb templates
Shaumik-Ashraf Nov 10, 2023
cb5411d
debugging
Shaumik-Ashraf Nov 13, 2023
36aa8e9
debug generator loading
Shaumik-Ashraf Nov 13, 2023
b6f41d2
implementing IG loading
Shaumik-Ashraf Nov 13, 2023
5e2831d
debugging
Shaumik-Ashraf Nov 14, 2023
4c1f7be
debugging
Shaumik-Ashraf Nov 14, 2023
cf384d7
debugging
Shaumik-Ashraf Nov 14, 2023
e375731
debugging
Shaumik-Ashraf Nov 14, 2023
65e3842
debugging
Shaumik-Ashraf Nov 14, 2023
9cc9fc1
debugging
Shaumik-Ashraf Nov 15, 2023
2e91394
debugging
Shaumik-Ashraf Nov 15, 2023
341981e
create new_spec file
Shaumik-Ashraf Nov 15, 2023
cfe5638
rspec testing for new generator WIP
Shaumik-Ashraf Nov 17, 2023
3ab2f69
factorize rspec for inferno new
Shaumik-Ashraf Nov 21, 2023
7c894e0
replace FileUtils.copy_file with Thor::Actions#get to support --pretend
Shaumik-Ashraf Nov 22, 2023
fb18c1f
add and fix name normalization tests
Shaumik-Ashraf Nov 22, 2023
179a7fb
update help description
Shaumik-Ashraf Nov 22, 2023
da8ff3c
debugging
Shaumik-Ashraf Nov 22, 2023
147068a
yank acronyms
Shaumik-Ashraf Nov 22, 2023
a8055bc
remove --pretend test, rely on Thor::Action
Shaumik-Ashraf Nov 22, 2023
df9d97c
doing rubocop and cleaning
Shaumik-Ashraf Nov 22, 2023
56ae6ff
Merge remote-tracking branch 'origin/main' into fi-2266-inferno-new
Shaumik-Ashraf Nov 22, 2023
0942980
remove new/ dir
Shaumik-Ashraf Nov 29, 2023
69ff29c
factorize naming into Utils::NamedThorActions
Shaumik-Ashraf Nov 29, 2023
37c63b3
create utils test
Shaumik-Ashraf Nov 29, 2023
e6971cf
clean comments and instance variables
Shaumik-Ashraf Nov 29, 2023
c41d874
fix ig loading and disable web connect in testing
Shaumik-Ashraf Nov 30, 2023
c7ba319
yank ig loading code
Shaumik-Ashraf Nov 30, 2023
bdeb594
add inferno new -a test
Shaumik-Ashraf Nov 30, 2023
45fb175
Merge remote-tracking branch 'origin/main' into fi-2266-inferno-new
Shaumik-Ashraf Nov 30, 2023
8cb51e1
remove github clone template line from README and bump ci
Shaumik-Ashraf Nov 30, 2023
70c313c
Merge remote-tracking branch 'origin/main' into fi-2266-inferno-new
Shaumik-Ashraf Nov 30, 2023
364ceaf
allow null progress bar in test
AlyssaWang Dec 1, 2023
782d209
Merge remote-tracking branch 'origin/main' into fi-2266-inferno-new
Shaumik-Ashraf Dec 4, 2023
6f2c927
Merge remote-tracking branch 'origin/main' into fi-2266-inferno-new
Shaumik-Ashraf Dec 8, 2023
82a0fa0
Merge remote-tracking branch 'origin/main' into fi-2266-inferno-new
Shaumik-Ashraf Dec 22, 2023
e9236d6
address PR review
Shaumik-Ashraf Dec 22, 2023
d2ea6d1
add PR suggesstion to lib/inferno/apps/cli/new.rb
Shaumik-Ashraf Dec 22, 2023
af8ec1c
add Gemfile.lock to new template
Shaumik-Ashraf Dec 22, 2023
11e4db9
remove Gemfile.lock.tt and add bundle install step in inferno new
Shaumik-Ashraf Jan 3, 2024
891f7f0
add and debug publish_template.sh script
Shaumik-Ashraf Jan 3, 2024
10b8641
rubocop conformance
Shaumik-Ashraf Jan 4, 2024
ce4a857
Merge remote-tracking branch 'origin/main' into fi-2266-inferno-new
Shaumik-Ashraf Jan 4, 2024
0c23905
put inferno-template repo url in publish_template.sh
Shaumik-Ashraf Jan 4, 2024
244751c
Merge remote-tracking branch 'origin/main' into fi-2266-inferno-new
Shaumik-Ashraf Jan 8, 2024
384240c
Merge remote-tracking branch 'origin/main' into fi-2266-inferno-new
Shaumik-Ashraf Jan 8, 2024
d05e84e
debugging
Shaumik-Ashraf Jan 8, 2024
d4bbf82
fix bundler bug in inferno new
Shaumik-Ashraf Jan 9, 2024
e4ab675
remove publish_template.sh
Shaumik-Ashraf Jan 9, 2024
de4e0cf
change fallback name from todo to put_your_name_here
Shaumik-Ashraf Jan 9, 2024
02770d5
add run inferno migrate
Shaumik-Ashraf Jan 11, 2024
5e8b482
Merge remote-tracking branch 'origin/main' into fi-2266-inferno-new
Shaumik-Ashraf Jan 11, 2024
4a6ced5
Merge remote-tracking branch 'origin/main' into fi-2266-inferno-new
Shaumik-Ashraf Jan 16, 2024
11da63d
add bundle exec to inferno migrate in lib/inferno/apps/cli/new.rb
Shaumik-Ashraf Jan 17, 2024
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
1 change: 1 addition & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ PATH
dry-configurable (= 0.13.0)
dry-container (= 0.9.0)
dry-core (= 0.8.1)
dry-inflector (= 0.3)
dry-system (= 0.20.0)
faraday (~> 1.2)
faraday_middleware (~> 1.2)
Expand Down
1 change: 1 addition & 0 deletions inferno_core.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Gem::Specification.new do |spec|
spec.add_runtime_dependency 'dry-configurable', '0.13.0'
spec.add_runtime_dependency 'dry-container', '0.9.0'
spec.add_runtime_dependency 'dry-core', '0.8.1'
spec.add_runtime_dependency 'dry-inflector', '0.3'
spec.add_runtime_dependency 'dry-system', '0.20.0'
spec.add_runtime_dependency 'faraday', '~> 1.2'
spec.add_runtime_dependency 'faraday_middleware', '~> 1.2'
Expand Down
3 changes: 3 additions & 0 deletions lib/inferno/apps/cli/main.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require_relative 'services'
require_relative 'suite'
require_relative 'suites'
require_relative 'new'

module Inferno
module CLI
Expand Down Expand Up @@ -49,6 +50,8 @@ def suites

desc 'suite SUBCOMMAND ...ARGS', 'Perform suite-based operations'
subcommand 'suite', Suite

register(New, 'new', 'new TEST_KIT_NAME', 'Run `inferno new --help` for full help')
end
end
end
103 changes: 103 additions & 0 deletions lib/inferno/apps/cli/new.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
require 'thor'
require 'bundler'
require_relative '../../utils/named_thor_actions'
require_relative '../../version'

module Inferno
module CLI
class New < Thor::Group
include Thor::Actions
include Inferno::Utils::NamedThorActions

desc <<~HELP
Generate a new Inferno test kit for FHIR software testing

Examples:

`inferno new test_fhir_app`
=> generates an Inferno app

`inferno new test_my_ig -a MyName`
=> generates Inferno app and specifies MyName as gemspec author

https://inferno-framework.github.io/index.html
HELP

def self.banner
'inferno new TEST_KIT_NAME'
end

def self.source_root
File.join(__dir__, 'templates')
end

argument :name,
type: :string,
required: true,
desc: 'name for new Inferno project'
class_option :author,
type: :string,
aliases: '-a',
default: [],
repeatable: true,
desc: "Author names for gemspec file; you may use '-a' multiple times"
class_option :skip_bundle,
type: :boolean,
aliases: '-b',
default: false,
desc: 'Do not run bundle install'

add_runtime_options!

def create_app
directory('.', root_name, { mode: :preserve, recursive: true, verbose: !options['quiet'] })

bundle_install
inferno_migrate

say_unless_quiet "Created #{root_name} Inferno test kit!", :green

return unless options['pretend']
Shaumik-Ashraf marked this conversation as resolved.
Show resolved Hide resolved

say_unless_quiet 'This was a dry run; re-run without `--pretend` to actually create project',
:yellow
end

private

def ig_path
File.join('lib', library_name, 'igs')
end

def authors
options['author'].presence || [default_author]
end

def default_author
ENV['USER'] || ENV['USERNAME'] || 'PUT_YOUR_NAME_HERE'
end

def bundle_install
return if options['skip_bundle']

inside(root_name) do
Bundler.with_unbundled_env do
run 'bundle install', verbose: !options['quiet'], capture: options['quiet']
end
end
end

def inferno_migrate
return if options['skip_bundle']

inside(root_name) do
run 'inferno migrate', verbose: !options['quiet'], capture: options['quiet']
Shaumik-Ashraf marked this conversation as resolved.
Show resolved Hide resolved
end
end

def say_unless_quiet(*args)
say(*args) unless options['quiet']
end
end
end
end
26 changes: 26 additions & 0 deletions lib/inferno/apps/cli/templates/%library_name%.gemspec.tt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Gem::Specification.new do |spec|
spec.name = '<%= library_name %>'
spec.version = '0.0.1'
spec.authors = <%= authors %>
# spec.email = ['TODO']
spec.date = Time.now.utc.strftime('%Y-%m-%d')
spec.summary = '<%= title_name %> Test Kit'
spec.description = '<%= human_name %> Inferno test kit for FHIR'
# spec.homepage = 'TODO'
spec.license = 'Apache-2.0'
spec.add_runtime_dependency 'inferno_core', '~> <%= Inferno::VERSION %>'
spec.add_development_dependency 'database_cleaner-sequel', '~> 1.8'
spec.add_development_dependency 'factory_bot', '~> 6.1'
spec.add_development_dependency 'rspec', '~> 3.10'
spec.add_development_dependency 'webmock', '~> 3.11'
spec.required_ruby_version = Gem::Requirement.new('>= 3.1.2')
# spec.metadata['homepage_uri'] = spec.homepage
# spec.metadata['source_code_uri'] = 'TODO'
spec.files = [
Dir['lib/**/*.rb'],
Dir['lib/**/*.json'],
'LICENSE'
].flatten

spec.require_paths = ['lib']
end
22 changes: 22 additions & 0 deletions lib/inferno/apps/cli/templates/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.env.local
.env.*.local
.env.development
.env.test
Dockerfile
.gitignore

.byebug_history
**/.DS_Store
.vscode/*
.project
.settings/.jsdtscope
.settings/org.eclipse.wst.jsdt.ui.superType.container
.settings/org.eclipse.wst.jsdt.ui.superType.name
.idea

/coverage
/data
/.git
/.github
/log
/tmp
1 change: 1 addition & 0 deletions lib/inferno/apps/cli/templates/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
JS_HOST=""
2 changes: 2 additions & 0 deletions lib/inferno/apps/cli/templates/.env.development
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
VALIDATOR_URL=http://localhost/validatorapi
REDIS_URL=redis://localhost:6379/0
2 changes: 2 additions & 0 deletions lib/inferno/apps/cli/templates/.env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
REDIS_URL=redis://redis:6379/0
VALIDATOR_URL=http://validator_service:4567
2 changes: 2 additions & 0 deletions lib/inferno/apps/cli/templates/.env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
VALIDATOR_URL=https://example.com/validatorapi
ASYNC_JOBS=false
20 changes: 20 additions & 0 deletions lib/inferno/apps/cli/templates/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/data/*.db
/data/redis/**/*.rdb
/data/redis/**/*.aof
/data/redis/**/*.manifest
/tmp
.env.local
.env.*.local
**/.DS_Store
.vscode/*
.project
.settings/.jsdtscope
.settings/org.eclipse.wst.jsdt.ui.superType.container
.settings/org.eclipse.wst.jsdt.ui.superType.name
.idea

/coverage
/spec/examples.txt
/docs/yard
.yardoc
node_modules
1 change: 1 addition & 0 deletions lib/inferno/apps/cli/templates/.rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--require spec_helper
1 change: 1 addition & 0 deletions lib/inferno/apps/cli/templates/.ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.1.2
1 change: 1 addition & 0 deletions lib/inferno/apps/cli/templates/.tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ruby 3.1.2
22 changes: 22 additions & 0 deletions lib/inferno/apps/cli/templates/Dockerfile.tt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM ruby:3.1.2

ENV INSTALL_PATH=/opt/inferno/
ENV APP_ENV=production
RUN mkdir -p $INSTALL_PATH

WORKDIR $INSTALL_PATH

ADD *.gemspec $INSTALL_PATH
ADD Gemfile* $INSTALL_PATH
RUN gem install bundler
# The below RUN line is commented out for development purposes, because any change to the
# required gems will break the dockerfile build process.
# If you want to run in Deploy mode, just run `bundle install` locally to update
# Gemfile.lock, and uncomment the following line.
# RUN bundle config set --local deployment 'true'
RUN bundle install

ADD . $INSTALL_PATH

EXPOSE 4567
CMD ["bundle", "exec", "puma"]
9 changes: 9 additions & 0 deletions lib/inferno/apps/cli/templates/Gemfile.tt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

source "https://rubygems.org"

gemspec

group :development, :test do
gem 'debug'
end
Loading
Loading