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 Apr 17, 2024
1 parent d5705b3 commit e9b02dd
Show file tree
Hide file tree
Showing 84 changed files with 4,014 additions and 0 deletions.
417 changes: 417 additions & 0 deletions lib/processors/manifestEnricher.js

Large diffs are not rendered by default.

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

/* eslint "jsdoc/check-param-names": ["error", {"disableExtraPropertyReporting":true}] */
/**
* Task for transforming the manifest.json file.
*
* @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 manifestEnricher({
resources,
fs: fsInterface(workspace),
options
});

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"},
enrichManifest: {path: "./enrichManifest.js"},
escapeNonAsciiCharacters: {path: "./escapeNonAsciiCharacters.js"},
executeJsdocSdkTransformation: {path: "./jsdoc/executeJsdocSdkTransformation.js"},
generateApiIndex: {path: "./jsdoc/generateApiIndex.js"},
Expand Down
12 changes: 12 additions & 0 deletions test/expected/build/application.m/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.m/dest/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<title>Application M</title>
<script id="sap-ui-bootstrap" src="test.js">
</script>
</head>
<body>

</body>
</html>
48 changes: 48 additions & 0 deletions test/expected/build/application.m/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.m",
"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.m.i18n.i18n",
"supportedLocales": [
"",
"en",
"en_US",
"en_US_sapprc"
]
}
},
"i18n-ui5": {
"type": "sap.ui.model.resource.ResourceModel",
"settings": {
"bundleUrl": "ui5://application/m/i18n/i18n.properties",
"supportedLocales": [
"",
"en",
"en_US",
"en_US_sapprc"
]
}
}
}
}
}
8 changes: 8 additions & 0 deletions test/expected/build/application.m/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.m/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.m/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.n/resources/library/n/.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.n</name>
<vendor>SAP SE</vendor>
<copyright>Some fancy copyright</copyright>
<version>1.0.0</version>

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

</library>
17 changes: 17 additions & 0 deletions test/expected/build/library.n/resources/library/n/library-dbg.js
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.n",
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.

5 changes: 5 additions & 0 deletions test/expected/build/library.n/resources/library/n/library.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.

103 changes: 103 additions & 0 deletions test/expected/build/library.n/resources/library/n/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
{
"_version": "1.58.0",
"sap.app": {
"id": "library.n",
"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.m/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "application.m",
"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.m/ui5.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
specVersion: "3.2"
type: application
metadata:
name: application.m
1 change: 1 addition & 0 deletions test/fixtures/application.m/webapp/i18n/i18n.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
welcome=Hello world
Loading

0 comments on commit e9b02dd

Please sign in to comment.