Skip to content

Commit

Permalink
[FEATURE] manifest.json: Auto-fill supportedLocales
Browse files Browse the repository at this point in the history
JIRA: CPOUI5FOUNDATION-296
  • Loading branch information
flovogt committed Jul 12, 2024
1 parent 7691b08 commit b085634
Show file tree
Hide file tree
Showing 84 changed files with 4,270 additions and 0 deletions.
420 changes: 420 additions & 0 deletions lib/processors/manifestEnhancer.js

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions lib/tasks/enhanceManifest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import manifestEnhancer from "../processors/manifestEnhancer.js";
import fsInterface from "@ui5/fs/fsInterface";

/* eslint "jsdoc/check-param-names": ["error", {"disableExtraPropertyReporting":true}] */
/**
* Task for transforming the manifest.json file.
* Adds missing information based on the available project resources,
* for example the locales supported by the present i18n resources.
*
* @public
* @function default
* @static
*
* @param {object} parameters Parameters
* @param {@ui5/fs/DuplexCollection} parameters.workspace DuplexCollection to read and write files
* @param {object} parameters.options Options
* @param {string} parameters.options.projectNamespace Namespace of the application
* @returns {Promise<undefined>} Promise resolving with <code>undefined</code> once data has been written
*/
export default async function({workspace, options}) {
const {projectNamespace} = options;

// Note: all "manifest.json" files in the given namespace
const resources = await workspace.byGlob(`/resources/${projectNamespace}/**/manifest.json`);

const processedResources = await manifestEnhancer({
resources,
fs: fsInterface(workspace),
});

await Promise.all(processedResources.map((resource) => workspace.write(resource)));
}
1 change: 1 addition & 0 deletions lib/tasks/taskRepository.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const taskInfos = {
replaceCopyright: {path: "./replaceCopyright.js"},
replaceVersion: {path: "./replaceVersion.js"},
replaceBuildtime: {path: "./replaceBuildtime.js"},
enhanceManifest: {path: "./enhanceManifest.js"},
escapeNonAsciiCharacters: {path: "./escapeNonAsciiCharacters.js"},
executeJsdocSdkTransformation: {path: "./jsdoc/executeJsdocSdkTransformation.js"},
generateApiIndex: {path: "./jsdoc/generateApiIndex.js"},
Expand Down
10 changes: 10 additions & 0 deletions test/expected/build/application.o/dest/Component-preload.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
welcome=Hello world
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
welcome=Hello EN world
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
welcome=Hello EN US world
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
welcome=Hello EN US sapprc world
11 changes: 11 additions & 0 deletions test/expected/build/application.o/dest/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<title>Application O</title>
<script id="sap-ui-bootstrap" src="test.js">
</script>
</head>
<body>

</body>
</html>
48 changes: 48 additions & 0 deletions test/expected/build/application.o/dest/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"_version": "1.22.0",
"sap.app": {
"id": "application.o",
"type": "application",
"applicationVersion": {
"version": "1.0.0"
},
"title": "{{title}}",
"i18n": {
"bundleUrl": "i18n/i18n.properties",
"supportedLocales": [
"",
"en",
"en_US",
"en_US_sapprc"
]
}
},
"sap.ui5": {
"models": {
"i18n": {
"type": "sap.ui.model.resource.ResourceModel",
"settings": {
"bundleName": "application.o.i18n.i18n",
"supportedLocales": [
"",
"en",
"en_US",
"en_US_sapprc"
]
}
},
"i18n-ui5": {
"type": "sap.ui.model.resource.ResourceModel",
"settings": {
"bundleUrl": "ui5://application/o/i18n/i18n.properties",
"supportedLocales": [
"",
"en",
"en_US",
"en_US_sapprc"
]
}
}
}
}
}
8 changes: 8 additions & 0 deletions test/expected/build/application.o/dest/test-dbg.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
sap.ui.define([
], () => {
test((paramA) => {
const variableA = paramA;
console.log(variableA);
})
test();
});
2 changes: 2 additions & 0 deletions test/expected/build/application.o/dest/test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions test/expected/build/application.o/dest/test.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions test/expected/build/library.o/dest/resources/library/o/.library
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
<library xmlns="http://www.sap.com/sap.ui.library.xsd" >

