milesoft init

Initialize workspace components and bootstrap applications.

milesoft init gcp

Configure and securely bootstrap a Google Cloud Platform (GCP) project for Milesoft application deployments. This command automates all remote workspace-to-cloud infrastructure provisioning securely and idempotently.

Operational Workflow
  • Billing Check: Interrogates GCP via gcloud billing projects describe to ensure the project has an active Google Billing Account linked. Prevents failed configurations due to disabled billing.
  • Project Number Discovery: Programmatically retrieves the unique numerical identifier for the GCP project.
  • Service API Activation: Activates all core Google Cloud Service APIs required for platform runtimes in parallel:
    • run.googleapis.com (Cloud Run)
    • cloudbuild.googleapis.com (Cloud Build)
    • secretmanager.googleapis.com (Secret Manager)
    • storage.googleapis.com (Cloud Storage)
    • firestore.googleapis.com (Cloud Firestore)
  • Cloud Storage Bucket Provisioning: Creates the build-artifact GCS bucket gs://[PROJECT_ID]_cloudbuild with standard multi-regional setups.
  • Auto-Cleanup Lifecycle Configuration: Idempotently configures a 7-day auto-delete object lifecycle policy on the build bucket, keeping storage footprints lightweight.
  • IAM Permission Granting: Safely adds IAM role bindings granting the default Cloud Run service account ([PROJECT_NUMBER]-compute@developer.gserviceaccount.com) the roles/secretmanager.secretAccessor role to read environment secrets securely.
  • Cryptographic Setup: Automatically generates high-entropy 256-bit AES master passwords (encryption_password) and random salt hexadecimal strings (encryption_salt), securely saving them to Secret Manager. Protects existing keys by skipping generation if they already exist.
  • Platform API Key Provisioning: Authenticates against the active accounts gateway client to register and provision a secure administrative platform API key (milesoft_apiKey) inside Secret Manager.
  • Gateway Registration: Registers the GCP project details and linking context idempotently on the Milesoft gateway.
  • Usage: milesoft init gcp --project <project-id> [flags]
  • Flags:
    • -p, --project string (Required): Target GCP Project ID to initialize.
Examples
Initializing a Google Cloud Project Environment
$ milesoft init gcp --project acme-sandbox
Checking if billing is enabled on the project...
Retrieving project number via gcloud...
Found project number: 123456789012
Enabling necessary cloud APIs (run, cloudbuild, secretmanager, storage, firestore)...
Creating storage bucket: gs://acme-sandbox_cloudbuild...
Setting up delete-after-7-days GCS lifecycle policy on the bucket...
Granting Cloud Run default service account (123456789012-compute@developer.gserviceaccount.com) Secret Manager Secret Accessor role...
Checking if Secret Manager secret encryption_password already exists...
Generating secure encryption key...
Creating Secret Manager secret: encryption_password...
Storing encryption_password secret value...
Checking if Secret Manager secret encryption_salt already exists...
Generating secure encryption salt...
Creating Secret Manager secret: encryption_salt...
Storing encryption_salt secret value...
Checking if Secret Manager secret milesoft_apiKey already exists...
Secret milesoft_apiKey does not exist. Generating fresh API key via Milesoft Platform...
Creating Secret Manager secret: milesoft_apiKey...
Storing milesoft_apiKey secret value...
Successfully generated and stored milesoft_apiKey securely in Secret Manager.
Registering project with Milesoft Platform...

=============================================================================
  SUCCESS: GCP Project 'acme-sandbox' has been successfully initialized!
=============================================================================
All required service APIs are enabled.
The Cloud Storage bucket gs://acme-sandbox_cloudbuild has been created with a 7-day lifecycle deletion policy.
Granted Secret Manager Secret Accessor role to the Cloud Run service account: 123456789012-compute@developer.gserviceaccount.com
Generated and stored encryption_password and encryption_salt secrets securely in Secret Manager.
The project is registered and linked to your Milesoft app.

milesoft init app

Initialize and bootstrap a new Spring Boot application based on the active application template configuration.

