From 26e2c8772bdfa16a90f5b98110b38040a7f52b62 Mon Sep 17 00:00:00 2001 From: bryantson <5396174+bryantson@users.noreply.github.com> Date: Wed, 25 May 2022 09:26:41 -0500 Subject: [PATCH] Sample NPM --- ghpr-demo-code/Maven/README.md | 38 ++++++++++++++++++++++++++++ ghpr-demo-code/Maven/pom.xml | 2 +- ghpr-demo-code/NPM/.npmrc | 3 +++ ghpr-demo-code/NPM/Dockerfile | 11 ++++++++ ghpr-demo-code/NPM/index.js | 7 +++++ ghpr-demo-code/NPM/package-lock.json | 5 ++++ ghpr-demo-code/NPM/package.json | 12 +++++++++ ghpr-demo-code/README.md | 8 ++++++ 8 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 ghpr-demo-code/NPM/.npmrc create mode 100644 ghpr-demo-code/NPM/Dockerfile create mode 100644 ghpr-demo-code/NPM/index.js create mode 100644 ghpr-demo-code/NPM/package-lock.json create mode 100644 ghpr-demo-code/NPM/package.json create mode 100644 ghpr-demo-code/README.md diff --git a/ghpr-demo-code/Maven/README.md b/ghpr-demo-code/Maven/README.md index 348fc3b..ac4311e 100644 --- a/ghpr-demo-code/Maven/README.md +++ b/ghpr-demo-code/Maven/README.md @@ -2,3 +2,41 @@ Follow documentation here: +Make sure to update `YOUR_PACKAGE_ORG/YOUR PACKAGE_REPO` in `pom.xml` file. And you need to update `~/.m2/settings.xml` file to include your PAT token and to change your organization name and repo name. + +## Sample .m2 file + +```xml + + + + github + + + + + github + + + github + https://maven.pkg.github.com/YOUR_ORGANIZATION_NAME_PACKAGE/YOUR_REPO_NAME + + false + + + + + + + + + github + YOUR_GITHUB_USER_NAME + YOUR_TOKEN_WITH_PACKAGE_PERMISSION + + + +``` diff --git a/ghpr-demo-code/Maven/pom.xml b/ghpr-demo-code/Maven/pom.xml index 5b57c57..0f15172 100644 --- a/ghpr-demo-code/Maven/pom.xml +++ b/ghpr-demo-code/Maven/pom.xml @@ -77,7 +77,7 @@ YOUR_PACKAGE_ID Some description for your package name/name> - https://maven.pkg.github.com/YOUR_PACKAGE_ORG/YOOUR PACKAGE_REPO + https://maven.pkg.github.com/YOUR_PACKAGE_ORG/YOUR PACKAGE_REPO diff --git a/ghpr-demo-code/NPM/.npmrc b/ghpr-demo-code/NPM/.npmrc new file mode 100644 index 0000000..5df9509 --- /dev/null +++ b/ghpr-demo-code/NPM/.npmrc @@ -0,0 +1,3 @@ +//npm.pkg.github.com/:_authToken=REPLACE WITH YOUR TOKEN with Package Permission +@REPLACE_WITH_YOUR_ORG_NAME:registry=https://npm.pkg.github.com + diff --git a/ghpr-demo-code/NPM/Dockerfile b/ghpr-demo-code/NPM/Dockerfile new file mode 100644 index 0000000..6882da3 --- /dev/null +++ b/ghpr-demo-code/NPM/Dockerfile @@ -0,0 +1,11 @@ +FROM ghcr.io/REPLACE_WITH_YOUR_ORG_NAME/REPLACE_WITH_YOUR_IMAGE_NAME:REPLACE_WITH_YOUR_IMAGE_VERSION + +WORKDIR /app + +COPY ["package.json", "package-lock.json", "./"] + +RUN npm install + +COPY . . + +CMD ["npm","test"] \ No newline at end of file diff --git a/ghpr-demo-code/NPM/index.js b/ghpr-demo-code/NPM/index.js new file mode 100644 index 0000000..8533735 --- /dev/null +++ b/ghpr-demo-code/NPM/index.js @@ -0,0 +1,7 @@ +function randomNoGenerator(min, max) { + if(typeof(max) !== 'number' && typeof(min) !== 'number') { + min = 0; max = 1; + } + return (Math.random() * (max-min)) + min; +} +module.exports = randomNoGenerator; diff --git a/ghpr-demo-code/NPM/package-lock.json b/ghpr-demo-code/NPM/package-lock.json new file mode 100644 index 0000000..dfbeee4 --- /dev/null +++ b/ghpr-demo-code/NPM/package-lock.json @@ -0,0 +1,5 @@ +{ + "name": "@REPLACE_WITH_YOUR_ORG_NAME/random-num", + "version": "1.0.0", + "lockfileVersion": 1 +} diff --git a/ghpr-demo-code/NPM/package.json b/ghpr-demo-code/NPM/package.json new file mode 100644 index 0000000..999752a --- /dev/null +++ b/ghpr-demo-code/NPM/package.json @@ -0,0 +1,12 @@ +{ + "name": "@REPLACE_WITH_YOUR_ORG_NAME/random-num", + "version": "1.0.0", + "description": "This is a sample test for GitHub NPM", + "main": "index.js", + "repository": "git@github.com:REPLACE_WITH_YOUR_ORG_NAME/REPLACE_WITH_YOUR_REPO_NAME.git", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC" +} diff --git a/ghpr-demo-code/README.md b/ghpr-demo-code/README.md new file mode 100644 index 0000000..fabc10d --- /dev/null +++ b/ghpr-demo-code/README.md @@ -0,0 +1,8 @@ +# GitHub Package Demo codes + +This directory contains sample codes to test your GitHub Package + +| Directory | Description | +| ---- | ----------- | +| [Maven](Maven) | Sample Maven code to use GitHub Package | +| [NPM](NPM) | Sample NPM code to use GitHub Package | \ No newline at end of file