<name>library.o</name>
<vendor>SAP SE</vendor>
<copyright>${copyright}</copyright>
<version>1.0.0</version>

<title>{{title}}</title>
<documentation>{{description}}</documentation>

</library>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*!
* Some fancy copyright
*/
sap.ui.define([
'sap/ui/core/Core',
], (Core) => {
"use strict";

sap.ui.getCore().initLibrary({
name : "library.o",
version: "1.0.0",
dependencies : []
});

return thisLib;

});

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

103 changes: 103 additions & 0 deletions test/expected/build/library.o/dest/resources/library/o/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
{
"_version": "1.58.0",
"sap.app": {
"id": "library.o",
"type": "library",
"embeds": [],
"applicationVersion": {
"version": "1.0.0"
},
"title": "{{title}}",
"description": "{{description}}",
"resources": "resources.json",
"offline": true
},
"sap.ui": {
"technology": "UI5",
"supportedThemes": []
},
"sap.ui5": {
"dependencies": {
"libs": {}
},
"library": {
"i18n": {
"bundleUrl": "messagebundle.properties",
"terminologies": {
"sports": {
"bundleUrl": "sports.properties",
"bundleUrlRelativeTo": "manifest",
"supportedLocales": [
"",
"de",
"en"
]
},
"travel": {
"bundleUrl": "travel.properties",
"bundleUrlRelativeTo": "manifest",
"supportedLocales": [
"",
"de",
"en"
]
}
},
"enhanceWith": [
{
"bundleUrl": "myfolder1/i18n.properties",
"bundleUrlRelativeTo": "manifest",
"terminologies": {
"sports": {
"bundleUrl": "myfolder1/soccer.properties",
"bundleUrlRelativeTo": "manifest",
"supportedLocales": [
"",
"de",
"en"
]
},
"travel": {
"bundleUrl": "myfolder1/vehicles.properties",
"bundleUrlRelativeTo": "manifest",
"supportedLocales": [
"",
"de",
"en"
]
}
},
"supportedLocales": [
"",
"en"
]
},
{
"bundleUrl": "myfolder2/i18n.properties",
"bundleUrlRelativeTo": "manifest",
"terminologies": {
"travel": {
"bundleUrl": "myfolder2/bicycles.properties",
"bundleUrlRelativeTo": "manifest",
"supportedLocales": [
"",
"de",
"en"
]
}
},
"supportedLocales": [
"",
"en"
]
}
],
"supportedLocales": [
"",
"de",
"en"
]
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
title=a title
description=a description
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
title=a title
description=a description
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
title=a title
description=a description
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
title=my company 1 title
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
title=my company 1 title
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
title=my soccer title
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
title=Mein Fussball Titel
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
title=my soccer title
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
title=my vehicle title
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
title=Mein Fahrzeugstitel
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
title=my vehicle title
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
title=my bicycle title
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
title=Mein Fahrradtitel
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
title=my bicycle title
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
title=my company 2 title
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
title=my company 2 title
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
title=a sports title
description=a sports description
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
title=ein Sporttitel
description=eine Sportbeschreibung
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
title=a sports title
description=a sports description
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
title=a travel title
description=a travel description
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
title=ein Reisetitel
description=eine Reisebeschreibung
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
title=a travel title
description=a travel description
8 changes: 8 additions & 0 deletions test/fixtures/application.o/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "application.o",
"version": "1.0.0",
"description": "Simple SAPUI5 based application",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
}
}
5 changes: 5 additions & 0 deletions test/fixtures/application.o/ui5.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
specVersion: "3.2"
type: application
metadata:
name: application.o
1 change: 1 addition & 0 deletions test/fixtures/application.o/webapp/i18n/i18n.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
welcome=Hello world
1 change: 1 addition & 0 deletions test/fixtures/application.o/webapp/i18n/i18n_en.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
welcome=Hello EN world
Loading

0 comments on commit b085634

Please sign in to comment.