ts_schema 0.1.1 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +0 -1
  3. data/lib/generators/generate_generator.rb +17 -0
  4. data/lib/generators/install_generator.rb +1 -4
  5. data/lib/generators/templates/ts_schema.rb +27 -0
  6. data/lib/tasks/ts_schema_tasks.rake +11 -5
  7. data/lib/ts_schema/configuration.rb +1 -0
  8. data/lib/ts_schema/conversion_table.yml +1 -1
  9. data/lib/ts_schema/schema_generator.rb +15 -14
  10. data/lib/ts_schema/version.rb +1 -1
  11. data/lib/ts_schema.rb +8 -1
  12. metadata +2 -63
  13. data/.gitignore +0 -9
  14. data/Gemfile +0 -10
  15. data/Gemfile.lock +0 -160
  16. data/bin/test +0 -5
  17. data/test/dummy/Rakefile +0 -6
  18. data/test/dummy/app/assets/images/.keep +0 -0
  19. data/test/dummy/app/assets/javascripts/schema.d.ts +0 -71
  20. data/test/dummy/app/assets/stylesheets/application.css +0 -1
  21. data/test/dummy/app/controllers/application_controller.rb +0 -2
  22. data/test/dummy/app/controllers/concerns/.keep +0 -0
  23. data/test/dummy/app/frontend/types/schema.d.ts +0 -71
  24. data/test/dummy/app/helpers/application_helper.rb +0 -2
  25. data/test/dummy/app/jobs/application_job.rb +0 -7
  26. data/test/dummy/app/models/application_record.rb +0 -3
  27. data/test/dummy/app/models/concerns/.keep +0 -0
  28. data/test/dummy/app/models/example.rb +0 -15
  29. data/test/dummy/app/models/five.rb +0 -3
  30. data/test/dummy/app/models/four.rb +0 -4
  31. data/test/dummy/app/models/one.rb +0 -4
  32. data/test/dummy/app/models/three.rb +0 -4
  33. data/test/dummy/app/models/two.rb +0 -3
  34. data/test/dummy/app/views/layouts/application.html.erb +0 -15
  35. data/test/dummy/bin/rails +0 -4
  36. data/test/dummy/bin/rake +0 -4
  37. data/test/dummy/bin/setup +0 -33
  38. data/test/dummy/config/application.rb +0 -41
  39. data/test/dummy/config/boot.rb +0 -5
  40. data/test/dummy/config/database.yml +0 -86
  41. data/test/dummy/config/environment.rb +0 -5
  42. data/test/dummy/config/environments/development.rb +0 -63
  43. data/test/dummy/config/environments/production.rb +0 -76
  44. data/test/dummy/config/environments/test.rb +0 -53
  45. data/test/dummy/config/initializers/config/initializers/ts_schema.rb +0 -30
  46. data/test/dummy/config/initializers/content_security_policy.rb +0 -26
  47. data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -8
  48. data/test/dummy/config/initializers/inflections.rb +0 -16
  49. data/test/dummy/config/initializers/permissions_policy.rb +0 -11
  50. data/test/dummy/config/locales/en.yml +0 -33
  51. data/test/dummy/config/puma.rb +0 -43
  52. data/test/dummy/config/routes.rb +0 -6
  53. data/test/dummy/config/storage.yml +0 -34
  54. data/test/dummy/config.ru +0 -6
  55. data/test/dummy/db/migrate/20220401195333_create_examples.rb +0 -23
  56. data/test/dummy/db/migrate/20220402131712_create_ones.rb +0 -9
  57. data/test/dummy/db/migrate/20220402131955_create_twos.rb +0 -9
  58. data/test/dummy/db/migrate/20220402132415_create_threes.rb +0 -7
  59. data/test/dummy/db/migrate/20220402132543_create_fours.rb +0 -10
  60. data/test/dummy/db/migrate/20220402132906_create_fives.rb +0 -12
  61. data/test/dummy/db/schema.rb +0 -81
  62. data/test/dummy/lib/assets/.keep +0 -0
  63. data/test/dummy/log/.keep +0 -0
  64. data/test/dummy/public/404.html +0 -67
  65. data/test/dummy/public/422.html +0 -67
  66. data/test/dummy/public/500.html +0 -66
  67. data/test/dummy/public/apple-touch-icon-precomposed.png +0 -0
  68. data/test/dummy/public/apple-touch-icon.png +0 -0
  69. data/test/dummy/public/favicon.ico +0 -0
  70. data/test/install_generator_test.rb +0 -13
  71. data/test/test_helper.rb +0 -18
  72. data/test/tmp/config/initializers/ts_schema.rb +0 -30
  73. data/test/ts_schema_test.rb +0 -26
  74. data/ts_schema.gemspec +0 -20
