Skip to content
This repository has been archived by the owner on Sep 26, 2024. It is now read-only.

Make Builds Environment-Aware #169

Merged
merged 3 commits into from
Sep 4, 2024
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
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,13 @@ jobs:
- name: Install dependencies
run: pnpm install --no-frozen-lockfile

# Set EXTENSION_ENV variable to the current branch name
- name: Set EXTENSION_ENV variable
run: echo "EXTENSION_ENV=${GITHUB_REF##refs/heads/}" | sed 's/\//-/g' >> $GITHUB_ENV
- name: Build artifacts
run: pnpm build
env:
EXTENSION_ENV: ${{ env.EXTENSION_ENV }}

- name: Upload extension artifacts
uses: actions/upload-artifact@v4
Expand Down
2 changes: 1 addition & 1 deletion apps/mocksi-lite-next/manifest.dev.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"externally_connectable": {
"matches": ["http://localhost:3030/*"]
},
"name": "Mocksi Lite: Next (DEV)",
"name": "[Develpment] Mocksi Lite",
"options_ui": {
"page": "src/pages/options/index.html"
}
Expand Down
7 changes: 3 additions & 4 deletions apps/mocksi-lite-next/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,17 @@
}
],
"content_security_policy": {
"extension_pages": "object-src 'none'; child-src https://nest-auth-ts-merge.onrender.com; frame-src https://nest-auth-ts-merge.onrender.com; script-src 'self'"
"extension_pages": "object-src 'none'; child-src https://app.mocksi.ai; frame-src https://app.mocksi.ai; script-src 'self'"
},
"description": "https://www.mocksi.ai",
"externally_connectable": {
"matches": ["https://nest-auth-ts-merge.onrender.com/*"]
"matches": ["https://app.mocksi.com/*"]
},
"icons": {
"128": "mocksi-logo.png"
},
"key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtdeTUTUuHZx1xSvDuISF7wJP8nEPwW4vP8zTkdfdtb/1wM0JJ7XFeUHSIiq8l4Cs6/2f8tpK6MspeD7WhwuFWFHA2GWKoLSP0keuuBAhUFKrfISlNwFaNLX5LRkLSZQnr0ujIznvEuRZaXydIYR1e9pdhYTIcp2ToHW4CI02FUBtJVUUVeKGDiKKlKUrxwGtt1ecGZwVrQ1t7dj3DLrKguw1bONtoczFT3cCs9oVYg4l8frzlyI6xfsX8ynd4F+xS6+gYQ3aJBj7phAWHGAxbVRxTAzpzXRkb9A3ne31Ysjy4uYF9x7fK6NvDj/cm+EEfGDb3VmyXvOa3zeerXtdmwIDAQAB",
"manifest_version": 3,
"name": "Mocksi Lite: Next",
"name": "Mocksi Lite",
"permissions": [
"activeTab",
"background",
Expand Down
48 changes: 48 additions & 0 deletions apps/mocksi-lite-next/manifest.staging.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"action": {
"default_icon": {
"32": "mocksi-icon.png"
}
},
"background": {
"service_worker": "src/pages/background/index.ts",
"type": "module"
},
"content_scripts": [
{
"js": ["src/pages/content/mocksi-extension.tsx"],
"matches": ["http://*/*", "https://*/*", "<all_urls>"]
}
],
"content_security_policy": {
"extension_pages": "object-src 'none'; child-src https://nest-auth-ts-merge.onrender.com; frame-src https://nest-auth-ts-merge.onrender.com; script-src 'self'"
},
"description": "https://www.mocksi.ai",
"externally_connectable": {
"matches": ["https://nest-auth-ts-merge.onrender.com/*"]
},
"icons": {
"128": "mocksi-logo.png"
},
"key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtdeTUTUuHZx1xSvDuISF7wJP8nEPwW4vP8zTkdfdtb/1wM0JJ7XFeUHSIiq8l4Cs6/2f8tpK6MspeD7WhwuFWFHA2GWKoLSP0keuuBAhUFKrfISlNwFaNLX5LRkLSZQnr0ujIznvEuRZaXydIYR1e9pdhYTIcp2ToHW4CI02FUBtJVUUVeKGDiKKlKUrxwGtt1ecGZwVrQ1t7dj3DLrKguw1bONtoczFT3cCs9oVYg4l8frzlyI6xfsX8ynd4F+xS6+gYQ3aJBj7phAWHGAxbVRxTAzpzXRkb9A3ne31Ysjy4uYF9x7fK6NvDj/cm+EEfGDb3VmyXvOa3zeerXtdmwIDAQAB",
"manifest_version": 3,
"name": "[Staging] Mocksi Lite: Next",
"permissions": [
"activeTab",
"background",
"cookies",
"downloads",
"debugger",
"scripting",
"storage",
"tabs",
"webNavigation",
"webRequest"
],
"web_accessible_resources": [
{
"matches": [],
"resources": ["mocksi-icon.png", "mocksi-logo.png"]
}
]
}
21 changes: 18 additions & 3 deletions apps/mocksi-lite-next/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { resolve } from "path";
import { defineConfig } from "vite";

import devManifest from "./manifest.dev.json";
import stagingManifest from "./manifest.staging.json";
import manifest from "./manifest.json";
import pkg from "./package.json";

Expand All @@ -15,10 +16,24 @@ const publicDir = resolve(__dirname, "public");

const isDev = process.env.__DEV__ === "true";

const extensionENV = process.env.EXTENSION_ENV || "development";
let activeManifest;

switch (extensionENV) {
case "staging":
activeManifest = Object.assign(manifest, stagingManifest);
break;
case "production":
activeManifest = manifest;
break;
default:
activeManifest = Object.assign(manifest, devManifest);
break;
}

const extensionManifest = {
...manifest,
...(isDev ? devManifest : ({} as ManifestV3Export)),
name: isDev ? `DEV: ${manifest.name}` : manifest.name,
...activeManifest,
name: activeManifest.name,
version: pkg.version,
};

Expand Down
Loading