potassium 6.6.0 → 6.7.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: 0bc57ea8c0f92d1ce3dd15feef9164f7bef381ce322051bd810a3303c8ca257c
4
- data.tar.gz: f31b33309764331c194d97380a37ccd0afdfa50ccd38eeba7931e330262179c3
3
+ metadata.gz: 81ec8c6408ed21f78421ecb48565bcd42e6478fc0a08a7ca0881035eb8d0c444
4
+ data.tar.gz: 0b925fa5a1344c3f284d91f8fdb092d984d47f8434b4beed51678e4a909e2ada
5
5
  SHA512:
6
- metadata.gz: c88f8cd6cb7f6814233c608c05aabb77369ab11887a64256efbba4e813c8cf1d2ee9c4fffc3ca9c45e24618b70e8e652318969cd38f50d7741888e06bdde1333
7
- data.tar.gz: 788dbd755914cae98ca2bbd6c4f3566deacdf8eccba0a0b50eaff92facbc95b31bd23ec31a9a4026e0643dfe9fa0a8a888b3c962dd3cc557c184b3d69f245a54
6
+ metadata.gz: 8a07cf43e021c0350e84eb0213f5ac513fa2446c16cfd492a0b7947acdd45776b817004d5f4cf42962947137dc988ccaa1e61020f23b89a63040b85d04e61a2e
7
+ data.tar.gz: af4598c990bede9a8be8cbf47dd324f9f13b584b5b0982ab277806f71318b4d97da289e9cad725d45398e66cc7454578bd89fc086b550ebc586286d46d217f98
data/CHANGELOG.md CHANGED
@@ -1,6 +1,20 @@
1
1
  # Changelog
2
2
 
