Permalink
Browse files

refactor: force users to reinstall old node_modules

  • Loading branch information...
1 parent 59cd8cb commit eb1ec303f28b79f770c83fda3fe08e7848ef06de @zkochan zkochan committed Jan 11, 2017
Showing with 20 additions and 7 deletions.
  1. +1 −1 package.json
  2. +19 −6 src/api/getContext.ts
View
@@ -1,7 +1,7 @@
{
"name": "pnpm",
"description": "A fast implementation of npm install",
- "version": "0.47.1",
+ "version": "0.48.0",
"author": "Rico Sta. Cruz <rico@ricostacruz.com>",
"bin": {
"pnpm": "lib/bin/pnpm.js"
View
@@ -62,7 +62,9 @@ export default async function (opts: StrictPnpmOptions): Promise<PnpmContext> {
`)
throw new Error(msg)
}
- failIfNotCompatible(modules.packageManager.split('@')[1])
+ const pnpmVersion = modules.packageManager.split('@')[1]
+ failIfNotCompatibleStore(pnpmVersion)
+ failIfNotCompatibleNodeModules(pnpmVersion)
}
const graph = await readGraph(path.join(root, 'node_modules')) || {}
@@ -84,33 +86,44 @@ export default async function (opts: StrictPnpmOptions): Promise<PnpmContext> {
return ctx
}
-function failIfNotCompatible (storeVersion: string) {
- if (!storeVersion || !semver.satisfies(storeVersion, '>=0.28')) {
+function failIfNotCompatibleStore (pnpmVersion: string) {
+ if (!pnpmVersion || !semver.satisfies(pnpmVersion, '>=0.28')) {
const msg = structureChangeMsg('More info about what was changed at: https://github.com/rstacruz/pnpm/issues/276')
throw new Error(msg)
}
- if (!semver.satisfies(storeVersion, '>=0.33')) {
+ if (!semver.satisfies(pnpmVersion, '>=0.33')) {
const msg = structureChangeMsg(stripIndent`
The change was needed to fix the GitHub rate limit issue:
Issue: https://github.com/rstacruz/pnpm/issues/361
PR: https://github.com/rstacruz/pnpm/pull/363
`)
throw new Error(msg)
}
- if (!semver.satisfies(storeVersion, '>=0.37')) {
+ if (!semver.satisfies(pnpmVersion, '>=0.37')) {
const msg = structureChangeMsg(stripIndent`
The structure of store.json/dependencies was changed to map dependencies to their fullnames
`)
throw new Error(msg)
}
- if (!semver.satisfies(storeVersion, '>=0.38')) {
+ if (!semver.satisfies(pnpmVersion, '>=0.38')) {
const msg = structureChangeMsg(stripIndent`
The structure of store.json/dependencies was changed to not include the redundunt package.json at the end
`)
throw new Error(msg)
}
}
+function failIfNotCompatibleNodeModules (pnpmVersion: string) {
+ if (!pnpmVersion || !semver.satisfies(pnpmVersion, '>=0.48')) {
+ throw new Error(stripIndent`
+ The node_modules structure was changed.
+ Remove it and run pnpm again.
+ Related PR: https://github.com/rstacruz/pnpm/pull/534
+ TIPS: you can run \`rm -rf node_modules\`
+ `)
+ }
+}
+
function structureChangeMsg (moreInfo: string): string {
return stripIndent`
The store structure was changed.

0 comments on commit eb1ec30

Please sign in to comment.