Tuesday, 30 June 2020

Update Drupal 8 using composer

How to Update Drupal 8 Using Composer

Keeping Drupal up to date is essential for security, performance, and compatibility. If you’re using Composer to manage your project (which is the recommended way), here’s a step-by-step guide to safely update Drupal 8.


📝 Step 1: Check Your Current Version

Before updating, it’s a good idea to see which version of Drupal core you’re running and if updates are available.

composer show drupal/core-recommended --check
composer outdated "drupal/*"

💾 Step 2: Take Backups

Always back up your site and database before making updates. You can use Drush for this:

drush sql:dump > /root/drush-backups/site-$(date +%F).sql
drush archive-dump > /root/drush-backups/site-archive-$(date +%F).tar.gz

🛠 Step 3: Enable Maintenance Mode

Put the site into maintenance mode so users don’t run into issues while the update is in progress.

drush state:set system.maintenance_mode 1
drush cache:rebuild

🔄 Step 4: Update Drupal Core

Run the Composer update command for core-recommended (which ensures the correct set of dependencies).

composer update drupal/core-recommended --with-dependencies

Then rebuild the cache:

drush cache:rebuild

✅ Step 5: Disable Maintenance Mode

Once the update is complete, bring your site back online:

drush state:set system.maintenance_mode 0
drush cache:rebuild

🔧 Optional Commands

Depending on your setup, you might also find these useful:

  • Update drupal/core directly (not always recommended):

    composer update drupal/core --with-dependencies
    
  • Update to a specific version:

    composer require 'drupal/core-recommended:^8.9' --update-with-all-dependencies
    
  • Use the development branch (not recommended for production):

    composer require drupal/core-recommended:8.9.x-dev --update-with-all-dependencies
    

That’s it! Your Drupal 8 site should now be running the latest version.


Monday, 15 June 2020

How to build an Android app for production using Native-script?

How to Build an Android App Using NativeScript

If you’re building Android apps with NativeScript, one of the important steps is preparing your app for production. This includes signing the app, generating a release build, and choosing the right file type for distribution.

Here’s a complete guide to help you through the process.


🔑 Step 1: Create a .jks Keystore File

Before you can publish your app, you’ll need a Java Keystore (.jks) file. This file is used to sign your app and is required every time you release an update.

👉 Important:

  • Store your .jks file in a safe location.

  • You must use the same .jks file for every update.

  • If you lose it, you’ll be forced to create a new .jks file and publish your app under a new package name.

📖 Official guide: Android App Signing


📦 Step 2: Build the Release Version

NativeScript gives you three options for building a production-ready Android app.


1) Generate an APK file

This is the traditional Android app package format.

tns build android --release \
--key-store-path [path-to-your.jks] \
--key-store-password [your-key-password] \
--key-store-alias [your-alias] \
--key-store-alias-password [your-alias-password]

The .apk file can then be uploaded directly to the Play Store or shared with users.


2) Generate an AAB file (Recommended)

Google now recommends the Android App Bundle (AAB) format because it reduces app size by delivering only the required resources for each device.

tns run android --release \
--key-store-path [path-to-your.jks] \
--key-store-password [your-key-password] \
--key-store-alias [your-alias] \
--key-store-alias-password [your-alias-password] \
--aab

3) Generate a Customized AAB file

You can optimize your app further with flags like --bundle, --env.uglify, --env.aot, and --env.snapshot. These options reduce size and improve performance.

tns run android --bundle --env.uglify --env.aot --env.snapshot \
--release \
--key-store-path [path-to-your.jks] \
--key-store-password [your-key-password] \
--key-store-alias [your-alias] \
--key-store-alias-password [your-alias-password] \
--aab --copy-to app1.aab

This will create an optimized .aab file named app1.aab.


⚠️ Note on App Size

A blank NativeScript project for Android is typically around 12MB. This is because it includes three versions of the NativeScript runtime to support different Android CPU architectures.

 Final Thoughts 

Always use the same .jks file for updates.

  • Prefer AAB over APK for smaller, more efficient app delivery.

  • Use build optimization flags for production-ready performance.

With these steps, you’re ready to publish your NativeScript Android app to the Play Store! 🎉