@babajide234/git-merge-workflow 1.0.2 → 1.0.4

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 babajide Tomoshegbo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -108,5 +108,26 @@ Publish-Module -Path . -NuGetApiKey <Your-API-Key>
108
108
  - `New-GitWorkflowConfig`: Generates the `.git-merge-workflow.json` configuration file.
109
109
  - `Get-GitWorkflowConfig`: Reads the current configuration.
110
110
 
111
+ ## Cross-Platform Support (Mac/Linux)
112
+
113
+ This tool works on Windows, macOS, and Linux.
114
+
115
+ ### Requirements for macOS/Linux
116
+ You must have **PowerShell Core** (`pwsh`) installed.
117
+
118
+ **macOS (Homebrew):**
119
+ ```bash
120
+ brew install --cask powershell
121
+ ```
122
+
123
+ **Linux (Ubuntu):**
124
+ ```bash
125
+ sudo apt-get install -y wget apt-transport-https software-properties-common
126
+ wget -q "https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb"
127
+ sudo dpkg -i packages-microsoft-prod.deb
128
+ sudo apt-get update
129
+ sudo apt-get install -y powershell
130
+ ```
131
+
111
132
  ## License
112
133
  MIT
package/bin/cli.js CHANGED
@@ -9,20 +9,45 @@ const modulePath = path.resolve(__dirname, '../GitMergeWorkflow.psd1');
9
9
  // Arguments passed to the CLI
10
10
  const args = process.argv.slice(2);
11
11
 
12
+ // Determine which PowerShell executable to use
13
+ // On Windows: try 'pwsh' (PowerShell Core) first, fallback to 'powershell' (Windows PowerShell)
14
+ // On macOS/Linux: must use 'pwsh'
15
+ const isWin = process.platform === 'win32';
16
+ const psExecutable = isWin ? 'powershell' : 'pwsh';
17
+
12
18
  // Construct the PowerShell command
13
19
  // We import the module and then invoke the function with passed arguments
20
+ // We need to ensure args are passed correctly.
21
+ // Since we are passing a command string, we rely on the user's shell to have parsed quotes,
22
+ // and we rejoin them. Ideally, we would quote arguments that contain spaces.
23
+ const formattedArgs = args.map(arg => {
24
+ if (arg.includes(' ') && !arg.startsWith('"') && !arg.startsWith("'")) {
25
+ return `"${arg}"`;
26
+ }
27
+ return arg;
28
+ }).join(' ');
29
+
14
30
  const psCommand = `
15
31
  $ErrorActionPreference = 'Stop'
16
32
  Import-Module '${modulePath}' -Force
17
- Invoke-GitMergeWorkflow ${args.join(' ')}
33
+ Invoke-GitMergeWorkflow ${formattedArgs}
18
34
  `;
19
35
 
20
- // Determine which PowerShell executable to use (pwsh for Core, powershell for Windows PowerShell)
21
- const psExecutable = process.platform === 'win32' ? 'powershell' : 'pwsh';
22
-
23
36
  const child = spawn(psExecutable, ['-NoProfile', '-Command', psCommand], {
24
37
  stdio: 'inherit',
25
- shell: true
38
+ shell: false // set to false to avoid shell injection, we are executing pwsh directly
39
+ });
40
+
41
+ child.on('error', (err) => {
42
+ if (err.code === 'ENOENT') {
43
+ console.error(`Error: Could not find '${psExecutable}'. Please ensure PowerShell is installed.`);
44
+ if (!isWin) {
45
+ console.error('On macOS/Linux, install PowerShell via Homebrew: brew install --cask powershell');
46
+ }
47
+ } else {
48
+ console.error('Failed to start PowerShell process:', err);
49
+ }
50
+ process.exit(1);
26
51
  });
27
52
 
28
53
  child.on('exit', (code) => {
package/package.json CHANGED
@@ -1,12 +1,22 @@
1
1
  {
2
2
  "name": "@babajide234/git-merge-workflow",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
+ "private": false,
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
4
8
  "description": "Automated Git workflow for merging feature branches through staging to develop",
5
- "main": "index.js",
6
9
  "bin": {
7
10
  "git-merge-workflow": "./bin/cli.js",
8
11
  "gmw": "./bin/cli.js"
9
12
  },
13
+ "files": [
14
+ "bin/",
15
+ "GitMergeWorkflow.psd1",
16
+ "GitMergeWorkflow.psm1",
17
+ "Install.ps1",
18
+ "README.md"
19
+ ],
10
20
  "scripts": {
11
21
  "test": "echo \"Error: no test specified\" && exit 1"
12
22
  },
@@ -1,36 +0,0 @@
1
- # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2
- # For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
3
-
4
- name: Node.js Package
5
-
6
- on:
7
- release:
8
- types: [created]
9
-
10
- jobs:
11
- build:
12
- runs-on: ubuntu-latest
13
- steps:
14
- - uses: actions/checkout@v4
15
- - uses: actions/setup-node@v4
16
- with:
17
- node-version: 20
18
- - run: npm ci
19
- - run: npm test
20
-
21
- publish-gpr:
22
- needs: build
23
- runs-on: ubuntu-latest
24
- permissions:
25
- contents: read
26
- packages: write
27
- steps:
28
- - uses: actions/checkout@v4
29
- - uses: actions/setup-node@v4
30
- with:
31
- node-version: 20
32
- registry-url: https://npm.pkg.github.com/
33
- - run: npm ci
34
- - run: npm publish
35
- env:
36
- NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
@@ -1,34 +0,0 @@
1
- name: Publish PowerShell Module
2
-
3
- on:
4
- release:
5
- types: [created]
6
- workflow_dispatch:
7
-
8
- jobs:
9
- publish-to-gallery:
10
- runs-on: ubuntu-latest
11
- steps:
12
- - uses: actions/checkout@v3
13
-
14
- - name: Build and Publish
15
- env:
16
- NUGET_KEY: ${{ secrets.NUGET_KEY }}
17
- shell: pwsh
18
- run: |
19
- Publish-Module -Path . -NuGetApiKey $env:NUGET_KEY -Verbose
20
-
21
- publish-to-npm:
22
- runs-on: ubuntu-latest
23
- needs: publish-to-gallery
24
- steps:
25
- - uses: actions/checkout@v3
26
- - uses: actions/setup-node@v3
27
- with:
28
- node-version: '16.x'
29
- registry-url: 'https://registry.npmjs.org'
30
-
31
- - run: npm install
32
- - run: npm publish --access public
33
- env:
34
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}