-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
305 additions
and
110 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
name: NPM | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
build: | ||
name: Build | ||
strategy: | ||
matrix: | ||
os: | ||
- ubuntu-latest | ||
node-version: | ||
- 16 | ||
|
||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: npm | ||
cache-dependency-path: package.json | ||
|
||
- name: Install Dependencies | ||
run: npm install | ||
|
||
- name: Test | ||
run: npm test | ||
|
||
pack: | ||
name: Pack | ||
needs: build | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node-version: | ||
- 16 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: npm | ||
cache-dependency-path: package.json | ||
|
||
- name: Install Dependencies | ||
run: npm install | ||
|
||
- name: Generate Package version | ||
run: ./scripts/generate-version.sh | ||
|
||
- name: Pack Testing | ||
run: ./scripts/npm-pack-testing.sh | ||
|
||
publish: | ||
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/v')) | ||
name: Publish | ||
needs: | ||
- build | ||
- pack | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: 16 | ||
registry-url: https://registry.npmjs.org/ | ||
cache: npm | ||
cache-dependency-path: package.json | ||
|
||
- name: Install Dependencies | ||
run: npm install | ||
|
||
- name: Generate Package version | ||
run: ./scripts/generate-version.sh | ||
|
||
- name: Set Publish Config | ||
run: ./scripts/package-publish-config-tag.sh | ||
|
||
- name: Build Dist | ||
run: npm run dist | ||
|
||
- name: Check Branch | ||
id: check-branch | ||
run: | | ||
if [[ ${{ github.ref }} =~ ^refs/heads/(main|v[0-9]+\.[0-9]+.*)$ ]]; then | ||
echo ::set-output name=match::true | ||
fi # See: https://stackoverflow.com/a/58869470/1123955 | ||
- name: Is A Publish Branch | ||
if: steps.check-branch.outputs.match == 'true' | ||
run: | | ||
NAME=$(npx pkg-jq -r .name) | ||
VERSION=$(npx pkg-jq -r .version) | ||
if npx version-exists "$NAME" "$VERSION" | ||
then echo "$NAME@$VERSION exists on NPM, skipped." | ||
else npm publish | ||
fi | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
- name: Is Not A Publish Branch | ||
if: steps.check-branch.outputs.match != 'true' | ||
run: echo 'Not A Publish Branch' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,67 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
VERSION=$(npx pkg-jq -r .version) | ||
|
||
if npx --package @chatie/semver semver-is-prod "$VERSION"; then | ||
NPM_TAG=latest | ||
else | ||
NPM_TAG=next | ||
fi | ||
|
||
npm run dist | ||
npm run pack | ||
npm pack | ||
|
||
TMPDIR="/tmp/npm-pack-testing.$$" | ||
mkdir "$TMPDIR" | ||
mv *-*.*.*.tgz "$TMPDIR" | ||
trap "rm -fr '$TMPDIR'" EXIT | ||
|
||
mv ./*-*.*.*.tgz "$TMPDIR" | ||
cp tests/fixtures/smoke-testing.ts "$TMPDIR" | ||
|
||
cd $TMPDIR | ||
|
||
npm init -y | ||
npm install *-*.*.*.tgz \ | ||
@types/node \ | ||
typescript | ||
npm install --production ./*-*.*.*.tgz \ | ||
@chatie/tsconfig@$NPM_TAG \ | ||
pkg-jq \ | ||
|
||
./node_modules/.bin/tsc \ | ||
# | ||
# CommonJS | ||
# | ||
npx tsc \ | ||
--target es6 \ | ||
--module CommonJS \ | ||
\ | ||
--moduleResolution node \ | ||
--esModuleInterop \ | ||
--lib esnext \ | ||
--noEmitOnError \ | ||
--noImplicitAny \ | ||
--target es6 \ | ||
--module commonjs \ | ||
--skipLibCheck \ | ||
smoke-testing.ts | ||
|
||
echo | ||
echo "CommonJS: pack testing..." | ||
node smoke-testing.js | ||
|
||
# | ||
# ES Modules | ||
# | ||
npx pkg-jq -i '.type="module"' | ||
|
||
npx tsc \ | ||
--target es2020 \ | ||
--module es2020 \ | ||
\ | ||
--moduleResolution node \ | ||
--esModuleInterop \ | ||
--lib esnext \ | ||
--noEmitOnError \ | ||
--noImplicitAny \ | ||
--skipLibCheck \ | ||
smoke-testing.ts | ||
|
||
echo | ||
echo "ES Module: pack testing..." | ||
node smoke-testing.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { | ||
Watchdog, | ||
WatchdogFood, | ||
} from './watchdog.js' | ||
import { | ||
VERSION, | ||
} from './version.js' | ||
|
||
export type { | ||
WatchdogFood, | ||
} | ||
export { | ||
VERSION, | ||
Watchdog, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
#!/usr/bin/env ts-node | ||
#!/usr/bin/env -S node --no-warnings --loader ts-node/esm | ||
|
||
// tslint:disable:no-shadowed-variable | ||
import test from 'blue-tape' | ||
import { test } from 'tstest' | ||
|
||
import { VERSION } from './version' | ||
import { VERSION } from './version.js' | ||
|
||
test('Make sure the VERSION is fresh in source code', async (t) => { | ||
test('Make sure the VERSION is fresh in source code', async t => { | ||
t.equal(VERSION, '0.0.0', 'version should be 0.0.0 in source code, only updated before publish to NPM') | ||
}) |
Oops, something went wrong.