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

Automatic publishing with lerna #133

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 6 additions & 4 deletions .github/workflows/ci.yaml
Expand Up @@ -11,9 +11,11 @@ jobs:
node-version:
- 16
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm test
- name: Install dependencies
run: yarn
- name: Run tests
run: yarn run test
8 changes: 8 additions & 0 deletions .gitignore
Expand Up @@ -3,3 +3,11 @@ node_modules

# logs
npm-debug.log
yarn-error.log

# coverage
coverage
.nyc_output

# build
dist/
2 changes: 2 additions & 0 deletions .npmrc
@@ -0,0 +1,2 @@
save-exact = true
strict-peer-dependencies=false
70 changes: 0 additions & 70 deletions README.md

This file was deleted.

1 change: 1 addition & 0 deletions README.md
21 changes: 21 additions & 0 deletions lerna.json
@@ -0,0 +1,21 @@
{
"npmClient": "yarn",
"useWorkspaces": true,
"packages": [
"packages/*"
],
"command": {
"version": {
"exact": true
},
"publish": {
"npmClient": "npm",
"allowBranch": [
"master",
"canary"
],
"registry": "https://registry.npmjs.org/"
}
},
"version": "9.4.0"
}
47 changes: 9 additions & 38 deletions package.json
@@ -1,46 +1,17 @@
{
"name": "micro-dev",
"version": "3.1.0",
"main": "./lib/index.js",
"files": [
"bin",
"lib"
"private": true,
"workspaces": [
"packages/*",
"test"
],
"scripts": {
"test": "vitest"
"prepublish": "lerna run prepublish",
"publish-canary": "lerna version prerelease --preid canary --force-publish && release --pre",
"publish-stable": "lerna version --force-publish",
"test": "cd test && yarn run test"
},
"bin": {
"micro-dev": "./bin/micro-dev.js"
},
"repository": "vercel/micro-dev",
"license": "MIT",
"keywords": [
"micro",
"development",
"service",
"microservice",
"serverless",
"API"
],
"dependencies": {
"boxen": "1.3.0",
"chalk": "2.4.1",
"chokidar": "3.5.3",
"clipboardy": "1.2.3",
"debounce": "1.1.0",
"dotenv": "5.0.1",
"get-port": "3.2.0",
"ip": "1.1.5",
"jsome": "2.5.0",
"mri": "1.1.1",
"pkg-up": "2.0.0",
"pretty-error": "4.0.0",
"string-length": "2.0.0"
},
"devDependencies": {
"vitest": "0.17.0"
},
"peerDependencies": {
"micro": ">=9.0.0"
"lerna": "^3.4.0"
}
}
70 changes: 70 additions & 0 deletions packages/micro-dev/README.md
@@ -0,0 +1,70 @@
# Micro (Dev) — Asynchronous HTTP microservices

This command line interface provides a belt full of tools that make building microservices using [micro](https://github.com/vercel/micro) a breeze! It's only meant to be used in development, **not in production** (that's where [micro](https://github.com/vercel/micro) comes in).

## Features

- **Hot Reloading:** When making changes to your code, the server will restart by itself
- **Logs:** Incoming and outgoing requests will be logged to `stdout`
- **Beautiful JSON:** When JSON bodies are logged, they're styled and prettified
- **Clipboard Support:** The local address is pasted to the clipboard automatically
- **Port Selection:** Automatic detection and use of an open port (if the specified one is in use)
- **Debug in Your Network:** The network address shown in addition to local one
- **Duration Logs:** Calculates and shows the duration for each request
- **Pretty Errors:** Prettifies the `Error` object if any exceptions are thrown

## Usage

**Important:** This tool is only meant to be used in development. In production, you should use [micro](https://github.com/vercel/micro), which is much lighter and faster (and also comes without the belt of tools used when developing microservices).

When preparing your development environment, firstly install `micro-dev`:

```bash
npm install --save-dev micro-dev
```

**Note:** You'll need at least Node.js v7.6.0 to run `micro-dev`.

Next, add a new `script` property below `micro` inside `package.json`:

```json
"scripts": {
"start": "micro",
"dev": "micro-dev"
}
```

As the final step, start the development server like this:

```bash
npm run dev
```

## Debugging

The package can be used in conjunction with the Node.js inspector like this:

```json
"scripts": {
"inspect": "node --inspect node_modules/.bin/micro-dev"
}
```

As the final step, start the development server like this:

```bash
npm run inspect
```

## Contributing

1. [Fork](https://help.github.com/articles/fork-a-repo/) this repository to your own GitHub account and then [clone](https://help.github.com/articles/cloning-a-repository/) it to your local device
2. Move into the directory of the clone: `cd micro-dev`
3. Link it to the global module directory of Node.js: `npm link`

Inside the project where you want to test your clone of the package, you can now either use `npm link micro-dev` to link the cloned source to your project's local dependencies or run `micro-dev` right in your terminal.

## Authors

- Leo Lamprecht ([@notquiteleo](https://twitter.com/notquiteleo))
- Tim Neutkens ([@timneutkens](https://twitter.com/timneutkens)) - [Vercel](https://vercel.com)
40 changes: 40 additions & 0 deletions packages/micro-dev/package.json
@@ -0,0 +1,40 @@
{
"name": "micro-dev",
"version": "3.1.0",
"main": "./src/lib/index.js",
"files": [
"bin",
"lib"
],
"bin": {
"micro-dev": "./src/bin/micro-dev.js"
},
"repository": "vercel/micro-dev",
"license": "MIT",
"keywords": [
"micro",
"development",
"service",
"microservice",
"serverless",
"API"
],
"dependencies": {
"boxen": "1.3.0",
"chalk": "2.4.1",
"chokidar": "3.5.3",
"clipboardy": "1.2.3",
"debounce": "1.1.0",
"dotenv": "5.0.1",
"get-port": "3.2.0",
"ip": "1.1.5",
"jsome": "2.5.0",
"mri": "1.1.1",
"pkg-up": "2.0.0",
"pretty-error": "4.0.0",
"string-length": "2.0.0"
},
"peerDependencies": {
"micro": ">=9.0.0"
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions test/help.test.js
@@ -1,7 +1,7 @@
import { expect, it } from 'vitest'
import generateHelp from '../lib/help'
import generateHelp from 'micro-dev/src/lib/help'

it('--help', () => {
const result = generateHelp()
expect(result).toMatchSnapshot()
})
})
11 changes: 11 additions & 0 deletions test/package.json
@@ -0,0 +1,11 @@
{
"name": "test",
"version": "1.0.0",
"scripts": {
"test": "vitest"
},
"devDependencies": {
"vitest": "0.17.0",
"micro-dev": "*"
}
}