[AAE-11255] adf-cli - Get rid of the build-testing and call copydist when needed (#7933)

* Get rid of the build-testing and call copydist when needed

* Use the relative path instead of node_modules and avoid to build cli/testing in the before e2e

* Try to build cli and testing as part of install

* Build cli and testing before e2e

* Copy cli bundle under dist

* Copy cli bundle under dist

* Copy testing into node_modules to fix protractor.js

* Created a bundle target to handle build and move of cli/testing

* Change from build target to something custom to avoid to exclude the packages

* Remove the build-testing.sh script
This commit is contained in:
Maurizio Vitale 2022-11-01 11:28:44 +00:00 committed by GitHub
parent cebe2501fa
commit 8b94caafef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 85 additions and 46 deletions

View File

@ -812,7 +812,7 @@
"projectType": "library", "projectType": "library",
"prefix": "adf", "prefix": "adf",
"architect": { "architect": {
"build": { "build-local": {
"builder": "@nrwl/node:webpack", "builder": "@nrwl/node:webpack",
"options": { "options": {
"projectRoot": "lib/testing", "projectRoot": "lib/testing",
@ -846,7 +846,20 @@
] ]
} }
}, },
"copydist": { "bundle": {
"executor": "nx:run-commands",
"options": {
"commands": [
{
"command": "echo testing bundle created"
}
]
},
"dependsOn": [
"copyToNodeModules"
]
},
"copyToNodeModules": {
"executor": "nx:run-commands", "executor": "nx:run-commands",
"options": { "options": {
"commands": [ "commands": [
@ -854,7 +867,13 @@
"command": "rm -rf ./node_modules/@alfresco/adf-testing/ && mkdir -p ./node_modules/@alfresco/adf-testing/ && cp -R ./dist/libs/testing/* ./node_modules/@alfresco/adf-testing/" "command": "rm -rf ./node_modules/@alfresco/adf-testing/ && mkdir -p ./node_modules/@alfresco/adf-testing/ && cp -R ./dist/libs/testing/* ./node_modules/@alfresco/adf-testing/"
} }
] ]
},
"dependsOn": [
{
"projects": "self",
"target": "build-local"
} }
]
} }
} }
}, },
@ -864,11 +883,11 @@
"projectType": "library", "projectType": "library",
"prefix": "adf", "prefix": "adf",
"architect": { "architect": {
"build": { "build-local": {
"builder": "@nrwl/workspace:run-commands", "builder": "@nrwl/workspace:run-commands",
"options": { "options": {
"commands": [ "commands": [
"cd lib/cli && npm i && npm run dist && nx run cli:copydist" "cd lib/cli && npm i && npm run dist"
] ]
}, },
"configurations": { "configurations": {
@ -877,6 +896,48 @@
} }
} }
}, },
"bundle": {
"executor": "nx:run-commands",
"options": {
"commands": [
{
"command": "echo cli bundle created"
}
]
},
"dependsOn": [
"copyToNodeModules"
]
},
"moveToDist": {
"executor": "nx:run-commands",
"options": {
"commands": [
{
"command": "mkdir -p ./dist/libs/cli && cp -R ./lib/cli/dist/* dist/libs/cli/"
}
]
},
"dependsOn": [
{
"projects": "self",
"target": "build-local"
}
]
},
"copyToNodeModules": {
"executor": "nx:run-commands",
"options": {
"commands": [
{
"command": "rm -rf ./node_modules/@alfresco/adf-cli/ && mkdir -p ./node_modules/@alfresco/adf-cli/ && cp -R ./dist/libs/cli/* ./node_modules/@alfresco/adf-cli/"
}
]
},
"dependsOn": [
"moveToDist"
]
},
"lint": { "lint": {
"builder": "@nrwl/linter:eslint", "builder": "@nrwl/linter:eslint",
"options": { "options": {
@ -885,16 +946,6 @@
"lib/cli/**/*.html" "lib/cli/**/*.html"
] ]
} }
},
"copydist": {
"executor": "nx:run-commands",
"options": {
"commands": [
{
"command": "cp -R ./lib/cli/dist dist/libs/cli/ && rm -rf ./node_modules/@alfresco/adf-cli/ && mkdir -p ./node_modules/@alfresco/adf-cli/ && cp -R ./dist/libs/cli/* ./node_modules/@alfresco/adf-cli/"
}
]
}
} }
} }
}, },

