Skip to content

Commit

Permalink
feat: add '--collaborate' option to CLI for opening GitHub repository
Browse files Browse the repository at this point in the history
- But a bug in which it activates the command by default.
  • Loading branch information
RaulCatalinas committed Apr 28, 2024
1 parent e3862ea commit 5696158
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 9 deletions.
Binary file modified bun.lockb
Binary file not shown.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@
"prepublishOnly": "bun run build"
},
"dependencies": {
"commander": "12.0.0"
"commander": "12.0.0",
"opener": "1.5.2"
},
"devDependencies": {
"@commitlint/cli": "19.3.0",
"@commitlint/config-conventional": "19.2.2",
"@swc/cli": "0.3.12",
"@swc/core": "1.4.17",
"@types/bun": "1.1.0",
"@types/opener": "1.4.3",
"@typescript-eslint/eslint-plugin": "^7.0.1",
"eslint": "^8.0.1",
"eslint-config-love": "47.0.0",
Expand Down
7 changes: 1 addition & 6 deletions src/config/huskybc.ts → src/config/cli.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
// Commander
import { createCommand } from 'commander'

// Constants
import { program } from '../constants/huskybc'
import { VERSION } from '../constants/version'

export const program = createCommand('HuskyBC')

export function configureCLI() {
program
.description('Command line for easy Husky configuration')
Expand Down
16 changes: 16 additions & 0 deletions src/config/options.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Third-Party libraries
import opener from 'opener'

// Constants
import { REPOSITORY } from '../constants/github'
import { program } from '../constants/huskybc'

export function configureOptions() {
program.option(
'--collaborate',
'Open GitHub repository for collaboration',
() => {
opener(REPOSITORY)
}
)
}
1 change: 1 addition & 0 deletions src/constants/github.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const REPOSITORY = 'https://github.com/RaulCatalinas/HuskyBC'
3 changes: 3 additions & 0 deletions src/constants/huskybc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { createCommand } from 'commander'

export const program = createCommand('HuskyBC')
9 changes: 7 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
// Config
import { configureCLI, program } from './config/huskybc'
// Config'
import { configureCLI } from './config/cli'
import { configureOptions } from './config/options'

// Controllers
import { huskyConfigController } from './controllers/husky-config'

// Constants
import { program } from './constants/huskybc'

configureCLI()
configureOptions()

const thereIsFirstArgument = program.args[0] !== undefined

Expand Down

0 comments on commit 5696158

Please sign in to comment.