fix(core): update
This commit is contained in:
parent
6b13e46947
commit
d59875f23f
701
package-lock.json
generated
701
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -15,15 +15,16 @@
|
|||||||
"@gitzone/tsbuild": "^2.1.25",
|
"@gitzone/tsbuild": "^2.1.25",
|
||||||
"@gitzone/tsrun": "^1.2.12",
|
"@gitzone/tsrun": "^1.2.12",
|
||||||
"@gitzone/tstest": "^1.0.52",
|
"@gitzone/tstest": "^1.0.52",
|
||||||
"@pushrocks/tapbundle": "^3.2.9",
|
"@pushrocks/tapbundle": "^3.2.14",
|
||||||
"@types/node": "^14.11.2",
|
"@types/node": "^14.14.41",
|
||||||
"tslint": "^6.1.3",
|
"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/smartarchive": "^2.0.2",
|
||||||
"@pushrocks/smartfile": "^8.0.4",
|
"@pushrocks/smartfile": "^8.0.9",
|
||||||
|
"@pushrocks/smartpromise": "^3.1.3",
|
||||||
"@pushrocks/smartrequest": "^1.1.51",
|
"@pushrocks/smartrequest": "^1.1.51",
|
||||||
"package-json": "^6.5.0"
|
"package-json": "^6.5.0"
|
||||||
},
|
},
|
||||||
|
@ -39,8 +39,9 @@ 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();
|
||||||
|
@ -48,9 +48,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 +58,38 @@ 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 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
|
* @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 +53,9 @@ 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) {
|
public async getFileFromPackage(packageNameArg: string, filePath: string): Promise<plugins.smartfile.Smartfile> {
|
||||||
const baseDir = plugins.path.join(paths.nogitDir, packageNameArg.replace('/', '__'));
|
const npmPackage = await this.getPackageInfo(packageNameArg);
|
||||||
await plugins.smartfile.fs.ensureDir(baseDir);
|
return npmPackage.getFileFromPackage(filePath);
|
||||||
await this.savePackageToDisk(packageNameArg, baseDir);
|
|
||||||
const smartfile = await plugins.smartfile.Smartfile.fromFilePath(
|
|
||||||
plugins.path.join(baseDir, 'package', filePath)
|
|
||||||
);
|
|
||||||
await plugins.smartfile.fs.remove(baseDir);
|
|
||||||
return smartfile;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getPackageAsSmartfileVirtualDir(packageNameArg: string): Promise<plugins.smartfile.VirtualDirectory> {
|
public async getPackageAsSmartfileVirtualDir(packageNameArg: string): Promise<plugins.smartfile.VirtualDirectory> {
|
||||||
|
@ -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);
|
|
||||||
|
@ -7,9 +7,10 @@ export { path };
|
|||||||
import * as consolecolor from '@pushrocks/consolecolor';
|
import * as consolecolor from '@pushrocks/consolecolor';
|
||||||
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';
|
||||||
|
|
||||||
export { consolecolor, smartarchive, smartfile, smartrequest };
|
export { consolecolor, smartarchive, smartfile, smartpromise, smartrequest };
|
||||||
|
|
||||||
// third party scope
|
// third party scope
|
||||||
import packageJson from 'package-json';
|
import packageJson from 'package-json';
|
||||||
|
Loading…
Reference in New Issue
Block a user