skyward 0.4.0 → 0.4.1
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 +4 -4
- data/LICENSE +21 -0
- data/README.md +2 -2
- data/lib/skyward/generator/cli/new/template/Gemfile.tt +8 -8
- data/lib/skyward/generator/cli/new/template/Rakefile.tt +1 -1
- data/lib/skyward/generator/cli/new/template/Steepfile.tt +3 -3
- data/lib/skyward/generator/cli/new/template/app.rb.tt +2 -2
- data/lib/skyward/generator/cli/new/template/boot.rb.tt +5 -5
- data/lib/skyward/generator/cli/new/template/config.ru.tt +1 -1
- data/lib/skyward/generator/cli/new/template/lib/health_api.rb.tt +3 -3
- data/lib/skyward/generator/cli/new/template/test/app_test.rb.tt +11 -11
- data/lib/skyward/generator/cli/new/template/test/lib/health_api_test.rb.tt +4 -4
- data/lib/skyward/generator/cli/new/template/test/test_helper.rb.tt +6 -6
- data/lib/skyward/generator/cli/new/template.rb +3 -3
- data/lib/skyward/generator/cli/new.rb +5 -5
- data/lib/skyward/generator/commands.rb +3 -3
- data/lib/skyward/generator.rb +4 -4
- data/lib/skyward/version.rb +1 -1
- data/lib/skyward.rb +3 -3
- metadata +8 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 68baf30f9dcf93f5253283546d47634e1d4b67f6362e3056f668372a5e8ac2f8
|
|
4
|
+
data.tar.gz: e498ff96af0bfd79b82506599248791ce532d6655bebc7a61d664d78c822ce92
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 18093a6e010528c66a38f90702012b51e0903c86d5f4c3ebd3dca816bb917d56828d5d41b3fef12137edb16a9718d43096f4d6c77d692772842b0228b3def0c2
|
|
7
|
+
data.tar.gz: 0f544fbb83c92010a204b1c30132089dcebe3bf0c45d5f8b6001b4e3316f25fc4065e62c89f65b9f4510b7771c231cf0c7d7bccf79c79968d2ce9a441faf7d4f
|
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jake Bottrall
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/README.md
CHANGED
|
@@ -14,11 +14,11 @@ Each works without the other. Add this gem when you want both.
|
|
|
14
14
|
|
|
15
15
|
```ruby
|
|
16
16
|
# Gemfile
|
|
17
|
-
gem
|
|
17
|
+
gem 'skyward'
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
```ruby
|
|
21
|
-
require
|
|
21
|
+
require 'skyward' # requires skyward/api and skyward/orm
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
Skyward supports every Ruby that isn't end-of-life (3.3 and later, as of November 2026).
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
source
|
|
3
|
+
source 'https://rubygems.org'
|
|
4
4
|
|
|
5
|
-
gem
|
|
6
|
-
gem
|
|
5
|
+
gem 'skyward', '= {{version}}'
|
|
6
|
+
gem 'sqlite3', '~> 2.10'
|
|
7
7
|
|
|
8
8
|
# Falcon serves the app in development (skyward serve) and in production. The
|
|
9
9
|
# app's code never requires it, which keeps its signatures out of the RBS
|
|
10
10
|
# collection.
|
|
11
|
-
gem
|
|
11
|
+
gem 'falcon', '~> 0.57', require: false
|
|
12
12
|
|
|
13
13
|
group :development, :test do
|
|
14
14
|
# skyward check runs both.
|
|
15
|
-
gem
|
|
16
|
-
gem
|
|
15
|
+
gem 'rbs-inline', '~> 0.14', require: false
|
|
16
|
+
gem 'steep', '~> 2.1', require: false
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
group :test do
|
|
20
|
-
gem
|
|
21
|
-
gem
|
|
20
|
+
gem 'minitest', '~> 6.0'
|
|
21
|
+
gem 'rake', '~> 13.4'
|
|
22
22
|
end
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
D = Steep::Diagnostic
|
|
4
4
|
|
|
5
5
|
target :app do
|
|
6
|
-
signature
|
|
6
|
+
signature 'sig'
|
|
7
7
|
|
|
8
|
-
check
|
|
8
|
+
check '*.rb', 'lib', 'modules'
|
|
9
9
|
|
|
10
10
|
# The Skyward gems' signatures come with the gems, and the rest from the RBS
|
|
11
11
|
# collection, which bin/setup installs.
|
|
12
|
-
collection_config
|
|
12
|
+
collection_config 'rbs_collection.yaml'
|
|
13
13
|
|
|
14
14
|
configure_code_diagnostics(D::Ruby.all_error)
|
|
15
15
|
end
|
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
# rbs_inline: enabled
|
|
4
4
|
|
|
5
|
-
require
|
|
6
|
-
require
|
|
5
|
+
require 'skyward'
|
|
6
|
+
require 'zeitwerk'
|
|
7
7
|
|
|
8
8
|
loader = Zeitwerk::Loader.new
|
|
9
9
|
loader.push_dir("#{__dir__}/lib")
|
|
10
10
|
loader.push_dir("#{__dir__}/modules")
|
|
11
|
-
loader.inflector.inflect(
|
|
11
|
+
loader.inflector.inflect('api' => 'API', 'health_api' => 'HealthAPI')
|
|
12
12
|
# skyward serve unloads the app's code to reload it, which Zeitwerk allows only
|
|
13
13
|
# for a loader set up with reloading on.
|
|
14
|
-
loader.enable_reloading if ENV[
|
|
14
|
+
loader.enable_reloading if ENV['RACK_ENV'] == 'development'
|
|
15
15
|
loader.setup
|
|
16
16
|
loader.eager_load
|
|
17
17
|
|
|
18
|
-
Skyward.connect(ENV.fetch(
|
|
18
|
+
Skyward.connect(ENV.fetch('DATABASE_URL', "sqlite://#{__dir__}/db/{{name}}.sqlite3"))
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
# rbs_inline: enabled
|
|
4
4
|
|
|
5
5
|
class HealthAPI < Skyward::API
|
|
6
|
-
description
|
|
6
|
+
description 'Whether the app is up, for load balancers and uptime checks.'
|
|
7
7
|
|
|
8
|
-
get
|
|
8
|
+
get '/up', to: :show, summary: 'Report that the app is up.'
|
|
9
9
|
|
|
10
10
|
# @rbs return: { status: "ok" }
|
|
11
|
-
def show = { status:
|
|
11
|
+
def show = { status: 'ok' }
|
|
12
12
|
end
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
3
|
+
require 'test_helper'
|
|
4
4
|
|
|
5
|
-
describe
|
|
5
|
+
describe 'App' do
|
|
6
6
|
let(:client) { Skyward::API::Test.client(App) }
|
|
7
7
|
|
|
8
|
-
describe
|
|
9
|
-
it
|
|
10
|
-
assert_equal({ status:
|
|
8
|
+
describe 'GET /up' do
|
|
9
|
+
it 'says the app is up' do
|
|
10
|
+
assert_equal({ status: 'ok' }, client.get('/up').json)
|
|
11
11
|
end
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
-
describe
|
|
15
|
-
it
|
|
16
|
-
paths = client.get(
|
|
14
|
+
describe 'GET /openapi.json' do
|
|
15
|
+
it 'documents every endpoint' do
|
|
16
|
+
paths = client.get('/openapi.json').json[:paths].keys
|
|
17
17
|
|
|
18
18
|
assert_equal %i[/up], paths
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
-
describe
|
|
23
|
-
it
|
|
24
|
-
assert_includes client.get(
|
|
22
|
+
describe 'GET /docs' do
|
|
23
|
+
it 'serves the API reference' do
|
|
24
|
+
assert_includes client.get('/docs').body, '<title>{{title}}</title>'
|
|
25
25
|
end
|
|
26
26
|
end
|
|
27
27
|
end
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
3
|
+
require 'test_helper'
|
|
4
4
|
|
|
5
5
|
describe HealthAPI do
|
|
6
|
-
describe
|
|
7
|
-
it
|
|
8
|
-
assert_equal({ status:
|
|
6
|
+
describe '#show' do
|
|
7
|
+
it 'says the app is up' do
|
|
8
|
+
assert_equal({ status: 'ok' }, HealthAPI.new.show)
|
|
9
9
|
end
|
|
10
10
|
end
|
|
11
11
|
end
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
4
|
-
require
|
|
5
|
-
require
|
|
3
|
+
require 'minitest/autorun'
|
|
4
|
+
require 'skyward'
|
|
5
|
+
require 'stringio'
|
|
6
6
|
|
|
7
7
|
# A database of the suite's own, migrated from empty each run, unless
|
|
8
8
|
# TEST_DATABASE_URL names another, so the tests never run against the
|
|
9
9
|
# DATABASE_URL the app uses.
|
|
10
|
-
ENV[
|
|
10
|
+
ENV['DATABASE_URL'] = ENV.fetch('TEST_DATABASE_URL', 'sqlite://:memory:')
|
|
11
11
|
|
|
12
12
|
# App logs every request to the $stdout it boots with, which would bury the
|
|
13
13
|
# test report, so it boots with one of its own. Its boot.rb connects with the
|
|
@@ -15,9 +15,9 @@ ENV["DATABASE_URL"] = ENV.fetch("TEST_DATABASE_URL", "sqlite://:memory:")
|
|
|
15
15
|
# Skyward.migrate.
|
|
16
16
|
stdout = $stdout
|
|
17
17
|
$stdout = StringIO.new
|
|
18
|
-
Skyward::ORM::Connection::SESSION.without_check { require_relative
|
|
18
|
+
Skyward::ORM::Connection::SESSION.without_check { require_relative '../app' }
|
|
19
19
|
$stdout = stdout
|
|
20
|
-
Skyward.migrate(File.expand_path(
|
|
20
|
+
Skyward.migrate(File.expand_path('../db/migrate', __dir__))
|
|
21
21
|
|
|
22
22
|
# Every test, App's HTTP tests too, runs in a transaction that's rolled back
|
|
23
23
|
# after it. The test client calls App on the test's fiber, so its requests run
|
|
@@ -7,7 +7,7 @@ module Skyward::Generator::CLI::New::Template
|
|
|
7
7
|
|
|
8
8
|
# Every file there ends in it, so none of the tools that read the gem's own
|
|
9
9
|
# Ruby, signatures and Steepfile takes the app's for the gem's.
|
|
10
|
-
SUFFIX =
|
|
10
|
+
SUFFIX = '.tt' #: String
|
|
11
11
|
|
|
12
12
|
PLACEHOLDER = /\{\{\w+\}\}/ #: Regexp
|
|
13
13
|
|
|
@@ -20,7 +20,7 @@ module Skyward::Generator::CLI::New::Template
|
|
|
20
20
|
# @rbs name: String
|
|
21
21
|
# @rbs return: Hash[String, String]
|
|
22
22
|
def files(name)
|
|
23
|
-
values = {
|
|
23
|
+
values = { '{{name}}' => name, '{{title}}' => title(name), '{{version}}' => Skyward::VERSION }
|
|
24
24
|
FILES.transform_values { |content| content.gsub(PLACEHOLDER) { |key| values.fetch(key) } }
|
|
25
25
|
end
|
|
26
26
|
|
|
@@ -28,5 +28,5 @@ module Skyward::Generator::CLI::New::Template
|
|
|
28
28
|
|
|
29
29
|
# @rbs name: String
|
|
30
30
|
# @rbs return: String
|
|
31
|
-
def title(name) = name.split(
|
|
31
|
+
def title(name) = name.split('_').map(&:capitalize).join
|
|
32
32
|
end
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
3
|
+
require 'fileutils'
|
|
4
4
|
|
|
5
5
|
module Skyward::Generator::CLI::New
|
|
6
6
|
extend self
|
|
7
7
|
|
|
8
|
-
SKIP_BUNDLE =
|
|
8
|
+
SKIP_BUNDLE = '--skip-bundle' #: String
|
|
9
9
|
|
|
10
10
|
# Lowercase, so it names one directory on every filesystem, and a constant
|
|
11
11
|
# once camelized.
|
|
@@ -24,11 +24,11 @@ module Skyward::Generator::CLI::New
|
|
|
24
24
|
file = File.join(app, path)
|
|
25
25
|
FileUtils.mkdir_p(File.dirname(file))
|
|
26
26
|
File.write(file, content)
|
|
27
|
-
File.chmod(0o755, file) if path.start_with?(
|
|
27
|
+
File.chmod(0o755, file) if path.start_with?('bin/')
|
|
28
28
|
out.write("Wrote #{File.join(name, path)}\n")
|
|
29
29
|
end
|
|
30
30
|
# system merges env into this process's environment unless told to replace it.
|
|
31
|
-
unless args.include?(SKIP_BUNDLE) || kernel.system(env,
|
|
31
|
+
unless args.include?(SKIP_BUNDLE) || kernel.system(env, 'bundle', 'install', chdir: app, unsetenv_others: true)
|
|
32
32
|
return kernel.abort("skyward: bundle install failed in #{name}. Fix what it printed, then run bin/setup there.")
|
|
33
33
|
end
|
|
34
34
|
|
|
@@ -47,7 +47,7 @@ module Skyward::Generator::CLI::New
|
|
|
47
47
|
end
|
|
48
48
|
unless name.match?(NAME)
|
|
49
49
|
return "skyward: #{name} can't name an app. Use lowercase letters, digits and underscores, " \
|
|
50
|
-
|
|
50
|
+
'starting with a letter, as in my_app.'
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
app = File.join(directory, name)
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
3
|
+
require 'skyward/generator'
|
|
4
4
|
|
|
5
5
|
Skyward::Core::CLI.register(
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
'new',
|
|
7
|
+
'Write a new app in NAME/ and install its gems, unless given --skip-bundle'
|
|
8
8
|
) do |args|
|
|
9
9
|
# Under bundle exec, the app's bundle install would otherwise read the
|
|
10
10
|
# Gemfile skyward runs under, not the app's.
|
data/lib/skyward/generator.rb
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
4
|
-
require
|
|
5
|
-
require_relative
|
|
3
|
+
require 'skyward/core'
|
|
4
|
+
require 'zeitwerk'
|
|
5
|
+
require_relative 'version'
|
|
6
6
|
|
|
7
7
|
loader = Zeitwerk::Loader.for_gem_extension(Skyward)
|
|
8
|
-
loader.inflector.inflect(
|
|
8
|
+
loader.inflector.inflect('cli' => 'CLI')
|
|
9
9
|
# The skyward executable loads it, and it defines no constant.
|
|
10
10
|
loader.ignore("#{__dir__}/generator/commands.rb")
|
|
11
11
|
# It defines Skyward::VERSION, not the Skyward::Version its name means to the loader.
|
data/lib/skyward/version.rb
CHANGED
data/lib/skyward.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: skyward
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.4.
|
|
4
|
+
version: 0.4.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jake Bottrall
|
|
@@ -15,42 +15,42 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - '='
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: 0.4.
|
|
18
|
+
version: 0.4.1
|
|
19
19
|
type: :runtime
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
23
|
- - '='
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: 0.4.
|
|
25
|
+
version: 0.4.1
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
27
|
name: skyward-core
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
29
29
|
requirements:
|
|
30
30
|
- - '='
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: 0.4.
|
|
32
|
+
version: 0.4.1
|
|
33
33
|
type: :runtime
|
|
34
34
|
prerelease: false
|
|
35
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
36
36
|
requirements:
|
|
37
37
|
- - '='
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
|
-
version: 0.4.
|
|
39
|
+
version: 0.4.1
|
|
40
40
|
- !ruby/object:Gem::Dependency
|
|
41
41
|
name: skyward-orm
|
|
42
42
|
requirement: !ruby/object:Gem::Requirement
|
|
43
43
|
requirements:
|
|
44
44
|
- - '='
|
|
45
45
|
- !ruby/object:Gem::Version
|
|
46
|
-
version: 0.4.
|
|
46
|
+
version: 0.4.1
|
|
47
47
|
type: :runtime
|
|
48
48
|
prerelease: false
|
|
49
49
|
version_requirements: !ruby/object:Gem::Requirement
|
|
50
50
|
requirements:
|
|
51
51
|
- - '='
|
|
52
52
|
- !ruby/object:Gem::Version
|
|
53
|
-
version: 0.4.
|
|
53
|
+
version: 0.4.1
|
|
54
54
|
- !ruby/object:Gem::Dependency
|
|
55
55
|
name: zeitwerk
|
|
56
56
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -71,6 +71,7 @@ executables: []
|
|
|
71
71
|
extensions: []
|
|
72
72
|
extra_rdoc_files: []
|
|
73
73
|
files:
|
|
74
|
+
- LICENSE
|
|
74
75
|
- README.md
|
|
75
76
|
- lib/skyward.rb
|
|
76
77
|
- lib/skyward/generator.rb
|