mirror of
https://github.com/pnpm/pnpm.git
synced 2026-05-03 21:44:52 -04:00
refactor: use StoreIndex type from @pnpm/types
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<Store | null> {
|
||||
export async function read (storePath: string): Promise<StoreIndex | null> {
|
||||
const storeJsonPath = path.join(storePath, STORE_JSON)
|
||||
try {
|
||||
return await loadJsonFile(storeJsonPath)
|
||||
@@ -20,7 +17,7 @@ export async function read (storePath: string): Promise<Store | null> {
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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<string>(R.values(storeIndex)))
|
||||
|
||||
return await pFilter(allProjects,
|
||||
|
||||
Reference in New Issue
Block a user