gemstack-cli 0.2.2 → 0.2.4

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: 8f9ebe8567d9943d054f3baaf1427483fd75242677bc8a461034d63a826b197e
4
- data.tar.gz: 816d6520c304822b290f30b417f574dfe8bd771586d5bc8a6df2b929ec144b4f
3
+ metadata.gz: 7896a4b00040ddd5556a6923b290c0fc08bcad07884246023343f5a84e7356c7
4
+ data.tar.gz: 30d763aa7d951a808183769dce19cd92b4c577b7aabc9c17af29ec7197b8eda2
5
5
  SHA512:
6
- metadata.gz: 7068ec73cee6b4f0e87cb5c84a4f0531bbfd8444df9170a994e6223f8a32cf7d5b814ef089bc5c5854ce539e919bc9a5dde10118dcfcd035ac02099bff5e5e28
7
- data.tar.gz: f1c8ddf36a3b0eb81f7a1a680b5c95bfa8df8328dbbf0804f927bfb85339f02fba020cb6e8d66e16f0c14fff3902a2183bd49a212dc1a39bf3ce650365b55b62
6
+ metadata.gz: 65e7fbeb0df98c81341c1cbb4f0a65ad7d8a13b590479fb47b7f100aec542504cd56c1e1f06154ab75b7ea02278a3ccf98ef62e998e71b81026132480bfdb71b
7
+ data.tar.gz: b35aff968928d09ca121b29607d579ede74c74829cd55713b001462f5d73e6b69087a31b0389239a53278e637ee678e1877d59497e3f7e201727d96f89a7948a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.4
4
+
5
+ See the [GemStack changelog](https://github.com/gemstack-rb/gemstack/blob/main/CHANGELOG.md).
6
+
7
+ ## 0.2.3
8
+
9
+ See the [GemStack changelog](https://github.com/gemstack-rb/gemstack/blob/main/CHANGELOG.md).
10
+
3
11
  ## 0.2.2
4
12
 
5
13
  See the [GemStack changelog](https://github.com/gemstack-rb/gemstack/blob/main/CHANGELOG.md).
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "gemstack/dev"
4
+
3
5
  module GemStack
4
6
  class CLI < Thor
5
7
  # `gemstack new NAME` — a Ruby API + Next.js application containing the
@@ -30,8 +32,12 @@ module GemStack
30
32
 
31
33
  def version = GemStack::VERSION
32
34
 
33
- # Pins the app to the Ruby that generated it (.ruby-version, .tool-versions).
35
+ # Pins the app to the Ruby that generated it, in files every version
36
+ # manager reads (.ruby-version: rbenv, rvm, chruby, asdf, mise;
37
+ # .tool-versions: asdf, mise), and Node.js likewise (.node-version,
38
+ # .nvmrc, .tool-versions) — DECISIONS D-066.
34
39
  def ruby_version = RUBY_VERSION
40
+ def node_version = @node_version ||= Dev::Toolchain.pinned_node_version
35
41
  def frontend? = !@options[:skip_frontend]
36
42
  def database? = !@options[:skip_database]
37
43
 
@@ -54,7 +60,8 @@ module GemStack
54
60
  database_adapter if database? # fail early on an unknown --database
55
61
  @output.puts("Creating GemStack application #{name} in #{destination}")
56
62
  render_directory("app", destination, skip: lambda { |rel|
57
- !database? && (rel.start_with?("db/", "app/models/") || rel == "config/database.yml.tt")
63
+ (!database? && (rel.start_with?("db/", "app/models/") || rel == "config/database.yml.tt")) ||
64
+ (!frontend? && %w[dot_node-version.tt dot_nvmrc.tt].include?(rel))
58
65
  })
59
66
  render_directory("frontend", File.join(destination, "frontend")) if frontend?
60
67
  install unless @options[:skip_install]
@@ -2,6 +2,7 @@
2
2
 
3
3
  require "open3"
4
4
  require "socket"
5
+ require "gemstack/dev"
5
6
 
6
7
  module GemStack
7
8
  class CLI < Thor
@@ -50,11 +51,11 @@ module GemStack
50
51
 
51
52
  def check_ruby
52
53
  wanted = read(".ruby-version")&.strip&.delete_prefix("ruby-")
53
- if wanted && !wanted.empty? && !RUBY_VERSION.start_with?(wanted)
54
- caution("Ruby #{RUBY_VERSION}",
55
- "the app pins #{wanted} (.ruby-version) — install it: asdf install ruby #{wanted}")
56
- elsif Gem::Version.new(RUBY_VERSION) < Gem::Version.new("4.0")
57
- problem("Ruby #{RUBY_VERSION}", "GemStack needs Ruby 4.0 or newer")
54
+ if !Dev::Toolchain.ruby_ok?
55
+ problem("Ruby #{RUBY_VERSION}", "GemStack needs Ruby #{Dev::Toolchain::MIN_RUBY} or newer — " \
56
+ "#{Dev::Toolchain.ruby_hint(wanted.to_s.empty? ? "3.4" : wanted)}")
57
+ elsif wanted && !wanted.empty? && !RUBY_VERSION.start_with?(wanted)
58
+ caution("Ruby #{RUBY_VERSION}", "the app pins #{wanted} (.ruby-version) — #{Dev::Toolchain.ruby_hint(wanted)}")
58
59
  else
59
60
  pass("Ruby #{RUBY_VERSION}#{" (YJIT available)" if defined?(RubyVM::YJIT)}")
60
61
  end
@@ -63,17 +64,17 @@ module GemStack
63
64
  def check_node
64
65
  return unless File.directory?(path("frontend"))
65
66
 
66
- out, status = @run.call("node", "--version")
67
- version = status.success? ? out.strip.delete_prefix("v") : nil
68
- if version.nil?
69
- problem("Node.js not found", "install Node.js #{MIN_NODE.join(".")}+ (the frontend is Next.js)")
70
- elsif (version.split(".").map(&:to_i) <=> MIN_NODE).negative?
71
- problem("Node.js #{version}", "Next.js 16 needs Node.js #{MIN_NODE.join(".")} or newer")
67
+ node = Dev::Toolchain.node(@run)
68
+ wanted = read(".node-version")&.strip || read(".nvmrc")&.strip || Dev::Toolchain::LTS_NODE
69
+ if node.nil?
70
+ problem("Node.js not found", Dev::Toolchain.node_hint(wanted, nil))
71
+ elsif !Dev::Toolchain.node_ok?(node[:version])
72
+ problem("Node.js #{node[:version]} (#{node[:path]})",
73
+ "Next.js 16 needs #{MIN_NODE.join(".")}+ — " \
74
+ "#{Dev::Toolchain.node_hint(wanted, Dev::Toolchain.node_manager(node[:path]))}")
72
75
  else
73
- pass("Node.js #{version}")
76
+ pass("Node.js #{node[:version]}")
74
77
  end
75
- rescue SystemCallError
76
- problem("Node.js not found", "install Node.js #{MIN_NODE.join(".")}+ (the frontend is Next.js)")
77
78
  end
78
79
 
79
80
  def check_frontend_dependencies
data/lib/gemstack/cli.rb CHANGED
@@ -86,7 +86,7 @@ module GemStack
86
86
  method_option :grep, aliases: "-g", type: :string, desc: "Only routes matching this text"
87
87
  def routes
88
88
  root = Project.ensure_bundle!(self.class.argv)
89
- ENV["GEMSTACK_ENV"] ||= "development"
89
+ use_environment!
90
90
  Project.load_config!(root)
91
91
  GemStack.config.reload_code = false
92
92
  GemStack.config.logger.level = :warn
@@ -101,7 +101,7 @@ module GemStack
101
101
  desc "console", "Start an IRB session with the application loaded (alias: c)"
102
102
  def console
103
103
  root = Project.ensure_bundle!(self.class.argv)
104
- ENV["GEMSTACK_ENV"] = options[:environment] || ENV["GEMSTACK_ENV"] || "development"
104
+ use_environment!
105
105
  Project.load_config!(root)
106
106
  GemStack.boot!
107
107
  require "irb"
@@ -228,6 +228,9 @@ module GemStack
228
228
  end
229
229
 
230
230
  no_commands do
231
+ # -e ENV, else GEMSTACK_ENV, else development.
232
+ def use_environment! = ENV["GEMSTACK_ENV"] = options[:environment] || ENV["GEMSTACK_ENV"] || "development"
233
+
231
234
  def generate_model(root, name, args)
232
235
  abort("Usage: gemstack generate model NAME field:type ...") unless name && !args.empty?
233
236
  spec = ResourceSpec.new(name, args)
@@ -38,7 +38,7 @@ gem "<%= driver_gem %>", "<%= driver_version %>" # the <%= database_adapter %> d
38
38
  # gem "stripe"
39
39
 
40
40
  group :development, :test do
41
- gem "irb" # `gemstack console`; a bundled (not default) gem since Ruby 4.0
41
+ gem "irb" # `gemstack console` (a bundled gem, not a default one, in newer Rubies)
42
42
  gem "minitest", "~> 5.25"
43
43
  gem "rack-test", "~> 2.2"
44
44
  end
@@ -12,19 +12,43 @@ Bundler.require(:default, GemStack.env.to_sym)
12
12
  GemStack.configure do |config|
13
13
  config.name = "<%= name %>"
14
14
 
15
- # Everything below is optional — these are the defaults. See docs/configuration.md.
16
- #
15
+ # Settings for every environment. Everything below is optional: each line
16
+ # shows the default — uncomment one to change it. Per-environment settings go
17
+ # in config/environments/*.rb. All settings: docs/configuration.md.
18
+
19
+ # ── HTTP ────────────────────────────────────────────────────────────────
17
20
  # config.http.api_path = "/api" # where the API lives (routes are relative to it)
18
21
  # config.http.max_body_size = 10 * 1024 * 1024 # bytes; larger requests get 413
19
22
  # config.http.json = :json # or :oj (add gem "oj"), or your own codec
20
23
  # config.http.cors.origins = [] # only for frontends on another domain
21
24
  # config.http.middleware.use MyMiddleware # add / insert_before / swap / delete
22
- # config.logger.level = :debug
23
- # config.filter_parameters += %w[iban] # masked in logs
25
+
26
+ # ── Pagination: paginate(...) in controllers, ?page=2&per_page=50 (docs/pagination.md) ──
27
+ # config.http.pagination.per_page = 25 # records per page when the client doesn't say
28
+ # config.http.pagination.max_per_page = 100 # the most a client may ask for with ?per_page=
29
+
30
+ # ── Responses ───────────────────────────────────────────────────────────
31
+ # config.http.compression.enabled = true # gzip/Brotli responses over 1 KB (add gem "brotli" for br)
32
+ # config.http.etags = true # ETag + 304 Not Modified for GET responses
33
+
34
+ # ── Logging ─────────────────────────────────────────────────────────────
35
+ # config.logger.level = :debug # :info in production (or GEMSTACK_LOG_LEVEL)
36
+ # config.filter_parameters += %w[iban] # masked in logs, next to password, token, secret…
24
37
  <% if database? -%>
25
- #
26
- # Connection: config/database.yml (DATABASE_URL / TEST_DATABASE_URL override it).
38
+
39
+ # ── Database — the connection is in config/database.yml (DATABASE_URL overrides it) ──
27
40
  # config.db.pool_size = 5 # default: GEMSTACK_MAX_THREADS (one per Puma thread)
28
41
  # config.db.statement_timeout = 5_000 # ms
29
42
  <% end -%>
43
+
44
+ # ── Cache (GemStack.cache) ──────────────────────────────────────────────
45
+ # config.cache.store = :memory # :redis to share it between processes (gem "redis-client")
46
+ # config.cache.default_expires_in = nil # seconds; nil = until evicted
47
+
48
+ # ── Background jobs ─────────────────────────────────────────────────────
49
+ # config.jobs.default_queue = "default"
50
+ # config.jobs.default_max_attempts = 10 # then the job is kept as failed
51
+
52
+ # ── Mail ────────────────────────────────────────────────────────────────
53
+ # config.mail.default_from = "<%= name %> <no-reply@localhost>" # or MAIL_FROM
30
54
  end
@@ -0,0 +1 @@
1
+ <%= node_version %>
@@ -0,0 +1 @@
1
+ <%= node_version %>
@@ -1 +1,4 @@
1
1
  ruby <%= ruby_version %>
2
+ <% if frontend? -%>
3
+ nodejs <%= node_version %>
4
+ <% end -%>
@@ -11,10 +11,11 @@ export const <%= spec.variable %>Keys = {
11
11
  };
12
12
  <% if spec.action?(:index) -%>
13
13
 
14
- export function use<%= spec.plural_class %>(page = 1) {
14
+ // perPage: records per page; omit it to use the API's default (config.http.pagination.per_page).
15
+ export function use<%= spec.plural_class %>(page = 1, perPage?: number) {
15
16
  return useQuery({
16
- queryKey: [...<%= spec.variable %>Keys.all, "page", page],
17
- queryFn: () => <%= spec.client_name %>.list({ page }),
17
+ queryKey: [...<%= spec.variable %>Keys.all, "page", page, perPage],
18
+ queryFn: () => <%= spec.client_name %>.list({ page, per_page: perPage }),
18
19
  placeholderData: keepPreviousData, // keep the current page visible while the next one loads
19
20
  });
20
21
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gemstack-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adware Technologies
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.2.2
19
+ version: 0.2.4
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 0.2.2
26
+ version: 0.2.4
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: gemstack-dev
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 0.2.2
33
+ version: 0.2.4
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 0.2.2
40
+ version: 0.2.4
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: thor
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -99,6 +99,8 @@ files:
99
99
  - templates/app/db/seeds.rb
100
100
  - templates/app/dot_env.example.tt
101
101
  - templates/app/dot_gitignore
102
+ - templates/app/dot_node-version.tt
103
+ - templates/app/dot_nvmrc.tt
102
104
  - templates/app/dot_ruby-version.tt
103
105
  - templates/app/dot_tool-versions.tt
104
106
  - templates/app/test/health_test.rb
@@ -190,7 +192,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
190
192
  requirements:
191
193
  - - ">="
192
194
  - !ruby/object:Gem::Version
193
- version: '4.0'
195
+ version: '3.3'
194
196
  required_rubygems_version: !ruby/object:Gem::Requirement
195
197
  requirements:
196
198
  - - ">="