diff --git a/postinstall.js b/postinstall.js index f8abf936..54d6b163 100644 --- a/postinstall.js +++ b/postinstall.js @@ -3,9 +3,14 @@ const { dirname } = require("path"); const hook = require("nativescript-hook")(__dirname); +const { compareProjectFiles } = require("./projectFilesManager"); const { getProjectDir } = require("./projectHelpers"); -if (getProjectDir()) { +const projectDir = getProjectDir(); + +if (projectDir) { + compareProjectFiles(projectDir); + hook.postinstall(); const installer = require("./installer"); installer.install(); diff --git a/projectFilesManager.js b/projectFilesManager.js index 9895406f..0409b860 100644 --- a/projectFilesManager.js +++ b/projectFilesManager.js @@ -37,6 +37,21 @@ function forceUpdateProjectFiles(projectDir, appDir) { addProjectFiles(projectDir, appDir); } +function compareProjectFiles(projectDir) { + const projectTemplates = getProjectTemplates(projectDir); + Object.keys(projectTemplates).forEach(newTemplatePath => { + const currentTemplatePath = projectTemplates[newTemplatePath]; + if (fs.existsSync(currentTemplatePath)) { + const currentTemplate = fs.readFileSync(currentTemplatePath).toString(); + const newTemplate = fs.readFileSync(newTemplatePath).toString(); + if (newTemplate !== currentTemplate) { + const message = `The current project contains a ${path.basename(currentTemplatePath)} file located at ${currentTemplatePath} that differs from the one in the new version of the nativescript-dev-webpack plugin located at ${newTemplatePath}. Some of the plugin features may not work as expected until you manually update the ${path.basename(currentTemplatePath)} file or automatically update it using "./node_modules/.bin/update-ns-webpack --configs" command.`; + console.info(`\x1B[33;1m${message}\x1B[0m` ); + } + } + }); +} + function deleteFile(destinationPath) { if (fs.existsSync(destinationPath)) { console.info(`Deleting file: ${destinationPath}`); @@ -108,5 +123,6 @@ module.exports = { addProjectFiles, removeProjectFiles, forceUpdateProjectFiles, + compareProjectFiles, };