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

Press4 277 #126

Merged
merged 10 commits into from
Sep 7, 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
70 changes: 69 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,72 @@ function EcommercePage(props) {
}
```

[More on NewFold WordPress Modules](https://github.com/newfold-labs/wp-module-loader)
[More on NewFold WordPress Modules](https://github.com/newfold-labs/wp-module-loader)

## Steps to create new release for Ecommerce module

We have switched to GH packages for publishing newer versions of the ecommerce module.

if you're doing something that will not break anything or not adding any new dependency. But, only doing basic stuff like bug fixes, copy changes etc. Change which doesn't really impact the plugin in bigger way you can put them under the last number of versions.

If you're doing something, like adding a new library, or changing something in the way the plugin can use our module then it's better to upgrade the minor version which is the 2nd digit of version.

In rare scenarios, like UI redesign where the change is bigger or a major refactor, we update the 1st digit of version.

#### Changes to Ecommerce Module

1. Merge approved PRs into trunk branch

2. Do version update to new one in package.json

3. Run, npm install (this will auto update version in package-lock.json)

4. Commit above change in separate commit (commit message: Bump to new version value)

5. Go to https://github.com/newfold-labs/wp-module-ecommerce/releases

6. Click on Draft a new release button

7. By default, you'll always create a release from target: trunk branch. In case we are making changes to crazydomains then we must switch to the legacy branch do the fixes there and create a release from target: legacy branch as it currently runs older version

8. Give V dot version that you want to release and click on create a new tag.

9. Click Generate release notes button it will basically collect all the pull requests that came in from the previous release to now and then just create a summary. (It won't track any direct comments to the trunk. It will just only track pull request)

10. Keep Set as the latest release checkbox `checked` as it is by default.

11. Click Publish a release button.

12. Go to https://newfold-labs.github.io/satis/ Satis is a PHP registry for our packages.

13. On above URL in `package` filter, you can search for ecommerce

14. We have set up an integration within our workflow itself so once workflow completes, we trigger alert to Satis that newer version of ecommerce module is released and rebuild Satis so that it can show newer version in packages (Repo: https://github.com/newfold-labs/satis/actions)

15. The newer version will appear in 5 to 10 minutes of rebuilding.

16. We do not have permission to rerun Satis build, so in case it fails PRESS1 team can help.

17. You can check the status of Statis build & Publish workflow here https://github.com/newfold-labs/wp-module-ecommerce/actions

18. On successful completion you can see latest package here https://github.com/newfold-labs/wp-module-ecommerce/pkgs/npm/wp-module-ecommerce

#### Changes to BlueHost plugin repo

1. In composer.json file, update version of newfold-labs/wp-module-ecommerce

2. In package.json file, newfold-labs/wp-module-ecommerce : version number

3. Run command,
```npm i --legacy-peer-deps```

4. Package-lock.json should auto update.

5. Once Satis starts showing updated version run below command for composer update,
```$ composer update newfold-labs/wp-module-ecommerce -W```

6. We need to create a branch (naming convention: dependencies/newfold-labs/wp-module-ecommerce-version_number).

7. Currently we don't have the permission to publish directly to the BlueHost plugin So, we need to create a fork basically of the repo then push it to that fork and then create a pull request against the develop branch.

8. The new release process is thus completed.
2 changes: 2 additions & 0 deletions bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ function () {
'name' => 'ecommerce',
'label' => __( 'eCommerce', 'wp-module-ecommerce' ),
'callback' => function ( Container $container ) {
define( 'NFD_ECOMMERCE_DIR', __DIR__ );
define( 'NFD_ECOMMERCE_BUILD_DIR', __DIR__ . '/build/' );
define( 'NFD_ECOMMERCE_PLUGIN_URL', $container->plugin()->url );
define( 'NFD_ECOMMERCE_PLUGIN_DIRNAME', dirname( $container->plugin()->basename ) );
new ECommerce( $container );
},
'isActive' => true,
Expand Down
2 changes: 1 addition & 1 deletion build/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('lodash', 'moment', 'react', 'wp-api-fetch', 'wp-data', 'wp-date', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => 'a5f290ac68f9d69a100b');
<?php return array('dependencies' => array('lodash', 'moment', 'react', 'wp-api-fetch', 'wp-data', 'wp-date', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => 'd92107dfb0bd29fc36c3');
38 changes: 19 additions & 19 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 20 additions & 1 deletion includes/ECommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use NewfoldLabs\WP\Module\ECommerce\Data\Brands;
use NewfoldLabs\WP\Module\ECommerce\Partials\CaptiveFlow;
use NewfoldLabs\WP\Module\ECommerce\Partials\WooCommerceBacklink;
use NewfoldLabs\WP\Module\ECommerce\I18nService;
use NewfoldLabs\WP\Module\Installer\Services\PluginInstaller;
use NewfoldLabs\WP\ModuleLoader\Container;

Expand Down Expand Up @@ -66,7 +67,8 @@ class ECommerce {
*/
public function __construct( Container $container ) {
$this->container = $container;
// Module functionality goes here
// Module functionality goes here
add_action( 'init', array( $this, 'load_php_textdomain' ) );
add_action( 'admin_init', array( $this, 'maybe_do_dash_redirect' ) );
add_action( 'admin_bar_menu', array( $this, 'newfold_site_status' ), 200 );
add_action( 'rest_api_init', array( $this, 'register_routes' ) );
Expand All @@ -87,6 +89,18 @@ public function __construct( Container $container ) {
add_filter( 'newfold-runtime', array( $this, 'add_to_runtime' ) );
}

/**
* Loads the textdomain for the module. This applies only to PHP strings.
*
* @return boolean
*/
public static function load_php_textdomain() {
return I18nService::load_php_translations(
'wp-module-ecommerce',
NFD_ECOMMERCE_PLUGIN_DIRNAME . '/vendor/newfold-labs/wp-module-ecommerce/languages'
);
}

public function add_to_runtime( $sdk ) {
$values = array(
'brand_settings' => Brands::get_config( $this->container ),
Expand Down Expand Up @@ -191,6 +205,11 @@ public function register_assets() {
array_merge( $asset['dependencies'], array() ),
$asset['version']
);
I18nService::load_js_translations(
'wp-module-ecommerce',
'nfd-ecommerce-dependency',
NFD_ECOMMERCE_DIR . '/languages'
);
\wp_enqueue_script( 'nfd-ecommerce-dependency' );
}
}
Expand Down
44 changes: 44 additions & 0 deletions includes/I18nService.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

namespace NewfoldLabs\WP\Module\ECommerce;

/**
* Class for handling internationalization.
*/
class I18nService {

/**
* Loads the PHP translations from .mo files in the languages dir.
* The .mo file must be named $domain-$locale.mo
*
* @param [string] $domain The text domain.
* @param [string] $languages_dir The directory containing the .mo files.
* @return boolean
*/
public static function load_php_translations( $domain, $languages_dir ) {
return load_plugin_textdomain(
$domain,
false,
$languages_dir
);
}

/**
* Localizes a particular script using a JSON file present in the languages dir.
* The JSON file must be named $domain-$locale-$script_slug.json.
* Note: The script must be registered before this function is called.
*
* @param [string] $domain The text domain.
* @param [string] $script_slug The slug of the registered script.
* @param [string] $languages_dir The directory containing the .json file for the script.
* @return boolean
*/
public static function load_js_translations( $domain, $script_slug, $languages_dir ) {
return wp_set_script_translations(
$script_slug,
$domain,
$languages_dir
);

}
}
Loading