@@ -1,23 +0,0 @@
1
- class CreateExamples < ActiveRecord::Migration[7.0]
2
- def change
3
- create_table :examples do |t|
4
- t.string :col_string, null: false
5
- t.text :col_text, null: false
6
- t.integer :col_integer, null: false
7
- t.integer :col_enum, null: false
8
- t.bigint :col_bigint, null: false
9
- t.float :col_float, null: false
10
- t.decimal :col_decimal, null: false
11
- t.json :col_json
12
- t.jsonb :col_jsonb
13
- t.binary :col_binary
14
- t.boolean :col_boolean
15
- t.date :col_date
16
- t.datetime :col_datetime
17
- t.timestamp :col_timestamp
18
- t.inet :col_inet
19
- t.cidr :col_cidr
20
- t.macaddr :col_macaddr
21
- end
22
- end
23
- end
@@ -1,9 +0,0 @@
1
- class CreateOnes < ActiveRecord::Migration[7.0]
2
- def change
3
- create_table :ones do |t|
4
- t.references :example, null: false, foreign_key: true
5
-
6
- t.timestamps
7
- end
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- class CreateTwos < ActiveRecord::Migration[7.0]
2
- def change
3
- create_table :twos do |t|
4
- t.references :example, null: false, foreign_key: true
5
-
6
- t.timestamps
7
- end
8
- end
9
- end
@@ -1,7 +0,0 @@
1
- class CreateThrees < ActiveRecord::Migration[7.0]
2
- def change
3
- create_table :threes do |t|
4
- t.timestamps
5
- end
6
- end
7
- end
@@ -1,10 +0,0 @@
1
- class CreateFours < ActiveRecord::Migration[7.0]
2
- def change
3
- create_table :fours do |t|
4
- t.references :example, null: false, foreign_key: true
5
- t.references :three, null: false, foreign_key: true
6
-
7
- t.timestamps
8
- end
9
- end
10
- end
@@ -1,12 +0,0 @@
1
- class CreateFives < ActiveRecord::Migration[7.0]
2
- def change
3
- create_table :fives do |t|
4
- t.timestamps
5
- end
6
-
7
- create_table :examples_fives, id: false do |t|
8
- t.belongs_to :example
9
- t.belongs_to :part
10
- end
11
- end
12
- end
@@ -1,81 +0,0 @@
1
- # This file is auto-generated from the current state of the database. Instead
2
- # of editing this file, please use the migrations feature of Active Record to
3
- # incrementally modify your database, and then regenerate this schema definition.
4
- #
5
- # This file is the source Rails uses to define your schema when running `bin/rails
6
- # db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
7
- # be faster and is potentially less error prone than running all of your
8
- # migrations from scratch. Old migrations may fail to apply correctly if those
9
- # migrations use external dependencies or application code.
10
- #
11
- # It's strongly recommended that you check this file into your version control system.
12
-
13
- ActiveRecord::Schema[7.0].define(version: 2022_04_02_132906) do
14
- # These are extensions that must be enabled in order to support this database
15
- enable_extension "plpgsql"
16
-
17
- create_table "examples", force: :cascade do |t|
18
- t.string "col_string", null: false
19
- t.text "col_text", null: false
20
- t.integer "col_integer", null: false
21
- t.integer "col_enum", null: false
22
- t.bigint "col_bigint", null: false
23
- t.float "col_float", null: false
24
- t.decimal "col_decimal", null: false
25
- t.json "col_json"
26
- t.jsonb "col_jsonb"
27
- t.binary "col_binary"
28
- t.boolean "col_boolean"
29
- t.date "col_date"
30
- t.datetime "col_datetime"
31
- t.datetime "col_timestamp", precision: nil
32
- t.inet "col_inet"
33
- t.cidr "col_cidr"
34
- t.macaddr "col_macaddr"
35
- end
36
-
37
- create_table "examples_fives", id: false, force: :cascade do |t|
38
- t.bigint "example_id"
39
- t.bigint "part_id"
40
- t.index ["example_id"], name: "index_examples_fives_on_example_id"
41
- t.index ["part_id"], name: "index_examples_fives_on_part_id"
42
- end
43
-
44
- create_table "fives", force: :cascade do |t|
45
- t.datetime "created_at", null: false
46
- t.datetime "updated_at", null: false
47
- end
48
-
49
- create_table "fours", force: :cascade do |t|
50
- t.bigint "example_id", null: false
51
- t.bigint "three_id", null: false
52
- t.datetime "created_at", null: false
53
- t.datetime "updated_at", null: false
54
- t.index ["example_id"], name: "index_fours_on_example_id"
55
- t.index ["three_id"], name: "index_fours_on_three_id"
56
- end
57
-
58
- create_table "ones", force: :cascade do |t|
59
- t.bigint "example_id", null: false
60
- t.datetime "created_at", null: false
61
- t.datetime "updated_at", null: false
62
- t.index ["example_id"], name: "index_ones_on_example_id"
63
- end
64
-
65
- create_table "threes", force: :cascade do |t|
66
- t.datetime "created_at", null: false
67
- t.datetime "updated_at", null: false
68
- end
69
-
70
- create_table "twos", force: :cascade do |t|
71
- t.bigint "example_id", null: false
72
- t.datetime "created_at", null: false
73
- t.datetime "updated_at", null: false
74
- t.index ["example_id"], name: "index_twos_on_example_id"
75
- end
76
-
77
- add_foreign_key "fours", "examples"
78
- add_foreign_key "fours", "threes"
79
- add_foreign_key "ones", "examples"
80
- add_foreign_key "twos", "examples"
81
- end
File without changes
data/test/dummy/log/.keep DELETED
File without changes
@@ -1,67 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>The page you were looking for doesn't exist (404)</title>
5
- <meta name="viewport" content="width=device-width,initial-scale=1">
6
- <style>
7
- .rails-default-error-page {
8
- background-color: #EFEFEF;
9
- color: #2E2F30;
10
- text-align: center;
11
- font-family: arial, sans-serif;
12
- margin: 0;
13
- }
14
-
15
- .rails-default-error-page div.dialog {
16
- width: 95%;
17
- max-width: 33em;
18
- margin: 4em auto 0;
19
- }
20
-
21
- .rails-default-error-page div.dialog > div {
22
- border: 1px solid #CCC;
23
- border-right-color: #999;
24
- border-left-color: #999;
25
- border-bottom-color: #BBB;
26
- border-top: #B00100 solid 4px;
27
- border-top-left-radius: 9px;
28
- border-top-right-radius: 9px;
29
- background-color: white;
30
- padding: 7px 12% 0;
31
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
- }
33
-
34
- .rails-default-error-page h1 {
35
- font-size: 100%;
36
- color: #730E15;
37
- line-height: 1.5em;
38
- }
39
-
40
- .rails-default-error-page div.dialog > p {
41
- margin: 0 0 1em;
42
- padding: 1em;
43
- background-color: #F7F7F7;
44
- border: 1px solid #CCC;
45
- border-right-color: #999;
46
- border-left-color: #999;
47
- border-bottom-color: #999;
48
- border-bottom-left-radius: 4px;
49
- border-bottom-right-radius: 4px;
50
- border-top-color: #DADADA;
51
- color: #666;
52
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
- }
54
- </style>
55
- </head>
56
-
57
- <body class="rails-default-error-page">
58
- <!-- This file lives in public/404.html -->
59
- <div class="dialog">
60
- <div>
61
- <h1>The page you were looking for doesn't exist.</h1>
62
- <p>You may have mistyped the address or the page may have moved.</p>
63
- </div>
64
- <p>If you are the application owner check the logs for more information.</p>
65
- </div>
66
- </body>
67
- </html>
@@ -1,67 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>The change you wanted was rejected (422)</title>
5
- <meta name="viewport" content="width=device-width,initial-scale=1">
6
- <style>
7
- .rails-default-error-page {
8
- background-color: #EFEFEF;
9
- color: #2E2F30;
10
- text-align: center;
11
- font-family: arial, sans-serif;
12
- margin: 0;
13
- }
14
-
15
- .rails-default-error-page div.dialog {
16
- width: 95%;
17
- max-width: 33em;
18
- margin: 4em auto 0;
19
- }
20
-
21
- .rails-default-error-page div.dialog > div {
22
- border: 1px solid #CCC;
23
- border-right-color: #999;
24
- border-left-color: #999;
25
- border-bottom-color: #BBB;
26
- border-top: #B00100 solid 4px;
27
- border-top-left-radius: 9px;
28
- border-top-right-radius: 9px;
29
- background-color: white;
30
- padding: 7px 12% 0;
31
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
- }
33
-
34
- .rails-default-error-page h1 {
35
- font-size: 100%;
36
- color: #730E15;
37
- line-height: 1.5em;
38
- }
39
-
40
- .rails-default-error-page div.dialog > p {
41
- margin: 0 0 1em;
42
- padding: 1em;
43
- background-color: #F7F7F7;
44
- border: 1px solid #CCC;
45
- border-right-color: #999;
46
- border-left-color: #999;
47
- border-bottom-color: #999;
48
- border-bottom-left-radius: 4px;
49
- border-bottom-right-radius: 4px;
50
- border-top-color: #DADADA;
51
- color: #666;
52
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
- }
54
- </style>
55
- </head>
56
-
57
- <body class="rails-default-error-page">
58
- <!-- This file lives in public/422.html -->
59
- <div class="dialog">
60
- <div>
61
- <h1>The change you wanted was rejected.</h1>
62
- <p>Maybe you tried to change something you didn't have access to.</p>
63
- </div>
64
- <p>If you are the application owner check the logs for more information.</p>
65
- </div>
66
- </body>
67
- </html>
@@ -1,66 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>We're sorry, but something went wrong (500)</title>
5
- <meta name="viewport" content="width=device-width,initial-scale=1">
6
- <style>
7
- .rails-default-error-page {
8
- background-color: #EFEFEF;
9
- color: #2E2F30;
10
- text-align: center;
11
- font-family: arial, sans-serif;
12
- margin: 0;
13
- }
14
-
15
- .rails-default-error-page div.dialog {
16
- width: 95%;
17
- max-width: 33em;
18
- margin: 4em auto 0;
19
- }
20
-
21
- .rails-default-error-page div.dialog > div {
22
- border: 1px solid #CCC;
23
- border-right-color: #999;
24
- border-left-color: #999;
25
- border-bottom-color: #BBB;
26
- border-top: #B00100 solid 4px;
27
- border-top-left-radius: 9px;
28
- border-top-right-radius: 9px;
29
- background-color: white;
30
- padding: 7px 12% 0;
31
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
- }
33
-
34
- .rails-default-error-page h1 {
35
- font-size: 100%;
36
- color: #730E15;
37
- line-height: 1.5em;
38
- }
39
-
40
- .rails-default-error-page div.dialog > p {
41
- margin: 0 0 1em;
42
- padding: 1em;
43
- background-color: #F7F7F7;
44
- border: 1px solid #CCC;
45
- border-right-color: #999;
46
- border-left-color: #999;
47
- border-bottom-color: #999;
48
- border-bottom-left-radius: 4px;
49
- border-bottom-right-radius: 4px;
50
- border-top-color: #DADADA;
51
- color: #666;
52
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
- }
54
- </style>
55
- </head>
56
-
57
- <body class="rails-default-error-page">
58
- <!-- This file lives in public/500.html -->
59
- <div class="dialog">
60
- <div>
61
- <h1>We're sorry, but something went wrong.</h1>
62
- </div>
63
- <p>If you are the application owner check the logs for more information.</p>
64
- </div>
65
- </body>
66
- </html>
File without changes
File without changes
File without changes
@@ -1,13 +0,0 @@
1
- require "test_helper"
2
-
3
- class InstallGeneratorTest < Rails::Generators::TestCase
4
- tests TsSchema::Generators::InstallGenerator
5
- destination File.expand_path("../tmp", __FILE__)
6
- setup :prepare_destination
7
-
8
- test "it creats a file" do
9
- run_generator
10
-
11
- assert_file "config/initializers/ts_schema.rb"
12
- end
13
- end
data/test/test_helper.rb DELETED
@@ -1,18 +0,0 @@
1
- # Configure Rails Environment
2
- ENV["RAILS_ENV"] = "test"
3
-
4
- require_relative "../test/dummy/config/environment"
5
- ActiveRecord::Migrator.migrations_paths = [File.expand_path("../test/dummy/db/migrate", __dir__)]
6
- require "rails/test_help"
7
-
8
- # Load fixtures from the engine
9
- if ActiveSupport::TestCase.respond_to?(:fixture_path=)
10
- ActiveSupport::TestCase.fixture_path = File.expand_path("fixtures", __dir__)
11
- ActionDispatch::IntegrationTest.fixture_path = ActiveSupport::TestCase.fixture_path
12
- ActiveSupport::TestCase.file_fixture_path = ActiveSupport::TestCase.fixture_path + "/files"
13
- ActiveSupport::TestCase.fixtures :all
14
- end
15
-
16
- # For generators
17
- require "rails/generators/test_case"
18
- require "generators/install_generator"
@@ -1,30 +0,0 @@
1
- TsSchema.setup do |config|
2
- # Options: camel|snake|pascal
3
- # config.case = :camel
4
-
5
- # Customize output path and file name
6
- # config.output = Rails.root.join('app', 'assets', 'javascripts', 'schema.d.ts')
7
-
8
- # Whether to generate the schema file on migrations and rollbacks
9
- # config.auto_generate = true
10
-
11
- # Add custom type mappings or overrides
12
- # config.custom_types = {
13
- #
14
- # }
15
-
16
- # Default type for unrecognized types
17
- # config.default_type = :string
18
-
19
- # Whether to generate types for associations
20
- # config.include_associated = true
21
-
22
- # Namespace
23
- # config.namespace = :schema
24
-
25
- # Options: tab|space
26
- # config.indent = :tab
27
-
28
- # If indent is spaces, specify how many
29
- # config.spaces = 2
30
- end
@@ -1,26 +0,0 @@
1
- require "test_helper"
2
-
3
- class TsSchemaTest < ActiveSupport::TestCase
4
- test "it loads custom config values from initializer" do
5
- assert TsSchema.configuration.case
6
- assert TsSchema.configuration.output
7
- assert TsSchema.configuration.auto_generate
8
- assert TsSchema.configuration.types
9
- assert TsSchema.configuration.custom_types
10
- assert TsSchema.configuration.default_type
11
- assert TsSchema.configuration.include_associated
12
- assert TsSchema.configuration.namespace
13
- end
14
-
15
- test "it generates a schema file" do
16
- path = TsSchema.configuration.output
17
- File.delete(path) if File.exist?(path)
18
-
19
- TsSchema.generate
20
- assert File.exist?(path)
21
- end
22
-
23
- test "it has a version number" do
24
- assert TsSchema::VERSION
25
- end
26
- end
data/ts_schema.gemspec DELETED
@@ -1,20 +0,0 @@
1
- require_relative "lib/ts_schema/version"
2
-
3
- Gem::Specification.new do |spec|
4
- spec.name = "ts_schema"
5
- spec.version = TsSchema::VERSION
6
- spec.authors = ["Avram Walden"]
7
- spec.email = ["aviemet@gmail.com"]
8
- spec.homepage = "https://github.com/aviemet"
9
- spec.summary = "Generates typescript definitions from ActiveRecord"
10
- spec.description = ""
11
- spec.license = "MIT"
12
-
13
- spec.metadata["homepage_uri"] = spec.homepage
14
- spec.metadata["source_code_uri"] = "https://github.com/aviemet/ts_schema"
15
-
16
- spec.files = `git ls-files`.split("\n")
17
- spec.require_paths = ["lib"]
18
-
19
- spec.add_dependency 'rails', '~> 7.0', '>= 7.0.2.3'
20
- end