mkbrut 0.4.2 → 0.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 984d9109d176ad8c71c73dcba0ca912ac355ac5c824916467c458c0c6f8258a9
4
- data.tar.gz: add21e575b83c2c556c03bfe3e23e060d2b0fbfa88ee74f8984fa624f5914400
3
+ metadata.gz: 635f737ab220cbf181b23c3852d8d1683a6b1d0cc2d2cefe496105d3495966e5
4
+ data.tar.gz: 21ee357eb30e0b5626c43af73d0b438b4dfd9378dcaa908289931b17ac4dcbdf
5
5
  SHA512:
6
- metadata.gz: 3df7e5b66d93762bc76b7c42191db13a79bd6492a789818420789ba3c937131066c90d56490efe774acdede15cab28c805bc572c77cd3a5de7dcdcc4476c8b61
7
- data.tar.gz: 2ecf2985b10b22face53190218b33e1cbbeda2dad1d308050a15eebbd354e5013bfaf877cdc71b4da43d3cb2d1fab1f73c548820bc4087aaf19c14ab30bc34b1
6
+ metadata.gz: df92f5935742d37a62ff9688ba37c6ea28f4c85aa23933ab64aeb6502bdd57e8f1fb481e28c8841702b05e4d2f13d3d0cae754615b8776279709b5ea0c706307
7
+ data.tar.gz: 1691f7280eab746527652a60d032119c138e1e241637c1bb74d2062ae09a4af59437dbb4cc237ce1f48aca69772f7de63444e0d9aeb625d37fefe9fe71eb0cb2
@@ -28,7 +28,7 @@ private
28
28
  hash: {
29
29
  en: {
30
30
  cv: {
31
- be: {
31
+ ss: {
32
32
  not_enough_words: "%{field} does not have enough words",
33
33
  already_posted: "You've already posted a message. Thanks for that!",
34
34
  },
@@ -72,6 +72,10 @@ end
72
72
  project_root: project_root,
73
73
  import: "constraint-violations.css"
74
74
  ),
75
+ MKBrut::Ops::AddCSSImport.new(
76
+ project_root: project_root,
77
+ import: "fonts.css"
78
+ ),
75
79
  MKBrut::Ops::InsertCodeInMethod.new(
76
80
  file: project_root / "app" / "src" / "front_end" / "pages"/ "home_page.rb",
77
81
  class_name: "HomePage",
@@ -1,3 +1,3 @@
1
1
  module MKBrut
2
- VERSION = "0.4.2"
2
+ VERSION = "0.6.0"
3
3
  end
data/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "author": "Irrelevant",
6
6
  "license": "Irrelevant",
7
7
  "devDependencies": {
8
- "brut-css": "^0.0.1",
9
- "brut-js": "^0.0.21"
8
+ "brut-css": "~0.0.1",
9
+ "brut-js": "~0.0.21"
10
10
  }
11
11
  }
@@ -1,4 +1,5 @@
1
- web: PORT=6502 bin/run
2
- css: bin/watch-and-build-assets css
3
- js: bin/watch-and-build-assets js
4
- images: bin/watch-and-build-assets images
1
+ web: PORT=6502 bin/run
2
+ css: bin/watch-and-build-assets css
3
+ js: bin/watch-and-build-assets js
4
+ images: bin/watch-and-build-assets images
5
+ startup_message: PORT=6502 bin/startup-message
@@ -88,7 +88,7 @@
88
88
  },
89
89
  cv: { # short for "constraint violations" to avoid having to type that out
90
90
  this_field: "This field",
91
- fe: { # short for "front-end", again to not have to type it out
91
+ cs: { # short for "client-side", again to not have to type it out
92
92
  # These keys use camel-case because that is how the browser defines
93
93
  # these values, based on ValidityState
94
94
  badInput: "%{field} is the wrong type of data",
@@ -102,7 +102,7 @@
102
102
  valueMissing: "%{field} is required",
103
103
  general: "Form is invalid",
104
104
  },
105
- be: { # short for "back-end", again not to have to type it out
105
+ ss: { # short for "server-side", again not to have to type it out
106
106
  # These are snake case, which is idiomatic for Ruby. The values
107
107
  # here are all based on DataObjectValidator's behavior
108
108
  required: "%{field} is required",
@@ -2,11 +2,11 @@
2
2
  {
3
3
  # en: must be the first entry, thus indicating this is the EN translations
4
4
  en: {
5
- cv: { # short for "constraint violations" to avoid having to type that out
6
- be: { # short for "back-end", again not to have to type it out
7
- email_taken: "This email has been taken",
5
+ cv: {
6
+ cs: {
8
7
  },
9
- fe: { # short for "front-end", again not to have type it out
8
+ ss: {
9
+ email_taken: "This email has been taken",
10
10
  },
11
11
  },
12
12
  pages: { # Page-specific messages - this key is relied-upon by Brut to exist
@@ -1,3 +1,2 @@
1
1
  @import "brut-css/dist/brut.css";
2
2
  @import "svgs.css";
3
- @import "fonts.css";
@@ -38,9 +38,9 @@ class DefaultLayout < Brut::FrontEnd::Layout
38
38
  PageIdentifier(@page_name)
39
39
 
40
40
  # Brut::FrontEnd::Components::I18nTranslations, which includes
41
- # translations starting with cv.fe for use with client-side
41
+ # translations starting with cv.cs for use with client-side
42
42
  # constraint violation messaging.
43
- I18nTranslations("cv.fe")
43
+ I18nTranslations("cv.cs")
44
44
  # Brut::FrontEnd::Components::I18nTranslations, which includes
45
45
  # translations for cv.this_field, which is used with client-side
46
46
  # constraint violation messaging.
@@ -58,17 +58,14 @@ class DefaultLayout < Brut::FrontEnd::Layout
58
58
  )
59
59
  )
60
60
  end
61
- body do
61
+ # Adds the page's name as a class name. You can use this for
62
+ # CSS if needed.
63
+ body(class: @page_name) do
62
64
  # Render the <brut-tracing> element, which will send
63
65
  # OpenTelemetry traces back to the server to be joined up with
64
66
  # the server's traces.
65
67
  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
68
+ yield # Contents of the page are inserted here
72
69
  end
73
70
  end
74
71
  end
@@ -0,0 +1,65 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "pathname"
4
+ require "yaml"
5
+ require "optparse"
6
+
7
+ option_parser = OptionParser.new do |opts|
8
+ opts.banner = "Usage: bin/startup-message\n\n Outputs a message about where the dev server is running\n\nENVIRONMENT VARIABLES\n\n PORT - the port configured for bin/run"
9
+ end
10
+ option_parser.parse!
11
+
12
+ docker_compose_file = Pathname.new(__FILE__).dirname / ".." / "docker-compose.dx.yml"
13
+
14
+ port_config = nil
15
+ error = nil
16
+
17
+ if docker_compose_file.exist?
18
+ docker_compose = YAML.load_file(docker_compose_file)
19
+
20
+ docker_port = begin
21
+ ENV.fetch("PORT")
22
+ rescue KeyError
23
+ $stderr.puts "ERROR: The PORT environment variable is not set."
24
+ $stderr.puts " Please set it to the port your app is running on."
25
+ exit 1
26
+ end
27
+
28
+ ports_config = docker_compose.dig("services", "app", "ports")
29
+ error = nil
30
+ if ports_config
31
+ port_config = ports_config.detect { |port_mapping|
32
+ host_port, container_port = port_mapping.split(":")
33
+ container_port.to_s == docker_port
34
+ }
35
+ if !port_config
36
+ error = "#{docker_compose_file} does not expose the port #{docker_port} for the 'app' service."
37
+ end
38
+ else
39
+ error = "#{docker_compose_file} does not contain a 'ports' section for the 'app' service."
40
+ end
41
+ else
42
+ error = "#{docker_compose_file} does not exist. This is assumed to be in placefor your dev environment"
43
+ end
44
+ if !error
45
+ sleep 2 # allow all other initial output from bin/dev to happen first
46
+
47
+ host_port = port_config.split(":")[0]
48
+
49
+ url = "http://localhost:#{host_port}"
50
+
51
+ $stdout.puts "Your app is now running at"
52
+ $stdout.puts
53
+ $stdout.puts " #{url}"
54
+ $stdout.puts
55
+ $stdout.flush # ensure this output happens immediately
56
+ else
57
+ $stderr.puts "WARN: #{$0} could not figure out what port the app is exposed on"
58
+ $stderr.puts
59
+ $stderr.puts " #{error}"
60
+ $stderr.puts
61
+ $stderr.puts " This won't stop your app from running, but it does mean"
62
+ $stderr.puts " there is some issue with your dev environment"
63
+ $stderr.flush # ensure this error output happens immediately
64
+ end
65
+ sleep
@@ -9,7 +9,7 @@ class GuestbookMessageHandler < AppHandler
9
9
  # If client-side constraint violation checking was skipped,
10
10
  # but there ARE such violations, the form will be able to check
11
11
  # that server-side and return true for #constraint_violations?
12
- if !@form.constraint_violations?
12
+ if @form.valid?
13
13
  save_message
14
14
  end
15
15
 
@@ -21,10 +21,10 @@ RSpec.describe "You can leave a guestbook message" do
21
21
  this_field = t("cv.this_field")
22
22
 
23
23
  expect(name_error_message).to have_text(
24
- t("cv.fe.valueMissing", field: this_field)
24
+ t("cv.cs.valueMissing", field: this_field)
25
25
  )
26
26
  expect(message_error_message).to have_text(
27
- t("cv.fe.valueMissing", field: this_field)
27
+ t("cv.cs.valueMissing", field: this_field)
28
28
  )
29
29
 
30
30
  name_field = page.locator("form input[name='name']")
@@ -39,7 +39,7 @@ RSpec.describe "You can leave a guestbook message" do
39
39
  flash = page.locator("[role='alert']")
40
40
  expect(flash).to have_text(t(:guestbook_not_saved))
41
41
  expect(message_error_message).to have_text(
42
- t("cv.be.not_enough_words", field: this_field)
42
+ t("cv.ss.not_enough_words", field: this_field)
43
43
  )
44
44
 
45
45
  message_field.fill("OK, fine, this site is awesome!")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mkbrut
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dave Copeland
@@ -100,14 +100,12 @@ files:
100
100
  - templates/Base/app/src/app.rb.erb
101
101
  - templates/Base/app/src/back_end/data_models/app_data_model.rb
102
102
  - templates/Base/app/src/back_end/data_models/db.rb
103
- - templates/Base/app/src/back_end/data_models/migrations/00000000000000_citext.rb
103
+ - templates/Base/app/src/back_end/data_models/migrations/20240101130000_citext.rb
104
104
  - templates/Base/app/src/back_end/data_models/seed/seed_data.rb
105
105
  - templates/Base/app/src/front_end/components/app_component.rb
106
106
  - templates/Base/app/src/front_end/components/custom_element_registration.rb.erb
107
- - templates/Base/app/src/front_end/css/fonts.css
108
107
  - templates/Base/app/src/front_end/css/index.css
109
108
  - templates/Base/app/src/front_end/css/svgs.css
110
- - templates/Base/app/src/front_end/fonts/monaspace-xenon.ttf
111
109
  - templates/Base/app/src/front_end/forms/app_form.rb
112
110
  - templates/Base/app/src/front_end/handlers/app_handler.rb
113
111
  - templates/Base/app/src/front_end/images/LogoPylon.png
@@ -137,6 +135,7 @@ files:
137
135
  - templates/Base/bin/run
138
136
  - templates/Base/bin/scaffold
139
137
  - templates/Base/bin/setup
138
+ - templates/Base/bin/startup-message
140
139
  - templates/Base/bin/test
141
140
  - templates/Base/bin/test-server
142
141
  - templates/Base/bin/watch-and-build-assets
@@ -169,6 +168,8 @@ files:
169
168
  - templates/segments/Demo/app/src/back_end/data_models/migrations/20250628194124_guestbook.rb
170
169
  - templates/segments/Demo/app/src/front_end/components/flash_component.rb
171
170
  - templates/segments/Demo/app/src/front_end/css/constraint-violations.css
171
+ - templates/segments/Demo/app/src/front_end/css/fonts.css
172
+ - templates/segments/Demo/app/src/front_end/fonts/monaspace-xenon.ttf
172
173
  - templates/segments/Demo/app/src/front_end/forms/guestbook_message_form.rb
173
174
  - templates/segments/Demo/app/src/front_end/handlers/guestbook_message_handler.rb
174
175
  - templates/segments/Demo/app/src/front_end/pages/guestbook_page.rb