Skip to content

Commit

Permalink
chore: display warning on deprecated <splash> tag usage (#1451)
Browse files Browse the repository at this point in the history
* chore: display warning on deprecated <splash> tag usage
* test: create spy on warnForDeprecatedSplashScreen
  • Loading branch information
erisu authored Jun 30, 2022
1 parent 606e9c4 commit 273d1bd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/prepare.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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 "<splash>" 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
Expand Down
4 changes: 4 additions & 0 deletions spec/unit/prepare.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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')
Expand Down

0 comments on commit 273d1bd

Please sign in to comment.