generated from SAP/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Simplify SAPUI5 types update process
- Loading branch information
Showing
6 changed files
with
71 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,25 @@ | ||
![UI5 logo](./docs/images/UI5_logo_wide.png) | ||
|
||
# UI5 linter Development | ||
|
||
**Note:** This document is intended to support UI5 Linter developers and is not meant for end users of the linter! | ||
|
||
## Metadata generation | ||
|
||
The UI5 Linter requires metadata to accurately identify certain issues within the codebase. While the absence of this metadata does not hinder the linter's basic functionality, it may result in incomplete findings. | ||
**Note:** This document is intended to support UI5 Linter developers and is not relevant for end users of the linter. | ||
|
||
The extracted and generated metadata is stored within the repository under the `/resources` folder. This metadata plays a crucial role in enhancing the accuracy of the linter's analysis. | ||
|
||
Regular updates to the metadata are necessary to ensure that the data is compatible with the corresponding UI5 type definitions. | ||
## Updating SAPUI5 types | ||
|
||
UI5 linter currently comes with a fixed version of the SAPUI5 types that needs to be updated manually. | ||
An update can be performed with following command: | ||
```sh | ||
npm run update-pseudo-modules-info -- $DOMAIN_NAME/com/sap/ui5/dist/sapui5-sdk-dist/1.120.15/sapui5-sdk-dist-1.120.15-api-jsons.zip 1.120.15 | ||
npm run update-sapui5-types -- <domain> <version> | ||
``` | ||
|
||
```sh | ||
npm run update-semantic-model-info -- $DOMAIN_NAME/com/sap/ui5/dist/sapui5-sdk-dist/1.120.15/sapui5-sdk-dist-1.120.15-api-jsons.zip 1.120.15 | ||
``` | ||
**Note:** | ||
- `domain` is the internal domain (without protocol) that hosts the SAPUI5 SDK API JSON files. | ||
- `version` is the version of the SAPUI5 distribution. | ||
|
||
The script updates multiple places where the corresponding SAPUI5 types are referenced or incorporated: | ||
- `@sapui5/types` npm dependency in [package.json](../package.json) | ||
- This package contains the TypeScript definitions of all SAPUI5 libraries and is relevant for the general TypeScript based detection. | ||
- [`resources/api-extract.json`](../resources/api-extract.json) | ||
- This file contains additional information that is not available or accessible via the TypeScript definitions. It is an extract from the original `api.json` files of the SAPUI5 libraries. | ||
- [`resources/dataTypes.json`](../resources/dataTypes.json) | ||
- This file is used to distinguish between data types and enumerations when analyzing pseudo modules. | ||
- [`resources/overrides/library`](../resources/overrides/library) | ||
- This folder contains additional module declarations that support detection of certain issues, for example usage of pseudo modules. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import createMetadataInfo from "./metadataProvider/createMetadataInfo.js"; | ||
import createPseudoModulesInfo from "./metadataProvider/createPseudoModulesInfo.js"; | ||
import {cleanup, fetchAndExtractApiJsons} from "./metadataProvider/helpers.js"; | ||
import {promisify} from "node:util"; | ||
import {execFile as execFileCb} from "node:child_process"; | ||
const execFile = promisify(execFileCb); | ||
|
||
try { | ||
const domain = process.argv[2]; | ||
const version = process.argv[3]; | ||
|
||
if (!domain) { | ||
throw new Error("First argument \"domain\" is missing"); | ||
} | ||
|
||
if (!version) { | ||
throw new Error("Second argument \"version\" is missing"); | ||
} | ||
|
||
const url = `https://${domain}/artifactory/build-releases/com/sap/ui5/dist/sapui5-sdk-dist/${version}/sapui5-sdk-dist-${version}-api-jsons.zip`; | ||
const apiJsonsRoot = await fetchAndExtractApiJsons(url); | ||
|
||
await createMetadataInfo(apiJsonsRoot, version); | ||
await createPseudoModulesInfo(apiJsonsRoot); | ||
|
||
await cleanup(); | ||
|
||
// Update @sapui5/types npm package | ||
await execFile("npm", ["install", "-E", `@sapui5/types@${version}`]); | ||
} catch (err) { | ||
process.stderr.write(String(err)); | ||
process.exit(1); | ||
} |