Skip to content

Commit da120c7

Browse files
committed
build: Remove additional UI5 CLI packages from npm workspace
The UI5 CLI packages have been added to the npm workspace (documentation package) in order to generate JSDoc and build the JSON schema files for the gh-pages deployment which should be based on the published packages rather than the local source code. This has caused issues during the release process where versions were adjusted incorrectly by release please during the version bump. The packages are now downloaded as tarballs from the npm registry during the build process using a new script (downloadPackages.sh). This prevents any interference with the npm workspace. It also reduces the local installation size during development. In addition, obsolete dependencies have been removed from the root package.json.
1 parent 83ceec2 commit da120c7

File tree

10 files changed

+202
-6606
lines changed

10 files changed

+202
-6606
lines changed

.github/workflows/deploy-vitepress-docs.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,15 @@ jobs:
5656
# The alias output
5757
npm run build:vitepress -- --base="/${{ github.event.repository.name }}/${DOC_ALIAS}/" --outDir="dist-${DOC_ALIAS}"
5858
npm run build:assets -- ./dist-${DOC_ALIAS}
59+
- name: Download UI5 CLI packages
60+
working-directory: internal/documentation
61+
run: npm run download-packages
5962
- name: Build jsdoc
6063
working-directory: internal/documentation
61-
run: npm run jsdoc-generate
64+
run: npm run jsdoc-generate-gh-pages
6265
- name: Build Schema
6366
working-directory: internal/documentation
64-
run: npm run schema-generate
67+
run: npm run schema-generate-gh-pages
6568
- name: Checkout gh-pages
6669
uses: actions/checkout@v5
6770
with:

.github/workflows/github-ci.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,26 @@ jobs:
3939
- name: Run unit tests
4040
run: npm run coverage
4141

42-
- name: Generate JSDoc documentation
42+
- name: Generate JSDoc documentation (workspace)
4343
working-directory: internal/documentation
4444
run: npm run jsdoc-generate
4545

46-
- name: Generate merged JSON schema
46+
- name: Generate merged JSON schema (workspace)
4747
working-directory: internal/documentation
4848
run: npm run schema-generate
4949

50+
- name: Download UI5 CLI packages
51+
working-directory: internal/documentation
52+
run: npm run download-packages
53+
54+
- name: Generate JSDoc documentation (gh-pages)
55+
working-directory: internal/documentation
56+
run: npm run jsdoc-generate-gh-pages
57+
58+
- name: Generate merged JSON schema (gh-pages)
59+
working-directory: internal/documentation
60+
run: npm run schema-generate-gh-pages
61+
5062
- name: Generate CLI documentation
5163
working-directory: internal/documentation
5264
run: npm run generate-cli-doc

.github/workflows/release-please.yml

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,6 @@ jobs:
4545
# Regenerate package-lock.json to sync with updated workspace packages
4646
npm install
4747
48-
# Fix lockfile corruption: node-workspace plugin updates npm alias entries in package-lock.json
49-
# but the internal/* packages have npm aliases (@ui5/builder-npm, @ui5/cli-npm, etc.) that point
50-
# to old versions (^4.0.x) which are still correct and should not be updated to new versions (^5.0.x)
51-
# that don't exist on npm yet. We restore these specific entries from the main branch.
52-
# Restore original entries for @ui5/*-npm packages to avoid unintended updates
53-
# Note: npm aliases can be in node_modules or internal/documentation/node_modules
54-
git show origin/main:package-lock.json | jq -r '.packages | to_entries[] | select(.key | test("(node_modules|internal/documentation/node_modules)/@ui5/(builder|cli|fs|logger|project|server)-npm$")) | .key' | while read key; do
55-
original_entry=$(git show origin/main:package-lock.json | jq ".packages[\"$key\"]")
56-
jq --tab --arg key "$key" --argjson entry "$original_entry" '.packages[$key] = $entry' package-lock.json > tmp.$$.json && mv tmp.$$.json package-lock.json
57-
done
58-
5948
# Commit the change back to the PR branch
6049
# Amend the Release Please commit to include our fixes
6150
# This keeps the PR clean with a single commit
@@ -84,13 +73,13 @@ jobs:
8473
uses: actions/setup-node@v5
8574
with:
8675
node-version: 24.x
87-
76+
8877
- name: Install dependencies
8978
run: npm ci
9079

