Skip to content

Commit 71d0d3e

Browse files
authored
Merge branch 'develop' into renovate/demo-phoenix_test_playwright-0.x
2 parents 009776d + 9b5edc7 commit 71d0d3e

File tree

2 files changed

+42
-18
lines changed

2 files changed

+42
-18
lines changed

.github/renovate.json

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,23 @@
99
"github>pehbehbeh/renovate-config//customManagers/hexEsbuild",
1010
"github>pehbehbeh/renovate-config//customManagers/hexTailwind",
1111
":reviewer(krns)",
12-
":automergePatch",
1312
"helpers:pinGitHubActionDigestsToSemver",
1413
"npm:unpublishSafe"
1514
],
15+
"additionalBranchPrefix": "{{packageFileDir}}-",
1616
"pinDigests": false,
1717
"lockFileMaintenance": {
1818
"enabled": true,
1919
"extends": ["schedule:weekly"]
2020
},
21-
"additionalBranchPrefix": "{{packageFileDir}}-",
21+
"patch": {
22+
"automerge": true,
23+
"minimumReleaseAge": "14"
24+
},
25+
"pin": {
26+
"automerge": true,
27+
"minimumReleaseAge": "14"
28+
},
2229
"packageRules": [
2330
{
2431
"description": "Set Mix versioning strategy to update-lockfile",
@@ -39,18 +46,14 @@
3946
"enabled": false
4047
},
4148
{
42-
"description": "Disable automerge for docker data source",
43-
"matchDatasources": ["docker"],
44-
"automerge": true
45-
},
46-
{
47-
"description": "Automatically merge non-major github actions updates",
49+
"description": "Automerge non-major github actions updates",
4850
"matchManagers": ["github-actions"],
4951
"matchUpdateTypes": ["minor", "patch", "pin", "pinDigest"],
50-
"automerge": true
52+
"automerge": true,
53+
"minimumReleaseAge": 14
5154
},
5255
{
53-
"description": "Automerge some non-major node package updates",
56+
"description": "Automerge some minor node package updates",
5457
"matchDepNames": [
5558
"@sentry/browser",
5659
"stylelint",
@@ -62,7 +65,8 @@
6265
],
6366
"matchDatasources": ["npm"],
6467
"matchUpdateTypes": ["minor", "patch"],
65-
"automerge": true
68+
"automerge": true,
69+
"minimumReleaseAge": 14
6670
},
6771
{
6872
"description": "Label dependency updates in demo directory",

lib/mix/tasks/backpex.install.ex

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ defmodule Mix.Tasks.Backpex.Install.Docs do
2121
## What this installer does:
2222
2323
- Sets up [Global Configuration](installation.html#global-configuration) by configuring the PubSub server
24-
- Adds [Backpex Hooks](installation.html#backpex-hooks) to your app.js file
24+
- Adds [Backpex Hooks](installation.html#backpex-hooks) to your app.js or app.ts file (auto-detected)
2525
- Installs [daisyUI](installation.html#daisyui) via npm (with your permission)
2626
- Sets up the [formatter configuration](installation.html#setup-formatter)
2727
- Adds [Backpex files to Tailwind content](installation.html#add-files-to-tailwind-content)
@@ -38,7 +38,7 @@ defmodule Mix.Tasks.Backpex.Install.Docs do
3838
3939
## Options
4040
41-
* `--app-js-path` - Path to your app.js file (default: "assets/js/app.js")
41+
* `--app-js-path` - Path to your app.js or app.ts file (auto-detected by default)
4242
* `--app-css-path` - Path to your app.css file (default: "assets/css/app.css")
4343
* `--no-layout` - Skip generating the admin layout
4444
"""
@@ -63,7 +63,6 @@ if Code.ensure_loaded?(Igniter) do
6363
alias Igniter.Util.Warning
6464
alias IgniterJs.Parsers.Javascript.Parser
6565

66-
@default_app_js_path Path.join(["assets", "js", "app.js"])
6766
@default_app_css_path Path.join(["assets", "css", "app.css"])
6867
@hooks "...BackpexHooks"
6968
@imports "import { Hooks as BackpexHooks } from 'backpex'"
@@ -75,7 +74,7 @@ if Code.ensure_loaded?(Igniter) do
7574
adds_deps: [igniter_js: "~> 0.4"],
7675
example: __MODULE__.Docs.example(),
7776
schema: [app_js_path: :string, app_css_path: :string, no_layout: :boolean],
78-
defaults: [app_js_path: @default_app_js_path, app_css_path: @default_app_css_path, no_layout: false]
77+
defaults: [app_js_path: nil, app_css_path: @default_app_css_path, no_layout: false]
7978
}
8079
end
8180

@@ -133,15 +132,36 @@ if Code.ensure_loaded?(Igniter) do
133132
# Backpex hooks
134133

135134
defp install_backpex_hooks(igniter) do
136-
app_js_path = igniter.args.options[:app_js_path]
135+
app_js_path = igniter.args.options[:app_js_path] || detect_app_file_path(igniter)
137136

138137
with {:ok, content} <- IgniterJs.Helpers.read_and_validate_file(app_js_path),
139138
{:ok, _fun, content} <- Parser.insert_imports(content, @imports, :content),
140139
{:ok, _fun, content} <- Parser.extend_hook_object(content, @hooks, :content) do
141140
Igniter.create_new_file(igniter, app_js_path, content, on_exists: :overwrite)
142141
else
143-
{:error, _fun, error} -> Mix.raise("Failed to modify app.js: #{error}")
144-
{:error, error} -> Mix.raise("Could not read app.js: #{error}")
142+
{:error, _fun, error} -> Mix.raise("Failed to modify app file: #{error}")
143+
{:error, error} -> Mix.raise("Could not read app file: #{error}")
144+
end
145+
end
146+
147+
# Auto-detect app.js or app.ts file
148+
149+
defp detect_app_file_path(igniter) do
150+
js_path = Path.join(["assets", "js", "app.js"])
151+
ts_path = Path.join(["assets", "js", "app.ts"])
152+
153+
cond do
154+
Igniter.exists?(igniter, ts_path) ->
155+
Mix.shell().info("Detected TypeScript app file: #{ts_path}")
156+
ts_path
157+
158+
Igniter.exists?(igniter, js_path) ->
159+
Mix.shell().info("Detected JavaScript app file: #{js_path}")
160+
js_path
161+
162+
true ->
163+
Mix.shell().info("No app.js or app.ts found, defaulting to: #{js_path}")
164+
js_path
145165
end
146166
end
147167

0 commit comments

Comments
 (0)