From 46b8a7b5962a4a919e7a875159db61c247ef4e9a Mon Sep 17 00:00:00 2001 From: Hardeep Asrani Date: Mon, 3 Jul 2023 19:00:35 +0530 Subject: [PATCH 1/7] Add dev build and development.php file --- .distignore | 6 +++++ .github/workflows/build-dev-artifacts.yml | 9 ++++--- bin/dist.sh | 13 ++++++++-- composer.json | 6 +++++ development.php | 29 +++++++++++++++++++++++ 5 files changed, 58 insertions(+), 5 deletions(-) create mode 100644 development.php diff --git a/.distignore b/.distignore index 16e1a443..d67785de 100644 --- a/.distignore +++ b/.distignore @@ -37,3 +37,9 @@ assets/vue .wporg .nvmrc .github +cypress.config.js +.eslintrc +postcss.config.js +tailwind.config.js +phpstan.neon +development.php diff --git a/.github/workflows/build-dev-artifacts.yml b/.github/workflows/build-dev-artifacts.yml index e77056ce..b1a3c37c 100644 --- a/.github/workflows/build-dev-artifacts.yml +++ b/.github/workflows/build-dev-artifacts.yml @@ -42,8 +42,10 @@ jobs: - name: Make build run: | npm run build - - name: Create zip - run: yarn run dist + - name: Create zip + run: yarn run dist + - name: Create dev zip + run: yarn run dist -- --dev - name: Retrieve branch name id: retrieve-branch-name run: echo "::set-output name=branch_name::$(REF=${GITHUB_HEAD_REF:-$GITHUB_REF} && echo ${REF#refs/heads/} | sed 's/\//-/g')" @@ -90,7 +92,8 @@ jobs: id: get-comment-body run: | body="Plugin build for ${{ github.event.pull_request.head.sha }} is ready :bellhop_bell:! - - Download [build](https://verti-artifacts.s3.amazonaws.com/${{ github.event.pull_request.base.repo.name }}-${{ needs.dev-zip.outputs.branch-name }}-${{ needs.dev-zip.outputs.git-sha-8 }}/optimole-wp.zip)" + - Download [build](https://verti-artifacts.s3.amazonaws.com/${{ github.event.pull_request.base.repo.name }}-${{ needs.dev-zip.outputs.branch-name }}-${{ needs.dev-zip.outputs.git-sha-8 }}/optimole-wp.zip) + - Download [dev](https://verti-artifacts.s3.amazonaws.com/${{ github.event.pull_request.base.repo.name }}-${{ needs.dev-zip.outputs.branch-name }}-${{ needs.dev-zip.outputs.git-sha-8 }}/optimole-wp-dev.zip)" body="${body//$'\n'/'%0A'}" echo "::set-output name=body::$body" - name: Create comment on PR with links to plugin builds diff --git a/bin/dist.sh b/bin/dist.sh index 45bcf99e..9a6e1bb7 100755 --- a/bin/dist.sh +++ b/bin/dist.sh @@ -13,8 +13,17 @@ if [ ! -d "artifact" ]; then mkdir "artifact" fi -rsync -rc --exclude-from ".distignore" "./" "dist/$BUILD_NAME" +if [ "$1" = "--dev" ]; then + DIST_FOLDER="$BUILD_NAME-dev" + cp -f "development.php" "dist/$DIST_FOLDER" +else + DIST_FOLDER=$BUILD_NAME +fi + +rsync -rc --exclude-from ".distignore" "./" "dist/$DIST_FOLDER" cd dist -zip -r "../artifact/$BUILD_NAME" "./$BUILD_NAME/" +zip -r "../artifact/$DIST_FOLDER" "./$DIST_FOLDER/" + +echo "BUILD GENERATED: $DIST_FOLDER" cd - diff --git a/composer.json b/composer.json index 235b28e5..ee7b5420 100644 --- a/composer.json +++ b/composer.json @@ -20,6 +20,12 @@ "vendor/codeinwp/themeisle-sdk/load.php" ] }, + "autoload-dev": { + "files": [ + "vendor/codeinwp/themeisle-sdk/load.php", + "development.php" + ] + }, "config": { "optimize-autoloader": true, "platform": { diff --git a/development.php b/development.php new file mode 100644 index 00000000..e529d4b8 --- /dev/null +++ b/development.php @@ -0,0 +1,29 @@ + 'https://staging-dashboard.optimole.com/api/', + 'OPTIML_UPLOAD_API_ROOT' => 'https://generateurls-dev.b.optml.cloud/upload', + 'OPTIML_ONBOARD_API_ROOT' => 'https://onboard.b.optml.cloud/onboard_api/', + 'OPTML_BASE_DOMAIN' => 'b.optml.cloud', + ]; + + foreach ( $optiml_constants as $key => $value ) { + if ( ! defined( $key ) ) { + define( $key, $value ); + } + } +} From 4717a117ed81d32eb500fe8e007ff9078930afc7 Mon Sep 17 00:00:00 2001 From: Hardeep Asrani Date: Mon, 3 Jul 2023 19:06:07 +0530 Subject: [PATCH 2/7] fix spacing issues --- .github/workflows/build-dev-artifacts.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-dev-artifacts.yml b/.github/workflows/build-dev-artifacts.yml index b1a3c37c..da5a7ad3 100644 --- a/.github/workflows/build-dev-artifacts.yml +++ b/.github/workflows/build-dev-artifacts.yml @@ -42,8 +42,8 @@ jobs: - name: Make build run: | npm run build - - name: Create zip - run: yarn run dist + - name: Create zip + run: yarn run dist - name: Create dev zip run: yarn run dist -- --dev - name: Retrieve branch name From 11f0b4fd4470652c6b0bc1ab30c601afc6fbf743 Mon Sep 17 00:00:00 2001 From: Hardeep Asrani Date: Mon, 3 Jul 2023 19:11:35 +0530 Subject: [PATCH 3/7] fix gh workflow --- bin/dist.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/dist.sh b/bin/dist.sh index 9a6e1bb7..999a3c00 100755 --- a/bin/dist.sh +++ b/bin/dist.sh @@ -15,13 +15,16 @@ fi if [ "$1" = "--dev" ]; then DIST_FOLDER="$BUILD_NAME-dev" - cp -f "development.php" "dist/$DIST_FOLDER" else DIST_FOLDER=$BUILD_NAME fi rsync -rc --exclude-from ".distignore" "./" "dist/$DIST_FOLDER" +if [ "$1" = "--dev" ]; then + cp -f "development.php" "dist/$DIST_FOLDER" +fi + cd dist zip -r "../artifact/$DIST_FOLDER" "./$DIST_FOLDER/" From 9d129fa8b2a55cf1dac953da2c1fd41a15d0e5b3 Mon Sep 17 00:00:00 2001 From: Hardeep Asrani Date: Mon, 3 Jul 2023 19:21:35 +0530 Subject: [PATCH 4/7] Add dev js build --- .github/workflows/build-dev-artifacts.yml | 9 ++++++--- package.json | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-dev-artifacts.yml b/.github/workflows/build-dev-artifacts.yml index da5a7ad3..4b35f796 100644 --- a/.github/workflows/build-dev-artifacts.yml +++ b/.github/workflows/build-dev-artifacts.yml @@ -40,12 +40,15 @@ jobs: npm ci composer install --no-dev --prefer-dist --no-progress --no-suggest - name: Make build - run: | - npm run build + run: yarn run build - name: Create zip run: yarn run dist + - name: Remove build folder + run: rm -rf assets/build + - name: Make build + run: yarn run build-dev - name: Create dev zip - run: yarn run dist -- --dev + run: yarn run dist --dev - name: Retrieve branch name id: retrieve-branch-name run: echo "::set-output name=branch_name::$(REF=${GITHUB_HEAD_REF:-$GITHUB_REF} && echo ${REF#refs/heads/} | sed 's/\//-/g')" diff --git a/package.json b/package.json index 2f156d3e..bee70b8a 100755 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "scripts": { "build": "wp-scripts build assets/src/index.js --output-path=assets/build", "dev": "wp-scripts start assets/src/index.js --output-path=assets/build", + "build-dev": "NODE_ENV=development wp-scripts build assets/src/index.js --output-path=assets/build", "lint": "wp-scripts lint-js assets/src", "format": "wp-scripts lint-js assets/src --fix", "release": "semantic-release --debug", From f17608e333394515776f301b3cee3a3e4b81bbf2 Mon Sep 17 00:00:00 2001 From: Hardeep Asrani Date: Mon, 3 Jul 2023 19:26:56 +0530 Subject: [PATCH 5/7] exclude react src code from build --- .distignore | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.distignore b/.distignore index d67785de..99ffad21 100644 --- a/.distignore +++ b/.distignore @@ -21,7 +21,6 @@ package.json package-lock.json composer.json composer.lock -assets/js/bundle.js npm-debug.log bin key.enc @@ -33,7 +32,7 @@ grunt tests dist artifact -assets/vue +assets/src .wporg .nvmrc .github From 440aedfa296eda46178b85dd7a34634c9846f79f Mon Sep 17 00:00:00 2001 From: Hardeep Asrani Date: Mon, 3 Jul 2023 20:17:04 +0530 Subject: [PATCH 6/7] include development.php file in dev build --- bin/dist.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/dist.sh b/bin/dist.sh index 999a3c00..17cdaab1 100755 --- a/bin/dist.sh +++ b/bin/dist.sh @@ -23,6 +23,7 @@ rsync -rc --exclude-from ".distignore" "./" "dist/$DIST_FOLDER" if [ "$1" = "--dev" ]; then cp -f "development.php" "dist/$DIST_FOLDER" + echo "require_once OPTML_PATH . '/development.php';" >> "dist/$DIST_FOLDER/optimole-wp.php" fi cd dist From 2bb39ddd2347d6c45596585451d21dd46aa0fa1a Mon Sep 17 00:00:00 2001 From: Hardeep Asrani Date: Mon, 3 Jul 2023 20:18:08 +0530 Subject: [PATCH 7/7] chore: fix spaces/tabs inconsistency --- bin/dist.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/dist.sh b/bin/dist.sh index 17cdaab1..fe7dd8c4 100755 --- a/bin/dist.sh +++ b/bin/dist.sh @@ -6,24 +6,24 @@ BUILD_NAME=$(node -pe "require('./package.json').name") export BUILD_NAME if [ ! -d "dist" ]; then - mkdir "dist" + mkdir "dist" fi if [ ! -d "artifact" ]; then - mkdir "artifact" + mkdir "artifact" fi if [ "$1" = "--dev" ]; then - DIST_FOLDER="$BUILD_NAME-dev" + DIST_FOLDER="$BUILD_NAME-dev" else - DIST_FOLDER=$BUILD_NAME + DIST_FOLDER=$BUILD_NAME fi rsync -rc --exclude-from ".distignore" "./" "dist/$DIST_FOLDER" if [ "$1" = "--dev" ]; then cp -f "development.php" "dist/$DIST_FOLDER" - echo "require_once OPTML_PATH . '/development.php';" >> "dist/$DIST_FOLDER/optimole-wp.php" + echo "require_once OPTML_PATH . '/development.php';" >> "dist/$DIST_FOLDER/optimole-wp.php" fi cd dist