3
- ## Unreleased
3
+ ## 6.7.0
4
+
5
+ Features
6
+ - Add type checking to reviewdog [#411](https://github.com/platanus/potassium/pull/411)
7
+ - Add initial api files [#412](https://github.com/platanus/potassium/pull/412)
8
+ - Add eslint-plugin-platanus [#415](https://github.com/platanus/potassium/pull/415)
9
+
10
+ Fixes
11
+ - Prepend vips installation [#407](https://github.com/platanus/potassium/pull/407)
12
+ - Fix jest install [#408](https://github.com/platanus/potassium/pull/408)
13
+ - Fix circle ci config. Provide global context to test job [#409](https://github.com/platanus/potassium/pull/409)
14
+ - Fix admin css (arctic_skin) [#413](https://github.com/platanus/potassium/pull/413)
15
+ - Fix tsc check [#414](https://github.com/platanus/potassium/pull/414)
16
+ - Fix monkeyci commenting because of uncovered lines when tests do exist [#416](https://github.com/platanus/potassium/pull/416)
17
+ - Typescript fixes [#417](https://github.com/platanus/potassium/pull/417)
4
18
 
5
19
  ## 6.6.0
6
20
  Features
@@ -116,6 +116,12 @@ jobs:
116
116
  RSPEC_FORMAT_ARGS="-f progress --no-color -p 10"
117
117
  bundle exec rspec spec $RSPEC_FORMAT_ARGS $RSPEC_JUNIT_ARGS
118
118
 
119
+ - run:
120
+ name: Run simplecov
121
+ shell: /bin/bash
122
+ command: |
123
+ cat coverage/coverage.txt | ./bin/reviewdog -reporter=github-pr-review -efm="%f:%l:%c: %m"
124
+
119
125
  - run:
120
126
  name: Run RSpec system tests
121
127
  command: |
@@ -123,12 +129,6 @@ jobs:
123
129
  RSPEC_FORMAT_ARGS="--tag type:system -f progress --no-color -p 10"
124
130
  bundle exec rspec spec $RSPEC_FORMAT_ARGS $RSPEC_JUNIT_ARGS
125
131
 
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
-
132
132
  <%- if selected?(:front_end, :vue) -%>
133
133
  - run:
134
134
  name: Run jest
@@ -164,6 +164,18 @@ jobs:
164
164
  cat tmp/files_to_lint | grep -E '.+\.(js|jsx|vue)$' | xargs yarn run eslint \
165
165
  | ./bin/reviewdog -reporter=github-pr-review -f=eslint
166
166
 
167
+ - run:
168
+ name: Run tsc
169
+ shell: /bin/bash
170
+ command: |
171
+ yarn run tsc --noEmit | ./bin/reviewdog -reporter=github-pr-review -f=tsc
172
+
173
+ - run:
174
+ name: Run vue-tsc
175
+ shell: /bin/bash
176
+ command: |
177
+ yarn run vue-tsc --noEmit | ./bin/reviewdog -reporter=github-pr-review -f=tsc
178
+
167
179
  - run:
168
180
  name: Run stylelint
169
181
  shell: /bin/bash
@@ -174,6 +186,7 @@ jobs:
174
186
  workflows:
175
187
  test_and_lint:
176
188
  jobs:
177
- - test
189
+ - test:
190
+ context: org-global
178
191
  - lint:
179
192
  context: org-global
@@ -22,7 +22,8 @@
22
22
  "plugin:vue/vue3-recommended",
23
23
  "@vue/typescript/recommended",
24
24
  "@vue/eslint-config-typescript",
25
- "plugin:tailwindcss/recommended"
25
+ "plugin:tailwindcss/recommended",
26
+ "plugin:platanus/recommended"
26
27
  ],
27
28
  "rules": {
28
29
  "accessor-pairs": 0,
@@ -0,0 +1,55 @@
1
+ import axios, { type AxiosRequestTransformer, type AxiosResponseTransformer } from 'axios';
2
+ import convertKeys from '../utils/case-converter';
3
+
4
+ const api = axios.create({
5
+ transformRequest: [
6
+ (data: any) => convertKeys(data, 'decamelize'),
7
+ ...(axios.defaults.transformRequest as AxiosRequestTransformer[]),
8
+ ],
9
+ transformResponse: [
10
+ ...(axios.defaults.transformResponse as AxiosResponseTransformer[]),
11
+ (data: any) => convertKeys(data, 'camelize'),
12
+ ],
13
+ });
14
+
15
+ export default api;
16
+
17
+ /*
18
+ // Example to use the api object in the path ´app/javascript/api/users.ts´
19
+
20
+ import api from './index';
21
+
22
+ export default {
23
+ index() {
24
+ const path = '/api/internal/users';
25
+
26
+ return api({
27
+ method: 'get',
28
+ url: path,
29
+ });
30
+ },
31
+ create(data: Partial<User>) {
32
+ const path = '/api/internal/users';
33
+
34
+ return api({
35
+ method: 'post',
36
+ url: path,
37
+ data: {
38
+ user: data,
39
+ },
40
+ });
41
+ },
42
+ update(data: Partial<User>) {
43
+ const path = `/api/internal/users/${data.id}`;
44
+
45
+ return api({
46
+ method: 'put',
47
+ url: path,
48
+ data: {
49
+ user: data,
50
+ },
51
+ });
52
+ },
53
+ };
54
+
55
+ */
@@ -0,0 +1,39 @@
1
+ // From https://github.com/domchristie/humps/issues/51#issuecomment-425113505
2
+ /* eslint-disable complexity */
3
+ /* eslint-disable max-statements */
4
+ import { camelize, decamelize } from 'humps';
5
+
6
+ type objectToConvert = File | FormData | Blob | Record<string, unknown> | Array<objectToConvert>;
7
+
8
+ function convertKeys(
9
+ object: objectToConvert,
10
+ conversion: 'camelize' | 'decamelize',
11
+ ): objectToConvert {
12
+ const converter = {
13
+ camelize,
14
+ decamelize,
15
+ };
16
+ if (object && !(object instanceof File) && !(object instanceof Blob)) {
17
+ if (object instanceof Array) {
18
+ return object.map((item: objectToConvert) => convertKeys(item, conversion));
19
+ }
20
+ if (object instanceof FormData) {
21
+ const formData = new FormData();
22
+ for (const [key, value] of object.entries()) {
23
+ formData.append(converter[conversion](key), value);
24
+ }
25
+
26
+ return formData;
27
+ }
28
+ if (typeof object === 'object') {
29
+ return Object.keys(object).reduce((acc, next) => ({
30
+ ...acc,
31
+ [converter[conversion](next)]: convertKeys(object[next] as objectToConvert, conversion),
32
+ }), {});
33
+ }
34
+ }
35
+
36
+ return object;
37
+ }
38
+
39
+ export default convertKeys;
@@ -26,6 +26,7 @@
26
26
  "app/javascript/**/*.vue"
27
27
  ],
28
28
  "exclude": [
29
- "node_modules"
29
+ "node_modules",
30
+ "**/*.spec.ts"
30
31
  ]
31
32
  }
@@ -66,7 +66,45 @@ class Recipes::Admin < Rails::AppBuilder
66
66
  aa_style,
67
67
  "@import \"~@activeadmin/activeadmin/src/scss/mixins\";\n" +
68
68
  "@import \"~@activeadmin/activeadmin/src/scss/base\";",
69
- "@import '~arctic_admin/src/scss/main'; \n"
69
+ <<~HERE
70
+ @import '~arctic_admin/src/scss/main';
71
+
72
+ // Fix for sidebar when there are too many filters
73
+ #sidebar {
74
+ height: 100vh;
75
+ top: 0;
76
+ z-index: 10;
77
+ }
78
+
79
+ #sidebar::before {
80
+ top: 200px !important;
81
+ }
82
+
83
+ #filters_sidebar_section {
84
+ height: 100vh;
85
+ overflow: auto;
86
+ }
87
+
88
+ // Fix for invisible datepicker calendar
89
+ #ui-datepicker-div {
90
+ z-index: 11 !important;
91
+ }
92
+
93
+ // Fix for backwards date range input
94
+ #sidebar .sidebar_section .filter_date_range input:nth-child(2) {
95
+ float: none;
96
+ }
97
+
98
+ #sidebar .sidebar_section .filter_date_range {
99
+ display: flex;
100
+ flex-flow: row wrap;
101
+ justify-content: space-between
102
+ }
103
+
104
+ #sidebar .sidebar_section .filter_date_range label {
105
+ width: 100%;
106
+ }
107
+ HERE
70
108
  )
