Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 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
46 changes: 46 additions & 0 deletions .github/workflows/update-cta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Update greeting CTA
on:
push:
branches:
- main
paths:
- config/cta.conf.js
workflow_dispatch:
inputs:
dry-run:
description: Run the script without updating the CTA
type: boolean
required: false
default: false
environment:
description: The environment to run the script in - must have the DOWNLOAD_CENTER_AWS_KEY and DOWNLOAD_CENTER_AWS_SECRET secrets configured
type: environment
required: true
default: CTA-Production

jobs:
dry-run:
name: Update greeting CTA
runs-on: ubuntu-latest
environment: ${{ github.event.inputs.environment || 'CTA-Production'}}
env:
npm_config_loglevel: verbose
npm_config_foreground_scripts: "true"
PUPPETEER_SKIP_DOWNLOAD: "true"
DOWNLOAD_CENTER_AWS_KEY: ${{ secrets.DOWNLOAD_CENTER_AWS_KEY }}
DOWNLOAD_CENTER_AWS_SECRET: ${{ secrets.DOWNLOAD_CENTER_AWS_SECRET }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ^20.x
cache: "npm"

- name: Install Dependencies and Compile
run: |
npm ci
npm run compile
- name: Update greeting CTA
run: |
npm run update-cta ${{ github.event.inputs.dry-run && '-- --dry-run' || '' }}
6 changes: 6 additions & 0 deletions config/build.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ const MANPAGE_NAME = 'mongosh.1.gz'
*/
const PACKAGE_VARIANT = process.env.PACKAGE_VARIANT;

const CTA_CONFIG = require(path.join(ROOT, 'config', 'cta-config.json'));

const CTA_CONFIG_SCHEMA = require(path.join(ROOT, 'config', 'cta-config.schema.json'));

/**
* Export the configuration for the build.
*/
Expand Down Expand Up @@ -194,4 +198,6 @@ module.exports = {
downloadPath: path.resolve(TMP_DIR, 'manpage'),
fileName: MANPAGE_NAME,
},
ctaConfig: CTA_CONFIG,
ctaConfigSchema: CTA_CONFIG_SCHEMA,
};
3 changes: 3 additions & 0 deletions config/cta-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"$schema": "./cta-config.schema.json"
}
94 changes: 94 additions & 0 deletions config/cta-config.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
{
"$id": "https://mongodb.com/schemas/mongosh/cta-config",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "CTAConfig",
"type": "object",
"properties": {
"*": {
"$ref": "#/definitions/GreetingCTADetails",
"description": "The default CTA for all versions that don't have an explicit one defined."
},
"$schema": {
"type": "string"
}
},
"patternProperties": {
"^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$": {
"$ref": "#/definitions/GreetingCTADetails",
"description": "The CTA for a specific version.",
"$comment": "The property name must be a valid semver string."
}
},
"additionalProperties": false,
"definitions": {
"GreetingCTADetails": {
"type": "object",
"additionalProperties": false,
"properties": {
"chunks": {
"description": "The chunks that make up the CTA. They will be combined sequentially with no additional spacing added.",
"items": {
"properties": {
"style": {
"description": "The style to apply to the text. It must match the values from clr.ts/StyleDefinition.",
"enum": [
"reset",
"bold",
"italic",
"underline",
"fontDefault",
"font2",
"font3",
"font4",
"font5",
"font6",
"imageNegative",
"imagePositive",
"black",
"red",
"green",
"yellow",
"blue",
"magenta",
"cyan",
"white",
"grey",
"gray",
"bg-black",
"bg-red",
"bg-green",
"bg-yellow",
"bg-blue",
"bg-magenta",
"bg-cyan",
"bg-white",
"bg-grey",
"bg-gray",
"mongosh:warning",
"mongosh:error",
"mongosh:section-header",
"mongosh:uri",
"mongosh:filename",
"mongosh:additional-error-info"
],
"type": "string"
},
"text": {
"type": "string",
"description": "The text in the chunk."
}
},
"type": "object",
"required": [
"text"
]
},
"type": "array"
}
},
"required": [
"chunks"
]
}
}
}
23 changes: 23 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"compile-all": "npm run compile-compass && npm run compile-exec",
"evergreen-release": "cd packages/build && npm run evergreen-release --",
"release": "cd packages/build && npm run release --",
"update-cta": "cd packages/build && npm run update-cta --",
"report-missing-help": "npm run report-missing-help --workspace @mongosh/shell-api",
"report-supported-api": "npm run report-supported-api --workspace @mongosh/shell-api",
"post-process-nyc": "ts-node scripts/nyc/post-process-nyc-output.ts",
Expand Down
4 changes: 3 additions & 1 deletion packages/build/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"publish": "ts-node src/index.ts publish",
"bump-auxiliary": "ts-node src/index.ts bump --auxiliary",
"publish-auxiliary": "ts-node src/index.ts publish --auxiliary",
"reformat": "npm run prettier -- --write . && npm run eslint --fix"
"reformat": "npm run prettier -- --write . && npm run eslint --fix",
"update-cta": "ts-node src/index.ts update-cta"
},
"license": "Apache-2.0",
"publishConfig": {
Expand Down Expand Up @@ -69,6 +70,7 @@
"@mongodb-js/monorepo-tools": "^1.1.16",
"@mongodb-js/signing-utils": "^0.3.7",
"@octokit/rest": "^17.9.0",
"ajv": "^8.17.1",
"aws-sdk": "^2.674.0",
"boxednode": "^2.4.3",
"command-exists": "^1.2.9",
Expand Down
15 changes: 15 additions & 0 deletions packages/build/src/config/config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Schema } from 'ajv';
import type { PackageInformationProvider } from '../packaging/package';
import type { PackageVariant } from './build-variant';

Expand All @@ -7,6 +8,18 @@ interface ManPageConfig {
fileName: string;
}

// TODO: this is duplicated in update-notification-manager.ts
export interface GreetingCTADetails {
chunks: {
text: string;
style?: string; // TODO: this is actually clr.ts/StyleDefinition
}[];
}

export type CTAConfig = {
[version: string | '*']: GreetingCTADetails;
};

/**
* Defines the configuration interface for the build system.
*/
Expand Down Expand Up @@ -47,4 +60,6 @@ export interface Config {
manpage?: ManPageConfig;
isDryRun?: boolean;
useAuxiliaryPackagesOnly?: boolean;
ctaConfig: CTAConfig;
ctaConfigSchema: Schema;
}
Loading