Skip to content

Commit

Permalink
Sample NPM
Browse files Browse the repository at this point in the history
  • Loading branch information
bryantson committed May 25, 2022
1 parent 0ce6134 commit 26e2c87
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 1 deletion.
38 changes: 38 additions & 0 deletions ghpr-demo-code/Maven/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,41 @@

Follow documentation here: <https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-apache-maven-registry>

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
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">

<activeProfiles>
<activeProfile>github</activeProfile>
</activeProfiles>

<profiles>
<profile>
<id>github</id>
<repositories>
<repository>
<id>github</id>
<url>https://maven.pkg.github.com/YOUR_ORGANIZATION_NAME_PACKAGE/YOUR_REPO_NAME</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>

<servers>
<server>
<id>github</id>
<username>YOUR_GITHUB_USER_NAME</username>
<password>YOUR_TOKEN_WITH_PACKAGE_PERMISSION</password>
</server>
</servers>
</settings>
```
2 changes: 1 addition & 1 deletion ghpr-demo-code/Maven/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
<repository>
<id>YOUR_PACKAGE_ID</id>
<name>Some description for your package name/name>
<url>https://maven.pkg.github.com/YOUR_PACKAGE_ORG/YOOUR PACKAGE_REPO</url>
<url>https://maven.pkg.github.com/YOUR_PACKAGE_ORG/YOUR PACKAGE_REPO</url>
</repository>
</distributionManagement>

Expand Down
3 changes: 3 additions & 0 deletions ghpr-demo-code/NPM/.npmrc
Original file line number Diff line number Diff line change
@@ -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

11 changes: 11 additions & 0 deletions ghpr-demo-code/NPM/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
7 changes: 7 additions & 0 deletions ghpr-demo-code/NPM/index.js
Original file line number Diff line number Diff line change
@@ -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;
5 changes: 5 additions & 0 deletions ghpr-demo-code/NPM/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions ghpr-demo-code/NPM/package.json
Original file line number Diff line number Diff line change
@@ -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": "[email protected]:REPLACE_WITH_YOUR_ORG_NAME/REPLACE_WITH_YOUR_REPO_NAME.git",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
8 changes: 8 additions & 0 deletions ghpr-demo-code/README.md
Original file line number Diff line number Diff line change
@@ -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 |

0 comments on commit 26e2c87

Please sign in to comment.