Skip to content

Commit

Permalink
add env var for enabling dark mode
Browse files Browse the repository at this point in the history
  • Loading branch information
seungpark committed May 23, 2024
1 parent 5688828 commit a40cab0
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 3 deletions.
2 changes: 2 additions & 0 deletions cdk-infra/lib/constructs/worker/worker-env-construct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export class WorkerEnvConstruct extends Construct {
const docsetsCollection = StringParameter.valueFromLookup(this, `${ssmPrefix}/atlas/collections/docsets`);
const jobCollection = StringParameter.valueFromLookup(this, `${ssmPrefix}/atlas/collections/job/queue`);
const gatsbyMarianUrl = StringParameter.valueFromLookup(this, `${ssmPrefix}/frontend/marian_url`);
const gatsbyEnableDarkMode = StringParameter.valueFromLookup(this, `${ssmPrefix}/frontend/enable_dark_mode`);

const dbPassword = secureStrings['MONGO_ATLAS_PASSWORD'];
this.environment = {
Expand Down Expand Up @@ -101,6 +102,7 @@ export class WorkerEnvConstruct extends Construct {
GATSBY_HIDE_UNIFIED_FOOTER_LOCALE: gatsbyHideUnifiedFooterLocale,
GATSBY_MARIAN_URL: gatsbyMarianUrl,
IS_FEATURE_BRANCH: getIsFeatureBranch(),
GATSBY_ENABLE_DARK_MODE: gatsbyEnableDarkMode,
};
}
}
3 changes: 2 additions & 1 deletion config/custom-environment-variables.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@
"cdnClientID": "CDN_CLIENT_ID",
"cdnClientSecret": "CDN_CLIENT_SECRET",
"cdnInvalidatorServiceURL": "CDN_INVALIDATOR_SERVICE_URL",
"searchIndexBucket": "SEARCH_INDEX_BUCKET"
"searchIndexBucket": "SEARCH_INDEX_BUCKET",
"gatsbyEnableDarkMode": "GATSBY_ENABLE_DARK_MODE"
}
2 changes: 2 additions & 0 deletions infrastructure/ecs-main/ecs_service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ Resources:
Value: ${self:custom.featureFlagSearchUI}
- Name: GATSBY_MARIAN_URL
Value: ${self:custom.gatsbyMarianURL}
- Name: GATSBY_ENABLE_DARK_MODE
Value: ${self:custom.gatsbyEnableDarkMode}
- Name: GATSBY_HIDE_UNIFIED_FOOTER_LOCALE
Value: ${self:custom.gatsbyHideUnifiedFooterLocale}
- Name: FASTLY_MAIN_TOKEN
Expand Down
3 changes: 2 additions & 1 deletion src/commands/src/helpers/dependency-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ async function createEnvProdFile({
GATSBY_MARIAN_URL=${process.env.GATSBY_MARIAN_URL}
PATH_PREFIX=${prefix}
${patchId ? `PATCH_ID=${patchId}` : ''}
${commitHash ? `COMMIT_HASH=${commitHash}` : ''}`,
${commitHash ? `COMMIT_HASH=${commitHash}` : ''}
GATSBY_ENABLE_DARK_MODE=${process.env.GATSBY_ENABLE_DARK_MODE}`,
'utf8'
);
} catch (e) {
Expand Down
1 change: 1 addition & 0 deletions src/job/jobHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ export abstract class JobHandler {
GATSBY_TEST_SEARCH_UI: this._config.get<string>('featureFlagSearchUI'),
GATSBY_HIDE_UNIFIED_FOOTER_LOCALE: this._config.get<string>('gatsbyHideUnifiedFooterLocale'),
GATSBY_MARIAN_URL: this._config.get<string>('gatsbyMarianURL'),
GATSBY_ENABLE_DARK_MODE: this._config.get<string>('gatsbyEnableDarkMode'),
};

for (const [envName, envValue] of Object.entries(snootyFrontEndVars)) {
Expand Down
2 changes: 1 addition & 1 deletion tests/data/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ export class TestDataProvider {
}

static getEnvVarsWithPathPrefixWithFlags(job: Job): string {
return `GATSBY_PARSER_USER=TestUser\nGATSBY_PARSER_BRANCH=${job.payload.branchName}\nPATH_PREFIX=${job.payload.pathPrefix}\nGATSBY_BASE_URL=test\nPREVIEW_BUILD_ENABLED=false\nGATSBY_TEST_SEARCH_UI=false\nGATSBY_HIDE_UNIFIED_FOOTER_LOCALE=true\nGATSBY_MARIAN_URL=test-url\n`;
return `GATSBY_PARSER_USER=TestUser\nGATSBY_PARSER_BRANCH=${job.payload.branchName}\nPATH_PREFIX=${job.payload.pathPrefix}\nGATSBY_BASE_URL=test\nPREVIEW_BUILD_ENABLED=false\nGATSBY_TEST_SEARCH_UI=false\nGATSBY_HIDE_UNIFIED_FOOTER_LOCALE=true\nGATSBY_MARIAN_URL=test-url\nGATSBY_ENABLE_DARK_MODE=true\n`;
}

static getPathPrefixCases(): Array<any> {
Expand Down
1 change: 1 addition & 0 deletions tests/utils/jobHandlerTestHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ export class JobHandlerTestHelper {
.calledWith(`repos/${this.job.payload.repoName}/worker.sh`)
.mockReturnValue(nextGenEntry);
this.config.get.calledWith('GATSBY_PARSER_USER').mockReturnValue('TestUser');
this.config.get.calledWith('gatsbyEnableDarkMode').mockReturnValue('true');
this.jobCommandExecutor.execute.mockResolvedValue({ status: 'success', output: 'Great work', error: null });
}
}

0 comments on commit a40cab0

Please sign in to comment.