Skip to content

Commit

Permalink
fix: prepare plugin for NativeScript 6.0.0 release
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rosen-vladimirov committed Jun 12, 2019
1 parent 8f7e1f2 commit 0680f59
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/plugin-hooks/after-prepare.js
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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 + '`');
});
}

Expand Down
4 changes: 2 additions & 2 deletions src/plugin-hooks/before-prepare.js
Original file line number Diff line number Diff line change
@@ -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;
Expand Down

0 comments on commit 0680f59

Please sign in to comment.