obsidian-plugin-config 1.6.18 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +9 -14
- package/.prettierrc +3 -12
- package/bin/obsidian-inject.js +1 -1
- package/docs/INTERACTIVE_INJECTION.md +4 -4
- package/docs/LLM-GUIDE.md +12 -2
- package/eslint.config.mts +63 -64
- package/package.json +3 -3
- package/scripts/acp.ts +52 -56
- package/scripts/build-npm.ts +161 -157
- package/scripts/inject-core.ts +835 -823
- package/scripts/inject-path.ts +150 -160
- package/scripts/inject-prompt.ts +89 -91
- package/scripts/update-version-config.ts +121 -89
- package/scripts/utils.ts +112 -112
- package/templates/.editorconfig +11 -14
- package/templates/.prettierrc +3 -12
- package/templates/env.template +12 -9
- package/templates/eslint.config.mts +1 -1
- package/templates/package.json +2 -3
- package/templates/scripts/acp.ts +50 -74
- package/templates/scripts/constants.ts +26 -0
- package/templates/scripts/env.ts +94 -0
- package/templates/scripts/esbuild.config.ts +134 -287
- package/templates/scripts/release.ts +92 -87
- package/templates/scripts/reload.ts +46 -0
- package/templates/scripts/typingsPlugin.ts +26 -0
- package/templates/scripts/update-version.ts +120 -123
- package/templates/scripts/utils.ts +234 -134
- package/templates/tsconfig.json +2 -2
- package/tsconfig.json +1 -1
package/.editorconfig
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
# top-most EditorConfig file
|
|
2
|
-
root = true
|
|
3
|
-
|
|
4
|
-
[*]
|
|
5
|
-
charset = utf-8
|
|
6
|
-
end_of_line = lf
|
|
7
|
-
insert_final_newline = true
|
|
8
|
-
indent_style =
|
|
9
|
-
indent_size =
|
|
10
|
-
tab_width = 4
|
|
11
|
-
|
|
12
|
-
[*.json]
|
|
13
|
-
indent_style = space
|
|
14
|
-
indent_size = 2
|
|
1
|
+
# top-most EditorConfig file
|
|
2
|
+
root = true
|
|
3
|
+
|
|
4
|
+
[*]
|
|
5
|
+
charset = utf-8
|
|
6
|
+
end_of_line = lf
|
|
7
|
+
insert_final_newline = true
|
|
8
|
+
indent_style = space
|
|
9
|
+
indent_size = 2
|
package/.prettierrc
CHANGED
|
@@ -1,19 +1,10 @@
|
|
|
1
1
|
{
|
|
2
|
-
"useTabs":
|
|
3
|
-
"tabWidth":
|
|
2
|
+
"useTabs": false,
|
|
3
|
+
"tabWidth": 2,
|
|
4
4
|
"printWidth": 90,
|
|
5
5
|
"endOfLine": "lf",
|
|
6
6
|
"trailingComma": "none",
|
|
7
7
|
"semi": true,
|
|
8
8
|
"singleQuote": true,
|
|
9
|
-
"arrowParens": "always"
|
|
10
|
-
"overrides": [
|
|
11
|
-
{
|
|
12
|
-
"files": ["*.json"],
|
|
13
|
-
"options": {
|
|
14
|
-
"useTabs": false,
|
|
15
|
-
"tabWidth": 2
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
]
|
|
9
|
+
"arrowParens": "always"
|
|
19
10
|
}
|
package/bin/obsidian-inject.js
CHANGED
|
@@ -105,11 +105,11 @@ Inject .env (template)? [Y/n]: y
|
|
|
105
105
|
Proceed with these options? [Y/n]: y
|
|
106
106
|
```
|
|
107
107
|
|
|
108
|
-
## Fichiers
|
|
108
|
+
## Fichiers Concernés
|
|
109
109
|
|
|
110
|
-
1. **scripts/inject-
|
|
111
|
-
2. **scripts/inject-
|
|
112
|
-
3. **scripts/inject-path.ts** -
|
|
110
|
+
1. **scripts/inject-core.ts** - Logique d'injection principale (options support)
|
|
111
|
+
2. **scripts/inject-prompt.ts** - Entrée interactive
|
|
112
|
+
3. **scripts/inject-path.ts** - Entrée CLI avec flags `--interactive` et `--preset`
|
|
113
113
|
|
|
114
114
|
## Cas d'Usage
|
|
115
115
|
|
package/docs/LLM-GUIDE.md
CHANGED
|
@@ -66,11 +66,18 @@ Creates `.injection-info.json` in target with version and date.
|
|
|
66
66
|
|
|
67
67
|
Scripts in `templates/scripts/` that get copied to target plugins:
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
**Build system (modular):**
|
|
70
|
+
- `esbuild.config.ts` — build entry point, orchestrates all build modules
|
|
71
|
+
- `constants.ts` — shared constants (external deps list, banner, REST port)
|
|
72
|
+
- `env.ts` — environment validation, manifest check, build path resolution
|
|
73
|
+
- `reload.ts` — Obsidian hot-reload via Local REST API
|
|
74
|
+
- `typingsPlugin.ts` — esbuild plugin for obsidian-typings resolution
|
|
75
|
+
- `utils.ts` — shared utilities (readline, file ops, git, vault path helpers)
|
|
76
|
+
|
|
77
|
+
**Workflow scripts:**
|
|
70
78
|
- `acp.ts` — add, commit, push workflow
|
|
71
79
|
- `update-version.ts` — version bump utility
|
|
72
80
|
- `release.ts` — GitHub release automation
|
|
73
|
-
- `utils.ts` — shared utilities
|
|
74
81
|
- `help.ts` — help documentation
|
|
75
82
|
|
|
76
83
|
---
|
|
@@ -83,6 +90,8 @@ When `--sass` flag is used:
|
|
|
83
90
|
2. Adds `esbuild-sass-plugin` dependency
|
|
84
91
|
3. The injected `esbuild.config.ts` automatically detects `.scss` files and uses the plugin
|
|
85
92
|
|
|
93
|
+
Without `--sass`, the build still works — the SASS import in `esbuild.config.ts` is conditional and only activates if `.scss` files exist.
|
|
94
|
+
|
|
86
95
|
---
|
|
87
96
|
|
|
88
97
|
## What NOT to do
|
|
@@ -90,6 +99,7 @@ When `--sass` flag is used:
|
|
|
90
99
|
- ❌ Do not hardcode deps/scripts in `inject-core.ts` — they must come from `templates/package.json`
|
|
91
100
|
- ❌ Do not modify root config files thinking it will affect injected plugins — always modify `templates/`
|
|
92
101
|
- ❌ Do not add `obsidian-plugin-config` as a dependency in `templates/package.json` — injected plugins are standalone
|
|
102
|
+
- ❌ Do not inject `esbuild.config.ts` without its dependencies (`constants.ts`, `env.ts`, `reload.ts`, `typingsPlugin.ts`, `utils.ts`) — they are all required
|
|
93
103
|
|
|
94
104
|
---
|
|
95
105
|
|
package/eslint.config.mts
CHANGED
|
@@ -1,64 +1,63 @@
|
|
|
1
|
-
import * as typescriptEslintParser from "@typescript-eslint/parser";
|
|
2
|
-
import typescriptEslintPlugin from "@typescript-eslint/eslint-plugin";
|
|
3
|
-
import "eslint-import-resolver-typescript";
|
|
4
|
-
import type {
|
|
5
|
-
Linter
|
|
6
|
-
} from "eslint";
|
|
7
|
-
|
|
8
|
-
const configs: Linter.Config[] = [
|
|
9
|
-
{
|
|
10
|
-
ignores: [
|
|
11
|
-
"eslint.config.mts"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"no-unused-vars": "
|
|
36
|
-
"@typescript-eslint/
|
|
37
|
-
"
|
|
38
|
-
"no-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"@typescript-eslint/explicit-
|
|
46
|
-
"@typescript-eslint/
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
"@typescript-eslint/no-unsafe-
|
|
51
|
-
"@typescript-eslint/no-unsafe-
|
|
52
|
-
"@typescript-eslint/no-unsafe-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
export default configs;
|
|
1
|
+
import * as typescriptEslintParser from "@typescript-eslint/parser";
|
|
2
|
+
import typescriptEslintPlugin from "@typescript-eslint/eslint-plugin";
|
|
3
|
+
import "eslint-import-resolver-typescript";
|
|
4
|
+
import type {
|
|
5
|
+
Linter
|
|
6
|
+
} from "eslint";
|
|
7
|
+
|
|
8
|
+
const configs: Linter.Config[] = [
|
|
9
|
+
{
|
|
10
|
+
ignores: [
|
|
11
|
+
"eslint.config.mts"
|
|
12
|
+
]
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
files: ["**/*.ts"],
|
|
16
|
+
ignores: [
|
|
17
|
+
"dist/**",
|
|
18
|
+
"node_modules/**",
|
|
19
|
+
"main.js"
|
|
20
|
+
],
|
|
21
|
+
languageOptions: {
|
|
22
|
+
parser: typescriptEslintParser,
|
|
23
|
+
sourceType: "module",
|
|
24
|
+
parserOptions: {
|
|
25
|
+
project: "./tsconfig.json",
|
|
26
|
+
ecmaVersion: 2023
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
plugins: {
|
|
30
|
+
"@typescript-eslint": typescriptEslintPlugin as any // Type assertion to bypass type checking
|
|
31
|
+
},
|
|
32
|
+
rules: {
|
|
33
|
+
// Base rules
|
|
34
|
+
"no-unused-vars": "off",
|
|
35
|
+
"@typescript-eslint/no-unused-vars": ["error", { "args": "none", "varsIgnorePattern": "^_" }],
|
|
36
|
+
"@typescript-eslint/ban-ts-comment": "warn",
|
|
37
|
+
"no-prototype-builtins": "off",
|
|
38
|
+
"@typescript-eslint/no-empty-function": "off",
|
|
39
|
+
|
|
40
|
+
// Useful rules but not too strict
|
|
41
|
+
"semi": "error",
|
|
42
|
+
"eqeqeq": ["error", "always"],
|
|
43
|
+
"prefer-const": "error",
|
|
44
|
+
"@typescript-eslint/explicit-function-return-type": ["warn", { "allowExpressions": true }],
|
|
45
|
+
"@typescript-eslint/no-explicit-any": "warn",
|
|
46
|
+
"@typescript-eslint/consistent-type-imports": ["warn", { "prefer": "type-imports" }],
|
|
47
|
+
|
|
48
|
+
// Disable overly strict rules
|
|
49
|
+
"@typescript-eslint/no-unsafe-assignment": "off",
|
|
50
|
+
"@typescript-eslint/no-unsafe-call": "off",
|
|
51
|
+
"@typescript-eslint/no-unsafe-member-access": "off",
|
|
52
|
+
"@typescript-eslint/no-unsafe-argument": "off"
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
files: ["src/**/*.ts"],
|
|
57
|
+
rules: {
|
|
58
|
+
"no-console": ["warn", { "allow": ["warn", "error", "debug"] }]
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
];
|
|
62
|
+
|
|
63
|
+
export default configs;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "obsidian-plugin-config",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "Global CLI injection tool for Obsidian plugins",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -20,6 +20,8 @@
|
|
|
20
20
|
"v": "tsx scripts/update-version-config.ts",
|
|
21
21
|
"lint": "eslint . --ext .ts",
|
|
22
22
|
"lint:fix": "eslint . --ext .ts --fix",
|
|
23
|
+
"prettier": "prettier --check '**/*.{ts,json}'",
|
|
24
|
+
"prettier:fix": "prettier --write '**/*.{ts,json}'",
|
|
23
25
|
"inject-path": "tsx scripts/inject-path.ts",
|
|
24
26
|
"inject-sass": "tsx scripts/inject-path.ts --sass",
|
|
25
27
|
"inject-prompt": "tsx scripts/inject-prompt.ts",
|
|
@@ -31,7 +33,6 @@
|
|
|
31
33
|
"devDependencies": {
|
|
32
34
|
"@types/eslint": "latest",
|
|
33
35
|
"@types/node": "^22.15.26",
|
|
34
|
-
"@types/semver": "^7.7.0",
|
|
35
36
|
"@typescript-eslint/eslint-plugin": "^8.58.0",
|
|
36
37
|
"@typescript-eslint/parser": "^8.58.0",
|
|
37
38
|
"dedent": "^1.6.0",
|
|
@@ -39,7 +40,6 @@
|
|
|
39
40
|
"eslint-import-resolver-typescript": "latest",
|
|
40
41
|
"jiti": "latest",
|
|
41
42
|
"prettier": "^3.4.0",
|
|
42
|
-
"semver": "^7.7.2",
|
|
43
43
|
"tsx": "^4.21.0",
|
|
44
44
|
"typescript": "^5.8.2"
|
|
45
45
|
},
|
package/scripts/acp.ts
CHANGED
|
@@ -2,78 +2,74 @@ import { execSync } from 'child_process';
|
|
|
2
2
|
import fs from 'fs';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
askQuestion,
|
|
6
|
+
cleanInput,
|
|
7
|
+
createReadlineInterface,
|
|
8
|
+
gitExec,
|
|
9
|
+
ensureGitSync
|
|
10
10
|
} from './utils.js';
|
|
11
11
|
|
|
12
12
|
const rl = createReadlineInterface();
|
|
13
13
|
|
|
14
14
|
// Check if we're in the centralized config repo
|
|
15
15
|
function isInCentralizedRepo(): boolean {
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
const packageJsonPath = path.join(process.cwd(), 'package.json');
|
|
17
|
+
if (!fs.existsSync(packageJsonPath)) return false;
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
20
|
+
return packageJson.name === 'obsidian-plugin-config';
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
async function main(): Promise<void> {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
24
|
+
try {
|
|
25
|
+
if (process.argv.includes('-b')) {
|
|
26
|
+
console.log('Building...');
|
|
27
|
+
// For obsidian-plugin-config, just run TypeScript check
|
|
28
|
+
if (isInCentralizedRepo()) {
|
|
29
|
+
gitExec('npx tsc --noEmit');
|
|
30
|
+
} else {
|
|
31
|
+
gitExec('yarn build');
|
|
32
|
+
}
|
|
33
|
+
console.log('Build successful.');
|
|
34
|
+
}
|
|
35
35
|
|
|
36
|
+
const input: string = await askQuestion('Enter commit message: ', rl);
|
|
36
37
|
|
|
38
|
+
const cleanedInput = cleanInput(input);
|
|
37
39
|
|
|
38
|
-
|
|
40
|
+
try {
|
|
41
|
+
gitExec('git add -A');
|
|
42
|
+
gitExec(`git commit -m "${cleanedInput}"`);
|
|
43
|
+
} catch {
|
|
44
|
+
console.log('Commit already exists or failed.');
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
39
47
|
|
|
40
|
-
|
|
48
|
+
// get current branch name
|
|
49
|
+
const currentBranch = execSync('git rev-parse --abbrev-ref HEAD').toString().trim();
|
|
41
50
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
gitExec(`git commit -m "${cleanedInput}"`);
|
|
45
|
-
} catch {
|
|
46
|
-
console.log('Commit already exists or failed.');
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
51
|
+
// Ensure Git is synchronized before pushing
|
|
52
|
+
await ensureGitSync();
|
|
49
53
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
gitExec(`git push --set-upstream origin ${currentBranch}`);
|
|
65
|
-
console.log('Upstream branch set and push successful.');
|
|
66
|
-
}
|
|
67
|
-
} catch (error) {
|
|
68
|
-
console.error('Error:', error instanceof Error ? error.message : String(error));
|
|
69
|
-
} finally {
|
|
70
|
-
rl.close();
|
|
71
|
-
}
|
|
54
|
+
try {
|
|
55
|
+
gitExec(`git push origin ${currentBranch}`);
|
|
56
|
+
console.log(`Commit and push successful to origin/${currentBranch}`);
|
|
57
|
+
} catch {
|
|
58
|
+
// new branch
|
|
59
|
+
console.log(`New branch detected. Setting upstream for ${currentBranch}...`);
|
|
60
|
+
gitExec(`git push --set-upstream origin ${currentBranch}`);
|
|
61
|
+
console.log('Upstream branch set and push successful.');
|
|
62
|
+
}
|
|
63
|
+
} catch (error) {
|
|
64
|
+
console.error('Error:', error instanceof Error ? error.message : String(error));
|
|
65
|
+
} finally {
|
|
66
|
+
rl.close();
|
|
67
|
+
}
|
|
72
68
|
}
|
|
73
69
|
|
|
74
70
|
main()
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
71
|
+
.catch(console.error)
|
|
72
|
+
.finally(() => {
|
|
73
|
+
console.log('Exiting...');
|
|
74
|
+
process.exit();
|
|
75
|
+
});
|