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

Add template for npm package #40

Merged
merged 9 commits into from
Jun 11, 2020
Merged
Show file tree
Hide file tree
Changes from 5 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
1 change: 1 addition & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ jobs:
- greeter
- koa-rest-api
- lambda-sqs-worker
- private-npm-package
steps:
- name: Check out repo
uses: actions/checkout@master
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ This initialises a new directory and Git repository.
a message queue is employed between the source topic and the Lambda function,
and unprocessed events are sent to a dead-letter queue for manual triage.

- `private-npm-package`

Setup new npm modules on SEEK-jobs using semantic release pipeline.
lumishrestha marked this conversation as resolved.
Show resolved Hide resolved

- `github →` (experimental)

BYO starter repo!
Expand Down
2 changes: 2 additions & 0 deletions scripts/test-template.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ yarn skuba init << EOF
"devBuildkiteQueueName": "my-account-dev:cicd",
"devGantryEnvironmentName": "dev",
"gitHubTeamName": "@my-org/my-team",
"moduleName":"module",
"fullModuleName": "my-first-module",
"prodAwsAccountId": "000000000000",
"prodBuildkiteQueueName": "my-account-prod:cicd",
"prodGantryEnvironmentName": "prod",
Expand Down
1 change: 1 addition & 0 deletions src/cli/init/prompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export const TEMPLATE_PROMPT = new Select({
'greeter',
'koa-rest-api',
'lambda-sqs-worker',
'private-npm-package',
'github →',
] as const,
message: 'Select a template:',
Expand Down
5 changes: 5 additions & 0 deletions src/cli/release.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { exec } from '../utils/exec';

export const release = async () => {
await exec('semanticRelease', '--success', 'false');
lumishrestha marked this conversation as resolved.
Show resolved Hide resolved
};
1 change: 1 addition & 0 deletions src/utils/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const COMMAND_LIST = [
'help',
'init',
'lint',
'release',
'start',
'test',
'version',
Expand Down
4 changes: 4 additions & 0 deletions template/private-npm-package/.buildkite/pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
steps:
- command: aws s3 cp s3://seek-npm-package-buildkite-pipeline/pipeline-latest.sh - | bash | buildkite-agent pipeline upload
agents:
queue: artefacts:npm
3 changes: 3 additions & 0 deletions template/private-npm-package/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
npm-debug.log
.DS_Store
64 changes: 64 additions & 0 deletions template/private-npm-package/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# <%- moduleName %>

This project is powered by the [skuba](https://github.com/SEEK-OSS/skuba).
lumishrestha marked this conversation as resolved.
Show resolved Hide resolved

<!--

## Table of contents

- [Usage](#usage)
- [Design](#design)
- [Development](#development)
- [Support](#support)

## Usage

...

## Design

...

## Development

...

## Support

...

-->

To publish your module to npm and release notes to GitHub:

## Release

While a Buildkite pipeline for CI/CD is generated out of the box, there are some additional steps to get semantic-release working:

<https://github.com/SEEK-Jobs/npm-package-buildkite-pipeline#installing-on-your-repository>

### Releasing latest

Commits to the `master` branch will be released with the `latest` tag, which is the default used when running `npm install` or `yarn install`.

### Releasing other dist-tags

semantic-release prescribes a branch-based workflow for managing [distribution tags].

[distribution tags]: https://docs.npmjs.com/adding-dist-tags-to-packages

You can push to other branches to manage betas, maintenance updates to prior major versions, and more.

Here are some branches that semantic-release supports by default:

| Git branch | npm dist-tag |
| :--------- | :----------- |
| master | latest |
| alpha | alpha |
| beta | beta |
| next | next |
| 1.x | release-1.x |

For more information, see the semantic-release docs:

<https://github.com/semantic-release/semantic-release/#triggering-a-release>
1 change: 1 addition & 0 deletions template/private-npm-package/_.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lts/*
26 changes: 26 additions & 0 deletions template/private-npm-package/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "<%- fullModuleName %>",
"description": "<%- description %>",
"version": "0.0.0-semantically-released",
"main": "lib-commonjs",
"module": "lib-es2015",
"typings": "lib-types",
lumishrestha marked this conversation as resolved.
Show resolved Hide resolved
"files": [
"lib"
lumishrestha marked this conversation as resolved.
Show resolved Hide resolved
],
"sideEffects": false,
lumishrestha marked this conversation as resolved.
Show resolved Hide resolved
"license": "UNLICENSED",
"scripts": {
"build": "skuba build",
lumishrestha marked this conversation as resolved.
Show resolved Hide resolved
"commit": "skuba commit",
lumishrestha marked this conversation as resolved.
Show resolved Hide resolved
"format": "skuba format",
"format:check": "skuba format check",
lumishrestha marked this conversation as resolved.
Show resolved Hide resolved
"lint": "skuba lint",
"prerelease": "skuba build",
"release": "skuba release",
"test": "echo \"No tests for now\""
lumishrestha marked this conversation as resolved.
Show resolved Hide resolved
},
"repository": {
"type": "git"
lumishrestha marked this conversation as resolved.
Show resolved Hide resolved
}
}
24 changes: 24 additions & 0 deletions template/private-npm-package/skuba.template.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Run `skuba configure` to finish templating and remove this file.
*/

module.exports = {
entryPoint: 'src/index.ts',
fields: [
{
name: 'moduleName',
message: 'Module name',
initial: 'module',
lumishrestha marked this conversation as resolved.
Show resolved Hide resolved
},
{
name: 'fullModuleName',
lumishrestha marked this conversation as resolved.
Show resolved Hide resolved
message: 'Full module name',
initial: 'my-first-module',
},
{
name: 'description',
message: 'Description',
initial: 'This is my first module',
},
],
};
4 changes: 4 additions & 0 deletions template/private-npm-package/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default (): void => {
lumishrestha marked this conversation as resolved.
Show resolved Hide resolved
/* eslint-disable-next-line no-console */
console.log('<%- moduleName %>');
};