[PRODENG-211] integrate JS-API with monorepo (part 1) (#9081)

* integrate JS-API with monorepo

* [ci:force] fix token issue

[ci:force] migrate docs folder

[ci:force] clean personal tokens

* [ci:force] gha workflow support

* [ci:force] npm publish target

* fix js-api test linting

* [ci:force] fix test linting, mocks, https scheme

* [ci:force] fix https scheme

* [ci:force] typescript mappings

* [ci:force] update scripts

* lint fixes

* linting fixes

* fix linting

* [ci:force] linting fixes

* linting fixes

* [ci:force] remove js-api upstream and corresponding scripts

* [ci:force] jsdoc fixes

* fix jsdoc linting

* [ci:force] jsdoc fixes

* [ci:force] jsdoc fixes

* jsdoc fixes

* jsdoc fixes

* jsdoc fixes

* [ci:force] fix jsdoc

* [ci:force] reduce code duplication

* replace 'chai' expect with node.js assert

* replace 'chai' expect with node.js assert

* [ci:force] remove chai and chai-spies for js-api testing

* [ci:force] cleanup and fix imports

* [ci:force] fix linting

* [ci:force] fix unit test

* [ci:force] fix sonar linting findings

* [ci:force] switch activiti api models to interfaces (-2.5% reduction of bundle)

* [ci:force] switch activiti api models to interfaces

* [ci:force] switch AGS api models to interfaces

* [ci:force] switch AGS api models to interfaces

* [ci:force] switch search api models to interfaces

* [ci:force] switch content api models to interfaces where applicable
This commit is contained in:
Denys Vuika
2023-11-21 10:27:51 +00:00
committed by GitHub
parent 804fa2ffd4
commit ea2c0ce229
1334 changed files with 82605 additions and 1068 deletions

View File

@@ -218,16 +218,18 @@ jobs:
# max-parallel: 4
matrix:
unit-tests:
- name: js-api
exclude: "core,insights,content-services,process-services,process-services-cloud,eslint-plugin-eslint-angular"
- name: content-services
exclude: "insights,core,extensions,process-services,process-services-cloud,eslint-plugin-eslint-angular"
exclude: "insights,core,extensions,process-services,process-services-cloud,eslint-plugin-eslint-angular,js-api"
- name: core
exclude: "insights,content-services,process-services,process-services-cloud,eslint-plugin-eslint-angular"
exclude: "insights,content-services,process-services,process-services-cloud,eslint-plugin-eslint-angular,js-api"
- name: insights
exclude: "core,extensions,content-services,process-services-cloud,process-services,eslint-plugin-eslint-angular"
exclude: "core,extensions,content-services,process-services-cloud,process-services,eslint-plugin-eslint-angular,js-api"
- name: process-services
exclude: "core,extensions,content-services,process-services-cloud,insights,eslint-plugin-eslint-angular"
exclude: "core,extensions,content-services,process-services-cloud,insights,eslint-plugin-eslint-angular,js-api"
- name: process-cloud
exclude: "insights,core,extensions,content-services,process-services,eslint-plugin-eslint-angular"
exclude: "insights,core,extensions,content-services,process-services,eslint-plugin-eslint-angular,js-api"
steps:
- name: Checkout repository
uses: actions/checkout@v3

View File

@@ -1,214 +0,0 @@
name: Upstream js
on:
schedule:
- cron: '0 */3 * * *' # “At minute 0 past every 3rd hour.”
workflow_dispatch:
inputs:
tag_version:
description: image tag
type: choice
required: true
options:
- alpha
- latest
default: alpha
jobs:
upstream:
runs-on: ubuntu-latest
outputs:
hasAtLeastOneNewVersion: ${{ steps.fetchLatestPkg.outputs.hasAtLeastOneNewVersion }}
hasNewVersionAvailableJS: ${{ steps.fetchLatestPkg.outputs.hasVersionNewJS }}
latestVersionAvailableJS: ${{ steps.fetchLatestPkg.outputs.latestVersionJS }}
hasAtLeastOneNewVersionWithoutPR: ${{ steps.checkPrAlreadyExist.outputs.hasAtLeastOneNewVersionWithoutPR }}
steps:
- id: checkoutRepo
name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 1
- id: fetchLatestPkg
name: Fetch the latest package version
uses: actions/github-script@v6
env:
TAG_VERSION: ${{ inputs.tag_version }}
with:
github-token: ${{ secrets.PAT_WRITE_PKG }}
script: |
const tagVersion = process.env.TAG_VERSION;
console.log('tagVersion:',tagVersion);
const getLatestVersionOf = require('./scripts/github/update/latest-version-of.js');
const { hasVersionNew: hasVersionNewJS, latestVersion: latestVersionJS } = await getLatestVersionOf({github, context, dependencyName: 'js-api', tagVersion});
console.log('hasVersionNewJS', hasVersionNewJS)
console.log('latestVersionJS', latestVersionJS)
if (hasVersionNewJS === 'true' ) {
core.setOutput('hasAtLeastOneNewVersion', 'true');
core.setOutput('hasVersionNewJS', 'true');
core.setOutput('latestVersionJS', latestVersionJS);
} else {
core.setOutput('hasAtLeastOneNewVersion', 'false');
console.log('No new version available, skipping upstream!')
}
- name: Check value after
run: |
echo "The value hasAtLeastOneNewVersion is: ${{ steps.fetchLatestPkg.outputs.hasAtLeastOneNewVersion }}"
echo "The value hasVersionNewJS is: ${{ steps.fetchLatestPkg.outputs.hasVersionNewJS }}"
echo "The value latestVersionJS is: ${{ steps.fetchLatestPkg.outputs.latestVersionJS }}"
- id: checkPrAlreadyExist
name: Check PR with latest already exist
if: ${{ steps.fetchLatestPkg.outputs.hasAtLeastOneNewVersion == 'true' }}
uses: actions/github-script@v6
env:
HAS_NEW_JS_VERSION: ${{ steps.fetchLatestPkg.outputs.hasVersionNewJS }}
LATEST_JS_VERSION: ${{ steps.fetchLatestPkg.outputs.latestVersionJS }}
with:
github-token: ${{ secrets.BOT_GITHUB_TOKEN }}
script: |
const hasVersionNewJS = process.env.HAS_NEW_JS_VERSION;
const latestVersionJS = process.env.LATEST_JS_VERSION;
const checkPRAlreadyExist = require('./scripts/github/update/check-pr-already-exist.js');
let isPRWithLatestJSAlreadyAvailable = false;
if (hasVersionNewJS === 'true') {
isPRWithLatestJSAlreadyAvailable = await checkPRAlreadyExist({github, context, version: latestVersionJS});
console.log('isPRWithLatestJSAlreadyAvailable', isPRWithLatestJSAlreadyAvailable);
}
if (isPRWithLatestJSAlreadyAvailable) {
console.log('Warning: Upstream PR already exist, stop the migration execution!');
core.setOutput('hasAtLeastOneNewVersionWithoutPR', 'false');
} else {
core.setOutput('hasAtLeastOneNewVersionWithoutPR', 'true');
}
migrate:
if: ${{ needs.upstream.outputs.hasAtLeastOneNewVersionWithoutPR == 'true' }}
runs-on: ubuntu-latest
needs: upstream
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
token: ${{ secrets.BOT_GITHUB_TOKEN }}
fetch-depth: 1
- name: setup NPM
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache-dependency-path: package-lock.json
- name: "General :: dbpci-install"
run: |
npm ci --ignore-scripts
- name: Migration
shell: bash
env:
IS_JS_AFFECTED: ${{ needs.upstream.outputs.hasNewVersionAvailableJS }}
PACKAGE_VERSION_JS: ${{ needs.upstream.outputs.latestVersionAvailableJS }}
BRANCH_TO_CREATE: "upstream-dependencies"
run: |
migrateDependenciesJS() {
echo "Update JS dependencies to: ${PACKAGE_VERSION_JS}"
echo "Calling migration JS"
npx nx migrate @alfresco/js-api@${PACKAGE_VERSION_JS}
echo "Migration JS done"
}
migrateLibDependenciesJS() {
eval projects=( "cli"
"core"
"content-services"
"process-services"
"process-services-cloud"
"insights"
"testing"
"extensions" )
projectslength=${#projects[@]}
for (( i=0; i<${projectslength}; i++ ));
do
echo "Update JS dependencies in adf-${projects[$i]} to: ${PACKAGE_VERSION_JS}"
DESTDIR="lib/${projects[$i]}"
sed -i "${sedi[@]}" "s/\"@alfresco\/js-api\": \".*\"/\"@alfresco\/js-api\": \">=${PACKAGE_VERSION_JS}\"/g" ${DESTDIR}/package.json
done
}
regeneratePackageLock() {
echo "Regenerate lock"
npm i --package-lock-only
echo "Package-lock done."
}
if git checkout ${BRANCH_TO_CREATE} 2>/dev/null ; then
git reset --hard origin/develop
echo "Reset branch"
fi
if [[ "$IS_JS_AFFECTED" == "true" ]]; then
migrateDependenciesJS
migrateLibDependenciesJS
fi
regeneratePackageLock
- name: Commit Code
if: ${{ needs.upstream.outputs.hasAtLeastOneNewVersion == 'true' }}
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "[ci:force][auto-commit] Update dependencies JS:${{ needs.upstream.outputs.latestVersionAvailableJS }}"
branch: upstream-dependencies
push_options: '--force'
create_branch: true
- name: Create a Pull request
uses: actions/github-script@v6
env:
PACKAGE_VERSION_JS: ${{ needs.upstream.outputs.latestVersionAvailableJS }}
with:
github-token: ${{ secrets.BOT_GITHUB_TOKEN }}
script: |
const { PACKAGE_VERSION_JS } = process.env
const BRANCH_TO_CREATE = 'upstream-dependencies';
const { data: prs } = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
head: `${context.repo.owner}:${BRANCH_TO_CREATE}`,
base: 'develop'
});
if (prs.length < 1) {
const payloadPullRequest = {
owner: context.repo.owner,
repo: context.repo.repo,
title: `GH Auto: Upstream dependencies JS-API:${PACKAGE_VERSION_JS}`,
head: `${context.repo.owner}:${BRANCH_TO_CREATE}`,
base: 'develop',
body: `Automatic PR`
};
console.log('Payload: ',payloadPullRequest);
const { data: pr } = await github.rest.pulls.create(payloadPullRequest);
return pr.number;
} else {
const upstreamPrOpen = prs[0];
// override the title to contains the latest js dep number
const payloadUpdatePullRequest = {
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: upstreamPrOpen.number,
title: `GH Auto: Upstream dependencies JS-API:${PACKAGE_VERSION_JS}`,
};
await github.rest.pulls.update(payloadUpdatePullRequest);
return upstreamPrOpen.number;
}
console.log(`Trigger a dispatch event for the monorepo`);