From d3cfce8cf081ba38c1d9dbe266cd33ca924e85f2 Mon Sep 17 00:00:00 2001 From: Jonathan Clem Date: Mon, 22 Apr 2019 11:54:05 -0400 Subject: [PATCH] Simplify package creation --- README.md | 12 +++--------- package.json | 1 + scripts/create-package | 13 +++++++++++++ 3 files changed, 17 insertions(+), 9 deletions(-) create mode 100755 scripts/create-package diff --git a/README.md b/README.md index 751004e5..034e050d 100644 --- a/README.md +++ b/README.md @@ -27,18 +27,12 @@ This repository uses [Lerna](https://github.com/lerna/lerna#readme) to manage mu 1. In a new branch, create a new Lerna package: ```console -$ lerna create @actions/new-package +$ npm run create-package new-package ``` This will ask you some questions about the new package. Start with `0.0.0` as the first version (look generally at some of the other packages for how the package.json is structured). -2. Add a `tsconfig.json` file for the new package (you can probably just reuse one from another existing package): - -```console -$ cp packages/toolkit/tsconfig.json packages/new-package/tsconfig.json -``` - -3. Add `tsc` script to the new package's package.json file: +1. Add `tsc` script to the new package's package.json file: ```json "scripts": { @@ -46,4 +40,4 @@ $ cp packages/toolkit/tsconfig.json packages/new-package/tsconfig.json } ``` -4. Start developing 😄 and open a pull request. +1. Start developing 😄 and open a pull request. diff --git a/package.json b/package.json index 404c2aa8..c93a4cda 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "bootstrap": "lerna bootstrap", "build": "lerna run tsc", "format": "prettier --check packages/*/src/**/*.ts", + "new-package": "scripts/create-package", "test": "jest" }, "devDependencies": { diff --git a/scripts/create-package b/scripts/create-package new file mode 100755 index 00000000..ed38d73a --- /dev/null +++ b/scripts/create-package @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +set -eo pipefail + +name=$1 + +if [[ -z "$name" ]]; then + >&2 echo "Usage: npm run new-package [name]" + exit 1 +fi + +lerna create @actions/$name +cp packages/toolkit/tsconfig.json packages/$name/tsconfig.json \ No newline at end of file