obsidian-plugin-config 1.3.12 β 1.4.1
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/.prettierrc +10 -1
- package/.vscode/tasks.json +8 -0
- package/bin/obsidian-inject.js +1 -1
- package/eslint.config.mts +4 -0
- package/package.json +3 -2
- package/scripts/build-npm.ts +26 -34
- package/scripts/help.ts +12 -3
- package/scripts/sync-template-deps.ts +59 -0
- package/scripts/update-version-config.ts +1 -1
- package/scripts/utils.ts +11 -11
- package/src/main.ts +2 -1
- package/src/modals/GenericConfirmModal.ts +2 -1
- package/templates/.prettierrc +10 -1
- package/templates/eslint.config.mts +4 -0
- package/templates/package-sass.json +1 -1
- package/templates/package.json +9 -9
- package/versions.json +3 -1
package/.prettierrc
CHANGED
package/.vscode/tasks.json
CHANGED
|
@@ -90,6 +90,14 @@
|
|
|
90
90
|
"presentation": { "reveal": "always", "panel": "shared" },
|
|
91
91
|
"problemMatcher": []
|
|
92
92
|
},
|
|
93
|
+
{
|
|
94
|
+
"label": "Upgrade All (yarn upgrade + sync templates)",
|
|
95
|
+
"type": "shell",
|
|
96
|
+
"command": "yarn upgrade-all",
|
|
97
|
+
"group": "build",
|
|
98
|
+
"presentation": { "reveal": "always", "panel": "shared" },
|
|
99
|
+
"problemMatcher": []
|
|
100
|
+
},
|
|
93
101
|
{
|
|
94
102
|
"label": "NPM Publish",
|
|
95
103
|
"type": "shell",
|
package/bin/obsidian-inject.js
CHANGED
package/eslint.config.mts
CHANGED
|
@@ -40,7 +40,11 @@ const configs: Linter.Config[] = [
|
|
|
40
40
|
|
|
41
41
|
// Useful rules but not too strict
|
|
42
42
|
"semi": "error",
|
|
43
|
+
"eqeqeq": ["error", "always"],
|
|
44
|
+
"prefer-const": "error",
|
|
43
45
|
"@typescript-eslint/explicit-function-return-type": ["warn", { "allowExpressions": true }],
|
|
46
|
+
"@typescript-eslint/no-explicit-any": "warn",
|
|
47
|
+
"@typescript-eslint/consistent-type-imports": ["warn", { "prefer": "type-imports" }],
|
|
44
48
|
|
|
45
49
|
// Disable overly strict rules
|
|
46
50
|
"@typescript-eslint/no-unsafe-assignment": "off",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "obsidian-plugin-config",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"description": "Système d'injection pour plugins Obsidian autonomes",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.ts",
|
|
@@ -36,7 +36,8 @@
|
|
|
36
36
|
"inject-prompt": "tsx scripts/inject-prompt.ts",
|
|
37
37
|
"inject": "tsx scripts/inject-prompt.ts",
|
|
38
38
|
"check-plugin": "tsx scripts/inject-path.ts --dry-run",
|
|
39
|
-
"
|
|
39
|
+
"sync-template-deps": "tsx scripts/sync-template-deps.ts",
|
|
40
|
+
"upgrade-all": "yarn upgrade && tsx scripts/sync-template-deps.ts",
|
|
40
41
|
"npm-publish": "tsx scripts/build-npm.ts",
|
|
41
42
|
"help": "tsx scripts/help.ts",
|
|
42
43
|
"h": "tsx scripts/help.ts"
|
package/scripts/build-npm.ts
CHANGED
|
@@ -197,11 +197,9 @@ main();
|
|
|
197
197
|
/**
|
|
198
198
|
* Complete NPM workflow - Version, Commit, Push, Publish
|
|
199
199
|
*/
|
|
200
|
-
function buildAndPublishNpm(): void {
|
|
200
|
+
async function buildAndPublishNpm(): Promise<void> {
|
|
201
201
|
console.log(`π Obsidian Plugin Config - Complete NPM Workflow`);
|
|
202
|
-
console.log(
|
|
203
|
-
`Full automation: version β exports β bin β commit β publish\n`
|
|
204
|
-
);
|
|
202
|
+
console.log(`Full automation: version β exports β bin β commit β publish\n`);
|
|
205
203
|
|
|
206
204
|
try {
|
|
207
205
|
// Step 0: Check NPM login
|
|
@@ -216,58 +214,52 @@ function buildAndPublishNpm(): void {
|
|
|
216
214
|
process.exit(1);
|
|
217
215
|
}
|
|
218
216
|
|
|
219
|
-
// Step 1: Update version
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
execSync('tsx scripts/update-version-config.ts', {
|
|
223
|
-
stdio: 'inherit'
|
|
224
|
-
});
|
|
217
|
+
// Step 1: Update version
|
|
218
|
+
console.log(`π Step 1/7: Updating version...`);
|
|
219
|
+
execSync('tsx scripts/update-version-config.ts', { stdio: 'inherit' });
|
|
225
220
|
|
|
226
|
-
// Step 2: Update exports
|
|
221
|
+
// Step 2: Update exports
|
|
227
222
|
console.log(`\nπ¦ Step 2/7: Updating exports...`);
|
|
228
223
|
execSync('yarn update-exports', { stdio: 'inherit' });
|
|
229
224
|
|
|
230
|
-
// Step 3: Generate bin file
|
|
225
|
+
// Step 3: Generate bin file
|
|
231
226
|
console.log(`\nπ§ Step 3/7: Generating bin/obsidian-inject.js...`);
|
|
232
|
-
generateBinFile();
|
|
227
|
+
await generateBinFile();
|
|
233
228
|
|
|
234
229
|
// Step 4: Verify package and sync versions.json
|
|
235
|
-
// (must happen before commit so versions.json is included)
|
|
236
230
|
console.log(`\nπ Step 4/7: Verifying package...`);
|
|
237
231
|
verifyPackage();
|
|
238
232
|
|
|
239
|
-
// Step 5: Commit and push
|
|
240
|
-
// (package.json version, bin/, versions.json, exports)
|
|
233
|
+
// Step 5: Commit and push
|
|
241
234
|
console.log(`\nπ€ Step 5/7: Committing and pushing changes...`);
|
|
242
235
|
try {
|
|
243
|
-
execSync(
|
|
244
|
-
'echo "Publish NPM package" | tsx scripts/acp.ts -b',
|
|
245
|
-
{ stdio: 'inherit' }
|
|
246
|
-
);
|
|
236
|
+
execSync('echo "Publish NPM package" | tsx scripts/acp.ts -b', { stdio: 'inherit' });
|
|
247
237
|
} catch {
|
|
248
238
|
console.log(` βΉοΈ No additional changes to commit`);
|
|
249
239
|
}
|
|
250
240
|
|
|
251
241
|
// Step 6: Publish to NPM
|
|
252
242
|
console.log(`\nπ€ Step 6/7: Publishing to NPM...`);
|
|
253
|
-
execSync(
|
|
254
|
-
|
|
255
|
-
|
|
243
|
+
execSync('npm publish --registry https://registry.npmjs.org/', { stdio: 'inherit' });
|
|
244
|
+
|
|
245
|
+
// Step 7: Offer global update
|
|
246
|
+
console.log(`\nπ Step 7/7: Update global CLI?`);
|
|
247
|
+
const { askConfirmation, createReadlineInterface } = await import("./utils.js");
|
|
248
|
+
const rl = createReadlineInterface();
|
|
249
|
+
const doUpdate = await askConfirmation(
|
|
250
|
+
`Install npm install -g obsidian-plugin-config@latest?`, rl
|
|
256
251
|
);
|
|
252
|
+
rl.close();
|
|
253
|
+
if (doUpdate) {
|
|
254
|
+
execSync('npm install -g obsidian-plugin-config@latest', { stdio: 'inherit' });
|
|
255
|
+
console.log(` β
Global CLI updated`);
|
|
256
|
+
}
|
|
257
257
|
|
|
258
258
|
console.log(`\nπ Complete workflow successful!`);
|
|
259
|
-
console.log(
|
|
260
|
-
console.log(` 1. npm install -g obsidian-plugin-config`);
|
|
261
|
-
console.log(
|
|
262
|
-
` 2. Test injection: cd any-plugin && obsidian-inject`
|
|
263
|
-
);
|
|
259
|
+
console.log(` Test: cd any-plugin && obsidian-inject`);
|
|
264
260
|
|
|
265
261
|
} catch (error) {
|
|
266
|
-
console.error(
|
|
267
|
-
`\nβ Workflow failed: ${
|
|
268
|
-
error instanceof Error ? error.message : String(error)
|
|
269
|
-
}`
|
|
270
|
-
);
|
|
262
|
+
console.error(`\nβ Workflow failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
271
263
|
process.exit(1);
|
|
272
264
|
}
|
|
273
265
|
}
|
|
@@ -334,4 +326,4 @@ function verifyPackage(): void {
|
|
|
334
326
|
}
|
|
335
327
|
|
|
336
328
|
// Run the script
|
|
337
|
-
buildAndPublishNpm();
|
|
329
|
+
await buildAndPublishNpm();
|
package/scripts/help.ts
CHANGED
|
@@ -30,11 +30,20 @@ INJECTION (Development phase):
|
|
|
30
30
|
yarn check-plugin <path> # Verification only (dry-run)
|
|
31
31
|
|
|
32
32
|
NPM PUBLISHING (all-in-one - no acp needed before):
|
|
33
|
-
yarn npm-publish # Full workflow:
|
|
34
|
-
#
|
|
35
|
-
#
|
|
33
|
+
yarn npm-publish # Full workflow (7 steps):
|
|
34
|
+
# 0. NPM auth check
|
|
35
|
+
# 1. version bump
|
|
36
|
+
# 2. update exports
|
|
37
|
+
# 3. generate bin
|
|
38
|
+
# 4. verify package
|
|
39
|
+
# 5. commit + push
|
|
40
|
+
# 6. publish to NPM
|
|
41
|
+
# 7. offer global CLI update
|
|
36
42
|
yarn build-npm # Alias for npm-publish
|
|
37
43
|
|
|
44
|
+
UPGRADE:
|
|
45
|
+
yarn upgrade-all # yarn upgrade + sync template deps
|
|
46
|
+
|
|
38
47
|
HELP:
|
|
39
48
|
yarn help, h # This help
|
|
40
49
|
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
#!/usr/bin/env tsx
|
|
2
|
+
|
|
3
|
+
import fs from "fs";
|
|
4
|
+
import path from "path";
|
|
5
|
+
|
|
6
|
+
const TEMPLATES_PKG = "templates/package.json";
|
|
7
|
+
const TEMPLATES_SASS = "templates/package-sass.json";
|
|
8
|
+
|
|
9
|
+
function resolvedVersion(dep: string): string | null {
|
|
10
|
+
const pkgPath = path.join("node_modules", dep, "package.json");
|
|
11
|
+
if (!fs.existsSync(pkgPath)) return null;
|
|
12
|
+
try {
|
|
13
|
+
return JSON.parse(fs.readFileSync(pkgPath, "utf8")).version as string;
|
|
14
|
+
} catch {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function updateDeps(deps: Record<string, string>): { updated: string[] } {
|
|
20
|
+
const updated: string[] = [];
|
|
21
|
+
|
|
22
|
+
for (const dep of Object.keys(deps)) {
|
|
23
|
+
const current = deps[dep];
|
|
24
|
+
// Skip wildcards like "*"
|
|
25
|
+
if (current === "*") continue;
|
|
26
|
+
|
|
27
|
+
const resolved = resolvedVersion(dep);
|
|
28
|
+
if (!resolved) continue;
|
|
29
|
+
|
|
30
|
+
// Keep "latest" as-is, update pinned/range versions
|
|
31
|
+
if (current !== "latest") {
|
|
32
|
+
const newVersion = `^${resolved}`;
|
|
33
|
+
if (deps[dep] !== newVersion) {
|
|
34
|
+
deps[dep] = newVersion;
|
|
35
|
+
updated.push(`${dep}: ${current} β ${newVersion}`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return { updated };
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function syncFile(filePath: string): void {
|
|
44
|
+
const pkg = JSON.parse(fs.readFileSync(filePath, "utf8"));
|
|
45
|
+
const { updated } = updateDeps(pkg.devDependencies ?? {});
|
|
46
|
+
|
|
47
|
+
if (updated.length) {
|
|
48
|
+
fs.writeFileSync(filePath, JSON.stringify(pkg, null, 2) + "\n", "utf8");
|
|
49
|
+
console.log(`\nβ
${filePath}`);
|
|
50
|
+
for (const u of updated) console.log(` ${u}`);
|
|
51
|
+
} else {
|
|
52
|
+
console.log(`\nβ
${filePath} β already up to date`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
console.log("π Syncing template deps from node_modules...");
|
|
57
|
+
syncFile(TEMPLATES_PKG);
|
|
58
|
+
syncFile(TEMPLATES_SASS);
|
|
59
|
+
console.log("\nβ
Done.");
|
|
@@ -31,7 +31,7 @@ async function getTargetVersion(currentVersion: string): Promise<string> {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
async function updateJsonFile(filename: string, updateFn: (json:
|
|
34
|
+
async function updateJsonFile(filename: string, updateFn: (json: Record<string, unknown>) => void): Promise<void> {
|
|
35
35
|
try {
|
|
36
36
|
const content = JSON.parse(await readFile(filename, "utf8"));
|
|
37
37
|
updateFn(content);
|
package/scripts/utils.ts
CHANGED
|
@@ -76,17 +76,17 @@ export async function copyFilesToTargetDir(buildPath: string): Promise<void> {
|
|
|
76
76
|
|
|
77
77
|
try {
|
|
78
78
|
await mkdir(buildPath, { recursive: true });
|
|
79
|
-
} catch (error:
|
|
80
|
-
if (error.code !== "EEXIST") {
|
|
81
|
-
console.error(`Error creating directory: ${error.message}`);
|
|
79
|
+
} catch (error: unknown) {
|
|
80
|
+
if ((error as NodeJS.ErrnoException).code !== "EEXIST") {
|
|
81
|
+
console.error(`Error creating directory: ${(error as Error).message}`);
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
// Copy manifest
|
|
86
86
|
try {
|
|
87
87
|
await copyFile(manifestSrc, manifestDest);
|
|
88
|
-
} catch (error:
|
|
89
|
-
console.error(`Error copying manifest: ${error.message}`);
|
|
88
|
+
} catch (error: unknown) {
|
|
89
|
+
console.error(`Error copying manifest: ${(error as Error).message}`);
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
// Copy CSS
|
|
@@ -107,16 +107,16 @@ export async function copyFilesToTargetDir(buildPath: string): Promise<void> {
|
|
|
107
107
|
} else {
|
|
108
108
|
return;
|
|
109
109
|
}
|
|
110
|
-
} catch (error:
|
|
111
|
-
console.error(`Error copying CSS: ${error.message}`);
|
|
110
|
+
} catch (error: unknown) {
|
|
111
|
+
console.error(`Error copying CSS: ${(error as Error).message}`);
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
export function gitExec(command: string): void {
|
|
116
116
|
try {
|
|
117
117
|
execSync(command, { stdio: "inherit" });
|
|
118
|
-
} catch (error:
|
|
119
|
-
console.error(`Error executing '${command}':`, error.message);
|
|
118
|
+
} catch (error: unknown) {
|
|
119
|
+
console.error(`Error executing '${command}':`, (error as Error).message);
|
|
120
120
|
throw error;
|
|
121
121
|
}
|
|
122
122
|
}
|
|
@@ -141,8 +141,8 @@ export async function ensureGitSync(): Promise<void> {
|
|
|
141
141
|
} else {
|
|
142
142
|
console.log('β
Repository is synchronized with remote');
|
|
143
143
|
}
|
|
144
|
-
} catch (error:
|
|
145
|
-
console.error(`β Git sync failed: ${error.message}`);
|
|
144
|
+
} catch (error: unknown) {
|
|
145
|
+
console.error(`β Git sync failed: ${(error as Error).message}`);
|
|
146
146
|
throw error;
|
|
147
147
|
}
|
|
148
148
|
}
|
package/src/main.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { App
|
|
1
|
+
import type { App } from 'obsidian';
|
|
2
|
+
import { Plugin, PluginSettingTab, Setting, Notice } from 'obsidian';
|
|
2
3
|
import { showConfirmModal } from './modals/GenericConfirmModal.ts';
|
|
3
4
|
// import { showTestMessage, getRandomEmoji } from "obsidian-plugin-config/tools";
|
|
4
5
|
|
package/templates/.prettierrc
CHANGED
|
@@ -37,7 +37,11 @@ const configs: Linter.Config[] = [
|
|
|
37
37
|
|
|
38
38
|
// Useful rules but not too strict
|
|
39
39
|
"semi": "error",
|
|
40
|
+
"eqeqeq": ["error", "always"],
|
|
41
|
+
"prefer-const": "error",
|
|
40
42
|
"@typescript-eslint/explicit-function-return-type": ["warn", { "allowExpressions": true }],
|
|
43
|
+
"@typescript-eslint/no-explicit-any": "warn",
|
|
44
|
+
"@typescript-eslint/consistent-type-imports": ["warn", { "prefer": "type-imports" }],
|
|
41
45
|
|
|
42
46
|
// Disable overly strict rules
|
|
43
47
|
"@typescript-eslint/no-unsafe-assignment": "off",
|
package/templates/package.json
CHANGED
|
@@ -22,22 +22,22 @@
|
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@types/eslint": "latest",
|
|
25
|
-
"@types/node": "
|
|
26
|
-
"@types/semver": "
|
|
25
|
+
"@types/node": "latest",
|
|
26
|
+
"@types/semver": "latest",
|
|
27
27
|
"@typescript-eslint/eslint-plugin": "latest",
|
|
28
28
|
"@typescript-eslint/parser": "latest",
|
|
29
|
-
"builtin-modules": "
|
|
30
|
-
"dedent": "
|
|
31
|
-
"dotenv": "
|
|
29
|
+
"builtin-modules": "latest",
|
|
30
|
+
"dedent": "latest",
|
|
31
|
+
"dotenv": "latest",
|
|
32
32
|
"esbuild": "latest",
|
|
33
33
|
"eslint": "latest",
|
|
34
34
|
"eslint-import-resolver-typescript": "latest",
|
|
35
35
|
"jiti": "latest",
|
|
36
36
|
"obsidian": "*",
|
|
37
37
|
"obsidian-typings": "latest",
|
|
38
|
-
"prettier": "
|
|
39
|
-
"semver": "
|
|
40
|
-
"tsx": "
|
|
41
|
-
"typescript": "
|
|
38
|
+
"prettier": "latest",
|
|
39
|
+
"semver": "latest",
|
|
40
|
+
"tsx": "latest",
|
|
41
|
+
"typescript": "latest"
|
|
42
42
|
}
|
|
43
43
|
}
|