obsidian-plugin-config 1.4.4 → 1.4.6

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.
@@ -1,75 +1,83 @@
1
- import { execSync } from "child_process";
2
- import fs from "fs";
3
- import path from "path";
1
+ import { execSync } from 'child_process';
2
+ import fs from 'fs';
3
+ import path from 'path';
4
4
  import {
5
- askQuestion,
6
- cleanInput,
7
- createReadlineInterface,
8
- gitExec,
9
- ensureGitSync
10
- } from "./utils.js";
5
+ askQuestion,
6
+ cleanInput,
7
+ createReadlineInterface,
8
+ gitExec,
9
+ ensureGitSync
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
- const packageJsonPath = path.join(process.cwd(), "package.json");
17
- if (!fs.existsSync(packageJsonPath)) return false;
16
+ const packageJsonPath = path.join(process.cwd(), 'package.json');
17
+ if (!fs.existsSync(packageJsonPath)) return false;
18
18
 
19
- const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
20
- return packageJson.name === "obsidian-plugin-config";
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
- try {
25
- if (process.argv.includes("-b")) {
26
- console.log("Building...");
27
- gitExec("yarn build");
28
- console.log("Build successful.");
29
- }
24
+ try {
25
+ if (process.argv.includes('-b')) {
26
+ console.log('Building...');
27
+ gitExec('yarn build');
28
+ console.log('Build successful.');
29
+ }
30
30
 
31
- // Only update exports if we're in the centralized repo and not explicitly disabled
32
- if (!process.argv.includes("-ne") && !process.argv.includes("--no-exports") && isInCentralizedRepo()) {
33
- console.log("Updating exports...");
34
- gitExec("yarn run update-exports");
35
- console.log("Exports updated.");
36
- }
31
+ // Only update exports if we're in the centralized repo and not explicitly disabled
32
+ if (
33
+ !process.argv.includes('-ne') &&
34
+ !process.argv.includes('--no-exports') &&
35
+ isInCentralizedRepo()
36
+ ) {
37
+ console.log('Updating exports...');
38
+ gitExec('yarn run update-exports');
39
+ console.log('Exports updated.');
40
+ }
37
41
 
38
- const input: string = await askQuestion("Enter commit message: ", rl);
42
+ const input: string = await askQuestion('Enter commit message: ', rl);
39
43
 
40
- const cleanedInput = cleanInput(input);
44
+ const cleanedInput = cleanInput(input);
41
45
 
42
- try {
43
- gitExec("git add -A");
44
- gitExec(`git commit -m "${cleanedInput}"`);
45
- } catch {
46
- console.log("Commit already exists or failed.");
47
- return;
48
- }
46
+ try {
47
+ gitExec('git add -A');
48
+ gitExec(`git commit -m "${cleanedInput}"`);
49
+ } catch {
50
+ console.log('Commit already exists or failed.');
51
+ return;
52
+ }
49
53
 
50
- // get current branch name
51
- const currentBranch = execSync("git rev-parse --abbrev-ref HEAD").toString().trim();
54
+ // get current branch name
55
+ const currentBranch = execSync('git rev-parse --abbrev-ref HEAD')
56
+ .toString()
57
+ .trim();
52
58
 
53
- // Ensure Git is synchronized before pushing
54
- await ensureGitSync();
59
+ // Ensure Git is synchronized before pushing
60
+ await ensureGitSync();
55
61
 
56
- try {
57
- gitExec(`git push origin ${currentBranch}`);
58
- console.log("Commit and push successful.");
59
- } catch {
60
- // new branch
61
- console.log(`New branch detected. Setting upstream for ${currentBranch}...`);
62
- gitExec(`git push --set-upstream origin ${currentBranch}`);
63
- console.log("Upstream branch set and push successful.");
64
- }
65
- } catch (error) {
66
- console.error("Error:", error instanceof Error ? error.message : String(error));
67
- } finally {
68
- rl.close();
69
- }
62
+ try {
63
+ gitExec(`git push origin ${currentBranch}`);
64
+ console.log('Commit and push successful.');
65
+ } catch {
66
+ // new branch
67
+ console.log(`New branch detected. Setting upstream for ${currentBranch}...`);
68
+ gitExec(`git push --set-upstream origin ${currentBranch}`);
69
+ console.log('Upstream branch set and push successful.');
70
+ }
71
+ } catch (error) {
72
+ console.error('Error:', error instanceof Error ? error.message : String(error));
73
+ } finally {
74
+ rl.close();
75
+ }
70
76
  }
71
77
 
72
- main().catch(console.error).finally(() => {
73
- console.log("Exiting...");
74
- process.exit();
75
- });
78
+ main()
79
+ .catch(console.error)
80
+ .finally(() => {
81
+ console.log('Exiting...');
82
+ process.exit();
83
+ });