Compare commits
17 Commits
Author | SHA1 | Date | |
---|---|---|---|
2d34397b9b | |||
2744e1a92b | |||
b8987b7913 | |||
95ffb06e77 | |||
71abbbb5f1 | |||
9dfa1a789e | |||
c68ea1c8fd | |||
8e943512f8 | |||
c010319076 | |||
cf03e58c6f | |||
d59875f23f | |||
6b13e46947 | |||
096c38de9e | |||
7292b45d33 | |||
3ddad53d29 | |||
617b49aaba | |||
2dcd93b431 |
@ -19,23 +19,35 @@ mirror:
|
|||||||
stage: security
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci git mirror
|
- npmci git mirror
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
|
|
||||||
audit:
|
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
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
stage: security
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci command npm install --ignore-scripts
|
- npmci command npm install --ignore-scripts
|
||||||
- npmci command npm config set registry https://registry.npmjs.org
|
- npmci command npm config set registry https://registry.npmjs.org
|
||||||
- npmci command npm audit --audit-level=high
|
- npmci command npm audit --audit-level=high --only=dev
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
allow_failure: true
|
||||||
|
|
||||||
# ====================
|
# ====================
|
||||||
# test stage
|
# test stage
|
||||||
@ -50,9 +62,7 @@ testStable:
|
|||||||
- npmci npm test
|
- npmci npm test
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
|
||||||
- docker
|
- docker
|
||||||
- priv
|
|
||||||
|
|
||||||
testBuild:
|
testBuild:
|
||||||
stage: test
|
stage: test
|
||||||
@ -63,9 +73,7 @@ testBuild:
|
|||||||
- npmci command npm run build
|
- npmci command npm run build
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
|
||||||
|
|
||||||
release:
|
release:
|
||||||
stage: release
|
stage: release
|
||||||
@ -85,6 +93,8 @@ release:
|
|||||||
codequality:
|
codequality:
|
||||||
stage: metadata
|
stage: metadata
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
script:
|
script:
|
||||||
- npmci command npm install -g tslint typescript
|
- npmci command npm install -g tslint typescript
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
|
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@ -15,7 +15,7 @@
|
|||||||
"properties": {
|
"properties": {
|
||||||
"projectType": {
|
"projectType": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": ["website", "element", "service", "npm"]
|
"enum": ["website", "element", "service", "npm", "wcc"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
8935
package-lock.json
generated
8935
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
24
package.json
24
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartnpm",
|
"name": "@pushrocks/smartnpm",
|
||||||
"version": "1.0.16",
|
"version": "1.0.25",
|
||||||
"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",
|
||||||
@ -12,19 +12,22 @@
|
|||||||
"build": "(tsbuild --web)"
|
"build": "(tsbuild --web)"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.24",
|
"@gitzone/tsbuild": "^2.1.25",
|
||||||
"@gitzone/tsrun": "^1.2.12",
|
"@gitzone/tsrun": "^1.2.12",
|
||||||
"@gitzone/tstest": "^1.0.33",
|
"@gitzone/tstest": "^1.0.52",
|
||||||
"@pushrocks/tapbundle": "^3.2.1",
|
"@pushrocks/tapbundle": "^3.2.14",
|
||||||
"@types/node": "^14.0.14",
|
"@types/node": "^14.14.41",
|
||||||
"tslint": "^6.1.2",
|
"tslint": "^6.1.3",
|
||||||
"tslint-config-prettier": "^1.18.0"
|
"tslint-config-prettier": "^1.18.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/consolecolor": "^2.0.1",
|
"@pushrocks/consolecolor": "^2.0.1",
|
||||||
"@pushrocks/smartarchive": "^1.0.12",
|
"@pushrocks/levelcache": "^1.0.9",
|
||||||
"@pushrocks/smartfile": "^7.0.12",
|
"@pushrocks/smartarchive": "^2.0.4",
|
||||||
"@pushrocks/smartrequest": "^1.1.47",
|
"@pushrocks/smartfile": "^8.0.10",
|
||||||
|
"@pushrocks/smartpromise": "^3.1.5",
|
||||||
|
"@pushrocks/smartrequest": "^1.1.51",
|
||||||
|
"@pushrocks/smartversion": "^2.0.7",
|
||||||
"package-json": "^6.5.0"
|
"package-json": "^6.5.0"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
@ -38,5 +41,8 @@
|
|||||||
"cli.js",
|
"cli.js",
|
||||||
"npmextra.json",
|
"npmextra.json",
|
||||||
"readme.md"
|
"readme.md"
|
||||||
|
],
|
||||||
|
"browserslist": [
|
||||||
|
"last 1 chrome versions"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -27,13 +27,6 @@ Platform support | [
|
|
||||||
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
|
||||||
|
|
||||||
[](https://push.rocks)
|
|
||||||
|
|
||||||
## Contribution
|
## Contribution
|
||||||
|
|
||||||
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). :)
|
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). :)
|
||||||
|
155
test/test.ts
155
test/test.ts
@ -17,7 +17,7 @@ tap.test('should create valid instances', async () => {
|
|||||||
|
|
||||||
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).to.equal('@pushrocks/smartupdate');
|
||||||
});
|
});
|
||||||
@ -25,7 +25,7 @@ tap.test('should produce a valid search string and this return npmts', async ()
|
|||||||
// 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.one',
|
||||||
});
|
});
|
||||||
expect(verdaccioRegistry).to.be.instanceOf(smartnpm.NpmRegistry);
|
expect(verdaccioRegistry).to.be.instanceOf(smartnpm.NpmRegistry);
|
||||||
});
|
});
|
||||||
@ -39,8 +39,157 @@ tap.test('should get package from verdaccio', async () => {
|
|||||||
tap.test('should get a specific file from a package', async () => {
|
tap.test('should get a specific file from a package', async () => {
|
||||||
const bundleFile = await verdaccioRegistry.getFileFromPackage(
|
const bundleFile = await verdaccioRegistry.getFileFromPackage(
|
||||||
'@pushrocks/websetup',
|
'@pushrocks/websetup',
|
||||||
'dist_bundle/bundle.js'
|
'ts/index.ts'
|
||||||
);
|
);
|
||||||
|
console.log(bundleFile.contentBuffer.toString());
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.start();
|
tap.start();
|
||||||
|
|
||||||
|
const hi = {
|
||||||
|
_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',
|
||||||
|
};
|
||||||
|
@ -1,13 +1,35 @@
|
|||||||
import * as plugins from './smartnpm.plugins';
|
import * as plugins from './smartnpm.plugins';
|
||||||
import { NpmRegistry } from './smartnpm.classes.npmregistry';
|
import { NpmRegistry } from './smartnpm.classes.npmregistry';
|
||||||
|
import { PackageDisttag } from './smartnpm.classes.packagedisttag';
|
||||||
|
import { PackageVersion, IVersionData } from './smartnpm.classes.packageversion';
|
||||||
|
|
||||||
export class NpmPackage {
|
export class NpmPackage {
|
||||||
public static async createFromFullMetadata(
|
public static async createFromFullMetadataAndVersionData(
|
||||||
npmRegistryArg: NpmRegistry,
|
npmRegistryArg: NpmRegistry,
|
||||||
fullMetadata: plugins.packageJson.FullMetadata
|
fullMetadataArg: plugins.packageJson.FullMetadata,
|
||||||
|
versionsDataArg: {
|
||||||
|
name: string;
|
||||||
|
'dist-tags': { [key: string]: string };
|
||||||
|
versions: { [key: string]: IVersionData };
|
||||||
|
}
|
||||||
) {
|
) {
|
||||||
const npmPackage = new NpmPackage(npmRegistryArg);
|
const npmPackage = new NpmPackage(npmRegistryArg);
|
||||||
Object.assign(npmPackage, fullMetadata);
|
Object.assign(npmPackage, fullMetadataArg);
|
||||||
|
npmPackage.allVersions = [];
|
||||||
|
npmPackage.allDistTags = [];
|
||||||
|
for (const versionArg of Object.keys(versionsDataArg.versions)) {
|
||||||
|
const packageVersion = PackageVersion.createFromVersionData(
|
||||||
|
versionsDataArg.versions[versionArg]
|
||||||
|
);
|
||||||
|
npmPackage.allVersions.push(packageVersion);
|
||||||
|
}
|
||||||
|
for (const distTagArg of Object.keys(versionsDataArg['dist-tags'])) {
|
||||||
|
const packageDistTag = new PackageDisttag(
|
||||||
|
distTagArg,
|
||||||
|
versionsDataArg['dist-tags'][distTagArg]
|
||||||
|
);
|
||||||
|
npmPackage.allDistTags.push(packageDistTag);
|
||||||
|
}
|
||||||
return npmPackage;
|
return npmPackage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -15,6 +37,8 @@ export class NpmPackage {
|
|||||||
public name: string = null;
|
public name: string = null;
|
||||||
public scope: string = null;
|
public scope: string = null;
|
||||||
public version: string = null;
|
public version: string = null;
|
||||||
|
public allVersions: PackageVersion[];
|
||||||
|
public allDistTags: PackageDisttag[];
|
||||||
public description: string = null;
|
public description: string = null;
|
||||||
public keywords: string[] = null;
|
public keywords: string[] = null;
|
||||||
public date: string;
|
public date: string;
|
||||||
@ -48,9 +72,9 @@ export class NpmPackage {
|
|||||||
} = null;
|
} = null;
|
||||||
public searchScore: number = null;
|
public searchScore: number = null;
|
||||||
|
|
||||||
public npmRegistry: NpmRegistry;
|
public npmRegistryRef: NpmRegistry;
|
||||||
constructor(npmRegistryArg: NpmRegistry) {
|
constructor(npmRegistryArg: NpmRegistry) {
|
||||||
this.npmRegistry = npmRegistryArg;
|
this.npmRegistryRef = npmRegistryArg;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -58,6 +82,78 @@ export class NpmPackage {
|
|||||||
*/
|
*/
|
||||||
public async saveToDisk(targetDir: string) {
|
public async saveToDisk(targetDir: string) {
|
||||||
const smartarchiveInstance = new plugins.smartarchive.SmartArchive();
|
const smartarchiveInstance = new plugins.smartarchive.SmartArchive();
|
||||||
await smartarchiveInstance.extractArchiveFromUrl(this.dist.tarball, targetDir);
|
await smartarchiveInstance.extractArchiveFromUrlToFs(this.dist.tarball, targetDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* saves the complete package to cache
|
||||||
|
*/
|
||||||
|
public async saveToCache() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get file from package
|
||||||
|
*/
|
||||||
|
public async getFileFromPackage(
|
||||||
|
filePath: string,
|
||||||
|
optionsArg?: {
|
||||||
|
distTag?: string;
|
||||||
|
version?: string;
|
||||||
|
}
|
||||||
|
): Promise<plugins.smartfile.Smartfile> {
|
||||||
|
const done = plugins.smartpromise.defer<plugins.smartfile.Smartfile>();
|
||||||
|
const smartarchiveInstance = new plugins.smartarchive.SmartArchive();
|
||||||
|
let tarballUrl = this.dist.tarball;
|
||||||
|
if (optionsArg && (optionsArg.version || optionsArg.distTag)) {
|
||||||
|
if (optionsArg.distTag && optionsArg.version) {
|
||||||
|
throw new Error('Please either sepcify version OR disttag, not both.');
|
||||||
|
}
|
||||||
|
let targetVersion: plugins.smartversion.SmartVersion;
|
||||||
|
if (optionsArg.distTag) {
|
||||||
|
const targetDistTag = this.allDistTags.find((distTag) => {
|
||||||
|
return distTag.name === optionsArg.distTag;
|
||||||
|
});
|
||||||
|
if (targetDistTag) {
|
||||||
|
targetVersion = new plugins.smartversion.SmartVersion(targetDistTag.targetVersion);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const smartversion = plugins.smartversion.SmartVersion.fromFuzzyString(optionsArg.version);
|
||||||
|
}
|
||||||
|
|
||||||
|
// lets find the best matching release
|
||||||
|
const versionStrings = this.allVersions.map((packageVersion) => packageVersion.version);
|
||||||
|
const bestMatchingVersion = targetVersion.getBestMatch(versionStrings);
|
||||||
|
if (!bestMatchingVersion) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
tarballUrl = this.allVersions.find(
|
||||||
|
(packageVersion) => packageVersion.version === bestMatchingVersion
|
||||||
|
).dist.tarball;
|
||||||
|
}
|
||||||
|
const fileObservable = await smartarchiveInstance.extractArchiveFromUrlToObservable(tarballUrl);
|
||||||
|
const wantedFilePath = plugins.path.join('package', filePath);
|
||||||
|
const subscription = fileObservable.subscribe(
|
||||||
|
(fileArg) => {
|
||||||
|
if (fileArg.path === wantedFilePath) {
|
||||||
|
// lets care about caching
|
||||||
|
|
||||||
|
// lets resolve with the wanted file
|
||||||
|
done.resolve(fileArg);
|
||||||
|
subscription.unsubscribe();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
(err) => {
|
||||||
|
console.log(err);
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
done.resolve(null);
|
||||||
|
subscription.unsubscribe();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return done.promise;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* updates the package with information from the registry
|
||||||
|
*/
|
||||||
|
update() {}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import { ISearchObject } from './smartnpm.interfaces';
|
|||||||
|
|
||||||
// classes
|
// classes
|
||||||
import { NpmPackage } from './smartnpm.classes.npmpackage';
|
import { NpmPackage } from './smartnpm.classes.npmpackage';
|
||||||
|
import { RegistryCache } from './smartnpm.classes.registrycache';
|
||||||
|
|
||||||
export interface INpmRegistryConstructorOptions {
|
export interface INpmRegistryConstructorOptions {
|
||||||
npmRegistryUrl?: string;
|
npmRegistryUrl?: string;
|
||||||
@ -13,7 +14,7 @@ export interface INpmRegistryConstructorOptions {
|
|||||||
|
|
||||||
export class NpmRegistry {
|
export class NpmRegistry {
|
||||||
public options: INpmRegistryConstructorOptions;
|
public options: INpmRegistryConstructorOptions;
|
||||||
public registry: string;
|
public registryCache: RegistryCache;
|
||||||
private searchDomain = 'https://api.npms.io/v2/search?q=';
|
private searchDomain = 'https://api.npms.io/v2/search?q=';
|
||||||
|
|
||||||
constructor(optionsArg: INpmRegistryConstructorOptions = {}) {
|
constructor(optionsArg: INpmRegistryConstructorOptions = {}) {
|
||||||
@ -24,6 +25,7 @@ export class NpmRegistry {
|
|||||||
...defaultOptions,
|
...defaultOptions,
|
||||||
...optionsArg,
|
...optionsArg,
|
||||||
};
|
};
|
||||||
|
this.registryCache = new RegistryCache(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -35,7 +37,11 @@ export class NpmRegistry {
|
|||||||
registryUrl: this.options.npmRegistryUrl,
|
registryUrl: this.options.npmRegistryUrl,
|
||||||
fullMetadata: true,
|
fullMetadata: true,
|
||||||
});
|
});
|
||||||
const npmPackage = await NpmPackage.createFromFullMetadata(this, fullMetadata);
|
const versionData = await plugins.packageJson(packageName, {
|
||||||
|
registryUrl: this.options.npmRegistryUrl,
|
||||||
|
allVersions: true
|
||||||
|
});
|
||||||
|
const npmPackage = await NpmPackage.createFromFullMetadataAndVersionData(this, fullMetadata, versionData as any);
|
||||||
return npmPackage;
|
return npmPackage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,6 +51,7 @@ export class NpmRegistry {
|
|||||||
* @param targetDir
|
* @param targetDir
|
||||||
*/
|
*/
|
||||||
public async savePackageToDisk(packageName: string, targetDir: string): Promise<void> {
|
public async savePackageToDisk(packageName: string, targetDir: string): Promise<void> {
|
||||||
|
plugins.smartfile.fs.ensureDirSync(paths.nogitDir);
|
||||||
const npmPackage = await this.getPackageInfo(packageName);
|
const npmPackage = await this.getPackageInfo(packageName);
|
||||||
await npmPackage.saveToDisk(targetDir);
|
await npmPackage.saveToDisk(targetDir);
|
||||||
}
|
}
|
||||||
@ -52,15 +59,32 @@ export class NpmRegistry {
|
|||||||
/**
|
/**
|
||||||
* gets a file from a package as Smartfile
|
* gets a file from a package as Smartfile
|
||||||
*/
|
*/
|
||||||
public async getFileFromPackage(packageName: string, filePath: string) {
|
public async getFileFromPackage(packageNameArg: string, filePath: string, optionsArg?: {
|
||||||
const baseDir = plugins.path.join(paths.nogitDir, packageName.replace('/', '__'));
|
distTag?: string;
|
||||||
|
version?: string;
|
||||||
|
}): Promise<plugins.smartfile.Smartfile> {
|
||||||
|
const fileId = `${this.options.npmRegistryUrl}//+//${packageNameArg}//+//${filePath}//+//${optionsArg?.distTag || optionsArg?.version}`;
|
||||||
|
const cachedFile: plugins.smartfile.Smartfile = await this.registryCache.getCachedFile(fileId);
|
||||||
|
if (!cachedFile) {
|
||||||
|
const npmPackage = await this.getPackageInfo(packageNameArg);
|
||||||
|
const fileResult = await npmPackage.getFileFromPackage(filePath, optionsArg);
|
||||||
|
this.registryCache.cacheSmartFile(fileId, fileResult);
|
||||||
|
return fileResult;
|
||||||
|
} else {
|
||||||
|
return cachedFile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getPackageAsSmartfileVirtualDir(packageNameArg: string): Promise<plugins.smartfile.VirtualDirectory> {
|
||||||
|
/**
|
||||||
|
* TODO: rewrite as memory only
|
||||||
|
*/
|
||||||
|
const baseDir = plugins.path.join(paths.nogitDir, packageNameArg.replace('/', '__'));
|
||||||
await plugins.smartfile.fs.ensureDir(baseDir);
|
await plugins.smartfile.fs.ensureDir(baseDir);
|
||||||
await this.savePackageToDisk(packageName, baseDir);
|
await this.savePackageToDisk(packageNameArg, baseDir);
|
||||||
const smartfile = await plugins.smartfile.Smartfile.fromFilePath(
|
const virtualDir = await plugins.smartfile.VirtualDirectory.fromFsDirPath(baseDir);
|
||||||
plugins.path.join(baseDir, 'package', filePath)
|
|
||||||
);
|
|
||||||
await plugins.smartfile.fs.remove(baseDir);
|
await plugins.smartfile.fs.remove(baseDir);
|
||||||
return smartfile;
|
return virtualDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
11
ts/smartnpm.classes.packagedisttag.ts
Normal file
11
ts/smartnpm.classes.packagedisttag.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import * as plugins from './smartnpm.plugins';
|
||||||
|
|
||||||
|
export class PackageDisttag {
|
||||||
|
name: string;
|
||||||
|
targetVersion: string;
|
||||||
|
|
||||||
|
constructor(nameArg: string, targetVersionArg: string) {
|
||||||
|
this.name = nameArg;
|
||||||
|
this.targetVersion = targetVersionArg;
|
||||||
|
}
|
||||||
|
}
|
31
ts/smartnpm.classes.packageversion.ts
Normal file
31
ts/smartnpm.classes.packageversion.ts
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
import * as plugins from './smartnpm.plugins';
|
||||||
|
|
||||||
|
export interface IVersionData {
|
||||||
|
name: string;
|
||||||
|
version: string;
|
||||||
|
dependencies: { [key: string]: string };
|
||||||
|
devDependencies: { [key: string]: string };
|
||||||
|
dist: {
|
||||||
|
integrity: string;
|
||||||
|
shasum: string;
|
||||||
|
tarball: string;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export class PackageVersion implements IVersionData {
|
||||||
|
public static createFromVersionData(versionDataArg: IVersionData) {
|
||||||
|
const packageVersion = new PackageVersion();
|
||||||
|
Object.assign(packageVersion, versionDataArg);
|
||||||
|
return packageVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
name: string;
|
||||||
|
version: string;
|
||||||
|
dependencies: { [key: string]: string };
|
||||||
|
devDependencies: { [key: string]: string };
|
||||||
|
dist: {
|
||||||
|
integrity: string;
|
||||||
|
shasum: string;
|
||||||
|
tarball: string;
|
||||||
|
};
|
||||||
|
}
|
30
ts/smartnpm.classes.registrycache.ts
Normal file
30
ts/smartnpm.classes.registrycache.ts
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
import { NpmRegistry } from './smartnpm.classes.npmregistry';
|
||||||
|
import * as plugins from './smartnpm.plugins';
|
||||||
|
|
||||||
|
export class RegistryCache {
|
||||||
|
npmregistryRef: NpmRegistry;
|
||||||
|
public levelCache: plugins.levelcache.LevelCache;
|
||||||
|
|
||||||
|
constructor(npmRegistryRefArg: NpmRegistry) {
|
||||||
|
this.npmregistryRef = npmRegistryRefArg;
|
||||||
|
this.levelCache = new plugins.levelcache.LevelCache({
|
||||||
|
cacheId: encodeURIComponent(this.npmregistryRef.options.npmRegistryUrl),
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getCachedFile (fileId: string): Promise<plugins.smartfile.Smartfile> {
|
||||||
|
const cacheEntry = await this.levelCache.retrieveCacheEntryByKey(fileId);
|
||||||
|
if (cacheEntry) {
|
||||||
|
return plugins.smartfile.Smartfile.fromFoldedJson(cacheEntry.contents.toString());
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async cacheSmartFile (fileIdArg: string, smartfileArg: plugins.smartfile.Smartfile) {
|
||||||
|
await this.levelCache.storeCacheEntryByKey(fileIdArg, new plugins.levelcache.CacheEntry({
|
||||||
|
contents: Buffer.from(smartfileArg.foldToJson()),
|
||||||
|
ttl: 60000
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
@ -2,4 +2,3 @@ import * as plugins from './smartnpm.plugins';
|
|||||||
|
|
||||||
export const packageDir = plugins.path.join(__dirname, '../');
|
export const packageDir = plugins.path.join(__dirname, '../');
|
||||||
export const nogitDir = plugins.path.join(packageDir, '.nogit/');
|
export const nogitDir = plugins.path.join(packageDir, '.nogit/');
|
||||||
plugins.smartfile.fs.ensureDirSync(nogitDir);
|
|
||||||
|
@ -5,11 +5,14 @@ export { path };
|
|||||||
|
|
||||||
// @pushrocks scope
|
// @pushrocks scope
|
||||||
import * as consolecolor from '@pushrocks/consolecolor';
|
import * as consolecolor from '@pushrocks/consolecolor';
|
||||||
|
import * as levelcache from '@pushrocks/levelcache';
|
||||||
import * as smartarchive from '@pushrocks/smartarchive';
|
import * as smartarchive from '@pushrocks/smartarchive';
|
||||||
import * as smartfile from '@pushrocks/smartfile';
|
import * as smartfile from '@pushrocks/smartfile';
|
||||||
|
import * as smartpromise from '@pushrocks/smartpromise';
|
||||||
import * as smartrequest from '@pushrocks/smartrequest';
|
import * as smartrequest from '@pushrocks/smartrequest';
|
||||||
|
import * as smartversion from '@pushrocks/smartversion';
|
||||||
|
|
||||||
export { consolecolor, smartarchive, smartfile, smartrequest };
|
export { consolecolor, levelcache, smartarchive, smartfile, smartpromise, smartrequest, smartversion };
|
||||||
|
|
||||||
// third party scope
|
// third party scope
|
||||||
import packageJson from 'package-json';
|
import packageJson from 'package-json';
|
||||||
|
Reference in New Issue
Block a user