Skip to content

Commit

Permalink
fix: flow issues
Browse files Browse the repository at this point in the history
  • Loading branch information
@jotadeveloper authored and sergiohgz committed Aug 13, 2019
1 parent 184466c commit f42a284
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 5 deletions.
53 changes: 53 additions & 0 deletions plugins/local-storage/src/___tests___/fixtures/pkg.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
const json = {
"_id": "@scope\/pk1-test",
"name": "@scope\/pk1-test",
"description": "",
"dist-tags": {
"latest": "1.0.6"
},
"versions": {
"1.0.6": {
"name": "@scope\/pk1-test",
"version": "1.0.6",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [

],
"author": {
"name": "Juan Picado",
"email": "[email protected]"
},
"license": "ISC",
"dependencies": {
"verdaccio": "^2.7.2"
},
"readme": "# test",
"readmeFilename": "README.md",
"_id": "@scope\/[email protected]",
"_npmVersion": "5.5.1",
"_nodeVersion": "8.7.0",
"_npmUser": {

},
"dist": {
"integrity": "sha512-6gHiERpiDgtb3hjqpQH5\/i7zRmvYi9pmCjQf2ZMy3QEa9wVk9RgdZaPWUt7ZOnWUPFjcr9cmE6dUBf+XoPoH4g==",
"shasum": "2c03764f651a9f016ca0b7620421457b619151b9",
"tarball": "http:\/\/localhost:5555\/@scope\/pk1-test\/-\/@scope\/pk1-test-1.0.6.tgz"
}
}
},
"readme": "# test",
"_attachments": {
"@scope\/pk1-test-1.0.6.tgz": {
"content_type": "application\/octet-stream",
"data": "H4sIAAAAAAAAE+2W32vbMBDH85y\/QnjQp9qxLEeBMsbGlocNBmN7bFdQ5WuqxJaEpGQdo\/\/79KPeQsnIw5KUDX\/9IOvurLuz\/DHSjK\/YAiY6jcXSKjk6sMqypHWNdtmD6hlBI0wqQmo8nVbVqMR4OsNoVB66kF1aW8eML+Vv10m9oF\/jP6IfY4QyyTrILlD2eqkcm+gVzpdrJrPz4NuAsULJ4MZFWdBkbcByI7R79CRjx0ScCdnAvf+SkjUFWu8IubzBgXUhDPidQlfZ3BhlLpBUKDiQ1cDFrYDmKkNnZwjuhUM4808+xNVW8P2bMk1Y7vJrtLC1u1MmLPjBF40+Cc4ahV6GDmI\/DWygVRpMwVX3KtXUCg7Sxp7ff3nbt6TBFy65gK1iffsN41yoEHtdFbOiisWMH8bPvXUH0SP3k+KG3UBr+DFy7OGfEJr4x5iWVeS\/pLQe+D+FIv\/agIWI6GX66kFuIhT+1gDjrp\/4d7WAvAwEJPh0u14IufWkM0zaW2W6nLfM2lybgJ4LTJ0\/jWiAK8OcMjt8MW3OlfQppcuhhQ6k+2OgkK2Q8DssFPi\/IHpU9fz3\/+xj5NjDf8QFE39VmE4JDfzPCBn4P4X6\/f88f\/Pu47zomiPk2Lv\/dOv8h+P\/34\/D\/p9CL+Kp67mrGDRo0KBBp9ZPsETQegASAAA=",
"length": 512
}
}
}

export default json;
6 changes: 4 additions & 2 deletions plugins/local-storage/src/___tests___/local-fs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import rm from 'rmdir-sync';
import type {Logger} from '@verdaccio/types';
import type {ILocalPackageManager} from '@verdaccio/local-storage';
import LocalFS, {fileExist} from '../local-fs';
import pkg from './fixtures/pkg';

let localTempStorage: string;
const pkgFileName: string = 'package.json';
Expand All @@ -15,6 +16,7 @@ const logger: Logger = {
error: (e)=> console.warn(e),
info: (e)=> console.warn(e),
debug: (e)=> console.warn(e),
warn: (e)=> console.warn(e),
child: (e)=> console.warn(e),
http: (e)=> console.warn(e),
trace: (e)=> console.warn(e),
Expand Down Expand Up @@ -72,7 +74,7 @@ describe('Local FS test', ()=> {
test('createPackage()', (done) => {
const localFs = new LocalFS(path.join(localTempStorage, 'createPackage'), logger);

localFs.createPackage(path.join(localTempStorage, 'package5'), '{data:6}', (err)=> {
localFs.createPackage(path.join(localTempStorage, 'package5'), pkg, (err)=> {
expect(err).toBeNull();
done();
});
Expand All @@ -81,7 +83,7 @@ describe('Local FS test', ()=> {
test('createPackage() fails by fileExist', (done) => {
const localFs = new LocalFS(path.join(localTempStorage, 'createPackage'), logger);

localFs.createPackage(path.join(localTempStorage, 'package5'), '{data:6}', (err)=> {
localFs.createPackage(path.join(localTempStorage, 'package5'), pkg, (err)=> {
expect(err).not.toBeNull();
expect(err.code).toBe(fileExist);
done();
Expand Down
1 change: 1 addition & 0 deletions plugins/local-storage/src/local-database.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ import type {IPackageStorage, ILocalData} from '@verdaccio/local-storage';
}

getPackageStorage(packageInfo: string): IPackageStorage {
// $FlowFixMe
const packagePath: string = this._getLocalStoragePath(this.config.getMatchedPackagesSpec(packageInfo).storage);

if (_.isString(packagePath) === false) {
Expand Down
7 changes: 4 additions & 3 deletions plugins/local-storage/src/local-fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import createError from 'http-errors';
import type {HttpError} from 'http-errors';
import {UploadTarball, ReadTarball} from '@verdaccio/streams';
import {unlockFile, readFile} from '@verdaccio/file-locking';
import type {IUploadTarball} from '@verdaccio/streams';
import type {Callback, Logger, Package} from '@verdaccio/types';
import type {ILocalPackageManager} from '@verdaccio/local-storage';

Expand Down Expand Up @@ -162,7 +163,7 @@ class LocalFS implements ILocalPackageManager {
});
}

writeTarball(name: string): UploadTarball {
writeTarball(name: string): IUploadTarball {
const uploadStream = new UploadTarball();

let _ended = 0;
Expand All @@ -174,7 +175,7 @@ class LocalFS implements ILocalPackageManager {

fs.exists(pathName, (exists) => {
if (exists) {
return uploadStream.emit('error', fSError(fileExist));
uploadStream.emit('error', fSError(fileExist));
}

const temporalName = path.join(this.path, `${name}.tmp-${String(Math.random()).replace(/^0\./, '')}`);
Expand Down Expand Up @@ -280,7 +281,7 @@ class LocalFS implements ILocalPackageManager {
});
}

_convertToString(value: string): string {
_convertToString(value: Package): string {
return JSON.stringify(value, null, '\t');
}

Expand Down

0 comments on commit f42a284

Please sign in to comment.