From 273d1bdecde92f918def2ffc76b3237afce2ea92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=A8=E3=83=AA=E3=82=B9?= Date: Thu, 30 Jun 2022 20:00:25 +0900 Subject: [PATCH] chore: display warning on deprecated tag usage (#1451) * chore: display warning on deprecated tag usage * test: create spy on warnForDeprecatedSplashScreen --- lib/prepare.js | 11 +++++++++++ spec/unit/prepare.spec.js | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/lib/prepare.js b/lib/prepare.js index 68ff7120a4..bb97c400ea 100644 --- a/lib/prepare.js +++ b/lib/prepare.js @@ -63,6 +63,7 @@ module.exports.prepare = function (cordovaProject, options) { // Update own www dir with project's www assets and plugins' assets and js-files return Promise.resolve(updateWww(cordovaProject, this.locations)) + .then(() => warnForDeprecatedSplashScreen(cordovaProject)) .then(() => updateProjectAccordingTo(self._config, self.locations)) .then(function () { updateIcons(cordovaProject, path.relative(cordovaProject.root, self.locations.res)); @@ -353,6 +354,16 @@ function updateProjectStrings (platformConfig, locations) { events.emit('verbose', 'Wrote out android application name "' + name + '" to ' + locations.strings); } +function warnForDeprecatedSplashScreen (cordovaProject) { + const hasOldSplashTags = ( + cordovaProject.projectConfig.doc.findall('./platform[@name="android"]/splash') || [] + ).length > 0; + + if (hasOldSplashTags) { + events.emit('warn', 'The "" tags were detected and are no longer supported. Please migrate to the "preference" tag "AndroidWindowSplashScreenAnimatedIcon".'); + } +} + /** * @param {ConfigParser} platformConfig A project's configuration that will * be used to update project diff --git a/spec/unit/prepare.spec.js b/spec/unit/prepare.spec.js index 8dec31eb02..be541b835a 100644 --- a/spec/unit/prepare.spec.js +++ b/spec/unit/prepare.spec.js @@ -766,6 +766,8 @@ describe('prepare', () => { prepare.__set__('updateWww', jasmine.createSpy()); prepare.__set__('updateProjectAccordingTo', jasmine.createSpy('updateProjectAccordingTo') .and.returnValue(Promise.resolve())); + prepare.__set__('warnForDeprecatedSplashScreen', jasmine.createSpy('warnForDeprecatedSplashScreen') + .and.returnValue(Promise.resolve())); prepare.__set__('updateIcons', jasmine.createSpy('updateIcons').and.returnValue(Promise.resolve())); prepare.__set__('updateFileResources', jasmine.createSpy('updateFileResources').and.returnValue(Promise.resolve())); prepare.__set__('updateConfigFilesFrom', @@ -859,6 +861,8 @@ describe('prepare', () => { prepare.__set__('updateWww', jasmine.createSpy('updateWww')); prepare.__set__('updateIcons', jasmine.createSpy('updateIcons').and.returnValue(Promise.resolve())); prepare.__set__('updateProjectSplashScreen', jasmine.createSpy('updateProjectSplashScreen')); + prepare.__set__('warnForDeprecatedSplashScreen', jasmine.createSpy('warnForDeprecatedSplashScreen') + .and.returnValue(Promise.resolve())); prepare.__set__('updateFileResources', jasmine.createSpy('updateFileResources').and.returnValue(Promise.resolve())); prepare.__set__('updateConfigFilesFrom', jasmine.createSpy('updateConfigFilesFrom')