Skip to content

Commit ebacbe7

Browse files
committed
refactoring and type fixing part 1 of 2
1 parent 421213a commit ebacbe7

74 files changed

Lines changed: 4247 additions & 1571 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.config/esbuild.config.mjs.old

Lines changed: 0 additions & 48 deletions
This file was deleted.

.config/rollup.config.mjs

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,30 @@
1+
import fs from "node:fs";
2+
import path from "node:path";
13
import typescript from "@rollup/plugin-typescript";
24
import { nodeResolve } from "@rollup/plugin-node-resolve";
35
import commonjs from "@rollup/plugin-commonjs";
46
import json from "@rollup/plugin-json";
57
import strip from '@rollup/plugin-strip';
68
import terser from "@rollup/plugin-terser";
9+
import replace from "@rollup/plugin-replace";
10+
import manifest from "../manifest.json" assert { type: "json" };
11+
12+
function readMarkdown(file) {
13+
return fs.readFileSync(path.resolve(file), "utf8");
14+
}
715

816
const isProd = ( process.env.BUILD === "production" );
917

18+
const namePatternDE = readMarkdown( "docs/namepattern.de.md" );
19+
const namePatternEN = readMarkdown( "docs/namepattern.en.md" );
20+
const templateDE = readMarkdown( "docs/template.de.md" );
21+
const templateEN = readMarkdown( "docs/template.en.md" );
22+
const typeDE = readMarkdown( "docs/type.de.md" );
23+
const typeEN = readMarkdown( "docs/type.en.md" );
24+
const ribbonsDE = readMarkdown( "docs/ribbons.de.md" );
25+
const ribbonsEN = readMarkdown( "docs/ribbons.en.md" );
26+
const readme = readMarkdown( "README.md" );
27+
1028
const banner =
1129
`/*
1230
* THIS IS A GENERATED/BUNDLED FILE BY ROLLUP
@@ -33,15 +51,36 @@ export default {
3351
"@codemirror/autocomplete"
3452
],
3553
plugins: [
36-
json(),
54+
json(), // required to import manifest.json
55+
replace({
56+
preventAssignment: true,
57+
values: {
58+
__PLUGIN_FALLBACK_LANGUAGE__: JSON.stringify("en"),
59+
__PLUGIN_NAME__: JSON.stringify(manifest.name),
60+
__PLUGIN_VERSION__: JSON.stringify(manifest.version),
61+
__PLUGIN_AUTHOR__: JSON.stringify(manifest.author),
62+
__PLUGIN_AUTHOR_URL__: JSON.stringify(manifest.authorUrl),
63+
__PLUGIN_REPOSITORY__: JSON.stringify(manifest.repository),
64+
__PLUGIN_DESCRIPTION__: JSON.stringify(manifest.description),
65+
__PLUGIN_README_MD__: JSON.stringify(readme),
66+
__PLUGIN_SETTINGS_NAMEPATTERN_CTXHLP_DE__: JSON.stringify(namePatternDE),
67+
__PLUGIN_SETTINGS_NAMEPATTERN_CTXHLP_EN__: JSON.stringify(namePatternEN),
68+
__PLUGIN_SETTINGS_TEMPLATE_CTXHLP_DE__: JSON.stringify(templateDE),
69+
__PLUGIN_SETTINGS_TEMPLATE_CTXHLP_EN__: JSON.stringify(templateEN),
70+
__PLUGIN_SETTINGS_TYPE_CTXHLP_DE__: JSON.stringify(typeDE),
71+
__PLUGIN_SETTINGS_TYPE_CTXHLP_EN__: JSON.stringify(typeEN),
72+
__PLUGIN_SETTINGS_RIBBONS_HELP_DE__: JSON.stringify(ribbonsDE),
73+
__PLUGIN_SETTINGS_RIBBONS_HELP_EN__: JSON.stringify(ribbonsEN)
74+
},
75+
}),
3776
typescript({tsconfig: ".config/tsconfig.build.json" }),
3877
nodeResolve({browser: true}),
3978
commonjs(),
4079
// Strip console and debugger statements first
4180
isProd && strip({
4281
include: '**/*.(js|ts)',
4382
exclude: 'src/lib/main.ts', // console.logging: "Plugin loaded" should be available!
44-
functions: ['console.*'],
83+
functions: [/*'console.*'*/],
4584
debugger: true
4685
}),
4786
// Remove all remaining comments

.config/tsconfig.build.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"extends": "./tsconfig.json",
33
"include": [
4-
"../src/lib/**/*.ts"
4+
"../src/lib/**/*.ts",
5+
"../src/lib/types/rollup-globals.d.ts"
56
],
67
"exclude": [
78
"../src/test/**"

.config/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
},
2323
"include": [
2424
"../src/lib/**/*.ts",
25+
"../src/lib/types/rollup-globals.d.ts",
2526
"../src/test/**/*.ts",
2627
"../src/test/00.initial/**/*.ts",
2728
"../src/test/*.*/**/*.ts"

.config/tsconfig.json.old

Lines changed: 0 additions & 28 deletions
This file was deleted.

.config/vitest.config.ts

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,36 @@
1-
import { defineConfig } from "vitest/config";
21
import path from "path";
2+
import { defineConfig } from "vitest/config";
3+
4+
const projectRoot = path.resolve(__dirname, "..");
35

46
export default defineConfig({
57
test: {
68
environment: "jsdom",
79
globals: true,
810

911
// Projektroot eine Ebene über .config
10-
root: path.resolve(__dirname, ".."),
12+
root: projectRoot,
13+
1114
sequence: {
1215
shuffle: false, // keine Zufallsreihenfolge
1316
concurrent: false, // Tests NICHT parallel, sondern nacheinander
1417
},
15-
16-
// nur Tests innerhalb von src/test/
17-
include: ["src/test/**/*.test.ts"],
18+
setupFiles: [ path.resolve(projectRoot, "src/test/__setup__/globals.ts") ],
19+
include: ["src/test/**/00.00.sequence.of.test.ts"],
20+
coverage: {
21+
provider: "istanbul",
22+
reporter: ["text", "lcov"],
23+
exclude: [
24+
"**/test/**",
25+
"**/*.test.ts",
26+
"**/*.spec.ts"
27+
]
28+
}
29+
},
30+
resolve: {
31+
alias: {
32+
obsidian: path.resolve(projectRoot, "src/test/__mocks__/obsidian.ts"),
33+
"ts-obsidian-log": path.resolve(projectRoot, "src/test/__mocks__/ts-obsidian-log.ts")
34+
},
1835
},
1936
});

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,25 @@ All notable changes to this project will be documented in this file.
1616

1717
- No fixes yet
1818

19+
## [1.4.0] - 2026-01-18
20+
21+
### Known Issues
22+
23+
- In some cases, the algorithm becomes inconsistent at the beginning
24+
of a month when generating calendar-week-dependent patterns.
25+
26+
### Changed
27+
28+
- Moved logging to `ts-obsidian-log`
29+
- Moved i18n to `ts-obsidian-i18n`
30+
- Moved settings handling to `ts-obsidian-plugin`
31+
- Moved tabular settings UI to `ts-obsidian-ui-settings`
32+
- `execute.default` now consistently uses `async`
33+
34+
### Added
35+
36+
- Added a full test suite for `execute.default`
37+
1938
## [1.3.0] - 2025-12-23
2039

2140
Reorganized and Refactored

README.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,15 @@ The structure is an array of `FolderStructure` objects:
9494
]
9595
```
9696

