mkbrut 0.1.0
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/README.md +51 -0
- data/exe/mkbrut +5 -0
- data/lib/mkbrut/app.rb +67 -0
- data/lib/mkbrut/app_id.rb +8 -0
- data/lib/mkbrut/app_name.rb +29 -0
- data/lib/mkbrut/app_options.rb +29 -0
- data/lib/mkbrut/base.rb +57 -0
- data/lib/mkbrut/cli.rb +91 -0
- data/lib/mkbrut/erb_binding_delegate.rb +20 -0
- data/lib/mkbrut/internet_identifier.rb +32 -0
- data/lib/mkbrut/invalid_identifier.rb +4 -0
- data/lib/mkbrut/ops/add_css_import.rb +42 -0
- data/lib/mkbrut/ops/add_i18n_message.rb +74 -0
- data/lib/mkbrut/ops/add_method.rb +48 -0
- data/lib/mkbrut/ops/append_to_file.rb +17 -0
- data/lib/mkbrut/ops/base_op.rb +21 -0
- data/lib/mkbrut/ops/copy_file.rb +12 -0
- data/lib/mkbrut/ops/insert_code_in_method.rb +58 -0
- data/lib/mkbrut/ops/insert_route.rb +52 -0
- data/lib/mkbrut/ops/mkdir.rb +13 -0
- data/lib/mkbrut/ops/prism_parsing_op.rb +70 -0
- data/lib/mkbrut/ops/render_template.rb +26 -0
- data/lib/mkbrut/ops/skip_file.rb +10 -0
- data/lib/mkbrut/ops.rb +16 -0
- data/lib/mkbrut/organization.rb +5 -0
- data/lib/mkbrut/prefix.rb +26 -0
- data/lib/mkbrut/prefixed_io.rb +16 -0
- data/lib/mkbrut/segments/bare_bones.rb +184 -0
- data/lib/mkbrut/segments/demo.rb +117 -0
- data/lib/mkbrut/segments/sidekiq.rb +3 -0
- data/lib/mkbrut/segments.rb +7 -0
- data/lib/mkbrut/version.rb +3 -0
- data/lib/mkbrut/versions.rb +16 -0
- data/lib/mkbrut.rb +17 -0
- data/templates/Base/Dockerfile.dx +205 -0
- data/templates/Base/Gemfile.erb +53 -0
- data/templates/Base/Procfile.development +4 -0
- data/templates/Base/Procfile.test +1 -0
- data/templates/Base/README.md +4 -0
- data/templates/Base/README.md.erb +40 -0
- data/templates/Base/app/bootstrap.rb +61 -0
- data/templates/Base/app/config/i18n/en/1_defaults.rb +128 -0
- data/templates/Base/app/config/i18n/en/2_app.rb +24 -0
- data/templates/Base/app/public/static/manifest.json.erb +33 -0
- data/templates/Base/app/src/app.rb.erb +37 -0
- data/templates/Base/app/src/back_end/data_models/app_data_model.rb +5 -0
- data/templates/Base/app/src/back_end/data_models/db.rb +19 -0
- data/templates/Base/app/src/back_end/data_models/seed/seed_data.rb +9 -0
- data/templates/Base/app/src/front_end/components/app_component.rb +8 -0
- data/templates/Base/app/src/front_end/components/custom_element_registration.rb.erb +7 -0
- data/templates/Base/app/src/front_end/css/fonts.css +19 -0
- data/templates/Base/app/src/front_end/css/index.css +3 -0
- data/templates/Base/app/src/front_end/css/svgs.css +12 -0
- data/templates/Base/app/src/front_end/fonts/monaspace-xenon.ttf +0 -0
- data/templates/Base/app/src/front_end/forms/app_form.rb +4 -0
- data/templates/Base/app/src/front_end/handlers/app_handler.rb +4 -0
- data/templates/Base/app/src/front_end/images/apple-touch-icon-120x120.png +0 -0
- data/templates/Base/app/src/front_end/images/apple-touch-icon-152x152.png +0 -0
- data/templates/Base/app/src/front_end/images/apple-touch-icon-167x167.png +0 -0
- data/templates/Base/app/src/front_end/images/apple-touch-icon-180x180.png +0 -0
- data/templates/Base/app/src/front_end/images/favicon.ico +0 -0
- data/templates/Base/app/src/front_end/images/icon.png +0 -0
- data/templates/Base/app/src/front_end/images/mkicons.sh +6 -0
- data/templates/Base/app/src/front_end/js/index.js +6 -0
- data/templates/Base/app/src/front_end/layouts/default_layout.rb.erb +76 -0
- data/templates/Base/app/src/front_end/pages/app_page.rb +11 -0
- data/templates/Base/app/src/front_end/pages/home_page.rb.erb +54 -0
- data/templates/Base/app/src/front_end/support/app_session.rb +6 -0
- data/templates/Base/app/src/front_end/svgs/README.md +5 -0
- data/templates/Base/app/src/front_end/svgs/comment-button.svg +59 -0
- data/templates/Base/bin/README.md.erb +5 -0
- data/templates/Base/bin/build-assets +7 -0
- data/templates/Base/bin/ci +39 -0
- data/templates/Base/bin/console +31 -0
- data/templates/Base/bin/db +9 -0
- data/templates/Base/bin/dbconsole +51 -0
- data/templates/Base/bin/dev +25 -0
- data/templates/Base/bin/release +26 -0
- data/templates/Base/bin/run +86 -0
- data/templates/Base/bin/scaffold +9 -0
- data/templates/Base/bin/setup +256 -0
- data/templates/Base/bin/test +9 -0
- data/templates/Base/bin/test-server +29 -0
- data/templates/Base/bin/watch-and-build-assets +37 -0
- data/templates/Base/config.ru +16 -0
- data/templates/Base/docker-compose.dx.yml +85 -0
- data/templates/Base/dx/README.md +28 -0
- data/templates/Base/dx/bash_customizations +12 -0
- data/templates/Base/dx/bash_customizations.local +4 -0
- data/templates/Base/dx/build +101 -0
- data/templates/Base/dx/docker-compose.env.erb +25 -0
- data/templates/Base/dx/dx.sh.lib +137 -0
- data/templates/Base/dx/exec +56 -0
- data/templates/Base/dx/prune +19 -0
- data/templates/Base/dx/show-help-in-app-container-then-wait.sh +38 -0
- data/templates/Base/dx/start +30 -0
- data/templates/Base/dx/stop +23 -0
- data/templates/Base/package.json.erb +37 -0
- data/templates/Base/puma.config.rb +53 -0
- data/templates/Base/specs/e2e/home_page.spec.rb.erb +23 -0
- data/templates/Base/specs/front_end/js/SpecHelper.js +24 -0
- data/templates/Base/specs/front_end/pages/home_page.spec.rb +22 -0
- data/templates/Base/specs/lint_factories.spec.rb +7 -0
- data/templates/Base/specs/spec_helper.rb +78 -0
- data/templates/Base/specs/support.rb +2 -0
- data/templates/segments/BareBones/app/src/front_end/handlers/trigger_exception_handler.rb +24 -0
- data/templates/segments/BareBones/app/src/front_end/js/Example.js.erb +49 -0
- data/templates/segments/BareBones/specs/front_end/handlers/trigger_exception_handler.spec.rb +41 -0
- data/templates/segments/BareBones/specs/front_end/js/Example.spec.js.erb +38 -0
- data/templates/segments/Demo/app/src/back_end/data_models/db/guestbook_message.rb +3 -0
- data/templates/segments/Demo/app/src/back_end/data_models/migrations/20250628194124_guestbook.rb +15 -0
- data/templates/segments/Demo/app/src/front_end/components/flash_component.rb +36 -0
- data/templates/segments/Demo/app/src/front_end/css/constraint-violations.css +18 -0
- data/templates/segments/Demo/app/src/front_end/forms/guestbook_message_form.rb +4 -0
- data/templates/segments/Demo/app/src/front_end/handlers/guestbook_message_handler.rb +64 -0
- data/templates/segments/Demo/app/src/front_end/pages/guestbook_page/message_component.rb +41 -0
- data/templates/segments/Demo/app/src/front_end/pages/guestbook_page.rb +43 -0
- data/templates/segments/Demo/app/src/front_end/pages/new_guestbook_message_page.rb +64 -0
- data/templates/segments/Demo/specs/back_end/data_models/db/guestbook_message.spec.rb +5 -0
- data/templates/segments/Demo/specs/e2e/guest_message.spec.rb +54 -0
- data/templates/segments/Demo/specs/factories/db/guestbook_message.rb +7 -0
- data/templates/segments/Demo/specs/front_end/components/flash_component.spec.rb +5 -0
- data/templates/segments/Demo/specs/front_end/handlers/guestbook_message_handler.spec.rb +122 -0
- data/templates/segments/Demo/specs/front_end/pages/guestbook_page/message_component.spec.rb +5 -0
- data/templates/segments/Demo/specs/front_end/pages/guestbook_page.spec.rb +52 -0
- data/templates/segments/Demo/specs/front_end/pages/new_guestbook_message_page.spec.rb +5 -0
- metadata +195 -0
@@ -0,0 +1,12 @@
|
|
1
|
+
/* Gives all SVGS a somewhat small height so as CSS loads,
|
2
|
+
* you don't have a big huge SVG */
|
3
|
+
svg {
|
4
|
+
width: 1em;
|
5
|
+
height: 1em;
|
6
|
+
}
|
7
|
+
|
8
|
+
/* Assuming SVGs are monochrome line art,
|
9
|
+
* this ensures the lines are drawn in the current color */
|
10
|
+
svg path {
|
11
|
+
fill: currentColor;
|
12
|
+
}
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# The default layout used by all pages.
|
2
|
+
# This code is heavily commented to explain what each
|
3
|
+
# line that isn't hopefully obvious does. Feel free to remove.
|
4
|
+
class DefaultLayout < Brut::FrontEnd::Layout
|
5
|
+
include Brut::FrontEnd::Components
|
6
|
+
|
7
|
+
def initialize(page_name:)
|
8
|
+
@page_name = page_name
|
9
|
+
end
|
10
|
+
|
11
|
+
# Brut::FrontEnd::Page's view_template ultimately calls this method
|
12
|
+
# to wrap itself in the layout defined below.
|
13
|
+
def view_template
|
14
|
+
doctype
|
15
|
+
html(lang: "en") do
|
16
|
+
head do
|
17
|
+
meta(charset: "utf-8")
|
18
|
+
meta(content: "width=device-width,initial-scale=1", name:"viewport")
|
19
|
+
meta(content: "website", property:"og:type")
|
20
|
+
# Sets this up as a PWA - see app/public/static/manifest.json
|
21
|
+
link(rel: "manifest", href: "/static/manifest.json")
|
22
|
+
|
23
|
+
# Load the bundled stylesheet. asset_path translates the logical
|
24
|
+
# path to the hased value produced by esbuild
|
25
|
+
link(rel: "preload", as: "style", href: asset_path("/css/styles.css"))
|
26
|
+
link(rel: "stylesheet", href: asset_path("/css/styles.css"))
|
27
|
+
|
28
|
+
# Load the bundled JavaScript. asset_path translates the logical
|
29
|
+
# path to the hased value produced by esbuild
|
30
|
+
script(defer: true, src: asset_path("/js/app.js"))
|
31
|
+
|
32
|
+
title do
|
33
|
+
"<%= app_name %>"
|
34
|
+
end
|
35
|
+
|
36
|
+
# Brut::FrontEnd::Components::PageIdentifier, which produces
|
37
|
+
# a <meta> tag with the page's name. Useful for end to end tests.
|
38
|
+
PageIdentifier(@page_name)
|
39
|
+
|
40
|
+
# Brut::FrontEnd::Components::I18nTranslations, which includes
|
41
|
+
# translations starting with cv.fe for use with client-side
|
42
|
+
# constraint violation messaging.
|
43
|
+
I18nTranslations("cv.fe")
|
44
|
+
# Brut::FrontEnd::Components::I18nTranslations, which includes
|
45
|
+
# translations for cv.this_field, which is used with client-side
|
46
|
+
# constraint violation messaging.
|
47
|
+
I18nTranslations("cv.this_field")
|
48
|
+
# Brut::FrontEnd::Components::Traceparent, which stores
|
49
|
+
# the OpenTelemetry traceparent in a <meta> attribute for use
|
50
|
+
# by the <brut-tracing> element.
|
51
|
+
Traceparent()
|
52
|
+
# Brut::FrontEnd::Components::LocaleDetection, which
|
53
|
+
# will send the browser's locale and timezone back to the server to
|
54
|
+
# help with locale determination.
|
55
|
+
render(
|
56
|
+
Brut::FrontEnd::RequestContext.inject(
|
57
|
+
Brut::FrontEnd::Components::LocaleDetection
|
58
|
+
)
|
59
|
+
)
|
60
|
+
end
|
61
|
+
body do
|
62
|
+
# Render the <brut-tracing> element, which will send
|
63
|
+
# OpenTelemetry traces back to the server to be joined up with
|
64
|
+
# the server's traces.
|
65
|
+
brut_tracing url: "/__brut/instrumentation", show_warnings: true
|
66
|
+
# Create <main> with a class named for the page. This will
|
67
|
+
# allow you to use CSS nested selectors to style this page
|
68
|
+
# only, if that is your CSS strategy.
|
69
|
+
main class: @page_name do
|
70
|
+
yield # Contents of the page are inserted here
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# Base class for all pages in the app
|
2
|
+
# Note that while Brut::FrontEnd::Page is a subclass
|
3
|
+
# of Brut::FrontEnd::Component, that is not the case
|
4
|
+
# for your app's pages and components. Thus, there is a small amount
|
5
|
+
# of duplication here.
|
6
|
+
class AppPage < Brut::FrontEnd::Page
|
7
|
+
include Brut::Framework::Errors # See AppComponent
|
8
|
+
include CustomElementRegistration # See AppComponent
|
9
|
+
include Brut::FrontEnd::Components # See AppComponent
|
10
|
+
end
|
11
|
+
|
@@ -0,0 +1,54 @@
|
|
1
|
+
class HomePage < AppPage
|
2
|
+
def page_template
|
3
|
+
# The duplication and excessive class sizes here are to
|
4
|
+
# make it easier for you to remove this when you start working
|
5
|
+
# on your app. There are pros and cons to how this code
|
6
|
+
# is written, so don't take this is as a directive on how to
|
7
|
+
# build your app. You do you!
|
8
|
+
div(class: "flex flex-column items-center justify-center h-80vh") do
|
9
|
+
img(src: "/static/images/icon.png", class: "h-50")
|
10
|
+
h1(class: "ff-sans ma-0 lh-title f-5") do
|
11
|
+
"Welcome to Brut"
|
12
|
+
end
|
13
|
+
h2(class: "ff-sans ma-0 lh-title f-4 fw-normal") do
|
14
|
+
plain("Version ")
|
15
|
+
plain(Gem.loaded_specs["brut"].version.to_s)
|
16
|
+
end
|
17
|
+
|
18
|
+
nav(class: [ "ff-sans",
|
19
|
+
"flex",
|
20
|
+
"flex-column",
|
21
|
+
"flex-row-ns",
|
22
|
+
"items-center",
|
23
|
+
"justify-between",
|
24
|
+
"gap-3",
|
25
|
+
"mt-3",
|
26
|
+
"ph-3"
|
27
|
+
]) do
|
28
|
+
a(href: "https://brutrb.com",
|
29
|
+
target: "_blank",
|
30
|
+
class: "f-3 red-300 tdu tdn-ns hover-tdu-ns") do
|
31
|
+
code { "brutrb.com" }
|
32
|
+
end
|
33
|
+
span(role: "separator",
|
34
|
+
class: "dn di-ns f-3 red-300") do
|
35
|
+
raw(safe "✣")
|
36
|
+
end
|
37
|
+
a(href: "https://brutrb.com/api/index.html",
|
38
|
+
target: "_blank",
|
39
|
+
class: "f-3 red-300 tdu tdn-ns hover-tdu-ns") do
|
40
|
+
"API Docs"
|
41
|
+
end
|
42
|
+
span(role: "separator",
|
43
|
+
class: "dn di-ns f-3 red-300") do
|
44
|
+
raw(safe "✣")
|
45
|
+
end
|
46
|
+
a(href: "http://localhost:6504",
|
47
|
+
target: "_blank",
|
48
|
+
class: "f-3 red-300 tdu tdn-ns hover-tdu-ns") do
|
49
|
+
"Local OpenTelemetry"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
2
|
+
<svg
|
3
|
+
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
4
|
+
xmlns:cc="http://creativecommons.org/ns#"
|
5
|
+
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
6
|
+
xmlns:svg="http://www.w3.org/2000/svg"
|
7
|
+
xmlns="http://www.w3.org/2000/svg"
|
8
|
+
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
9
|
+
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
10
|
+
aria-label="Comment"
|
11
|
+
class="_8-yf5 "
|
12
|
+
fill="#262626"
|
13
|
+
height="24"
|
14
|
+
viewBox="0 0 48 48"
|
15
|
+
width="24"
|
16
|
+
version="1.1"
|
17
|
+
id="svg22"
|
18
|
+
sodipodi:docname="comment button.svg"
|
19
|
+
inkscape:version="0.92.4 (5da689c313, 2019-01-14)">
|
20
|
+
<metadata
|
21
|
+
id="metadata28">
|
22
|
+
<rdf:RDF>
|
23
|
+
<cc:Work
|
24
|
+
rdf:about="">
|
25
|
+
<dc:format>image/svg+xml</dc:format>
|
26
|
+
<dc:type
|
27
|
+
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
28
|
+
<dc:title></dc:title>
|
29
|
+
</cc:Work>
|
30
|
+
</rdf:RDF>
|
31
|
+
</metadata>
|
32
|
+
<defs
|
33
|
+
id="defs26" />
|
34
|
+
<sodipodi:namedview
|
35
|
+
pagecolor="#ffffff"
|
36
|
+
bordercolor="#666666"
|
37
|
+
borderopacity="1"
|
38
|
+
objecttolerance="10"
|
39
|
+
gridtolerance="10"
|
40
|
+
guidetolerance="10"
|
41
|
+
inkscape:pageopacity="0"
|
42
|
+
inkscape:pageshadow="2"
|
43
|
+
inkscape:window-width="1920"
|
44
|
+
inkscape:window-height="1001"
|
45
|
+
id="namedview24"
|
46
|
+
showgrid="false"
|
47
|
+
inkscape:zoom="23.805928"
|
48
|
+
inkscape:cx="12.634482"
|
49
|
+
inkscape:cy="10.463496"
|
50
|
+
inkscape:window-x="-9"
|
51
|
+
inkscape:window-y="-9"
|
52
|
+
inkscape:window-maximized="1"
|
53
|
+
inkscape:current-layer="svg22" />
|
54
|
+
<path
|
55
|
+
d="M47.5 46.1l-2.8-11c1.8-3.3 2.8-7.1 2.8-11.1C47.5 11 37 .5 24 .5S.5 11 .5 24 11 47.5 24 47.5c4 0 7.8-1 11.1-2.8l11 2.8c.8.2 1.6-.6 1.4-1.4zm-3-22.1c0 4-1 7-2.6 10-.2.4-.3.9-.2 1.4l2.1 8.4-8.3-2.1c-.5-.1-1-.1-1.4.2-1.8 1-5.2 2.6-10 2.6-11.4 0-20.6-9.2-20.6-20.5S12.7 3.5 24 3.5 44.5 12.7 44.5 24z"
|
56
|
+
id="path20"
|
57
|
+
clip-rule="evenodd"
|
58
|
+
fill-rule="evenodd" />
|
59
|
+
</svg>
|
@@ -0,0 +1,39 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
set -e
|
4
|
+
|
5
|
+
usage() {
|
6
|
+
echo "Usage: $0"
|
7
|
+
echo
|
8
|
+
echo " Run all tests and quality checks, as if on a CI server"
|
9
|
+
echo
|
10
|
+
}
|
11
|
+
|
12
|
+
for arg in "$@"; do
|
13
|
+
if [ "${arg}" = "-h" ] || [ "${arg}" = "--help" ] || [ "${arg}" = "help" ]; then
|
14
|
+
usage
|
15
|
+
exit 0
|
16
|
+
fi
|
17
|
+
done
|
18
|
+
|
19
|
+
|
20
|
+
echo "[ bin/ci ] Building Assets"
|
21
|
+
bin/build-assets
|
22
|
+
|
23
|
+
echo "[ bin/ci ] Running non E2E tests"
|
24
|
+
bin/test run --rebuild
|
25
|
+
|
26
|
+
echo "[ bin/ci ] Running JS tests"
|
27
|
+
bin/test js
|
28
|
+
|
29
|
+
echo "[ bin/ci ] Running E2E tests"
|
30
|
+
bin/test e2e --rebuild --rebuild-after
|
31
|
+
|
32
|
+
echo "[ bin/ci ] Analyzing Ruby gems for"
|
33
|
+
echo "[ bin/ci ] security vulnerabilities"
|
34
|
+
bundle exec bundle audit check --update
|
35
|
+
|
36
|
+
echo "[ bin/ci ] Checking to see that all classes have tests"
|
37
|
+
bin/test audit --ignore app/src/front_end/components/custom_element_registration.rb
|
38
|
+
|
39
|
+
echo "[ bin/ci ] Done"
|
@@ -0,0 +1,31 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "optparse"
|
4
|
+
|
5
|
+
option_parser = OptionParser.new do |opts|
|
6
|
+
opts.banner = "Usage: bin/console [options]\n\n Get an IRB session with your app loaded in the development RACK_ENV\n\nOPTIONS"
|
7
|
+
|
8
|
+
opts.on("-h", "--help", "Display this help message") do
|
9
|
+
puts opts
|
10
|
+
exit
|
11
|
+
end
|
12
|
+
end
|
13
|
+
option_parser.parse!
|
14
|
+
if ARGV[0] == "help"
|
15
|
+
puts option_parser
|
16
|
+
exit
|
17
|
+
end
|
18
|
+
|
19
|
+
ENV["RACK_ENV"] = "development"
|
20
|
+
if ENV["LOG_LEVEL"].to_s == ""
|
21
|
+
ENV["LOG_LEVEL"] = "warn"
|
22
|
+
end
|
23
|
+
require "pathname"
|
24
|
+
require "dotenv"
|
25
|
+
|
26
|
+
project_root = Pathname(__dir__) / ".."
|
27
|
+
Dotenv.load(project_root / ".env.development.local",
|
28
|
+
project_root / ".env.development")
|
29
|
+
require_relative project_root / "app" / "bootstrap"
|
30
|
+
Bootstrap.new.bootstrap!
|
31
|
+
binding.irb
|
@@ -0,0 +1,51 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
set -e
|
4
|
+
SCRIPT_DIR=$( cd -- "$( dirname -- "${0}" )" > /dev/null 2>&1 && pwd )
|
5
|
+
|
6
|
+
usage() {
|
7
|
+
echo "Usage: $0 -e env"
|
8
|
+
echo
|
9
|
+
echo " Get a PostgreSQL console for the specified environment"
|
10
|
+
echo
|
11
|
+
echo "OPTIONS"
|
12
|
+
echo
|
13
|
+
echo " env - 'test' or 'development' (default is 'development')"
|
14
|
+
}
|
15
|
+
for arg in "${@}"; do
|
16
|
+
if [ "${arg}" = "-h" ] || [ "${arg}" = "--help" ] || [ "${arg}" = "help" ]; then
|
17
|
+
usage
|
18
|
+
exit 0
|
19
|
+
fi
|
20
|
+
done
|
21
|
+
|
22
|
+
RACK_ENV=development
|
23
|
+
while getopts ":e:" opt "${@}"; do
|
24
|
+
case ${opt} in
|
25
|
+
e )
|
26
|
+
RACK_ENV="${OPTARG}"
|
27
|
+
;;
|
28
|
+
\? )
|
29
|
+
echo "[ $0 ] Unknown option: ${opt}"
|
30
|
+
usage
|
31
|
+
exit 1
|
32
|
+
;;
|
33
|
+
: )
|
34
|
+
echo "[ $0 ] Invalid option: ${opt}"
|
35
|
+
exit 0
|
36
|
+
usage
|
37
|
+
;;
|
38
|
+
esac
|
39
|
+
done
|
40
|
+
shift $((OPTIND -1))
|
41
|
+
ENV_FILE="${SCRIPT_DIR}"/../".env.${RACK_ENV}"
|
42
|
+
|
43
|
+
if [ -e "${ENV_FILE}" ]; then
|
44
|
+
database_url=$(grep DATABASE_URL "${ENV_FILE}" | sed 's/^[^=]*=//g')
|
45
|
+
psql "${database_url}"
|
46
|
+
else
|
47
|
+
echo "[ $0 ] error: '${RACK_ENV}' is not a valid environment"
|
48
|
+
echo
|
49
|
+
usage
|
50
|
+
exit 1
|
51
|
+
fi
|
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
set -e
|
4
|
+
SCRIPT_DIR=$( cd -- "$( dirname -- "${0}" )" > /dev/null 2>&1 && pwd )
|
5
|
+
ROOT_DIR="${SCRIPT_DIR}/.."
|
6
|
+
|
7
|
+
usage() {
|
8
|
+
echo "Usage: $0"
|
9
|
+
echo
|
10
|
+
echo " Run the app for local development, with asset and code reloading"
|
11
|
+
echo
|
12
|
+
}
|
13
|
+
|
14
|
+
for arg in "$@"; do
|
15
|
+
if [ "${arg}" = "-h" ] || [ "${arg}" = "--help" ] || [ "${arg}" = "help" ]; then
|
16
|
+
usage
|
17
|
+
exit 0
|
18
|
+
fi
|
19
|
+
done
|
20
|
+
|
21
|
+
RACK_ENV="development"
|
22
|
+
export RACK_ENV
|
23
|
+
"${SCRIPT_DIR}"/build-assets
|
24
|
+
foreman start --procfile "${ROOT_DIR}/Procfile.${RACK_ENV}" --root "${ROOT_DIR}"
|
25
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
set -e
|
3
|
+
|
4
|
+
usage() {
|
5
|
+
echo "Usage: $0"
|
6
|
+
echo
|
7
|
+
echo " Run tasks on production after code is avaiable, but before deployment"
|
8
|
+
echo
|
9
|
+
}
|
10
|
+
|
11
|
+
for arg in "$@"; do
|
12
|
+
if [ "${arg}" = "-h" ] || [ "${arg}" = "--help" ] || [ "${arg}" = "help" ]; then
|
13
|
+
usage
|
14
|
+
exit 0
|
15
|
+
fi
|
16
|
+
done
|
17
|
+
|
18
|
+
echo "[ bin/release ] started"
|
19
|
+
echo "[ bin/release ] Creating DB if needed"
|
20
|
+
BRUT_CLI_RAISE_ON_ERROR=true bundle exec ./bin/db create --env=production
|
21
|
+
echo "[ bin/release ] Migrating DB if needed"
|
22
|
+
BRUT_CLI_RAISE_ON_ERROR=true bundle exec ./bin/db migrate --env=production
|
23
|
+
|
24
|
+
# Add additional commands here as needed
|
25
|
+
|
26
|
+
echo "[ bin/release ] DONE"
|
@@ -0,0 +1,86 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
|
3
|
+
set -e
|
4
|
+
SCRIPT_DIR=$( cd -- "$( dirname -- "${0}" )" > /dev/null 2>&1 && pwd )
|
5
|
+
|
6
|
+
usage() {
|
7
|
+
echo "Usage: $0"
|
8
|
+
echo
|
9
|
+
echo " Run the app in the given RACK_ENV."
|
10
|
+
echo " You likely want to use bin/dev instead of this command."
|
11
|
+
echo
|
12
|
+
echo "ENVIRONMENT VARIABLES"
|
13
|
+
echo
|
14
|
+
echo " PORT - The port to run the app on. Default is 6502"
|
15
|
+
echo " RACK_ENV - The Rack environment to use. Default is development"
|
16
|
+
echo
|
17
|
+
}
|
18
|
+
|
19
|
+
for arg in "$@"; do
|
20
|
+
if [ "${arg}" = "-h" ] || [ "${arg}" = "--help" ] || [ "${arg}" = "help" ]; then
|
21
|
+
usage
|
22
|
+
exit 0
|
23
|
+
fi
|
24
|
+
done
|
25
|
+
|
26
|
+
PORT="${PORT:-6502}"
|
27
|
+
RACK_ENV="${RACK_ENV:-development}"
|
28
|
+
|
29
|
+
export PORT
|
30
|
+
export RACK_ENV
|
31
|
+
|
32
|
+
set -e
|
33
|
+
|
34
|
+
# Everything here is trying its best to prevent more than
|
35
|
+
# one server from running, as this is extremely confusing.
|
36
|
+
# Note that the puma invocation at the bottom
|
37
|
+
# of this script uses the pidfile concept.
|
38
|
+
if [ -f tmp/pidfile ]; then
|
39
|
+
echo "[ $0 ] pidfile found"
|
40
|
+
pid=$(cat tmp/pidfile)
|
41
|
+
|
42
|
+
# First, try to gracefully stop the server with kill
|
43
|
+
if ps -p "${pid}" > /dev/null; then
|
44
|
+
echo "[ $0 ] Attempting to kill PID '${pid}'"
|
45
|
+
kill "${pid}"
|
46
|
+
else
|
47
|
+
echo "[ $0 ] PID '${pid}' no longer running"
|
48
|
+
fi
|
49
|
+
|
50
|
+
# Now, wait 5 seconds to see if it stopped
|
51
|
+
if timeout 5 tail --pid="${pid}" -f /dev/null; then
|
52
|
+
echo "[ $0 ] PID '${pid}' stopped. Restarting server"
|
53
|
+
else
|
54
|
+
# if it has not stopeed, use kill -9 which should work.
|
55
|
+
# But, like all things computer, it's not guaranteed.
|
56
|
+
echo "[ $0 ] PID '${pid}' has not stopped. Trying kill -9"
|
57
|
+
kill -9 "${pid}"
|
58
|
+
if timeout 1 tail --pid="${pid}" -f /dev/null; then
|
59
|
+
echo "[ $0 ] PID '${pid}' killed. Restarting server"
|
60
|
+
else
|
61
|
+
echo "[ $0 ] PID '${pid}' still running. Something seriously wrong"
|
62
|
+
echo "[ $0 ] You may need to stop all Docker containers and restart them"
|
63
|
+
exit 1
|
64
|
+
fi
|
65
|
+
fi
|
66
|
+
|
67
|
+
else
|
68
|
+
echo "[ $0 ] No pidfile-Starting up"
|
69
|
+
fi
|
70
|
+
|
71
|
+
# Run puma in a UNIX environment provided by dotenv.
|
72
|
+
#
|
73
|
+
# A few things to note:
|
74
|
+
#
|
75
|
+
# * dotenv is OK if -f is given non-existent files. That's why this works
|
76
|
+
# in production where there are no .env files.
|
77
|
+
# * the `--` marks the end of dotenv's options and the start of the command
|
78
|
+
# to run. That's why the flags given to puma are not interpreted by dotenv
|
79
|
+
# as flags for itself.
|
80
|
+
dotenv \
|
81
|
+
-f "${SCRIPT_DIR}/../.env.${RACK_ENV}.local,${SCRIPT_DIR}/../.env.${RACK_ENV}" \
|
82
|
+
--ignore \
|
83
|
+
-- \
|
84
|
+
bin/puma \
|
85
|
+
-C puma.config.rb \
|
86
|
+
--pid tmp/pidfile
|