potassium 6.3.0 → 6.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +1 -1
- data/.node-version +1 -1
- data/CHANGELOG.md +45 -0
- data/README.md +30 -3
- data/docs/CONTRIBUTING.md +2 -2
- data/lib/potassium/assets/.circleci/config.yml.erb +40 -12
- data/lib/potassium/assets/.eslintrc.json +15 -9
- data/lib/potassium/assets/.pryrc +0 -6
- data/lib/potassium/assets/.rubocop.yml +1 -0
- data/lib/potassium/assets/Aptfile +5 -0
- data/lib/potassium/assets/README.yml +74 -7
- data/lib/potassium/assets/active_admin/admin-component.vue +22 -30
- data/lib/potassium/assets/active_admin/policies/admin_user_policy.rb +2 -0
- data/lib/potassium/assets/active_admin/policies/comment_policy.rb +2 -0
- data/lib/potassium/assets/active_admin/policies/default_policy.rb +49 -0
- data/lib/potassium/assets/active_admin/policies/page_policy.rb +2 -0
- data/lib/potassium/assets/app/javascript/{app.spec.js → components/app.spec.ts} +2 -2
- data/lib/potassium/assets/app/javascript/components/app.vue +9 -0
- data/lib/potassium/assets/app/javascript/types/vue.d.ts +5 -0
- data/lib/potassium/assets/app/jobs/shrine_promote_job.rb +14 -0
- data/lib/potassium/assets/app/mailers/application_mailer.rb +1 -1
- data/lib/potassium/assets/app/mailers/example_mailer.rb +6 -0
- data/lib/potassium/assets/app/serializers/base_serializer.rb +3 -0
- data/lib/potassium/assets/app/serializers/concerns/image_handling_attributes.rb +20 -0
- data/lib/potassium/assets/app/uploaders/cover_image_uploader.rb +52 -0
- data/lib/potassium/assets/app/views/example_mailer/example_mail.html.mjml +7 -0
- data/lib/potassium/assets/app/views/layouts/default_mail.html.mjml +49 -0
- data/lib/potassium/assets/config/initializers/shrine/plugins/image_handling_utilities.rb +143 -0
- data/lib/potassium/assets/config/mailer.rb.erb +0 -2
- data/lib/potassium/assets/config/shrine.rb +15 -0
- data/lib/potassium/assets/config/webpack/rules/css.js +5 -0
- data/lib/potassium/assets/config/webpack/rules/index.js +11 -0
- data/lib/potassium/assets/config/webpack/rules/jquery.js +11 -0
- data/lib/potassium/assets/config/webpack/rules/typescript.js +32 -0
- data/lib/potassium/assets/config/webpack/rules/vue.js +19 -0
- data/lib/potassium/assets/config/webpack/webpack.config.js +4 -0
- data/lib/potassium/assets/public/mails/platanus-logo.png +0 -0
- data/lib/potassium/assets/testing/.rspec +1 -0
- data/lib/potassium/assets/testing/devise_config.rb +6 -0
- data/lib/potassium/assets/testing/factory_bot_config.rb +3 -0
- data/lib/potassium/assets/testing/faker_config.rb +1 -0
- data/lib/potassium/assets/testing/power_types_config.rb +1 -0
- data/lib/potassium/assets/testing/rails_helper.rb +130 -49
- data/lib/potassium/assets/testing/shoulda_matchers_config.rb +8 -0
- data/lib/potassium/assets/testing/simplecov_config.rb +64 -0
- data/lib/potassium/assets/testing/system_tests_config.rb +6 -0
- data/lib/potassium/assets/tsconfig.json +31 -0
- data/lib/potassium/cli/commands/create.rb +3 -1
- data/lib/potassium/cli_options.rb +23 -3
- data/lib/potassium/platanus_config.rb +20 -0
- data/lib/potassium/recipes/admin.rb +37 -16
- data/lib/potassium/recipes/api.rb +8 -85
- data/lib/potassium/recipes/coverage.rb +66 -0
- data/lib/potassium/recipes/file_storage.rb +50 -0
- data/lib/potassium/recipes/front_end.rb +87 -108
- data/lib/potassium/recipes/google_tag_manager.rb +20 -16
- data/lib/potassium/recipes/heroku.rb +1 -2
- data/lib/potassium/recipes/mailer.rb +22 -10
- data/lib/potassium/recipes/mjml.rb +31 -0
- data/lib/potassium/recipes/node.rb +11 -13
- data/lib/potassium/recipes/pundit.rb +29 -10
- data/lib/potassium/recipes/rails.rb +0 -4
- data/lib/potassium/recipes/spring.rb +9 -0
- data/lib/potassium/recipes/style.rb +9 -2
- data/lib/potassium/recipes/testing.rb +75 -18
- data/lib/potassium/recipes/vue_admin.rb +38 -8
- data/lib/potassium/templates/application.rb +5 -2
- data/lib/potassium/version.rb +10 -4
- data/spec/features/api_spec.rb +6 -1
- data/spec/features/ci_spec.rb +1 -1
- data/spec/features/coverage_spec.rb +43 -0
- data/spec/features/file_storage_spec.rb +102 -26
- data/spec/features/front_end_spec.rb +16 -47
- data/spec/features/google_tag_manager_spec.rb +1 -24
- data/spec/features/heroku_spec.rb +0 -4
- data/spec/features/mailer_spec.rb +79 -33
- data/spec/features/mjml_spec.rb +53 -0
- data/spec/features/node_spec.rb +1 -1
- data/spec/features/pundit_spec.rb +34 -0
- data/spec/features/testing_spec.rb +56 -0
- data/spec/features/vue_admin_spec.rb +0 -10
- data/spec/support/potassium_test_helpers.rb +2 -2
- data/spec/support/shared_examples.rb +5 -0
- metadata +50 -27
- data/lib/potassium/assets/active_admin/admin_application.js +0 -14
- data/lib/potassium/assets/active_admin/admin_user_policy.rb +0 -2
- data/lib/potassium/assets/active_admin/comment_policy.rb +0 -2
- data/lib/potassium/assets/active_admin/init_activeadmin_vue.rb +0 -10
- data/lib/potassium/assets/active_admin/pundit_page_policy.rb +0 -5
- data/lib/potassium/assets/app/graphql/graphql_controller.rb +0 -55
- data/lib/potassium/assets/app/graphql/mutations/login_mutation.rb +0 -23
- data/lib/potassium/assets/app/graphql/queries/base_query.rb +0 -4
- data/lib/potassium/assets/app/graphql/types/base/base_argument.rb +0 -4
- data/lib/potassium/assets/app/graphql/types/base/base_enum.rb +0 -4
- data/lib/potassium/assets/app/graphql/types/base/base_field.rb +0 -5
- data/lib/potassium/assets/app/graphql/types/base/base_input_object.rb +0 -5
- data/lib/potassium/assets/app/graphql/types/base/base_interface.rb +0 -7
- data/lib/potassium/assets/app/graphql/types/base/base_object.rb +0 -5
- data/lib/potassium/assets/app/graphql/types/base/base_scalar.rb +0 -4
- data/lib/potassium/assets/app/graphql/types/base/base_union.rb +0 -4
- data/lib/potassium/assets/app/graphql/types/mutation_type.rb +0 -10
- data/lib/potassium/assets/app/graphql/types/query_type.rb +0 -13
- data/lib/potassium/assets/config/graphql_playground.rb +0 -20
- data/spec/features/graphql_spec.rb +0 -71
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0bc57ea8c0f92d1ce3dd15feef9164f7bef381ce322051bd810a3303c8ca257c
|
4
|
+
data.tar.gz: f31b33309764331c194d97380a37ccd0afdfa50ccd38eeba7931e330262179c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c88f8cd6cb7f6814233c608c05aabb77369ab11887a64256efbba4e813c8cf1d2ee9c4fffc3ca9c45e24618b70e8e652318969cd38f50d7741888e06bdde1333
|
7
|
+
data.tar.gz: 788dbd755914cae98ca2bbd6c4f3566deacdf8eccba0a0b50eaff92facbc95b31bd23ec31a9a4026e0643dfe9fa0a8a888b3c962dd3cc557c184b3d69f245a54
|
data/.circleci/config.yml
CHANGED
data/.node-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
14
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,51 @@
|
|
2
2
|
|
3
3
|
## Unreleased
|
4
4
|
|
5
|
+
## 6.6.0
|
6
|
+
Features
|
7
|
+
- Update power api gem to use v2.0.0. Install "internal" API mode [#394](https://github.com/platanus/potassium/pull/394)
|
8
|
+
- Updates Webpacker to Shakapacker, upgrading Vue and TailwindCSS to their latest versions [#395](https://github.com/platanus/potassium/pull/395)
|
9
|
+
- Add some image handling and processing in shrine file storage option [#398](https://github.com/platanus/potassium/pull/398)
|
10
|
+
- Include `--platanus-config` option to skip most of the instalation options [#399](https://github.com/platanus/potassium/pull/399).
|
11
|
+
- Add [`rubocop-platanus`](https://github.com/platanus/rubocop-platanus) gem for linting platanus' best practices [#402](https://github.com/platanus/potassium/pull/402).
|
12
|
+
- Remove graphql option [#404](https://github.com/platanus/potassium/pull/404)
|
13
|
+
- Add frontend testing coverage for Jest [#401](https://github.com/platanus/potassium/pull/401) and associated reviewdog comments [#406](https://github.com/platanus/potassium/pull/406)
|
14
|
+
- Add MJML to handle mail templates, with example [#405](https://github.com/platanus/potassium/pull/405)
|
15
|
+
|
16
|
+
Fixes
|
17
|
+
- Add missing vips CI config when selecting shrine [#403](https://github.com/platanus/potassium/pull/403).
|
18
|
+
- Fix shakapacker to version 6.2.x to avoid [this bug](https://github.com/shakacode/shakapacker/issues/123) [#404](https://github.com/platanus/potassium/pull/404)
|
19
|
+
|
20
|
+
## 6.5.0
|
21
|
+
|
22
|
+
Features
|
23
|
+
- Update node to latest LTS version, 14 [#363](https://github.com/platanus/potassium/pull/363)
|
24
|
+
- Update ActiveAdmin to 2.9 to fix CSV streaming issues [#384](https://github.com/platanus/potassium/pull/384)
|
25
|
+
- Separates Pundit's configuration for Active Admin from Application's configuration [#378](https://github.com/platanus/potassium/pull/378)
|
26
|
+
- Add SimpleCov recipe [#387](https://github.com/platanus/potassium/pull/387)
|
27
|
+
- Update Rails to 6.1 [#389](https://github.com/platanus/potassium/pull/389) & [#392](https://github.com/platanus/potassium/pull/392)
|
28
|
+
- Include `run_test` as a valid example group [#379](https://github.com/platanus/potassium/pull/379). This was added incorrectly in this [PR](https://github.com/platanus/potassium/pull/379).
|
29
|
+
- Add system tests configuration [#388](https://github.com/platanus/potassium/pull/388)
|
30
|
+
- Allow CircleCI cache clearing [#383](https://github.com/platanus/potassium/pull/383)
|
31
|
+
|
32
|
+
Fixes
|
33
|
+
- Remove rails_stdout_logging gem because it is no longer needed after Rails 5 and it was generating a deprecation warning [#325](https://github.com/platanus/potassium/pull/325)
|
34
|
+
- Fix default action dissapearance when using `binding.pry` in generated projects [#385](https://github.com/platanus/potassium/pull/385)
|
35
|
+
|
36
|
+
## 6.4.0
|
37
|
+
|
38
|
+
Features
|
39
|
+
- Include `run_test` as a valid example group [#379](https://github.com/platanus/potassium/pull/379)
|
40
|
+
- Updates ActiveAdmin installation to use webpacker [#350](https://github.com/platanus/potassium/pull/350)
|
41
|
+
- Replaces Active Skin with Arctic Admin [#350](https://github.com/platanus/potassium/pull/350)
|
42
|
+
|
43
|
+
Fixes
|
44
|
+
- Forces `vue-loader` version to 15, as 16 requires `@vue/compiler-sfc`, which is a part of Vue 3 [#375](https://github.com/platanus/potassium/pull/375)
|
45
|
+
- Changes Content Security Policy added by GTM recipe to: [#375](https://github.com/platanus/potassium/pull/375)
|
46
|
+
- Include the same config regardless of environment
|
47
|
+
- Include `unsafe_eval` in `script_src`, as it is required for Vue's compiler build
|
48
|
+
- Changes the front-end test to avoid using the deprecated method `isVueInstance` [#376](https://github.com/platanus/potassium/pull/376)
|
49
|
+
|
5
50
|
## 6.3.0
|
6
51
|
|
7
52
|
Features:
|
data/README.md
CHANGED
@@ -21,6 +21,34 @@ Use the `potassium create` command to create a new project:
|
|
21
21
|
> 2. If you feel that it's too slow, you may need to update rubygems: `gem update --system`.
|
22
22
|
> 3. Potassium uses node under the hood, so a check will also be performed to ensure you are running the supported version.
|
23
23
|
|
24
|
+
#### Platanus Configutarion
|
25
|
+
|
26
|
+
In case you want to use the Platanus Configuration you should use the following command:
|
27
|
+
|
28
|
+
$ potassium create <project-name> --platanus-config
|
29
|
+
|
30
|
+
This will create a project with the following configuration:
|
31
|
+
1. `database`: `'postgresql'`
|
32
|
+
2. `local`: `'es-CL'`
|
33
|
+
3. `email_service`: `'sendgrid'`
|
34
|
+
4. `devise`: `true`
|
35
|
+
5. `devise-user-model`: `true`
|
36
|
+
6. `admin`: `true`
|
37
|
+
7. `vue_admin`: `true`
|
38
|
+
8. `pundit`: `true`
|
39
|
+
9. `api`: `true`
|
40
|
+
10. `storage`: `'shrine'`
|
41
|
+
11. `heroku`: `true`
|
42
|
+
12. `background_processor`: `true`
|
43
|
+
13. `draper`: `true`
|
44
|
+
14. `schedule`: `true`
|
45
|
+
15. `sentry`: `true`
|
46
|
+
16. `front_end`: `'vue'`
|
47
|
+
17. `google_tag_manager`: `true`
|
48
|
+
18. `test`: `true`
|
49
|
+
19. `spring`: `true`
|
50
|
+
|
51
|
+
The remaining question will be asked as usual.
|
24
52
|
### Adding recipes to an existing project
|
25
53
|
|
26
54
|
Use the `potassium install` command to add a recipe to a project:
|
@@ -53,6 +81,7 @@ Potassium Rails apps includes the following gems and technologies:
|
|
53
81
|
- [Tzinfo-Data](https://github.com/tzinfo/tzinfo-data) for updating timezone information
|
54
82
|
- [Faker](https://github.com/stympy/faker) for creating development data
|
55
83
|
- [Scout](https://github.com/scoutapp/scout_apm_ruby) for monitoring performance
|
84
|
+
- [Mjml](https://github.com/sighmon/mjml-rails) for mails style
|
56
85
|
|
57
86
|
The following optional integrations are also added:
|
58
87
|
|
@@ -93,7 +122,6 @@ The optional API support includes:
|
|
93
122
|
|
94
123
|
When you choose to deploy to heroku a few extra things are added for the project.
|
95
124
|
|
96
|
-
- Adds the [Rails Stdout Logging][logging-gem] gem to configure the app to log to standard out, which is how [Heroku's logging][heroku-logging] works
|
97
125
|
- Adds a [Procfile][procfile] to define the processes to run in heroku
|
98
126
|
- Setup continuous integration using docker and herokuish to maintain better parity between testing and production environments
|
99
127
|
- Adds a `bin/release` file with the release phase script to run specific tasks before the app is deployed completely, for example `rails db:migrate:with_data`
|
@@ -129,7 +157,6 @@ Go to https://circleci.com/add-projects, choose the repository from the list and
|
|
129
157
|
|
130
158
|
In order to enable code linting via CircleCI and ReviewDog, you need to activate the **Only build pull requests** option under the `Advanced settings` section for your project.
|
131
159
|
|
132
|
-
[logging-gem]: https://github.com/heroku/rails_stdout_logging
|
133
160
|
[heroku-logging]: https://devcenter.heroku.com/articles/logging#writing-to-your-log
|
134
161
|
[procfile]: https://devcenter.heroku.com/articles/procfile
|
135
162
|
[heroku-buildpack-ruby-version]: http://github.com/platanus/heroku-buildpack-ruby-version
|
@@ -179,4 +206,4 @@ potassium is maintained by [platanus](http://platan.us).
|
|
179
206
|
|
180
207
|
## License
|
181
208
|
|
182
|
-
Potassium is © 2014 Platanus, SPA. It is free software and may be redistributed under the terms specified in the LICENSE file.
|
209
|
+
Potassium is © 2014 Platanus, SPA. It is free software and may be redistributed under the terms specified in the [LICENSE](/LICENSE.txt) file.
|
data/docs/CONTRIBUTING.md
CHANGED
@@ -54,7 +54,7 @@ This method is used if you need to ask something to the user before doing someth
|
|
54
54
|
```ruby
|
55
55
|
def ask
|
56
56
|
use_banana_split = answer(:banana_split) do
|
57
|
-
Ask.confirm("Do you
|
57
|
+
Ask.confirm("Do you want to use Banana Split?")
|
58
58
|
end
|
59
59
|
set(:use_banana_split, true) if use_banana_split
|
60
60
|
end
|
@@ -103,7 +103,7 @@ For example if you run `portassium install devise` this will use
|
|
103
103
|
[the recipe template](/lib/potassium/templates/recipe.rb) to load an execute the
|
104
104
|
`install` method for the **devise** recipe.
|
105
105
|
|
106
|
-
You can
|
106
|
+
You can define the main functionallity of a recipe in a private method and call
|
107
107
|
it from the `create` and `install` methods.
|
108
108
|
|
109
109
|
```ruby
|
@@ -1,6 +1,6 @@
|
|
1
1
|
version: 2.1
|
2
2
|
|
3
|
-
ruby-image: &ruby-image
|
3
|
+
ruby-image: &ruby-image cimg/ruby:<%= ruby_version %>
|
4
4
|
<%- if selected?(:database, :postgresql) -%>
|
5
5
|
postgres-image: &postgres-image postgres:<%= Potassium::POSTGRES_VERSION %>
|
6
6
|
<%- end -%>
|
@@ -12,6 +12,9 @@ env-vars: &env-vars
|
|
12
12
|
BUNDLE_PATH: vendor/bundle
|
13
13
|
RAILS_ENV: test
|
14
14
|
|
15
|
+
orbs:
|
16
|
+
browser-tools: circleci/browser-tools@1.1
|
17
|
+
|
15
18
|
executors:
|
16
19
|
test-executor:
|
17
20
|
docker:
|
@@ -37,14 +40,19 @@ commands:
|
|
37
40
|
|
38
41
|
- restore_cache:
|
39
42
|
keys:
|
40
|
-
- bundle-dependencies-{{ checksum "Gemfile.lock" }}
|
43
|
+
- bundle-dependencies-{{ .Environment.BUNDLE_CACHE_VERSION }}-{{ checksum "Gemfile.lock" }}
|
41
44
|
- bundle-dependencies-
|
42
45
|
|
43
46
|
- restore_cache:
|
44
47
|
keys:
|
45
|
-
- yarn-dependencies-{{ checksum "yarn.lock" }}
|
48
|
+
- yarn-dependencies-{{ .Environment.YARN_CACHE_VERSION }}-{{ checksum "yarn.lock" }}
|
46
49
|
- yarn-dependencies-
|
47
50
|
|
51
|
+
- run:
|
52
|
+
name: Install reviewdog
|
53
|
+
command: |
|
54
|
+
curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh | sh -s -- -b ./bin
|
55
|
+
|
48
56
|
- run:
|
49
57
|
name: Install bundle dependencies
|
50
58
|
command: |
|
@@ -62,20 +70,29 @@ commands:
|
|
62
70
|
yarn install --frozen-lockfile
|
63
71
|
|
64
72
|
- save_cache:
|
65
|
-
key: bundle-dependencies-{{ checksum "Gemfile.lock" }}
|
73
|
+
key: bundle-dependencies-{{ .Environment.BUNDLE_CACHE_VERSION }}-{{ checksum "Gemfile.lock" }}
|
66
74
|
paths:
|
67
75
|
- vendor/bundle
|
68
76
|
|
69
77
|
- save_cache:
|
70
|
-
key: yarn-dependencies-{{ checksum "yarn.lock" }}
|
78
|
+
key: yarn-dependencies-{{ .Environment.YARN_CACHE_VERSION }}-{{ checksum "yarn.lock" }}
|
71
79
|
paths:
|
72
80
|
- node_modules
|
81
|
+
<%- if selected?(:storage, :shrine) -%>
|
82
|
+
- run:
|
83
|
+
name: Install apt and vips buildpack dependencies
|
84
|
+
command: |
|
85
|
+
xargs -a Aptfile sudo apt-get install
|
86
|
+
sudo apt-get install libvips
|
87
|
+
<%- end -%>
|
73
88
|
|
74
89
|
jobs:
|
75
90
|
test:
|
76
91
|
executor: test-executor
|
77
92
|
steps:
|
78
93
|
- setup
|
94
|
+
- browser-tools/install-chrome
|
95
|
+
- browser-tools/install-chromedriver
|
79
96
|
|
80
97
|
<%- if selected?(:background_processor) -%>
|
81
98
|
- run:
|
@@ -93,16 +110,32 @@ jobs:
|
|
93
110
|
<%- end -%>
|
94
111
|
|
95
112
|
- run:
|
96
|
-
name: Run
|
113
|
+
name: Run RSpec unit tests
|
97
114
|
command: |
|
98
115
|
RSPEC_JUNIT_ARGS="-r rspec_junit_formatter -f RspecJunitFormatter -o test_results/rspec.xml"
|
99
116
|
RSPEC_FORMAT_ARGS="-f progress --no-color -p 10"
|
100
117
|
bundle exec rspec spec $RSPEC_FORMAT_ARGS $RSPEC_JUNIT_ARGS
|
101
118
|
|
119
|
+
- run:
|
120
|
+
name: Run RSpec system tests
|
121
|
+
command: |
|
122
|
+
RSPEC_JUNIT_ARGS="-r rspec_junit_formatter -f RspecJunitFormatter -o test_results/rspec-system.xml"
|
123
|
+
RSPEC_FORMAT_ARGS="--tag type:system -f progress --no-color -p 10"
|
124
|
+
bundle exec rspec spec $RSPEC_FORMAT_ARGS $RSPEC_JUNIT_ARGS
|
125
|
+
|
126
|
+
- run:
|
127
|
+
name: Run simplecov
|
128
|
+
shell: /bin/bash
|
129
|
+
command: |
|
130
|
+
cat coverage/coverage.txt | ./bin/reviewdog -reporter=github-pr-review -efm="%f:%l:%c: %m"
|
131
|
+
|
102
132
|
<%- if selected?(:front_end, :vue) -%>
|
103
133
|
- run:
|
104
134
|
name: Run jest
|
105
|
-
command:
|
135
|
+
command: |
|
136
|
+
yarn run test > coverage/input_jest.txt
|
137
|
+
./node_modules/.bin/format-coverage coverage/input_jest.txt coverage/output_jest.txt /home/circleci/project/app/javascript
|
138
|
+
cat coverage/output_jest.txt | ./bin/reviewdog -reporter=github-pr-review -efm="%f:%l:%c: %m"
|
106
139
|
<%- end -%>
|
107
140
|
|
108
141
|
- store_test_results:
|
@@ -113,11 +146,6 @@ jobs:
|
|
113
146
|
steps:
|
114
147
|
- setup
|
115
148
|
|
116
|
-
- run:
|
117
|
-
name: Install reviewdog
|
118
|
-
command: |
|
119
|
-
curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh | sh -s -- -b ./bin
|
120
|
-
|
121
149
|
- run:
|
122
150
|
name: Get files to lint
|
123
151
|
command: git diff origin/master --name-only --diff-filter=d > tmp/files_to_lint
|
@@ -1,12 +1,16 @@
|
|
1
1
|
{
|
2
2
|
"env": {
|
3
|
-
"
|
3
|
+
"browser": true,
|
4
|
+
"es2021": true,
|
5
|
+
"node": true,
|
6
|
+
"jest/globals": true,
|
7
|
+
"vue/setup-compiler-macros": true
|
4
8
|
},
|
5
9
|
"parserOptions": {
|
6
|
-
"ecmaVersion":
|
10
|
+
"ecmaVersion": 2020,
|
7
11
|
"sourceType": "module"
|
8
12
|
},
|
9
|
-
"plugins": ["import"],
|
13
|
+
"plugins": ["import", "jest", "tailwindcss"],
|
10
14
|
"settings": {
|
11
15
|
"import/resolver": {
|
12
16
|
"node": {
|
@@ -15,7 +19,10 @@
|
|
15
19
|
}
|
16
20
|
},
|
17
21
|
"extends": [
|
18
|
-
"plugin:vue/
|
22
|
+
"plugin:vue/vue3-recommended",
|
23
|
+
"@vue/typescript/recommended",
|
24
|
+
"@vue/eslint-config-typescript",
|
25
|
+
"plugin:tailwindcss/recommended"
|
19
26
|
],
|
20
27
|
"rules": {
|
21
28
|
"accessor-pairs": 0,
|
@@ -338,14 +345,13 @@
|
|
338
345
|
"vue/max-len": ["error", {
|
339
346
|
"code": 120,
|
340
347
|
"ignoreHTMLAttributeValues": true
|
341
|
-
|
348
|
+
}]
|
342
349
|
},
|
343
350
|
"overrides": [
|
344
351
|
{
|
345
|
-
"files": ["
|
346
|
-
"
|
347
|
-
|
348
|
-
"node": true
|
352
|
+
"files": ["*.ts", "*.vue"],
|
353
|
+
"rules": {
|
354
|
+
"no-undef": "off"
|
349
355
|
}
|
350
356
|
}
|
351
357
|
]
|
data/lib/potassium/assets/.pryrc
CHANGED
@@ -4,9 +4,3 @@ if defined?(PryByebug)
|
|
4
4
|
Pry.commands.alias_command 'n', 'next'
|
5
5
|
Pry.commands.alias_command 'f', 'finish'
|
6
6
|
end
|
7
|
-
|
8
|
-
if defined?(Rails)
|
9
|
-
require 'rails/console/app'
|
10
|
-
require 'rails/console/helpers'
|
11
|
-
include Rails::ConsoleMethods # rubocop:disable Style/MixinUsage
|
12
|
-
end
|
@@ -27,7 +27,7 @@ readme:
|
|
27
27
|
body: |
|
28
28
|
For hot-reloading and fast webpacker compilation you need to run webpack's dev server along with the rails server:
|
29
29
|
|
30
|
-
$ ./bin/
|
30
|
+
$ ./bin/webpacker-dev-server
|
31
31
|
|
32
32
|
Running the dev server will also solve problems with the cache not refreshing between changes and provide better error messages if something fails to compile.
|
33
33
|
|
@@ -105,7 +105,34 @@ readme:
|
|
105
105
|
body: "For managing uploads, this project uses [Active Storage](https://github.com/rails/rails/tree/master/activestorage)."
|
106
106
|
shrine:
|
107
107
|
title: "File Storage"
|
108
|
-
body:
|
108
|
+
body: |
|
109
|
+
For managing uploads, this project uses [Shrine](https://github.com/shrinerb/shrine). When generated, this project includes the following files and configurations:
|
110
|
+
|
111
|
+
- `ImageUploader` that includes file type validation
|
112
|
+
- `CoverImageUploader`, inheriting from `ImageUploader`. It does a couple of things:
|
113
|
+
- Generates derivatives in `jpg` and `webp` format, for three different sizes. For an attachment of name `image`, to get the url for a derivative, let's say `sm`, you would do `record.image_url(:sm)`
|
114
|
+
- Saves a [blurhash](https://blurha.sh/) code to the attachment metadata
|
115
|
+
- `ImageHandlingUtilities`, a shrine plugin in the initializers folder that is used in the `CoverImageUploader`. Given a model with an attachment of name `image`, it adds the following methods to the model:
|
116
|
+
- `image_blurhash`: returns blurhash from metadata
|
117
|
+
- `generate_image_derivatives`: It generates all derivatives defined in Uploader. If file already had derivatives, it replaces them with newly generated ones. Associated class method: `generate_all_image_derivatives`
|
118
|
+
- `generate_image_metadata`: refreshes all metadata for attachment. Associated class method: `generate_all_image_metadata`
|
119
|
+
- `generate_image_derivatives_and_metadata`: does both previous things. Useful because it does so opening the file only once. Associated class method: `generate_all_image_derivatives_and_metadata`
|
120
|
+
|
121
|
+
Class methods are the same as their instance counterparts, but for collections. They also allow error handling on an individual record by passing a block to handle each error. If no block is given, attachments that throw errors are ignored and the iteration continues
|
122
|
+
- `ImageHandlingAttributes` serializer concern. It adds a method `add_image_handling_attributes` to all serializers that inherit from `BaseSerializer`. Considering an attachment of name `image`, this method adds two attributes to the serialized record:
|
123
|
+
- `image_blurhash`
|
124
|
+
- `image`. This is a hash that includes urls for all derivatives passed to the method. For example:
|
125
|
+
```
|
126
|
+
add_image_handling_attributes(attachment_name: :image, derivatives: [:sm, :md], include_original_image: true)
|
127
|
+
|
128
|
+
# results in the following hash for the image attribute:
|
129
|
+
# {
|
130
|
+
# sm: { url: 'someurl.com/bla' },
|
131
|
+
# md: { url: 'someurl.com/ble' },
|
132
|
+
# original: { url: 'someurl.com/ble' }
|
133
|
+
# }
|
134
|
+
```
|
135
|
+
- `SHRINE_SECRET_KEY` environment variable. It comes witha value set in `.env.development`, but you'll need to set one for it in staging and production. It can be any random value, generating it with `SecureRandom.hex` for instance
|
109
136
|
pundit:
|
110
137
|
title: "Authorization"
|
111
138
|
body: "For defining which parts of the system each user has access to, we have chosen to include the [Pundit](https://github.com/elabs/pundit) gem, by [Elabs](http://elabs.se/)."
|
@@ -123,20 +150,17 @@ readme:
|
|
123
150
|
body: "This project uses [Draper](https://github.com/drapergem/draper) to add an object-oriented layer of presentation logic"
|
124
151
|
power_types:
|
125
152
|
title: "Rails pattern enforcing types"
|
126
|
-
body: "This
|
153
|
+
body: "This project uses [Power-Types](https://github.com/platanus/power-types) to generate Services, Commands, Utils and Values."
|
127
154
|
power_api:
|
128
155
|
title: "API Support"
|
129
156
|
body: "This projects uses [Power API](https://github.com/platanus/power_api). It's a Rails engine that gathers a set of gems and configurations designed to build incredible REST APIs."
|
130
|
-
graphql:
|
131
|
-
title: "API Support"
|
132
|
-
body: "This projects uses [graphql-ruby](https://graphql-ruby.org/) to generate a GraphQL API."
|
133
157
|
active_admin:
|
134
158
|
title: "Administration"
|
135
159
|
body: |
|
136
160
|
This project uses [Active Admin](https://github.com/activeadmin/activeadmin) which is a Ruby on Rails framework for creating elegant backends for website administration.
|
137
161
|
<% if get(:vue_admin) %>
|
138
162
|
This project supports Vue inside ActiveAdmin
|
139
|
-
- The main package is located in `app/javascript/
|
163
|
+
- The main package is located in `app/javascript/active_admin.js`, here you will declare the components you want to include in your ActiveAdmin views as you would in a normal Vue App.
|
140
164
|
- Additionally, to be able to use Vue components as [Arbre](https://github.com/activeadmin/arbre) Nodes the component names are also declared in `config/initializers/active_admin.rb`
|
141
165
|
- The generator includes an example component called `admin_component`, you can use this component inside any ActiveAdmin view by just writing `admin_component` as you would with any `html` tag.
|
142
166
|
- For example:
|
@@ -153,8 +177,51 @@ readme:
|
|
153
177
|
```
|
154
178
|
- You can also use **any** vue bindings such as `v-for` , `:key` etc.
|
155
179
|
<% end %>
|
180
|
+
<% if get(:authorization) %>
|
181
|
+
It uses the [ActiveAdmin's Pundit adapter](https://activeadmin.info/13-authorization-adapter.html).
|
182
|
+
- Policies for admin resources must inherit from `BackOffice::DefaultPolicy` and be placed inside the `app/policies/back_office` directory.
|
183
|
+
- For example:
|
184
|
+
|
185
|
+
`app/admin/clients.rb`:
|
186
|
+
|
187
|
+
```ruby
|
188
|
+
ActiveAdmin.register Client do
|
189
|
+
# ...
|
190
|
+
end
|
191
|
+
```
|
192
|
+
|
193
|
+
`app/policies/back_office/client_policy.rb`:
|
194
|
+
|
195
|
+
```ruby
|
196
|
+
class BackOffice::ClientPolicy < BackOffice::DefaultPolicy
|
197
|
+
end
|
198
|
+
```
|
199
|
+
<% end %>
|
156
200
|
seeds:
|
157
201
|
title: "Seeds"
|
158
202
|
body: |
|
159
203
|
To populate your database with initial data you can add, inside the `/db/seeds.rb` file, the code to generate **only the necessary data** to run the application.
|
160
204
|
If you need to generate data with **development purposes**, you can customize the `lib/fake_data_loader.rb` module and then to run the `rake load_fake_data` task from your terminal.
|
205
|
+
testing:
|
206
|
+
title: "Testing"
|
207
|
+
body: |
|
208
|
+
We use:
|
209
|
+
- [RSpec](https://github.com/rspec/rspec-rails): the testing framework.
|
210
|
+
- [Shoulda Matchers](https://github.com/thoughtbot/shoulda-matchers): one-liners to test common Rails functionality that, if written by hand, would be much longer, more complex, and error-prone.
|
211
|
+
- [Factory Bot](https://github.com/thoughtbot/factory_bot_rails): a fixtures replacement with a straightforward definition syntax, support for multiple build strategies (saved instances, unsaved instances, attribute hashes, and stubbed objects), and support for multiple factories for the same class (user, admin_user, and so on), including factory inheritance.
|
212
|
+
- [Faker](https://github.com/faker-ruby/faker): a port of Perl's Data::Faker library that generates fake data.
|
213
|
+
- [Guard](https://github.com/guard/guard): automates various tasks by running custom rules whenever file or directories are modified. We use it to run RSpec when files change.
|
214
|
+
|
215
|
+
Place your unit tests inside the `spec` directory.
|
216
|
+
|
217
|
+
To run unit tests: `bin/guard`
|
218
|
+
|
219
|
+
#### System tests
|
220
|
+
|
221
|
+
We use, in addition to the previous gems:
|
222
|
+
- [Capybara](https://github.com/teamcapybara/capybara): helps you test web applications by simulating how a real user would interact with your app. It is agnostic about the driver running your tests and comes with Rack::Test and Selenium support built in. WebKit is supported through an external gem.
|
223
|
+
- [Webdrivers](https://github.com/titusfortner/webdrivers): run Selenium tests more easily with automatic installation and updates for all supported webdrivers.
|
224
|
+
|
225
|
+
Place your system tests inside the `spec/system` directory.
|
226
|
+
|
227
|
+
To run system tests: `bin/rspec --tag type:system`
|
@@ -1,35 +1,27 @@
|
|
1
|
+
<script setup lang="ts">
|
2
|
+
interface Props {
|
3
|
+
test?: string
|
4
|
+
testNumber?: number
|
5
|
+
testObject?: {[key: string]: string},
|
6
|
+
testList?: number[],
|
7
|
+
}
|
8
|
+
|
9
|
+
const props = withDefaults(
|
10
|
+
defineProps<Props>(),
|
11
|
+
{
|
12
|
+
test: undefined,
|
13
|
+
testNumber: 0,
|
14
|
+
testObject: undefined,
|
15
|
+
testList: undefined,
|
16
|
+
},
|
17
|
+
);
|
18
|
+
|
19
|
+
const message = 'Hello World';
|
20
|
+
</script>
|
21
|
+
|
1
22
|
<template>
|
2
23
|
<div>
|
3
|
-
I am a Vue Component {{ test }} {{ message }}
|
24
|
+
I am a Vue Component {{ props.test }} {{ message }}
|
4
25
|
<slot />
|
5
26
|
</div>
|
6
27
|
</template>
|
7
|
-
|
8
|
-
<script>
|
9
|
-
export default {
|
10
|
-
props: {
|
11
|
-
test: {
|
12
|
-
type: String,
|
13
|
-
default: '',
|
14
|
-
},
|
15
|
-
testNumber: {
|
16
|
-
type: Number,
|
17
|
-
default: 0,
|
18
|
-
},
|
19
|
-
testObject: {
|
20
|
-
type: Object,
|
21
|
-
default: null,
|
22
|
-
},
|
23
|
-
testList: {
|
24
|
-
type: Array,
|
25
|
-
default: null,
|
26
|
-
},
|
27
|
-
},
|
28
|
-
|
29
|
-
data() {
|
30
|
-
return {
|
31
|
-
message: 'Hello World',
|
32
|
-
};
|
33
|
-
},
|
34
|
-
};
|
35
|
-
</script>
|
@@ -0,0 +1,49 @@
|
|
1
|
+
class BackOffice::DefaultPolicy
|
2
|
+
attr_reader :admin_user, :record
|
3
|
+
|
4
|
+
def initialize(admin_user, record)
|
5
|
+
@admin_user = admin_user
|
6
|
+
@record = record
|
7
|
+
end
|
8
|
+
|
9
|
+
def index?
|
10
|
+
true
|
11
|
+
end
|
12
|
+
|
13
|
+
def show?
|
14
|
+
true
|
15
|
+
end
|
16
|
+
|
17
|
+
def create?
|
18
|
+
true
|
19
|
+
end
|
20
|
+
|
21
|
+
def new?
|
22
|
+
create?
|
23
|
+
end
|
24
|
+
|
25
|
+
def update?
|
26
|
+
true
|
27
|
+
end
|
28
|
+
|
29
|
+
def edit?
|
30
|
+
update?
|
31
|
+
end
|
32
|
+
|
33
|
+
def destroy?
|
34
|
+
true
|
35
|
+
end
|
36
|
+
|
37
|
+
class Scope
|
38
|
+
attr_reader :admin_user, :scope
|
39
|
+
|
40
|
+
def initialize(admin_user, scope)
|
41
|
+
@admin_user = admin_user
|
42
|
+
@scope = scope
|
43
|
+
end
|
44
|
+
|
45
|
+
def resolve
|
46
|
+
scope.all
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
import { shallowMount } from '@vue/test-utils';
|
2
|
-
import App from 'app';
|
2
|
+
import App from './app.vue';
|
3
3
|
|
4
4
|
describe('App', () => {
|
5
5
|
test('is a Vue instance', () => {
|
6
6
|
const wrapper = shallowMount(App);
|
7
|
-
expect(wrapper.
|
7
|
+
expect(wrapper.vm).toBeTruthy();
|
8
8
|
});
|
9
9
|
|
10
10
|
it('displays message on load', () => {
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class ShrinePromoteJob < ApplicationJob
|
2
|
+
queue_as :default
|
3
|
+
|
4
|
+
def perform(attacher_class, record_class, record_id, name, file_data)
|
5
|
+
attacher_class = Object.const_get(attacher_class)
|
6
|
+
record = Object.const_get(record_class).find(record_id)
|
7
|
+
|
8
|
+
attacher = attacher_class.retrieve(model: record, name: name, file: file_data)
|
9
|
+
attacher.create_derivatives
|
10
|
+
attacher.atomic_promote
|
11
|
+
rescue Shrine::AttachmentChanged, ActiveRecord::RecordNotFound
|
12
|
+
# attachment has changed or the record has been deleted, nothing to do
|
13
|
+
end
|
14
|
+
end
|