Skip to content

Commit

Permalink
[INTERNAL] ui5-workspace.yaml schema generation (#744)
Browse files Browse the repository at this point in the history
JIRA: CPOUI5FOUNDATION-584

Generate ui5-workspace.yaml schema that complies with the [local dependency resolution spec](https://github.com/SAP/ui5-tooling/blob/rfc-local-dependency-resolution/rfcs/0006-local-dependency-resolution.md#workspace-configuration-file)

For further details, check the [RFC 0006 Local Dependency Resolution](https://github.com/SAP/ui5-tooling/blob/rfc-local-dependency-resolution/rfcs/0006-local-dependency-resolution.md)

This change depends on SAP/ui5-project#543
  • Loading branch information
d3xter666 authored Jan 24, 2023
1 parent 6f6e2ed commit 425ffad
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ jobs:
run: docker run --rm -v $(pwd):/docs --entrypoint mike --env GIT_COMMITTER_NAME="${GIT_COMMITTER_NAME}" --env GIT_COMMITTER_EMAIL="${GIT_COMMITTER_EMAIL}" $DOCKER_IMAGE set-default stable --push

- name: Build Schema
run: npm run schema-generate
run: |
npm run schema-generate
npm run schema-workspace-generate
- name: Checkout gh-pages
uses: actions/checkout@v3
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"jsdoc-generate-workspace": "jsdoc -c ./jsdoc-workspace.json -t $(node -p 'path.dirname(require.resolve(\"docdash\"))') ../ || (echo 'Error during JSDoc generation! Check log.' && exit 1)",
"docs": "bash ./scripts/serveDocs.sh",
"docs-generate": "bash ./scripts/buildDocs.sh && open-cli http://localhost:8000 && ws --compress -d site",
"schema-generate": "node ./scripts/buildSchema.js",
"schema-generate": "node ./scripts/buildSchema.js ui5",
"schema-workspace-generate": "node ./scripts/buildSchema.js ui5-workspace",
"generate-cli-doc": "node ./scripts/generateCliDoc.js",
"depcheck": "depcheck --ignores @ui5/builder,@ui5/cli,@ui5/fs,@ui5/logger,@ui5/project,@ui5/server,docdash,local-web-server"
},
Expand Down
8 changes: 5 additions & 3 deletions scripts/buildSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ import traverse from "traverse";
// Using CommonsJS require.resolve as long as import.meta.resolve is experimental
import {createRequire} from "node:module";
const require = createRequire(import.meta.url);
// Provide schema name as CLI argument
const schemaName = process.argv[2] || "ui5";

// Using @ui5/project/package.json export to calculate the path to the root ui5-project folder
const SOURCE_SCHEMA_PATH = fileURLToPath(
new URL("./lib/validation/schema/ui5.json", pathToFileURL(require.resolve("@ui5/project/package.json")))
new URL(`./lib/validation/schema/${schemaName}.json`, pathToFileURL(require.resolve("@ui5/project/package.json")))
);
const TARGET_SCHEMA_PATH = fileURLToPath(
new URL(`../site/schema/ui5.yaml.json`, import.meta.url)
new URL(`../site/schema/${schemaName}.yaml.json`, import.meta.url)
);

try {
Expand Down Expand Up @@ -45,7 +47,7 @@ try {
await mkdir(path.dirname(TARGET_SCHEMA_PATH), {recursive: true});
await writeFile(TARGET_SCHEMA_PATH, JSON.stringify(schema, null, 2));

console.log("Wrote bundled ui5.yaml schema file to " + TARGET_SCHEMA_PATH);
console.log(`Wrote bundled ${schemaName}.yaml schema file to ${TARGET_SCHEMA_PATH}`);
} catch (error) {
console.log(error);
process.exit(1);
Expand Down

0 comments on commit 425ffad

Please sign in to comment.