Skip to content

Commit

Permalink
Add okta-angular as downstream of okta-auth-js (#102)
Browse files Browse the repository at this point in the history
OKTA-468781 Install auth-js from upstream artifact
  • Loading branch information
denysoblohin-okta authored Aug 26, 2022
1 parent 5094aa2 commit cd43698
Show file tree
Hide file tree
Showing 24 changed files with 757 additions and 652 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"@angular/platform-server": "7.2.16",
"@angular/router": "7.2.16",
"@compodoc/compodoc": "^1.1.19",
"@okta/okta-auth-js": "^6.2.0",
"@okta/okta-auth-js": "^6.7.6",
"@rollup/plugin-commonjs": "11.0.1",
"@rollup/plugin-node-resolve": "7.0.0",
"@types/jest": "^26.0.14",
Expand Down Expand Up @@ -101,7 +101,7 @@
"ts-loader": "^9.0.2",
"tsickle": "^0.39.1",
"tslint": "^6.1.3",
"typescript": "~3.2.0",
"typescript": "~3.8.0",
"uglify-js": "3.13.5",
"webpack": "^4.32.2",
"webpack-filter-warnings-plugin": "1.2.1",
Expand Down
17 changes: 17 additions & 0 deletions scripts/downstream/create-downstream-for-authjs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

# download okta-auth-js artifact version if empty and assign to upstream_artifact_version
if [[ -z "${upstream_artifact_version}" ]]; then
pushd ${OKTA_HOME}/okta-auth-js > /dev/null
download_job_data global artifact_version upstream_artifact_version okta-auth-js ${upstream_artifact_sha}
popd > /dev/null
echo "okta-auth-js version that will be tested: ${upstream_artifact_version}"
fi

pushd ${OKTA_HOME}/okta-angular/scripts > /dev/null
sdk_version_number="$(echo ${upstream_artifact_version} | cut -d'@' -f3)"
echo "Update okta-auth-js version in scripts/setup.sh to ${sdk_version_number}"
sed -i "s/\(AUTHJS_VERSION\=\).*/\1\"${sdk_version_number}\"/g" setup.sh
echo "Update okta-auth-js version in scripts/setup-e2e.sh to ${sdk_version_number}"
sed -i "s/\(AUTHJS_VERSION\=\).*/\1\"${sdk_version_number}\"/g" setup-e2e.sh
popd > /dev/null
54 changes: 49 additions & 5 deletions scripts/setup-e2e.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,39 @@
#!/bin/bash -xe

# Install yarn
setup_service yarn 1.21.1
# Can be used to run a canary build against a beta AuthJS version that has been published to artifactory.
# This is available from the "downstream artifact" menu on any okta-auth-js build in Bacon.
# DO NOT MERGE ANY CHANGES TO THIS LINE!!
export AUTHJS_VERSION=""

yarn global add yalc
# Install a specific version of auth-js, used by downstream artifact builds
install_auth_js () {
if [ ! -z "$AUTHJS_VERSION" ]; then
echo "Installing AUTHJS_VERSION: ${AUTHJS_VERSION}"
npm config set strict-ssl false

AUTHJS_URI=https://artifacts.aue1d.saasure.com/artifactory/npm-topic/@okta/okta-auth-js/-/@okta/okta-auth-js-${AUTHJS_VERSION}.tgz
if ! yarn add -DW --ignore-scripts ${AUTHJS_URI}; then
echo "AUTHJS_VERSION could not be installed: ${AUTHJS_VERSION}"
exit ${FAILED_SETUP}
fi

npm config set strict-ssl true
echo "AUTHJS_VERSION installed: ${AUTHJS_VERSION}"

# verify single version of auth-js is installed
# NOTE: okta-signin-widget will install it's own version of auth-js, filtered out
AUTHJS_INSTALLS=$(find . -type d -path "*/node_modules/@okta/okta-auth-js" -not -path "*/okta-signin-widget/*" | wc -l)
if [ $AUTHJS_INSTALLS -gt 1 ]; then
echo "ADDITIONAL AUTH JS INSTALL DETECTED"
yarn why @okta/okta-auth-js
exit ${FAILED_SETUP}
fi
fi
}

# Install yarn
# Use the cacert bundled with centos as okta root CA is self-signed and cause issues downloading from yarn
setup_service yarn 1.21.1 /etc/pki/tls/certs/ca-bundle.crt

# Add yarn to the $PATH so npm cli commands do not fail
export PATH="${PATH}:$(yarn global bin)"
Expand All @@ -12,6 +42,8 @@ export PATH="${PATH}:$(yarn global bin)"
export NVM_DIR="/root/.nvm"
setup_service node v14.19.3

yarn global add yalc

cd ${OKTA_HOME}/${REPO}

# undo permissions change on scripts/publish.sh
Expand Down Expand Up @@ -41,15 +73,27 @@ OKTA_REGISTRY=${ARTIFACTORY_URL}/api/npm/npm-okta-master
echo "Replacing $YARN_REGISTRY with $OKTA_REGISTRY within yarn.lock files..."
find . -type d -name node_modules -prune -o -name 'yarn.lock' -print -exec sed -i "s#${YARN_REGISTRY}#${OKTA_REGISTRY}#" {} +

if ! yarn install --frozen-lockfile; then
# Install dependencies but do not build
if ! yarn install --frozen-lockfile --ignore-scripts; then
echo "yarn install failed! Exiting..."
exit ${FAILED_SETUP}
fi

for app in test/apps/*
# Install a specific version of auth-js
install_auth_js

# Build
if ! yarn build; then
echo "yarn build failed! Exiting..."
exit ${FAILED_SETUP}
fi

# Install dependencies for test apps
for app in test/apps/angular-*
do
pushd $app
yarn install
install_auth_js
popd
done

Expand Down
46 changes: 44 additions & 2 deletions scripts/setup.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,39 @@
#!/bin/bash -xe

# Can be used to run a canary build against a beta AuthJS version that has been published to artifactory.
# This is available from the "downstream artifact" menu on any okta-auth-js build in Bacon.
# DO NOT MERGE ANY CHANGES TO THIS LINE!!
export AUTHJS_VERSION=""

# Install a specific version of auth-js, used by downstream artifact builds
install_auth_js () {
if [ ! -z "$AUTHJS_VERSION" ]; then
echo "Installing AUTHJS_VERSION: ${AUTHJS_VERSION}"
npm config set strict-ssl false

AUTHJS_URI=https://artifacts.aue1d.saasure.com/artifactory/npm-topic/@okta/okta-auth-js/-/@okta/okta-auth-js-${AUTHJS_VERSION}.tgz
if ! yarn add -DW --ignore-scripts ${AUTHJS_URI}; then
echo "AUTHJS_VERSION could not be installed: ${AUTHJS_VERSION}"
exit ${FAILED_SETUP}
fi

npm config set strict-ssl true
echo "AUTHJS_VERSION installed: ${AUTHJS_VERSION}"

# verify single version of auth-js is installed
# NOTE: okta-signin-widget will install it's own version of auth-js, filtered out
AUTHJS_INSTALLS=$(find . -type d -path "*/node_modules/@okta/okta-auth-js" -not -path "*/okta-signin-widget/*" | wc -l)
if [ $AUTHJS_INSTALLS -gt 1 ]; then
echo "ADDITIONAL AUTH JS INSTALL DETECTED"
yarn why @okta/okta-auth-js
exit ${FAILED_SETUP}
fi
fi
}

# Install yarn
setup_service yarn 1.21.1
# Use the cacert bundled with centos as okta root CA is self-signed and cause issues downloading from yarn
setup_service yarn 1.21.1 /etc/pki/tls/certs/ca-bundle.crt

# Add yarn to the $PATH so npm cli commands do not fail
export PATH="${PATH}:$(yarn global bin)"
Expand Down Expand Up @@ -39,11 +71,21 @@ OKTA_REGISTRY=${ARTIFACTORY_URL}/api/npm/npm-okta-master
echo "Replacing $YARN_REGISTRY with $OKTA_REGISTRY within yarn.lock files..."
sed -i "s#${YARN_REGISTRY}#${OKTA_REGISTRY}#" yarn.lock

if ! yarn install --frozen-lockfile; then
# Install dependencies but do not build
if ! yarn install --frozen-lockfile --ignore-scripts; then
echo "yarn install failed! Exiting..."
exit ${FAILED_SETUP}
fi

# Revert the original change(s)
echo "Replacing $OKTA_REGISTRY with $YARN_REGISTRY within yarn.lock files..."
sed -i "s#${OKTA_REGISTRY}#${YARN_REGISTRY}#" yarn.lock

# Install a specific version of auth-jss
install_auth_js

# Build
if ! yarn build; then
echo "yarn build failed! Exiting..."
exit ${FAILED_SETUP}
fi
2 changes: 1 addition & 1 deletion test/apps/angular-v10/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"@angular/platform-browser": "~10.2.4",
"@angular/platform-browser-dynamic": "~10.2.4",
"@angular/router": "~10.2.4",
"@okta/okta-auth-js": "^6.2.0",
"@okta/okta-auth-js": "*",
"rxjs": "~6.6.0",
"tslib": "^2.0.0",
"zone.js": "~0.10.2"
Expand Down
Loading

0 comments on commit cd43698

Please sign in to comment.