97+
> **Note on file extensions**
98+
>
99+
> File extensions are **not added implicitly**.
100+
> A file will only have an extension if it is explicitly included in the
101+
> `namepattern` (for example `{{YYYY}}-{{MM}}-{{DD}}.md`).
102+
>
103+
> In the example above, the generated file will be named `YYYY-MM-DD`
104+
> **without** a `.md` suffix unless the suffix is part of the pattern.
105+
97106
---
98107

99108
### Properties
@@ -105,14 +114,27 @@ Must be `"folder"` or `"file"`.
105114
A string containing characters and patterns.
106115
Patterns must follow `{{<pattern>}}`, where `<pattern>` is a valid [moment.js format](https://momentjs.com/docs/#/displaying/format/).
107116

117+
File name patterns are resolved verbatim.
118+
No file extension is added automatically.
119+
120+
If a generated file is expected to be a Markdown note, the `.md` suffix
121+
must be explicitly included in the `namepattern`
122+
(e.g. `{{YYYY}}-{{MM}}-{{DD}}.md`).
123+
108124
Do **not** combine patterns inline (e.g., `{{YYYY-MM-DD}}`).
109125
Use `{{YYYY}}-{{MM}}-{{DD}}` instead.
110126

111127
**`template`** {string} – *optional*
112128
Path to a markdown file used as a template.
113129

114130
* For `type: "file"`, the generated file’s content will match the template.
115-
* For `type: "folder"`, a markdown file with the folder name will be created inside the folder, containing the template content.
131+
* For `type: "folder"`, a folder note is created **only if a `template` is specified**.
132+
The folder note will be created inside the folder, containing the template content.
133+
In this case, the folder note is always a Markdown file (`.md`).
134+
135+
The file name is derived directly from the folder name;
136+
both the file name and the `.md` suffix are **implicit and not configurable**.
137+
116138
For best results, install a folder note plugin.
117139

118140
**`description`** {string} – *optional*

docs/namepattern.de.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
## Name Pattern
2+
3+
Das **Name Pattern** legt fest, wie der Name einer Datei oder eines Ordners erzeugt wird.
4+
Es besteht aus beliebigen Zeichen und **Patterns**, die in **doppelte geschweifte Klammern**
5+
eingeschlossen werden: `{{<pattern>}}`.
6+
7+
### Wichtig
8+
9+
- Patterns müssen gültige **moment.js**-Format-Tokens sein.
10+
- **Keine Inline-Kombinationen**:
11+
- ❌ Ungültig: `{{YYYY-MM-DD}}`
12+
- ✅ Gültig: `{{YYYY}}-{{MM}}-{{DD}}`
13+
14+
### Semantik von Dateinamen und Dateiendungen
15+
16+
- Name Patterns werden **wortgetreu** aufgelöst.
17+
- Es wird **keine Dateiendung automatisch ergänzt**.
18+
- Eine Datei erhält **nur dann** eine Dateiendung, wenn diese explizit im
19+
Name Pattern angegeben ist (z. B. `{{YYYY}}-{{MM}}-{{DD}}.md`).
20+
- Ist keine Dateiendung angegeben, wird die Datei **ohne Suffix** erzeugt.
21+
22+
> **Ausnahme: Folder Notes**
23+
> Eine Folder Note wird **nur dann erzeugt**, wenn für einen Ordner ein
24+
> **`template`** angegeben ist.
25+
> In diesem Fall ist die Folder Note **immer** eine Markdown-Datei (`.md`).
26+
> Sowohl der Dateiname als auch die `.md`-Endung sind dabei **implizit festgelegt
27+
> und nicht konfigurierbar**.
28+
29+
### Beispiele
30+
31+
- `Tägliche Notiz - {{YYYY}}-{{MM}}-{{DD}}`
32+
→ Erzeugt täglich eine Datei, z. B. `Tägliche Notiz - 2026-01-15`
33+
34+
- `Tägliche Notiz - {{YYYY}}-{{MM}}-{{DD}}.md`
35+
→ Erzeugt täglich eine Markdown-Datei, z. B. `Tägliche Notiz - 2026-01-15.md`
36+
37+
- `Projekt_{{YYYY}}-{{MM}}_Zusammenfassung`
38+
→ Erzeugt monatlich eine Datei, z. B. `Projekt_2026-01_Zusammenfassung`

docs/namepattern.en.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
## Name Pattern
2+
3+
The **name pattern** defines how the name of a file or folder is generated.
4+
It consists of arbitrary characters and **patterns** enclosed in **double curly braces**:
5+
`{{<pattern>}}`.
6+
7+
### Important
8+
9+
- Patterns must be valid **moment.js** format tokens.
10+
- **No inline combinations** are allowed:
11+
- ❌ Invalid: `{{YYYY-MM-DD}}`
12+
- ✅ Valid: `{{YYYY}}-{{MM}}-{{DD}}`
13+
14+
### File name and extension semantics
15+
16+
- Name patterns are resolved **verbatim**.
17+
- No file extension is added automatically.
18+
- A generated file will only have an extension if it is explicitly included
19+
in the name pattern (for example: `{{YYYY}}-{{MM}}-{{DD}}.md`).
20+
- If no extension is specified, the resulting file will be created **without**
21+
a suffix.
22+
23+
> Folder notes are an exception:
24+
> A folder note is created **only if a `template` is specified for a folder**.
25+
> In this case, the folder note is always a Markdown file (`.md`), and both the
26+
> file name and the `.md` suffix are implicit and not configurable.
27+
28+
### Examples
29+
30+
- `Daily Note - {{YYYY}}-{{MM}}-{{DD}}`
31+
→ Generates a file daily, for example: `Daily Note - 2026-01-15`
32+
33+
- `Daily Note - {{YYYY}}-{{MM}}-{{DD}}.md`
34+
→ Generates a Markdown file daily, for example: `Daily Note - 2026-01-15.md`
35+
36+
- `Project_{{YYYY}}-{{MM}}_Summary`
37+
→ Generates a file updated monthly, for example: `Project_2026-01_Summary`

0 commit comments

Comments
 (0)