From f305429067610404f0958b55ef3a570e555a532e Mon Sep 17 00:00:00 2001 From: Merlin Beutlberger Date: Mon, 8 Oct 2018 16:42:16 +0200 Subject: [PATCH] [FIX] Replace copyright and version strings in *.json and .library files Currently only placeholders in *.js files are processed Fixes #76 --- lib/types/application/ApplicationBuilder.js | 6 +++--- lib/types/library/LibraryBuilder.js | 4 ++-- test/expected/build/application.b/dest/manifest.json | 2 +- .../build/application.g/dest/Component-preload.js | 2 +- test/expected/build/application.g/dest/manifest.json | 7 ++++--- .../build/library.d/dest/resources/library/d/.library | 2 +- .../build/library.e/dest/resources/library/e/.library | 6 ++++-- .../build/library.h/dest/resources/library/h/.library | 2 +- .../build/library.i/dest/resources/library/i/.library | 2 +- test/fixtures/application.b/webapp/manifest.json | 2 +- test/fixtures/application.g/webapp/manifest.json | 7 ++++--- test/fixtures/library.i/main/src/library/i/.library | 2 +- test/lib/builder/builder.js | 8 +++++--- 13 files changed, 29 insertions(+), 23 deletions(-) diff --git a/lib/types/application/ApplicationBuilder.js b/lib/types/application/ApplicationBuilder.js index 8bdf071b4..949e44152 100644 --- a/lib/types/application/ApplicationBuilder.js +++ b/lib/types/application/ApplicationBuilder.js @@ -18,7 +18,7 @@ class ApplicationBuilder extends AbstractBuilder { constructor({resourceCollections, project, parentLogger}) { super({project, parentLogger}); - // All available library tasks in execution order + // All available application tasks in execution order this.availableTasks = [ "replaceCopyright", "replaceVersion", @@ -37,7 +37,7 @@ class ApplicationBuilder extends AbstractBuilder { workspace: resourceCollections.workspace, options: { copyright: project.metadata.copyright, - pattern: "/**/*.js" + pattern: "/**/*.{js,json}" } }); }); @@ -47,7 +47,7 @@ class ApplicationBuilder extends AbstractBuilder { workspace: resourceCollections.workspace, options: { version: project.version, - pattern: "/**/*.js" + pattern: "/**/*.{js,json}" } }); }); diff --git a/lib/types/library/LibraryBuilder.js b/lib/types/library/LibraryBuilder.js index 8075d26c2..e4d564460 100644 --- a/lib/types/library/LibraryBuilder.js +++ b/lib/types/library/LibraryBuilder.js @@ -38,7 +38,7 @@ class LibraryBuilder extends AbstractBuilder { workspace: resourceCollections.workspace, options: { copyright: project.metadata.copyright, - pattern: "/resources/**/*.js" + pattern: "/resources/**/*.{js,json,library}" } }); }); @@ -49,7 +49,7 @@ class LibraryBuilder extends AbstractBuilder { workspace: resourceCollections.workspace, options: { version: project.version, - pattern: "/resources/**/*.js" + pattern: "/resources/**/*.{js,json,library}" } }); }); diff --git a/test/expected/build/application.b/dest/manifest.json b/test/expected/build/application.b/dest/manifest.json index 781945df9..d33902df7 100644 --- a/test/expected/build/application.b/dest/manifest.json +++ b/test/expected/build/application.b/dest/manifest.json @@ -10,4 +10,4 @@ "embeds": ["embedded"], "title": "{{title}}" } -} \ No newline at end of file +} diff --git a/test/expected/build/application.g/dest/Component-preload.js b/test/expected/build/application.g/dest/Component-preload.js index a976c01f8..11002677f 100644 --- a/test/expected/build/application.g/dest/Component-preload.js +++ b/test/expected/build/application.g/dest/Component-preload.js @@ -3,5 +3,5 @@ jQuery.sap.registerPreloadedModules({ "modules":{ "application/g/Component.js":function(){sap.ui.define(["sap/ui/core/UIComponent"],function(n){"use strict";return n.extend("application.g.Component",{metadata:{manifest:"json"}})}); }, - "application/g/manifest.json":'{"_version":"1.1.0","sap.app":{"_version":"1.1.0","id":"application.g","type":"application","applicationVersion":{"version":"1.2.2"},"embeds":["embedded"],"title":"{{title}}"}}' + "application/g/manifest.json":'{"_version":"1.1.0","sap.app":{"_version":"1.1.0","id":"application.g","type":"application","applicationVersion":{"version":"1.0.0"},"embeds":["embedded"],"title":"{{title}}"},"customCopyrightString":"Some fancy copyright"}' }}); diff --git a/test/expected/build/application.g/dest/manifest.json b/test/expected/build/application.g/dest/manifest.json index 6fe9d5250..620705334 100644 --- a/test/expected/build/application.g/dest/manifest.json +++ b/test/expected/build/application.g/dest/manifest.json @@ -5,9 +5,10 @@ "id": "application.g", "type": "application", "applicationVersion": { - "version": "1.2.2" + "version": "1.0.0" }, "embeds": ["embedded"], "title": "{{title}}" - } -} \ No newline at end of file + }, + "customCopyrightString": "Some fancy copyright" +} diff --git a/test/expected/build/library.d/dest/resources/library/d/.library b/test/expected/build/library.d/dest/resources/library/d/.library index 53c2d14c9..d6a612a92 100644 --- a/test/expected/build/library.d/dest/resources/library/d/.library +++ b/test/expected/build/library.d/dest/resources/library/d/.library @@ -4,7 +4,7 @@ library.d SAP SE Some fancy copyright - ${version} + 1.0.0 Library D diff --git a/test/expected/build/library.e/dest/resources/library/e/.library b/test/expected/build/library.e/dest/resources/library/e/.library index 20c990700..83723364d 100644 --- a/test/expected/build/library.e/dest/resources/library/e/.library +++ b/test/expected/build/library.e/dest/resources/library/e/.library @@ -3,8 +3,10 @@ library.d SAP SE - ${copyright} - ${version} + UI development toolkit for HTML5 (OpenUI5) + * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. + * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + 1.0.0 Library E diff --git a/test/expected/build/library.h/dest/resources/library/h/.library b/test/expected/build/library.h/dest/resources/library/h/.library index 8d1e46775..2b110f205 100644 --- a/test/expected/build/library.h/dest/resources/library/h/.library +++ b/test/expected/build/library.h/dest/resources/library/h/.library @@ -4,7 +4,7 @@ library.h SAP SE Some fancy copyright - ${version} + 1.0.0 Library D diff --git a/test/expected/build/library.i/dest/resources/library/i/.library b/test/expected/build/library.i/dest/resources/library/i/.library index 5d16039e8..4ef9fffe7 100644 --- a/test/expected/build/library.i/dest/resources/library/i/.library +++ b/test/expected/build/library.i/dest/resources/library/i/.library @@ -4,7 +4,7 @@ library.i SAP SE Some fancy copyright - ${version} + 1.0.0 {{title}} {{description}} diff --git a/test/fixtures/application.b/webapp/manifest.json b/test/fixtures/application.b/webapp/manifest.json index 781945df9..d33902df7 100644 --- a/test/fixtures/application.b/webapp/manifest.json +++ b/test/fixtures/application.b/webapp/manifest.json @@ -10,4 +10,4 @@ "embeds": ["embedded"], "title": "{{title}}" } -} \ No newline at end of file +} diff --git a/test/fixtures/application.g/webapp/manifest.json b/test/fixtures/application.g/webapp/manifest.json index 6fe9d5250..56cc0ec3b 100644 --- a/test/fixtures/application.g/webapp/manifest.json +++ b/test/fixtures/application.g/webapp/manifest.json @@ -5,9 +5,10 @@ "id": "application.g", "type": "application", "applicationVersion": { - "version": "1.2.2" + "version": "${version}" }, "embeds": ["embedded"], "title": "{{title}}" - } -} \ No newline at end of file + }, + "customCopyrightString": "${copyright}" +} diff --git a/test/fixtures/library.i/main/src/library/i/.library b/test/fixtures/library.i/main/src/library/i/.library index 5d16039e8..8c8c09d1b 100644 --- a/test/fixtures/library.i/main/src/library/i/.library +++ b/test/fixtures/library.i/main/src/library/i/.library @@ -3,7 +3,7 @@ library.i SAP SE - Some fancy copyright + ${copyright} ${version} {{title}} diff --git a/test/lib/builder/builder.js b/test/lib/builder/builder.js index 21ffa3dca..9b10e8915 100644 --- a/test/lib/builder/builder.js +++ b/test/lib/builder/builder.js @@ -112,7 +112,7 @@ test("Build application.g", (t) => { }); test("Build application.g with component preload paths", (t) => { - const destPath = "./test/tmp/build/application.g/dest"; + const destPath = "./test/tmp/build/application.g/dest2"; const expectedPath = "./test/expected/build/application.g/dest"; return builder.build({ @@ -387,7 +387,8 @@ const applicationGTree = { "type": "application", "metadata": { "name": "application.g", - "namespace": "application/g" + "namespace": "application/g", + "copyright": "Some fancy copyright" }, "dependencies": [], "resources": { @@ -420,7 +421,8 @@ const applicationGTreeComponentPreloadPaths = { "type": "application", "metadata": { "name": "application.g", - "namespace": "application/g" + "namespace": "application/g", + "copyright": "Some fancy copyright" }, "dependencies": [], "resources": {