generated from JS-DevTools/template-node-typescript
-
Notifications
You must be signed in to change notification settings - Fork 74
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
11 changed files
with
280 additions
and
28 deletions.
There are no files selected for viewing
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,2 +1,3 @@ | ||
dist | ||
lib | ||
coverage |
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,23 @@ | ||
name: Set up Node.js | ||
description: Install Node.js and development dependencies | ||
|
||
inputs: | ||
node-version: | ||
description: Node.js version to install | ||
default: "18" | ||
install-command: | ||
description: Install command to run | ||
default: npm ci | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: "Install Node.js" | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ inputs.node-version }} | ||
cache: npm | ||
|
||
- name: "Install development dependencies" | ||
shell: bash | ||
run: ${{ inputs.install-command }} |
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 |
---|---|---|
|
@@ -44,3 +44,4 @@ pids | |
# Test output | ||
/.nyc_output | ||
/coverage | ||
/e2e/fixture |
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,3 +1,5 @@ | ||
dist | ||
lib | ||
coverage | ||
.nyc_output | ||
package-lock.json |
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,31 @@ | ||
#!/usr/bin/env bash | ||
# Login into the registry and extract the auth token | ||
# Usage: 00-login.sh | ||
|
||
set -e | ||
|
||
REGISTRY_HOSTNAME="localhost:4873" | ||
|
||
registry_url=http://${REGISTRY_HOSTNAME} | ||
token_matcher='^\/\/'${REGISTRY_HOSTNAME}'\/:_authToken="(.+)"$' | ||
temporary_dir=${RUNNER_TEMP:-${TMPDIR}} | ||
npmrc=${temporary_dir}.npmrc-e2e | ||
|
||
{ | ||
echo -e "test" | ||
sleep 1 | ||
echo -e "test" | ||
} | NPM_CONFIG_USERCONFIG=${npmrc} npm login --registry ${registry_url} > /dev/null 2>&1 | ||
|
||
echo "DEBUG: wrote config to temporary file: ${npmrc}" 1>&2 | ||
|
||
npmrc_contents=$(<${npmrc}) | ||
rm -f ${npmrc} | ||
|
||
if [[ "${npmrc_contents}" =~ ${token_matcher} ]]; then | ||
echo "${BASH_REMATCH[1]}" | ||
exit 0 | ||
fi | ||
|
||
echo "ERROR: No token found" 1>&2 | ||
exit 1 |
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,20 @@ | ||
#!/usr/bin/env bash | ||
# Create a test fixture package | ||
# Usage: 01-setup-package.sh <package_directory> <version> | ||
|
||
set -e | ||
|
||
PACKAGE_SPEC=$1 | ||
PACKAGE_VERSION=$2 | ||
|
||
package_manifest=${PACKAGE_SPEC}/package.json | ||
|
||
mkdir -p ${PACKAGE_SPEC} | ||
|
||
echo "{" > ${package_manifest} | ||
echo " \"name\": \"@jsdevtools/fixture\"," >> ${package_manifest} | ||
echo " \"version\": \"${PACKAGE_VERSION}\"" >> ${package_manifest} | ||
echo "}" >> ${package_manifest} | ||
|
||
echo "DEBUG: wrote ${package_manifest}" 1>&2 | ||
echo ${PACKAGE_SPEC} |
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,11 @@ | ||
#!/usr/bin/env bash | ||
# Publish a package to the registry using the CLI | ||
# Usage: 02-publish.sh <package_directory> <token> | ||
|
||
set -e | ||
|
||
REGISTRY_URL="http://localhost:4873" | ||
PACKAGE_SPEC=$1 | ||
TOKEN=$2 | ||
|
||
node ./bin/npm-publish --token=${TOKEN} --registry=${REGISTRY_URL} ${PACKAGE_SPEC}/package.json |
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,13 @@ | ||
#!/usr/bin/env bash | ||
# Verify that a package was published | ||
# Usage: 03-verify.sh <package_directory> | ||
|
||
set -e | ||
|
||
REGISTRY_URL="http://localhost:4873" | ||
PACKAGE_SPEC=$1 | ||
|
||
package_name=$(cd $1 && npm pkg get name | sed 's/"//g') | ||
package_version=$(cd $1 && npm pkg get version | sed 's/"//g') | ||
|
||
npm view $package_name@$package_version |
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,44 @@ | ||
# End-to-end tests | ||
|
||
This directory contains scripts to run end-to-end tests against a locally running [Verdaccio][] registry. | ||
|
||
These test are run automatically in CI, but can be run locally, too. | ||
|
||
[Verdaccio]: https://verdaccio.org/ | ||
|
||
## Usage | ||
|
||
### Launch a Verdaccio registry | ||
|
||
We use Docker to run a default instance of the Verdaccio server. | ||
|
||
```shell | ||
docker run -it --rm --name verdaccio -p 4873:4873 verdaccio/verdaccio | ||
``` | ||
|
||
### Setup | ||
|
||
Login to the local registry and create a fixture package. | ||
|
||
```shell | ||
export TOKEN=$(./e2e/00-login.sh) | ||
export PACKAGE=$(./e2e/01-setup-package.sh ./e2e/fixture 0.0.1) | ||
``` | ||
|
||
### Test the CLI | ||
|
||
1. Publish the package to the registry. | ||
2. Verify the package was published. | ||
3. Try to publish again, verify publish is skipped. | ||
4. Create a new version. | ||
5. Publish the new version. | ||
6. Verify the new version was published. | ||
|
||
```shell | ||
./e2e/02-publish.sh ${PACKAGE} ${TOKEN} | ||
./e2e/03-verify.sh ${PACKAGE} | ||
./e2e/02-publish.sh ${PACKAGE} ${TOKEN} | ||
./e2e/01-setup-package.sh ${PACKAGE} 0.0.2 | ||
./e2e/02-publish.sh ${PACKAGE} ${TOKEN} | ||
./e2e/03-verify.sh ${PACKAGE} | ||
``` |
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