mirror of
https://github.com/sharevb/it-tools.git
synced 2026-11-26 07:33:21 +03:00
feat(Git Attributes Generator): get all .gitattributes on subfolders + fallback in case of API Rate
Fix #244
This commit is contained in:
1 parent
be14d3a62b
commit
8e379e4611
1 file changed
+41
-9
@@ -2,7 +2,7 @@
|
|||||||
import { onMounted } from 'vue';
|
import { onMounted } from 'vue';
|
||||||
import { useLocalStorage } from '@vueuse/core';
|
import { useLocalStorage } from '@vueuse/core';
|
||||||
|
|
||||||
const options = useLocalStorage<{ label: string; value: string }[]>('gitattr-gen:opts', []);
|
const options = useLocalStorage<{ label: string; value: string }[]>('gitattr-gen:opts2', []);
|
||||||
const selected = ref<string[]>([]);
|
const selected = ref<string[]>([]);
|
||||||
const output = ref<string>('');
|
const output = ref<string>('');
|
||||||
|
|
||||||
@@ -19,17 +19,49 @@ async function loadOptions() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const res = await fetch('https://api.github.com/repos/alexkaratarakis/gitattributes/contents');
|
try {
|
||||||
const files = await res.json();
|
const res = await fetch('https://api.github.com/repos/alexkaratarakis/gitattributes/git/trees/master?recursive=true');
|
||||||
options.value = files
|
const files = await res.json();
|
||||||
.filter((f: any) => f.name.endsWith('.gitattributes'))
|
options.value = files.tree
|
||||||
.map((f: any) => f.name.replace('.gitattributes', ''))
|
.filter((f: any) => f.path.endsWith('.gitattributes'))
|
||||||
.filter(Boolean)
|
.map((f: any) => f.path.replace('.gitattributes', ''))
|
||||||
.map((name: string) => ({
|
.filter(Boolean)
|
||||||
|
.map((name: string) => ({
|
||||||
|
label: name,
|
||||||
|
value: name,
|
||||||
|
}));
|
||||||
|
lastFetched.value = now;
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
options.value = [
|
||||||
|
'ActionScript',
|
||||||
|
'Ada',
|
||||||
|
'Ballerina',
|
||||||
|
'C++',
|
||||||
|
'CSharp',
|
||||||
|
'Common',
|
||||||
|
'Delphi',
|
||||||
|
'Drupal',
|
||||||
|
'Fortran',
|
||||||
|
'Fountain',
|
||||||
|
'Go',
|
||||||
|
'Java',
|
||||||
|
'Lua',
|
||||||
|
'Matlab',
|
||||||
|
'ObjectiveC',
|
||||||
|
'Pascal',
|
||||||
|
'Perl',
|
||||||
|
'Python',
|
||||||
|
'R',
|
||||||
|
'Rails',
|
||||||
|
'Servoy',
|
||||||
|
'VisualStudio',
|
||||||
|
'Web',
|
||||||
|
].map(name => ({
|
||||||
label: name,
|
label: name,
|
||||||
value: name,
|
value: name,
|
||||||
}));
|
}));
|
||||||
lastFetched.value = now;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function generateOutput() {
|
async function generateOutput() {
|
||||||
|
|||||||
Reference in new issue
Block a user