9180
- name: Publish ${{ matrix.package }} package
9281
working-directory: packages/${{ matrix.package }}
93-
run: |
82+
run: |
9483
echo "🚀 Publishing @ui5/${{ matrix.package }}"
9584
npm publish --access public --tag next
9685

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,4 @@ internal/documentation/.vitepress/dist
6868
internal/documentation/.vitepress/cache
6969
internal/documentation/dist
7070
internal/documentation/schema/*
71+
internal/documentation/tmp

internal/documentation/jsdoc/jsdoc.json

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@
33
"allowUnknownTags": false
44
},
55
"source": {
6-
"include": ["jsdoc/index.md", "../../node_modules/@ui5"],
6+
"include": ["jsdoc/index.md"],
77
"exclude": [
8-
"../../node_modules/@ui5/builder-npm/lib/lbt/utils/JSTokenizer.js",
9-
"../../node_modules/@ui5/builder-npm/lib/processors/jsdoc/lib/ui5/plugin.js",
10-
"../../node_modules/@ui5/builder-npm/lib/processors/jsdoc/lib/ui5/template/publish.js",
11-
"../../node_modules/@ui5/builder-npm/lib/processors/jsdoc/lib/ui5/template/utils/versionUtil.js"
8+
"tmp/packages/@ui5/builder/lib/lbt/utils/JSTokenizer.js",
9+
"tmp/packages/@ui5/builder/lib/processors/jsdoc/lib/ui5/plugin.js",
10+
"tmp/packages/@ui5/builder/lib/processors/jsdoc/lib/ui5/template/publish.js",
11+
"tmp/packages/@ui5/builder/lib/processors/jsdoc/lib/ui5/template/utils/versionUtil.js"
1212
],
13-
"includePattern": "@ui5/[^/]*-npm/(lib/.+|index)\\.js$",
14-
"excludePattern": "@ui5/.*/node_modules/@ui5"
13+
"includePattern": "tmp/packages/@ui5/[^/]*/(lib/.+|index)\\.js$"
1514
},
1615
"plugins": [
1716
"jsdoc/jsdoc-plugin.cjs"

internal/documentation/package.json

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,18 @@
2424
"scripts": {
2525
"start": "vitepress dev --open",
2626
"lint": "eslint .",
27-
"depcheck": "depcheck --ignores @ui5/documentation,vitepress,docdash,jsdoc,open-cli,handlebars,@types/node,@ui5/webcomponents,autoprefixer,cssnano,@ui5/cli-npm,@ui5/builder-npm,@ui5/fs-npm,@ui5/logger-npm,@ui5/project-npm,@ui5/server-npm,@theme/components",
27+
"depcheck": "depcheck --ignores @ui5/documentation,vitepress,docdash,jsdoc,open-cli,handlebars,@types/node,@ui5/webcomponents,autoprefixer,cssnano,@theme/components",
2828
"dev": "vitepress dev",
2929
"build:vitepress": "vitepress build",
3030
"build:assets": "sh -c 'DEST_DIR=${1:-./dist}; cp -r ./docs/images \"$DEST_DIR/images\"' --",
3131
"preview": "vitepress preview --port 8080",
3232
"jsdoc": "npm run jsdoc-generate && open-cli dist/api/index.html",
33-
"jsdoc-generate": "jsdoc -c jsdoc/jsdoc.json -t $(node -p 'path.dirname(require.resolve(\"docdash\"))') ./ || (echo 'Error during JSDoc generation! Check log.' && exit 1)",
34-
"jsdoc-generate-workspace": "jsdoc -c jsdoc/jsdoc-workspace.json -t $(node -p 'path.dirname(require.resolve(\"docdash\"))') ./ || (echo 'Error during JSDoc generation! Check log.' && exit 1)",
33+
"jsdoc-generate": "jsdoc -c jsdoc/jsdoc-workspace.json -t $(node -p 'path.dirname(require.resolve(\"docdash\"))') ./ || (echo 'Error during JSDoc generation! Check log.' && exit 1)",
34+
"jsdoc-generate-gh-pages": "jsdoc -c jsdoc/jsdoc.json -t $(node -p 'path.dirname(require.resolve(\"docdash\"))') ./ || (echo 'Error during JSDoc generation! Check log.' && exit 1)",
3535
"generate-cli-doc": "node ./scripts/generateCliDoc.js",
36-
"schema-generate": "node ./scripts/buildSchema.js @ui5/project-npm",
37-
"schema-generate-workspace": "node ./scripts/buildSchema.js @ui5/project"
36+
"schema-generate": "node ./scripts/buildSchema.js",
37+
"schema-generate-gh-pages": "node ./scripts/buildSchema.js gh-pages",
38+
"download-packages": "./scripts/downloadPackages.sh"
3839
},
3940
"dependencies": {
4041
"@types/node": "^22.5.1",
@@ -49,12 +50,6 @@
4950
},
5051
"devDependencies": {
5152
"@apidevtools/json-schema-ref-parser": "^14.2.1",
52-
"@ui5/builder-npm": "npm:@ui5/builder@^4.0.11",
53-
"@ui5/cli-npm": "npm:@ui5/cli@^4.0.26",
54-
"@ui5/fs-npm": "npm:@ui5/fs@^4.0.2",
55-
"@ui5/logger-npm": "npm:@ui5/logger@^4.0.2",
56-
"@ui5/project-npm": "npm:@ui5/project@^4.0.6",
57-
"@ui5/server-npm": "npm:@ui5/server@^4.0.7",
5853
"docdash": "^2.0.2",
5954
"handlebars": "^4.7.8",
6055
"jsdoc": "^4.0.4",

internal/documentation/scripts/buildSchema.js

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,30 @@ import {writeFile, mkdir} from "node:fs/promises";
44
import {$RefParser} from "@apidevtools/json-schema-ref-parser";
55
import traverse from "traverse";
66

7-
// Read the given CLI parameter to set which UI5/project version to use.
8-
// Default to "@ui5/project-npm" to use the latest published version (for Github Pages).
9-
// For testing, the local version can be used by providing "@ui5/project".
10-
// Example: node buildSchema.js @ui5/project-npm
11-
// Example: node buildSchema.js @ui5/project
12-
const UI5_PROJECT_VERSION = process.argv[2] || "@ui5/project-npm";
7+
// Read the given CLI parameter to determine in which mode to run the script:
8+
// - workspace (default): Use @ui5/project from local workspace (packages/project)
9+
// - gh-pages: Use published version of @ui5/project from npm (downloaded via "downloadPackages.sh" beforehand)
10+
const MODE = process.argv[2] || "workspace";
1311

1412
try {
13+
// Determine base URL for resolving schema files based on the mode
14+
let BASE_URL;
15+
if (MODE === "workspace") {
16+
BASE_URL = import.meta.resolve(`@ui5/project/package.json`);
17+
} else if (MODE === "gh-pages") {
18+
BASE_URL = new URL("../tmp/packages/@ui5/project/package.json", import.meta.url);
19+
} else {
20+
throw new Error(`Unknown mode: '${MODE}'. Supported modes are 'workspace' and 'gh-pages'.`);
21+
}
22+
23+
console.log(`Building JSON Schema files in mode '${MODE}' using package at: ${BASE_URL}`);
24+
1525
// Use ui5.yaml.json and ui5-workspace.yaml.json
1626
const schemaNames = ["ui5", "ui5-workspace"];
1727

1828
schemaNames.forEach(async (schemaName) => {
1929
const SOURCE_SCHEMA_PATH = fileURLToPath(
20-
new URL(`./lib/validation/schema/${schemaName}.json`,
21-
import.meta.resolve(`${UI5_PROJECT_VERSION}/package.json`))
30+
new URL(`./lib/validation/schema/${schemaName}.json`, BASE_URL)
2231
);
2332
const TARGET_SCHEMA_PATH = fileURLToPath(
2433
new URL(`../schema/${schemaName}.yaml.json`, import.meta.url)
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
# Constants
5+
readonly UI5_CLI_PACKAGES_VERSION="latest"
6+
readonly UI5_CLI_PACKAGES=($(find ../../packages/*/package.json -exec jq -r '.name' {} \;))
7+
8+
# Directories
9+
readonly SCRIPT_DIR="$(dirname -- "$0")"
10+
readonly DOC_ROOT="${SCRIPT_DIR}/.."
11+
readonly TMP_PACKAGES_DIR="./tmp/packages"
12+
13+
# Functions
14+
extract_package_file_name() {
15+
local package="$1"
16+
17+
# Remove "@" from scoped package names
18+
local package_file_name="${package#@}"
19+
20+
# Replace "/" with "-" for file name
21+
package_file_name="${package_file_name//\//-}"
22+
23+
echo "$package_file_name"
24+
}
25+
26+
download_packages() {
27+
echo "Downloading UI5 CLI packages for JSDoc / JSON Schema generation..."
28+
29+
mkdir -p "$TMP_PACKAGES_DIR"
30+
31+
for package in "${UI5_CLI_PACKAGES[@]}"; do
32+
echo "Downloading and extracting $package..."
33+
npm pack "$package@$UI5_CLI_PACKAGES_VERSION" --workspaces false --quiet --pack-destination "$TMP_PACKAGES_DIR"
34+
local package_file_name="$(extract_package_file_name "$package")"
35+
rm -rf "$TMP_PACKAGES_DIR/${package}"
36+
mkdir -p "$TMP_PACKAGES_DIR/${package}"
37+
tar -xzf "$TMP_PACKAGES_DIR/${package_file_name}"-*.tgz --strip-components=1 -C "$TMP_PACKAGES_DIR/${package}"
38+
rm "$TMP_PACKAGES_DIR/${package_file_name}"-*.tgz
39+
done
40+
}
41+
42+
main() {
43+
cd "$DOC_ROOT"
44+
echo "Changed directory to $(pwd)"
45+
46+
download_packages
47+
}
48+
49+
main "$@"

0 commit comments

Comments
 (0)