diff --git a/.github/workflows/cd.deploy.stg.yml b/.github/workflows/cd.deploy.stg.yml index 343ebd23c..88a614afd 100644 --- a/.github/workflows/cd.deploy.stg.yml +++ b/.github/workflows/cd.deploy.stg.yml @@ -51,7 +51,7 @@ jobs: - name: "Bundle info" shell: bash run: | - yarn generate:bundle-info ${{ github.ref_name }} + yarn generate:bundle-info ${{ github.ref_name }} stage - name: "Build" shell: bash diff --git a/.github/workflows/cd.deploy.yml b/.github/workflows/cd.deploy.yml index 168a09942..59207e46c 100644 --- a/.github/workflows/cd.deploy.yml +++ b/.github/workflows/cd.deploy.yml @@ -58,7 +58,7 @@ jobs: - name: "Bundle info" shell: bash run: | - yarn generate:bundle-info ${{ github.ref_name }} + yarn generate:bundle-info ${{ github.ref_name }} production - name: "Build" shell: bash diff --git a/mobile/babel.config.js b/mobile/babel.config.js index 9e8c9f8fe..af27361c5 100644 --- a/mobile/babel.config.js +++ b/mobile/babel.config.js @@ -2,16 +2,12 @@ const { readFileSync } = require("fs"); const internalIp = require("internal-ip"); const localIP = internalIp.v4.sync(); -let bundleInfo = { version: require("./package.json").version }; +let bundleInfo = { version: require("./package.json").version, environment: "development" }; try { bundleInfo = JSON.parse(readFileSync(".bundle-info.json").toString()); } catch (error) { /**/ } - -bundleInfo.channel = process.env.BUILD_CHANNEL; -if (bundleInfo.channel) throw new Error("BUILD_CHANNEL is not defined"); - module.exports = function (api) { api.cache(true); return { diff --git a/mobile/package.json b/mobile/package.json index c32fb8b60..7642e917f 100644 --- a/mobile/package.json +++ b/mobile/package.json @@ -62,9 +62,9 @@ "build:alone:watch": "tsc --watch --preserveWatchOutput", "build:android": "eas build -p android --no-wait --non-interactive", "build:ios": "eas build -p ios --no-wait --non-interactive", - "build:production": "cross-env BUILD_CHANNEL=production yarn build:ios --profile production && cross-env BUILD_CHANNEL=production yarn build:android --profile production", - "build:stage": "cross-env BUILD_CHANNEL=stage yarn build:ios --profile stage && cross-env BUILD_CHANNEL=stage yarn build:android --profile stage", - "build:watch": "cross-env BUILD_CHANNEL=development lerna run build:alone:watch --scope=@dzcode.io/mobile --include-dependencies --parallel", + "build:production": "yarn build:ios --profile production && yarn build:android --profile production", + "build:stage": "yarn build:ios --profile stage && yarn build:android --profile stage", + "build:watch": "lerna run build:alone:watch --scope=@dzcode.io/mobile --include-dependencies --parallel", "clean": "lerna run clean:alone --scope=@dzcode.io/mobile --include-dependencies --stream", "clean:alone": "rimraf .expo dist", "combine:components": "rnhc combine -c", @@ -93,7 +93,7 @@ "lint:prettier": "prettier --config ../packages/tooling/.prettierrc --ignore-path ../packages/tooling/.prettierignore --loglevel warn", "lint:tsc": "tsc --noEmit", "start:dev": "echo \" \n\\033[0;32mPlease run in a separate terminal session the following command:\n \n\\033[0;32myarn --cwd=mobile start:expo\n \n \"", - "start:expo": "cross-env BUILD_CHANNEL=development expo start --port 1010", + "start:expo": "expo start --port 1010", "test": "yarn build && yarn test:alone", "test:alone": "jest --rootDir .", "test:watch": "npm-run-all build --parallel build:watch \"test:alone --watch {@}\" --" diff --git a/mobile/src/types/__global.d.ts b/mobile/src/types/__global.d.ts index 27a9665ce..39d6ebbb5 100644 --- a/mobile/src/types/__global.d.ts +++ b/mobile/src/types/__global.d.ts @@ -5,7 +5,7 @@ declare global { interface Window { bundleInfo: { version: string; - channel: "production" | "stage" | "development"; + environment: "production" | "stage" | "development"; }; } } diff --git a/mobile/src/utils/env.ts b/mobile/src/utils/env.ts index edbcabab5..540853fdd 100644 --- a/mobile/src/utils/env.ts +++ b/mobile/src/utils/env.ts @@ -1,5 +1,5 @@ export const getEnv = () => { - switch (window.bundleInfo.channel) { + switch (window.bundleInfo.environment) { case "production": return "production"; case "stage": diff --git a/packages/tooling/bundle-info.ts b/packages/tooling/bundle-info.ts index 4052c6d07..3ac901b51 100644 --- a/packages/tooling/bundle-info.ts +++ b/packages/tooling/bundle-info.ts @@ -4,6 +4,10 @@ import { writeFileSync } from "fs"; const version = process.argv[2]; if (!version) throw new Error("Please provide a version"); +// Get the environment passed as argument +const environment = process.argv[3]; +if (!environment) throw new Error("Please provide an environment"); + console.log(`Creating .bundle-info.json ...`); writeFileSync( @@ -11,6 +15,7 @@ writeFileSync( JSON.stringify( { version, + environment, }, null, 2,