Skip to content

Commit

Permalink
feat: create CLI (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
levibostian committed Sep 30, 2023
1 parent 37eeacf commit 083c859
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 1 deletion.
17 changes: 16 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,26 @@ jobs:
- run: npm run test

run-compile:
name: Expect code to be able to compile successfully
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
- run: npm ci
- run: npm run compile
- run: npm run compile

run-cli:
name: Run the CLI, expect no errors
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
- run: npm ci
- run: npm run compile
- run: npm pack
- run: npm install --no-save is-it-deployed-1.0.0.tgz
- run: node node_modules/.bin/is-it-deployed --package-manager npm --package-name react --package-version 18.0.0
9 changes: 9 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"typescript": "^5.2.2"
},
"dependencies": {
"commander": "^11.0.0",
"tiny-json-http": "^7.5.1"
}
}
33 changes: 33 additions & 0 deletions src/cli.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { Command } from 'commander';
import { isItDeployed } from '.';
import { exit } from 'process';

const program = new Command()
.requiredOption('--package-manager <name>', 'npm')
.requiredOption('--package-name <name>', 'react')
.requiredOption('--package-version <name>', '1.0.0')
.parse();

(async () => {
const {
packageManager,
packageName,
packageVersion
} = program.opts()

console.log(`Checking if ${packageName}@${packageVersion} is deployed on ${packageManager}...`)

const isItDeployedResult = await isItDeployed({
packageManager,
packageName,
packageVersion
})

if (!isItDeployedResult) {
console.log('its not')
exit(1)
}

console.log('its deployed')
exit(0)
})()

0 comments on commit 083c859

Please sign in to comment.