From 1044447948a04c6ae511d7282dca023d9cf24eef Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Sun, 10 Dec 2017 22:55:56 +0200 Subject: [PATCH] refactor: use StoreIndex type from @pnpm/types --- package.json | 1 + shrinkwrap.yaml | 6 ++++++ src/fs/storeIndex.ts | 9 +++------ src/index.ts | 3 +-- src/storeController/index.ts | 4 ++-- 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index d2b7716c96..0500935384 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "dependencies": { "@pnpm/fs-locker": "^1.0.0", "@pnpm/package-requester": "^0.4.0", + "@pnpm/types": "^1.3.0", "@types/load-json-file": "^2.0.5", "@types/node": "^8.0.34", "@types/ramda": "^0.25.0", diff --git a/shrinkwrap.yaml b/shrinkwrap.yaml index 807d9f8d4d..7d02e85cc7 100644 --- a/shrinkwrap.yaml +++ b/shrinkwrap.yaml @@ -1,6 +1,7 @@ dependencies: '@pnpm/fs-locker': 1.0.0 '@pnpm/package-requester': 0.4.0 + '@pnpm/types': 1.3.0 '@types/load-json-file': 2.0.7 '@types/node': 8.0.53 '@types/ramda': 0.25.6 @@ -97,6 +98,10 @@ packages: dev: false resolution: integrity: sha512-gvOa3EP2z7O+IFiYsRBB+SBdnyE+SHTVFM5bPr2WGHhPhrScMUJ2jqgzlC79FgRP9c7uoe8Wbp3LYClEDh/U6A== + /@pnpm/types/1.3.0: + dev: false + resolution: + integrity: sha512-dhW0tHPWT19r1lwgv2RMnt31oC6PcsNeGcUlIDYRmC+J7g7Rcm19tZ0xmIAqh9R+U2Uw3PecXsuz+jkC/r5h+A== /@types/fs-extra/4.0.5: dependencies: '@types/node': 8.0.53 @@ -2864,6 +2869,7 @@ specifiers: '@pnpm/fs-locker': ^1.0.0 '@pnpm/logger': ^1.0.0 '@pnpm/package-requester': ^0.4.0 + '@pnpm/types': ^1.3.0 '@types/load-json-file': ^2.0.5 '@types/nock': ^8.2.1 '@types/node': ^8.0.34 diff --git a/src/fs/storeIndex.ts b/src/fs/storeIndex.ts index 2c4ab8517e..d458844fa1 100644 --- a/src/fs/storeIndex.ts +++ b/src/fs/storeIndex.ts @@ -1,14 +1,11 @@ +import {StoreIndex} from '@pnpm/types' import loadJsonFile = require('load-json-file') import path = require('path') import writeJsonFile = require('write-json-file') const STORE_JSON = 'store.json' -export interface Store { - [name: string]: string[], -} - -export async function read (storePath: string): Promise { +export async function read (storePath: string): Promise { const storeJsonPath = path.join(storePath, STORE_JSON) try { return await loadJsonFile(storeJsonPath) @@ -20,7 +17,7 @@ export async function read (storePath: string): Promise { } } -export function save (storePath: string, store: Store) { +export function save (storePath: string, store: StoreIndex) { const storeJsonPath = path.join(storePath, STORE_JSON) return writeJsonFile(storeJsonPath, store) } diff --git a/src/index.ts b/src/index.ts index 6a39d7a781..406a423fa5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,12 +1,11 @@ import getRegistryName = require('encode-registry') // TODO: remove this. BREAKING CHANGE -import {read, save, Store} from './fs/storeIndex' +import {read, save} from './fs/storeIndex' import resolveStore from './resolveStore' import createStore, {StoreController} from './storeController' export default createStore export { - Store, read, save, getRegistryName, diff --git a/src/storeController/index.ts b/src/storeController/index.ts index cf661e3502..ddde05122c 100644 --- a/src/storeController/index.ts +++ b/src/storeController/index.ts @@ -5,6 +5,7 @@ import createPackageRequester, { RequestPackageFunction, ResolveFunction, } from '@pnpm/package-requester' +import {StoreIndex} from '@pnpm/types' import pFilter = require('p-filter') import pLimit = require('p-limit') import path = require('path') @@ -14,7 +15,6 @@ import rimraf = require('rimraf-then') import { read as readStore, save as saveStore, - Store, } from '../fs/storeIndex' export interface StoreController { @@ -106,7 +106,7 @@ export default async function ( const limitExistsCheck = pLimit(10) -async function getRemovedProject (storeIndex: Store) { +async function getRemovedProject (storeIndex: StoreIndex) { const allProjects = R.uniq(R.unnest(R.values(storeIndex))) return await pFilter(allProjects,