From 309ab790615d9706af06803ce4bc3c6344f37c94 Mon Sep 17 00:00:00 2001 From: Alex Lavrov <36633600+alexslavr@users.noreply.github.com> Date: Tue, 24 Oct 2023 20:01:36 +0400 Subject: [PATCH] Prepare all necessary JS artifacts for build task (#25842) Co-authored-by: Lykoi18 --- .github/workflows/update_version.yml | 52 +++++++++++++ build/build-all.ts | 73 +++++++++++++++++++ build/pack-all.ts | 54 -------------- build/update-version.ts | 19 +++++ package-lock.json | 6 +- package.json | 3 +- packages/devextreme-angular/package.json | 1 - packages/devextreme-themebuilder/package.json | 2 +- playgrounds/angular/package.json | 15 ++-- 9 files changed, 159 insertions(+), 66 deletions(-) create mode 100644 .github/workflows/update_version.yml create mode 100644 build/build-all.ts delete mode 100644 build/pack-all.ts create mode 100644 build/update-version.ts diff --git a/.github/workflows/update_version.yml b/.github/workflows/update_version.yml new file mode 100644 index 000000000000..5c26c6f59845 --- /dev/null +++ b/.github/workflows/update_version.yml @@ -0,0 +1,52 @@ +name: Update version in all workspaces + +on: + workflow_dispatch: + inputs: + branch_name: + type: string + description: XX_X Branch name (23_2+) + required: true + version: + type: string + description: XX.X.X Set exact version + required: true + +jobs: + update_version: + name: Update version and create PR + runs-on: ubuntu-latest + + steps: + - name: Get sources + uses: actions/checkout@v4 + with: + ref: ${{ inputs.branch_name }} + + - name: Use Node.js + uses: actions/setup-node@v3 + with: + node-version: '18.16.1' + + - name: Setup git config + run: | + git config --global user.email "DXGitHubRobot@devexpress.com" + git config --global user.name "DX Robot" + + - name: Install packages in devextreme repo + run: npm install --no-audit --no-fund + + - name: Bump version + run: npm run all:update-version -- ${{ inputs.version }} + + - name: Commit changes and make PR + env: + GITHUB_TOKEN: ${{ secrets.DX_ROBOT_PAT }} + branch_name: 'robot/update-version-${{ inputs.version }}' + run: | + git checkout -b $branch_name + git add . -N + git commit -a -m "Bump devextreme version" + git push --set-upstream origin $branch_name --force + gh pr create --base ${{ inputs.branch_name }} --title "Bump devextreme version (${{ inputs.version }})" --body "Bump devextreme version" --reviewer DevExpress/devextreme-devops + diff --git a/build/build-all.ts b/build/build-all.ts new file mode 100644 index 000000000000..7a8030f9f7e7 --- /dev/null +++ b/build/build-all.ts @@ -0,0 +1,73 @@ +import sh from 'shelljs'; +import path from 'node:path'; + +const MONOREPO_ROOT = path.join(__dirname, '..'); +const INTERNAL_TOOLS_ARTIFACTS = path.join(MONOREPO_ROOT, 'artifacts', 'internal-tools'); + +const OUTPUT_DIR = path.join(MONOREPO_ROOT, 'artifacts'); +const NPM_OUTPUT_DIR = path.join(OUTPUT_DIR, 'npm'); + +sh.mkdir('-p', NPM_OUTPUT_DIR); + +const { 'devextreme-main': devextremeVersion, devextreme: devextremeNpmVersion } = JSON.parse(sh.exec('npm pkg get version -ws --json').stdout); +const MAJOR_VERSION = devextremeVersion.split('.').slice(0, 2).join('_'); + +// Prepare metadata +sh.cd(MONOREPO_ROOT); +sh.exec('npm run tools:discover-declarations'); +sh.exec(`npm run tools -- make-aspnet-metadata --version ${MAJOR_VERSION}`); + +// Inject descriptions +const DOCUMENTATION_TEMP_DIR = path.join(OUTPUT_DIR, 'doc_tmp'); +sh.exec(`git clone -b ${MAJOR_VERSION} --depth 1 --config core.longpaths=true https://github.com/DevExpress/devextreme-documentation.git ${DOCUMENTATION_TEMP_DIR}`); + +sh.pushd(DOCUMENTATION_TEMP_DIR); +sh.exec('npm i'); +sh.exec(`npm run update-topics -- --artifacts ${INTERNAL_TOOLS_ARTIFACTS}`); +sh.popd(); + +sh.rm('-rf', DOCUMENTATION_TEMP_DIR); + +sh.exec('npm run devextreme:inject-descriptions'); + +sh.exec('npm run build-dist -w devextreme-main'); + +// Copy artifacts for DXBuild (Installation) +sh.pushd(path.join(MONOREPO_ROOT, 'packages/devextreme/artifacts')); +sh.cp('-r', 'ts', OUTPUT_DIR); +sh.cp('-r', 'js', OUTPUT_DIR); +sh.cp('-r', 'css', OUTPUT_DIR); +sh.popd(); + +// TODO: maybe we should add bootstrap to vendors +const BOOTSTRAP_DIR = path.join(MONOREPO_ROOT, 'node_modules', 'bootstrap', 'dist'); +sh.cp([path.join(BOOTSTRAP_DIR, 'js', 'bootstrap.js'), path.join(BOOTSTRAP_DIR, 'js', 'bootstrap.min.js')], path.join(OUTPUT_DIR, 'js')); +sh.cp([path.join(BOOTSTRAP_DIR, 'css', 'bootstrap.css'), path.join(BOOTSTRAP_DIR, 'js', 'bootstrap.min.css')], path.join(OUTPUT_DIR, 'css')); + +// Update versions for non-semver builds (daily, alpha and beta) +if (devextremeVersion !== devextremeNpmVersion) { + sh.exec(`npm run all:update-version -- ${devextremeNpmVersion}`); +} + +const DEVEXTREME_NPM_DIR = path.join(MONOREPO_ROOT, 'packages/devextreme/artifacts/npm'); + +sh.pushd(path.join(DEVEXTREME_NPM_DIR, 'devextreme')) +sh.exec('npm pack'); +sh.cp('*.tgz', NPM_OUTPUT_DIR); +sh.popd(); + +sh.pushd(path.join(DEVEXTREME_NPM_DIR, 'devextreme-dist')) +sh.exec('npm pack'); +sh.cp('*.tgz', NPM_OUTPUT_DIR); +sh.popd(); + +sh.pushd(path.join(MONOREPO_ROOT, 'packages', 'devextreme-themebuilder')) +sh.exec('npm run build && npm run pack'); +sh.cp('dist/*.tgz', NPM_OUTPUT_DIR); +sh.popd(); + +sh.exec('npm run pack --ws --if-present'); + +sh.cp(path.join(MONOREPO_ROOT, 'packages', 'devextreme-angular', 'npm', 'dist', '*.tgz'), NPM_OUTPUT_DIR); +sh.cp(path.join(MONOREPO_ROOT, 'packages', 'devextreme-react', 'npm', '*.tgz'), NPM_OUTPUT_DIR); +sh.cp(path.join(MONOREPO_ROOT, 'packages', 'devextreme-vue', 'npm', '*.tgz'), NPM_OUTPUT_DIR); diff --git a/build/pack-all.ts b/build/pack-all.ts deleted file mode 100644 index 3e1f9e8d09d1..000000000000 --- a/build/pack-all.ts +++ /dev/null @@ -1,54 +0,0 @@ -import sh from "shelljs"; -import path from "node:path"; - -const MONOREPO_ROOT = path.join(__dirname, '..'); -const INTERNAL_TOOLS_ARTIFACTS = path.join(MONOREPO_ROOT, 'artifacts', 'internal-tools'); - -const OUTPUT_DIR = path.join(MONOREPO_ROOT, 'npm'); -sh.mkdir('-p', OUTPUT_DIR); - -sh.cd(MONOREPO_ROOT); -sh.exec('npm run tools:discover-declarations'); - -// Descriptions -const DOCUMENTATION_DIR = path.join(OUTPUT_DIR, 'documentation'); -sh.exec(`git clone -b 23_2 --depth 1 --config core.longpaths=true https://github.com/DevExpress/devextreme-documentation.git ${DOCUMENTATION_DIR}`); - -sh.pushd(DOCUMENTATION_DIR); -sh.exec('npm i'); -sh.exec(`npm run update-topics -- --artifacts ${INTERNAL_TOOLS_ARTIFACTS}`); -sh.popd(); - -sh.exec('npm run devextreme:inject-descriptions'); - -sh.exec('npm run build-dist -w devextreme-main'); - -const DEVEXTREME_NPM_DIR = path.join(MONOREPO_ROOT, 'packages/devextreme/artifacts/npm'); - -/* -TODO: We might need this when running on farm to bump non-semver versions for all packages. -sh.exec(`npm version ${version} -ws --workspaces-update=false`); -sh.sed('-i', /"devextreme": ".*"/, `"devextreme": "${version}"`, path.join(MONOREPO_ROOT, 'packages', '**', 'package.json')); -sh.exec('npm i'); -*/ - -sh.pushd(path.join(DEVEXTREME_NPM_DIR, 'devextreme')) -sh.exec('npm pack'); -sh.cp('*.tgz', OUTPUT_DIR); -sh.popd(); - -sh.pushd(path.join(DEVEXTREME_NPM_DIR, 'devextreme-dist')) -sh.exec('npm pack'); -sh.cp('*.tgz', OUTPUT_DIR); -sh.popd(); - -sh.pushd(path.join(MONOREPO_ROOT, 'packages', 'devextreme-themebuilder')) -sh.exec('npm run build && npm run pack'); -sh.cp('dist/*.tgz', OUTPUT_DIR); -sh.popd(); - -sh.exec('npm run pack --ws --if-present'); - -sh.cp(path.join(MONOREPO_ROOT, 'packages', 'devextreme-angular', 'npm', 'dist', '*.tgz'), OUTPUT_DIR); -sh.cp(path.join(MONOREPO_ROOT, 'packages', 'devextreme-react', 'npm', '*.tgz'), OUTPUT_DIR); -sh.cp(path.join(MONOREPO_ROOT, 'packages', 'devextreme-vue', 'npm', '*.tgz'), OUTPUT_DIR); diff --git a/build/update-version.ts b/build/update-version.ts new file mode 100644 index 000000000000..2338a6241e99 --- /dev/null +++ b/build/update-version.ts @@ -0,0 +1,19 @@ +import sh from 'shelljs'; +import path from 'node:path'; + +const version = process.argv[2]; + +if (version == null) { + console.error(`Usage: 'npm run all:update-version -- $version' (XX.X.X)`); + process.exit(1); +} + +const MONOREPO_ROOT = path.join(__dirname, '..'); +const packagesPath = path.join(MONOREPO_ROOT, 'packages', '**', 'package.json'); +const playgroundsPath = path.join(MONOREPO_ROOT, 'playgrounds', '**', 'package.json'); + +sh.exec(`npm version ${version} -ws --include-workspace-root --git-tag-version=false --workspaces-update=false`); + +sh.sed('-i', /"devextreme(-angular|-react|-vue)?": ".*"/, `"devextreme$1": "~${version}"`, [packagesPath, playgroundsPath]); + +sh.exec('npm i'); diff --git a/package-lock.json b/package-lock.json index 39d623fec91d..17c054698172 100644 --- a/package-lock.json +++ b/package-lock.json @@ -47276,7 +47276,6 @@ "codelyzer": "6.0.2", "core-js": "^2.6.12", "del": "^2.2.2", - "devextreme": "~23.2.0", "gulp": "^4.0.2", "gulp-header": "^1.8.12", "gulp-replace": "^0.6.1", @@ -49188,7 +49187,7 @@ } }, "packages/devextreme-themebuilder": { - "version": "0.0.1", + "version": "23.2.0", "license": "SEE LICENSE IN README.md", "dependencies": { "autoprefixer": "^10.4.7", @@ -50268,7 +50267,8 @@ }, "playgrounds/angular": { "name": "devextreme-angular-playground", - "version": "0.0.0", + "version": "23.2.0", + "license": "MIT", "dependencies": { "@angular/animations": "~12.2.17", "@angular/common": "~12.2.17", diff --git a/package.json b/package.json index bcaedb285ce4..f834bfb49dfa 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,8 @@ "regenerate-all": "nx run-many -t regenerate", "lint-staged": "lint-staged", "prepare": "husky install", - "all:pack": "ts-node build/pack-all.ts" + "all:update-version": "ts-node build/update-version.ts", + "all:build": "ts-node build/build-all.ts" }, "nx": {}, "private": true, diff --git a/packages/devextreme-angular/package.json b/packages/devextreme-angular/package.json index f029517c2f50..55976a8be719 100644 --- a/packages/devextreme-angular/package.json +++ b/packages/devextreme-angular/package.json @@ -38,7 +38,6 @@ "codelyzer": "6.0.2", "core-js": "^2.6.12", "del": "^2.2.2", - "devextreme": "~23.2.0", "gulp": "^4.0.2", "gulp-header": "^1.8.12", "gulp-replace": "^0.6.1", diff --git a/packages/devextreme-themebuilder/package.json b/packages/devextreme-themebuilder/package.json index afbbf80dde34..fcdb98f92426 100644 --- a/packages/devextreme-themebuilder/package.json +++ b/packages/devextreme-themebuilder/package.json @@ -1,6 +1,6 @@ { "name": "devextreme-themebuilder", - "version": "0.0.1", + "version": "23.2.0", "description": "DevExtreme ThemeBuilder", "keywords": [ "devextreme", diff --git a/playgrounds/angular/package.json b/playgrounds/angular/package.json index 83f366f75d94..5d8210bcfcad 100644 --- a/playgrounds/angular/package.json +++ b/playgrounds/angular/package.json @@ -1,12 +1,10 @@ { "name": "devextreme-angular-playground", - "version": "0.0.0", - "scripts": { - "ng": "ng", - "start": "cross-env NODE_OPTIONS=--openssl-legacy-provider ng serve --open -c dev", - "build": "echo empty" - }, + "description": "DevExtreme Angular UI and Visualization Components", "private": true, + "version": "23.2.0", + "author": "Developer Express Inc.", + "license": "MIT", "dependencies": { "@angular/animations": "~12.2.17", "@angular/common": "~12.2.17", @@ -30,5 +28,10 @@ "@angular/language-service": "12.2.17", "@types/node": "8.10.66", "ts-node": "7.0.1" + }, + "scripts": { + "ng": "ng", + "start": "cross-env NODE_OPTIONS=--openssl-legacy-provider ng serve --open -c dev", + "build": "echo empty" } }