-
Notifications
You must be signed in to change notification settings - Fork 0
portless worktree and local settings modes #261
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
Open
jasonmorais
wants to merge
14
commits into
main
Choose a base branch
from
jason/portless-worktrees
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
f78c3be
initial commit for verify
jasonmorais 09e9ab0
staging changes for portless modification - using worktree as an env …
jasonmorais b4db123
fixes for e2e tests along with overall pattern cleanup
jasonmorais 2d54c57
overall improvements to workspace files, along with implementation of…
jasonmorais 6c415ea
small fixes for build file issue
jasonmorais 395bfcd
small improvements based on my comments, simplified overcomplicated l…
jasonmorais 628694e
Merge branch 'main' of github.com:CellixJs/cellixjs into jason/portle…
jasonmorais 372b674
Merge remote-tracking branch 'origin/main' into jason/portless-worktrees
jasonmorais 1522602
retrigger build
jasonmorais 843f3d0
sourcery suggestions pt1
jasonmorais c184d92
sourcery suggestions reound 2 - reusability
jasonmorais fabfb36
Update readme.md
jasonmorais 0b76477
undo tsc to tsgo
jasonmorais 110f771
fix serenity pattern - use task pattern instead of interaction
jasonmorais File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,4 +45,3 @@ apps/api/deploy/ | |
|
|
||
| # Build-time evidence artifacts (generated) | ||
| build-artifacts/ | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| { | ||
| "IsEncrypted": false, | ||
| "Values": { | ||
| "FUNCTIONS_WORKER_RUNTIME": "node", | ||
| "NODE_ENV": "development", | ||
| "languageWorkers__node__arguments": "", | ||
| "AZURE_STORAGE_CONNECTION_STRING": "UseDevelopmentStorage=true", | ||
| "AzureWebJobsStorage": "UseDevelopmentStorage=true", | ||
| "ACCOUNT_PORTAL_OIDC_AUDIENCE": "mock-client", | ||
| "ACCOUNT_PORTAL_OIDC_ENDPOINT": "https://mock-auth.ownercommunity.localhost:1355/community/.well-known/jwks.json", | ||
| "ACCOUNT_PORTAL_OIDC_ISSUER": "https://mock-auth.ownercommunity.localhost:1355/community", | ||
| "ACCOUNT_PORTAL_OIDC_IGNORE_ISSUER": true, | ||
| "APPLICATIONINSIGHTS_CONNECTION_STRING": "", | ||
| "CONFIG_VERSION": "3.0", | ||
| "COSMOSDB_CONNECTION_STRING": "mongodb://127.0.0.1:50000/owner-community?replicaSet=globaldb", | ||
| "COSMOSDB_DBNAME": "owner-community", | ||
| "STAFF_PORTAL_OIDC_AUDIENCE": "mock-client", | ||
| "STAFF_PORTAL_OIDC_ENDPOINT": "https://mock-auth.ownercommunity.localhost:1355/staff/.well-known/jwks.json", | ||
| "STAFF_PORTAL_OIDC_ISSUER": "https://mock-auth.ownercommunity.localhost:1355/staff", | ||
| "STAFF_PORTAL_OIDC_IGNORE_ISSUER": true, | ||
| "STORAGE_ACCOUNT_NAME": "devstoreaccount1", | ||
| "STORAGE_ACCOUNT_KEY": "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==" | ||
| }, | ||
| "ConnectionStrings": {}, | ||
| "Host": { | ||
| "LocalHttpPort": 7071, | ||
| "CORS": "*" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| import { copyFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'; | ||
| import path from 'node:path'; | ||
| import { fileURLToPath } from 'node:url'; | ||
| import { buildPortlessUrl, getHostnames } from '../../../scripts/local-dev/portless-hostnames.mjs'; | ||
| import { getAzuriteConnectionString } from '../../../scripts/local-dev/worktree-ports.mjs'; | ||
|
|
||
| const apiDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..'); | ||
| const mode = process.argv[2] ?? (isE2E() ? 'e2e' : undefined); | ||
| const localSettingsPath = path.join(apiDir, 'local.settings.json'); | ||
| const e2eLocalSettingsPath = path.join(apiDir, 'local-settings.e2e.json'); | ||
| const targetPath = path.join(apiDir, 'deploy', 'local.settings.json'); | ||
|
|
||
| mkdirSync(path.dirname(targetPath), { recursive: true }); | ||
|
|
||
| if (!mode) { | ||
| if (existsSync(localSettingsPath)) { | ||
| copyFileSync(localSettingsPath, targetPath); | ||
| } | ||
| process.exit(0); | ||
| } | ||
|
|
||
| if (mode !== 'e2e') { | ||
| throw new Error('[sync-local-settings] Invalid mode: expected one of e2e'); | ||
| } | ||
|
|
||
| if (!existsSync(e2eLocalSettingsPath)) { | ||
| throw new Error(`[sync-local-settings] Missing local settings for mode "e2e": ${e2eLocalSettingsPath}`); | ||
| } | ||
|
|
||
| const settings = JSON.parse(readFileSync(e2eLocalSettingsPath, 'utf-8')); | ||
| applyE2EOverrides(settings); | ||
| writeFileSync(targetPath, `${JSON.stringify(settings, null, '\t')}\n`); | ||
|
|
||
| function applyE2EOverrides(settings) { | ||
| const values = { ...(settings.Values ?? {}) }; | ||
|
|
||
| // Worktree-scoped overrides: when WORKTREE_NAME is set the proxy hostnames | ||
| // and Azurite ports are scoped to that worktree, so we rewrite the URLs and | ||
| // connection strings here. Without WORKTREE_NAME the committed JSON values | ||
| // already match the default hostnames, so we leave them alone. | ||
| if (process.env.WORKTREE_NAME) { | ||
| const hostnames = getHostnames(); | ||
| values.ACCOUNT_PORTAL_OIDC_ISSUER = buildPortlessUrl(hostnames.mockAuth, '/community'); | ||
| values.ACCOUNT_PORTAL_OIDC_ENDPOINT = buildPortlessUrl(hostnames.mockAuth, '/community/.well-known/jwks.json'); | ||
| values.STAFF_PORTAL_OIDC_ISSUER = buildPortlessUrl(hostnames.mockAuth, '/staff'); | ||
| values.STAFF_PORTAL_OIDC_ENDPOINT = buildPortlessUrl(hostnames.mockAuth, '/staff/.well-known/jwks.json'); | ||
| const azurite = getAzuriteConnectionString(values); | ||
| values.AZURE_STORAGE_CONNECTION_STRING = azurite; | ||
| values.AzureWebJobsStorage = azurite; | ||
| } | ||
|
|
||
| // Runtime-only injection: the e2e harness spawns MongoMemoryServer on a | ||
| // random port and passes the connection string through process.env. | ||
| if (process.env.COSMOSDB_CONNECTION_STRING) { | ||
| values.COSMOSDB_CONNECTION_STRING = process.env.COSMOSDB_CONNECTION_STRING; | ||
| } | ||
|
|
||
| settings.Values = values; | ||
| } | ||
|
|
||
| function isE2E() { | ||
| return ['1', 'true', 'yes'].includes((process.env.E2E ?? '').toLowerCase()); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| import { spawn } from 'node:child_process'; | ||
| import { isGracefulInterruptExit } from '../../scripts/local-dev/dev-process-exit.mjs'; | ||
| import { getAzuritePorts } from '../../scripts/local-dev/worktree-ports.mjs'; | ||
|
|
||
| const ports = getAzuritePorts(); | ||
| const worktreeName = process.env.WORKTREE_NAME ?? ''; | ||
| const storageSuffix = worktreeName ? `-${worktreeName}` : ''; | ||
|
|
||
| const blobDir = `../../__blobstorage__${storageSuffix}`; | ||
| const queueDir = `../../__queuestorage__${storageSuffix}`; | ||
| const tableDir = `../../__tablestorage__${storageSuffix}`; | ||
|
|
||
| const procSpecs = [ | ||
| ['azurite-blob', ['--silent', '--blobPort', String(ports.blob), '--location', blobDir]], | ||
| ['azurite-queue', ['--silent', '--queuePort', String(ports.queue), '--location', queueDir]], | ||
| ['azurite-table', ['--silent', '--tablePort', String(ports.table), '--location', tableDir]], | ||
| ]; | ||
| const procs = procSpecs.map(([command, args]) => { | ||
| const proc = spawn(command, args, { stdio: 'inherit' }); | ||
| proc.on('error', (error) => { | ||
| console.error(`[azurite] failed to start ${command}: ${error.message}`); | ||
| for (const p of procs) p.kill(); | ||
| process.exit(1); | ||
| }); | ||
| return proc; | ||
| }); | ||
|
|
||
| console.log(`[azurite] started (blob=${ports.blob}, queue=${ports.queue}, table=${ports.table})`); | ||
|
|
||
| let exited = 0; | ||
| for (const proc of procs) { | ||
| proc.on('exit', (code, signal) => { | ||
| if (isGracefulInterruptExit(signal, code)) { | ||
| if (++exited === procs.length) process.exit(0); | ||
| return; | ||
| } | ||
| console.error(`[azurite] process exited unexpectedly: code=${code} signal=${signal}`); | ||
| for (const p of procs) p.kill(); | ||
| process.exit(code ?? 1); | ||
| }); | ||
| } | ||
| process.on('SIGINT', () => { | ||
| for (const p of procs) p.kill('SIGINT'); | ||
| }); | ||
| process.on('SIGTERM', () => { | ||
| for (const p of procs) p.kill('SIGTERM'); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,10 @@ | ||
| import { spawn } from 'node:child_process'; | ||
| import { isGracefulInterruptExit } from '../../build-pipeline/scripts/dev-process-exit.mjs'; | ||
| import { forwardChildExit } from '../../scripts/local-dev/dev-process-exit.mjs'; | ||
|
|
||
| const port = process.env.PORT ?? '3001'; | ||
|
|
||
| const child = spawn('docusaurus', ['start', '--port', port, '--host', '127.0.0.1', '--no-open'], { | ||
| stdio: 'inherit', | ||
| }); | ||
|
|
||
| child.on('exit', (code, signal) => { | ||
| // Turbo sends signals to interrupt persistent tasks; treat those as graceful exits. | ||
| if (isGracefulInterruptExit(signal, code)) { | ||
| process.exitCode = 0; | ||
| return; | ||
| } | ||
| process.exitCode = code ?? 1; | ||
| }); | ||
| forwardChildExit(child); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import { spawn } from 'node:child_process'; | ||
| import { forwardChildExit } from '../../scripts/local-dev/dev-process-exit.mjs'; | ||
| import { getMongoPort } from '../../scripts/local-dev/worktree-ports.mjs'; | ||
|
|
||
| const MONGO_PORT = getMongoPort(); | ||
|
|
||
| const child = spawn('tsx', ['src/index.ts'], { | ||
| stdio: 'inherit', | ||
| env: { ...process.env, PORT: String(MONGO_PORT) }, | ||
| }); | ||
|
|
||
| forwardChildExit(child); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import { spawn } from 'node:child_process'; | ||
| import { forwardChildExit } from '../../scripts/local-dev/dev-process-exit.mjs'; | ||
| import { buildPortlessUrl, getHostnames } from '../../scripts/local-dev/portless-hostnames.mjs'; | ||
|
|
||
| const childEnv = { ...process.env }; | ||
|
|
||
| if (process.env.WORKTREE_NAME) { | ||
| const hostnames = getHostnames(); | ||
| childEnv.BASE_URL = buildPortlessUrl(hostnames.mockAuth); | ||
| // Override redirect URIs so portal-discovery picks up worktree-scoped URLs. | ||
| childEnv.VITE_APP_UI_COMMUNITY_B2C_REDIRECT_URI = buildPortlessUrl(hostnames.uiCommunity, '/auth-redirect'); | ||
| childEnv.VITE_APP_UI_STAFF_AAD_REDIRECT_URI = buildPortlessUrl(hostnames.uiStaff, '/auth-redirect'); | ||
| } | ||
|
|
||
| const child = spawn('tsx', ['src/index.ts'], { | ||
| stdio: 'inherit', | ||
| env: childEnv, | ||
| }); | ||
|
|
||
| forwardChildExit(child); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.