Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

Commit

Permalink
Self hosted dprint plugins (#107)
Browse files Browse the repository at this point in the history
ref: #106
  • Loading branch information
kachick committed Sep 16, 2022
1 parent 7e68734 commit 2cacfd4
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 13 deletions.
4 changes: 2 additions & 2 deletions default.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"local>kachick/renovate-config-asdf//plugins/clojure.json5",
"local>kachick/renovate-config-asdf//plugins/crystal.json5",
"local>kachick/renovate-config-asdf//plugins/deno.json5",
"local>kachick/renovate-config-asdf//plugins/dprint.json5",
"local>kachick/renovate-config-asdf//plugins/elixir.json5",
"local>kachick/renovate-config-asdf//plugins/elm.json5",
"local>kachick/renovate-config-asdf//plugins/erlang.json5",
Expand All @@ -28,7 +29,6 @@
"local>kachick/renovate-config-asdf//plugins/shellcheck.json5",
"local>kachick/renovate-config-asdf//plugins/shfmt.json5",
"local>kachick/renovate-config-asdf//plugins/trivy.json5",
"local>kachick/renovate-config-asdf//plugins/zig.json5",
"github>kachick/renovate-config-dprint:asdf"
"local>kachick/renovate-config-asdf//plugins/zig.json5"
]
}
15 changes: 15 additions & 0 deletions plugins/dprint.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"description": "Bump dprint in .tool-versions",
// Imported from https://github.com/kachick/renovate-config-dprint/blob/d057d2fafba244d3533b353924e4b4375abfae43/asdf.json
"regexManagers": [
{
"fileMatch": ["\\.tool-versions$"],
"matchStrings": ["dprint (?<currentValue>.+?)\\n"],
// Plugin Fetcher Permalink: https://github.com/asdf-community/asdf-dprint/blob/28517e6ee649bad5c859d9ad09aebcd6bbbff2bf/bin/list-all#L11-L12
// DataSource URL: https://github.com/dprint/dprint/tags
"depNameTemplate": "dprint/dprint",
"datasourceTemplate": "github-releases"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"local>kachick/renovate-config-asdf//plugins/clojure.json5",
"local>kachick/renovate-config-asdf//plugins/crystal.json5",
"local>kachick/renovate-config-asdf//plugins/deno.json5",
"local>kachick/renovate-config-asdf//plugins/dprint.json5",
"local>kachick/renovate-config-asdf//plugins/elixir.json5",
"local>kachick/renovate-config-asdf//plugins/elm.json5",
"local>kachick/renovate-config-asdf//plugins/gauche.json5",
Expand All @@ -26,7 +27,6 @@
"local>kachick/renovate-config-asdf//plugins/shellcheck.json5",
"local>kachick/renovate-config-asdf//plugins/shfmt.json5",
"local>kachick/renovate-config-asdf//plugins/trivy.json5",
"local>kachick/renovate-config-asdf//plugins/zig.json5",
"github>kachick/renovate-config-dprint:asdf"
"local>kachick/renovate-config-asdf//plugins/zig.json5"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"local>kachick/renovate-config-asdf//plugins/bun.json5",
"local>kachick/renovate-config-asdf//plugins/clojure.json5",
"local>kachick/renovate-config-asdf//plugins/deno.json5",
"local>kachick/renovate-config-asdf//plugins/dprint.json5",
"local>kachick/renovate-config-asdf//plugins/elixir.json5",
"local>kachick/renovate-config-asdf//plugins/elm.json5",
"local>kachick/renovate-config-asdf//plugins/erlang.json5",
Expand All @@ -28,7 +29,6 @@
"local>kachick/renovate-config-asdf//plugins/shfmt.json5",
"local>kachick/renovate-config-asdf//plugins/trivy.json5",
"local>kachick/renovate-config-asdf//plugins/zig.json5",
"local>kachick/renovate-config-asdf//plugins/crystal.json5",
"github>kachick/renovate-config-dprint:asdf"
"local>kachick/renovate-config-asdf//plugins/crystal.json5"
]
}
4 changes: 2 additions & 2 deletions spec/linter_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ describe RenovateConfigAsdf::Linter do
end

it "returns false for missing entries" do
success, message = RenovateConfigAsdf::Linter.lint_default_json("spec/fixtures/default.json-invalid-missing")
success, message = RenovateConfigAsdf::Linter.lint_default_json("spec/fixtures/default-invalid-missing.json")
success.should eq(false)
message.should contain("Some plugins are not linked: [\"erlang\", \"nodejs\"]")
end

it "returns false for unsorted entries" do
success, message = RenovateConfigAsdf::Linter.lint_default_json("spec/fixtures/default.json-invalid-unsorted")
success, message = RenovateConfigAsdf::Linter.lint_default_json("spec/fixtures/default-invalid-unsorted.json")
success.should eq(false)
message.should contain("Examples are not sorted")
end
Expand Down
2 changes: 1 addition & 1 deletion src/renovate_cofig_asdf/linter.cr
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module RenovateConfigAsdf
json = Hash(String, String | Array(String)).from_json(File.read(path))
entries = json["extends"]
return {false, "Unexpected JSON schema"} unless entries.is_a?(Array(String))
plugins = entries.reject(&.includes?("dprint")).map(&.[%r<plugins/([^/]+)\.json5\z>, 1])
plugins = entries.map(&.[%r<plugins/([^/]+)\.json5\z>, 1])
lint_plugins_list(plugins)
end

Expand Down
16 changes: 12 additions & 4 deletions test/regex_test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,19 @@ test('extractVersionTemplate', (_t) => {
} else {
throw 'RE2 did not match to given string';
}
});
});
});

const filePattern = new RE2(json5['regexManagers'][0]['fileMatch'][0]);
assert.equal(true, !!filePattern.exec('.tool-versions'));
assert.equal(true, !!filePattern.exec('examples/.tool-versions'));
assert.equal(false, !!filePattern.exec('spec/fixtures/.tool-versions-invalid-duplicated'));
test('fileMatch', (_t) => {
fs.readdirSync('plugins').forEach(plugin => {
test(plugin, (_t) => {
const definition = fs.readFileSync(`plugins/${plugin}`, 'utf8');
const json5 = JSON5.parse(definition);
const pattern = new RE2(json5['regexManagers'][0]['fileMatch'][0]);
assert.equal(true, !!pattern.exec('.tool-versions'));
assert.equal(true, !!pattern.exec('examples/.tool-versions'));
assert.equal(false, !!pattern.exec('spec/fixtures/.tool-versions-invalid-duplicated'));
});
});
});

0 comments on commit 2cacfd4

Please sign in to comment.