Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release/v2.0.0 #6

Draft
wants to merge 14 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
root = true

[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/lib
6 changes: 6 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": [
"oclif",
"oclif-typescript"
]
}
3 changes: 3 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ jobs:
with:
node-version: 12
- run: npm ci
- run: ./bin/run --version
- run: ./bin/run --help
- run: npm test
- run: npm run test:library

publish-npm:
needs: build
Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This workflow will do a clean install of node dependencies and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: test

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [8.x, 10.x, 12.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: ./bin/run --version
- run: ./bin/run --help
- run: npm test
- run: npm run test:library
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Ignore generated directories
tmp/
lib/
dist/
exec/

Expand Down
181 changes: 159 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,18 @@ Resource and domain modeling for quick APIs, CMSs, and applications.

![GitHub last commit](https://img.shields.io/github/last-commit/khalidx/resource-x.svg?style=flat-square)

[![oclif](https://img.shields.io/badge/cli-oclif-brightgreen.svg)](https://oclif.io)
[![Version](https://img.shields.io/npm/v/@khalidx/resource-x.svg)](https://npmjs.org/package/@khalidx/resource-x)
[![Downloads/week](https://img.shields.io/npm/dw/@khalidx/resource-x.svg)](https://npmjs.org/package/@khalidx/resource-x)
[![License](https://img.shields.io/npm/l/@khalidx/resource-x.svg)](https://github.com/khalidx/resource-x/blob/master/package.json)

## Quick start

Deploy an API to the cloud **in under 30 seconds**, *in just 3 steps*.

![tutorial](./tutorial.gif)

1) Build your domain objects as JSON Schemas, all in the same Markdown document. Alternatively, run `rx init` to get a [ready-to-use document](./sample.md) with two sample schemas.
1) Build your domain objects as JSON Schemas, all in the same Markdown document. Alternatively, run `rx init` to get a [ready-to-use document](./example/sample.md) with two sample schemas.

2) When you run `rx generate sample.md`, you'll get a full CRUD (create-read-update-delete) Swagger specification for your API.

Expand Down Expand Up @@ -48,47 +53,179 @@ Windows, Mac, and Linux are all supported.

## Usage

Initialize a new sample project in the current directory.
<!-- toc -->
* [resource-x](#resource-x)
* [Usage](#usage)
* [Commands](#commands)
<!-- tocstop -->
# Usage
<!-- usage -->
```sh-session
$ npm install -g @khalidx/resource-x
$ rx COMMAND
running command...
$ rx (-v|--version|version)
@khalidx/resource-x/2.0.0 darwin-x64 node-v12.16.3
$ rx --help [COMMAND]
USAGE
$ rx COMMAND
...
```
<!-- usagestop -->
# Commands
<!-- commands -->
- [resource-x](#resource-x)
- [Quick start](#quick-start)
- [Features](#features)
- [Installation](#installation)
- [Usage](#usage)
- [Usage](#usage-1)
- [Commands](#commands)
- [`rx browse [FILE]`](#rx-browse-file)
- [`rx clean [FILE]`](#rx-clean-file)
- [`rx deploy [FILE]`](#rx-deploy-file)
- [`rx generate [FILE]`](#rx-generate-file)
- [`rx hello [FILE]`](#rx-hello-file)
- [`rx help [COMMAND]`](#rx-help-command)
- [`rx init [FILE]`](#rx-init-file)
- [`rx undeploy [FILE]`](#rx-undeploy-file)
- [Pro tips and tricks](#pro-tips-and-tricks)
- [Support](#support)

## `rx browse [FILE]`

describe the command here

```sh
rx init
```
Generate an API specification from the document file.
USAGE
$ rx browse [FILE]

```sh
rx generate <file>
OPTIONS
-f, --force
-h, --help show CLI help
-n, --name=name name to print
```

Opens the browser to view the resources in the document file.
_See code: [src/commands/browse.ts](https://github.com/khalidx/resource-x/blob/v2.0.0/src/commands/browse.ts)_

## `rx clean [FILE]`

describe the command here

```sh
rx browse <file>
```
USAGE
$ rx clean [FILE]

Deploy the API with mock integration to AWS API Gateway.
OPTIONS
-f, --force
-h, --help show CLI help
-n, --name=name name to print
```

_See code: [src/commands/clean.ts](https://github.com/khalidx/resource-x/blob/v2.0.0/src/commands/clean.ts)_

## `rx deploy [FILE]`

describe the command here

```sh
rx deploy <file>
```
USAGE
$ rx deploy [FILE]

Undeploy the API from AWS API Gateway.
OPTIONS
-f, --force
-h, --help show CLI help
-n, --name=name name to print
```

_See code: [src/commands/deploy.ts](https://github.com/khalidx/resource-x/blob/v2.0.0/src/commands/deploy.ts)_

## `rx generate [FILE]`

describe the command here

```sh
rx undeploy <file>
```
USAGE
$ rx generate [FILE]

Remove the generated .rx/ directory.
OPTIONS
-f, --force
-h, --help show CLI help
-n, --name=name name to print
```

_See code: [src/commands/generate.ts](https://github.com/khalidx/resource-x/blob/v2.0.0/src/commands/generate.ts)_

## `rx hello [FILE]`

describe the command here

```sh
rx clean
```
USAGE
$ rx hello [FILE]

See help and usage information about all available commands.
OPTIONS
-f, --force
-h, --help show CLI help
-n, --name=name name to print

```sh
rx --help
EXAMPLE
$ rx hello
hello world from ./src/hello.ts!
```

_See code: [src/commands/hello.ts](https://github.com/khalidx/resource-x/blob/v2.0.0/src/commands/hello.ts)_

## `rx help [COMMAND]`

display help for rx

```
USAGE
$ rx help [COMMAND]

ARGUMENTS
COMMAND command to show help for

OPTIONS
--all see all commands in CLI
```

_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v2.2.3/src/commands/help.ts)_

## `rx init [FILE]`

describe the command here

```
USAGE
$ rx init [FILE]

OPTIONS
-f, --force
-h, --help show CLI help
-n, --name=name name to print
```

_See code: [src/commands/init.ts](https://github.com/khalidx/resource-x/blob/v2.0.0/src/commands/init.ts)_

## `rx undeploy [FILE]`

describe the command here

```
USAGE
$ rx undeploy [FILE]

OPTIONS
-f, --force
-h, --help show CLI help
-n, --name=name name to print
```

_See code: [src/commands/undeploy.ts](https://github.com/khalidx/resource-x/blob/v2.0.0/src/commands/undeploy.ts)_
<!-- commandsstop -->

## Pro tips and tricks

- Commit the `.rx/**/deploy.json` files. These track your AWS API Gateway deployments, so that you don't end up creating a new API every time you check out from git and deploy.
Expand Down
5 changes: 5 additions & 0 deletions bin/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env node

require('@oclif/command').run()
.then(require('@oclif/command/flush'))
.catch(require('@oclif/errors/handle'))
3 changes: 3 additions & 0 deletions bin/run.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@echo off

node "%~dp0\run" %*
20 changes: 20 additions & 0 deletions example/contacts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# The Contacts API

Here's how a contact should be defined:

```yaml
contact:
type: object
required:
- name
properties:
name:
type: string
description: The contact's full name
email:
type: string
description: The contact's email address
phone:
type: string
description: The contact's phone number
```
File renamed without changes.
Loading