Compare commits
28 Commits
Author | SHA1 | Date | |
---|---|---|---|
16e58bbbc2 | |||
8ffdf58d68 | |||
2abac29dff | |||
293da8859d | |||
111ef1fe44 | |||
97b285be5c | |||
cc659a57f7 | |||
f5cb86b53e | |||
207f1e9d51 | |||
750b029ef8 | |||
710fd5ec2e | |||
d1315392a1 | |||
cf894d9e82 | |||
1da4e08ed2 | |||
66546a8b17 | |||
3c3275ece5 | |||
d43fbe6de6 | |||
16fd8be8be | |||
297e65ebe5 | |||
a5c019419b | |||
815694dd8b | |||
083786795e | |||
284f4753e0 | |||
335e9160a6 | |||
94c22b65e5 | |||
f1d07f968d | |||
ac53d801a6 | |||
a75bb09d3f |
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
|
4
.gitignore
vendored
4
.gitignore
vendored
@ -15,8 +15,6 @@ node_modules/
|
|||||||
|
|
||||||
# builds
|
# builds
|
||||||
dist/
|
dist/
|
||||||
dist_web/
|
dist_*/
|
||||||
dist_serve/
|
|
||||||
dist_ts_web/
|
|
||||||
|
|
||||||
# custom
|
# custom
|
119
.gitlab-ci.yml
119
.gitlab-ci.yml
@ -1,119 +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
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
snyk:
|
|
||||||
stage: security
|
|
||||||
script:
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci command npm install -g snyk
|
|
||||||
- npmci command npm install --ignore-scripts
|
|
||||||
- npmci command snyk test
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
# ====================
|
|
||||||
# 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
|
|
||||||
- priv
|
|
||||||
|
|
||||||
testBuild:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci node install lts
|
|
||||||
- npmci npm install
|
|
||||||
- npmci command npm run build
|
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
release:
|
|
||||||
stage: release
|
|
||||||
script:
|
|
||||||
- npmci node install lts
|
|
||||||
- npmci npm publish
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
# ====================
|
|
||||||
# metadata stage
|
|
||||||
# ====================
|
|
||||||
codequality:
|
|
||||||
stage: metadata
|
|
||||||
allow_failure: true
|
|
||||||
script:
|
|
||||||
- npmci command npm install -g tslint typescript
|
|
||||||
- npmci npm install
|
|
||||||
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
- priv
|
|
||||||
|
|
||||||
trigger:
|
|
||||||
stage: metadata
|
|
||||||
script:
|
|
||||||
- npmci trigger
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
pages:
|
|
||||||
image: hosttoday/ht-docker-dbase:npmci
|
|
||||||
services:
|
|
||||||
- docker:stable-dind
|
|
||||||
stage: metadata
|
|
||||||
script:
|
|
||||||
- npmci command npm install -g @gitzone/tsdoc
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci npm install
|
|
||||||
- npmci command tsdoc
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
artifacts:
|
|
||||||
expire_in: 1 week
|
|
||||||
paths:
|
|
||||||
- public
|
|
||||||
allow_failure: true
|
|
11
.vscode/launch.json
vendored
Normal file
11
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"command": "npm test",
|
||||||
|
"name": "Run npm test",
|
||||||
|
"request": "launch",
|
||||||
|
"type": "node-terminal"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
26
.vscode/settings.json
vendored
Normal file
26
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"json.schemas": [
|
||||||
|
{
|
||||||
|
"fileMatch": ["/npmextra.json"],
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"npmci": {
|
||||||
|
"type": "object",
|
||||||
|
"description": "settings for npmci"
|
||||||
|
},
|
||||||
|
"gitzone": {
|
||||||
|
"type": "object",
|
||||||
|
"description": "settings for gitzone",
|
||||||
|
"properties": {
|
||||||
|
"projectType": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": ["website", "element", "service", "npm", "wcc"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -3,16 +3,14 @@
|
|||||||
"npmGlobalTools": [],
|
"npmGlobalTools": [],
|
||||||
"npmAccessLevel": "public"
|
"npmAccessLevel": "public"
|
||||||
},
|
},
|
||||||
"npmts": {
|
|
||||||
"coverageTreshold": 50
|
|
||||||
},
|
|
||||||
"gitzone": {
|
"gitzone": {
|
||||||
|
"projectType": "npm",
|
||||||
"module": {
|
"module": {
|
||||||
"githost": "gitlab.com",
|
"githost": "gitlab.com",
|
||||||
"gitscope": "pushrocks",
|
"gitscope": "push.rocks",
|
||||||
"gitrepo": "smartupdate",
|
"gitrepo": "smartupdate",
|
||||||
"shortDescription": "update your tools in a smart way",
|
"description": "update your tools in a smart way",
|
||||||
"npmPackagename": "@pushrocks/smartupdate",
|
"npmPackagename": "@push.rocks/smartupdate",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
1773
package-lock.json
generated
1773
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
53
package.json
53
package.json
@ -1,43 +1,46 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartupdate",
|
"name": "@push.rocks/smartupdate",
|
||||||
"version": "1.0.24",
|
"version": "2.0.6",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "update your tools in a smart way",
|
"description": "update your tools in a smart way",
|
||||||
"main": "dist/index.js",
|
"main": "dist_ts/index.js",
|
||||||
"typings": "dist/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)"
|
"build": "(tsbuild --web --allowimplicitany)",
|
||||||
|
"buildDocs": "tsdoc"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.17",
|
"@gitzone/tsbuild": "^2.1.66",
|
||||||
"@gitzone/tsrun": "^1.2.8",
|
"@gitzone/tsrun": "^1.2.44",
|
||||||
"@gitzone/tstest": "^1.0.24",
|
"@gitzone/tstest": "^1.0.77",
|
||||||
"@pushrocks/tapbundle": "^3.0.13",
|
"@push.rocks/tapbundle": "^5.0.12",
|
||||||
"@types/node": "^12.7.4",
|
"@types/node": "^20.4.5"
|
||||||
"tslint": "^5.19.0",
|
|
||||||
"tslint-config-prettier": "^1.18.0"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/consolecolor": "^2.0.1",
|
"@push.rocks/consolecolor": "^2.0.1",
|
||||||
"@pushrocks/npmextra": "^3.0.5",
|
"@push.rocks/npmextra": "^3.0.9",
|
||||||
"@pushrocks/smartlog": "^2.0.19",
|
"@push.rocks/smartnpm": "^2.0.4",
|
||||||
"@pushrocks/smartnpm": "^1.0.10",
|
"@push.rocks/smartopen": "^2.0.0",
|
||||||
"@pushrocks/smartopen": "^1.0.21",
|
"@push.rocks/smarttime": "^4.0.4",
|
||||||
"@pushrocks/smarttime": "^3.0.12",
|
"@push.rocks/smartversion": "^3.0.2"
|
||||||
"@pushrocks/smartversion": "^2.0.0"
|
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"ts/*",
|
"ts/**/*",
|
||||||
"ts_web/*",
|
"ts_web/**/*",
|
||||||
"dist/*",
|
"dist/**/*",
|
||||||
"dist_web/*",
|
"dist_*/**/*",
|
||||||
"dist_ts_web/*",
|
"dist_ts/**/*",
|
||||||
"assets/*",
|
"dist_ts_web/**/*",
|
||||||
|
"assets/**/*",
|
||||||
"cli.js",
|
"cli.js",
|
||||||
"npmextra.json",
|
"npmextra.json",
|
||||||
"readme.md"
|
"readme.md"
|
||||||
|
],
|
||||||
|
"browserslist": [
|
||||||
|
"last 1 chrome versions"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
5382
pnpm-lock.yaml
generated
Normal file
5382
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
42
readme.md
42
readme.md
@ -1,20 +1,26 @@
|
|||||||
# @pushrocks/smartupdate
|
# @push.rocks/smartupdate
|
||||||
update your tools in a smart way
|
update your tools in a smart way
|
||||||
|
|
||||||
## Availabililty and Links
|
## Availabililty and Links
|
||||||
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartupdate)
|
* [npmjs.org (npm package)](https://www.npmjs.com/package/@push.rocks/smartupdate)
|
||||||
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartupdate)
|
* [gitlab.com (source)](https://gitlab.com/push.rocks/smartupdate)
|
||||||
* [github.com (source mirror)](https://github.com/pushrocks/smartupdate)
|
* [github.com (source mirror)](https://github.com/push.rocks/smartupdate)
|
||||||
* [docs (typedoc)](https://pushrocks.gitlab.io/smartupdate/)
|
* [docs (typedoc)](https://push.rocks.gitlab.io/smartupdate/)
|
||||||
|
|
||||||
## Status for master
|
## Status for master
|
||||||
[](https://gitlab.com/pushrocks/smartupdate/commits/master)
|
|
||||||
[](https://gitlab.com/pushrocks/smartupdate/commits/master)
|
Status Category | Status Badge
|
||||||
[](https://www.npmjs.com/package/@pushrocks/smartupdate)
|
-- | --
|
||||||
[](https://snyk.io/test/npm/@pushrocks/smartupdate)
|
GitLab Pipelines | [](https://lossless.cloud)
|
||||||
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
||||||
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
npm | [](https://lossless.cloud)
|
||||||
[](https://prettier.io/)
|
Snyk | [](https://lossless.cloud)
|
||||||
|
TypeScript Support | [](https://lossless.cloud)
|
||||||
|
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
|
Code Style | [](https://lossless.cloud)
|
||||||
|
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
||||||
|
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
||||||
|
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
@ -34,16 +40,12 @@ await smartupdate.standardHandler.check(
|
|||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
For further information read the linked docs at the top of this README.
|
## Contribution
|
||||||
|
|
||||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
|
||||||
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
|
||||||
|
|
||||||
[](https://push.rocks)
|
|
||||||
|
|
||||||
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)
|
|
||||||
|
17
test/test.ts
17
test/test.ts
@ -1,12 +1,15 @@
|
|||||||
import { expect, tap } from '@pushrocks/tapbundle';
|
import { expect, tap } from '@push.rocks/tapbundle';
|
||||||
import * as smartupdate from '../ts/index';
|
import * as smartupdate from '../ts/index.js';
|
||||||
|
|
||||||
|
let testSmartUpdate: smartupdate.SmartUpdate;
|
||||||
|
|
||||||
|
tap.test('should create an instance of SmartUpdate', async () => {
|
||||||
|
testSmartUpdate = new smartupdate.SmartUpdate();
|
||||||
|
});
|
||||||
|
|
||||||
tap.test('should check for a npm module', async () => {
|
tap.test('should check for a npm module', async () => {
|
||||||
await smartupdate.standardHandler.check(
|
const result = await testSmartUpdate.check('lodash', '1.0.5');
|
||||||
'lodash',
|
expect(result).toBeTrue();
|
||||||
'1.0.5',
|
|
||||||
'http://gitzone.gitlab.io/npmts/changelog.html'
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.start();
|
tap.start();
|
||||||
|
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/smartupdate',
|
||||||
|
version: '2.0.6',
|
||||||
|
description: 'update your tools in a smart way'
|
||||||
|
}
|
105
ts/index.ts
105
ts/index.ts
@ -1,104 +1 @@
|
|||||||
import * as plugins from './smartupdate.plugins';
|
export { SmartUpdate } from './smartupdate.classes.smartupdate.js';
|
||||||
|
|
||||||
import { TimeStamp } from '@pushrocks/smarttime';
|
|
||||||
|
|
||||||
interface ICacheStatus {
|
|
||||||
lastCheck: number;
|
|
||||||
latestVersion: string;
|
|
||||||
performedUpgrade: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
import { KeyValueStore } from '@pushrocks/npmextra';
|
|
||||||
|
|
||||||
export class SmartUpdate {
|
|
||||||
public kvStore = new plugins.npmextra.KeyValueStore('custom', 'global_smartupdate');
|
|
||||||
|
|
||||||
public async check(npmnameArg: string, compareVersion: string, changelogUrlArg?: string) {
|
|
||||||
// the newData to write
|
|
||||||
const timeStamp = new TimeStamp();
|
|
||||||
const newData = {
|
|
||||||
lastCheck: timeStamp.milliSeconds,
|
|
||||||
latestVersion: 'x.x.x',
|
|
||||||
performedUpgrade: false
|
|
||||||
};
|
|
||||||
|
|
||||||
// the comparison data from the keyValue store
|
|
||||||
const result: ICacheStatus = await this.kvStore.readKey(npmnameArg);
|
|
||||||
|
|
||||||
if (result) {
|
|
||||||
const lastCheckTimeStamp = TimeStamp.fromMilliSeconds(result.lastCheck);
|
|
||||||
const tresholdTime = plugins.smarttime.getMilliSecondsFromUnits({ hours: 1 });
|
|
||||||
if (!lastCheckTimeStamp.isOlderThan(timeStamp, tresholdTime)) {
|
|
||||||
newData.lastCheck = lastCheckTimeStamp.milliSeconds;
|
|
||||||
const nextCheckInMinutes =
|
|
||||||
(tresholdTime - (timeStamp.milliSeconds - lastCheckTimeStamp.milliSeconds)) / 60000;
|
|
||||||
console.log(
|
|
||||||
`next update check in less than ${Math.floor(nextCheckInMinutes) + 1} minute(s): ` +
|
|
||||||
`${plugins.consolecolor.coloredString(
|
|
||||||
`${npmnameArg} has already been checked within the last hour.`,
|
|
||||||
'pink'
|
|
||||||
)}`
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const npmPackage = await this.getNpmPackageFromRegistry(npmnameArg);
|
|
||||||
if (!npmPackage) {
|
|
||||||
plugins.smartlog.defaultLogger.log('warn', 'failed to retrieve package information...');
|
|
||||||
plugins.smartlog.defaultLogger.log('info', 'npms.io might be down');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
newData.latestVersion = npmPackage.version;
|
|
||||||
const upgradeBool = await this.checkIfUpgrade(npmPackage, compareVersion, changelogUrlArg);
|
|
||||||
if (upgradeBool) {
|
|
||||||
// TODO:
|
|
||||||
}
|
|
||||||
this.kvStore.writeKey(npmnameArg, newData);
|
|
||||||
}
|
|
||||||
|
|
||||||
private async getNpmPackageFromRegistry(npmnameArg): Promise<plugins.smartnpm.NpmPackage> {
|
|
||||||
console.log(
|
|
||||||
`smartupdate: checking for newer version of ${plugins.consolecolor.coloredString(
|
|
||||||
npmnameArg,
|
|
||||||
'pink'
|
|
||||||
)}...`
|
|
||||||
);
|
|
||||||
const npmRegistry = new plugins.smartnpm.NpmRegistry();
|
|
||||||
const npmPackage = (await npmRegistry.search({ name: npmnameArg, boostExact: true }))[0];
|
|
||||||
return npmPackage;
|
|
||||||
}
|
|
||||||
|
|
||||||
private async checkIfUpgrade(
|
|
||||||
npmPackage: plugins.smartnpm.NpmPackage,
|
|
||||||
localVersionStringArg: string,
|
|
||||||
changelogUrlArg?: string
|
|
||||||
) {
|
|
||||||
// create Version objects
|
|
||||||
const versionNpm = new plugins.smartversion.SmartVersion(npmPackage.version);
|
|
||||||
const versionLocal = new plugins.smartversion.SmartVersion(localVersionStringArg);
|
|
||||||
if (!versionNpm.greaterThan(versionLocal)) {
|
|
||||||
console.log(
|
|
||||||
`smartupdate: You are running the latest version of ${plugins.consolecolor.coloredString(
|
|
||||||
npmPackage.name,
|
|
||||||
'pink'
|
|
||||||
)}`
|
|
||||||
);
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
plugins.smartlog.defaultLogger.log(
|
|
||||||
'warn',
|
|
||||||
`There is a newer version of ${npmPackage.name} available on npm.`
|
|
||||||
);
|
|
||||||
plugins.smartlog.defaultLogger.log(
|
|
||||||
'warn',
|
|
||||||
`Your version: ${versionLocal.versionString} | version on npm: ${versionNpm.versionString}`
|
|
||||||
);
|
|
||||||
if (!process.env.CI && changelogUrlArg) {
|
|
||||||
console.log('trying to open changelog...');
|
|
||||||
plugins.smartopen.openUrl(changelogUrlArg);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
export let standardHandler = new SmartUpdate();
|
|
||||||
|
105
ts/smartupdate.classes.smartupdate.ts
Normal file
105
ts/smartupdate.classes.smartupdate.ts
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
import * as plugins from './smartupdate.plugins.js';
|
||||||
|
|
||||||
|
interface ICacheStatus {
|
||||||
|
lastCheck: number;
|
||||||
|
latestVersion: string;
|
||||||
|
performedUpgrade: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class SmartUpdate {
|
||||||
|
public npmRegistry: plugins.smartnpm.NpmRegistry;
|
||||||
|
public kvStore = new plugins.npmextra.KeyValueStore('custom', 'global_smartupdate');
|
||||||
|
|
||||||
|
constructor(optionsArg: plugins.smartnpm.INpmRegistryConstructorOptions = {}) {
|
||||||
|
this.npmRegistry = new plugins.smartnpm.NpmRegistry(optionsArg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async checkForCli(npmnameArg: string, compareVersion: string, changelogUrlArg?: string) {
|
||||||
|
// the newData to write
|
||||||
|
const timeStamp = new plugins.smarttime.TimeStamp();
|
||||||
|
const newCacheData: ICacheStatus = {
|
||||||
|
lastCheck: timeStamp.milliSeconds,
|
||||||
|
latestVersion: 'x.x.x',
|
||||||
|
performedUpgrade: false,
|
||||||
|
};
|
||||||
|
|
||||||
|
// the comparison data from the keyValue store
|
||||||
|
const retrievedCacheData: ICacheStatus = await this.kvStore.readKey(npmnameArg);
|
||||||
|
|
||||||
|
if (retrievedCacheData) {
|
||||||
|
const lastCheckTimeStamp = plugins.smarttime.TimeStamp.fromMilliSeconds(
|
||||||
|
retrievedCacheData.lastCheck
|
||||||
|
);
|
||||||
|
const tresholdTime = plugins.smarttime.getMilliSecondsFromUnits({ hours: 1 });
|
||||||
|
if (!lastCheckTimeStamp.isOlderThan(timeStamp, tresholdTime)) {
|
||||||
|
newCacheData.lastCheck = lastCheckTimeStamp.milliSeconds;
|
||||||
|
const nextCheckInMinutes =
|
||||||
|
(tresholdTime - (timeStamp.milliSeconds - lastCheckTimeStamp.milliSeconds)) / 60000;
|
||||||
|
console.log(
|
||||||
|
`next update check in less than ${Math.floor(nextCheckInMinutes) + 1} minute(s): ` +
|
||||||
|
`${plugins.consolecolor.coloredString(
|
||||||
|
`${npmnameArg} has already been checked within the last hour.`,
|
||||||
|
'pink'
|
||||||
|
)}`
|
||||||
|
);
|
||||||
|
return false; // don't upgrade if checked within reasonable time
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const upgradeBool = await this.check(npmnameArg, compareVersion, changelogUrlArg);
|
||||||
|
if (upgradeBool) {
|
||||||
|
const npmPackage = await this.npmRegistry.getPackageInfo(npmnameArg);
|
||||||
|
newCacheData.latestVersion = npmPackage.version;
|
||||||
|
this.kvStore.writeKey(npmnameArg, newCacheData);
|
||||||
|
}
|
||||||
|
|
||||||
|
return upgradeBool;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async getNpmPackageFromRegistry(npmnameArg): Promise<plugins.smartnpm.NpmPackage> {
|
||||||
|
console.log(
|
||||||
|
`smartupdate: checking for newer version of ${plugins.consolecolor.coloredString(
|
||||||
|
npmnameArg,
|
||||||
|
'pink'
|
||||||
|
)}...`
|
||||||
|
);
|
||||||
|
const npmPackage = this.npmRegistry.getPackageInfo(npmnameArg);
|
||||||
|
return npmPackage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async check(
|
||||||
|
npmPackageName: string,
|
||||||
|
localVersionStringArg: string,
|
||||||
|
changelogUrlArg?: string
|
||||||
|
) {
|
||||||
|
const npmPackage = await this.getNpmPackageFromRegistry(npmPackageName);
|
||||||
|
if (!npmPackage) {
|
||||||
|
console.log('warn: failed to retrieve package information...');
|
||||||
|
console.log('info: is the registry down?');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// create Version objects
|
||||||
|
const versionNpm = new plugins.smartversion.SmartVersion(npmPackage.version);
|
||||||
|
const versionLocal = new plugins.smartversion.SmartVersion(localVersionStringArg);
|
||||||
|
if (!versionNpm.greaterThan(versionLocal)) {
|
||||||
|
console.log(
|
||||||
|
`smartupdate: You are running the latest version of ${plugins.consolecolor.coloredString(
|
||||||
|
npmPackage.name,
|
||||||
|
'pink'
|
||||||
|
)}`
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
console.log(`warn: There is a newer version of ${npmPackage.name} available on npm.`);
|
||||||
|
console.log(
|
||||||
|
`warn: Your version: ${versionLocal.versionString} | version on npm: ${versionNpm.versionString}`
|
||||||
|
);
|
||||||
|
if (!process.env.CI && changelogUrlArg) {
|
||||||
|
console.log('trying to open changelog...');
|
||||||
|
plugins.smartopen.openUrl(changelogUrlArg);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,10 +1,8 @@
|
|||||||
import * as smartlog from '@pushrocks/smartlog';
|
import * as consolecolor from '@push.rocks/consolecolor';
|
||||||
smartlog.defaultLogger.enableConsole();
|
import * as npmextra from '@push.rocks/npmextra';
|
||||||
import * as consolecolor from '@pushrocks/consolecolor';
|
import * as smartnpm from '@push.rocks/smartnpm';
|
||||||
import * as npmextra from '@pushrocks/npmextra';
|
import * as smartopen from '@push.rocks/smartopen';
|
||||||
import * as smartnpm from '@pushrocks/smartnpm';
|
import * as smarttime from '@push.rocks/smarttime';
|
||||||
import * as smartopen from '@pushrocks/smartopen';
|
import * as smartversion from '@push.rocks/smartversion';
|
||||||
import * as smarttime from '@pushrocks/smarttime';
|
|
||||||
import * as smartversion from '@pushrocks/smartversion';
|
|
||||||
|
|
||||||
export { smartlog, consolecolor, npmextra, smartnpm, smartopen, smarttime, smartversion };
|
export { consolecolor, npmextra, smartnpm, smartopen, smarttime, smartversion };
|
||||||
|
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