Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
c68ea1c8fd | |||
8e943512f8 | |||
c010319076 | |||
cf03e58c6f | |||
d59875f23f | |||
6b13e46947 | |||
096c38de9e | |||
7292b45d33 | |||
3ddad53d29 | |||
617b49aaba | |||
2dcd93b431 |
@ -19,23 +19,35 @@ mirror:
|
||||
stage: security
|
||||
script:
|
||||
- npmci git mirror
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- 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
|
||||
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
|
||||
- npmci command npm audit --audit-level=high --only=dev
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
allow_failure: true
|
||||
|
||||
# ====================
|
||||
# test stage
|
||||
@ -50,9 +62,7 @@ testStable:
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- priv
|
||||
|
||||
testBuild:
|
||||
stage: test
|
||||
@ -63,9 +73,7 @@ testBuild:
|
||||
- npmci command npm run build
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
release:
|
||||
stage: release
|
||||
@ -85,6 +93,8 @@ release:
|
||||
codequality:
|
||||
stage: metadata
|
||||
allow_failure: true
|
||||
only:
|
||||
- tags
|
||||
script:
|
||||
- npmci command npm install -g tslint typescript
|
||||
- npmci npm prepare
|
||||
|
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@ -15,7 +15,7 @@
|
||||
"properties": {
|
||||
"projectType": {
|
||||
"type": "string",
|
||||
"enum": ["website", "element", "service", "npm"]
|
||||
"enum": ["website", "element", "service", "npm", "wcc"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
8609
package-lock.json
generated
8609
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
22
package.json
22
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@pushrocks/smartnpm",
|
||||
"version": "1.0.16",
|
||||
"version": "1.0.22",
|
||||
"private": false,
|
||||
"description": "interface with npm to retrieve package information",
|
||||
"main": "dist_ts/index.js",
|
||||
@ -12,19 +12,20 @@
|
||||
"build": "(tsbuild --web)"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.1.24",
|
||||
"@gitzone/tsbuild": "^2.1.25",
|
||||
"@gitzone/tsrun": "^1.2.12",
|
||||
"@gitzone/tstest": "^1.0.33",
|
||||
"@pushrocks/tapbundle": "^3.2.1",
|
||||
"@types/node": "^14.0.14",
|
||||
"tslint": "^6.1.2",
|
||||
"@gitzone/tstest": "^1.0.52",
|
||||
"@pushrocks/tapbundle": "^3.2.14",
|
||||
"@types/node": "^14.14.41",
|
||||
"tslint": "^6.1.3",
|
||||
"tslint-config-prettier": "^1.18.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@pushrocks/consolecolor": "^2.0.1",
|
||||
"@pushrocks/smartarchive": "^1.0.12",
|
||||
"@pushrocks/smartfile": "^7.0.12",
|
||||
"@pushrocks/smartrequest": "^1.1.47",
|
||||
"@pushrocks/smartarchive": "^2.0.4",
|
||||
"@pushrocks/smartfile": "^8.0.9",
|
||||
"@pushrocks/smartpromise": "^3.1.3",
|
||||
"@pushrocks/smartrequest": "^1.1.51",
|
||||
"package-json": "^6.5.0"
|
||||
},
|
||||
"files": [
|
||||
@ -38,5 +39,8 @@
|
||||
"cli.js",
|
||||
"npmextra.json",
|
||||
"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
|
||||
|
||||
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). :)
|
||||
|
@ -17,7 +17,7 @@ tap.test('should create valid instances', async () => {
|
||||
|
||||
tap.test('should produce a valid search string and this return npmts', async () => {
|
||||
const packages = await npmRegistry.searchOnNpm({
|
||||
name: '@pushrocks/smartupdate'
|
||||
name: '@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
|
||||
tap.test('should create a verdaccio registry', async () => {
|
||||
verdaccioRegistry = new NpmRegistry({
|
||||
npmRegistryUrl: 'https://verdaccio.lossless.one'
|
||||
npmRegistryUrl: 'https://verdaccio.lossless.one',
|
||||
});
|
||||
expect(verdaccioRegistry).to.be.instanceOf(smartnpm.NpmRegistry);
|
||||
});
|
||||
@ -39,8 +39,9 @@ tap.test('should get package from verdaccio', async () => {
|
||||
tap.test('should get a specific file from a package', async () => {
|
||||
const bundleFile = await verdaccioRegistry.getFileFromPackage(
|
||||
'@pushrocks/websetup',
|
||||
'dist_bundle/bundle.js'
|
||||
'ts/index.ts'
|
||||
);
|
||||
console.log(bundleFile.contentBuffer.toString());
|
||||
});
|
||||
|
||||
tap.start();
|
||||
|
@ -48,9 +48,9 @@ export class NpmPackage {
|
||||
} = null;
|
||||
public searchScore: number = null;
|
||||
|
||||
public npmRegistry: NpmRegistry;
|
||||
public npmRegistryRef: NpmRegistry;
|
||||
constructor(npmRegistryArg: NpmRegistry) {
|
||||
this.npmRegistry = npmRegistryArg;
|
||||
this.npmRegistryRef = npmRegistryArg;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -58,6 +58,38 @@ export class NpmPackage {
|
||||
*/
|
||||
public async saveToDisk(targetDir: string) {
|
||||
const smartarchiveInstance = new plugins.smartarchive.SmartArchive();
|
||||
await smartarchiveInstance.extractArchiveFromUrl(this.dist.tarball, targetDir);
|
||||
await smartarchiveInstance.extractArchiveFromUrlToFs(this.dist.tarball, targetDir);
|
||||
}
|
||||
|
||||
/**
|
||||
* saves the package to memory
|
||||
*/
|
||||
public async saveToMemory() {}
|
||||
|
||||
/**
|
||||
* get file from package
|
||||
*/
|
||||
public async getFileFromPackage(filePath: string): Promise<plugins.smartfile.Smartfile> {
|
||||
const done = plugins.smartpromise.defer<plugins.smartfile.Smartfile>();
|
||||
const smartarchiveInstance = new plugins.smartarchive.SmartArchive();
|
||||
const fileObservable = await smartarchiveInstance.extractArchiveFromUrlToObservable(
|
||||
this.dist.tarball
|
||||
);
|
||||
const wantedFilePath = plugins.path.join('package', filePath);
|
||||
const subscription = fileObservable.subscribe(
|
||||
(fileArg) => {
|
||||
if (fileArg.path === wantedFilePath) {
|
||||
done.resolve(fileArg);
|
||||
subscription.unsubscribe();
|
||||
}
|
||||
},
|
||||
(err) => {
|
||||
console.log(err);
|
||||
},
|
||||
() => {
|
||||
subscription.unsubscribe();
|
||||
}
|
||||
);
|
||||
return done.promise;
|
||||
}
|
||||
}
|
||||
|
@ -45,6 +45,7 @@ export class NpmRegistry {
|
||||
* @param targetDir
|
||||
*/
|
||||
public async savePackageToDisk(packageName: string, targetDir: string): Promise<void> {
|
||||
plugins.smartfile.fs.ensureDirSync(paths.nogitDir);
|
||||
const npmPackage = await this.getPackageInfo(packageName);
|
||||
await npmPackage.saveToDisk(targetDir);
|
||||
}
|
||||
@ -52,15 +53,18 @@ export class NpmRegistry {
|
||||
/**
|
||||
* gets a file from a package as Smartfile
|
||||
*/
|
||||
public async getFileFromPackage(packageName: string, filePath: string) {
|
||||
const baseDir = plugins.path.join(paths.nogitDir, packageName.replace('/', '__'));
|
||||
public async getFileFromPackage(packageNameArg: string, filePath: string): Promise<plugins.smartfile.Smartfile> {
|
||||
const npmPackage = await this.getPackageInfo(packageNameArg);
|
||||
return npmPackage.getFileFromPackage(filePath);
|
||||
}
|
||||
|
||||
public async getPackageAsSmartfileVirtualDir(packageNameArg: string): Promise<plugins.smartfile.VirtualDirectory> {
|
||||
const baseDir = plugins.path.join(paths.nogitDir, packageNameArg.replace('/', '__'));
|
||||
await plugins.smartfile.fs.ensureDir(baseDir);
|
||||
await this.savePackageToDisk(packageName, baseDir);
|
||||
const smartfile = await plugins.smartfile.Smartfile.fromFilePath(
|
||||
plugins.path.join(baseDir, 'package', filePath)
|
||||
);
|
||||
await this.savePackageToDisk(packageNameArg, baseDir);
|
||||
const virtualDir = await plugins.smartfile.VirtualDirectory.fromFsDirPath(baseDir);
|
||||
await plugins.smartfile.fs.remove(baseDir);
|
||||
return smartfile;
|
||||
return virtualDir;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2,4 +2,3 @@ import * as plugins from './smartnpm.plugins';
|
||||
|
||||
export const packageDir = plugins.path.join(__dirname, '../');
|
||||
export const nogitDir = plugins.path.join(packageDir, '.nogit/');
|
||||
plugins.smartfile.fs.ensureDirSync(nogitDir);
|
||||
|
@ -7,9 +7,10 @@ export { path };
|
||||
import * as consolecolor from '@pushrocks/consolecolor';
|
||||
import * as smartarchive from '@pushrocks/smartarchive';
|
||||
import * as smartfile from '@pushrocks/smartfile';
|
||||
import * as smartpromise from '@pushrocks/smartpromise';
|
||||
import * as smartrequest from '@pushrocks/smartrequest';
|
||||
|
||||
export { consolecolor, smartarchive, smartfile, smartrequest };
|
||||
export { consolecolor, smartarchive, smartfile, smartpromise, smartrequest };
|
||||
|
||||
// third party scope
|
||||
import packageJson from 'package-json';
|
||||
|
Reference in New Issue
Block a user