chore: fromat project

This commit is contained in:
antoKeinanen 2023-10-04 15:53:12 +03:00
parent df3599b60f
commit 6fdd93316d
8 changed files with 144 additions and 132 deletions

View file

@ -2,9 +2,7 @@
"root": true,
"parser": "@typescript-eslint/parser",
"env": { "node": true },
"plugins": [
"@typescript-eslint"
],
"plugins": ["@typescript-eslint"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",

View file

@ -1,10 +1,9 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
title: ""
labels: ""
assignees: antoKeinanen
---
**Describe the bug**
@ -12,6 +11,7 @@ A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
@ -24,9 +24,10 @@ A clear and concise description of what you expected to happen.
If applicable, add screenshots to help explain your problem.
**System information:**
- OS: [e.g. iOS8.1, linux]
- Obsidian version [e.g. 1.1.16] *(can be found at about page in settings)*
- Plugin version [e.g. 1.0.0] *(can be found at community plugins page in settings)*
- Obsidian version [e.g. 1.1.16] _(can be found at about page in settings)_
- Plugin version [e.g. 1.0.0] _(can be found at community plugins page in settings)_
**Additional context**
Add any other context about the problem here.

View file

@ -1,10 +1,9 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''
title: ""
labels: ""
assignees: ""
---
**Is your feature request related to a problem? Please describe.**

2
.gitignore vendored
View file

@ -23,3 +23,5 @@ data.json
# Exclude macOS Finder (System Explorer) View States
.DS_Store
bun.lockb

View file

@ -1,4 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
npx pretty-quick --staged
npx prettier . --write

124
main.ts
View file

@ -35,16 +35,19 @@ const TRANSLATIONS: { [name: string]: Translation } = {
OverwriteFileQuestion: "Vorhandene Datei überschreiben",
Settings: "Einstellungen",
SettingIncludeNestedFolders: "Verschachtelte Ordner einbeziehen",
SettingIncludeNestedFoldersDescription: "Wenn aktiviert, werden Dateien in verschachtelten Ordnern zusammengeführt. Andernfalls werden nur Dateien im ausgewählten Ordner zusammengeführt (Standardverhalten).",
SettingIncludeNestedFoldersDescription:
"Wenn aktiviert, werden Dateien in verschachtelten Ordnern zusammengeführt. Andernfalls werden nur Dateien im ausgewählten Ordner zusammengeführt (Standardverhalten).",
SettingIncludeFoldersAsSections: "Ordner als Abschnitte einbeziehen",
SettingIncludeFoldersAsSectionsDescription: "Ordner werden als benannte Abschnitte in die Ausgabedatei eingefügt.",
SettingIncludeFoldersAsSectionsDescription:
"Ordner werden als benannte Abschnitte in die Ausgabedatei eingefügt.",
Yes: "Ja",
No: "Nein",
SettingSortMode: "Sortiermodus",
SettingSortModeDescription: "Wählen Sie den Sortiermodus für das Zusammenführen von Notizen.",
SettingSortModeDescription:
"Wählen Sie den Sortiermodus für das Zusammenführen von Notizen.",
SettingSortDateCreated: "Erstellungsdatum",
SettingSortLogical: "Logisch",
SettingSortAlphabetically: "Alphabetisch"
SettingSortAlphabetically: "Alphabetisch",
},
en: {
MergeFolder: "Merge folder",
@ -52,16 +55,18 @@ const TRANSLATIONS: { [name: string]: Translation } = {
OverwriteFileQuestion: "Overwite exising file",
Settings: "Settings",
SettingIncludeNestedFolders: "Include nested folders",
SettingIncludeNestedFoldersDescription: "If enabled, files in nested folders will be included in merge. Otherwise, only files in selected folder will be merged (default behaviour).",
SettingIncludeNestedFoldersDescription:
"If enabled, files in nested folders will be included in merge. Otherwise, only files in selected folder will be merged (default behaviour).",
SettingIncludeFoldersAsSections: "Include folders as sections",
SettingIncludeFoldersAsSectionsDescription: "Folders will be included as named sections into output file.",
SettingIncludeFoldersAsSectionsDescription:
"Folders will be included as named sections into output file.",
Yes: "Yes",
No: "No",
SettingSortMode: "Sort mode",
SettingSortModeDescription: "Pick the sorting mode for merging notes.",
SettingSortDateCreated: "Date created",
SettingSortLogical: "Logical",
SettingSortAlphabetically: "Alphabetical"
SettingSortAlphabetically: "Alphabetical",
},
fi: {
MergeFolder: "Yhdistä kansio",
@ -69,16 +74,19 @@ const TRANSLATIONS: { [name: string]: Translation } = {
OverwriteFileQuestion: "Korvaa olemassa oleva tiedosto",
Settings: "Asetukset",
SettingIncludeNestedFolders: "Sisällytä sisäkkäiset kansiot",
SettingIncludeNestedFoldersDescription: "Jos käytössä, sisäkkäisten kansioiden tiedostot yhdistetään. Muussa tapauksessa vain valitun kansion tiedostot yhdistetään (oletustoiminto).",
SettingIncludeNestedFoldersDescription:
"Jos käytössä, sisäkkäisten kansioiden tiedostot yhdistetään. Muussa tapauksessa vain valitun kansion tiedostot yhdistetään (oletustoiminto).",
SettingIncludeFoldersAsSections: "Sisällytä kansiot osioihin",
SettingIncludeFoldersAsSectionsDescription: "Kansiot sisällytetään nimettyinä osina tulostiedostoon.",
SettingIncludeFoldersAsSectionsDescription:
"Kansiot sisällytetään nimettyinä osina tulostiedostoon.",
Yes: "Kyllä",
No: "Ei",
SettingSortMode: "Lajittelu järjestys",
SettingSortModeDescription: "Valitse lajittelutapa muistiinpanojen yhdistämistä varten.",
SettingSortModeDescription:
"Valitse lajittelutapa muistiinpanojen yhdistämistä varten.",
SettingSortDateCreated: "Luontipäivämäärä",
SettingSortLogical: "Looginen",
SettingSortAlphabetically: "Aakkosjärjestys"
SettingSortAlphabetically: "Aakkosjärjestys",
},
fr: {
MergeFolder: "Fusionner le dossier",
@ -86,16 +94,20 @@ const TRANSLATIONS: { [name: string]: Translation } = {
OverwriteFileQuestion: "Remplacer le fichier existant",
Settings: "Paramètres",
SettingIncludeNestedFolders: "Inclure les dossiers imbriqués",
SettingIncludeNestedFoldersDescription: "Si activé, les fichiers des dossiers imbriqués seront inclus dans la fusion. Sinon, seuls les fichiers du dossier sélectionné seront fusionnés (comportement par défaut).",
SettingIncludeFoldersAsSections: "Inclure les dossiers en tant que sections",
SettingIncludeFoldersAsSectionsDescription: "Les dossiers seront inclus en tant que sections nommées dans le fichier de sortie.",
SettingIncludeNestedFoldersDescription:
"Si activé, les fichiers des dossiers imbriqués seront inclus dans la fusion. Sinon, seuls les fichiers du dossier sélectionné seront fusionnés (comportement par défaut).",
SettingIncludeFoldersAsSections:
"Inclure les dossiers en tant que sections",
SettingIncludeFoldersAsSectionsDescription:
"Les dossiers seront inclus en tant que sections nommées dans le fichier de sortie.",
Yes: "Oui",
No: "Non",
SettingSortMode: "mode de tri",
SettingSortModeDescription: "Choisissez le mode de tri pour la fusion des notes.",
SettingSortModeDescription:
"Choisissez le mode de tri pour la fusion des notes.",
SettingSortDateCreated: "Date de création",
SettingSortLogical: "Logique",
SettingSortAlphabetically: "Alphabétique"
SettingSortAlphabetically: "Alphabétique",
},
ru: {
MergeFolder: "Объединить папку",
@ -103,16 +115,19 @@ const TRANSLATIONS: { [name: string]: Translation } = {
OverwriteFileQuestion: "Перезаписать существующий файл",
Settings: "Настройки",
SettingIncludeNestedFolders: "Влючать вложенные папки",
SettingIncludeNestedFoldersDescription: "Если включено, файлы во вложенных папках будут включены в слияние. В противном случае будут объединены только файлы в выбранной папке (поведение по умолчанию).",
SettingIncludeNestedFoldersDescription:
"Если включено, файлы во вложенных папках будут включены в слияние. В противном случае будут объединены только файлы в выбранной папке (поведение по умолчанию).",
SettingIncludeFoldersAsSections: "Включать папки как разделы",
SettingIncludeFoldersAsSectionsDescription: "Папки будут включены в выходной файл в качестве разделов.",
SettingIncludeFoldersAsSectionsDescription:
"Папки будут включены в выходной файл в качестве разделов.",
Yes: "Да",
No: "Нет",
SettingSortMode: "режим сортировки",
SettingSortModeDescription: "Выберите режим сортировки при объединении заметок.",
SettingSortModeDescription:
"Выберите режим сортировки при объединении заметок.",
SettingSortDateCreated: "Дата создания",
SettingSortLogical: "Логический",
SettingSortAlphabetically: "Алфавитный указатель"
SettingSortAlphabetically: "Алфавитный указатель",
},
ua: {
MergeFolder: "Об'єднати папку",
@ -120,16 +135,19 @@ const TRANSLATIONS: { [name: string]: Translation } = {
OverwriteFileQuestion: "Перезаписати існуючий файл",
Settings: "Налаштування",
SettingIncludeNestedFolders: "Включити вкладені папки",
SettingIncludeNestedFoldersDescription: "Якщо ввімкнено, файли у вкладених папках будуть включені в об’єднання. В іншому випадку буде об’єднано лише файли у вибраній папці (поведінка за замовчуванням).",
SettingIncludeNestedFoldersDescription:
"Якщо ввімкнено, файли у вкладених папках будуть включені в об’єднання. В іншому випадку буде об’єднано лише файли у вибраній папці (поведінка за замовчуванням).",
SettingIncludeFoldersAsSections: "Включити папки як розділи",
SettingIncludeFoldersAsSectionsDescription: "Папки будуть включені як іменовані розділи у вихідний файл.",
SettingIncludeFoldersAsSectionsDescription:
"Папки будуть включені як іменовані розділи у вихідний файл.",
Yes: "Так",
No: "Ні",
SettingSortMode: "Логический",
SettingSortModeDescription: "Виберіть режим сортування для об'єднання нотаток.",
SettingSortModeDescription:
"Виберіть режим сортування для об'єднання нотаток.",
SettingSortDateCreated: "Дата створення",
SettingSortLogical: "Логічний",
SettingSortAlphabetically: "За алфавітом"
SettingSortAlphabetically: "За алфавітом",
},
};
@ -216,10 +234,10 @@ export default class AdvancedMerge extends Plugin {
.setIcon(ICON_NAME)
.onClick(
async (evt) =>
await this.onClickCallback(folder, evt)
await this.onClickCallback(folder, evt),
);
});
})
}),
);
// This adds a settings tab so the user can configure various aspects of the plugin
@ -228,7 +246,7 @@ export default class AdvancedMerge extends Plugin {
private async onClickCallback(
folder: TFolder,
_evt: MouseEvent | KeyboardEvent
_evt: MouseEvent | KeyboardEvent,
): Promise<void> {
const { vault } = this.app;
@ -251,7 +269,7 @@ export default class AdvancedMerge extends Plugin {
});
const entries = this.sortNotes(
documentEntries.filter((entry) => this.filterNotes(folder, entry))
documentEntries.filter((entry) => this.filterNotes(folder, entry)),
);
const outputFileName = `${folder.path}-${
@ -266,18 +284,18 @@ export default class AdvancedMerge extends Plugin {
async (deleteFile) => {
if (!deleteFile) {
console.info(
`file "${outputFileName}" already exists, but user cancelled deleting..`
`file "${outputFileName}" already exists, but user cancelled deleting..`,
);
return;
}
console.info(
`file "${outputFileName}" already exists, deleting..`
`file "${outputFileName}" already exists, deleting..`,
);
await vault.adapter.remove(outputFileName);
await this.mergeNotes(vault, entries, outputFileName);
}
},
).open();
return;
}
@ -293,7 +311,7 @@ export default class AdvancedMerge extends Plugin {
private async mergeNotes(
vault: Vault,
entries: Array<TAbstractFile>,
outputFileName: string
outputFileName: string,
): Promise<void> {
const outputFile = await vault.create(outputFileName, "");
@ -309,19 +327,19 @@ export default class AdvancedMerge extends Plugin {
const fileSectionName = folderOrFile.name.replace(/\.md$/, "");
// For the first file in a row, we shouldnt add new line
sectionContents = `${SECTION_CHAR.repeat(
sectionLevel
sectionLevel,
)} ${fileSectionName}${DOUBLE_NEW_LINE_CHAR}${sectionContents}${
lastEntry ? "" : DOUBLE_NEW_LINE_CHAR
}`;
console.info(
`Adding file "${folderOrFile.name}" as section "${fileSectionName}" into file "${outputFileName}"..`
`Adding file "${folderOrFile.name}" as section "${fileSectionName}" into file "${outputFileName}"..`,
);
} else if (folderOrFile instanceof TFolder) {
sectionContents += `${SECTION_CHAR.repeat(sectionLevel)} ${
folderOrFile.name
}${DOUBLE_NEW_LINE_CHAR}`;
console.info(
`Adding folder "${folderOrFile.name}" as section "${sectionContents}" into file "${outputFileName}"..`
`Adding folder "${folderOrFile.name}" as section "${sectionContents}" into file "${outputFileName}"..`,
);
}
vault.append(outputFile, sectionContents);
@ -353,7 +371,7 @@ export default class AdvancedMerge extends Plugin {
numeric: true,
sensitivity: "base",
usage: "sort",
})
}),
);
case SortOptions.CreationDate:
return files.sort((a, b) => a.stat.ctime - b.stat.ctime);
@ -370,7 +388,7 @@ export default class AdvancedMerge extends Plugin {
this.settings = Object.assign(
{},
DEFAULT_SETTINGS,
await this.loadData()
await this.loadData(),
);
}
@ -409,16 +427,16 @@ class AdvancedMergeSettingTab extends PluginSettingTab {
// Add "sort mode" dropdown in settings
new Setting(containerEl)
.setName(this.plugin.translation.get().SettingSortMode)
.setDesc(
this.plugin.translation.get()
.SettingSortModeDescription
)
.setDesc(this.plugin.translation.get().SettingSortModeDescription)
.addDropdown((dropdown) =>
dropdown.addOptions({
[SortOptions.Alphabetically]: this.plugin.translation.get().SettingSortAlphabetically,
[SortOptions.CreationDate]: this.plugin.translation.get().SettingSortDateCreated,
[SortOptions.Logical]: this.plugin.translation.get().SettingSortLogical,
})
[SortOptions.Alphabetically]:
this.plugin.translation.get().SettingSortAlphabetically,
[SortOptions.CreationDate]:
this.plugin.translation.get().SettingSortDateCreated,
[SortOptions.Logical]:
this.plugin.translation.get().SettingSortLogical,
}),
);
// Add "include nested folders" toggle in settings
@ -426,7 +444,7 @@ class AdvancedMergeSettingTab extends PluginSettingTab {
.setName(this.plugin.translation.get().SettingIncludeNestedFolders)
.setDesc(
this.plugin.translation.get()
.SettingIncludeNestedFoldersDescription
.SettingIncludeNestedFoldersDescription,
)
.addToggle((toggle) =>
toggle
@ -439,7 +457,7 @@ class AdvancedMergeSettingTab extends PluginSettingTab {
: this.plugin.settings.includeFoldersAsSections;
await this.plugin.saveSettings();
this.showIncludeFolderAsSectionSetting(containerEl);
})
}),
);
this.showIncludeFolderAsSectionSetting(containerEl);
@ -454,11 +472,11 @@ class AdvancedMergeSettingTab extends PluginSettingTab {
// Add "include folders as sections" toggle in settings
this.includeFolderAsSectionSetting = new Setting(containerEl)
.setName(
this.plugin.translation.get().SettingIncludeFoldersAsSections
this.plugin.translation.get().SettingIncludeFoldersAsSections,
)
.setDesc(
this.plugin.translation.get()
.SettingIncludeFoldersAsSectionsDescription
.SettingIncludeFoldersAsSectionsDescription,
)
.addToggle((toggle) =>
toggle
@ -466,7 +484,7 @@ class AdvancedMergeSettingTab extends PluginSettingTab {
.onChange(async (value) => {
this.plugin.settings.includeFoldersAsSections = value;
await this.plugin.saveSettings();
})
}),
);
}
}
@ -488,7 +506,7 @@ class AdvancedMergeOverwriteFileModal extends Modal {
app: App,
translation: AdvancedMergeTranslation,
existingFileName: string,
handler: (result: boolean) => void
handler: (result: boolean) => void,
) {
super(app);
this.tranlation = translation;
@ -516,7 +534,7 @@ class AdvancedMergeOverwriteFileModal extends Modal {
.onClick(() => {
this.close();
this.onSubmitHandler(false);
})
}),
)
.addButton((btn) =>
btn
@ -525,7 +543,7 @@ class AdvancedMergeOverwriteFileModal extends Modal {
.onClick(() => {
this.close();
this.onSubmitHandler(true);
})
}),
);
}

View file

@ -1,34 +1,11 @@
{
"name": "obsidian-advanced-merger",
"version": "1.4.0",
"description": "Merge a folder of notes for easier export. This plugin is designed for Obsidian (https://obsidian.md).",
"homepage": "https://github.com/antoKeinanen/obsidian-advanced-merger",
"contributors": [
{
"name": "Dmitry Besedin",
"email": "endarvaluk@gmail.com",
"url": "https://github.com/EndarValuk/"
}
],
"funding": [
{
"type": "individual",
"url": "https://www.buymeacoffee.com/antokeinanen"
}
],
"main": "main.js",
"scripts": {
"dev": "node esbuild.config.mjs",
"build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production",
"version": "node version-bump.mjs && git add manifest.json versions.json",
"prepare": "husky install"
},
"keywords": [],
"author": {
"name": "Anto Keinänen",
"url": "https://github.com/antoKeinanen/"
},
"license": "MIT",
"main": "main.js",
"devDependencies": {
"@types/node": "^16.11.6",
"@typescript-eslint/eslint-plugin": "5.29.0",
@ -37,8 +14,32 @@
"esbuild": "0.17.3",
"husky": "^8.0.0",
"obsidian": "latest",
"prettier": "^3.0.3",
"pretty-quick": "^3.1.3",
"tslib": "2.4.0",
"typescript": "4.7.4"
},
"contributors": [
{
"name": "Dmitry Besedin",
"email": "endarvaluk@gmail.com",
"url": "https://github.com/EndarValuk/"
}
],
"description": "Merge a folder of notes for easier export. This plugin is designed for Obsidian (https://obsidian.md).",
"funding": [
{
"type": "individual",
"url": "https://www.buymeacoffee.com/antokeinanen"
}
],
"homepage": "https://github.com/antoKeinanen/obsidian-advanced-merger",
"keywords": [],
"license": "MIT",
"scripts": {
"dev": "node esbuild.config.mjs",
"build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production",
"version": "node version-bump.mjs && git add manifest.json versions.json",
"prepare": "husky install"
}
}

View file

@ -11,14 +11,7 @@
"importHelpers": true,
"isolatedModules": true,
"strictNullChecks": true,
"lib": [
"DOM",
"ES5",
"ES6",
"ES7"
]
"lib": ["DOM", "ES5", "ES6", "ES7"]
},
"include": [
"**/*.ts"
]
"include": ["**/*.ts"]
}