71
109
 
72
110
  aa_js = "app/javascript/packs/active_admin.js"
@@ -86,7 +86,7 @@ class Recipes::FileStorage < Rails::AppBuilder
86
86
  end
87
87
 
88
88
  def add_image_handling_heroku_setup
89
- append_to_file(
89
+ prepend_file(
90
90
  '.buildpacks',
91
91
  <<~HERE
92
92
  https://github.com/heroku/heroku-buildpack-apt
@@ -5,7 +5,7 @@ class Recipes::FrontEnd < Rails::AppBuilder
5
5
  POSTCSS_VERSION = Potassium::POSTCSS_VERSION
6
6
  TAILWINDCSS_VERSION = Potassium::TAILWINDCSS_VERSION
7
7
  AUTOPREFIXER_VERSION = Potassium::AUTOPREFIXER_VERSION
8
- VUE_JEST_VERSION = Potassium::VUE_JEST_VERSION
8
+ JEST_VERSION = Potassium::JEST_VERSION
9
9
 
10
10
  def ask
11
11
  frameworks = {
@@ -35,6 +35,7 @@ class Recipes::FrontEnd < Rails::AppBuilder
35
35
  recipe.setup_vue if value == :vue
36
36
  recipe.add_responsive_meta_tag
37
37
  recipe.setup_tailwind
38
+ recipe.setup_api_client
38
39
  add_readme_header :webpack
39
40
  end
40
41
  end
@@ -107,8 +108,10 @@ class Recipes::FrontEnd < Rails::AppBuilder
107
108
  end
108
109
 
109
110
  def setup_jest
110
- run "bin/yarn add jest @vue/vue3-jest@#{VUE_JEST_VERSION} babel-jest "\
111
- "@vue/test-utils@#{VUE_TEST_UTILS_VERSION} ts-jest"
111
+ run "bin/yarn add jest@#{JEST_VERSION} @vue/vue3-jest@#{JEST_VERSION} "\
112
+ "babel-jest@#{JEST_VERSION} @vue/test-utils@#{VUE_TEST_UTILS_VERSION} ts-jest@#{JEST_VERSION} "\
113
+ "jest-environment-jsdom@#{JEST_VERSION} --dev"
114
+ run "bin/yarn add @types/jest@#{JEST_VERSION}"
112
115
  json_file = File.read(Pathname.new("package.json"))
113
116
  js_package = JSON.parse(json_file)
114
117
  js_package = js_package.merge(jest_config)
@@ -121,7 +124,8 @@ class Recipes::FrontEnd < Rails::AppBuilder
121
124
 
122
125
  def setup_vue
123
126
  run "bin/yarn add vue@#{VUE_VERSION} vue-loader@#{VUE_LOADER_VERSION} "\
124
- "babel-preset-typescript-vue3"
127
+ "babel-preset-typescript-vue3 @types/humps"
128
+ run "bin/yarn add vue-tsc --dev"
125
129
  gsub_file(
126
130
  'config/webpack/webpack.config.js',
127
131
  ' merge(typescriptConfig, cssConfig, jQueryConfig, webpackConfig);',
@@ -136,6 +140,13 @@ class Recipes::FrontEnd < Rails::AppBuilder
136
140
  end
137
141
  end
138
142
 
143
+ def setup_api_client
144
+ run "bin/yarn add axios humps"
145
+ copy_file '../assets/app/javascript/api/index.ts', 'app/javascript/api/index.ts'
146
+ copy_file '../assets/app/javascript/utils/case-converter.ts',
147
+ 'app/javascript/utils/case-converter.ts'
148
+ end
149
+
139
150
  private
140
151
 
141
152
  def frameworks(framework)
@@ -239,6 +250,9 @@ class Recipes::FrontEnd < Rails::AppBuilder
239
250
  "moduleNameMapper": {
240
251
  "^@/(.*)$": "app/javascript/$1"
241
252
  },
253
+ "testEnvironmentOptions": {
254
+ "customExportConditions": ["node", "node-addons"]
255
+ },
242
256
  "moduleFileExtensions": [
243
257
  "js",
244
258
  "ts",
@@ -22,7 +22,8 @@ class Recipes::Style < Rails::AppBuilder
22
22
 
23
23
  after(:webpacker_install) do
24
24
  run "yarn add --dev stylelint eslint eslint-plugin-import "\
25
- "@typescript-eslint/eslint-plugin @types/jest @typescript-eslint/parser eslint-plugin-jest"
25
+ "@typescript-eslint/eslint-plugin @types/jest @typescript-eslint/parser "\
26
+ "eslint-plugin-jest eslint-plugin-platanus"
26
27
  if selected?(:front_end, :vue)
27
28
  run 'yarn add --dev eslint-plugin-vue @vue/eslint-config-typescript'
28
29
  end
@@ -1,5 +1,5 @@
1
1
  module Potassium
2
- VERSION = "6.6.0"
2
+ VERSION = "6.7.0"
3
3
  RUBY_VERSION = "2.7.0"
4
4
  RAILS_VERSION = "~> 6.1.4.4"
5
5
  RUBOCOP_VERSION = "~> 1.9"
@@ -10,8 +10,8 @@ module Potassium
10
10
  TAILWINDCSS_VERSION = "^3"
11
11
  POSTCSS_VERSION = "^8"
12
12
  AUTOPREFIXER_VERSION = "^10"
13
- VUE_VERSION = "^3"
14
- VUE_LOADER_VERSION = "^16"
15
- VUE_TEST_UTILS_VERSION = "^2.0.0-rc.18"
16
- VUE_JEST_VERSION = "^27.0.0-alpha.1"
13
+ VUE_VERSION = "^3.2.33"
14
+ VUE_LOADER_VERSION = "^16.8.3"
15
+ VUE_TEST_UTILS_VERSION = "^2.0.2"
16
+ JEST_VERSION = "^28.0.1"
17
17
  end
@@ -67,5 +67,10 @@ RSpec.describe "Front end" do
67
67
  it 'includes correct version of vue-loader in package' do
68
68
  expect(node_modules_file).to include("\"vue-loader\": \"#{Potassium::VUE_LOADER_VERSION}\"")
69
69
  end
70
+
71
+ it 'includes correct packages for basic api client' do
72
+ expect(node_modules_file).to include("\"axios\"")
73
+ expect(node_modules_file).to include("\"humps\"")
74
+ end
70
75
  end
71
76
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: potassium
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.6.0
4
+ version: 6.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - juliogarciag
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-15 00:00:00.000000000 Z
11
+ date: 2022-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -281,9 +281,11 @@ files:
281
281
  - lib/potassium/assets/active_admin/policies/comment_policy.rb
282
282
  - lib/potassium/assets/active_admin/policies/default_policy.rb
283
283
  - lib/potassium/assets/active_admin/policies/page_policy.rb
284
+ - lib/potassium/assets/app/javascript/api/index.ts
284
285
  - lib/potassium/assets/app/javascript/components/app.spec.ts
285
286
  - lib/potassium/assets/app/javascript/components/app.vue
286
287
  - lib/potassium/assets/app/javascript/types/vue.d.ts
288
+ - lib/potassium/assets/app/javascript/utils/case-converter.ts
287
289
  - lib/potassium/assets/app/jobs/shrine_promote_job.rb
288
290
  - lib/potassium/assets/app/mailers/application_mailer.rb
289
291
  - lib/potassium/assets/app/mailers/example_mailer.rb