Compare commits
22 Commits
Author | SHA1 | Date | |
---|---|---|---|
37d69e201e | |||
afa511550d | |||
e0a9e9702a | |||
85f5985249 | |||
e337241dd6 | |||
a7a1343e3c | |||
f54402aa1e | |||
b7ecd5a6b7 | |||
ba57be2fe5 | |||
2b308e8824 | |||
0b1b6deb98 | |||
d5636aaf9a | |||
0276faa949 | |||
c0d64926a0 | |||
7737014464 | |||
349360cdc6 | |||
983a860e2f | |||
c375d9ba10 | |||
e874c935bb | |||
001a79252c | |||
634d1c3570 | |||
cd8c9bcdaa |
66
.gitea/workflows/default_nottags.yaml
Normal file
66
.gitea/workflows/default_nottags.yaml
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
name: Default (not tags)
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags-ignore:
|
||||||
|
- '**'
|
||||||
|
|
||||||
|
env:
|
||||||
|
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
|
||||||
|
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
|
||||||
|
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
|
||||||
|
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
|
||||||
|
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
security:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
continue-on-error: true
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Install pnpm and npmci
|
||||||
|
run: |
|
||||||
|
pnpm install -g pnpm
|
||||||
|
pnpm install -g @shipzone/npmci
|
||||||
|
|
||||||
|
- name: Run npm prepare
|
||||||
|
run: npmci npm prepare
|
||||||
|
|
||||||
|
- name: Audit production dependencies
|
||||||
|
run: |
|
||||||
|
npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
npmci command pnpm audit --audit-level=high --prod
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
- name: Audit development dependencies
|
||||||
|
run: |
|
||||||
|
npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
npmci command pnpm audit --audit-level=high --dev
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
test:
|
||||||
|
if: ${{ always() }}
|
||||||
|
needs: security
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Test stable
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm install
|
||||||
|
npmci npm test
|
||||||
|
|
||||||
|
- name: Test build
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm install
|
||||||
|
npmci npm build
|
124
.gitea/workflows/default_tags.yaml
Normal file
124
.gitea/workflows/default_tags.yaml
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
name: Default (tags)
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- '*'
|
||||||
|
|
||||||
|
env:
|
||||||
|
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
|
||||||
|
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
|
||||||
|
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
|
||||||
|
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
|
||||||
|
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
security:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
continue-on-error: true
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Prepare
|
||||||
|
run: |
|
||||||
|
pnpm install -g pnpm
|
||||||
|
pnpm install -g @shipzone/npmci
|
||||||
|
npmci npm prepare
|
||||||
|
|
||||||
|
- name: Audit production dependencies
|
||||||
|
run: |
|
||||||
|
npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
npmci command pnpm audit --audit-level=high --prod
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
- name: Audit development dependencies
|
||||||
|
run: |
|
||||||
|
npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
npmci command pnpm audit --audit-level=high --dev
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
test:
|
||||||
|
if: ${{ always() }}
|
||||||
|
needs: security
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Prepare
|
||||||
|
run: |
|
||||||
|
pnpm install -g pnpm
|
||||||
|
pnpm install -g @shipzone/npmci
|
||||||
|
npmci npm prepare
|
||||||
|
|
||||||
|
- name: Test stable
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm install
|
||||||
|
npmci npm test
|
||||||
|
|
||||||
|
- name: Test build
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm install
|
||||||
|
npmci npm build
|
||||||
|
|
||||||
|
release:
|
||||||
|
needs: test
|
||||||
|
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Prepare
|
||||||
|
run: |
|
||||||
|
pnpm install -g pnpm
|
||||||
|
pnpm install -g @shipzone/npmci
|
||||||
|
npmci npm prepare
|
||||||
|
|
||||||
|
- name: Release
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm publish
|
||||||
|
|
||||||
|
metadata:
|
||||||
|
needs: test
|
||||||
|
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Prepare
|
||||||
|
run: |
|
||||||
|
pnpm install -g pnpm
|
||||||
|
pnpm install -g @shipzone/npmci
|
||||||
|
npmci npm prepare
|
||||||
|
|
||||||
|
- name: Code quality
|
||||||
|
run: |
|
||||||
|
npmci command npm install -g typescript
|
||||||
|
npmci npm install
|
||||||
|
|
||||||
|
- name: Trigger
|
||||||
|
run: npmci trigger
|
||||||
|
|
||||||
|
- name: Build docs and upload artifacts
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm install
|
||||||
|
pnpm install -g @gitzone/tsdoc
|
||||||
|
npmci command tsdoc
|
||||||
|
continue-on-error: true
|
137
.gitlab-ci.yml
137
.gitlab-ci.yml
@ -1,137 +0,0 @@
|
|||||||
# gitzone ci_default
|
|
||||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
|
||||||
|
|
||||||
cache:
|
|
||||||
paths:
|
|
||||||
- .npmci_cache/
|
|
||||||
key: '$CI_BUILD_STAGE'
|
|
||||||
|
|
||||||
stages:
|
|
||||||
- security
|
|
||||||
- test
|
|
||||||
- release
|
|
||||||
- metadata
|
|
||||||
|
|
||||||
# ====================
|
|
||||||
# security stage
|
|
||||||
# ====================
|
|
||||||
mirror:
|
|
||||||
stage: security
|
|
||||||
script:
|
|
||||||
- npmci git mirror
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
tags:
|
|
||||||
- lossless
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
auditProductionDependencies:
|
|
||||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
|
||||||
stage: security
|
|
||||||
script:
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci command npm install --production --ignore-scripts
|
|
||||||
- npmci command npm config set registry https://registry.npmjs.org
|
|
||||||
- npmci command npm audit --audit-level=high --only=prod --production
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
|
|
||||||
auditDevDependencies:
|
|
||||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
|
||||||
stage: security
|
|
||||||
script:
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci command npm install --ignore-scripts
|
|
||||||
- npmci command npm config set registry https://registry.npmjs.org
|
|
||||||
- npmci command npm audit --audit-level=high --only=dev
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
allow_failure: true
|
|
||||||
|
|
||||||
# ====================
|
|
||||||
# test stage
|
|
||||||
# ====================
|
|
||||||
|
|
||||||
testStable:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci node install stable
|
|
||||||
- npmci npm install
|
|
||||||
- npmci npm test
|
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
|
|
||||||
testBuild:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci node install stable
|
|
||||||
- npmci npm install
|
|
||||||
- npmci command npm run build
|
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
|
|
||||||
release:
|
|
||||||
stage: release
|
|
||||||
script:
|
|
||||||
- npmci node install stable
|
|
||||||
- npmci npm publish
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
tags:
|
|
||||||
- lossless
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
# ====================
|
|
||||||
# metadata stage
|
|
||||||
# ====================
|
|
||||||
codequality:
|
|
||||||
stage: metadata
|
|
||||||
allow_failure: true
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
script:
|
|
||||||
- npmci command npm install -g tslint typescript
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci npm install
|
|
||||||
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
|
||||||
tags:
|
|
||||||
- lossless
|
|
||||||
- docker
|
|
||||||
- priv
|
|
||||||
|
|
||||||
trigger:
|
|
||||||
stage: metadata
|
|
||||||
script:
|
|
||||||
- npmci trigger
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
tags:
|
|
||||||
- lossless
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
pages:
|
|
||||||
stage: metadata
|
|
||||||
script:
|
|
||||||
- npmci node install lts
|
|
||||||
- npmci command npm install -g @gitzone/tsdoc
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci npm install
|
|
||||||
- npmci command tsdoc
|
|
||||||
tags:
|
|
||||||
- lossless
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
artifacts:
|
|
||||||
expire_in: 1 week
|
|
||||||
paths:
|
|
||||||
- public
|
|
||||||
allow_failure: true
|
|
24
.vscode/launch.json
vendored
24
.vscode/launch.json
vendored
@ -2,28 +2,10 @@
|
|||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
"name": "current file",
|
"command": "npm test",
|
||||||
"type": "node",
|
"name": "Run npm test",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"args": [
|
"type": "node-terminal"
|
||||||
"${relativeFile}"
|
|
||||||
],
|
|
||||||
"runtimeArgs": ["-r", "@gitzone/tsrun"],
|
|
||||||
"cwd": "${workspaceRoot}",
|
|
||||||
"protocol": "inspector",
|
|
||||||
"internalConsoleOptions": "openOnSessionStart"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "test.ts",
|
|
||||||
"type": "node",
|
|
||||||
"request": "launch",
|
|
||||||
"args": [
|
|
||||||
"test/test.ts"
|
|
||||||
],
|
|
||||||
"runtimeArgs": ["-r", "@gitzone/tsrun"],
|
|
||||||
"cwd": "${workspaceRoot}",
|
|
||||||
"protocol": "inspector",
|
|
||||||
"internalConsoleOptions": "openOnSessionStart"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -7,10 +7,10 @@
|
|||||||
"projectType": "npm",
|
"projectType": "npm",
|
||||||
"module": {
|
"module": {
|
||||||
"githost": "gitlab.com",
|
"githost": "gitlab.com",
|
||||||
"gitscope": "pushrocks",
|
"gitscope": "push.rocks",
|
||||||
"gitrepo": "smartnpm",
|
"gitrepo": "smartnpm",
|
||||||
"shortDescription": "interface with npm to retrieve package information",
|
"description": "interface with npm to retrieve package information",
|
||||||
"npmPackagename": "@pushrocks/smartnpm",
|
"npmPackagename": "@push.rocks/smartnpm",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
12294
package-lock.json
generated
12294
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
38
package.json
38
package.json
@ -1,34 +1,36 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartnpm",
|
"name": "@push.rocks/smartnpm",
|
||||||
"version": "1.0.35",
|
"version": "2.0.4",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "interface with npm to retrieve package information",
|
"description": "interface with npm to retrieve package information",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
"typings": "dist_ts/index.d.ts",
|
"typings": "dist_ts/index.d.ts",
|
||||||
|
"type": "module",
|
||||||
"author": "Lossless GmbH",
|
"author": "Lossless GmbH",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(tstest test/)",
|
"test": "(tstest test/)",
|
||||||
"build": "(tsbuild --web)"
|
"build": "(tsbuild --web --allowimplicitany)",
|
||||||
|
"buildDocs": "tsdoc"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.25",
|
"@gitzone/tsbuild": "^2.1.66",
|
||||||
"@gitzone/tsrun": "^1.2.12",
|
"@gitzone/tsrun": "^1.2.44",
|
||||||
"@gitzone/tstest": "^1.0.54",
|
"@gitzone/tstest": "^1.0.77",
|
||||||
"@pushrocks/tapbundle": "^3.2.14",
|
"@push.rocks/tapbundle": "^5.0.12",
|
||||||
"@types/node": "^15.0.1",
|
"@types/node": "^20.4.4"
|
||||||
"tslint": "^6.1.3",
|
|
||||||
"tslint-config-prettier": "^1.18.0"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/consolecolor": "^2.0.1",
|
"@push.rocks/consolecolor": "^2.0.1",
|
||||||
"@pushrocks/levelcache": "^1.0.9",
|
"@push.rocks/levelcache": "^3.0.6",
|
||||||
"@pushrocks/smartarchive": "^2.0.4",
|
"@push.rocks/smartarchive": "^3.0.6",
|
||||||
"@pushrocks/smartfile": "^8.0.10",
|
"@push.rocks/smartfile": "^10.0.28",
|
||||||
"@pushrocks/smartpromise": "^3.1.5",
|
"@push.rocks/smartpath": "^5.0.11",
|
||||||
"@pushrocks/smartrequest": "^1.1.51",
|
"@push.rocks/smartpromise": "^4.0.3",
|
||||||
"@pushrocks/smartversion": "^2.0.7",
|
"@push.rocks/smartrequest": "^2.0.18",
|
||||||
"package-json": "^6.5.0"
|
"@push.rocks/smarttime": "^4.0.4",
|
||||||
|
"@push.rocks/smartversion": "^3.0.2",
|
||||||
|
"package-json": "^8.1.1"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"ts/**/*",
|
"ts/**/*",
|
||||||
|
5228
pnpm-lock.yaml
generated
Normal file
5228
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
30
readme.md
30
readme.md
@ -1,27 +1,26 @@
|
|||||||
# @pushrocks/smartnpm
|
# @push.rocks/smartnpm
|
||||||
interface with npm to retrieve package information
|
interface with npm to retrieve package information
|
||||||
|
|
||||||
## Availabililty and Links
|
## Availabililty and Links
|
||||||
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartnpm)
|
* [npmjs.org (npm package)](https://www.npmjs.com/package/@push.rocks/smartnpm)
|
||||||
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartnpm)
|
* [gitlab.com (source)](https://gitlab.com/push.rocks/smartnpm)
|
||||||
* [github.com (source mirror)](https://github.com/pushrocks/smartnpm)
|
* [github.com (source mirror)](https://github.com/push.rocks/smartnpm)
|
||||||
* [docs (typedoc)](https://pushrocks.gitlab.io/smartnpm/)
|
* [docs (typedoc)](https://push.rocks.gitlab.io/smartnpm/)
|
||||||
|
|
||||||
## Status for master
|
## Status for master
|
||||||
|
|
||||||
Status Category | Status Badge
|
Status Category | Status Badge
|
||||||
-- | --
|
-- | --
|
||||||
GitLab Pipelines | [](https://lossless.cloud)
|
GitLab Pipelines | [](https://lossless.cloud)
|
||||||
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
||||||
npm | [](https://lossless.cloud)
|
npm | [](https://lossless.cloud)
|
||||||
Snyk | [](https://lossless.cloud)
|
Snyk | [](https://lossless.cloud)
|
||||||
TypeScript Support | [](https://lossless.cloud)
|
TypeScript Support | [](https://lossless.cloud)
|
||||||
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
Code Style | [](https://lossless.cloud)
|
Code Style | [](https://lossless.cloud)
|
||||||
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
||||||
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
||||||
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
||||||
Platform support | [](https://lossless.cloud) [](https://lossless.cloud)
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
@ -33,7 +32,6 @@ We are always happy for code contributions. If you are not the code contributing
|
|||||||
|
|
||||||
For further information read the linked docs at the top of this readme.
|
For further information read the linked docs at the top of this readme.
|
||||||
|
|
||||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
## Legal
|
||||||
|
> MIT licensed | **©** [Task Venture Capital GmbH](https://task.vc)
|
||||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
||||||
|
|
||||||
[](https://maintainedby.lossless.com)
|
|
||||||
|
184
test/test.ts
184
test/test.ts
@ -1,6 +1,6 @@
|
|||||||
import { expect, tap } from '@pushrocks/tapbundle';
|
import { expect, tap } from '@push.rocks/tapbundle';
|
||||||
import * as smartnpm from '../ts/index';
|
import * as smartnpm from '../ts/index.js';
|
||||||
import { NpmRegistry } from '../ts/index';
|
import { NpmRegistry } from '../ts/index.js';
|
||||||
|
|
||||||
let npmRegistry: smartnpm.NpmRegistry;
|
let npmRegistry: smartnpm.NpmRegistry;
|
||||||
let verdaccioRegistry: smartnpm.NpmRegistry;
|
let verdaccioRegistry: smartnpm.NpmRegistry;
|
||||||
@ -9,197 +9,53 @@ let testPackage: smartnpm.NpmPackage;
|
|||||||
// lets test things with the standard npm registry
|
// lets test things with the standard npm registry
|
||||||
tap.test('should create valid instances', async () => {
|
tap.test('should create valid instances', async () => {
|
||||||
npmRegistry = new smartnpm.NpmRegistry();
|
npmRegistry = new smartnpm.NpmRegistry();
|
||||||
expect(npmRegistry).to.be.instanceof(smartnpm.NpmRegistry);
|
expect(npmRegistry).toBeInstanceOf(smartnpm.NpmRegistry);
|
||||||
|
|
||||||
testPackage = new smartnpm.NpmPackage(npmRegistry);
|
testPackage = new smartnpm.NpmPackage(npmRegistry);
|
||||||
expect(testPackage).to.be.instanceof(smartnpm.NpmPackage);
|
expect(testPackage).toBeInstanceOf(smartnpm.NpmPackage);
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should produce a valid search string and this return npmts', async () => {
|
tap.test('should produce a valid search string and this return npmts', async () => {
|
||||||
const packages = await npmRegistry.searchOnNpm({
|
const packages = await npmRegistry.searchOnNpm({
|
||||||
name: '@pushrocks/smartupdate',
|
name: '@pushrocks/smartupdate',
|
||||||
});
|
});
|
||||||
expect(packages[0].name).to.equal('@pushrocks/smartupdate');
|
expect(packages[0].name).toEqual('@pushrocks/smartupdate');
|
||||||
});
|
});
|
||||||
|
|
||||||
// lets test things with the verdaccio registry
|
// lets test things with the verdaccio registry
|
||||||
tap.test('should create a verdaccio registry', async () => {
|
tap.test('should create a verdaccio registry', async () => {
|
||||||
verdaccioRegistry = new NpmRegistry({
|
verdaccioRegistry = new NpmRegistry({
|
||||||
npmRegistryUrl: 'https://verdaccio.lossless.one',
|
npmRegistryUrl: 'https://verdaccio.lossless.digital',
|
||||||
});
|
});
|
||||||
expect(verdaccioRegistry).to.be.instanceOf(smartnpm.NpmRegistry);
|
expect(verdaccioRegistry).toBeInstanceOf(smartnpm.NpmRegistry);
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should get package from verdaccio', async () => {
|
tap.test('should get package from verdaccio', async () => {
|
||||||
const npmPackage = await verdaccioRegistry.getPackageInfo('@pushrocks/smartupdate');
|
const npmPackage = await verdaccioRegistry.getPackageInfo('@pushrocks/smartupdate');
|
||||||
console.log(npmPackage);
|
expect(npmPackage.license).toEqual('MIT');
|
||||||
expect(npmPackage.license).to.equal('MIT');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should get a specific file from a package', async () => {
|
tap.test('should get a specific file from a package', async () => {
|
||||||
const wantedFile = await verdaccioRegistry.getFileFromPackage(
|
const wantedFile = await verdaccioRegistry.getFileFromPackage(
|
||||||
'@pushrocks/websetup',
|
'@pushrocks/websetup',
|
||||||
'ts/index.ts'
|
'./ts/index.ts'
|
||||||
);
|
);
|
||||||
console.log(wantedFile.contentBuffer.toString());
|
console.log(wantedFile.contentBuffer.toString());
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should get a specific file from a package', async () => {
|
tap.test('should get a specific file from a package', async () => {
|
||||||
const wantedFiles = await verdaccioRegistry.getFilesFromPackage(
|
const wantedFiles = await verdaccioRegistry.getFilesFromPackage('@pushrocks/websetup', 'ts/');
|
||||||
'@pushrocks/websetup',
|
for (const file of wantedFiles) {
|
||||||
'ts/'
|
|
||||||
);
|
|
||||||
for(const file of wantedFiles) {
|
|
||||||
console.log(file.path);
|
console.log(file.path);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.start();
|
tap.test('should not get a nonexisting file from a package', async () => {
|
||||||
|
const wantedFileNotThere = await verdaccioRegistry.getFileFromPackage(
|
||||||
|
'@pushrocks/websetup',
|
||||||
|
'ts/notthere'
|
||||||
|
);
|
||||||
|
expect(wantedFileNotThere).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
const hi = {
|
tap.start();
|
||||||
_id: '@pushrocks/smartversion',
|
|
||||||
_rev: '2-93b6e6391f7209fcbd1db76c92164777',
|
|
||||||
name: '@pushrocks/smartversion',
|
|
||||||
'dist-tags': { latest: '2.0.4' },
|
|
||||||
versions: {
|
|
||||||
'2.0.0': {
|
|
||||||
name: '@pushrocks/smartversion',
|
|
||||||
version: '2.0.0',
|
|
||||||
private: false,
|
|
||||||
description: 'handle semver with easy',
|
|
||||||
main: 'dist/index.js',
|
|
||||||
typings: 'dist/index.d.ts',
|
|
||||||
author: { name: 'Lossless GmbH' },
|
|
||||||
license: 'MIT',
|
|
||||||
scripts: { test: '(tstest test/)', build: '(tsbuild)' },
|
|
||||||
devDependencies: {
|
|
||||||
'@gitzone/tsbuild': '^2.0.22',
|
|
||||||
'@gitzone/tsrun': '^1.1.12',
|
|
||||||
'@gitzone/tstest': '^1.0.15',
|
|
||||||
'@pushrocks/tapbundle': '^3.0.5',
|
|
||||||
'@types/node': '^10.9.4',
|
|
||||||
},
|
|
||||||
dependencies: { '@types/semver': '^5.5.0', semver: '^5.5.1' },
|
|
||||||
gitHead: 'df6b1a9730551884aa4c4fae5577b2b11058f508',
|
|
||||||
_id: '@pushrocks/smartversion@2.0.0',
|
|
||||||
_npmVersion: '6.2.0',
|
|
||||||
_nodeVersion: '10.9.0',
|
|
||||||
_npmUser: { name: 'lossless', email: 'npm@lossless.com' },
|
|
||||||
dist: {
|
|
||||||
integrity:
|
|
||||||
'sha512-+loQHivWzEO39X/PEzi+UOptDveez0n8Eu/bDIht55wkjhav33HkNjab8MeK/g76gOia3ZHoPyqLTvD4yvXDiA==',
|
|
||||||
shasum: 'd663a39d77950de1a743adb0c2eb00e325d230df',
|
|
||||||
tarball: 'https://registry.npmjs.org/@pushrocks/smartversion/-/smartversion-2.0.0.tgz',
|
|
||||||
fileCount: 12,
|
|
||||||
unpackedSize: 12011,
|
|
||||||
'npm-signature':
|
|
||||||
'-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbi7zUCRA9TVsSAnZWagAAigcP/0gRmizQkzjE9Gw8gCeK\n56m41mJQmtl6tRvYVyVGuqfiCaiLvB/B0fkKt2r/MNsJVjC372ayWKya4nev\nTOLSg+g4e9gnkyn8i1OFVE5kr8C4MvLc6P771v2UDXJF5c3pYq6i5fSyGz/s\ngpOuy/KxyVo5wH16yasGWDq9Gl58yp+7vZKR6cc+7Rlq0UhyezhDBRBiKkB0\nk6Y/4J4KWK7CmO+3Y/QUPGBxGmoUHNSiS5cz8vWbycRP7pT11asksgxNPGdv\nyeW/VNVLZkemwrXhSuYKM0DK6aZpjJxk3A8OAyDuHGfZDzAmyaRsfUL84Mgl\nlN1S92CCfuAOyA1os8rsrJU133TV8zVTck3IdmO4AqJ8aB3WNkmNYE5IHxWf\nnmhUUo1Rv/M5fJniTHOBGaeOahFqEp+8URNW1zylC3NoFwiUon1lvnMp1Dd1\nczGPWvQ12ZAeMOR/qpO4RRzTdD45iuvvj2NRhZZN1pthnhUi8XpgMIDuCODT\n2Srew7JBkdfX3F1q/LGgk9e+RYCWTlLPgmzOBUH39ljpfa70liAH5sU+yyfk\nFLfVQlLwWAEwRnkm4j/l/xBWJcwqVG2nDOOzScfYVG3BXSBHo4PfywhFdbnc\nQ3MMrJsrJPhppfMJEEQWlQSkNSCCEV7DDPeH4oK9tKRUdmDaKJpnb6tVZqzM\nBWac\r\n=0NZU\r\n-----END PGP SIGNATURE-----\r\n',
|
|
||||||
},
|
|
||||||
maintainers: [{ name: 'lossless', email: 'npm@lossless.com' }],
|
|
||||||
directories: {},
|
|
||||||
_npmOperationalInternal: {
|
|
||||||
host: 's3://npm-registry-packages',
|
|
||||||
tmp: 'tmp/smartversion_2.0.0_1535884499821_0.9273118882229912',
|
|
||||||
},
|
|
||||||
_hasShrinkwrap: false,
|
|
||||||
},
|
|
||||||
'2.0.3': {
|
|
||||||
name: '@pushrocks/smartversion',
|
|
||||||
version: '2.0.3',
|
|
||||||
private: false,
|
|
||||||
description: 'handle semver with easy',
|
|
||||||
main: 'dist/index.js',
|
|
||||||
typings: 'dist/index.d.ts',
|
|
||||||
author: { name: 'Lossless GmbH' },
|
|
||||||
license: 'MIT',
|
|
||||||
scripts: { test: '(tstest test/)', build: '(tsbuild)' },
|
|
||||||
devDependencies: {
|
|
||||||
'@gitzone/tsbuild': '^2.1.17',
|
|
||||||
'@gitzone/tsrun': '^1.2.8',
|
|
||||||
'@gitzone/tstest': '^1.0.24',
|
|
||||||
'@pushrocks/tapbundle': '^3.0.13',
|
|
||||||
'@types/node': '^12.7.5',
|
|
||||||
},
|
|
||||||
dependencies: { '@types/semver': '^6.0.2', semver: '^6.3.0' },
|
|
||||||
gitHead: 'e364545d0ef6ef7fa1b8467fb48d2b67f09f2d07',
|
|
||||||
_id: '@pushrocks/smartversion@2.0.3',
|
|
||||||
_nodeVersion: '12.10.0',
|
|
||||||
_npmVersion: '6.11.3',
|
|
||||||
dist: {
|
|
||||||
integrity:
|
|
||||||
'sha512-nhauxBGMxjJtXj+k1Z7H2yB184ZhWhU0NKN5ATwlgfEM4zbbZNjCFRLVg/7sOXvbS2b0QU1aStRQ+6QGC2hW4A==',
|
|
||||||
shasum: '9272da89412556946c5a3d5ba3b6a253154de6ae',
|
|
||||||
tarball: 'https://registry.npmjs.org/@pushrocks/smartversion/-/smartversion-2.0.3.tgz',
|
|
||||||
fileCount: 9,
|
|
||||||
unpackedSize: 9127,
|
|
||||||
'npm-signature':
|
|
||||||
'-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdeRYfCRA9TVsSAnZWagAApCkP/RrWk6+hxpoTpflJ65x/\nm05egDhfyTs2BZKArkSnvtc+q6Fo3iDlumqiv3HRyHwDBFLgK5gAOgU0jyqW\nmhwumGMfKT4bzG65iU2z6FgS+RhEh3JaKzjgPohr1oEaLOaaKL0S9+Ybxt6u\nkwv4CgnmzQ/6zVZYJ+qFbV0v+n6iiuIbOTS8j7+X0nA/DkvvZ1Nwhng++vH8\nLm8lT78F/vcxHkSf2RfC6kabhVF+vVRBazq/cI4OQ+xjBQC2y+6YxEq/4Hsz\nKZBF9u2ZcyeI7NEuo1FaojvqvLX3lPxi9Xfw2PSO2iri+DS8KIOVgzwJ+9ih\nb1h/vpoFv8dbhZzkqSs/4rab3rvQYqy7AgvslI8mEeOQk/BhrjxQIvG0re3H\nzc0iWlNp6W3Lsf3/gmKGZbhl39ZgQxInfWLNW60ghqzUq85gyAwPDRb2yxez\nP7bMT0qb/bQSmAa63/q3qE+JAjZFQFDB6Pj6sO1p3csv0T+7mRj9T/4pSc8B\nv5rD9t0mVlAZXwmz3zDhpomct3bhUlAidw7tcax8sr9SowA2hqY3TB1uJ52y\nKPDVMQZ4Voi7kft+icYoVm1XkQMwmmedAoTbS49s52wW6dm4CWmnlBOZzzqN\neT4Q1INrTUXaMxRv/zxguk7TV8xi6gRf+EBDtnEKukITWTvvPsGq4SS9toRa\n9L6F\r\n=yVBx\r\n-----END PGP SIGNATURE-----\r\n',
|
|
||||||
},
|
|
||||||
maintainers: [{ name: 'lossless', email: 'npm@lossless.com' }],
|
|
||||||
_npmUser: { name: 'lossless', email: 'npm@lossless.com' },
|
|
||||||
directories: {},
|
|
||||||
_npmOperationalInternal: {
|
|
||||||
host: 's3://npm-registry-packages',
|
|
||||||
tmp: 'tmp/smartversion_2.0.3_1568216607132_0.9216415895294796',
|
|
||||||
},
|
|
||||||
_hasShrinkwrap: false,
|
|
||||||
},
|
|
||||||
'2.0.4': {
|
|
||||||
name: '@pushrocks/smartversion',
|
|
||||||
version: '2.0.4',
|
|
||||||
private: false,
|
|
||||||
description: 'handle semver with easy',
|
|
||||||
main: 'dist/index.js',
|
|
||||||
typings: 'dist/index.d.ts',
|
|
||||||
author: { name: 'Lossless GmbH' },
|
|
||||||
license: 'MIT',
|
|
||||||
scripts: { test: '(tstest test/)', build: '(tsbuild)' },
|
|
||||||
devDependencies: {
|
|
||||||
'@gitzone/tsbuild': '^2.1.17',
|
|
||||||
'@gitzone/tsrun': '^1.2.8',
|
|
||||||
'@gitzone/tstest': '^1.0.24',
|
|
||||||
'@pushrocks/tapbundle': '^3.0.13',
|
|
||||||
'@types/node': '^12.7.5',
|
|
||||||
tslint: '^5.20.0',
|
|
||||||
'tslint-config-prettier': '^1.18.0',
|
|
||||||
},
|
|
||||||
dependencies: { '@types/semver': '^6.0.2', semver: '^6.3.0' },
|
|
||||||
gitHead: 'bb8e7cb608f3a116e7bfb0b52dd5ce9a7c4eaec1',
|
|
||||||
_id: '@pushrocks/smartversion@2.0.4',
|
|
||||||
_nodeVersion: '12.10.0',
|
|
||||||
_npmVersion: '6.11.3',
|
|
||||||
dist: {
|
|
||||||
integrity:
|
|
||||||
'sha512-LrtaWRn1DD2zIUr8nVAsKwZ+Y55TFIVZ0z3xjwAQ46SoiTrFWooeQ2Xw18DqsEo1cEqMZyGAskaJkOaRkXHtUA==',
|
|
||||||
shasum: '7c6297f9c596e729001c2b6e2a8fa72c40ed42a9',
|
|
||||||
tarball: 'https://registry.npmjs.org/@pushrocks/smartversion/-/smartversion-2.0.4.tgz',
|
|
||||||
fileCount: 9,
|
|
||||||
unpackedSize: 9263,
|
|
||||||
'npm-signature':
|
|
||||||
'-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdeRazCRA9TVsSAnZWagAAxX0P/j12DYB5zjZQh3/IpY1t\n+vzvLmTgn2b0lhheLxUX9EYMW+cethYbd8Q8p/SOsytfB2IHCKBdkpE5ZAIK\nsv7d/myZaihZ9RHCd/UQOj99b/KfdbN/7ndtEL7V4hmcNyWUmebeRsxMhxZ5\nLRvWMZiNsgdXbKxs6JpId3iuSFuTxRgL41smiklcW0nGRp9uMieN8TC3xmOW\nsia6JcvGNQT1/LD9XN6l9U/ZWfzOMaEtjv4Hd9XzOVv0SMYT5Nyv3JQV2Jd5\nc5G5aGZe0QXSB9LwnNUcXC3mrZ9+SvmqpECcV2BTJ+JJlzp4Pny51r2nPyC6\nypdsfTfDzAL6BIq433OScEyjRMcufLC+caGXPCjUhtPW6wlf9kTFiRd2L3uk\nWhg2LmFhL4bHz67ty2wAy8XlLYOS/QFOZLEZr7bZDhINkkqR5RQd5RfkMJ6Q\n0skcsspq69tWKrgY3Uh6aK30Z+g7C4V/KGfquz6EsET9xP+7MRTVcd+FLfC1\ndfCcfe3/l49oXbCPwApH9X8ETc3HDJuSRdfVV7PVsEzbOwN4sqTIS9vAHXDN\ncjAmrhbZkhA7VD4PNjhEov1veo/UOoNB7xlN4JLuRZ40SqCSr4akVnNImUDc\nCg+b16mZhlVpLNgjVjG9rgDD7zCn+zn9EZTsq3/qL4jEcf4JY+T2YKmf7AMb\nhmej\r\n=eqby\r\n-----END PGP SIGNATURE-----\r\n',
|
|
||||||
},
|
|
||||||
maintainers: [{ name: 'lossless', email: 'npm@lossless.com' }],
|
|
||||||
_npmUser: { name: 'lossless', email: 'npm@lossless.com' },
|
|
||||||
directories: {},
|
|
||||||
_npmOperationalInternal: {
|
|
||||||
host: 's3://npm-registry-packages',
|
|
||||||
tmp: 'tmp/smartversion_2.0.4_1568216754658_0.06886864906713819',
|
|
||||||
},
|
|
||||||
_hasShrinkwrap: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
time: {
|
|
||||||
created: '2018-09-02T10:34:59.735Z',
|
|
||||||
'2.0.0': '2018-09-02T10:34:59.913Z',
|
|
||||||
modified: '2019-09-11T15:45:58.404Z',
|
|
||||||
'2.0.3': '2019-09-11T15:43:27.294Z',
|
|
||||||
'2.0.4': '2019-09-11T15:45:54.786Z',
|
|
||||||
},
|
|
||||||
maintainers: [{ name: 'lossless', email: 'npm@lossless.com' }],
|
|
||||||
description: 'handle semver with easy',
|
|
||||||
author: { name: 'Lossless GmbH' },
|
|
||||||
license: 'MIT',
|
|
||||||
readme:
|
|
||||||
'# @pushrocks/smartversion\nhandle semver with easy\n\n## Availabililty and Links\n* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartversion)\n* [gitlab.com (source)](https://gitlab.com/pushrocks/smartversion)\n* [github.com (source mirror)](https://github.com/pushrocks/smartversion)\n* [docs (typedoc)](https://pushrocks.gitlab.io/smartversion/)\n\n## Status for master\n[](https://gitlab.com/pushrocks/smartversion/commits/master)\n[](https://gitlab.com/pushrocks/smartversion/commits/master)\n[](https://www.npmjs.com/package/@pushrocks/smartversion)\n[](https://snyk.io/test/npm/@pushrocks/smartversion)\n[](https://nodejs.org/dist/latest-v10.x/docs/api/)\n[](https://nodejs.org/dist/latest-v10.x/docs/api/)\n[](https://prettier.io/)\n\n## Usage\n\nUse TypeScript for best in class instellisense.\n\nFor further information read the linked docs at the top of this readme.\n\n> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)\n| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)\n\n[](https://maintainedby.lossless.com)\n',
|
|
||||||
readmeFilename: 'readme.md',
|
|
||||||
};
|
|
||||||
|
8
ts/00_commitinfo_data.ts
Normal file
8
ts/00_commitinfo_data.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
/**
|
||||||
|
* autocreated commitinfo by @pushrocks/commitinfo
|
||||||
|
*/
|
||||||
|
export const commitinfo = {
|
||||||
|
name: '@push.rocks/smartnpm',
|
||||||
|
version: '2.0.4',
|
||||||
|
description: 'interface with npm to retrieve package information'
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
import * as plugins from './smartnpm.plugins';
|
import * as plugins from './smartnpm.plugins.js';
|
||||||
|
|
||||||
export * from './smartnpm.classes.npmregistry';
|
export * from './smartnpm.classes.npmregistry.js';
|
||||||
export * from './smartnpm.classes.npmpackage';
|
export * from './smartnpm.classes.npmpackage.js';
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import * as plugins from './smartnpm.plugins';
|
import * as plugins from './smartnpm.plugins.js';
|
||||||
import { NpmRegistry } from './smartnpm.classes.npmregistry';
|
import { NpmRegistry } from './smartnpm.classes.npmregistry.js';
|
||||||
import { PackageDisttag } from './smartnpm.classes.packagedisttag';
|
import { PackageDisttag } from './smartnpm.classes.packagedisttag.js';
|
||||||
import { PackageVersion, IVersionData } from './smartnpm.classes.packageversion';
|
import { PackageVersion, type IVersionData } from './smartnpm.classes.packageversion.js';
|
||||||
|
|
||||||
export class NpmPackage {
|
export class NpmPackage {
|
||||||
public static async createFromFullMetadataAndVersionData(
|
public static async createFromFullMetadataAndVersionData(
|
||||||
@ -139,7 +139,7 @@ export class NpmPackage {
|
|||||||
// lets resolve with the wanted file
|
// lets resolve with the wanted file
|
||||||
done.resolve([fileArg]);
|
done.resolve([fileArg]);
|
||||||
subscription.unsubscribe();
|
subscription.unsubscribe();
|
||||||
} else if(!returnOnFirstArg && fileArg.path.startsWith(wantedFilePath)) {
|
} else if (!returnOnFirstArg && fileArg.path.startsWith(wantedFilePath)) {
|
||||||
allMatchingFiles.push(fileArg);
|
allMatchingFiles.push(fileArg);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -157,7 +157,7 @@ export class NpmPackage {
|
|||||||
/**
|
/**
|
||||||
* get files from package
|
* get files from package
|
||||||
*/
|
*/
|
||||||
public async getFileFromPackage(
|
public async getFileFromPackage(
|
||||||
filePath: string,
|
filePath: string,
|
||||||
optionsArg?: {
|
optionsArg?: {
|
||||||
distTag?: string;
|
distTag?: string;
|
||||||
@ -165,7 +165,7 @@ export class NpmPackage {
|
|||||||
}
|
}
|
||||||
): Promise<plugins.smartfile.Smartfile> {
|
): Promise<plugins.smartfile.Smartfile> {
|
||||||
const result = await this.getFilesFromPackage(filePath, optionsArg, true);
|
const result = await this.getFilesFromPackage(filePath, optionsArg, true);
|
||||||
return result[0];
|
return result[0] || null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import * as plugins from './smartnpm.plugins';
|
import * as plugins from './smartnpm.plugins.js';
|
||||||
import * as paths from './smartnpm.paths';
|
import * as paths from './smartnpm.paths.js';
|
||||||
|
|
||||||
// interfaces
|
// interfaces
|
||||||
import { ISearchObject } from './smartnpm.interfaces';
|
import { type ISearchObject } from './smartnpm.interfaces.js';
|
||||||
|
|
||||||
// classes
|
// classes
|
||||||
import { NpmPackage } from './smartnpm.classes.npmpackage';
|
import { NpmPackage } from './smartnpm.classes.npmpackage.js';
|
||||||
import { RegistryCache } from './smartnpm.classes.registrycache';
|
import { type ICacheDescriptor, RegistryCache } from './smartnpm.classes.registrycache.js';
|
||||||
|
|
||||||
export interface INpmRegistryConstructorOptions {
|
export interface INpmRegistryConstructorOptions {
|
||||||
npmRegistryUrl?: string;
|
npmRegistryUrl?: string;
|
||||||
@ -33,18 +33,24 @@ export class NpmRegistry {
|
|||||||
* @param packageName
|
* @param packageName
|
||||||
*/
|
*/
|
||||||
public async getPackageInfo(packageName: string): Promise<NpmPackage> {
|
public async getPackageInfo(packageName: string): Promise<NpmPackage> {
|
||||||
const fullMetadata = await plugins.packageJson(packageName, {
|
const fullMetadata = await plugins
|
||||||
|
.packageJson.default(packageName, {
|
||||||
|
registryUrl: this.options.npmRegistryUrl,
|
||||||
|
fullMetadata: true,
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.log(err);
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
const versionData = await plugins.packageJson.default(packageName, {
|
||||||
registryUrl: this.options.npmRegistryUrl,
|
registryUrl: this.options.npmRegistryUrl,
|
||||||
fullMetadata: true,
|
allVersions: true,
|
||||||
}).catch(err => {
|
|
||||||
console.log(err);
|
|
||||||
return null;
|
|
||||||
});
|
});
|
||||||
const versionData = await plugins.packageJson(packageName, {
|
const npmPackage = await NpmPackage.createFromFullMetadataAndVersionData(
|
||||||
registryUrl: this.options.npmRegistryUrl,
|
this,
|
||||||
allVersions: true
|
fullMetadata,
|
||||||
});
|
versionData as any
|
||||||
const npmPackage = await NpmPackage.createFromFullMetadataAndVersionData(this, fullMetadata, versionData as any);
|
);
|
||||||
return npmPackage;
|
return npmPackage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,47 +68,76 @@ export class NpmRegistry {
|
|||||||
/**
|
/**
|
||||||
* gets a file from a package as Smartfile
|
* gets a file from a package as Smartfile
|
||||||
*/
|
*/
|
||||||
public async getFileFromPackage(packageNameArg: string, filePath: string, optionsArg?: {
|
public async getFileFromPackage(
|
||||||
distTag?: string;
|
packageNameArg: string,
|
||||||
version?: string;
|
filePathArg: string,
|
||||||
}): Promise<plugins.smartfile.Smartfile> {
|
optionsArg?: {
|
||||||
const fileId = `${this.options.npmRegistryUrl}//+//${packageNameArg}//+//${filePath}//+//${optionsArg?.distTag || optionsArg?.version}`;
|
distTag?: string;
|
||||||
const cachedFile: plugins.smartfile.Smartfile = await this.registryCache.getCachedFile(fileId);
|
version?: string;
|
||||||
|
}
|
||||||
|
): Promise<plugins.smartfile.Smartfile> {
|
||||||
|
// lets create a cache descriptor
|
||||||
|
const cacheDescriptor: ICacheDescriptor = {
|
||||||
|
registryUrl: this.options.npmRegistryUrl,
|
||||||
|
packageName: packageNameArg,
|
||||||
|
filePath: filePathArg,
|
||||||
|
distTag: optionsArg?.distTag,
|
||||||
|
version: optionsArg?.version,
|
||||||
|
};
|
||||||
|
|
||||||
|
// lets see if we have something cached
|
||||||
|
const cachedFile: plugins.smartfile.Smartfile = await this.registryCache.getCachedFile(
|
||||||
|
cacheDescriptor
|
||||||
|
);
|
||||||
|
|
||||||
|
// lets handle both occasions
|
||||||
if (!cachedFile) {
|
if (!cachedFile) {
|
||||||
const npmPackage = await this.getPackageInfo(packageNameArg);
|
const npmPackage = await this.getPackageInfo(packageNameArg);
|
||||||
if (!optionsArg?.version && !optionsArg?.distTag) {
|
if (!optionsArg?.version && !optionsArg?.distTag) {
|
||||||
const latestAvailable = npmPackage.allDistTags.find(packageArg => packageArg.name === 'latest');
|
const latestAvailable = npmPackage.allDistTags.find(
|
||||||
|
(packageArg) => packageArg.name === 'latest'
|
||||||
|
);
|
||||||
if (!latestAvailable) {
|
if (!latestAvailable) {
|
||||||
optionsArg = {
|
optionsArg = {
|
||||||
version: npmPackage.getBestMatchingVersion('*')
|
version: npmPackage.getBestMatchingVersion('*'),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const fileResult = await npmPackage.getFileFromPackage(filePath, optionsArg);
|
const fileResult = await npmPackage.getFileFromPackage(filePathArg, optionsArg);
|
||||||
this.registryCache.cacheSmartFile(fileId, fileResult);
|
if (fileResult) {
|
||||||
|
this.registryCache.cacheSmartFile(cacheDescriptor, fileResult);
|
||||||
|
}
|
||||||
return fileResult;
|
return fileResult;
|
||||||
} else {
|
} else {
|
||||||
return cachedFile;
|
return cachedFile;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getFilesFromPackage(packageNameArg: string, filePath: string, optionsArg?: {
|
public async getFilesFromPackage(
|
||||||
distTag?: string;
|
packageNameArg: string,
|
||||||
version?: string;
|
filePath: string,
|
||||||
}): Promise<plugins.smartfile.Smartfile[]> {
|
optionsArg?: {
|
||||||
|
distTag?: string;
|
||||||
|
version?: string;
|
||||||
|
}
|
||||||
|
): Promise<plugins.smartfile.Smartfile[]> {
|
||||||
const npmPackage = await this.getPackageInfo(packageNameArg);
|
const npmPackage = await this.getPackageInfo(packageNameArg);
|
||||||
if (!optionsArg?.version && !optionsArg?.distTag) {
|
if (!optionsArg?.version && !optionsArg?.distTag) {
|
||||||
const latestAvailable = npmPackage.allDistTags.find(packageDistTagArg => packageDistTagArg.name === 'latest');
|
const latestAvailable = npmPackage.allDistTags.find(
|
||||||
|
(packageDistTagArg) => packageDistTagArg.name === 'latest'
|
||||||
|
);
|
||||||
if (!latestAvailable) {
|
if (!latestAvailable) {
|
||||||
optionsArg = {
|
optionsArg = {
|
||||||
version: npmPackage.getBestMatchingVersion('*')
|
version: npmPackage.getBestMatchingVersion('*'),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return npmPackage.getFilesFromPackage(filePath, optionsArg);
|
return npmPackage.getFilesFromPackage(filePath, optionsArg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getPackageAsSmartfileVirtualDir(packageNameArg: string): Promise<plugins.smartfile.VirtualDirectory> {
|
public async getPackageAsSmartfileVirtualDir(
|
||||||
|
packageNameArg: string
|
||||||
|
): Promise<plugins.smartfile.VirtualDirectory> {
|
||||||
/**
|
/**
|
||||||
* TODO: rewrite as memory only
|
* TODO: rewrite as memory only
|
||||||
*/
|
*/
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import * as plugins from './smartnpm.plugins';
|
import * as plugins from './smartnpm.plugins.js';
|
||||||
|
|
||||||
export class PackageDisttag {
|
export class PackageDisttag {
|
||||||
name: string;
|
name: string;
|
||||||
@ -8,4 +8,4 @@ export class PackageDisttag {
|
|||||||
this.name = nameArg;
|
this.name = nameArg;
|
||||||
this.targetVersion = targetVersionArg;
|
this.targetVersion = targetVersionArg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import * as plugins from './smartnpm.plugins';
|
import * as plugins from './smartnpm.plugins.js';
|
||||||
|
|
||||||
export interface IVersionData {
|
export interface IVersionData {
|
||||||
name: string;
|
name: string;
|
||||||
|
@ -1,5 +1,13 @@
|
|||||||
import { NpmRegistry } from './smartnpm.classes.npmregistry';
|
import { NpmRegistry } from './smartnpm.classes.npmregistry.js';
|
||||||
import * as plugins from './smartnpm.plugins';
|
import * as plugins from './smartnpm.plugins.js';
|
||||||
|
|
||||||
|
export interface ICacheDescriptor {
|
||||||
|
registryUrl: string;
|
||||||
|
packageName: string;
|
||||||
|
filePath: string;
|
||||||
|
distTag?: string;
|
||||||
|
version?: string;
|
||||||
|
}
|
||||||
|
|
||||||
export class RegistryCache {
|
export class RegistryCache {
|
||||||
npmregistryRef: NpmRegistry;
|
npmregistryRef: NpmRegistry;
|
||||||
@ -9,24 +17,47 @@ export class RegistryCache {
|
|||||||
this.npmregistryRef = npmRegistryRefArg;
|
this.npmregistryRef = npmRegistryRefArg;
|
||||||
this.levelCache = new plugins.levelcache.LevelCache({
|
this.levelCache = new plugins.levelcache.LevelCache({
|
||||||
cacheId: encodeURIComponent(this.npmregistryRef.options.npmRegistryUrl),
|
cacheId: encodeURIComponent(this.npmregistryRef.options.npmRegistryUrl),
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getCachedFile (fileId: string): Promise<plugins.smartfile.Smartfile> {
|
public async getCachedFile(
|
||||||
const cacheEntry = await this.levelCache.retrieveCacheEntryByKey(fileId);
|
cacheDescriptorArg: ICacheDescriptor
|
||||||
|
): Promise<plugins.smartfile.Smartfile> {
|
||||||
|
const cacheEntry = await this.levelCache.retrieveCacheEntryByKey(
|
||||||
|
this.getCacheDescriptorAsString(cacheDescriptorArg)
|
||||||
|
);
|
||||||
if (cacheEntry) {
|
if (cacheEntry) {
|
||||||
return plugins.smartfile.Smartfile.fromFoldedJson(cacheEntry.contents.toString());
|
return plugins.smartfile.Smartfile.fromFoldedJson(cacheEntry.contents.toString());
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async cacheSmartFile (fileIdArg: string, smartfileArg: plugins.smartfile.Smartfile) {
|
public async cacheSmartFile(
|
||||||
if (smartfileArg) {
|
cacheDescriptorArg: ICacheDescriptor,
|
||||||
await this.levelCache.storeCacheEntryByKey(fileIdArg, new plugins.levelcache.CacheEntry({
|
smartfileArg: plugins.smartfile.Smartfile
|
||||||
contents: Buffer.from(smartfileArg.foldToJson()),
|
) {
|
||||||
ttl: 60000
|
if (smartfileArg && cacheDescriptorArg.version) {
|
||||||
}));
|
await this.levelCache.storeCacheEntryByKey(
|
||||||
|
this.getCacheDescriptorAsString(cacheDescriptorArg),
|
||||||
|
new plugins.levelcache.CacheEntry({
|
||||||
|
contents: Buffer.from(smartfileArg.foldToJson()),
|
||||||
|
ttl: plugins.smarttime.getMilliSecondsFromUnits({ hours: 1 }),
|
||||||
|
})
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
await this.levelCache.storeCacheEntryByKey(
|
||||||
|
this.getCacheDescriptorAsString(cacheDescriptorArg),
|
||||||
|
new plugins.levelcache.CacheEntry({
|
||||||
|
contents: Buffer.from(smartfileArg.foldToJson()),
|
||||||
|
ttl: plugins.smarttime.getMilliSecondsFromUnits({ minutes: 1 }),
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public getCacheDescriptorAsString(cacheDescriptorArg?: ICacheDescriptor) {
|
||||||
|
return `${cacheDescriptorArg.registryUrl}//+//${cacheDescriptorArg.packageName}//+//${
|
||||||
|
cacheDescriptorArg.filePath
|
||||||
|
}//+//${cacheDescriptorArg.distTag || cacheDescriptorArg.version}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
import * as plugins from './smartnpm.plugins';
|
import * as plugins from './smartnpm.plugins.js';
|
||||||
|
|
||||||
export const packageDir = plugins.path.join(__dirname, '../');
|
export const packageDir = plugins.path.join(
|
||||||
|
plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url),
|
||||||
|
'../'
|
||||||
|
);
|
||||||
export const nogitDir = plugins.path.join(packageDir, '.nogit/');
|
export const nogitDir = plugins.path.join(packageDir, '.nogit/');
|
||||||
|
@ -4,17 +4,29 @@ import * as path from 'path';
|
|||||||
export { path };
|
export { path };
|
||||||
|
|
||||||
// @pushrocks scope
|
// @pushrocks scope
|
||||||
import * as consolecolor from '@pushrocks/consolecolor';
|
import * as consolecolor from '@push.rocks/consolecolor';
|
||||||
import * as levelcache from '@pushrocks/levelcache';
|
import * as levelcache from '@push.rocks/levelcache';
|
||||||
import * as smartarchive from '@pushrocks/smartarchive';
|
import * as smartarchive from '@push.rocks/smartarchive';
|
||||||
import * as smartfile from '@pushrocks/smartfile';
|
import * as smartfile from '@push.rocks/smartfile';
|
||||||
import * as smartpromise from '@pushrocks/smartpromise';
|
import * as smartpath from '@push.rocks/smartpath';
|
||||||
import * as smartrequest from '@pushrocks/smartrequest';
|
import * as smartpromise from '@push.rocks/smartpromise';
|
||||||
import * as smartversion from '@pushrocks/smartversion';
|
import * as smartrequest from '@push.rocks/smartrequest';
|
||||||
|
import * as smartversion from '@push.rocks/smartversion';
|
||||||
|
import * as smarttime from '@push.rocks/smarttime';
|
||||||
|
|
||||||
export { consolecolor, levelcache, smartarchive, smartfile, smartpromise, smartrequest, smartversion };
|
export {
|
||||||
|
consolecolor,
|
||||||
|
levelcache,
|
||||||
|
smartarchive,
|
||||||
|
smartfile,
|
||||||
|
smartpath,
|
||||||
|
smartpromise,
|
||||||
|
smartrequest,
|
||||||
|
smartversion,
|
||||||
|
smarttime,
|
||||||
|
};
|
||||||
|
|
||||||
// third party scope
|
// third party scope
|
||||||
import packageJson from 'package-json';
|
import * as packageJson from 'package-json';
|
||||||
|
|
||||||
export { packageJson };
|
export { packageJson };
|
||||||
|
9
tsconfig.json
Normal file
9
tsconfig.json
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"useDefineForClassFields": false,
|
||||||
|
"target": "ES2022",
|
||||||
|
"module": "ES2022",
|
||||||
|
"moduleResolution": "nodenext"
|
||||||
|
}
|
||||||
|
}
|
17
tslint.json
17
tslint.json
@ -1,17 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": ["tslint:latest", "tslint-config-prettier"],
|
|
||||||
"rules": {
|
|
||||||
"semicolon": [true, "always"],
|
|
||||||
"no-console": false,
|
|
||||||
"ordered-imports": false,
|
|
||||||
"object-literal-sort-keys": false,
|
|
||||||
"member-ordering": {
|
|
||||||
"options":{
|
|
||||||
"order": [
|
|
||||||
"static-method"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"defaultSeverity": "warning"
|
|
||||||
}
|
|
Reference in New Issue
Block a user