obsidian-plugin-config 1.4.0 → 1.4.2
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/bin/obsidian-inject.js +1 -1
- package/eslint.config.mts +10 -0
- package/package.json +1 -1
- package/scripts/build-npm.ts +26 -34
- package/scripts/help.ts +13 -4
- package/scripts/inject-core.ts +2 -2
- package/scripts/update-version-config.ts +1 -1
- package/scripts/utils.ts +11 -11
- package/src/main.ts +3 -4
- package/src/modals/GenericConfirmModal.ts +13 -1
- package/src/modals/index.ts +1 -1
- package/templates/.prettierrc +10 -1
- package/templates/eslint.config.mts +4 -0
- package/versions.json +3 -1
package/.prettierrc
CHANGED
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",
|
|
@@ -48,6 +52,12 @@ const configs: Linter.Config[] = [
|
|
|
48
52
|
"@typescript-eslint/no-unsafe-member-access": "off",
|
|
49
53
|
"@typescript-eslint/no-unsafe-argument": "off"
|
|
50
54
|
}
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
files: ["src/**/*.ts"],
|
|
58
|
+
rules: {
|
|
59
|
+
"no-console": ["warn", { "allow": ["warn", "error", "debug"] }]
|
|
60
|
+
}
|
|
51
61
|
}
|
|
52
62
|
];
|
|
53
63
|
|
package/package.json
CHANGED
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 --force', { 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
|
|
|
@@ -129,7 +138,7 @@ STANDARD DEVELOPMENT WORKFLOW:
|
|
|
129
138
|
(not required before npm-publish).
|
|
130
139
|
|
|
131
140
|
AFTER NPM PUBLISH - Update global CLI:
|
|
132
|
-
npm install -g obsidian-plugin-config@latest
|
|
141
|
+
npm install -g obsidian-plugin-config@latest --force
|
|
133
142
|
obsidian-inject # Test in current plugin dir
|
|
134
143
|
obsidian-inject ../test-plugin --sass
|
|
135
144
|
|
package/scripts/inject-core.ts
CHANGED
|
@@ -282,7 +282,7 @@ export async function cleanOldLintFiles(targetPath: string): Promise<void> {
|
|
|
282
282
|
/**
|
|
283
283
|
* Inject scripts and config files
|
|
284
284
|
*/
|
|
285
|
-
export async function injectScripts(targetPath: string
|
|
285
|
+
export async function injectScripts(targetPath: string): Promise<void> {
|
|
286
286
|
const scriptsPath = path.join(targetPath, "scripts");
|
|
287
287
|
|
|
288
288
|
if (!await isValidPath(scriptsPath)) {
|
|
@@ -708,7 +708,7 @@ export async function performInjection(
|
|
|
708
708
|
try {
|
|
709
709
|
await cleanNpmArtifactsIfNeeded(targetPath);
|
|
710
710
|
await ensureTsxInstalled(targetPath);
|
|
711
|
-
await injectScripts(targetPath
|
|
711
|
+
await injectScripts(targetPath);
|
|
712
712
|
|
|
713
713
|
console.log(`\n📦 Updating package.json...`);
|
|
714
714
|
await updatePackageJson(targetPath, useSass);
|
|
@@ -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
|
|
|
@@ -14,7 +15,7 @@ export default class ObsidianPluginConfigPlugin extends Plugin {
|
|
|
14
15
|
settings: MyPluginSettings;
|
|
15
16
|
|
|
16
17
|
async onload(): Promise<void> {
|
|
17
|
-
console.
|
|
18
|
+
console.debug('Loading obsidian-plugin-config plugin for testing NPM exports');
|
|
18
19
|
await this.loadSettings();
|
|
19
20
|
|
|
20
21
|
this.addCommand({
|
|
@@ -51,11 +52,9 @@ export default class ObsidianPluginConfigPlugin extends Plugin {
|
|
|
51
52
|
cancelText: 'Annuler',
|
|
52
53
|
onConfirm: () => {
|
|
53
54
|
new Notice('Action confirmée !');
|
|
54
|
-
console.log("Action confirmée par l'utilisateur");
|
|
55
55
|
},
|
|
56
56
|
onCancel: () => {
|
|
57
57
|
new Notice('Action annulée.');
|
|
58
|
-
console.log("Action annulée par l'utilisateur");
|
|
59
58
|
}
|
|
60
59
|
});
|
|
61
60
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { App
|
|
1
|
+
import type { App } from 'obsidian';
|
|
2
|
+
import { Modal } from 'obsidian';
|
|
2
3
|
|
|
3
4
|
export interface ConfirmModalOptions {
|
|
4
5
|
title: string;
|
|
@@ -65,3 +66,14 @@ export class GenericConfirmModal extends Modal {
|
|
|
65
66
|
export function showConfirmModal(app: App, options: ConfirmModalOptions): void {
|
|
66
67
|
new GenericConfirmModal(app, options).open();
|
|
67
68
|
}
|
|
69
|
+
|
|
70
|
+
export async function confirmation(app: App, message: string): Promise<boolean> {
|
|
71
|
+
return new Promise((resolve) => {
|
|
72
|
+
new GenericConfirmModal(app, {
|
|
73
|
+
title: 'Confirm',
|
|
74
|
+
message,
|
|
75
|
+
onConfirm: () => resolve(true),
|
|
76
|
+
onCancel: () => resolve(false)
|
|
77
|
+
}).open();
|
|
78
|
+
});
|
|
79
|
+
}
|
package/src/modals/index.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// Export all modals for easy importing
|
|
2
|
-
export { GenericConfirmModal, showConfirmModal } from './GenericConfirmModal.js';
|
|
2
|
+
export { GenericConfirmModal, showConfirmModal, confirmation } from './GenericConfirmModal.js';
|
|
3
3
|
export type { ConfirmModalOptions } from './GenericConfirmModal.js';
|
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",
|