diff --git a/.distignore b/.distignore index 16e1a443..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,13 @@ grunt tests dist artifact -assets/vue +assets/src .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..4b35f796 100644 --- a/.github/workflows/build-dev-artifacts.yml +++ b/.github/workflows/build-dev-artifacts.yml @@ -40,10 +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 - 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 +95,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..fe7dd8c4 100755 --- a/bin/dist.sh +++ b/bin/dist.sh @@ -6,15 +6,28 @@ 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 -rsync -rc --exclude-from ".distignore" "./" "dist/$BUILD_NAME" +if [ "$1" = "--dev" ]; then + DIST_FOLDER="$BUILD_NAME-dev" +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" + echo "require_once OPTML_PATH . '/development.php';" >> "dist/$DIST_FOLDER/optimole-wp.php" +fi 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 ); + } + } +} 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",