diff --git a/package.json b/package.json index 44dc4ffda..5f37faca8 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,8 @@ "serve": "tsc -p ./debug/serve/tsconfig.json && node ./build/server/debug/serve/plumbing/run.js", "start": "npm run serve", "test": "tsc -p ./test/tsconfig.json && mocha --verbose --logging", - "test-build": "tsc -p ./test/tsconfig.json" + "test-build": "tsc -p ./test/tsconfig.json", + "postinstall": "node tools/postinstall/script.cjs" }, "repository": { "type": "git", @@ -86,4 +87,4 @@ "url": "https://github.com/pnp/pnpjs/issues" }, "homepage": "https://github.com/pnp/pnpjs" -} +} \ No newline at end of file diff --git a/tools/postinstall/script.cjs b/tools/postinstall/script.cjs new file mode 100644 index 000000000..0c4bd8a9c --- /dev/null +++ b/tools/postinstall/script.cjs @@ -0,0 +1,19 @@ +const fs = require("fs"); +const projectRoot = process.env.INIT_CWD; +const packageLoc = `${projectRoot}\\package.json`; +const packageFile = fs.readFileSync(packageLoc, "utf8"); +const packageJSON = JSON.parse(packageFile); +if (packageJSON.dependencies != null) { + const spfxVersion = packageJSON.dependencies["@microsoft/sp-core-library"]; + if (spfxVersion != null) { + const spfxVersionFloat = parseFloat(spfxVersion); + if (spfxVersionFloat > 1.11 && spfxVersionFloat < 1.15) { + console.log(""); + console.log("\x1b[43m%s\x1b[0m", " PnPjs WARNING "); + console.log("\x1b[33m%s\x1b[0m", " The version of SPFx you are using requires an update to work with PnPjs. Please make sure to follow the getting started instructions to make the appropriate changes. ➡ https://pnp.github.io/pnpjs/getting-started/#spfx-version-1121-later"); + console.log(""); + } + } +} else { + console.log("Package has no dependencies"); +} \ No newline at end of file