View File

@ -8,7 +8,7 @@ echo "====== Run lib ====="
if [ "$CI" = "true" ]; then if [ "$CI" = "true" ]; then
echo "Building libs for production with NX_FLAG $NX_CALCULATION_FLAGS" echo "Building libs for production with NX_FLAG $NX_CALCULATION_FLAGS"
NODE_OPTIONS="--max-old-space-size=8192" $(npm bin)/nx affected:build $NX_CALCULATION_FLAGS --prod --exclude="demoshell,testing" || exit 1 NODE_OPTIONS="--max-old-space-size=8192" $(npm bin)/nx affected:build $NX_CALCULATION_FLAGS --prod --exclude="demoshell" || exit 1
else else
echo "Building libs for development with NX_FLAG $NX_CALCULATION_FLAGS" echo "Building libs for development with NX_FLAG $NX_CALCULATION_FLAGS"
NODE_OPTIONS="--max-old-space-size=8192" $(npm bin)/nx affected:build $NX_CALCULATION_FLAGS --exclude=demoshell || exit 1 NODE_OPTIONS="--max-old-space-size=8192" $(npm bin)/nx affected:build $NX_CALCULATION_FLAGS --exclude=demoshell || exit 1
@ -17,5 +17,3 @@ fi
echo "====== run core =====" echo "====== run core ====="
./scripts/build/build-core.sh || exit 1 ./scripts/build/build-core.sh || exit 1
echo "====== Run testing ====="
./scripts/build/build-testing.sh || exit 1

View File

@ -1,11 +0,0 @@
#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR/../..
echo "====== Testing ======"
echo "====== Move to node_modules ======"
nx build testing
nx run testing:copydist

View File

@ -3,15 +3,4 @@
# Download protractor-smartrunner artifact related to this particular job from S3, if exists # Download protractor-smartrunner artifact related to this particular job from S3, if exists
./scripts/ci/utils/artifact-from-s3.sh -a "$S3_SMART_RUNNER_PATH/$TRAVIS_JOB_ID.tar.bz2" -o "$SMART_RUNNER_DIRECTORY" ./scripts/ci/utils/artifact-from-s3.sh -a "$S3_SMART_RUNNER_PATH/$TRAVIS_JOB_ID.tar.bz2" -o "$SMART_RUNNER_DIRECTORY"
# TODO: This one needs to be cleaned up... Only fixing it like this, because for the current PR it is out of scope
# =======================================
rm -rf ./node_modules/@alfresco/adf-cli/ && \
mkdir -p ./node_modules/@alfresco/adf-cli/ && \
cp -R ./dist/libs/cli/* ./node_modules/@alfresco/adf-cli/
rm -rf ./node_modules/@alfresco/adf-testing/ && \
mkdir -p ./node_modules/@alfresco/adf-testing/ && \
cp -R ./dist/libs/testing/* ./node_modules/@alfresco/adf-testing/
# =======================================
exit 0 exit 0

View File

@ -1,3 +1,15 @@
#!/usr/bin/env bash #!/usr/bin/env bash
npm ci npm ci
# the cli/testing need to be always build because they are now installed from NPM!
# nx build cli
# nx build testing
# The adf-cli is not installed through NPM for this reason it needs to be built
# in addition the dist folder needs to be moved as part of the node modules
# in this way every check like check-cs check-ps can use the adf cli
# the bundle is saved under node_modules also to use the same cache of travis
nx run cli:bundle
# The adf-testing is not installed through NPM for this reason it needs to be built
# in addition the dist folder needs to be moved as part of the node modules
# in this way the protractor.config.js can use require('@alfresco/adf-testing');
nx run testing:bundle