Skip to content

Commit

Permalink
Added init command
Browse files Browse the repository at this point in the history
  • Loading branch information
mishushakov committed Oct 24, 2023
1 parent b23a8d5 commit e4043bf
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 9 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,6 @@ dist

# TernJS port file
.tern-port
.vitepress/cache/

# VitePress
cache/
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,7 @@ As an open-source project, we welcome contributions from the community. If you a

Get support hours covered by SLA, setup and training sessions, prioritized feature requests and bug resolution.

[→ Learn more](https://stepci.com/#pricing)

[→ Schedule a call](https://cal.com/wissmueller/step-ci-enterprise-support)
<a href="https://cal.com/wissmueller/step-ci-enterprise-support"><img alt="Book us with Cal.com" src="https://cal.com/book-with-cal-dark.svg" /></a>

## Privacy

Expand All @@ -109,7 +107,7 @@ By default, the CLI collects anonymous usage data, which includes:
- OS Name
- Node Version
- CLI Version
- Command (`stepci run`, `stepci generate`)
- Command (`stepci init`, `stepci run`, `stepci generate`)
- Environment (Local, Docker, CI/CD)

> **Note**: The usage analytics can be disabled by setting `STEPCI_DISABLE_ANALYTICS` environment variable
Expand Down
2 changes: 1 addition & 1 deletion docs/legal/privacy.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ By default, the CLI collects anonymous usage data, which includes:
- OS Name
- Node Version
- CLI Version
- Command (`stepci run`, `stepci generate`)
- Command (`stepci init`, `stepci run`, `stepci generate`)
- Environment (Local, Docker, CI/CD)

::: info
Expand Down
23 changes: 23 additions & 0 deletions docs/reference/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,29 @@ Options:

## Commands

### `init [path]`

The `init` command lets you init a new workflow

#### **Arguments**

| Argument | Required | Description |
|-|-|-|
| path | No | Specify the path to a workflow |

#### **Examples**

Initialise a workflow

```
stepci init
```

```
Success! The workflow file can be found at workflow.yml
Enter npx stepci run workflow.yml to run it
```

### `run [workflow]`

The `run` command lets you run a specified workflow
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "stepci",
"version": "2.6.9",
"version": "2.7.0",
"description": "API Testing and Monitoring made simple",
"main": "index.js",
"bin": {
Expand Down Expand Up @@ -34,6 +34,7 @@
"scripts": {
"build": "tsc -p tsconfig.json",
"build:watch": "tsc -w -p tsconfig.json",
"init": "ts-node ./src/index.ts init",
"test": "ts-node ./src/index.ts run",
"test:generate": "ts-node ./src/index.ts generate",
"test:loadtest": "ts-node ./src/index.ts run --loadtest",
Expand Down
27 changes: 27 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env node
import yargs from 'yargs'
import { hideBin } from 'yargs/helpers'
import fs from 'fs'
import { runFromFile, TestResult, WorkflowResult } from '@stepci/runner'
import { loadTestFromFile } from '@stepci/runner/dist/loadtesting'
import { generateWorkflowFile, GenerateWorkflowOptions } from '@stepci/plugin-openapi'
Expand Down Expand Up @@ -148,6 +149,32 @@ yargs(hideBin(process.argv))
console.log(`${chalk.greenBright('Success!')} The workflow file can be found at ${argv.path}`)
renderFeedbackMessage()
})
.command('init', 'Init a Step CI workflow', yargs => {
return yargs
.positional('path', {
describe: 'workflow file path',
type: 'string',
default: 'workflow.yml'
})
},
(argv) => {
const defaultWorkflow = `version: "1.1"
name: Status Check
env:
host: example.com
tests:
example:
steps:
- name: GET request
http:
url: https://\${{env.host}}
method: GET
check:
status: /^20/`

fs.writeFileSync(argv.path, defaultWorkflow)
console.log(`${chalk.greenBright('Success!')} The workflow file can be found at ${argv.path}\nEnter ${chalk.grey('npx stepci run ' + argv.path)} to run it`)
})
.command(['$0'], false, () => {}, () => console.log(defaultText))
.parse()

Expand Down

0 comments on commit e4043bf

Please sign in to comment.