Operational Overview
  • Active Profile Discovery: Fetches the active application's configuration settings from the Milesoft Platform to determine the target architecture type (MultiTenant, SingleTenant, or MobileOnly). The template scaffolded corresponds to the discovered profile:
Profile Automatic Template Scaffolded Main Controller Generated Primary Frontend Auth Mechanism
MultiTenant MultiTenant Spring Boot + React Web AuthController (extends AbstractMultiTenantAuthController) React Web / Native Web View Username/Password + Switch Accounts
SingleTenant SingleTenant Spring Boot + React Web AuthController (extends AbstractSingleTenantAuthController) React Web / Native Web View Username/Password
MobileOnly MobileOnly Spring Boot + React Native AuthController (extends AbstractMobileOnlyAuthController) React Native (No Web) Device-bound Simple Auth & Link Code
  • Automatic GCP Project & Tenant Resolution: The command automatically queries the active application context on the gateway to resolve the primary registered GCP Project ID.
    • Note: This requires you to have run milesoft init gcp first.
    • If the application is a SingleTenant or MobileOnly deployment, it also automatically resolves the pre-created tenant ID and tenant join code from the platform database to bind your local config files out of the box.
  • Interactive Customization: Prompts the developer interactively for:
    • Company Name: The name of the organization (defaults to a cached value or "My Company").
    • Company Domain: The primary company domain (e.g., mycompany.com), which is reversed and sanitized to generate idiomatic Java package structures (e.g., com.mycompany).
    • Saves these company settings to config.yaml to minimize input on future bootstrapping requests.
  • Template Retrieval & Extraction: Downloads the appropriate template archive (multi-tenant.zip, single-tenant.zip, or mobile-only.zip) from our secure template CDN (with fallback to Google Cloud Storage), extracts the package contents locally, and handles directory-nesting stripping gracefully.
  • Dynamic Package Relocation: Translates the parsed company domain into a reversed DNS folder hierarchy under src/main/java and src/test/java, moving files from com.example.barebones to match the target package namespace.
  • Surgical Refactoring: Walks the newly generated structure and performs precise bulk string replacements across code and configuration files (such as Dockerfile, Gradle build files, and application properties) to replace default variables with customized details (such as copyright year, company name, App ID, pre-bound Tenant ID/Join Code where applicable, and custom URLs).
  • Private test configuration: Generates src/test/http/http-client.private.env.json to securely manage your Personal Access Tokens (PAT) during testing. See the IntelliJ HTTP Client Guide for setup details.
  • Usage: milesoft init app [flags]
Examples
Bootstrapping a MultiTenant Backend Application
$ milesoft init app
Fetching active application settings from Milesoft Platform...
Enter Company Name [My Company]: Acme Corp
Enter Company Domain [mycompany.com]: acme.com

Initializing Project: acme-app
Java Package Namespace: com.acme
GCP Project ID:         acme-sandbox
---------------------------------------------------------
Downloading template...
Customizing Java package directories...
Customizing project files and config configurations...

=========================================================
  SUCCESS: Project 'acme-app' has been initialized!
=========================================================

Next steps to run and deploy your application:
1. Navigate to your project directory:
   cd acme-app

2. Update src/test/http/http-client.env.json with your production environment details.
   After your first deployment, replace the 'TBD' in the baseUrl:
   "baseUrl" : "https://acme-app-TBD.us-central1.run.app"

3. Set your Personal Access Token (PAT) in src/test/http/http-client.private.env.json:
   First, generate a new key nonce (roles can be comma-separated) by running:
     milesoft key create --roles ROLE_OPS,ROLE_GUEST
   Then, use that nonce to call the 'Initialize key' endpoint in src/test/http/requests.http to get your PAT.
   Finally, replace the 'TBD' in your src/test/http/http-client.private.env.json with your new PAT.

Bootstrap completed successfully.

milesoft init web

Initialize and bootstrap a new React application based on the active application template configuration.

Coming soon!

milesoft init mobile

Initialize and bootstrap a new React Native application based on the active application template configuration.

Coming soon!