node-power-user 1.0.11 → 1.0.13

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/README.md CHANGED
@@ -91,6 +91,12 @@ Pull the latest changes from the remote repository and push your changes. You ca
91
91
  npu sync
92
92
  ```
93
93
 
94
+ ### Open Repository
95
+ Open the current repository's remote URL in your default browser.
96
+ ```shell
97
+ npu open
98
+ ```
99
+
94
100
  ### Check Version
95
101
  Check the version of node-power-user.
96
102
  ```shell
package/TODO.md ADDED
@@ -0,0 +1,7 @@
1
+ Use "keychain" for something?
2
+
3
+ Interesting - the git status shows your branch is up to date now. However, the error you encountered was about needing to configure how to handle divergent branches in the future. The issue is that git needs to know your preference for handling situations where branches have diverged. You have three options:
4
+ Merge (git config pull.rebase false) - Creates merge commits
5
+ Rebase (git config pull.rebase true) - Replays your local commits on top of remote changes (cleaner history)
6
+ Fast-forward only (git config pull.ff only) - Only pulls if it can fast-forward (safest, but fails if branches diverged)
7
+ Which strategy would you prefer for handling divergent branches during pulls? I'd recommend rebase for a cleaner history, but I can set it to whichever you prefer. Would you like me to configure this globally for all your repositories or just for this one?
package/dist/cli.js CHANGED
@@ -8,6 +8,7 @@ const ALIASES = {
8
8
  bump: ['-b', '--bump'],
9
9
  clean: ['-c', '--clean'],
10
10
  global: ['-g', '--global'],
11
+ open: ['--open', 'repo', '--repo'],
11
12
  outdated: ['-o', 'out', '--outdated'],
12
13
  packages: ['-p', 'pack', '--packages'],
13
14
  version: ['-v', '--version'],
@@ -0,0 +1,71 @@
1
+ // Libraries
2
+ const logger = new (require('../lib/logger'))('node-power-user');
3
+ const path = require('path');
4
+ const jetpack = require('fs-jetpack');
5
+ const { execute } = require('node-powertools');
6
+
7
+ // Module
8
+ module.exports = async function (options) {
9
+ // Find the repository root by locating the .git folder
10
+ const repoRoot = findGitRoot(process.cwd());
11
+ if (!repoRoot) {
12
+ logger.error('Could not find the .git folder. Are you inside a Git repository?');
13
+ return false;
14
+ }
15
+
16
+ try {
17
+ // Get the remote URL
18
+ const result = await execute('git remote get-url origin', {
19
+ log: false,
20
+ config: { cwd: repoRoot },
21
+ });
22
+
23
+ let remoteUrl = (result.stdout || '').trim();
24
+
25
+ if (!remoteUrl) {
26
+ logger.error('No remote origin found for this repository.');
27
+ return false;
28
+ }
29
+
30
+ // Convert SSH URL to HTTPS URL if needed
31
+ // git@github.com:owner/repo.git -> https://github.com/owner/repo
32
+ if (remoteUrl.startsWith('git@')) {
33
+ remoteUrl = remoteUrl
34
+ .replace(/^git@/, 'https://')
35
+ .replace(/:([^/])/, '/$1')
36
+ .replace(/\.git$/, '');
37
+ } else if (remoteUrl.startsWith('https://') || remoteUrl.startsWith('http://')) {
38
+ // Remove .git suffix if present
39
+ remoteUrl = remoteUrl.replace(/\.git$/, '');
40
+ }
41
+
42
+ // Log the URL
43
+ logger.log(`Opening ${remoteUrl}...`);
44
+
45
+ // Open the URL in the default browser
46
+ await execute(`open "${remoteUrl}"`, {
47
+ log: false,
48
+ config: { cwd: repoRoot },
49
+ });
50
+
51
+ logger.log(logger.format.green('Repository opened in browser!'));
52
+
53
+ return true;
54
+ } catch (e) {
55
+ logger.error(`Failed to open repository`, e.stack);
56
+ return false;
57
+ }
58
+ };
59
+
60
+ function findGitRoot(startPath) {
61
+ let currentPath = startPath;
62
+
63
+ while (currentPath !== path.parse(currentPath).root) {
64
+ if (jetpack.exists(path.join(currentPath, '.git')) === 'dir') {
65
+ return currentPath;
66
+ }
67
+ currentPath = path.dirname(currentPath);
68
+ }
69
+
70
+ return null;
71
+ }
@@ -18,23 +18,50 @@ module.exports = async function (options) {
18
18
  return false;
19
19
  }
20
20
 
21
- // Collect answers using the new @inquirer/prompts methods
22
- const message = await ask({
23
- message: 'Enter a commit message',
24
- default: 'Update',
25
- value: options.message,
26
- multiline: false,
27
- });
28
-
29
- // Define cleanup command
30
- const command = `git pull && git add . && git commit -m "${message}" && git push origin`;
31
-
32
21
  // Log initial state
33
22
  logger.log(`Syncing repo...`);
34
23
 
35
24
  try {
36
- // Run cleanup commands with the repository root as the working directory
37
- await execute(command, {
25
+ // First, pull changes from remote
26
+ logger.log('Pulling changes from remote...');
27
+ const pullResult = await execute('git pull', {
28
+ log: false,
29
+ config: {cwd: repoRoot},
30
+ });
31
+
32
+ // Check if there were any changes pulled
33
+ const pullOutput = pullResult.stdout || '';
34
+ if (pullOutput.includes('Already up to date') || pullOutput.includes('Already up-to-date')) {
35
+ logger.log('Already up to date - no changes pulled');
36
+ } else {
37
+ // Try to extract the number of files changed
38
+ const filesChangedMatch = pullOutput.match(/(\d+) file[s]? changed/);
39
+ const insertionsMatch = pullOutput.match(/(\d+) insertion[s]?/);
40
+ const deletionsMatch = pullOutput.match(/(\d+) deletion[s]?/);
41
+
42
+ if (filesChangedMatch) {
43
+ const filesChanged = filesChangedMatch[1];
44
+ const insertions = insertionsMatch ? insertionsMatch[1] : '0';
45
+ const deletions = deletionsMatch ? deletionsMatch[1] : '0';
46
+ logger.log(logger.format.green(`Pulled changes: ${filesChanged} file(s) changed, ${insertions} insertion(s), ${deletions} deletion(s)`));
47
+ } else {
48
+ logger.log(logger.format.green('Changes pulled successfully'));
49
+ }
50
+ }
51
+
52
+ // Collect answers using the new @inquirer/prompts methods
53
+ const message = await ask({
54
+ message: 'Enter a commit message',
55
+ default: 'Update',
56
+ value: options.message,
57
+ multiline: false,
58
+ });
59
+
60
+ // Then, add, commit, and push changes
61
+ logger.log('Committing and pushing changes...');
62
+ const pushCommand = `git add . && git commit -m "${message}" && git push origin`;
63
+
64
+ await execute(pushCommand, {
38
65
  log: true,
39
66
  config: {cwd: repoRoot},
40
67
  });
@@ -0,0 +1,58 @@
1
+ [debug] [2025-10-26T14:46:37.834Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
2
+ [debug] [2025-10-26T14:46:37.835Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
3
+ [debug] [2025-10-26T14:46:37.836Z] > authorizing via signed-in user (ian.wiedenman@gmail.com)
4
+ [debug] [2025-10-26T14:46:37.837Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
5
+ [debug] [2025-10-26T14:46:37.837Z] > authorizing via signed-in user (ian.wiedenman@gmail.com)
6
+ [debug] [2025-10-26T14:46:37.845Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
7
+ [debug] [2025-10-26T14:46:37.845Z] > authorizing via signed-in user (ian.wiedenman@gmail.com)
8
+ [debug] [2025-10-26T14:46:37.837Z] > authorizing via signed-in user (ian.wiedenman@gmail.com)
9
+ [debug] [2025-10-26T14:46:37.838Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
10
+ [debug] [2025-10-26T14:46:37.838Z] > authorizing via signed-in user (ian.wiedenman@gmail.com)
11
+ [debug] [2025-10-26T14:46:37.849Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
12
+ [debug] [2025-10-26T14:46:37.849Z] > authorizing via signed-in user (ian.wiedenman@gmail.com)
13
+ [debug] [2025-10-26T14:46:37.860Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
14
+ [debug] [2025-10-26T14:46:37.861Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
15
+ [debug] [2025-10-26T14:46:37.860Z] > authorizing via signed-in user (ian.wiedenman@gmail.com)
16
+ [debug] [2025-10-26T14:46:37.861Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
17
+ [debug] [2025-10-26T14:46:37.861Z] > authorizing via signed-in user (ian.wiedenman@gmail.com)
18
+ [debug] [2025-10-26T14:46:37.863Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
19
+ [debug] [2025-10-26T14:46:37.863Z] > authorizing via signed-in user (ian.wiedenman@gmail.com)
20
+ [debug] [2025-10-26T14:46:37.864Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
21
+ [debug] [2025-10-26T14:46:37.864Z] > authorizing via signed-in user (ian.wiedenman@gmail.com)
22
+ [debug] [2025-10-26T14:46:37.861Z] > authorizing via signed-in user (ian.wiedenman@gmail.com)
23
+ [debug] [2025-10-26T14:46:37.862Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
24
+ [debug] [2025-10-26T14:46:37.862Z] > authorizing via signed-in user (ian.wiedenman@gmail.com)
25
+ [debug] [2025-10-26T14:46:37.864Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
26
+ [debug] [2025-10-26T14:46:37.864Z] > authorizing via signed-in user (ian.wiedenman@gmail.com)
27
+ [debug] [2025-10-26T14:46:37.864Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
28
+ [debug] [2025-10-26T14:46:37.864Z] > authorizing via signed-in user (ian.wiedenman@gmail.com)
29
+ [debug] [2025-10-26T20:17:50.677Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
30
+ [debug] [2025-10-26T20:17:50.679Z] > authorizing via signed-in user (ian.wiedenman@gmail.com)
31
+ [debug] [2025-10-26T20:17:50.679Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
32
+ [debug] [2025-10-26T20:17:50.679Z] > authorizing via signed-in user (ian.wiedenman@gmail.com)
33
+ [debug] [2025-10-26T20:17:50.688Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
34
+ [debug] [2025-10-26T20:17:50.688Z] > authorizing via signed-in user (ian.wiedenman@gmail.com)
35
+ [debug] [2025-10-26T20:17:50.700Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
36
+ [debug] [2025-10-26T20:17:50.700Z] > authorizing via signed-in user (ian.wiedenman@gmail.com)
37
+ [debug] [2025-10-26T20:17:50.701Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
38
+ [debug] [2025-10-26T20:17:50.701Z] > authorizing via signed-in user (ian.wiedenman@gmail.com)
39
+ [debug] [2025-10-26T20:17:50.703Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
40
+ [debug] [2025-10-26T20:17:50.703Z] > authorizing via signed-in user (ian.wiedenman@gmail.com)
41
+ [debug] [2025-10-26T20:17:50.703Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
42
+ [debug] [2025-10-26T20:17:50.703Z] > authorizing via signed-in user (ian.wiedenman@gmail.com)
43
+ [debug] [2025-10-26T20:17:50.755Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
44
+ [debug] [2025-10-26T20:17:50.757Z] > authorizing via signed-in user (ian.wiedenman@gmail.com)
45
+ [debug] [2025-10-26T20:17:50.757Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
46
+ [debug] [2025-10-26T20:17:50.758Z] > authorizing via signed-in user (ian.wiedenman@gmail.com)
47
+ [debug] [2025-10-26T20:17:50.769Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
48
+ [debug] [2025-10-26T20:17:50.769Z] > authorizing via signed-in user (ian.wiedenman@gmail.com)
49
+ [debug] [2025-10-26T20:17:50.780Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
50
+ [debug] [2025-10-26T20:17:50.780Z] > authorizing via signed-in user (ian.wiedenman@gmail.com)
51
+ [debug] [2025-10-26T20:17:50.781Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
52
+ [debug] [2025-10-26T20:17:50.781Z] > authorizing via signed-in user (ian.wiedenman@gmail.com)
53
+ [debug] [2025-10-26T20:17:50.782Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
54
+ [debug] [2025-10-26T20:17:50.782Z] > authorizing via signed-in user (ian.wiedenman@gmail.com)
55
+ [debug] [2025-10-26T20:17:50.783Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
56
+ [debug] [2025-10-26T20:17:50.783Z] > authorizing via signed-in user (ian.wiedenman@gmail.com)
57
+ [debug] [2025-10-27T13:47:53.709Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
58
+ [debug] [2025-10-27T13:47:53.716Z] > authorizing via signed-in user (ian.wiedenman@gmail.com)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-power-user",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "description": "Easy tools for every Node.js developer!",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -8,7 +8,7 @@
8
8
  "start": "npm run prepare && ./bin/node-power-user",
9
9
  "help": "echo 'npm start -- -v'",
10
10
  "prepare": "node -e \"require('prepare-package')()\"",
11
- "prepare:watch": "nodemon -w ./src -e '*' --exec 'npm run prepare'"
11
+ "prepare:watch": "node -e \"require('prepare-package/watch')()\""
12
12
  },
13
13
  "bin": {
14
14
  "npu": "bin/node-power-user",
@@ -36,16 +36,12 @@
36
36
  "replace": {}
37
37
  },
38
38
  "dependencies": {
39
- "@inquirer/prompts": "^7.4.1",
39
+ "@inquirer/prompts": "^7.9.0",
40
40
  "chalk": "^4.1.2",
41
41
  "cli-progress": "^3.12.0",
42
- "fs-jetpack": "^4.3.1",
43
- "inquirer": "^8.2.6",
42
+ "fs-jetpack": "^5.1.0",
44
43
  "itwcw-package-analytics": "^1.0.6",
45
- "json5": "^2.2.3",
46
- "keychain": "^1.5.0",
47
- "lodash": "^4.17.21",
48
- "node-powertools": "^2.2.0",
44
+ "node-powertools": "^2.3.1",
49
45
  "npm-api": "^1.0.1",
50
46
  "table": "^6.9.0",
51
47
  "wonderful-version": "^1.3.2",
@@ -53,6 +49,6 @@
53
49
  },
54
50
  "devDependencies": {
55
51
  "mocha": "^8.4.0",
56
- "prepare-package": "^1.1.14"
52
+ "prepare-package": "^1.2.5"
57
53
  }
58
54
  }