@docupace/pipeline 1.0.6 → 1.0.7-7.micro-cli2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prettierrc.cjs +12 -12
- package/README.md +136 -0
- package/bin/azuread_update_callbacks_for_app.sh +58 -0
- package/bin/next-changeset-validate.sh +8 -8
- package/bitbucket-pipelines.yml +60 -0
- package/eslint.config.js +49 -26
- package/jest.config.js +15 -0
- package/next/changeset.sh +75 -75
- package/next/copy.sh +34 -34
- package/next/deploy.sh +40 -40
- package/next/execute.sh +123 -117
- package/next/sonar.sh +23 -23
- package/package.json +23 -7
- package/src/auth0/alias.js +79 -0
- package/src/auth0/alias.test.js +172 -0
- package/src/auth0/cli.js +82 -0
- package/src/auth0/configure.js +902 -0
- package/src/auth0/configure.test.js +167 -0
- package/src/auth0/export.js +48 -0
- package/src/auth0/export.test.js +103 -0
- package/src/auth0/metadata.js +141 -0
- package/src/auth0/metadata.test.js +186 -0
- package/src/auth0/vault.js +60 -0
- package/src/auth0/vault.test.js +134 -0
- package/src/changeset/changelog-wiki.js +328 -0
- package/src/changeset/changeset-config.js +34 -0
- package/src/changeset/cli.js +237 -281
- package/src/changeset/create.js +215 -0
- package/src/changeset/package-util.js +87 -0
- package/src/changeset/util.js +43 -0
- package/src/changeset/validate.js +91 -47
- package/src/changeset/version.js +102 -0
- package/src/jenkins/setParams.groovy +58 -59
- package/src/lib/merge-driver.js +204 -0
- package/src/merge/cli-merge-all.js +507 -0
- package/src/merge/cli-merge.js +492 -0
- package/src/merge/cli-resolve.js +399 -0
- package/src/merge/cli.js +38 -0
- package/src/merge/merge-changelog.js +87 -0
- package/src/merge/merge-package.js +106 -0
- package/src/merge/merge-types.js +82 -0
- package/src/merge/pr.js +231 -0
- package/src/micro/cli.js +71 -0
- package/src/micro/ms-deploy.js +273 -0
- package/src/micro/ms-publish.js +186 -0
- package/src/next/alias.js +53 -0
- package/src/next/apache.js +81 -0
- package/src/next/cli.js +111 -15
- package/src/next/config.js +137 -72
- package/src/next/connect.js +226 -0
- package/src/next/copy.js +61 -30
- package/src/next/deploy.js +633 -312
- package/src/next/git-to-semver.js +79 -0
- package/src/next/haproxy.js +76 -0
- package/src/next/jenkins.js +123 -88
- package/src/next/jira.js +84 -0
- package/src/next/logger.js +17 -0
- package/src/next/pipline.js +114 -115
- package/src/next/publish.js +71 -48
- package/src/next/pull.js +7 -7
- package/src/next/sonar.js +23 -23
- package/src/next/test.js +5 -0
- package/src/next/util.js +93 -0
- package/src/next/vault.js +45 -0
- package/terraform/apply.sh +37 -0
- package/terraform/init.sh +72 -0
- package/terraform/plan.sh +76 -0
- package/terraform/validate.sh +17 -0
package/next/deploy.sh
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
set -e # Enable command tracing
|
|
4
|
-
# Variables
|
|
5
|
-
REPO_NAME="gitops-dev"
|
|
6
|
-
REPO_URL="https://x-token-auth:$GITOPS_REP_TOKEN@bitbucket.org/dp-cloud/${REPO_NAME}.git"
|
|
7
|
-
FILE_PATH="dp/$2/$1.values.yaml"
|
|
8
|
-
BUILD_NUMBER=$BITBUCKET_BUILD_NUMBER
|
|
9
|
-
GITOPS_BRANCH=master
|
|
10
|
-
if [ -n "$VERSION_TAG" ]; then
|
|
11
|
-
DEPLOY_TAG=$VERSION_TAG
|
|
12
|
-
else
|
|
13
|
-
DEPLOY_TAG="build-$BUILD_NUMBER"
|
|
14
|
-
fi
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
# Clone the repository
|
|
19
|
-
|
|
20
|
-
git config user.email qxebpukjnzljnwty1knte7ym53aogk@bots.bitbucket.org
|
|
21
|
-
git clone $REPO_URL
|
|
22
|
-
cd ${REPO_NAME} || exit
|
|
23
|
-
|
|
24
|
-
# Checkout the branch
|
|
25
|
-
|
|
26
|
-
# Modify the YAML file
|
|
27
|
-
sed -i "s/tag: .*/tag: $DEPLOY_TAG/" $FILE_PATH
|
|
28
|
-
|
|
29
|
-
# Add changes to git
|
|
30
|
-
git add $FILE_PATH
|
|
31
|
-
|
|
32
|
-
# Commit changes
|
|
33
|
-
git commit -m "Update image tag to $DEPLOY_TAG"
|
|
34
|
-
|
|
35
|
-
# Push changes
|
|
36
|
-
git push origin $GITOPS_BRANCH
|
|
37
|
-
|
|
38
|
-
# Clean up
|
|
39
|
-
cd ..
|
|
40
|
-
rm -rf ${REPO_NAME}
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
set -e # Enable command tracing
|
|
4
|
+
# Variables
|
|
5
|
+
REPO_NAME="gitops-dev"
|
|
6
|
+
REPO_URL="https://x-token-auth:$GITOPS_REP_TOKEN@bitbucket.org/dp-cloud/${REPO_NAME}.git"
|
|
7
|
+
FILE_PATH="dp/$2/$1.values.yaml"
|
|
8
|
+
BUILD_NUMBER=$BITBUCKET_BUILD_NUMBER
|
|
9
|
+
GITOPS_BRANCH=master
|
|
10
|
+
if [ -n "$VERSION_TAG" ]; then
|
|
11
|
+
DEPLOY_TAG=$VERSION_TAG
|
|
12
|
+
else
|
|
13
|
+
DEPLOY_TAG="build-$BUILD_NUMBER"
|
|
14
|
+
fi
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
# Clone the repository
|
|
19
|
+
|
|
20
|
+
git config user.email qxebpukjnzljnwty1knte7ym53aogk@bots.bitbucket.org
|
|
21
|
+
git clone $REPO_URL
|
|
22
|
+
cd ${REPO_NAME} || exit
|
|
23
|
+
|
|
24
|
+
# Checkout the branch
|
|
25
|
+
|
|
26
|
+
# Modify the YAML file
|
|
27
|
+
sed -i "s/tag: .*/tag: $DEPLOY_TAG/" $FILE_PATH
|
|
28
|
+
|
|
29
|
+
# Add changes to git
|
|
30
|
+
git add $FILE_PATH
|
|
31
|
+
|
|
32
|
+
# Commit changes
|
|
33
|
+
git commit -m "Update image tag to $DEPLOY_TAG"
|
|
34
|
+
|
|
35
|
+
# Push changes
|
|
36
|
+
git push origin $GITOPS_BRANCH
|
|
37
|
+
|
|
38
|
+
# Clean up
|
|
39
|
+
cd ..
|
|
40
|
+
rm -rf ${REPO_NAME}
|
package/next/execute.sh
CHANGED
|
@@ -1,117 +1,123 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# Usage: ./pipeline.sh <function> <BITBUCKET_REPO_SLUG>
|
|
4
|
-
# Example: ./pipeline.sh build docupace-ui-main
|
|
5
|
-
|
|
6
|
-
set -e # Enable command tracing
|
|
7
|
-
GIT_SHA=$(git log --pretty=format:'%h' -n 1)
|
|
8
|
-
JF_REGISTRY_FULL_URL="${JF_REGISTRY_URL}/${JF_REGISTRY_REPO_NAME}"
|
|
9
|
-
PARAM1=$2
|
|
10
|
-
PARAM2=$3
|
|
11
|
-
|
|
12
|
-
pull() {
|
|
13
|
-
IMAGE_NAME=$2
|
|
14
|
-
docker pull "${JF_REGISTRY_FULL_URL}/${IMAGE_NAME}"
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
# Function to run Sonar analysis
|
|
18
|
-
sonar() {
|
|
19
|
-
export DOCKER_HOST=""
|
|
20
|
-
IMAGE_NAME="${BITBUCKET_REPO_SLUG}:sha-${GIT_SHA}"
|
|
21
|
-
SONAR_CONTAINER_NAME="${BITBUCKET_REPO_SLUG}-${GIT_SHA}"
|
|
22
|
-
|
|
23
|
-
echo "Running Sonar analysis on Docker image ${IMAGE_NAME}..."
|
|
24
|
-
|
|
25
|
-
# Remove any existing container with the same name
|
|
26
|
-
if [ "$(docker ps -a --filter "name=$SONAR_CONTAINER_NAME" --format "{{.Names}}")" ]; then
|
|
27
|
-
docker rm -f $SONAR_CONTAINER_NAME
|
|
28
|
-
fi
|
|
29
|
-
|
|
30
|
-
cd "$ROOT_DIR"
|
|
31
|
-
docker run --rm \
|
|
32
|
-
-e BRANCH=$BITBUCKET_BRANCH \
|
|
33
|
-
-e PR_ID=$BITBUCKET_PR_ID \
|
|
34
|
-
-e PR_DESTINATION_BRANCH=$BITBUCKET_PR_DESTINATION_BRANCH \
|
|
35
|
-
-e SONAR_TOKEN=$SONAR_TOKEN \
|
|
36
|
-
--name $SONAR_CONTAINER_NAME $IMAGE_NAME pnpm sonar
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
# Function to publish the Docker image
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
loginRegistry() {
|
|
43
|
-
echo ${JF_REGISTRY_PASSWORD_DEV} | docker login --username ${JF_REGISTRY_USER_DEV} --password-stdin ${JF_REGISTRY_URL}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
logoutRegistry() {
|
|
47
|
-
docker logout ${JF_REGISTRY_URL}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
copy() {
|
|
51
|
-
DIR="$(dirname "$0")"
|
|
52
|
-
bash $DIR/copy.sh
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
publish() {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
#
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
;;
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
;;
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
;;
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Usage: ./pipeline.sh <function> <BITBUCKET_REPO_SLUG>
|
|
4
|
+
# Example: ./pipeline.sh build docupace-ui-main
|
|
5
|
+
|
|
6
|
+
set -e # Enable command tracing
|
|
7
|
+
GIT_SHA=$(git log --pretty=format:'%h' -n 1)
|
|
8
|
+
JF_REGISTRY_FULL_URL="${JF_REGISTRY_URL}/${JF_REGISTRY_REPO_NAME}"
|
|
9
|
+
PARAM1=$2
|
|
10
|
+
PARAM2=$3
|
|
11
|
+
|
|
12
|
+
pull() {
|
|
13
|
+
IMAGE_NAME=$2
|
|
14
|
+
docker pull "${JF_REGISTRY_FULL_URL}/${IMAGE_NAME}"
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
# Function to run Sonar analysis
|
|
18
|
+
sonar() {
|
|
19
|
+
export DOCKER_HOST=""
|
|
20
|
+
IMAGE_NAME="${BITBUCKET_REPO_SLUG}:sha-${GIT_SHA}"
|
|
21
|
+
SONAR_CONTAINER_NAME="${BITBUCKET_REPO_SLUG}-${GIT_SHA}"
|
|
22
|
+
|
|
23
|
+
echo "Running Sonar analysis on Docker image ${IMAGE_NAME}..."
|
|
24
|
+
|
|
25
|
+
# Remove any existing container with the same name
|
|
26
|
+
if [ "$(docker ps -a --filter "name=$SONAR_CONTAINER_NAME" --format "{{.Names}}")" ]; then
|
|
27
|
+
docker rm -f $SONAR_CONTAINER_NAME
|
|
28
|
+
fi
|
|
29
|
+
|
|
30
|
+
cd "$ROOT_DIR"
|
|
31
|
+
docker run --rm \
|
|
32
|
+
-e BRANCH=$BITBUCKET_BRANCH \
|
|
33
|
+
-e PR_ID=$BITBUCKET_PR_ID \
|
|
34
|
+
-e PR_DESTINATION_BRANCH=$BITBUCKET_PR_DESTINATION_BRANCH \
|
|
35
|
+
-e SONAR_TOKEN=$SONAR_TOKEN \
|
|
36
|
+
--name $SONAR_CONTAINER_NAME $IMAGE_NAME pnpm sonar
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
# Function to publish the Docker image
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
loginRegistry() {
|
|
43
|
+
echo ${JF_REGISTRY_PASSWORD_DEV} | docker login --username ${JF_REGISTRY_USER_DEV} --password-stdin ${JF_REGISTRY_URL}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
logoutRegistry() {
|
|
47
|
+
docker logout ${JF_REGISTRY_URL}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
copy() {
|
|
51
|
+
DIR="$(dirname "$0")"
|
|
52
|
+
bash $DIR/copy.sh
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
publish() {
|
|
56
|
+
SLUG_SUFFIX=""
|
|
57
|
+
if [ -n "$APP_NAME" ]; then
|
|
58
|
+
SLUG_SUFFIX="-${APP_NAME}"
|
|
59
|
+
fi
|
|
60
|
+
|
|
61
|
+
BUILD_IMAGE_NAME="${BITBUCKET_REPO_SLUG}${SLUG_SUFFIX}:build-${BITBUCKET_BUILD_NUMBER}"
|
|
62
|
+
IMAGE_NAME="${BITBUCKET_REPO_SLUG}${SLUG_SUFFIX}:sha-${GIT_SHA}"
|
|
63
|
+
|
|
64
|
+
export DOCKER_HOST=""
|
|
65
|
+
|
|
66
|
+
echo "Publishing Docker image ${IMAGE_NAME}..."
|
|
67
|
+
|
|
68
|
+
loginRegistry
|
|
69
|
+
|
|
70
|
+
# Check if the image already exists in the registry
|
|
71
|
+
if docker manifest inspect ${JF_REGISTRY_FULL_URL}/${IMAGE_NAME} >/dev/null 2>&1; then
|
|
72
|
+
echo "Tag sha-${GIT_SHA} already exists in the remote repository. Skipping push."
|
|
73
|
+
else
|
|
74
|
+
docker tag ${IMAGE_NAME} "${JF_REGISTRY_FULL_URL}/${IMAGE_NAME}"
|
|
75
|
+
docker push "${JF_REGISTRY_FULL_URL}/${IMAGE_NAME}"
|
|
76
|
+
fi
|
|
77
|
+
|
|
78
|
+
# Tag and push the build image
|
|
79
|
+
docker tag ${IMAGE_NAME} "${JF_REGISTRY_FULL_URL}/${BUILD_IMAGE_NAME}"
|
|
80
|
+
docker push "${JF_REGISTRY_FULL_URL}/${BUILD_IMAGE_NAME}"
|
|
81
|
+
|
|
82
|
+
# Tag and push each Git tag as a Docker tag
|
|
83
|
+
GIT_TAGS=$(git tag --points-at HEAD)
|
|
84
|
+
for GIT_TAG in ${GIT_TAGS}; do
|
|
85
|
+
docker tag ${IMAGE_NAME} "${JF_REGISTRY_FULL_URL}/${BITBUCKET_REPO_SLUG}:${GIT_TAG}"
|
|
86
|
+
docker push "${JF_REGISTRY_FULL_URL}/${BITBUCKET_REPO_SLUG}:${GIT_TAG}"
|
|
87
|
+
done
|
|
88
|
+
|
|
89
|
+
# Logout from Docker registry
|
|
90
|
+
loginRegistry
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
# Function to deploy
|
|
94
|
+
# application - ui|graphql
|
|
95
|
+
# site
|
|
96
|
+
deploy() {
|
|
97
|
+
echo "Deploying $PARAM1 application for site $PARAM2..."
|
|
98
|
+
DIR="$(dirname "$0")"
|
|
99
|
+
bash $DIR/deploy.sh $PARAM1 $PARAM2
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
# Main logic to call the appropriate function
|
|
103
|
+
case "$1" in
|
|
104
|
+
build)
|
|
105
|
+
build
|
|
106
|
+
;;
|
|
107
|
+
sonar)
|
|
108
|
+
sonar
|
|
109
|
+
;;
|
|
110
|
+
publish)
|
|
111
|
+
publish
|
|
112
|
+
;;
|
|
113
|
+
deploy)
|
|
114
|
+
deploy
|
|
115
|
+
;;
|
|
116
|
+
copy)
|
|
117
|
+
copy
|
|
118
|
+
;;
|
|
119
|
+
*)
|
|
120
|
+
echo "Usage: $0 {build|sonar|publish|deploy|copy} <BITBUCKET_REPO_SLUG>"
|
|
121
|
+
exit 1
|
|
122
|
+
;;
|
|
123
|
+
esac
|
package/next/sonar.sh
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# Initialize sonar-scanner command with common parameters
|
|
4
|
-
SONAR_CMD="npx sonarqube-scanner"
|
|
5
|
-
|
|
6
|
-
echo "PR_ID=$PR_ID"
|
|
7
|
-
echo "BRANCH=$BRANCH"
|
|
8
|
-
echo "PR_DESTINATION_BRANCH=$PR_DESTINATION_BRANCH"
|
|
9
|
-
|
|
10
|
-
# Determine the type of scan based on environment variables
|
|
11
|
-
if [[ ! -z "$PR_ID" ]]; then
|
|
12
|
-
SONAR_CMD+=" \
|
|
13
|
-
-Dsonar.pullrequest.key=$PR_ID \
|
|
14
|
-
-Dsonar.pullrequest.branch=$BRANCH \
|
|
15
|
-
-Dsonar.pullrequest.base=$PR_DESTINATION_BRANCH"
|
|
16
|
-
else
|
|
17
|
-
SONAR_CMD+=" \
|
|
18
|
-
-Dsonar.branch.name=$BRANCH"
|
|
19
|
-
fi
|
|
20
|
-
|
|
21
|
-
# Execute the sonar-scanner command
|
|
22
|
-
echo "Running: $SONAR_CMD"
|
|
23
|
-
$SONAR_CMD
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Initialize sonar-scanner command with common parameters
|
|
4
|
+
SONAR_CMD="npx sonarqube-scanner"
|
|
5
|
+
|
|
6
|
+
echo "PR_ID=$PR_ID"
|
|
7
|
+
echo "BRANCH=$BRANCH"
|
|
8
|
+
echo "PR_DESTINATION_BRANCH=$PR_DESTINATION_BRANCH"
|
|
9
|
+
|
|
10
|
+
# Determine the type of scan based on environment variables
|
|
11
|
+
if [[ ! -z "$PR_ID" ]]; then
|
|
12
|
+
SONAR_CMD+=" \
|
|
13
|
+
-Dsonar.pullrequest.key=$PR_ID \
|
|
14
|
+
-Dsonar.pullrequest.branch=$BRANCH \
|
|
15
|
+
-Dsonar.pullrequest.base=$PR_DESTINATION_BRANCH"
|
|
16
|
+
else
|
|
17
|
+
SONAR_CMD+=" \
|
|
18
|
+
-Dsonar.branch.name=$BRANCH"
|
|
19
|
+
fi
|
|
20
|
+
|
|
21
|
+
# Execute the sonar-scanner command
|
|
22
|
+
echo "Running: $SONAR_CMD"
|
|
23
|
+
$SONAR_CMD
|
package/package.json
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docupace/pipeline",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "",
|
|
3
|
+
"version": "1.0.77.micro-cli2",
|
|
5
4
|
"main": "index.js",
|
|
6
5
|
"type": "module",
|
|
7
6
|
"bin": {
|
|
8
7
|
"dp-changeset-cli": "src/changeset/cli.js",
|
|
9
|
-
"dp-next-cli": "src/next/cli.js"
|
|
8
|
+
"dp-next-cli": "src/next/cli.js",
|
|
9
|
+
"dp-auth0-cli": "src/auth0/cli.js",
|
|
10
|
+
"dp-merge-cli": "src/merge/cli.js",
|
|
11
|
+
"dp-micro-cli": "src/merge/cli.js"
|
|
10
12
|
},
|
|
11
13
|
"keywords": [
|
|
12
14
|
"bash"
|
|
@@ -15,27 +17,41 @@
|
|
|
15
17
|
"license": "ISC",
|
|
16
18
|
"dependencies": {
|
|
17
19
|
"@changesets/cli": "^2.27.10",
|
|
20
|
+
"@docupace/core-client": "^1.0.1",
|
|
21
|
+
"@docupace/pipeline": "^1.0.12",
|
|
22
|
+
"@jest/globals": "^30.1.2",
|
|
23
|
+
"auth0-deploy-cli": "^8.8.0",
|
|
18
24
|
"axios": "^1.7.9",
|
|
19
25
|
"commander": "^12.1.0",
|
|
20
26
|
"dotenv": "^16.4.7",
|
|
27
|
+
"eslint-plugin-import": "^2.32.0",
|
|
28
|
+
"fs-extra": "^11.3.0",
|
|
29
|
+
"inquirer": "^12.6.1",
|
|
21
30
|
"js-yaml": "^4.1.0",
|
|
22
31
|
"lodash": "^4.17.21",
|
|
23
32
|
"openai": "^4.76.3",
|
|
33
|
+
"semver": "^7.7.2",
|
|
24
34
|
"zod": "^3.24.1",
|
|
25
|
-
"zx": "^8.
|
|
35
|
+
"zx": "^8.8.1"
|
|
26
36
|
},
|
|
27
37
|
"devDependencies": {
|
|
28
38
|
"@eslint/js": "^9.17.0",
|
|
29
|
-
"esbuild": "^0.
|
|
30
|
-
"eslint": "^9.
|
|
39
|
+
"esbuild": "^0.25.12",
|
|
40
|
+
"eslint": "^9.34.0",
|
|
31
41
|
"eslint-config-prettier": "^9.1.0",
|
|
42
|
+
"eslint-import-resolver-node": "^0.3.9",
|
|
43
|
+
"eslint-import-resolver-typescript": "^4.4.4",
|
|
32
44
|
"eslint-plugin-prettier": "^5.2.1",
|
|
33
45
|
"globals": "^15.14.0",
|
|
46
|
+
"jest": "^30.1.3",
|
|
34
47
|
"prettier": "^3.4.2"
|
|
35
48
|
},
|
|
36
49
|
"scripts": {
|
|
50
|
+
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js --coverage --testPathIgnorePatterns='src/next/test\\.js'",
|
|
37
51
|
"test-deploy-core": "dp-next-cli deploy-core-pipeline dev template",
|
|
38
52
|
"test-deploy-from-site": "dp-next-cli deploy-from-site --from-env dev --to-env dev --from-site financialdev --to-site template --deploy-core true",
|
|
39
|
-
"test-run-pipline": "dp-next-cli run-pipeline -r docupace-next-e2e -b master -p run-tests-qa"
|
|
53
|
+
"test-run-pipline": "dp-next-cli run-pipeline -r docupace-next-e2e -b master -p run-tests-qa",
|
|
54
|
+
"test-validate": "dp-changset-cli validate",
|
|
55
|
+
"test-create": "dp-changset-cli create-changeset"
|
|
40
56
|
}
|
|
41
57
|
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import { createAlias } from '../next/alias.js';
|
|
3
|
+
import { getAuth0AuthToken } from './configure.js';
|
|
4
|
+
import { getVaultSecrets } from './vault.js';
|
|
5
|
+
import { getVaultSecretsConfigs } from '../next/config.js';
|
|
6
|
+
import { cloneEnvRepository, readDeployConfig } from '../next/deploy.js';
|
|
7
|
+
|
|
8
|
+
export async function getCCAlias({ application, auth0Domain, auth0AuthToken }) {
|
|
9
|
+
console.log(`Forming alias name for application ${application}...`);
|
|
10
|
+
|
|
11
|
+
try {
|
|
12
|
+
const auth0Response = await axios.get(
|
|
13
|
+
`https://${auth0Domain}/api/v2/clients`,
|
|
14
|
+
{
|
|
15
|
+
headers: { authorization: `Bearer ${auth0AuthToken}` },
|
|
16
|
+
},
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
const appAuth0ClientIdData = auth0Response.data.find(
|
|
20
|
+
(client) => client.name === `${application}`,
|
|
21
|
+
);
|
|
22
|
+
const appAuth0ClientId = appAuth0ClientIdData.client_id;
|
|
23
|
+
|
|
24
|
+
console.log(`Client Credentials Alias: ${appAuth0ClientId}@clients`);
|
|
25
|
+
return `${appAuth0ClientId}@clients`;
|
|
26
|
+
} catch (err) {
|
|
27
|
+
console.error(
|
|
28
|
+
`Failed to form alias name for application: ${application}: ${err.message}`,
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export async function configureAlias(
|
|
34
|
+
site,
|
|
35
|
+
env,
|
|
36
|
+
username,
|
|
37
|
+
password,
|
|
38
|
+
realm,
|
|
39
|
+
auth0Tenant,
|
|
40
|
+
) {
|
|
41
|
+
console.log(`Creating alias for site: ${site} in env: ${env}`);
|
|
42
|
+
// Site Common Secrets
|
|
43
|
+
const siteCommonSecretsPath =
|
|
44
|
+
getVaultSecretsConfigs(site).siteCommonSecretsPath;
|
|
45
|
+
console.log(`siteCommonSecretsPath => ${siteCommonSecretsPath}`);
|
|
46
|
+
const siteCommonSecrets = await getVaultSecrets(siteCommonSecretsPath);
|
|
47
|
+
|
|
48
|
+
let auth0Domain;
|
|
49
|
+
if (auth0Tenant === '') {
|
|
50
|
+
auth0Domain = `docupace-${env}-${site}.us.auth0.com`;
|
|
51
|
+
} else {
|
|
52
|
+
auth0Domain = `${auth0Tenant}.us.auth0.com`;
|
|
53
|
+
}
|
|
54
|
+
const auth0ClientId = siteCommonSecrets.AUTH0_CLIENT_ID;
|
|
55
|
+
const auth0ClientSecret = siteCommonSecrets.AUTH0_CLIENT_SECRET;
|
|
56
|
+
const auth0Token = await getAuth0AuthToken(
|
|
57
|
+
auth0Domain,
|
|
58
|
+
auth0ClientId,
|
|
59
|
+
auth0ClientSecret,
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
await cloneEnvRepository(env);
|
|
63
|
+
|
|
64
|
+
const { deployConfig: deployGraphQLServerConfig } = await readDeployConfig(
|
|
65
|
+
'graphql-server',
|
|
66
|
+
env,
|
|
67
|
+
site,
|
|
68
|
+
'values',
|
|
69
|
+
);
|
|
70
|
+
const coreUrl = deployGraphQLServerConfig.graphqlServer.coreUrl;
|
|
71
|
+
|
|
72
|
+
const clientCredentialsAlias = await getCCAlias({
|
|
73
|
+
application: 'docupace-graphql-client-credentials',
|
|
74
|
+
auth0Domain: auth0Domain,
|
|
75
|
+
auth0AuthToken: auth0Token,
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
await createAlias(coreUrl, username, password, realm, clientCredentialsAlias);
|
|
79
|
+
}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
// alias.test.js
|
|
2
|
+
import { jest } from '@jest/globals';
|
|
3
|
+
|
|
4
|
+
// --------- ESM-Compatible Mocks ---------
|
|
5
|
+
jest.unstable_mockModule('axios', () => ({
|
|
6
|
+
default: {
|
|
7
|
+
get: jest.fn(),
|
|
8
|
+
},
|
|
9
|
+
}));
|
|
10
|
+
|
|
11
|
+
jest.unstable_mockModule('../next/alias.js', () => ({
|
|
12
|
+
createAlias: jest.fn(),
|
|
13
|
+
}));
|
|
14
|
+
|
|
15
|
+
jest.unstable_mockModule('./configure.js', () => ({
|
|
16
|
+
getAuth0AuthToken: jest.fn(),
|
|
17
|
+
}));
|
|
18
|
+
|
|
19
|
+
jest.unstable_mockModule('./vault.js', () => ({
|
|
20
|
+
getVaultSecrets: jest.fn(),
|
|
21
|
+
}));
|
|
22
|
+
|
|
23
|
+
jest.unstable_mockModule('../next/config.js', () => ({
|
|
24
|
+
getVaultSecretsConfigs: jest.fn(),
|
|
25
|
+
}));
|
|
26
|
+
|
|
27
|
+
jest.unstable_mockModule('../next/deploy.js', () => ({
|
|
28
|
+
cloneEnvRepository: jest.fn(),
|
|
29
|
+
readDeployConfig: jest.fn(),
|
|
30
|
+
}));
|
|
31
|
+
|
|
32
|
+
// --------- Import AFTER mocks ---------
|
|
33
|
+
const { configureAlias, getCCAlias } = await import('./alias.js');
|
|
34
|
+
const axios = (await import('axios')).default;
|
|
35
|
+
const { createAlias } = await import('../next/alias.js');
|
|
36
|
+
const { getAuth0AuthToken } = await import('./configure.js');
|
|
37
|
+
const { getVaultSecrets } = await import('./vault.js');
|
|
38
|
+
const { getVaultSecretsConfigs } = await import('../next/config.js');
|
|
39
|
+
const { cloneEnvRepository, readDeployConfig } = await import(
|
|
40
|
+
'../next/deploy.js'
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
// --------- Shared Test Setup ---------
|
|
44
|
+
beforeAll(() => {
|
|
45
|
+
jest.spyOn(console, 'log').mockImplementation(() => {}); // silence logs
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
afterAll(() => {
|
|
49
|
+
console.log.mockRestore();
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
describe('configureAlias', () => {
|
|
53
|
+
const site = 'example';
|
|
54
|
+
const env = 'dev';
|
|
55
|
+
const username = 'admin';
|
|
56
|
+
const password = 'pass';
|
|
57
|
+
const realm = 'Users';
|
|
58
|
+
const auth0Tenant = '';
|
|
59
|
+
|
|
60
|
+
const mockSecrets = {
|
|
61
|
+
AUTH0_CLIENT_ID: 'client-id',
|
|
62
|
+
AUTH0_CLIENT_SECRET: 'client-secret',
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const mockToken = 'mocked-auth0-token';
|
|
66
|
+
|
|
67
|
+
const mockClients = [
|
|
68
|
+
{ name: 'docupace-graphql-client-credentials', client_id: 'client-123' },
|
|
69
|
+
];
|
|
70
|
+
|
|
71
|
+
const mockConfig = {
|
|
72
|
+
deployConfig: {
|
|
73
|
+
graphqlServer: {
|
|
74
|
+
coreUrl: 'https://core.example.com',
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
beforeEach(() => {
|
|
80
|
+
jest.clearAllMocks();
|
|
81
|
+
|
|
82
|
+
getVaultSecretsConfigs.mockReturnValue({
|
|
83
|
+
siteCommonSecretsPath: 'vault/path/to/secrets',
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
getVaultSecrets.mockResolvedValue(mockSecrets);
|
|
87
|
+
getAuth0AuthToken.mockResolvedValue(mockToken);
|
|
88
|
+
axios.get.mockResolvedValue({ data: mockClients });
|
|
89
|
+
cloneEnvRepository.mockResolvedValue(undefined);
|
|
90
|
+
readDeployConfig.mockResolvedValue(mockConfig);
|
|
91
|
+
createAlias.mockResolvedValue(undefined);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it('should configure alias with default tenant and call all required steps', async () => {
|
|
95
|
+
await configureAlias(site, env, username, password, realm, auth0Tenant);
|
|
96
|
+
|
|
97
|
+
expect(getVaultSecretsConfigs).toHaveBeenCalledWith(site);
|
|
98
|
+
expect(getVaultSecrets).toHaveBeenCalledWith('vault/path/to/secrets');
|
|
99
|
+
|
|
100
|
+
expect(getAuth0AuthToken).toHaveBeenCalledWith(
|
|
101
|
+
'docupace-dev-example.us.auth0.com',
|
|
102
|
+
'client-id',
|
|
103
|
+
'client-secret',
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
expect(cloneEnvRepository).toHaveBeenCalledWith(env);
|
|
107
|
+
|
|
108
|
+
expect(readDeployConfig).toHaveBeenCalledWith(
|
|
109
|
+
'graphql-server',
|
|
110
|
+
env,
|
|
111
|
+
site,
|
|
112
|
+
'values',
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
expect(axios.get).toHaveBeenCalledWith(
|
|
116
|
+
'https://docupace-dev-example.us.auth0.com/api/v2/clients',
|
|
117
|
+
{ headers: { authorization: `Bearer ${mockToken}` } },
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
expect(createAlias).toHaveBeenCalledWith(
|
|
121
|
+
'https://core.example.com',
|
|
122
|
+
username,
|
|
123
|
+
password,
|
|
124
|
+
realm,
|
|
125
|
+
'client-123@clients',
|
|
126
|
+
);
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
describe('getCCAlias', () => {
|
|
131
|
+
const application = 'docupace-graphql-client-credentials';
|
|
132
|
+
const auth0Domain = 'example.auth0.com';
|
|
133
|
+
const auth0AuthToken = 'token';
|
|
134
|
+
|
|
135
|
+
it('should return correct alias string for client', async () => {
|
|
136
|
+
axios.get.mockResolvedValue({
|
|
137
|
+
data: [{ name: application, client_id: 'abc123' }],
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
const alias = await getCCAlias({
|
|
141
|
+
application,
|
|
142
|
+
auth0Domain,
|
|
143
|
+
auth0AuthToken,
|
|
144
|
+
});
|
|
145
|
+
expect(alias).toBe('abc123@clients');
|
|
146
|
+
|
|
147
|
+
expect(axios.get).toHaveBeenCalledWith(
|
|
148
|
+
'https://example.auth0.com/api/v2/clients',
|
|
149
|
+
{ headers: { authorization: 'Bearer token' } },
|
|
150
|
+
);
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
it('should log error and return undefined if axios fails', async () => {
|
|
154
|
+
axios.get.mockRejectedValue(new Error('Network error'));
|
|
155
|
+
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
|
156
|
+
|
|
157
|
+
const result = await getCCAlias({
|
|
158
|
+
application,
|
|
159
|
+
auth0Domain,
|
|
160
|
+
auth0AuthToken,
|
|
161
|
+
});
|
|
162
|
+
expect(result).toBeUndefined();
|
|
163
|
+
|
|
164
|
+
expect(errorSpy).toHaveBeenCalledWith(
|
|
165
|
+
expect.stringContaining(
|
|
166
|
+
'Failed to form alias name for application: docupace-graphql-client-credentials: Network error',
|
|
167
|
+
),
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
errorSpy.mockRestore();
|
|
171
|
+
});
|
|
172
|
+
});
|