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

Add dev build and development.php file #586

Merged
merged 7 commits into from
Jul 4, 2023
Merged
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
9 changes: 7 additions & 2 deletions .distignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ package.json
package-lock.json
composer.json
composer.lock
assets/js/bundle.js
npm-debug.log
bin
key.enc
Expand All @@ -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
12 changes: 9 additions & 3 deletions .github/workflows/build-dev-artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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')"
Expand Down Expand Up @@ -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
Expand Down
21 changes: 17 additions & 4 deletions bin/dist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 -
6 changes: 6 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
29 changes: 29 additions & 0 deletions development.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php
/**
* Development Helpers.
*
* @package ThemeIsle
*/

if ( ! defined( 'WPINC' ) ) {
die;
}

if ( ! defined( 'ENABLE_OPTIMOLE_WP_DEV' ) ) {
define( 'ENABLE_OPTIMOLE_WP_DEV', true );
}

if ( ENABLE_OPTIMOLE_WP_DEV ) {
$optiml_constants = [
'OPTIML_API_ROOT' => '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 );
}
}
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading