{"id":18336492,"url":"https://github.com/reinskywalker/allure-mailer","last_synced_at":"2025-04-09T19:55:46.618Z","repository":{"id":248336193,"uuid":"827075927","full_name":"reinskywalker/allure-mailer","owner":"reinskywalker","description":"Extracts data from Allure reports, generates an HTML template from the extracted data, and sends it via Nodemailer.","archived":false,"fork":false,"pushed_at":"2024-07-14T05:20:28.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-09T19:55:43.274Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/reinskywalker.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-11T01:25:46.000Z","updated_at":"2024-07-14T05:20:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"b4cd0da2-9cb3-49fc-9794-7e56db65bcff","html_url":"https://github.com/reinskywalker/allure-mailer","commit_stats":null,"previous_names":["reinskywalker/allure-mailer"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reinskywalker%2Fallure-mailer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reinskywalker%2Fallure-mailer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reinskywalker%2Fallure-mailer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reinskywalker%2Fallure-mailer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/reinskywalker","download_url":"https://codeload.github.com/reinskywalker/allure-mailer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248103911,"owners_count":21048245,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-05T20:08:04.330Z","updated_at":"2025-04-09T19:55:46.594Z","avatar_url":"https://github.com/reinskywalker.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Documentation\n\n## Overview\n\nThis script is designed to compose and send an email report using dynamic content and configuration settings. The script utilizes a template engine for generating the email's HTML content and dotenv for environment variable management.\n\n## Prerequisites\n\n- Node.js installed on your machine.\n- Required dependencies installed via npm:\n  - `dotenv`: For loading environment variables from a `.env` file.\n  - `getContent` and `main` functions from `template_engine.mjs` and `mail_composer.mjs` respectively.\n  - `getArguments` function from `argument_config.mjs`.\n\n## Script Breakdown\n\n### 1. Importing Required Modules\n\n```javascript\nimport { getContent } from './plugins/template_engine.mjs';\nimport { main } from './plugins/mail_composer.mjs';\nimport dotenv from 'dotenv';\nimport { getArguments } from './plugins/argument_config.mjs';\ndotenv.config();\n```\n\n- `getContent`: A function to generate HTML content for the email.\n- `main`: A function to send the composed email.\n- `dotenv`: Module to load environment variables from a `.env` file.\n- `getArguments`: Function to retrieve command-line arguments.\n\n### 2. Retrieve Arguments\n\n```javascript\nconst { debug, env } = getArguments();\nconsole.log(getArguments());\n```\n\n- Retrieves `debug` and `env` arguments using the `getArguments` function.\n- Logs the arguments to the console for debugging purposes.\n\n### 3. Content Configuration\n\n```javascript\nconst contentConfig = {\n  /* content configuration */\n  dateObject: new Date(),\n  get localDate() { return new Date(this.dateObject.getTime() + (7 * 60 * 60 * 1000)); },\n  env: env || 'dev',\n  title: 'TITLE_FOR_REPORTER',\n  get reportUrl() { return `https://YOUR_REPORT_LINK${this.env}`; },\n  /* mail configuration */\n  imageCID: 'unique@cid.image',\n  allurePath: './reports/webdriverio/',\n  envAbbr: 'dev',\n  chartImgName: 'testcase_summary.jpeg',\n  chartImgPath: 'data/image',\n  get chartAsAttachment() {\n    return `${this.chartImgPath}/${this.chartImgName}`;\n  },\n};\n```\n\n- `dateObject`: Current date and time.\n- `localDate`: Adjusted date and time for the local timezone (UTC+7).\n- `env`: Environment setting, defaults to 'dev' if not provided.\n- `title`: Title for the reporter.\n- `reportUrl`: URL for the report, dynamically generated based on the environment.\n- `imageCID`: Unique identifier for the inline image in the email.\n- `allurePath`: Path to the Allure report.\n- `envAbbr`: Environment abbreviation.\n- `chartImgName`: Name of the chart image file.\n- `chartImgPath`: Path to the directory containing the chart image.\n- `chartAsAttachment`: Full path to the chart image file.\n\n### 4. Create Mail Options\n\n```javascript\nexport const createMailOptions = (cid, stats, individualStats) =\u003e ({\n  from: 'NAME_MASK \u003cSENDER_MAIL\u003e',\n  to: 'DESTINATION_MAIL_ADDRESS',\n  subject: `MAIL_SUBJECT - ${contentConfig.localDate}`,\n  html: getContent({\n    contentTitle: contentConfig.title,\n    reportUrl: contentConfig.reportUrl,\n    imageCID: cid,\n    localDate: contentConfig.localDate,\n    getSummary: stats,\n    individualData: individualStats,\n  }),\n  attachments: [{ filename: contentConfig.chartImgName, path: contentConfig.chartAsAttachment, cid }],\n});\n```\n\n- `createMailOptions`: Function to create the mail options.\n  - `from`: Sender's email address.\n  - `to`: Recipient's email address.\n  - `subject`: Email subject including the local date.\n  - `html`: HTML content generated using the `getContent` function.\n  - `attachments`: Attachments for the email, including the chart image.\n\n### 5. Main Function Call\n\n```javascript\nmain(contentConfig, debug || false);\n```\n\n- Calls the `main` function with the `contentConfig` and `debug` flag.\n\n---\n\n## How to Use\n\n1. **Install Dependencies**:\n   Ensure you have installed all the necessary dependencies using npm:\n   ```bash\n   npm install dotenv\n   ```\n\n2. **Set Up Environment Variables**:\n   Create a `.env` file in the root of your project and add your environment variables:\n   ```env\n   SENDER_MAIL=your_sender_email@example.com\n   DESTINATION_MAIL_ADDRESS=recipient_email@example.com\n   ```\n\n3. **Run the Script**:\n   Execute the script using Node.js:\n   ```bash\n   node your_script.js\n   ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freinskywalker%2Fallure-mailer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freinskywalker%2Fallure-mailer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freinskywalker%2Fallure-mailer/lists"}