Skip to content

Commit

Permalink
feat: add version info lib, logs and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ahochsteger committed May 25, 2024
1 parent ee0031d commit 5470741
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 24 deletions.
3 changes: 3 additions & 0 deletions docs/docs/reference/placeholder.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ These placeholder are valid globally and can also be used for internal purposes
| <a id="placeholder.date.now">`date.now`</a> | Current Timestamp | The current timestamp. Use `"${<key>:date::<format>}"` to format the date/time using a custom [date-fns format strings](https://date-fns.org/docs/format) (default: `"yyyy-MM-dd HH:mm:ss"`). | `2023-06-26 09:00:00` |
| <a id="placeholder.env.runMode">`env.runMode`</a> | Runmode | The runMode used for processing. | `safe-mode` |
| <a id="placeholder.env.timezone">`env.timezone`</a> | Timezone | The timezone used for processing. | `UTC` |
| <a id="placeholder.lib.description">`lib.description`</a> | Library Description | The description of the Gmail Processor library. | |
| <a id="placeholder.lib.name">`lib.name`</a> | Library Name | The name of the Gmail Processor library. | `gmail-processor` |
| <a id="placeholder.lib.version">`lib.version`</a> | Library Version | The version of the Gmail Processor library. | `0.0.0` |
| <a id="placeholder.user.email">`user.email`</a> | User Email | The email address of the active user. | `[email protected]` |

## Processing Placeholder
Expand Down
6 changes: 6 additions & 0 deletions docs/docusaurus.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// @ts-check
// Note: type annotations allow type checking and IDEs autocompletion
import { themes } from 'prism-react-renderer';
import { version } from "../package.json"
const lightCodeTheme = themes.vsLight;
const darkCodeTheme = themes.vsDark;

Expand Down Expand Up @@ -84,6 +85,11 @@ const config = {
},
// {to: '/blog', label: 'Blog', position: 'left'},
{ to: '/playground', label: 'Playground', position: 'left' },
{
href: `https://github.com/ahochsteger/gmail-processor/releases/${version}`,
position: 'right',
label: `Latest Release: ${version}`,
},
{
href: 'https://github.com/ahochsteger/gmail-processor',
position: 'right',
Expand Down
5 changes: 5 additions & 0 deletions global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
declare const __PACKAGE_JSON__: {
description: string
name: string
version: string
}
27 changes: 27 additions & 0 deletions src/lib/EnvProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ import {
} from "./Context"
import { Logger as Log } from "./utils/Logger"

const packageInfo: {
description: string
name: string
version: string
} =
typeof __PACKAGE_JSON__ !== "undefined"
? __PACKAGE_JSON__
: { version: "0.0.0", name: "gmail-processor", description: "" }

export class EnvProvider {
public static buildMetaInfo(ctx: EnvContext) {
const m: MetaInfo = {
Expand All @@ -29,6 +38,24 @@ export class EnvProvider {
"Timezone",
"The timezone used for processing.",
),
"lib.description": mi(
MIT.STRING,
() => packageInfo.description,
"Library Description",
"The description of the Gmail Processor library.",
),
"lib.name": mi(
MIT.STRING,
() => packageInfo?.name,
"Library Name",
"The name of the Gmail Processor library.",
),
"lib.version": mi(
MIT.STRING,
() => packageInfo?.version,
"Library Version",
"The version of the Gmail Processor library.",
),
"user.email": mi(
MIT.STRING,
() => ctx.env.session.getActiveUser().getEmail(),
Expand Down
6 changes: 5 additions & 1 deletion src/lib/processors/GmailProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
newConfig,
} from "../config/Config"
import { VariableEntry } from "../config/GlobalConfig"
import { PatternUtil } from "../utils/PatternUtil"
import { Timer } from "../utils/Timer"
import { BaseProcessor } from "./BaseProcessor"
import { ThreadProcessor } from "./ThreadProcessor"
Expand Down Expand Up @@ -150,7 +151,10 @@ export class GmailProcessor extends BaseProcessor {
ctx: EnvContext,
reportFormat = "text",
): ProcessingResult {
ctx.log.info("Processing GmailProcessor config started ...")
const version = PatternUtil.stringValue(ctx, "lib.version")
ctx.log.info(
`Processing config started using Gmail Processor v${version} ...`,
)
this.checkTimezone(ctx, config)
const actionRegistry = GmailProcessor.setupActionRegistry(ctx)
actionRegistry.registerCustomActions(customActions)
Expand Down
24 changes: 2 additions & 22 deletions tsconfig-examples.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,4 @@
{
"compilerOptions": {
"allowJs": true,
"baseUrl": "src/",
"declaration": true,
"emitDecoratorMetadata": true,
"esModuleInterop": true,
"experimentalDecorators": true,
"inlineSourceMap": true,
"lib": ["ES2020"],
"module": "commonjs",
"noFallthroughCasesInSwitch": true,
"noImplicitReturns": false,
"noUnusedLocals": true,
"noUnusedParameters": true,
"outDir": "build",
"resolveJsonModule": true,
"strict": true,
// ES2019 for V8 support: https://github.com/google/clasp/blob/master/docs/typescript.md#v8-engine-support
"target": "ES2019",
"types": ["google-apps-script", "jest", "node"]
},
"include": ["src/examples/**/*", "src/lib/**/*"]
"extends": "./tsconfig.json",
"include": ["src/lib/**/*", "src/examples/**/*", "./global.d.ts"]
}
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@
"target": "ES2019",
"types": ["google-apps-script", "jest", "node"]
},
"include": ["src/lib/**/*"]
"include": ["src/lib/**/*", "./global.d.ts"]
}
3 changes: 3 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/* eslint-disable no-undef, @typescript-eslint/no-var-requires */
const GasPlugin = require("gas-webpack-plugin")
const NodePolyfillPlugin = require("node-polyfill-webpack-plugin")
const __PACKAGE_JSON__ = require("./package.json")
const { DefinePlugin } = require("webpack")

module.exports = {
mode: "development",
Expand All @@ -20,6 +22,7 @@ module.exports = {
comment: true,
}),
new NodePolyfillPlugin(),
new DefinePlugin({ __PACKAGE_JSON__: JSON.stringify(__PACKAGE_JSON__) }),
],
devtool: false,
}

0 comments on commit 5470741

Please sign in to comment.