From 0680f59cf3f54a13da0dbac91c86cba535a9861e Mon Sep 17 00:00:00 2001 From: rosen-vladimirov Date: Wed, 12 Jun 2019 08:18:43 +0300 Subject: [PATCH] fix: prepare plugin for NativeScript 6.0.0 release In NativeScript 6.0.0 there's a major refactoring in CLI that will require changes in most of the plugin hooks. The major changes are the hookArgs injected by CLI for each hook - they are changed, so some of the properties used from them, should be taken from different property. The other major change is the injected data - in the function used as hook, you can use any service registered in CLI's bootstrap and CLI will pass it to the hook. Several of the services are now renamed or deleted, so hooks using them should be migrated. Such service is platformsData. The last major change is that some logger methods are deleted (they've been deprecated). The current PR makes the hooks of this plugin compatible with the both 6.0.0 and old releases of NativeScript. --- src/plugin-hooks/after-prepare.js | 6 +++--- src/plugin-hooks/before-prepare.js | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/plugin-hooks/after-prepare.js b/src/plugin-hooks/after-prepare.js index 2c29809..b029723 100755 --- a/src/plugin-hooks/after-prepare.js +++ b/src/plugin-hooks/after-prepare.js @@ -1,8 +1,8 @@ var fs = require('fs-promise'); var path = require('path'); -module.exports = function (logger, platformsData, projectData, hookArgs) { - var platform = hookArgs.platform.toLowerCase(); +module.exports = function (logger, projectData, hookArgs) { + var platform = (hookArgs && (hookArgs.platform || (hookArgs.prepareData && hookArgs.prepareData.platform)) || '').toLowerCase(); if (platform == 'ios') { var appResourcesDirectoryPath = projectData.appResourcesDirectoryPath; @@ -14,7 +14,7 @@ module.exports = function (logger, platformsData, projectData, hookArgs) { var fileToCopy = fs.existsSync(entitlementsFile) ? entitlementsFile : entitlementsFileAlt; return fs.copy(fileToCopy, dest) .then(function () { - logger.out('Copied `' + fileToCopy + '` to `' + dest + '`'); + logger.info('Copied `' + fileToCopy + '` to `' + dest + '`'); }); } diff --git a/src/plugin-hooks/before-prepare.js b/src/plugin-hooks/before-prepare.js index 8e39575..1cafb49 100755 --- a/src/plugin-hooks/before-prepare.js +++ b/src/plugin-hooks/before-prepare.js @@ -1,8 +1,8 @@ var fs = require('fs-promise'); var path = require('path'); -module.exports = function (logger, platformsData, projectData, hookArgs) { - var platform = hookArgs.platform.toLowerCase(); +module.exports = function (logger, projectData, hookArgs) { + var platform = (hookArgs && (hookArgs.platform || (hookArgs.prepareData && hookArgs.prepareData.platform)) || '').toLowerCase(); if (platform == 'ios') { var appResourcesDirectoryPath = projectData.appResourcesDirectoryPath;