Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Buie react test app #3738

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ test/videos
test/dev.html
yarn-debug.log
yarn-error.log
verdaccio
95 changes: 95 additions & 0 deletions scripts/app-testing/app_testing_main.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#!/bin/bash


VERDACCIO_PORT=4873
VERDACCIO_REGISTRY="http://localhost:$VERDACCIO_PORT"
PACKAGE_NAME="box-ui-elements"
TEST_APP_NAME="test-app"
TEST_APP_PORT=3000

echo "Setting up..."
npm install -g create-next-app --registry https://registry.npmjs.org/
npm install -g verdaccio --registry https://registry.npmjs.org/
verdaccio --version

echo "Starting Verdaccio..."
verdaccio --config ./scripts/app-testing/verdaccio.yaml &
VERDACCIO_PID=$!
echo "Verdaccio is running on PID: $VERDACCIO_PID"

echo "Setting npm registry to Verdaccio..."
echo "registry=$VERDACCIO_REGISTRY" > .npmrc
echo "npm registry is set to: "
npm get registry

echo "registry \"$VERDACCIO_REGISTRY\"" > .yarnrc
echo "yarn registry is set to: "
yarn config get registry

echo "Adding user to Verdaccio..."
expect -c "
spawn npm adduser --registry $VERDACCIO_REGISTRY
expect \"Username:\" { send \"testuser\r\"; exp_continue }
expect \"Password:\" { send \"testpass\r\"; exp_continue }
expect \"Email: \" { send \"[email protected]\r\"; exp_continue }
"
npm whoami --registry $VERDACCIO_REGISTRY

echo "Publishing package to Verdaccio..."
yarn install --force
yarn build:npm
npm publish --registry $VERDACCIO_REGISTRY
mkdir -p ~/test-apps
cd ~/test-apps
pwd

echo "Create test app..."
pwd
create-next-app $TEST_APP_NAME --yes
cd ./$TEST_APP_NAME
pwd
echo "registry=$VERDACCIO_REGISTRY" > .npmrc
echo "registry \"$VERDACCIO_REGISTRY\"" > .yarnrc
yarn add $PACKAGE_NAME

echo "Modify test app..."
pwd
cat > ./src/app/page.js <<EOL
import styles from "./page.module.css";

export default function Home() {
return (
<div className={styles.page}>
<main className={styles.main}>
HELLO WORLD
</main>
</div>
);
}
EOL

echo "Building test app..."
pwd
yarn build

echo "Starting test app..."
pwd
yarn start &
APP_PID=$!

sleep 10

echo "Verifying test app..."
curl --fail http://localhost:$TEST_APP_PORT || (echo "Test app failed to start" && exit 1)

echo "Resetting npm registry..."
npm set registry https://registry.npmjs.org/
yarn config set registry https://registry.yarnpkg.com/

echo "Stopping test app..."
kill $APP_PID

echo "Stopping Verdaccio..."
kill $VERDACCIO_PID

echo "Complete successfully!"
6 changes: 6 additions & 0 deletions scripts/app-testing/clean_app_testing.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

echo "Cleaning up..."
rm -rf ./scripts/app-testing/verdaccio
rm -rf ~/test-apps
npm cache clean --force || true
19 changes: 19 additions & 0 deletions scripts/app-testing/verdaccio.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
storage: ./verdaccio/storage

uplinks:
npmjs:
url: https://registry.npmjs.org/
auth:
htpasswd:
file: ./verdaccio/htpasswd
max_users: 1
packages:
'**':
access: $all
publish: $all
proxy: npmjs
allow_offline_publish: true
log:
- { type: stdout, format: pretty, level: http }

max_body_size: 100mb
Loading