Skip to content

Commit

Permalink
Merge pull request #1 from hardillb/hardillb-patch-1
Browse files Browse the repository at this point in the history
Allow upstream registry to be on HTTPS
  • Loading branch information
hardillb committed Sep 22, 2023
2 parents 7d3ecb7 + 91b8766 commit fd7b82b
Show file tree
Hide file tree
Showing 6 changed files with 563 additions and 297 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules/
temp/
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The container takes the following Environment variables:

- PORT - Which port to listen on (defaults to `3000`)
- HOST - Which local IP Address to bind to (defaults to `0.0.0.0`)
- REGISTRY - A host and optional port number to connect to the NPM registry (defaults to `registry:4873`)
- REGISTRY - A host and optional port number to connect to the NPM registry (defaults to `http:https://registry:4873`)
- KEYWORD - The npm keyword to filter on (defaults to `node-red`)

It presents 2 HTTP endpoints
Expand Down Expand Up @@ -68,4 +68,4 @@ $ docker push private.example.com/catalogue
env:
- name: REGISTRY
value: 'registry:4873'
```
```
15 changes: 8 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ const nodeRedModule = require('node-red-module-parser')

const port = (process.env.PORT || 80)
const listenHost = (process.env.HOST || '0.0.0.0')
const registryHost = (process.env.REGISTRY || 'registry:4873')
const registryHost = (process.env.REGISTRY || 'http:https://registry:4873')
const keyword = (process.env.KEYWORD || "node-red")

const url = "http:https://" + registryHost + "/-/all"
const url = registryHost + "/-/all"

const catalogue = {
"name":"Ben's custom catalogue",
Expand Down Expand Up @@ -60,12 +60,13 @@ function update() {
let latest = details.body['dist-tags'].latest
let version = details.body.versions[latest]
let tar = version.dist.tarball
fs.mkdirSync(path.dirname(path.join("temp", nodeNames[node])))
let tarPath = path.join('temp', nodeNames[node] + ".tgz")
let tarDir = path.join("temp", nodeNames[node])
fs.mkdirSync(tarDir,{recursive: true})
let tarPath = path.join(tarDir, nodeNames[node].split('/').slice(-1) + ".tgz")
let tarRes = await superagent.get(tar).responseType('blob')
fs.writeFileSync(tarPath, tarRes.body)
let moduleDetails = nodeRedModule.examinTar(tarPath, "temp")
fs.rmSync(tarPath)
let moduleDetails = nodeRedModule.examinTar(tarPath, tarDir)
fs.rmSync(tarDir, {force: true, recursive: true})

var entry = {
id: n.name,
Expand All @@ -76,7 +77,7 @@ function update() {
url: "http:https://" + registryHost + "/-/web/details/" + n.name
}

if (moduleDetails.types) {
if (moduleDetails.types.length) {
entry.types = moduleDetails.types
}
if (moduleDetails["node-red"]) {
Expand Down
Loading

0 comments on commit fd7b82b

Please sign in to comment.