├── .all-contributorsrc ├── .devcontainer └── devcontainer.json ├── .editorconfig ├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── config.yml │ ├── feature_request.md │ └── new-source.md ├── pull_request_template.md └── workflows │ ├── build.yml │ ├── release-to-github.yml │ └── version-bump.yml ├── .gitignore ├── .jshintrc ├── .npmrc ├── .nvmrc ├── .snyk ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── SECURITY.md ├── action.yml ├── dist └── blog-post-workflow.js ├── local-run.js ├── package.json ├── src ├── blog-post-workflow.js ├── filters.js └── utils.js ├── test ├── .gitignore ├── categories-template.js ├── categories.js ├── counter.js ├── custom-template.js ├── default.js ├── disable-sort-reverse.js ├── disable-sort.js ├── duplicate.js ├── emojikey.js ├── feed-names.js ├── js-manipulation.js ├── max-post-count.js ├── multiple.js ├── random-emoji.js ├── retry.js ├── snapshots │ ├── Readme.categories.md.snap │ ├── Readme.categories.template.md.snap │ ├── Readme.comments.md.snap │ ├── Readme.counter.md.snap │ ├── Readme.custom-tags.md.snap │ ├── Readme.custom.md.snap │ ├── Readme.disable-sort-reverse-order.md.snap │ ├── Readme.emojiKey.md.snap │ ├── Readme.emptyTags.md.snap │ ├── Readme.exec.md.snap │ ├── Readme.feedNames.md.snap │ ├── Readme.maxPostCount.md.snap │ ├── Readme.md.snap │ ├── Readme.multi.1.md.snap │ ├── Readme.multi.2.md.snap │ ├── Readme.randomEmoji.md.snap │ ├── Readme.removeDuplicates.md.snap │ ├── Readme.retry.md.snap │ ├── Readme.sort-order-asc.md.snap │ ├── Readme.sort.md.snap │ ├── Readme.truncate.description.md.snap │ └── Readme.truncate.title.md.snap ├── sort-order-asc.js ├── testUtils │ ├── default-env.js │ ├── sample.duplicate.xml │ ├── sample.xml │ ├── test-server.js │ └── testUtils.js ├── truncated description.js ├── truncated-title.js ├── util.test.js ├── validation-flag.js ├── without-custom-elements.js └── without-filters.js └── yarn.lock /.all-contributorsrc: -------------------------------------------------------------------------------- 1 | { 2 | "files": [ 3 | "README.md" 4 | ], 5 | "imageSize": 100, 6 | "commit": false, 7 | "commitType": "docs", 8 | "commitConvention": "angular", 9 | "contributors": [ 10 | { 11 | "login": "khaosdoctor", 12 | "name": "Lucas Santos", 13 | "avatar_url": "https://avatars.githubusercontent.com/u/3200560?v=4", 14 | "profile": "https://github.com/khaosdoctor", 15 | "contributions": [ 16 | "code", 17 | "doc" 18 | ] 19 | }, 20 | { 21 | "login": "MichaelCurrin", 22 | "name": "Michael Currin", 23 | "avatar_url": "https://avatars.githubusercontent.com/u/18750745?v=4", 24 | "profile": "https://github.com/MichaelCurrin", 25 | "contributions": [ 26 | "doc" 27 | ] 28 | }, 29 | { 30 | "login": "Curious-Yu", 31 | "name": "WY", 32 | "avatar_url": "https://avatars.githubusercontent.com/u/22830590?v=4", 33 | "profile": "https://curious-yu.github.io/", 34 | "contributions": [ 35 | "doc" 36 | ] 37 | }, 38 | { 39 | "login": "hexxdump", 40 | "name": "Hussaina Begum", 41 | "avatar_url": "https://avatars.githubusercontent.com/u/631835?v=4", 42 | "profile": "https://github.com/hexxdump", 43 | "contributions": [ 44 | "doc" 45 | ] 46 | }, 47 | { 48 | "login": "riginoommen", 49 | "name": "Rigin Oommen", 50 | "avatar_url": "https://avatars.githubusercontent.com/u/3840244?v=4", 51 | "profile": "https://github.com/riginoommen", 52 | "contributions": [ 53 | "doc" 54 | ] 55 | }, 56 | { 57 | "login": "polilluminato", 58 | "name": "Alberto Bonacina", 59 | "avatar_url": "https://avatars.githubusercontent.com/u/202140?v=4", 60 | "profile": "https://github.com/polilluminato", 61 | "contributions": [ 62 | "doc" 63 | ] 64 | }, 65 | { 66 | "login": "Vadorequest", 67 | "name": "Vadorequest", 68 | "avatar_url": "https://avatars.githubusercontent.com/u/3807458?v=4", 69 | "profile": "https://www.linkedin.com/in/ambroise-dhenain/", 70 | "contributions": [ 71 | "doc" 72 | ] 73 | }, 74 | { 75 | "login": "DenverCoder1", 76 | "name": "Jonah Lawrence", 77 | "avatar_url": "https://avatars.githubusercontent.com/u/20955511?v=4", 78 | "profile": "https://freshidea.com/jonah", 79 | "contributions": [ 80 | "code" 81 | ] 82 | }, 83 | { 84 | "login": "denvercoder", 85 | "name": "Tim Myers", 86 | "avatar_url": "https://avatars.githubusercontent.com/u/22165183?v=4", 87 | "profile": "https://denvercoder.com/", 88 | "contributions": [ 89 | "doc" 90 | ] 91 | }, 92 | { 93 | "login": "kaustubhgupta", 94 | "name": "Kaustubh Gupta", 95 | "avatar_url": "https://avatars.githubusercontent.com/u/43691873?v=4", 96 | "profile": "https://linktr.ee/kaustubhgupta", 97 | "contributions": [ 98 | "doc" 99 | ] 100 | }, 101 | { 102 | "login": "matyo91", 103 | "name": "Mathieu Ledru", 104 | "avatar_url": "https://avatars.githubusercontent.com/u/1254025?v=4", 105 | "profile": "https://darkwood.com/", 106 | "contributions": [ 107 | "doc" 108 | ] 109 | }, 110 | { 111 | "login": "adityadees", 112 | "name": "Aditya Dharmawan Saputra", 113 | "avatar_url": "https://avatars.githubusercontent.com/u/37553901?v=4", 114 | "profile": "https://adityadees.com/", 115 | "contributions": [ 116 | "doc" 117 | ] 118 | }, 119 | { 120 | "login": "minnczi", 121 | "name": "Minji", 122 | "avatar_url": "https://avatars.githubusercontent.com/u/32619843?v=4", 123 | "profile": "https://velog.io/@minnczi", 124 | "contributions": [ 125 | "doc" 126 | ] 127 | }, 128 | { 129 | "login": "madushadhanushka", 130 | "name": "Dhanushka Madushan", 131 | "avatar_url": "https://avatars.githubusercontent.com/u/7068605?v=4", 132 | "profile": "https://dhanushka.netlify.com/", 133 | "contributions": [ 134 | "doc" 135 | ] 136 | }, 137 | { 138 | "login": "curtiscde", 139 | "name": "Curtis Timson", 140 | "avatar_url": "https://avatars.githubusercontent.com/u/15653985?v=4", 141 | "profile": "https://curtiscode.dev/", 142 | "contributions": [ 143 | "code" 144 | ] 145 | }, 146 | { 147 | "login": "mdobydullah", 148 | "name": "Md Obydullah", 149 | "avatar_url": "https://avatars.githubusercontent.com/u/13184472?v=4", 150 | "profile": "https://bio.link/obydul", 151 | "contributions": [ 152 | "doc" 153 | ] 154 | }, 155 | { 156 | "login": "davidaparicio", 157 | "name": "David Aparicio", 158 | "avatar_url": "https://avatars.githubusercontent.com/u/809982?v=4", 159 | "profile": "http://david.aparicio.eu/", 160 | "contributions": [ 161 | "doc" 162 | ] 163 | }, 164 | { 165 | "login": "banyudu", 166 | "name": "Yudu", 167 | "avatar_url": "https://avatars.githubusercontent.com/u/2416493?v=4", 168 | "profile": "https://github.com/banyudu", 169 | "contributions": [ 170 | "doc" 171 | ] 172 | }, 173 | { 174 | "login": "TLOWAC", 175 | "name": "Changhun Lee", 176 | "avatar_url": "https://avatars.githubusercontent.com/u/58043975?v=4", 177 | "profile": "https://github.com/TLOWAC", 178 | "contributions": [ 179 | "doc" 180 | ] 181 | }, 182 | { 183 | "login": "adrianpaniagualeon", 184 | "name": "Adrián Paniagua", 185 | "avatar_url": "https://avatars.githubusercontent.com/u/66434978?v=4", 186 | "profile": "https://cv.adrianpaniagua.es/", 187 | "contributions": [ 188 | "doc" 189 | ] 190 | }, 191 | { 192 | "login": "muktoakash", 193 | "name": "Mukto Akash", 194 | "avatar_url": "https://avatars.githubusercontent.com/u/73410983?v=4", 195 | "profile": "https://github.com/muktoakash", 196 | "contributions": [ 197 | "doc" 198 | ] 199 | }, 200 | { 201 | "login": "joshjohanning", 202 | "name": "Josh Johanning", 203 | "avatar_url": "https://avatars.githubusercontent.com/u/19912012?v=4", 204 | "profile": "https://josh-ops.com", 205 | "contributions": [ 206 | "code" 207 | ] 208 | }, 209 | { 210 | "login": "kakkoyun", 211 | "name": "Kemal Akkoyun", 212 | "avatar_url": "https://avatars.githubusercontent.com/u/536449?v=4", 213 | "profile": "https://kakkoyun.me", 214 | "contributions": [ 215 | "code" 216 | ] 217 | } 218 | ], 219 | "contributorsPerLine": 7, 220 | "skipCi": true, 221 | "repoType": "github", 222 | "repoHost": "https://github.com", 223 | "projectName": "blog-post-workflow", 224 | "projectOwner": "gautamkrishnar" 225 | } 226 | -------------------------------------------------------------------------------- /.devcontainer/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "image":"mcr.microsoft.com/devcontainers/universal:2", 3 | "features":{ 4 | "ghcr.io/devcontainers/features/node:1":{ 5 | "version":"16" 6 | } 7 | }, 8 | "customizations":{ 9 | "codespaces":{ 10 | "openFiles":[ 11 | "README.md", 12 | "CONTRIBUTING.md" 13 | ] 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | end_of_line = lf 7 | indent_size = 2 8 | indent_style = space 9 | insert_final_newline = true 10 | max_line_length = 120 11 | trim_trailing_whitespace = true 12 | 13 | [*.md] 14 | max_line_length = 0 15 | trim_trailing_whitespace = false 16 | 17 | [COMMIT_EDITMSG] 18 | max_line_length = 0 19 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: gautamkrishnar 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: "[Bug]: " 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | ### Describe the bug 11 | A clear and concise description of what the bug is. 12 | 13 | ### Expected behavior 14 | A clear and concise description of what you expected to happen. 15 | 16 | ### Screenshots 17 | If applicable, add screenshots to help explain your problem. 18 | 19 | ### Workflow Yml Used 20 | ```yml 21 | Insert the workflow's yml file you used 22 | ``` 23 | 24 | ### Additional context 25 | Add any other context about the problem here. 26 | 27 | ### Double check the following 28 | Before opening a bug, Please make sure that you had done the following, add a checkmark if done by marking it with `[x]`: 29 | 30 | - [ ] I had gone through the [FAQs](https://github.com/gautamkrishnar/blog-post-workflow#faqs-and-common-issues) 31 | - [ ] I had followed all the steps mentioned in the [documentation](https://github.com/gautamkrishnar/blog-post-workflow) 32 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: Blog Post Workflow Community Support 4 | url: https://github.com/gautamkrishnar/blog-post-workflow/discussions 5 | about: You can ask and answer the questions here 6 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: "[Feature]: " 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. e.g. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | 22 | ### Double check the following 23 | Before creating a feature request, Please make sure that you had done the following, add a checkmark if done by marking it with `[x]`: 24 | 25 | - [ ] This feature cannot be accomplished using any of the available [options](https://github.com/gautamkrishnar/blog-post-workflow#options) provided by the workflow. 26 | - [ ] I had followed all the steps mentioned in the [documentation](https://github.com/gautamkrishnar/blog-post-workflow) 27 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/new-source.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: New Source 3 | about: Use this for adding new sources to the Popular Sources section on the readme. 4 | title: "[New Source]: Source-Name" 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | Source Name: 11 | Source URL: 12 | Comments: 13 | Example: 14 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | * **Please check if the PR fulfills these requirements** 2 | - [ ] The commit message follows our contribution guidelines 3 | - [ ] Tests for the changes have been added (for bug fixes / features) 4 | - [ ] Docs have been added / updated (for bug fixes / features) 5 | 6 | 7 | * **What kind of change does this PR introduce?** (Bug fix, feature, docs update, ...) 8 | 9 | 10 | 11 | * **What is the current behavior?** (You can also link to an open issue here) 12 | 13 | 14 | 15 | * **What is the new behavior (if this is a feature change)?** 16 | 17 | 18 | 19 | * **Does this PR introduce a breaking change?** (What changes might users need to make in their application due to this PR?) 20 | 21 | 22 | 23 | * **Other information**: 24 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build and test 2 | on: 3 | workflow_dispatch: 4 | push: 5 | paths: 6 | - '**.js' 7 | - 'package.json' 8 | - '.github/workflows/build.yml' 9 | pull_request: 10 | paths: 11 | - '**.js' 12 | - 'package.json' 13 | permissions: 14 | contents: read 15 | actions: read 16 | checks: write 17 | jobs: 18 | test: 19 | if: | 20 | !contains(toJSON(github.event.commits.*.message), '[skip-ci]') && 21 | !startsWith(github.ref, 'refs/tags') 22 | name: Generate build and test 23 | runs-on: ubuntu-latest 24 | steps: 25 | - uses: actions/checkout@v4 26 | - uses: actions/setup-node@v4 27 | with: 28 | node-version: "20" 29 | cache: "yarn" 30 | - run: yarn install --frozen-lockfile 31 | - run: yarn test 32 | - run: yarn build && yarn run test-dist 33 | - name: Test Report 34 | uses: dorny/test-reporter@v1 35 | if: ${{ github.repository == 'gautamkrishnar/blog-post-workflow' && github.event_name != 'pull_request' && (success() || failure()) }} 36 | with: 37 | name: Mocha Tests 38 | path: "*-report.json" 39 | reporter: mocha-json 40 | -------------------------------------------------------------------------------- /.github/workflows/release-to-github.yml: -------------------------------------------------------------------------------- 1 | name: Publish release to GitHub 2 | on: 3 | workflow_dispatch: 4 | workflow_run: 5 | workflows: ["Version bump"] 6 | branches: [master] 7 | types: 8 | - completed 9 | permissions: 10 | contents: write 11 | jobs: 12 | version-bump: 13 | name: Release to github releases 14 | runs-on: ubuntu-latest 15 | steps: 16 | - uses: actions/checkout@v4 17 | - name: Set env 18 | run: echo "pkg_version=$(awk '/version/{gsub(/("|",)/,"",$2);print $2}' package.json)" >> $GITHUB_ENV 19 | - name: Create Release 20 | id: create_release 21 | uses: actions/create-release@v1 22 | env: 23 | GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} 24 | with: 25 | tag_name: ${{ env.pkg_version }} 26 | release_name: ${{ env.pkg_version }} 27 | body: | 28 | - 29 | draft: true 30 | prerelease: false 31 | - name: Update v1 release with the latest code 32 | run: | 33 | git config user.name gkr-bot 34 | git config user.email gkr@tuta.io 35 | git tag -fa v1 -m "Updated v1 tag with the latest code" 36 | git push origin v1 --force 37 | -------------------------------------------------------------------------------- /.github/workflows/version-bump.yml: -------------------------------------------------------------------------------- 1 | name: Version bump 2 | on: 3 | workflow_dispatch: 4 | inputs: 5 | tag_name: 6 | description: 'Version' 7 | required: true 8 | permissions: 9 | contents: write 10 | jobs: 11 | version-bump: 12 | name: Update dist 13 | runs-on: ubuntu-latest 14 | steps: 15 | - uses: actions/checkout@v4 16 | - uses: actions/setup-node@v4 17 | with: 18 | node-version: "20" 19 | - name: Install dependancies 20 | run: yarn install 21 | - name: Build source code 22 | run: yarn build 23 | - name: Test built source code 24 | run: yarn run test-dist 25 | - name: Setup Git 26 | run: | 27 | git config user.name gkr-bot 28 | git config user.email gkr@tuta.io 29 | - name: Version bump on package.json 30 | run: yarn version --new-version ${{ github.event.inputs.tag_name }} --no-git-tag-version 31 | - name: Commit the changes 32 | run: | 33 | git add ./dist/blog-post-workflow.js ./package.json 34 | git commit -m "[skip-ci] Published ${{ github.event.inputs.tag_name }}" 35 | - name: Push to repository 36 | run: git push --quiet 37 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | 9 | # Diagnostic reports (https://nodejs.org/api/report.html) 10 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 11 | 12 | # Runtime data 13 | pids 14 | *.pid 15 | *.seed 16 | *.pid.lock 17 | 18 | # Directory for instrumented libs generated by jscoverage/JSCover 19 | lib-cov 20 | 21 | # Coverage directory used by tools like istanbul 22 | coverage 23 | *.lcov 24 | 25 | # nyc test coverage 26 | .nyc_output 27 | 28 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 29 | .grunt 30 | 31 | # Bower dependency directory (https://bower.io/) 32 | bower_components 33 | 34 | # node-waf configuration 35 | .lock-wscript 36 | 37 | # Compiled binary addons (https://nodejs.org/api/addons.html) 38 | build/Release 39 | 40 | # Dependency directories 41 | node_modules/ 42 | jspm_packages/ 43 | 44 | # Snowpack dependency directory (https://snowpack.dev/) 45 | web_modules/ 46 | 47 | # TypeScript cache 48 | *.tsbuildinfo 49 | 50 | # Optional npm cache directory 51 | .npm 52 | 53 | # Optional eslint cache 54 | .eslintcache 55 | 56 | # Microbundle cache 57 | .rpt2_cache/ 58 | .rts2_cache_cjs/ 59 | .rts2_cache_es/ 60 | .rts2_cache_umd/ 61 | 62 | # Optional REPL history 63 | .node_repl_history 64 | 65 | # Output of 'npm pack' 66 | *.tgz 67 | 68 | # Yarn Integrity file 69 | .yarn-integrity 70 | 71 | # dotenv environment variables file 72 | .env 73 | .env.test 74 | 75 | # parcel-bundler cache (https://parceljs.org/) 76 | .cache 77 | .parcel-cache 78 | 79 | # Next.js build output 80 | .next 81 | out 82 | 83 | # Nuxt.js build / generate output 84 | .nuxt 85 | 86 | # Gatsby files 87 | .cache/ 88 | # Comment in the public line in if your project uses Gatsby and not Next.js 89 | # https://nextjs.org/blog/next-9-1#public-directory-support 90 | # public 91 | 92 | # vuepress build output 93 | .vuepress/dist 94 | 95 | # Serverless directories 96 | .serverless/ 97 | 98 | # FuseBox cache 99 | .fusebox/ 100 | 101 | # DynamoDB Local files 102 | .dynamodb/ 103 | 104 | # TernJS port file 105 | .tern-port 106 | 107 | # Stores VSCode versions used for testing VSCode extensions 108 | .vscode-test 109 | 110 | # yarn v2 111 | .yarn/cache 112 | .yarn/unplugged 113 | .yarn/build-state.yml 114 | .yarn/install-state.gz 115 | .pnp.* 116 | 117 | # reports 118 | src-report.json 119 | dist-report.json 120 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "node": true, 3 | "esversion": 9, 4 | "camelcase": true, 5 | "curly": true, 6 | "eqeqeq": true, 7 | "evil": true, 8 | "freeze": true, 9 | "indent": 2, 10 | "newcap": true, 11 | "quotmark": "single", 12 | "maxlen": 120, 13 | "eqnull": true, 14 | "funcscope": true, 15 | "globals": {} 16 | } 17 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | scripts-prepend-node-path=true 2 | -------------------------------------------------------------------------------- /.nvmrc: -------------------------------------------------------------------------------- 1 | v20 2 | -------------------------------------------------------------------------------- /.snyk: -------------------------------------------------------------------------------- 1 | ignore: 2 | - dist/ 3 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, sex characteristics, gender identity and expression, 9 | level of experience, education, socio-economic status, nationality, personal 10 | appearance, race, religion, or sexual identity and orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project maintainer at r.gautamkrishna@gmail.com. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project maintainer is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html 72 | 73 | [homepage]: https://www.contributor-covenant.org 74 | 75 | For answers to common questions about this code of conduct, see 76 | https://www.contributor-covenant.org/faq 77 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | ### Getting started locally 3 | - Fork the project 4 | - Clone your fork locally 5 | ```bash 6 | git clone https://github.com//blog-post-workflow 7 | cd blog-post-workflow 8 | ``` 9 | - Create a new branch 10 | ```bash 11 | git checkout -b new-feature 12 | ``` 13 | - Install the dependencies 14 | ```bash 15 | yarn 16 | ``` 17 | - To test the workflow locally run 18 | ```bash 19 | yarn local-run 20 | ``` 21 | - Do required changes and make sure that the tests are passing by running: 22 | ```bash 23 | yarn test 24 | ``` 25 | 26 | Please run `export TEST_MODE=true` before running the [blog-post-workflow.js](src/blog-post-workflow.js) directly, to prevent accidental 27 | automated committing and pushing to your fork. 28 | 29 | Please note we have a [code of conduct](CODE_OF_CONDUCT.md), please follow it in all your interactions with the project. 30 | 31 | ## Pull Request Requirements 32 | 33 | 1. Update the README.md with details of changes to the API if you made those changes. Add an example as well 34 | 2. Add proper comments to the code you have added. You should use the `yarn lint` to check linting of the code, 35 | make sure that you dont add/remove any linting rules. Discuss with the maintainer if you require any of such changes. 36 | 3. Do not run `yarn build`, It will be done by the maintainer's bot when he release a new version. Revert the changes if you had 37 | accidentally done it. 38 | 4. Add descriptive title and description to the PRs 39 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU AFFERO GENERAL PUBLIC LICENSE 2 | Version 3, 19 November 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU Affero General Public License is a free, copyleft license for 11 | software and other kinds of works, specifically designed to ensure 12 | cooperation with the community in the case of network server software. 13 | 14 | The licenses for most software and other practical works are designed 15 | to take away your freedom to share and change the works. By contrast, 16 | our General Public Licenses are intended to guarantee your freedom to 17 | share and change all versions of a program--to make sure it remains free 18 | software for all its users. 19 | 20 | When we speak of free software, we are referring to freedom, not 21 | price. Our General Public Licenses are designed to make sure that you 22 | have the freedom to distribute copies of free software (and charge for 23 | them if you wish), that you receive source code or can get it if you 24 | want it, that you can change the software or use pieces of it in new 25 | free programs, and that you know you can do these things. 26 | 27 | Developers that use our General Public Licenses protect your rights 28 | with two steps: (1) assert copyright on the software, and (2) offer 29 | you this License which gives you legal permission to copy, distribute 30 | and/or modify the software. 31 | 32 | A secondary benefit of defending all users' freedom is that 33 | improvements made in alternate versions of the program, if they 34 | receive widespread use, become available for other developers to 35 | incorporate. Many developers of free software are heartened and 36 | encouraged by the resulting cooperation. However, in the case of 37 | software used on network servers, this result may fail to come about. 38 | The GNU General Public License permits making a modified version and 39 | letting the public access it on a server without ever releasing its 40 | source code to the public. 41 | 42 | The GNU Affero General Public License is designed specifically to 43 | ensure that, in such cases, the modified source code becomes available 44 | to the community. It requires the operator of a network server to 45 | provide the source code of the modified version running there to the 46 | users of that server. Therefore, public use of a modified version, on 47 | a publicly accessible server, gives the public access to the source 48 | code of the modified version. 49 | 50 | An older license, called the Affero General Public License and 51 | published by Affero, was designed to accomplish similar goals. This is 52 | a different license, not a version of the Affero GPL, but Affero has 53 | released a new version of the Affero GPL which permits relicensing under 54 | this license. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | TERMS AND CONDITIONS 60 | 61 | 0. Definitions. 62 | 63 | "This License" refers to version 3 of the GNU Affero General Public License. 64 | 65 | "Copyright" also means copyright-like laws that apply to other kinds of 66 | works, such as semiconductor masks. 67 | 68 | "The Program" refers to any copyrightable work licensed under this 69 | License. Each licensee is addressed as "you". "Licensees" and 70 | "recipients" may be individuals or organizations. 71 | 72 | To "modify" a work means to copy from or adapt all or part of the work 73 | in a fashion requiring copyright permission, other than the making of an 74 | exact copy. The resulting work is called a "modified version" of the 75 | earlier work or a work "based on" the earlier work. 76 | 77 | A "covered work" means either the unmodified Program or a work based 78 | on the Program. 79 | 80 | To "propagate" a work means to do anything with it that, without 81 | permission, would make you directly or secondarily liable for 82 | infringement under applicable copyright law, except executing it on a 83 | computer or modifying a private copy. Propagation includes copying, 84 | distribution (with or without modification), making available to the 85 | public, and in some countries other activities as well. 86 | 87 | To "convey" a work means any kind of propagation that enables other 88 | parties to make or receive copies. Mere interaction with a user through 89 | a computer network, with no transfer of a copy, is not conveying. 90 | 91 | An interactive user interface displays "Appropriate Legal Notices" 92 | to the extent that it includes a convenient and prominently visible 93 | feature that (1) displays an appropriate copyright notice, and (2) 94 | tells the user that there is no warranty for the work (except to the 95 | extent that warranties are provided), that licensees may convey the 96 | work under this License, and how to view a copy of this License. If 97 | the interface presents a list of user commands or options, such as a 98 | menu, a prominent item in the list meets this criterion. 99 | 100 | 1. Source Code. 101 | 102 | The "source code" for a work means the preferred form of the work 103 | for making modifications to it. "Object code" means any non-source 104 | form of a work. 105 | 106 | A "Standard Interface" means an interface that either is an official 107 | standard defined by a recognized standards body, or, in the case of 108 | interfaces specified for a particular programming language, one that 109 | is widely used among developers working in that language. 110 | 111 | The "System Libraries" of an executable work include anything, other 112 | than the work as a whole, that (a) is included in the normal form of 113 | packaging a Major Component, but which is not part of that Major 114 | Component, and (b) serves only to enable use of the work with that 115 | Major Component, or to implement a Standard Interface for which an 116 | implementation is available to the public in source code form. A 117 | "Major Component", in this context, means a major essential component 118 | (kernel, window system, and so on) of the specific operating system 119 | (if any) on which the executable work runs, or a compiler used to 120 | produce the work, or an object code interpreter used to run it. 121 | 122 | The "Corresponding Source" for a work in object code form means all 123 | the source code needed to generate, install, and (for an executable 124 | work) run the object code and to modify the work, including scripts to 125 | control those activities. However, it does not include the work's 126 | System Libraries, or general-purpose tools or generally available free 127 | programs which are used unmodified in performing those activities but 128 | which are not part of the work. For example, Corresponding Source 129 | includes interface definition files associated with source files for 130 | the work, and the source code for shared libraries and dynamically 131 | linked subprograms that the work is specifically designed to require, 132 | such as by intimate data communication or control flow between those 133 | subprograms and other parts of the work. 134 | 135 | The Corresponding Source need not include anything that users 136 | can regenerate automatically from other parts of the Corresponding 137 | Source. 138 | 139 | The Corresponding Source for a work in source code form is that 140 | same work. 141 | 142 | 2. Basic Permissions. 143 | 144 | All rights granted under this License are granted for the term of 145 | copyright on the Program, and are irrevocable provided the stated 146 | conditions are met. This License explicitly affirms your unlimited 147 | permission to run the unmodified Program. The output from running a 148 | covered work is covered by this License only if the output, given its 149 | content, constitutes a covered work. This License acknowledges your 150 | rights of fair use or other equivalent, as provided by copyright law. 151 | 152 | You may make, run and propagate covered works that you do not 153 | convey, without conditions so long as your license otherwise remains 154 | in force. You may convey covered works to others for the sole purpose 155 | of having them make modifications exclusively for you, or provide you 156 | with facilities for running those works, provided that you comply with 157 | the terms of this License in conveying all material for which you do 158 | not control copyright. Those thus making or running the covered works 159 | for you must do so exclusively on your behalf, under your direction 160 | and control, on terms that prohibit them from making any copies of 161 | your copyrighted material outside their relationship with you. 162 | 163 | Conveying under any other circumstances is permitted solely under 164 | the conditions stated below. Sublicensing is not allowed; section 10 165 | makes it unnecessary. 166 | 167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 168 | 169 | No covered work shall be deemed part of an effective technological 170 | measure under any applicable law fulfilling obligations under article 171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 172 | similar laws prohibiting or restricting circumvention of such 173 | measures. 174 | 175 | When you convey a covered work, you waive any legal power to forbid 176 | circumvention of technological measures to the extent such circumvention 177 | is effected by exercising rights under this License with respect to 178 | the covered work, and you disclaim any intention to limit operation or 179 | modification of the work as a means of enforcing, against the work's 180 | users, your or third parties' legal rights to forbid circumvention of 181 | technological measures. 182 | 183 | 4. Conveying Verbatim Copies. 184 | 185 | You may convey verbatim copies of the Program's source code as you 186 | receive it, in any medium, provided that you conspicuously and 187 | appropriately publish on each copy an appropriate copyright notice; 188 | keep intact all notices stating that this License and any 189 | non-permissive terms added in accord with section 7 apply to the code; 190 | keep intact all notices of the absence of any warranty; and give all 191 | recipients a copy of this License along with the Program. 192 | 193 | You may charge any price or no price for each copy that you convey, 194 | and you may offer support or warranty protection for a fee. 195 | 196 | 5. Conveying Modified Source Versions. 197 | 198 | You may convey a work based on the Program, or the modifications to 199 | produce it from the Program, in the form of source code under the 200 | terms of section 4, provided that you also meet all of these conditions: 201 | 202 | a) The work must carry prominent notices stating that you modified 203 | it, and giving a relevant date. 204 | 205 | b) The work must carry prominent notices stating that it is 206 | released under this License and any conditions added under section 207 | 7. This requirement modifies the requirement in section 4 to 208 | "keep intact all notices". 209 | 210 | c) You must license the entire work, as a whole, under this 211 | License to anyone who comes into possession of a copy. This 212 | License will therefore apply, along with any applicable section 7 213 | additional terms, to the whole of the work, and all its parts, 214 | regardless of how they are packaged. This License gives no 215 | permission to license the work in any other way, but it does not 216 | invalidate such permission if you have separately received it. 217 | 218 | d) If the work has interactive user interfaces, each must display 219 | Appropriate Legal Notices; however, if the Program has interactive 220 | interfaces that do not display Appropriate Legal Notices, your 221 | work need not make them do so. 222 | 223 | A compilation of a covered work with other separate and independent 224 | works, which are not by their nature extensions of the covered work, 225 | and which are not combined with it such as to form a larger program, 226 | in or on a volume of a storage or distribution medium, is called an 227 | "aggregate" if the compilation and its resulting copyright are not 228 | used to limit the access or legal rights of the compilation's users 229 | beyond what the individual works permit. Inclusion of a covered work 230 | in an aggregate does not cause this License to apply to the other 231 | parts of the aggregate. 232 | 233 | 6. Conveying Non-Source Forms. 234 | 235 | You may convey a covered work in object code form under the terms 236 | of sections 4 and 5, provided that you also convey the 237 | machine-readable Corresponding Source under the terms of this License, 238 | in one of these ways: 239 | 240 | a) Convey the object code in, or embodied in, a physical product 241 | (including a physical distribution medium), accompanied by the 242 | Corresponding Source fixed on a durable physical medium 243 | customarily used for software interchange. 244 | 245 | b) Convey the object code in, or embodied in, a physical product 246 | (including a physical distribution medium), accompanied by a 247 | written offer, valid for at least three years and valid for as 248 | long as you offer spare parts or customer support for that product 249 | model, to give anyone who possesses the object code either (1) a 250 | copy of the Corresponding Source for all the software in the 251 | product that is covered by this License, on a durable physical 252 | medium customarily used for software interchange, for a price no 253 | more than your reasonable cost of physically performing this 254 | conveying of source, or (2) access to copy the 255 | Corresponding Source from a network server at no charge. 256 | 257 | c) Convey individual copies of the object code with a copy of the 258 | written offer to provide the Corresponding Source. This 259 | alternative is allowed only occasionally and noncommercially, and 260 | only if you received the object code with such an offer, in accord 261 | with subsection 6b. 262 | 263 | d) Convey the object code by offering access from a designated 264 | place (gratis or for a charge), and offer equivalent access to the 265 | Corresponding Source in the same way through the same place at no 266 | further charge. You need not require recipients to copy the 267 | Corresponding Source along with the object code. If the place to 268 | copy the object code is a network server, the Corresponding Source 269 | may be on a different server (operated by you or a third party) 270 | that supports equivalent copying facilities, provided you maintain 271 | clear directions next to the object code saying where to find the 272 | Corresponding Source. Regardless of what server hosts the 273 | Corresponding Source, you remain obligated to ensure that it is 274 | available for as long as needed to satisfy these requirements. 275 | 276 | e) Convey the object code using peer-to-peer transmission, provided 277 | you inform other peers where the object code and Corresponding 278 | Source of the work are being offered to the general public at no 279 | charge under subsection 6d. 280 | 281 | A separable portion of the object code, whose source code is excluded 282 | from the Corresponding Source as a System Library, need not be 283 | included in conveying the object code work. 284 | 285 | A "User Product" is either (1) a "consumer product", which means any 286 | tangible personal property which is normally used for personal, family, 287 | or household purposes, or (2) anything designed or sold for incorporation 288 | into a dwelling. In determining whether a product is a consumer product, 289 | doubtful cases shall be resolved in favor of coverage. For a particular 290 | product received by a particular user, "normally used" refers to a 291 | typical or common use of that class of product, regardless of the status 292 | of the particular user or of the way in which the particular user 293 | actually uses, or expects or is expected to use, the product. A product 294 | is a consumer product regardless of whether the product has substantial 295 | commercial, industrial or non-consumer uses, unless such uses represent 296 | the only significant mode of use of the product. 297 | 298 | "Installation Information" for a User Product means any methods, 299 | procedures, authorization keys, or other information required to install 300 | and execute modified versions of a covered work in that User Product from 301 | a modified version of its Corresponding Source. The information must 302 | suffice to ensure that the continued functioning of the modified object 303 | code is in no case prevented or interfered with solely because 304 | modification has been made. 305 | 306 | If you convey an object code work under this section in, or with, or 307 | specifically for use in, a User Product, and the conveying occurs as 308 | part of a transaction in which the right of possession and use of the 309 | User Product is transferred to the recipient in perpetuity or for a 310 | fixed term (regardless of how the transaction is characterized), the 311 | Corresponding Source conveyed under this section must be accompanied 312 | by the Installation Information. But this requirement does not apply 313 | if neither you nor any third party retains the ability to install 314 | modified object code on the User Product (for example, the work has 315 | been installed in ROM). 316 | 317 | The requirement to provide Installation Information does not include a 318 | requirement to continue to provide support service, warranty, or updates 319 | for a work that has been modified or installed by the recipient, or for 320 | the User Product in which it has been modified or installed. Access to a 321 | network may be denied when the modification itself materially and 322 | adversely affects the operation of the network or violates the rules and 323 | protocols for communication across the network. 324 | 325 | Corresponding Source conveyed, and Installation Information provided, 326 | in accord with this section must be in a format that is publicly 327 | documented (and with an implementation available to the public in 328 | source code form), and must require no special password or key for 329 | unpacking, reading or copying. 330 | 331 | 7. Additional Terms. 332 | 333 | "Additional permissions" are terms that supplement the terms of this 334 | License by making exceptions from one or more of its conditions. 335 | Additional permissions that are applicable to the entire Program shall 336 | be treated as though they were included in this License, to the extent 337 | that they are valid under applicable law. If additional permissions 338 | apply only to part of the Program, that part may be used separately 339 | under those permissions, but the entire Program remains governed by 340 | this License without regard to the additional permissions. 341 | 342 | When you convey a copy of a covered work, you may at your option 343 | remove any additional permissions from that copy, or from any part of 344 | it. (Additional permissions may be written to require their own 345 | removal in certain cases when you modify the work.) You may place 346 | additional permissions on material, added by you to a covered work, 347 | for which you have or can give appropriate copyright permission. 348 | 349 | Notwithstanding any other provision of this License, for material you 350 | add to a covered work, you may (if authorized by the copyright holders of 351 | that material) supplement the terms of this License with terms: 352 | 353 | a) Disclaiming warranty or limiting liability differently from the 354 | terms of sections 15 and 16 of this License; or 355 | 356 | b) Requiring preservation of specified reasonable legal notices or 357 | author attributions in that material or in the Appropriate Legal 358 | Notices displayed by works containing it; or 359 | 360 | c) Prohibiting misrepresentation of the origin of that material, or 361 | requiring that modified versions of such material be marked in 362 | reasonable ways as different from the original version; or 363 | 364 | d) Limiting the use for publicity purposes of names of licensors or 365 | authors of the material; or 366 | 367 | e) Declining to grant rights under trademark law for use of some 368 | trade names, trademarks, or service marks; or 369 | 370 | f) Requiring indemnification of licensors and authors of that 371 | material by anyone who conveys the material (or modified versions of 372 | it) with contractual assumptions of liability to the recipient, for 373 | any liability that these contractual assumptions directly impose on 374 | those licensors and authors. 375 | 376 | All other non-permissive additional terms are considered "further 377 | restrictions" within the meaning of section 10. If the Program as you 378 | received it, or any part of it, contains a notice stating that it is 379 | governed by this License along with a term that is a further 380 | restriction, you may remove that term. If a license document contains 381 | a further restriction but permits relicensing or conveying under this 382 | License, you may add to a covered work material governed by the terms 383 | of that license document, provided that the further restriction does 384 | not survive such relicensing or conveying. 385 | 386 | If you add terms to a covered work in accord with this section, you 387 | must place, in the relevant source files, a statement of the 388 | additional terms that apply to those files, or a notice indicating 389 | where to find the applicable terms. 390 | 391 | Additional terms, permissive or non-permissive, may be stated in the 392 | form of a separately written license, or stated as exceptions; 393 | the above requirements apply either way. 394 | 395 | 8. Termination. 396 | 397 | You may not propagate or modify a covered work except as expressly 398 | provided under this License. Any attempt otherwise to propagate or 399 | modify it is void, and will automatically terminate your rights under 400 | this License (including any patent licenses granted under the third 401 | paragraph of section 11). 402 | 403 | However, if you cease all violation of this License, then your 404 | license from a particular copyright holder is reinstated (a) 405 | provisionally, unless and until the copyright holder explicitly and 406 | finally terminates your license, and (b) permanently, if the copyright 407 | holder fails to notify you of the violation by some reasonable means 408 | prior to 60 days after the cessation. 409 | 410 | Moreover, your license from a particular copyright holder is 411 | reinstated permanently if the copyright holder notifies you of the 412 | violation by some reasonable means, this is the first time you have 413 | received notice of violation of this License (for any work) from that 414 | copyright holder, and you cure the violation prior to 30 days after 415 | your receipt of the notice. 416 | 417 | Termination of your rights under this section does not terminate the 418 | licenses of parties who have received copies or rights from you under 419 | this License. If your rights have been terminated and not permanently 420 | reinstated, you do not qualify to receive new licenses for the same 421 | material under section 10. 422 | 423 | 9. Acceptance Not Required for Having Copies. 424 | 425 | You are not required to accept this License in order to receive or 426 | run a copy of the Program. Ancillary propagation of a covered work 427 | occurring solely as a consequence of using peer-to-peer transmission 428 | to receive a copy likewise does not require acceptance. However, 429 | nothing other than this License grants you permission to propagate or 430 | modify any covered work. These actions infringe copyright if you do 431 | not accept this License. Therefore, by modifying or propagating a 432 | covered work, you indicate your acceptance of this License to do so. 433 | 434 | 10. Automatic Licensing of Downstream Recipients. 435 | 436 | Each time you convey a covered work, the recipient automatically 437 | receives a license from the original licensors, to run, modify and 438 | propagate that work, subject to this License. You are not responsible 439 | for enforcing compliance by third parties with this License. 440 | 441 | An "entity transaction" is a transaction transferring control of an 442 | organization, or substantially all assets of one, or subdividing an 443 | organization, or merging organizations. If propagation of a covered 444 | work results from an entity transaction, each party to that 445 | transaction who receives a copy of the work also receives whatever 446 | licenses to the work the party's predecessor in interest had or could 447 | give under the previous paragraph, plus a right to possession of the 448 | Corresponding Source of the work from the predecessor in interest, if 449 | the predecessor has it or can get it with reasonable efforts. 450 | 451 | You may not impose any further restrictions on the exercise of the 452 | rights granted or affirmed under this License. For example, you may 453 | not impose a license fee, royalty, or other charge for exercise of 454 | rights granted under this License, and you may not initiate litigation 455 | (including a cross-claim or counterclaim in a lawsuit) alleging that 456 | any patent claim is infringed by making, using, selling, offering for 457 | sale, or importing the Program or any portion of it. 458 | 459 | 11. Patents. 460 | 461 | A "contributor" is a copyright holder who authorizes use under this 462 | License of the Program or a work on which the Program is based. The 463 | work thus licensed is called the contributor's "contributor version". 464 | 465 | A contributor's "essential patent claims" are all patent claims 466 | owned or controlled by the contributor, whether already acquired or 467 | hereafter acquired, that would be infringed by some manner, permitted 468 | by this License, of making, using, or selling its contributor version, 469 | but do not include claims that would be infringed only as a 470 | consequence of further modification of the contributor version. For 471 | purposes of this definition, "control" includes the right to grant 472 | patent sublicenses in a manner consistent with the requirements of 473 | this License. 474 | 475 | Each contributor grants you a non-exclusive, worldwide, royalty-free 476 | patent license under the contributor's essential patent claims, to 477 | make, use, sell, offer for sale, import and otherwise run, modify and 478 | propagate the contents of its contributor version. 479 | 480 | In the following three paragraphs, a "patent license" is any express 481 | agreement or commitment, however denominated, not to enforce a patent 482 | (such as an express permission to practice a patent or covenant not to 483 | sue for patent infringement). To "grant" such a patent license to a 484 | party means to make such an agreement or commitment not to enforce a 485 | patent against the party. 486 | 487 | If you convey a covered work, knowingly relying on a patent license, 488 | and the Corresponding Source of the work is not available for anyone 489 | to copy, free of charge and under the terms of this License, through a 490 | publicly available network server or other readily accessible means, 491 | then you must either (1) cause the Corresponding Source to be so 492 | available, or (2) arrange to deprive yourself of the benefit of the 493 | patent license for this particular work, or (3) arrange, in a manner 494 | consistent with the requirements of this License, to extend the patent 495 | license to downstream recipients. "Knowingly relying" means you have 496 | actual knowledge that, but for the patent license, your conveying the 497 | covered work in a country, or your recipient's use of the covered work 498 | in a country, would infringe one or more identifiable patents in that 499 | country that you have reason to believe are valid. 500 | 501 | If, pursuant to or in connection with a single transaction or 502 | arrangement, you convey, or propagate by procuring conveyance of, a 503 | covered work, and grant a patent license to some of the parties 504 | receiving the covered work authorizing them to use, propagate, modify 505 | or convey a specific copy of the covered work, then the patent license 506 | you grant is automatically extended to all recipients of the covered 507 | work and works based on it. 508 | 509 | A patent license is "discriminatory" if it does not include within 510 | the scope of its coverage, prohibits the exercise of, or is 511 | conditioned on the non-exercise of one or more of the rights that are 512 | specifically granted under this License. You may not convey a covered 513 | work if you are a party to an arrangement with a third party that is 514 | in the business of distributing software, under which you make payment 515 | to the third party based on the extent of your activity of conveying 516 | the work, and under which the third party grants, to any of the 517 | parties who would receive the covered work from you, a discriminatory 518 | patent license (a) in connection with copies of the covered work 519 | conveyed by you (or copies made from those copies), or (b) primarily 520 | for and in connection with specific products or compilations that 521 | contain the covered work, unless you entered into that arrangement, 522 | or that patent license was granted, prior to 28 March 2007. 523 | 524 | Nothing in this License shall be construed as excluding or limiting 525 | any implied license or other defenses to infringement that may 526 | otherwise be available to you under applicable patent law. 527 | 528 | 12. No Surrender of Others' Freedom. 529 | 530 | If conditions are imposed on you (whether by court order, agreement or 531 | otherwise) that contradict the conditions of this License, they do not 532 | excuse you from the conditions of this License. If you cannot convey a 533 | covered work so as to satisfy simultaneously your obligations under this 534 | License and any other pertinent obligations, then as a consequence you may 535 | not convey it at all. For example, if you agree to terms that obligate you 536 | to collect a royalty for further conveying from those to whom you convey 537 | the Program, the only way you could satisfy both those terms and this 538 | License would be to refrain entirely from conveying the Program. 539 | 540 | 13. Remote Network Interaction; Use with the GNU General Public License. 541 | 542 | Notwithstanding any other provision of this License, if you modify the 543 | Program, your modified version must prominently offer all users 544 | interacting with it remotely through a computer network (if your version 545 | supports such interaction) an opportunity to receive the Corresponding 546 | Source of your version by providing access to the Corresponding Source 547 | from a network server at no charge, through some standard or customary 548 | means of facilitating copying of software. This Corresponding Source 549 | shall include the Corresponding Source for any work covered by version 3 550 | of the GNU General Public License that is incorporated pursuant to the 551 | following paragraph. 552 | 553 | Notwithstanding any other provision of this License, you have 554 | permission to link or combine any covered work with a work licensed 555 | under version 3 of the GNU General Public License into a single 556 | combined work, and to convey the resulting work. The terms of this 557 | License will continue to apply to the part which is the covered work, 558 | but the work with which it is combined will remain governed by version 559 | 3 of the GNU General Public License. 560 | 561 | 14. Revised Versions of this License. 562 | 563 | The Free Software Foundation may publish revised and/or new versions of 564 | the GNU Affero General Public License from time to time. Such new versions 565 | will be similar in spirit to the present version, but may differ in detail to 566 | address new problems or concerns. 567 | 568 | Each version is given a distinguishing version number. If the 569 | Program specifies that a certain numbered version of the GNU Affero General 570 | Public License "or any later version" applies to it, you have the 571 | option of following the terms and conditions either of that numbered 572 | version or of any later version published by the Free Software 573 | Foundation. If the Program does not specify a version number of the 574 | GNU Affero General Public License, you may choose any version ever published 575 | by the Free Software Foundation. 576 | 577 | If the Program specifies that a proxy can decide which future 578 | versions of the GNU Affero General Public License can be used, that proxy's 579 | public statement of acceptance of a version permanently authorizes you 580 | to choose that version for the Program. 581 | 582 | Later license versions may give you additional or different 583 | permissions. However, no additional obligations are imposed on any 584 | author or copyright holder as a result of your choosing to follow a 585 | later version. 586 | 587 | 15. Disclaimer of Warranty. 588 | 589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 597 | 598 | 16. Limitation of Liability. 599 | 600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 608 | SUCH DAMAGES. 609 | 610 | 17. Interpretation of Sections 15 and 16. 611 | 612 | If the disclaimer of warranty and limitation of liability provided 613 | above cannot be given local legal effect according to their terms, 614 | reviewing courts shall apply local law that most closely approximates 615 | an absolute waiver of all civil liability in connection with the 616 | Program, unless a warranty or assumption of liability accompanies a 617 | copy of the Program in return for a fee. 618 | 619 | END OF TERMS AND CONDITIONS 620 | 621 | How to Apply These Terms to Your New Programs 622 | 623 | If you develop a new program, and you want it to be of the greatest 624 | possible use to the public, the best way to achieve this is to make it 625 | free software which everyone can redistribute and change under these terms. 626 | 627 | To do so, attach the following notices to the program. It is safest 628 | to attach them to the start of each source file to most effectively 629 | state the exclusion of warranty; and each file should have at least 630 | the "copyright" line and a pointer to where the full notice is found. 631 | 632 | 633 | Copyright (C) 634 | 635 | This program is free software: you can redistribute it and/or modify 636 | it under the terms of the GNU Affero General Public License as published 637 | by the Free Software Foundation, either version 3 of the License, or 638 | (at your option) any later version. 639 | 640 | This program is distributed in the hope that it will be useful, 641 | but WITHOUT ANY WARRANTY; without even the implied warranty of 642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 643 | GNU Affero General Public License for more details. 644 | 645 | You should have received a copy of the GNU Affero General Public License 646 | along with this program. If not, see . 647 | 648 | Also add information on how to contact you by electronic and paper mail. 649 | 650 | If your software can interact with users remotely through a computer 651 | network, you should also make sure that it provides a way for users to 652 | get its source. For example, if your program is a web application, its 653 | interface could display a "Source" link that leads users to an archive 654 | of the code. There are many ways you could offer source, and different 655 | solutions will be better for different programs; see section 13 for the 656 | specific requirements. 657 | 658 | You should also get your employer (if you work as a programmer) or school, 659 | if any, to sign a "copyright disclaimer" for the program, if necessary. 660 | For more information on this, and how to apply and follow the GNU AGPL, see 661 | . 662 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | | Version | Supported | 6 | | ------- | ------------------ | 7 | | > 1.x.x | :white_check_mark: | 8 | | < 0.x.x | :x: | 9 | 10 | ## Reporting a Vulnerability 11 | 12 | If you discover a security vulnerability in this project, we strongly encourage you to report it privately. 13 | 14 | **Please do not create public GitHub issues or pull requests that contain security-related information.** 15 | 16 | Instead, please email your report via GitHub Vulnerability reporting: https://github.com/gautamkrishnar/blog-post-workflow/security/advisories/new 17 | 18 | I will review your report as quickly as possible and take appropriate action. 19 | 20 | ## Preferred Reporting Guidelines 21 | 22 | When reporting a vulnerability, please include as much information as possible, such as: 23 | 24 | - A clear description of the vulnerability 25 | - Steps to reproduce the issue 26 | - Potential impact 27 | - Any known mitigations or workarounds 28 | 29 | We appreciate your efforts in making this project more secure! 30 | 31 | --- 32 | 33 | Thank you for helping improve the security of this project. 34 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: 'Blog Post Workflow' 2 | author: 'Gautam Krishna R' 3 | description: 'Allows you to show your latest blog posts on your github profile or project readme' 4 | 5 | inputs: 6 | gh_token: 7 | description: 'GitHub access token with Repo scope' 8 | required: false 9 | default: ${{ github.token }} 10 | readme_path: 11 | description: 'Comma separated paths of the readme files you want to update' 12 | default: './README.md' 13 | required: false 14 | max_post_count: 15 | description: 'Maximum number of posts you want to show on your readme, all feeds combined' 16 | default: '5' 17 | required: false 18 | feed_list: 19 | description: "Comma separated list of RSS feed urls" 20 | default: "" 21 | required: true 22 | disable_sort: 23 | description: "Disables the sorting of list based on publish date" 24 | default: "false" 25 | required: false 26 | sort_order: 27 | description: "Specifies the sort order of posts when date sorting is enabled (disable_sort is 'false'). Supports 'asc' (ascending, oldest first) and 'desc' (descending, newest first). Has no effect if disable_sort is 'true'." 28 | default: "desc" 29 | required: false 30 | reverse_order: 31 | description: "Reverses the order of posts when `disable_sort` is set to true" 32 | default: "false" 33 | required: false 34 | filter_comments: 35 | description: "Comma separated list of platforms you want to enable the comment filter" 36 | default: "stackoverflow/Comment by $author/,stackexchange/Comment by $author/" 37 | required: false 38 | tag_post_pre_newline: 39 | description: "Inserts newline before the closing tag and after the opening tag when using the template option, for formatting" 40 | required: false 41 | template: 42 | description: "Template to use while creating the list of posts. It can contain $title,$url, $newline and $date as variables" 43 | default: "default" 44 | required: false 45 | date_format: 46 | description: "Allows you to change the format of the date or time displayed when using the $date in the template option" 47 | default: "UTC:ddd mmm dd yyyy h:MM TT" 48 | required: false 49 | comment_tag_name: 50 | description: "Override the default comment tag name, if you want to show multiple instances of the action on the same repo" 51 | required: false 52 | user_agent: 53 | description: "Allows you to customize the user agent used by the RSS feed crawler" 54 | default: "rss-parser" 55 | required: false 56 | accept_header: 57 | description: "Allows you to customize the accept header of the http request" 58 | default: "application/rss+xml" 59 | required: false 60 | custom_tags: 61 | description: "Allows you to use the custom tags from your feed items in your template" 62 | default: "" 63 | required: false 64 | title_max_length: 65 | description: "Allows you to trim the title in the posts list" 66 | default: "" 67 | required: false 68 | description_max_length: 69 | description: "Allows you to trim the description in the posts list" 70 | default: "" 71 | required: false 72 | item_exec: 73 | description: "Allows you to execute custom JavaScript code on each item to do advanced text manipulation" 74 | default: "" 75 | required: false 76 | commit_message: 77 | description: "Commit message used while committing to the repo" 78 | default: "Updated with the latest blog posts" 79 | required: false 80 | committer_username: 81 | description: "Username used while committing to the repo" 82 | default: "blog-post-bot" 83 | required: false 84 | committer_email: 85 | description: "Email id used while committing to the repo" 86 | default: "blog-post-bot@example.com" 87 | required: false 88 | output_only: 89 | description: "Prevent updating the readme, instead sets the output to the output variable named `results`" 90 | default: "false" 91 | required: false 92 | enable_keepalive: 93 | description: "Enables the feature that keeps the repo active by automatically committing to it even though there is no change" 94 | default: "true" 95 | required: false 96 | retry_count: 97 | description: "Maximum number of times to retry the fetch operation if it fails" 98 | default: "0" 99 | required: false 100 | retry_wait_time: 101 | description: "Time to wait before each retry operation in seconds" 102 | default: "1" 103 | required: false 104 | feed_names: 105 | description: "Comma separated name of the feeds to show on template" 106 | default: "" 107 | required: false 108 | disable_html_encoding: 109 | description: "Disables html encoding of the feed contents" 110 | default: "false" 111 | required: false 112 | categories_template: 113 | description: "Allows you to specify a template for the individual items in the category list" 114 | default: "default" 115 | required: false 116 | disable_item_validation: 117 | description: "Disables the validation checks for Title, publish date and URL" 118 | default: "false" 119 | required: false 120 | filter_dates: 121 | description: "Enables date filters" 122 | default: "" 123 | required: false 124 | rand_seed: 125 | description: "Provide your own seeding string for the randomness" 126 | default: "" 127 | required: false 128 | remove_duplicates: 129 | description: "Allows you to remove duplicate blog posts from multiple sources" 130 | default: "" 131 | required: false 132 | skip_commit: 133 | description: "Skips committing the changes to repo" 134 | default: "false" 135 | required: false 136 | dummy_commit_message: 137 | description: "Dummy commit message, This is when the workflow is doing automated commits to keep the repository active" 138 | default: "dummy commit to keep the repository active, see https://git.io/Jtm4V" 139 | required: false 140 | outputs: 141 | results: 142 | description: "JSON stringified array of posts" 143 | 144 | runs: 145 | using: node20 146 | main: dist/blog-post-workflow.js 147 | branding: 148 | icon: 'activity' 149 | color: 'blue' 150 | -------------------------------------------------------------------------------- /local-run.js: -------------------------------------------------------------------------------- 1 | const process = require('process'); 2 | const path = require('path'); 3 | const fs = require('fs'); 4 | const {DEFAULT_TEST_ENV} = require('./test/testUtils/default-env'); 5 | // language=markdown 6 | const template = `# Readme test 7 | Post list example: 8 | 9 | 10 | 11 | # Other contents 12 | Test content 13 | `; 14 | fs.writeFile(path.join(__dirname, 'test', 'Readme.md'), template, () => { 15 | console.log('Written test file....'); 16 | Object.assign(process.env, { 17 | ...DEFAULT_TEST_ENV, 18 | INPUT_README_PATH: path.join(__dirname, 'test', 'Readme.md') 19 | }); 20 | const testFile = process.env.DIST ? './dist/blog-post-workflow' : './src/blog-post-workflow'; 21 | console.log('Testing: ', testFile); 22 | const action = require(testFile); 23 | action.runWorkflow(); 24 | }); 25 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "blog-post-workflow", 3 | "version": "1.9.3", 4 | "description": "Allows you to show your latest blog posts on your github profile or project readme", 5 | "main": "blog-post-workflow.js", 6 | "scripts": { 7 | "build": "esbuild ./src/blog-post-workflow.js --bundle --platform=node --outfile=dist/blog-post-workflow.js", 8 | "lint": "jshint --exclude='node_modules/' *.js", 9 | "start-server": "node test/testUtils/test-server.js", 10 | "local-run-script": "node local-run.js", 11 | "local-run": "start-server-and-test start-server http://localhost:8080 local-run-script", 12 | "test-run": "mocha --parallel --reporter json --reporter-option output=src-report.json --jobs 100 test/**.js", 13 | "test": "yarn run lint && start-server-and-test start-server http://localhost:8080 test-run", 14 | "test-run-dist": "DIST=true mocha --parallel --reporter json --reporter-option output=dist-report.json --jobs 100 test/**.js", 15 | "test-dist": "yarn run lint && start-server-and-test start-server http://localhost:8080 test-run-dist" 16 | }, 17 | "repository": { 18 | "type": "git", 19 | "url": "git+https://github.com/gautamkrishnar/blog-post-workflow.git" 20 | }, 21 | "keywords": [ 22 | "github", 23 | "workflow", 24 | "blog", 25 | "posts" 26 | ], 27 | "author": "Gautam krishna R (https://www.github.com/gautamkrishnar)", 28 | "license": "GPL-3.0", 29 | "bugs": { 30 | "url": "https://github.com/gautamkrishnar/blog-post-workflow/issues" 31 | }, 32 | "homepage": "https://github.com/gautamkrishnar/blog-post-workflow#readme", 33 | "dependencies": { 34 | "@actions/core": "^1.11.1", 35 | "dateformat": "^3.0.3", 36 | "esbuild": "^0.25.2", 37 | "keepalive-workflow": "^2.0.9", 38 | "process": "latest", 39 | "promise-retry": "^2.0.1", 40 | "random-seed": "^0.3.0", 41 | "rss-parser": "^3.13.0" 42 | }, 43 | "devDependencies": { 44 | "jshint": "^2.13.6", 45 | "mocha": "^11.1.0", 46 | "start-server-and-test": "^2.0.11" 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/blog-post-workflow.js: -------------------------------------------------------------------------------- 1 | const process = require('process'); 2 | let Parser = require('rss-parser'); 3 | const core = require('@actions/core'); 4 | const fs = require('fs'); 5 | const dateFormat = require('dateformat'); 6 | const rand = require('random-seed'); 7 | const promiseRetry = require('promise-retry'); 8 | const keepaliveWorkflow = require('keepalive-workflow'); 9 | const { 10 | updateAndParseCompoundParams, 11 | commitReadme, 12 | truncateString, 13 | buildReadme, 14 | exec, 15 | getParameterisedTemplate, 16 | escapeHTML, 17 | categoriesToArray 18 | } = require('./utils'); 19 | const { 20 | ignoreStackExchangeComments, 21 | ignoreMediumComments, 22 | ignoreStackOverflowComments, 23 | dateFilter 24 | } = require('./filters'); 25 | const path = require('path'); 26 | 27 | // Blog workflow code 28 | const userAgent = core.getInput('user_agent'); 29 | const acceptHeader = core.getInput('accept_header'); 30 | 31 | // Total no of posts to display on readme, all sources combined, default: 5 32 | const TOTAL_POST_COUNT = Number.parseInt(core.getInput('max_post_count')); 33 | 34 | // Disables sort 35 | const ENABLE_SORT = core.getInput('disable_sort') === 'false'; 36 | 37 | // Specifies sort order 38 | const SORT_ORDER = core.getInput('sort_order'); // 'asc' or 'desc 39 | 40 | // Specifies sort order 41 | const REVERSE_ORDER = core.getInput('reverse_order') !== 'false'; 42 | 43 | // Disables validation checks 44 | const ENABLE_VALIDATION = core.getInput('disable_item_validation') === 'false'; 45 | 46 | // Title trimming parameter, default: "" 47 | const TITLE_MAX_LENGTH = core.getInput('title_max_length') ? 48 | Number.parseInt(core.getInput('title_max_length')) : null; 49 | 50 | // Description trimming parameter, default: "" 51 | const DESCRIPTION_MAX_LENGTH = core.getInput('description_max_length') ? 52 | Number.parseInt(core.getInput('description_max_length')) : null; 53 | 54 | // Advanced content modification parameter, default: "" 55 | const ITEM_EXEC = core.getInput('item_exec'); 56 | 57 | // Readme path, default: ./README.md 58 | const README_FILE_PATH_LIST = core.getInput('readme_path') 59 | .split(',') 60 | .map(item => item.trim()); 61 | const GITHUB_TOKEN = core.getInput('gh_token'); 62 | 63 | // Custom tags 64 | const CUSTOM_TAGS = {}; 65 | 66 | // Keepalive flag 67 | const ENABLE_KEEPALIVE = core.getInput('enable_keepalive') === 'true'; 68 | 69 | // Skip commit flag 70 | const SKIP_COMMITS = core.getInput('skip_commit') === 'true'; 71 | 72 | // Retry configuration 73 | const retryConfig = { 74 | retries: Number.parseInt(core.getInput('retry_count')), 75 | factor: 1, 76 | minTimeout: Number.parseInt(core.getInput('retry_wait_time')) * 1000 77 | }; 78 | 79 | core.setSecret(GITHUB_TOKEN); 80 | 81 | core.getInput('custom_tags') 82 | .trim() 83 | .split(',') 84 | .forEach((item) => { 85 | item = item.trim(); 86 | updateAndParseCompoundParams(item, CUSTOM_TAGS); // Creates custom tag object 87 | }); 88 | 89 | const promiseArray = []; // Runner 90 | const runnerNameArray = []; // To show the error/success message 91 | let postsArray = []; // Array to store posts 92 | let jobFailFlag = false; // Job status flag 93 | 94 | const feedObjString = core.getInput('feed_list').trim(); 95 | 96 | // Reading feed list from the workflow input 97 | let feedList = feedObjString.split(',').map(item => item.trim()); 98 | if (feedList.length === 0) { 99 | core.error('Please double check the value of feed_list'); 100 | process.exit(1); 101 | } 102 | 103 | // Grabbing feed names and converting it into array 104 | const feedNames = core.getInput('feed_names').trim(); 105 | const feedNamesList = feedNames.split(',').map(item => item.trim()); 106 | 107 | const customTagArgs = Object.keys(CUSTOM_TAGS).map( 108 | item => [CUSTOM_TAGS[item], item]); 109 | 110 | let parser = new Parser({ 111 | 'headers': { 112 | 'User-Agent': userAgent, 113 | 'Accept': acceptHeader 114 | }, 115 | customFields: { 116 | item: [...customTagArgs] 117 | } 118 | }); 119 | 120 | // Generating promise array 121 | feedList.forEach((siteUrl) => { 122 | runnerNameArray.push(siteUrl); 123 | promiseArray.push(new Promise((resolve, reject) => { 124 | promiseRetry((retry, tryNumber) => { 125 | // Retry block 126 | if (tryNumber > 1) { 127 | core.info(`Previous try for ${siteUrl} failed, retrying: ${tryNumber - 1}`); 128 | } 129 | return parser.parseURL(siteUrl) 130 | .catch(retry); 131 | }, retryConfig) 132 | .then((data) => { 133 | if (!data.items) { 134 | reject('Cannot read response->item'); 135 | } else { 136 | const responsePosts = data.items; 137 | // To handle duplicate filter 138 | const appendedPostTitles = []; 139 | const appendedPostDesc = []; 140 | const posts = responsePosts 141 | .filter(ignoreStackOverflowComments) 142 | .filter(ignoreStackExchangeComments) 143 | .filter(dateFilter) 144 | .map((item) => { 145 | // Validating keys to avoid errors 146 | if (ENABLE_SORT && ENABLE_VALIDATION && !item.pubDate) { 147 | reject('Cannot read response->item->pubDate'); 148 | } 149 | 150 | // Handle missing titles gracefully 151 | if (ENABLE_VALIDATION && !item.title) { 152 | // Either skip the item by returning null 153 | // or use a fallback title (from URL or a default value) 154 | core.warning(`Missing title for item with link: ${item.link || 'unknown'}`); 155 | if (core.getInput('skip_items_without_title') === 'true') { 156 | return null; // This item will be filtered out later 157 | } 158 | // Use URL as fallback or a default text 159 | item.title = item.link ? 160 | `[No Title] - ${item.link.split('/').pop() || 'Post'}` : 161 | 'Post without title'; 162 | } 163 | 164 | if (ENABLE_VALIDATION && !item.link) { 165 | reject('Cannot read response->item->link'); 166 | } 167 | // Custom tags 168 | let customTags = {}; 169 | Object.keys(CUSTOM_TAGS).forEach((tag) => { 170 | if (item[tag]) { 171 | Object.assign(customTags, {[tag]: item[tag]}); 172 | } 173 | }); 174 | const categories = item.categories ? categoriesToArray(item.categories) : []; 175 | let post = { 176 | title: item.title ? item.title.trim() : item.title, // Handle null safely 177 | url: item.link.trim(), 178 | description: item.content ? item.content : '', 179 | ...customTags, 180 | categories 181 | }; 182 | 183 | if (ENABLE_SORT) { 184 | post.date = new Date(item.pubDate.trim()); 185 | } 186 | 187 | if (TITLE_MAX_LENGTH && post && post.title) { 188 | // Trimming the title 189 | post.title = truncateString(post.title, TITLE_MAX_LENGTH); 190 | } 191 | 192 | if (DESCRIPTION_MAX_LENGTH && post && post.description) { 193 | // Trimming the description 194 | post.description = truncateString(post.description, DESCRIPTION_MAX_LENGTH); 195 | } 196 | 197 | // Advanced content manipulation using javascript code 198 | if (ITEM_EXEC) { 199 | try { 200 | eval(ITEM_EXEC); 201 | } catch (e) { 202 | core.error('Failure in executing `item_exec` parameter'); 203 | core.error(e); 204 | process.exit(1); 205 | } 206 | } 207 | if (post && core.getInput('remove_duplicates') === 'true') { 208 | if ( 209 | appendedPostTitles.indexOf(post.title.trim()) !== -1 || 210 | appendedPostDesc.indexOf(post.description.trim()) !== -1 211 | ) { 212 | post = null; 213 | } else { 214 | if (post.title) { 215 | appendedPostTitles.push(post.title.trim()); 216 | } 217 | if (post.description) { 218 | appendedPostDesc.push(post.description.trim()); 219 | } 220 | } 221 | } 222 | 223 | // Doing HTML encoding at last ref: #117 224 | const disableHtmlEncoding = core.getInput('disable_html_encoding') !== 'false'; 225 | if (!disableHtmlEncoding && post) { 226 | Object.keys(post).forEach((key)=> { 227 | if (typeof post[key] === 'string' && key !== 'url') { 228 | post[key] = escapeHTML(post[key]); 229 | } 230 | }); 231 | } 232 | return post; 233 | }); 234 | resolve(posts); 235 | } 236 | }, (err) => { 237 | reject(err); 238 | }); 239 | })); 240 | }); 241 | 242 | const runWorkflow = async () => { 243 | // Processing the generated promises 244 | await Promise.allSettled(promiseArray).then((results) => { 245 | results.forEach((result, index) => { 246 | if (result.status === 'fulfilled') { 247 | // Succeeded 248 | core.info(runnerNameArray[index] + ' runner succeeded. Post count: ' + result.value.length); 249 | // Adds feed name to the items 250 | if (typeof feedNamesList[index] !== undefined && feedNamesList[index]) { 251 | result.value = result.value.map((item) => { 252 | item.feedName = feedNamesList[index]; 253 | return item; 254 | }); 255 | } 256 | postsArray.push(...result.value); 257 | } else { 258 | jobFailFlag = true; 259 | // Rejected 260 | core.error(runnerNameArray[index] + ' runner failed, please verify the configuration. Error:'); 261 | if (result.reason && result.reason.message && result.reason.message.startsWith('Status code')) { 262 | const code = result.reason.message.replace('Status code ', ''); 263 | core.error(`Looks like your website returned ${code}, There is nothing blog post workflow ` + 264 | `can do to fix it. Please check your website's RSS feed generation source code. Also double check ` + 265 | `the URL. If you are using a third party blogging platform, please reach out to the platform's support ` + 266 | `team and ask them why this is failing.`); 267 | if (code === `503`) { 268 | core.error(`If you are using Cloudflare or Akamai, make sure that you have the user agent ` + 269 | ` ${userAgent} or GitHub actions IP ranges whitelisted in your firewall.`); 270 | } 271 | } else { 272 | core.error(result.reason || result.reason.message); 273 | } 274 | } 275 | }); 276 | }).finally(async () => { 277 | // Ignore null items, allows you to ignore items by setting null in post via `item_exec` 278 | postsArray = postsArray.filter(item => item !== null); 279 | 280 | // Sorting posts based on date 281 | if (ENABLE_SORT) { 282 | postsArray.sort(function (a, b) { 283 | // Handle items without dates consistently by moving them to the end 284 | const aHasDate = !!a.date; 285 | const bHasDate = !!b.date; 286 | 287 | if (!aHasDate && !bHasDate) return 0; // Keep original relative order for items without dates 288 | if (!aHasDate) return 1; // 'a' (no date) comes after 'b' (has date) 289 | if (!bHasDate) return -1; // 'b' (no date) comes after 'a' (has date) 290 | 291 | // Both items have dates, sort according to SORT_ORDER 292 | if (SORT_ORDER === 'asc') { 293 | return a.date - b.date; // Sorts ascending by date (oldest first) 294 | } else { 295 | return b.date - a.date; // Sorts descending by date (newest first) by default 296 | } 297 | }); 298 | } 299 | // If ENABLE_SORT is false 300 | else if (REVERSE_ORDER) { 301 | postsArray.reverse(); 302 | } 303 | 304 | // Slicing with the max count 305 | postsArray = postsArray.slice(0, TOTAL_POST_COUNT); 306 | if (postsArray.length > 0) { 307 | try { 308 | if (!process.env.TEST_MODE) { 309 | await exec('git', ['config', 'pull.rebase', 'true'], {stdio: ['pipe', 'pipe', 'pipe']}); 310 | // Pulling the latest changes from upstream 311 | await exec('git', ['pull'], {stdio: ['pipe', 'pipe', 'pipe']}); 312 | } 313 | const template = core.getInput('template'); 314 | const randEmojiArr = getParameterisedTemplate(template, 'randomEmoji'); 315 | const constEmojiArr = getParameterisedTemplate(template, 'emojiKey'); 316 | const postListMarkdown = postsArray.reduce((acc, cur, index) => { 317 | if (template === 'default') { 318 | // Default template: - [$title]($url) 319 | return acc + `\n- [${cur.title}](${cur.url})` + (((index + 1) === postsArray.length) ? '\n' : ''); 320 | } else { 321 | // Building categories listing 322 | const categoryTemplate = core.getInput('categories_template'); 323 | const categoryList = categoryTemplate === 'default' ? 324 | cur.categories.join(', ') : cur.categories.reduce((prev, current) => 325 | prev + categoryTemplate.replace(/\$category\b/g, current.toString()), ''); 326 | // Building with custom template 327 | const date = dateFormat(cur.date, core.getInput('date_format')); // Formatting date 328 | let content = template 329 | .replace(/\$title\b/g, cur.title) 330 | .replace(/\$url\b/g, cur.url) 331 | .replace(/\$description\b/g, cur.description) 332 | .replace(/\$date\b/g, date) 333 | .replace(/\$counter\b/g, (index + 1).toString()) 334 | .replace(/\$feedName\b/g, cur.feedName ? cur.feedName : '') 335 | .replace(/\$categories\b/g, categoryList.toString()) 336 | .replace(/\$newline/g, '\n'); 337 | 338 | // Setting Custom tags to the template 339 | Object.keys(CUSTOM_TAGS).forEach((tag) => { 340 | const replaceValue = cur[tag] ? cur[tag] : ''; 341 | content = content.replace(new RegExp('\\$' + tag + '\\b', 'g'), replaceValue); 342 | }); 343 | 344 | // Emoji implementation: Random 345 | if (randEmojiArr) { 346 | // For making randomness unique for each repos 347 | let seed = (process.env.GITHUB_REPOSITORY && !process.env.TEST_MODE ? 348 | process.env.GITHUB_REPOSITORY : 'example') + index; 349 | if (core.getInput('rand_seed')) { 350 | // If manual seed is provided, use it 351 | seed = core.getInput('rand_seed') + index; 352 | } 353 | const emoji = randEmojiArr[rand.create(seed).range(randEmojiArr.length)]; 354 | content = content.replace(/\$randomEmoji\((\S)*\)/g, emoji); 355 | } 356 | 357 | // Emoji implementation: Static 358 | if (constEmojiArr) { 359 | // using modulus 360 | content = content.replace(/\$emojiKey\((\S)*\)/g, constEmojiArr[index % constEmojiArr.length]); 361 | } 362 | 363 | return acc + content; 364 | } 365 | }, ''); 366 | 367 | // Output only mode 368 | const outputOnly = core.getInput('output_only') !== 'false'; 369 | if (outputOnly) { 370 | // Sets output as output as `results` variable in github action 371 | core.info('outputOnly mode: set `results` variable. Readme not committed.'); 372 | core.setOutput('results', postsArray); 373 | const outputFilePath = path.join('/','tmp', 'blog_post_workflow_output.json'); 374 | if(fs.existsSync(outputFilePath)) { 375 | fs.rmSync(outputFilePath); 376 | } 377 | fs.writeFileSync(outputFilePath, JSON.stringify(postsArray), { encoding: 'utf-8'}); 378 | process.exit(jobFailFlag ? 1 : 0); 379 | } 380 | 381 | // Writing to each readme file 382 | let changedReadmeCount = 0; 383 | README_FILE_PATH_LIST.forEach((README_FILE_PATH) => { 384 | const readmeData = fs.readFileSync(README_FILE_PATH, 'utf8'); 385 | const newReadme = buildReadme(readmeData, postListMarkdown); 386 | // if there's change in readme file update it 387 | if (newReadme !== readmeData) { 388 | core.info('Writing to ' + README_FILE_PATH); 389 | fs.writeFileSync(README_FILE_PATH, newReadme); 390 | changedReadmeCount = changedReadmeCount + 1; 391 | } 392 | }); 393 | 394 | if (changedReadmeCount > 0 && !SKIP_COMMITS) { 395 | if (!process.env.TEST_MODE) { 396 | // Commit to readme 397 | await commitReadme(GITHUB_TOKEN, README_FILE_PATH_LIST).then(() => { 398 | // Making job fail if one of the source fails 399 | process.exit(jobFailFlag ? 1 : 0); 400 | }); 401 | } 402 | } else { 403 | // Calculating last commit date, please see https://git.io/Jtm4V 404 | if (!process.env.TEST_MODE && ENABLE_KEEPALIVE) { 405 | // Do dummy commit if elapsed time is greater than 50 days 406 | const committerUsername = core.getInput('committer_username'); 407 | const committerEmail = core.getInput('committer_email'); 408 | const message = await keepaliveWorkflow.KeepAliveWorkflow(GITHUB_TOKEN, committerUsername, committerEmail, 409 | core.getInput('dummy_commit_message'), 50, true); 410 | core.info(message.toString()); 411 | } else { 412 | core.info('No change detected, skipping'); 413 | } 414 | process.exit(jobFailFlag ? 1 : 0); 415 | } 416 | } catch (e) { 417 | core.error(e); 418 | process.exit(1); 419 | } 420 | } else { 421 | core.info('0 blog posts fetched'); 422 | process.exit(jobFailFlag ? 1 : 0); 423 | } 424 | }); 425 | }; 426 | 427 | module.exports = { 428 | runWorkflow 429 | }; 430 | 431 | if (!module.parent) { 432 | runWorkflow().then(); 433 | } 434 | -------------------------------------------------------------------------------- /src/filters.js: -------------------------------------------------------------------------------- 1 | const {updateAndParseCompoundParams} = require('./utils'); 2 | const core = require('@actions/core'); 3 | const url = require("url"); 4 | 5 | const FILTER_PARAMS = { 6 | stackoverflow: 'Comment by $author', 7 | stackexchange: 'Comment by $author', 8 | }; 9 | 10 | const COMMENT_FILTERS = core 11 | .getInput('filter_comments') 12 | .trim() 13 | .split(',') 14 | .map((item) => { 15 | item = item.trim(); 16 | if (item.startsWith('stackoverflow') || item.startsWith('stackexchange')) { 17 | return updateAndParseCompoundParams(item, FILTER_PARAMS); 18 | } else { 19 | return item; 20 | } 21 | }); 22 | 23 | const parseUrlAndCheckItem = (item, domain) => { 24 | try { 25 | return url.parse(item.link).host === domain; 26 | } catch(e) { 27 | return false; 28 | } 29 | }; 30 | 31 | // filters out stackOverflow comments (#16) 32 | const ignoreStackOverflowComments = (item) => !(COMMENT_FILTERS.indexOf('stackoverflow') !== -1 && 33 | item.link && parseUrlAndCheckItem(item,'stackoverflow.com') && 34 | item.title.startsWith(FILTER_PARAMS.stackoverflow.replace(/\$author/g, item.author))); 35 | 36 | // filters out stackExchange comments (#16) 37 | const ignoreStackExchangeComments = (item) => !(COMMENT_FILTERS.indexOf('stackexchange') !== -1 && 38 | item.link && parseUrlAndCheckItem(item, 'stackexchange.com') && 39 | item.title.startsWith(FILTER_PARAMS.stackexchange.replace(/\$author/g, item.author))); 40 | 41 | const dateFilter = (item) => { 42 | if (!item.pubDate) { return true; } 43 | const today = new Date(); 44 | const itemDate = new Date(item.pubDate.trim()); 45 | const dateFilter = core 46 | .getInput('filter_dates') 47 | .trim(); 48 | 49 | if (dateFilter.indexOf('daysAgo') !== -1) { 50 | // Filters out posts that are older than n days 51 | const filterParam = { 52 | daysAgo: '' 53 | }; 54 | updateAndParseCompoundParams(dateFilter, filterParam); 55 | const dayInMilliSeconds = 24 * 60 * 60 * 1000; 56 | const daysAgo = Number(filterParam.daysAgo); 57 | const dateObj = new Date(Date.now() - (dayInMilliSeconds * daysAgo)); 58 | return itemDate >= dateObj; 59 | } else if (dateFilter.indexOf('currentMonth') !== -1) { 60 | // Filters out current month's posts 61 | return (itemDate.getMonth() === today.getMonth()) && (itemDate.getFullYear() === today.getFullYear()); 62 | } else if (dateFilter.indexOf('currentYear') !== -1) { 63 | // Filters out current year's posts 64 | return itemDate.getFullYear() === today.getFullYear(); 65 | } else { 66 | return true; 67 | } 68 | }; 69 | module.exports = { 70 | ignoreStackOverflowComments, 71 | ignoreStackExchangeComments, 72 | dateFilter 73 | }; 74 | -------------------------------------------------------------------------------- /src/utils.js: -------------------------------------------------------------------------------- 1 | const {spawn} = require('child_process'); 2 | const core = require('@actions/core'); 3 | 4 | /** 5 | * Executes a command and returns its result as promise 6 | * @param cmd {string} command to execute 7 | * @param args {array} command line args 8 | * @param options {Object} extra options 9 | * @return {Promise} 10 | */ 11 | const exec = (cmd, args = [], options = {}) => new Promise((resolve, reject) => { 12 | let outputData = ''; 13 | const optionsToCLI = { 14 | ...options 15 | }; 16 | if (!optionsToCLI.stdio) { 17 | Object.assign(optionsToCLI, {stdio: ['inherit', 'inherit', 'inherit']}); 18 | } 19 | const app = spawn(cmd, args, optionsToCLI); 20 | if (app.stdout) { 21 | // Only needed for pipes 22 | app.stdout.on('data', function (data) { 23 | outputData += data.toString(); 24 | }); 25 | } 26 | 27 | app.on('close', (code) => { 28 | if (code !== 0) { 29 | return reject({code, outputData}); 30 | } 31 | return resolve({code, outputData}); 32 | }); 33 | app.on('error', () => reject({code: 1, outputData})); 34 | }); 35 | 36 | /** 37 | * Builds the new readme by replacing the readme's tags 38 | * @param previousContent {string} actual readme content 39 | * @param newContent {string} content to add 40 | * @return {string}: content after combining previousContent and newContent 41 | */ 42 | const buildReadme = (previousContent, newContent) => { 43 | const tagNameInput = core.getInput('comment_tag_name'); 44 | const tagToLookFor = tagNameInput ? `'; 46 | const tagNewlineFlag = core.getInput('tag_post_pre_newline') === 'true'; 47 | const startOfOpeningTagIndex = previousContent.indexOf( 48 | `${tagToLookFor}START`, 49 | ); 50 | const endOfOpeningTagIndex = previousContent.indexOf( 51 | closingTag, 52 | startOfOpeningTagIndex, 53 | ); 54 | const startOfClosingTagIndex = previousContent.indexOf( 55 | `${tagToLookFor}END`, 56 | endOfOpeningTagIndex, 57 | ); 58 | if ( 59 | startOfOpeningTagIndex === -1 || 60 | endOfOpeningTagIndex === -1 || 61 | startOfClosingTagIndex === -1 62 | ) { 63 | // Exit with error if comment is not found on the readme 64 | core.error( 65 | `Cannot find the comment tag on the readme:\n${tagToLookFor}START -->\n${tagToLookFor}END -->` 66 | ); 67 | process.exit(1); 68 | } 69 | return [ 70 | previousContent.slice(0, endOfOpeningTagIndex + closingTag.length), 71 | tagNewlineFlag ? '\n' : '', 72 | newContent, 73 | tagNewlineFlag ? '\n' : '', 74 | previousContent.slice(startOfClosingTagIndex), 75 | ].join(''); 76 | }; 77 | 78 | /** 79 | * Unicode aware javascript truncate 80 | * @param str {string} string to truncated 81 | * @param length {number} length to truncate 82 | * @return {string} truncated value 83 | */ 84 | const truncateString = (str, length) => { 85 | const trimmedString = str.trim(); 86 | const truncatedString = [...trimmedString].slice(0, length).join(''); 87 | return truncatedString === trimmedString ? 88 | trimmedString : truncatedString.trim() + '...'; 89 | }; 90 | 91 | /** 92 | * Code to do git commit 93 | * @param githubToken {string} github token 94 | * @param readmeFilePaths {string[]} path to the readme file 95 | * @return {Promise} 96 | */ 97 | const commitReadme = async (githubToken, readmeFilePaths) => { 98 | // Getting config 99 | const committerUsername = core.getInput('committer_username'); 100 | const committerEmail = core.getInput('committer_email'); 101 | const commitMessage = core.getInput('commit_message'); 102 | // Doing commit and push 103 | await exec('git', [ 104 | 'config', 105 | '--global', 106 | 'user.email', 107 | committerEmail, 108 | ]); 109 | if (githubToken) { 110 | // git remote set-url origin 111 | await exec('git', ['remote', 'set-url', 'origin', 112 | `https://${githubToken}@github.com/${process.env.GITHUB_REPOSITORY}.git`]); 113 | } 114 | await exec('git', ['config', '--global', 'user.name', committerUsername]); 115 | await exec('git', ['add', ...readmeFilePaths]); 116 | await exec('git', ['commit', '-m', commitMessage]); 117 | await exec('git', ['push']); 118 | core.info('Readme updated successfully in the upstream repository'); 119 | }; 120 | 121 | /** 122 | * Compound parameter parser, Updates obj with compound parameters and returns item name 123 | * @param sourceWithParam filter source with compound param eg: stackoverflow/Comment by $author/ 124 | * @param obj {Object} object to update 125 | * @return {string} actual source name eg: stackoverflow 126 | */ 127 | const updateAndParseCompoundParams = (sourceWithParam, obj) => { 128 | const param = sourceWithParam.split('/'); // Reading params ['stackoverflow','Comment by $author', ''] 129 | if (param.length === 3) { 130 | Object.assign(obj, {[param[0]]: param[1]}); 131 | return param[0];// Returning source name 132 | } else { 133 | return sourceWithParam; 134 | } 135 | }; 136 | 137 | /** 138 | * Returns parsed parameterised templates as array or return null 139 | * @param template 140 | * @param keyName 141 | * @return {null|string[]} 142 | */ 143 | const getParameterisedTemplate = (template, keyName) => { 144 | const key = '$' + keyName + '('; 145 | if (template.indexOf(key) > -1) { 146 | const startIndex = template.indexOf(key) + key.length; 147 | const endIndex = template.indexOf(')', startIndex); 148 | if (endIndex === -1) { 149 | return null; 150 | } 151 | return template.slice(startIndex, endIndex).split(',').map(item => item.trim()); 152 | } else { 153 | return null; 154 | } 155 | }; 156 | 157 | /*** 158 | * Returns html encoded version of some of the conflicting markdown special characters 159 | * @param str {string} string to escape 160 | * @return string 161 | */ 162 | const escapeHTML = str => str.replace(/[&<>')("]/g, 163 | (tag) => ({ 164 | '&': '&', 165 | '<': '<', 166 | '>': '>', 167 | '\'': ''', 168 | '"': '"', 169 | ')': ')', 170 | '(': '(' 171 | }[tag])); 172 | 173 | /** 174 | * @typedef CategoryObj 175 | * @property {string} _ 176 | */ 177 | 178 | /*** 179 | * Converts categories from RSS Spec to parseable arrays 180 | * https://validator.w3.org/feed/docs/rss2.html#ltcategorygtSubelementOfLtitemgt 181 | * @param categories {[CategoryObj] | [string]} 182 | * @returns {[string]} 183 | */ 184 | const categoriesToArray = (categories) => { 185 | const categoriesStr = []; 186 | if (Array.isArray(categories)) { 187 | categories.forEach((item) => { 188 | // C# 189 | // Controller 190 | if (typeof item === 'string') { 191 | categoriesStr.push(item); 192 | } 193 | // C# 194 | // Controller 195 | else if (typeof item === 'object' && item._) { 196 | categoriesStr.push(item._); 197 | } 198 | }); 199 | } 200 | return categoriesStr; 201 | }; 202 | 203 | module.exports = { 204 | updateAndParseCompoundParams, 205 | commitReadme, 206 | truncateString, 207 | buildReadme, 208 | exec, 209 | getParameterisedTemplate, 210 | escapeHTML, 211 | categoriesToArray 212 | }; 213 | -------------------------------------------------------------------------------- /test/.gitignore: -------------------------------------------------------------------------------- 1 | *.md 2 | snapshots/*.md 3 | -------------------------------------------------------------------------------- /test/categories-template.js: -------------------------------------------------------------------------------- 1 | const {DEFAULT_TEST_ENV} = require('./testUtils/default-env'); 2 | const {runAndCompareSnap} = require('./testUtils/testUtils'); 3 | describe('Generated readme with categories template', function () { 4 | it('should match the snapshot', async function () { 5 | const envObj = { 6 | ...process.env, 7 | ...DEFAULT_TEST_ENV, 8 | INPUT_FEED_LIST: 'http://localhost:8080', 9 | INPUT_TEMPLATE: '$categories', 10 | INPUT_CATEGORIES_TEMPLATE: '$category
' 11 | }; 12 | await runAndCompareSnap('Readme.categories.template.md', envObj); 13 | }); 14 | }); 15 | -------------------------------------------------------------------------------- /test/categories.js: -------------------------------------------------------------------------------- 1 | const {DEFAULT_TEST_ENV} = require('./testUtils/default-env'); 2 | const {runAndCompareSnap} = require('./testUtils/testUtils'); 3 | describe('Generated readme with categories names', function () { 4 | it('should match the snapshot', async function () { 5 | const envObj = { 6 | ...process.env, 7 | ...DEFAULT_TEST_ENV, 8 | INPUT_FEED_LIST: 'http://localhost:8080', 9 | INPUT_TEMPLATE: '$categories', 10 | }; 11 | await runAndCompareSnap('Readme.categories.md', envObj); 12 | }); 13 | }); 14 | -------------------------------------------------------------------------------- /test/counter.js: -------------------------------------------------------------------------------- 1 | const {DEFAULT_TEST_ENV} = require('./testUtils/default-env'); 2 | const {runAndCompareSnap} = require('./testUtils/testUtils'); 3 | describe('Generated readme with $counter template', function () { 4 | it('should match the snapshot', async function () { 5 | const envObj = { 6 | ...process.env, 7 | ...DEFAULT_TEST_ENV, 8 | INPUT_TEMPLATE: '- $counter $title' 9 | }; 10 | await runAndCompareSnap('Readme.counter.md', envObj); 11 | }); 12 | }); 13 | -------------------------------------------------------------------------------- /test/custom-template.js: -------------------------------------------------------------------------------- 1 | const {DEFAULT_TEST_ENV} = require('./testUtils/default-env'); 2 | const {runAndCompareSnap} = require('./testUtils/testUtils'); 3 | describe('Custom template readme generated', function () { 4 | it('should match the snapshot', async function () { 5 | const envObj = { 6 | ...process.env, 7 | ...DEFAULT_TEST_ENV, 8 | INPUT_TEMPLATE: '$newline[$title]($url): $date $description $newline' 9 | }; 10 | await runAndCompareSnap('Readme.custom.md', envObj); 11 | }); 12 | }); 13 | -------------------------------------------------------------------------------- /test/default.js: -------------------------------------------------------------------------------- 1 | const {DEFAULT_TEST_ENV} = require('./testUtils/default-env'); 2 | const {runAndCompareSnap} = require('./testUtils/testUtils'); 3 | describe('Default template readme generated', function () { 4 | it('should match the snapshot', async function () { 5 | const envObj = { 6 | ...DEFAULT_TEST_ENV 7 | }; 8 | await runAndCompareSnap('Readme.md', envObj); 9 | }); 10 | }); 11 | -------------------------------------------------------------------------------- /test/disable-sort-reverse.js: -------------------------------------------------------------------------------- 1 | const {DEFAULT_TEST_ENV} = require('./testUtils/default-env'); 2 | const {runAndCompareSnap} = require('./testUtils/testUtils'); 3 | 4 | describe('Disabled sort with desc order (disable_sort: true, sort_order: desc)', function () { 5 | it('should reverse feed order and be equal to the saved snapshot', async function () { 6 | const envObj = { 7 | ...process.env, 8 | ...DEFAULT_TEST_ENV, 9 | INPUT_DISABLE_SORT: 'true', 10 | INPUT_REVERSE_ORDER: 'true', 11 | INPUT_MAX_POST_COUNT: '3' 12 | }; 13 | await runAndCompareSnap('Readme.disable-sort-reverse-order.md', envObj); 14 | }); 15 | }); 16 | -------------------------------------------------------------------------------- /test/disable-sort.js: -------------------------------------------------------------------------------- 1 | const {DEFAULT_TEST_ENV} = require('./testUtils/default-env'); 2 | const {runAndCompareSnap} = require('./testUtils/testUtils'); 3 | describe('Sorting disabled readme', function () { 4 | it('should be equal to the saved snapshot', async function () { 5 | const envObj = { 6 | ...process.env, 7 | ...DEFAULT_TEST_ENV, 8 | INPUT_DISABLE_SORT: 'true' 9 | }; 10 | await runAndCompareSnap('Readme.sort.md', envObj); 11 | }); 12 | }); 13 | -------------------------------------------------------------------------------- /test/duplicate.js: -------------------------------------------------------------------------------- 1 | const {DEFAULT_TEST_ENV} = require('./testUtils/default-env'); 2 | const {runAndCompareSnap} = require('./testUtils/testUtils'); 3 | describe('Generated readme with remove duplicates flag', function () { 4 | it('should match the snapshot', async function () { 5 | const envObj = { 6 | ...process.env, 7 | ...DEFAULT_TEST_ENV, 8 | INPUT_FEED_LIST: 'http://localhost:8080/duplicates', 9 | INPUT_REMOVE_DUPLICATES: 'true' 10 | }; 11 | await runAndCompareSnap('Readme.removeDuplicates.md', envObj); 12 | }); 13 | }); 14 | -------------------------------------------------------------------------------- /test/emojikey.js: -------------------------------------------------------------------------------- 1 | const {DEFAULT_TEST_ENV} = require('./testUtils/default-env'); 2 | const {runAndCompareSnap} = require('./testUtils/testUtils'); 3 | describe('Generated readme with $emojiKey template', function () { 4 | it('should match the snapshot', async function () { 5 | const envObj = { 6 | ...process.env, 7 | ...DEFAULT_TEST_ENV, 8 | INPUT_TEMPLATE: '- $emojiKey(💯,🔥)' 9 | }; 10 | await runAndCompareSnap('Readme.emojiKey.md', envObj); 11 | }); 12 | }); 13 | -------------------------------------------------------------------------------- /test/feed-names.js: -------------------------------------------------------------------------------- 1 | const {DEFAULT_TEST_ENV} = require('./testUtils/default-env'); 2 | const {runAndCompareSnap} = require('./testUtils/testUtils'); 3 | describe('Generated readme with feed names', function () { 4 | it('should match the snapshot', async function () { 5 | const envObj = { 6 | ...process.env, 7 | ...DEFAULT_TEST_ENV, 8 | INPUT_FEED_LIST: 'http://localhost:8080,http://localhost:8080,http://localhost:8080', 9 | INPUT_FEED_NAMES: 'hello,,world', 10 | INPUT_TEMPLATE: '$newline - $feedName -> $title ', 11 | INPUT_MAX_POST_COUNT: '100', 12 | }; 13 | await runAndCompareSnap('Readme.feedNames.md', envObj); 14 | }); 15 | }); 16 | -------------------------------------------------------------------------------- /test/js-manipulation.js: -------------------------------------------------------------------------------- 1 | const {DEFAULT_TEST_ENV} = require('./testUtils/default-env'); 2 | const {runAndCompareSnap} = require('./testUtils/testUtils'); 3 | describe('Generated readme with advanced manipulation via JS', function () { 4 | it('should match the snapshot', async function () { 5 | const envObj = { 6 | ...process.env, 7 | ...DEFAULT_TEST_ENV, 8 | INPUT_ITEM_EXEC: 'post.title=post.title.replace("Gautam",""); post.title=post.title.replace("browser","");' 9 | }; 10 | await runAndCompareSnap('Readme.exec.md', envObj); 11 | }); 12 | }); 13 | -------------------------------------------------------------------------------- /test/max-post-count.js: -------------------------------------------------------------------------------- 1 | const {DEFAULT_TEST_ENV} = require('./testUtils/default-env'); 2 | const {runAndCompareSnap} = require('./testUtils/testUtils'); 3 | describe('Generated readme with max post count', function () { 4 | it('should match the snapshot', async function () { 5 | const envObj = { 6 | ...process.env, 7 | ...DEFAULT_TEST_ENV, 8 | INPUT_MAX_POST_COUNT: '1' 9 | }; 10 | await runAndCompareSnap('Readme.maxPostCount.md', envObj); 11 | }); 12 | }); 13 | -------------------------------------------------------------------------------- /test/multiple.js: -------------------------------------------------------------------------------- 1 | const {DEFAULT_TEST_ENV} = require('./testUtils/default-env'); 2 | const path = require('path'); 3 | const fs = require('fs'); 4 | const assert = require('assert'); 5 | const {TEST_SNAP_DIR, TEMPLATE, TEST_FILE} = require("./testUtils/testUtils"); 6 | describe('Multiple readme generated via readme_path', function () { 7 | it('should match the snapshots', async function () { 8 | const readme1 = path.join(TEST_SNAP_DIR, 'Readme.multi.1.md'); 9 | const readme2 = path.join(TEST_SNAP_DIR, 'Readme.multi.2.md'); 10 | const envObj = { 11 | ...DEFAULT_TEST_ENV, 12 | INPUT_README_PATH: readme1 + ',' + readme2 13 | }; 14 | process.env = { 15 | ...process.env, 16 | ...envObj 17 | }; 18 | fs.writeFileSync(readme1, TEMPLATE); 19 | fs.writeFileSync(readme2, TEMPLATE); 20 | const workflow = await require(TEST_FILE); 21 | await workflow.runWorkflow(); 22 | const snapshot1 = fs.readFileSync(readme1 + '.snap', 'utf-8'); 23 | const snapshot2 = fs.readFileSync(readme2 + '.snap', 'utf-8'); 24 | const newReadme1 = fs.readFileSync(readme1, 'utf-8'); 25 | const newReadme2 = fs.readFileSync(readme2, 'utf-8'); 26 | assert.strictEqual(snapshot1, newReadme1); 27 | assert.strictEqual(snapshot2, newReadme2); 28 | }); 29 | }); 30 | -------------------------------------------------------------------------------- /test/random-emoji.js: -------------------------------------------------------------------------------- 1 | const {DEFAULT_TEST_ENV} = require('./testUtils/default-env'); 2 | const {runAndCompareSnap} = require('./testUtils/testUtils'); 3 | describe('Default template readme generated', function () { 4 | it('Generated readme with $randomEmoji template should match the snapshot', async function () { 5 | const envObj = { 6 | ...process.env, 7 | ...DEFAULT_TEST_ENV, 8 | INPUT_TEMPLATE: '- $randomEmoji(💯,🔥,💫,🚀,🌮)' 9 | }; 10 | await runAndCompareSnap('Readme.randomEmoji.md', envObj); 11 | }); 12 | }); 13 | -------------------------------------------------------------------------------- /test/retry.js: -------------------------------------------------------------------------------- 1 | const {DEFAULT_TEST_ENV} = require('./testUtils/default-env'); 2 | const {runAndCompareSnap} = require('./testUtils/testUtils'); 3 | describe('Readme generated after retry', function () { 4 | it('should match the snapshot', async function () { 5 | const envObj = { 6 | ...process.env, 7 | ...DEFAULT_TEST_ENV, 8 | INPUT_FEED_LIST: 'http://localhost:8080/failtest', 9 | INPUT_RETRY_COUNT: '5' 10 | }; 11 | await runAndCompareSnap('Readme.retry.md', envObj); 12 | }).timeout(20 * 1000); 13 | }); 14 | -------------------------------------------------------------------------------- /test/snapshots/Readme.categories.md.snap: -------------------------------------------------------------------------------- 1 | # Readme test 2 | Post list example: 3 | chrome, firefox, devtools, webdevtrick, chrome, privacy, httpsmicrosoft, student, partner, mspnumpy, python, introductionintroductionsduckduckgo, searching, tips, privacy 4 | 5 | # Other contents 6 | Test content 7 | -------------------------------------------------------------------------------- /test/snapshots/Readme.categories.template.md.snap: -------------------------------------------------------------------------------- 1 | # Readme test 2 | Post list example: 3 | chrome
firefox
devtools
webdev
trick
chrome
privacy
https
microsoft
student
partner
msp
numpy
python
introduction
introductions
duckduckgo
searching
tips
privacy
4 | 5 | # Other contents 6 | Test content 7 | -------------------------------------------------------------------------------- /test/snapshots/Readme.comments.md.snap: -------------------------------------------------------------------------------- 1 | # Readme test 2 | Post list example: 3 | 4 | - [God Mode in browsers: document.designMode = "on"](https://dev.to/gautamkrishnar/god-mode-in-browsers-document-designmode-on-2pmo) 5 | - [Skipping the Chrome "Your connection is not private" warning](https://dev.to/gautamkrishnar/quickbits-1-skipping-the-chrome-your-connection-is-not-private-warning-4kp1) 6 | - [Microsoft Student Partners – Geek is the new rockstar](https://dev.to/gautamkrishnar/microsoft-student-partners--geek-is-the-new-rockstar) 7 | - [An Introduction to NumPy](https://dev.to/gautamkrishnar/an-introduction-to-numpy) 8 | - [Comment by Gautam Krishna R on test](https://stackoverflow.com/questions/49310909/omniauth-facebook-login-does-not-work/49311637?cid=85720166#49311637) 9 | - [Hi, I'm Gautam krishna.R](https://dev.to/gautamkrishnar/hi-im-gautam-krishnar) 10 | - [DuckDuckGo – The search engine redefined](https://dev.to/gautamkrishnar/duckduckgo-the-search-engine-redefined-4c7d) 11 | 12 | 13 | # Other contents 14 | Test content 15 | -------------------------------------------------------------------------------- /test/snapshots/Readme.counter.md.snap: -------------------------------------------------------------------------------- 1 | # Readme test 2 | Post list example: 3 | - 1 God Mode in browsers: document.designMode = "on"- 2 Skipping the Chrome "Your connection is not private" warning- 3 Microsoft Student Partners – Geek is the new rockstar- 4 An Introduction to NumPy- 5 Hi, I'm Gautam krishna.R- 6 DuckDuckGo – The search engine redefined 4 | 5 | # Other contents 6 | Test content 7 | -------------------------------------------------------------------------------- /test/snapshots/Readme.custom-tags.md.snap: -------------------------------------------------------------------------------- 1 | # Readme test 2 | Post list example: 3 | God Mode in browsers: document.designMode = "on" https://dev.to/gautamkrishnar/god-mode-in-browsers-document-designmode-on-2pmo world 4 | Skipping the Chrome "Your connection is not private" warning https://dev.to/gautamkrishnar/quickbits-1-skipping-the-chrome-your-connection-is-not-private-warning-4kp1 5 | Microsoft Student Partners – Geek is the new rockstar https://dev.to/gautamkrishnar/microsoft-student-partners--geek-is-the-new-rockstar 6 | An Introduction to NumPy https://dev.to/gautamkrishnar/an-introduction-to-numpy 7 | Hi, I'm Gautam krishna.R https://dev.to/gautamkrishnar/hi-im-gautam-krishnar hello apple 8 | DuckDuckGo – The search engine redefined https://dev.to/gautamkrishnar/duckduckgo-the-search-engine-redefined-4c7d 9 | 10 | 11 | # Other contents 12 | Test content 13 | -------------------------------------------------------------------------------- /test/snapshots/Readme.disable-sort-reverse-order.md.snap: -------------------------------------------------------------------------------- 1 | # Readme test 2 | Post list example: 3 | 4 | - [An Introduction to NumPy](https://dev.to/gautamkrishnar/an-introduction-to-numpy) 5 | - [Skipping the Chrome "Your connection is not private" warning](https://dev.to/gautamkrishnar/quickbits-1-skipping-the-chrome-your-connection-is-not-private-warning-4kp1) 6 | - [DuckDuckGo – The search engine redefined](https://dev.to/gautamkrishnar/duckduckgo-the-search-engine-redefined-4c7d) 7 | 8 | 9 | # Other contents 10 | Test content 11 | -------------------------------------------------------------------------------- /test/snapshots/Readme.emojiKey.md.snap: -------------------------------------------------------------------------------- 1 | # Readme test 2 | Post list example: 3 | - 💯- 🔥- 💯- 🔥- 💯- 🔥 4 | 5 | # Other contents 6 | Test content 7 | -------------------------------------------------------------------------------- /test/snapshots/Readme.emptyTags.md.snap: -------------------------------------------------------------------------------- 1 | # Readme test 2 | Post list example: 3 | 4 | - []() 5 | 6 | 7 | # Other contents 8 | Test content 9 | -------------------------------------------------------------------------------- /test/snapshots/Readme.exec.md.snap: -------------------------------------------------------------------------------- 1 | # Readme test 2 | Post list example: 3 | 4 | - [God Mode in s: document.designMode = "on"](https://dev.to/gautamkrishnar/god-mode-in-browsers-document-designmode-on-2pmo) 5 | - [Skipping the Chrome "Your connection is not private" warning](https://dev.to/gautamkrishnar/quickbits-1-skipping-the-chrome-your-connection-is-not-private-warning-4kp1) 6 | - [Microsoft Student Partners – Geek is the new rockstar](https://dev.to/gautamkrishnar/microsoft-student-partners--geek-is-the-new-rockstar) 7 | - [An Introduction to NumPy](https://dev.to/gautamkrishnar/an-introduction-to-numpy) 8 | - [Hi, I'm krishna.R](https://dev.to/gautamkrishnar/hi-im-gautam-krishnar) 9 | - [DuckDuckGo – The search engine redefined](https://dev.to/gautamkrishnar/duckduckgo-the-search-engine-redefined-4c7d) 10 | 11 | 12 | # Other contents 13 | Test content 14 | -------------------------------------------------------------------------------- /test/snapshots/Readme.feedNames.md.snap: -------------------------------------------------------------------------------- 1 | # Readme test 2 | Post list example: 3 | 4 | - hello -> God Mode in browsers: document.designMode = "on" 5 | - -> God Mode in browsers: document.designMode = "on" 6 | - world -> God Mode in browsers: document.designMode = "on" 7 | - hello -> Skipping the Chrome "Your connection is not private" warning 8 | - -> Skipping the Chrome "Your connection is not private" warning 9 | - world -> Skipping the Chrome "Your connection is not private" warning 10 | - hello -> Microsoft Student Partners – Geek is the new rockstar 11 | - -> Microsoft Student Partners – Geek is the new rockstar 12 | - world -> Microsoft Student Partners – Geek is the new rockstar 13 | - hello -> An Introduction to NumPy 14 | - -> An Introduction to NumPy 15 | - world -> An Introduction to NumPy 16 | - hello -> Hi, I'm Gautam krishna.R 17 | - -> Hi, I'm Gautam krishna.R 18 | - world -> Hi, I'm Gautam krishna.R 19 | - hello -> DuckDuckGo – The search engine redefined 20 | - -> DuckDuckGo – The search engine redefined 21 | - world -> DuckDuckGo – The search engine redefined 22 | 23 | # Other contents 24 | Test content 25 | -------------------------------------------------------------------------------- /test/snapshots/Readme.maxPostCount.md.snap: -------------------------------------------------------------------------------- 1 | # Readme test 2 | Post list example: 3 | 4 | - [God Mode in browsers: document.designMode = "on"](https://dev.to/gautamkrishnar/god-mode-in-browsers-document-designmode-on-2pmo) 5 | 6 | 7 | # Other contents 8 | Test content 9 | -------------------------------------------------------------------------------- /test/snapshots/Readme.md.snap: -------------------------------------------------------------------------------- 1 | # Readme test 2 | Post list example: 3 | 4 | - [God Mode in browsers: document.designMode = "on"](https://dev.to/gautamkrishnar/god-mode-in-browsers-document-designmode-on-2pmo) 5 | - [Skipping the Chrome "Your connection is not private" warning](https://dev.to/gautamkrishnar/quickbits-1-skipping-the-chrome-your-connection-is-not-private-warning-4kp1) 6 | - [Microsoft Student Partners – Geek is the new rockstar](https://dev.to/gautamkrishnar/microsoft-student-partners--geek-is-the-new-rockstar) 7 | - [An Introduction to NumPy](https://dev.to/gautamkrishnar/an-introduction-to-numpy) 8 | - [Hi, I'm Gautam krishna.R](https://dev.to/gautamkrishnar/hi-im-gautam-krishnar) 9 | - [DuckDuckGo – The search engine redefined](https://dev.to/gautamkrishnar/duckduckgo-the-search-engine-redefined-4c7d) 10 | 11 | 12 | # Other contents 13 | Test content 14 | -------------------------------------------------------------------------------- /test/snapshots/Readme.multi.1.md.snap: -------------------------------------------------------------------------------- 1 | # Readme test 2 | Post list example: 3 | 4 | - [God Mode in browsers: document.designMode = "on"](https://dev.to/gautamkrishnar/god-mode-in-browsers-document-designmode-on-2pmo) 5 | - [Skipping the Chrome "Your connection is not private" warning](https://dev.to/gautamkrishnar/quickbits-1-skipping-the-chrome-your-connection-is-not-private-warning-4kp1) 6 | - [Microsoft Student Partners – Geek is the new rockstar](https://dev.to/gautamkrishnar/microsoft-student-partners--geek-is-the-new-rockstar) 7 | - [An Introduction to NumPy](https://dev.to/gautamkrishnar/an-introduction-to-numpy) 8 | - [Hi, I'm Gautam krishna.R](https://dev.to/gautamkrishnar/hi-im-gautam-krishnar) 9 | - [DuckDuckGo – The search engine redefined](https://dev.to/gautamkrishnar/duckduckgo-the-search-engine-redefined-4c7d) 10 | 11 | 12 | # Other contents 13 | Test content 14 | -------------------------------------------------------------------------------- /test/snapshots/Readme.multi.2.md.snap: -------------------------------------------------------------------------------- 1 | # Readme test 2 | Post list example: 3 | 4 | - [God Mode in browsers: document.designMode = "on"](https://dev.to/gautamkrishnar/god-mode-in-browsers-document-designmode-on-2pmo) 5 | - [Skipping the Chrome "Your connection is not private" warning](https://dev.to/gautamkrishnar/quickbits-1-skipping-the-chrome-your-connection-is-not-private-warning-4kp1) 6 | - [Microsoft Student Partners – Geek is the new rockstar](https://dev.to/gautamkrishnar/microsoft-student-partners--geek-is-the-new-rockstar) 7 | - [An Introduction to NumPy](https://dev.to/gautamkrishnar/an-introduction-to-numpy) 8 | - [Hi, I'm Gautam krishna.R](https://dev.to/gautamkrishnar/hi-im-gautam-krishnar) 9 | - [DuckDuckGo – The search engine redefined](https://dev.to/gautamkrishnar/duckduckgo-the-search-engine-redefined-4c7d) 10 | 11 | 12 | # Other contents 13 | Test content 14 | -------------------------------------------------------------------------------- /test/snapshots/Readme.randomEmoji.md.snap: -------------------------------------------------------------------------------- 1 | # Readme test 2 | Post list example: 3 | - 🌮- 💫- 🌮- 🚀- 🔥- 🚀 4 | 5 | # Other contents 6 | Test content 7 | -------------------------------------------------------------------------------- /test/snapshots/Readme.removeDuplicates.md.snap: -------------------------------------------------------------------------------- 1 | # Readme test 2 | Post list example: 3 | 4 | - [God Mode in browsers: document.designMode = "on"](https://dev.to/gautamkrishnar/god-mode-in-browsers-document-designmode-on-2pmo) 5 | - [Hi, I'm Gautam krishna.R](https://dev.to/gautamkrishnar/hi-im-gautam-krishnar) 6 | 7 | 8 | # Other contents 9 | Test content 10 | -------------------------------------------------------------------------------- /test/snapshots/Readme.retry.md.snap: -------------------------------------------------------------------------------- 1 | # Readme test 2 | Post list example: 3 | 4 | - [God Mode in browsers: document.designMode = "on"](https://dev.to/gautamkrishnar/god-mode-in-browsers-document-designmode-on-2pmo) 5 | - [Skipping the Chrome "Your connection is not private" warning](https://dev.to/gautamkrishnar/quickbits-1-skipping-the-chrome-your-connection-is-not-private-warning-4kp1) 6 | - [Microsoft Student Partners – Geek is the new rockstar](https://dev.to/gautamkrishnar/microsoft-student-partners--geek-is-the-new-rockstar) 7 | - [An Introduction to NumPy](https://dev.to/gautamkrishnar/an-introduction-to-numpy) 8 | - [Hi, I'm Gautam krishna.R](https://dev.to/gautamkrishnar/hi-im-gautam-krishnar) 9 | - [DuckDuckGo – The search engine redefined](https://dev.to/gautamkrishnar/duckduckgo-the-search-engine-redefined-4c7d) 10 | 11 | 12 | # Other contents 13 | Test content 14 | -------------------------------------------------------------------------------- /test/snapshots/Readme.sort-order-asc.md.snap: -------------------------------------------------------------------------------- 1 | # Readme test 2 | Post list example: 3 | 4 | - [DuckDuckGo – The search engine redefined](https://dev.to/gautamkrishnar/duckduckgo-the-search-engine-redefined-4c7d) 5 | - [Hi, I'm Gautam krishna.R](https://dev.to/gautamkrishnar/hi-im-gautam-krishnar) 6 | - [An Introduction to NumPy](https://dev.to/gautamkrishnar/an-introduction-to-numpy) 7 | - [Microsoft Student Partners – Geek is the new rockstar](https://dev.to/gautamkrishnar/microsoft-student-partners--geek-is-the-new-rockstar) 8 | - [Skipping the Chrome "Your connection is not private" warning](https://dev.to/gautamkrishnar/quickbits-1-skipping-the-chrome-your-connection-is-not-private-warning-4kp1) 9 | - [God Mode in browsers: document.designMode = "on"](https://dev.to/gautamkrishnar/god-mode-in-browsers-document-designmode-on-2pmo) 10 | 11 | 12 | # Other contents 13 | Test content 14 | -------------------------------------------------------------------------------- /test/snapshots/Readme.sort.md.snap: -------------------------------------------------------------------------------- 1 | # Readme test 2 | Post list example: 3 | 4 | - [Hi, I'm Gautam krishna.R](https://dev.to/gautamkrishnar/hi-im-gautam-krishnar) 5 | - [God Mode in browsers: document.designMode = "on"](https://dev.to/gautamkrishnar/god-mode-in-browsers-document-designmode-on-2pmo) 6 | - [Microsoft Student Partners – Geek is the new rockstar](https://dev.to/gautamkrishnar/microsoft-student-partners--geek-is-the-new-rockstar) 7 | - [DuckDuckGo – The search engine redefined](https://dev.to/gautamkrishnar/duckduckgo-the-search-engine-redefined-4c7d) 8 | - [Skipping the Chrome "Your connection is not private" warning](https://dev.to/gautamkrishnar/quickbits-1-skipping-the-chrome-your-connection-is-not-private-warning-4kp1) 9 | - [An Introduction to NumPy](https://dev.to/gautamkrishnar/an-introduction-to-numpy) 10 | 11 | 12 | # Other contents 13 | Test content 14 | -------------------------------------------------------------------------------- /test/snapshots/Readme.truncate.description.md.snap: -------------------------------------------------------------------------------- 1 | # Readme test 2 | Post list example: 3 | <p>Just ty... 4 | <p>You guy... 5 | <p><a href... 6 | <p><a href... 7 | <p>I have... 8 | <p><a href... 9 | 10 | 11 | # Other contents 12 | Test content 13 | -------------------------------------------------------------------------------- /test/snapshots/Readme.truncate.title.md.snap: -------------------------------------------------------------------------------- 1 | # Readme test 2 | Post list example: 3 | 4 | - [God Mode i...](https://dev.to/gautamkrishnar/god-mode-in-browsers-document-designmode-on-2pmo) 5 | - [Skipping t...](https://dev.to/gautamkrishnar/quickbits-1-skipping-the-chrome-your-connection-is-not-private-warning-4kp1) 6 | - [Microsoft...](https://dev.to/gautamkrishnar/microsoft-student-partners--geek-is-the-new-rockstar) 7 | - [An Introdu...](https://dev.to/gautamkrishnar/an-introduction-to-numpy) 8 | - [Hi, I'm Ga...](https://dev.to/gautamkrishnar/hi-im-gautam-krishnar) 9 | - [DuckDuckGo...](https://dev.to/gautamkrishnar/duckduckgo-the-search-engine-redefined-4c7d) 10 | 11 | 12 | # Other contents 13 | Test content 14 | -------------------------------------------------------------------------------- /test/sort-order-asc.js: -------------------------------------------------------------------------------- 1 | const {DEFAULT_TEST_ENV} = require('./testUtils/default-env'); 2 | const {runAndCompareSnap} = require('./testUtils/testUtils'); 3 | 4 | describe('Ascending sort order readme (sort_order: asc)', function () { 5 | it('should be equal to the saved snapshot', async function () { 6 | const envObj = { 7 | ...process.env, 8 | ...DEFAULT_TEST_ENV, 9 | INPUT_SORT_ORDER: 'asc' 10 | }; 11 | // Snapshot name will also need to be changed to Readme.sort-order-asc.md 12 | await runAndCompareSnap('Readme.sort-order-asc.md', envObj); 13 | }); 14 | }); 15 | -------------------------------------------------------------------------------- /test/testUtils/default-env.js: -------------------------------------------------------------------------------- 1 | const DEFAULT_TEST_ENV = { 2 | INPUT_MAX_POST_COUNT: '10', 3 | INPUT_FEED_LIST: 'http://localhost:8080', 4 | INPUT_DISABLE_SORT: 'false', 5 | INPUT_SORT_ORDER: 'desc', 6 | INPUT_TEMPLATE: 'default', 7 | INPUT_FILTER_COMMENTS: 'medium,stackoverflow/Comment by $author/,stackexchange/Comment by $author/', 8 | INPUT_USER_AGENT: 'rss-parser', 9 | INPUT_ACCEPT_HEADER: 'application/rss+xml', 10 | INPUT_GH_TOKEN: 'secret-test', 11 | INPUT_DATE_FORMAT: 'UTC:ddd mmm dd yyyy h:MM TT', 12 | INPUT_CUSTOM_TAGS: '', 13 | INPUT_TITLE_MAX_LENGTH: '', 14 | INPUT_DESCRIPTION_MAX_LENGTH: '', 15 | INPUT_ITEM_EXEC: '', 16 | INPUT_OUTPUT_ONLY: 'false', 17 | INPUT_ENABLE_KEEPALIVE: 'true', 18 | INPUT_TAG_POST_PRE_NEWLINE: 'false', 19 | INPUT_RETRY_COUNT: '0', 20 | INPUT_RETRY_WAIT_TIME: '1', 21 | INPUT_FEED_NAMES: '', 22 | INPUT_DISABLE_HTML_ENCODING: 'false', 23 | TEST_MODE: 'true', 24 | INPUT_CATEGORIES_TEMPLATE: 'default', 25 | INPUT_DISABLE_ITEM_VALIDATION: 'false', 26 | INPUT_FILTER_DATES: '', 27 | INPUT_RAND_SEED: '', 28 | INPUT_REMOVE_DUPLICATES: 'false', 29 | INPUT_SKIP_COMMIT: 'false', 30 | INPUT_REVERSE_ORDER: 'false', 31 | }; 32 | 33 | 34 | module.exports = { 35 | DEFAULT_TEST_ENV 36 | }; 37 | -------------------------------------------------------------------------------- /test/testUtils/sample.duplicate.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Gautam krishna.R 5 | Gautam krishna.R 6 | Developer, open source lover and after all a wonderful human being... Software Engineer at Red Hat | DuckDuckGo Community Leader | Polygot 7 | https://dev.to/gautamkrishnar 8 | en 9 | 10 | Hi, I'm Gautam krishna.R 11 | Gautam krishna.R 12 | Sun, 02 Apr 2017 19:04:43 +0000 13 | https://dev.to/gautamkrishnar/hi-im-gautam-krishnar 14 | https://dev.to/gautamkrishnar/hi-im-gautam-krishnar 15 | <p>I have been coding for 9 years, I am a Microsoft student partner and DuckDuckGo community leader who's actively involved in several open source projects.</p> 16 | 17 | <p>You can find me on GitHub at <a href="https://github.com/gautamkrishnar">@gautamkrishnar</a></p> 18 | 19 | <p>You can also find me on Twitter as <a href="https://twitter.com/gautamkrishnar">@gautamkrishnar</a></p> 20 | 21 | <p>I live in Kollam.</p> 22 | 23 | <p>I mostly program in these languages: Phython, NodeJS, PHP, C, C#, Java.</p> 24 | 25 | <p>I am currently learning more about ML.</p> 26 | 27 | <p>Nice to meet you.</p> 28 | 29 | 30 | hello 31 | apple 32 | introductions 33 | 34 | 35 | God Mode in browsers: document.designMode = "on" 36 | Gautam krishna.R 37 | Thu, 16 Jul 2020 10:40:11 +0000 38 | world 39 | https://dev.to/gautamkrishnar/god-mode-in-browsers-document-designmode-on-2pmo 40 | https://dev.to/gautamkrishnar/god-mode-in-browsers-document-designmode-on-2pmo 41 | <p>Just type <code>document.designMode = "on"</code> on you favourite browser devtools and see the magic. </p> 42 | 43 | <p>It will make any website editable:</p> 44 | 45 | <p><a href="https://i.giphy.com/media/iDByhJJoZGSac2RH5z/giphy.gif" class="article-body-image-wrapper"><img src="https://i.giphy.com/media/iDByhJJoZGSac2RH5z/giphy.gif" alt="preview"></a></p> 46 | 47 | 48 | chrome 49 | firefox 50 | devtools 51 | webdev 52 | 53 | 54 | God Mode in browsers: document.designMode = "on" 55 | Gautam krishna.R 56 | Thu, 16 Jul 2020 10:40:11 +0000 57 | world 58 | https://dev.to/gautamkrishnar/god-mode-in-browsers-document-designmode-on-2pmo 59 | https://dev.to/gautamkrishnar/god-mode-in-browsers-document-designmode-on-2pmo 60 | <p>Just type <code>document.designMode = "on"</code> on you favourite browser devtools and see the magic. </p> 61 | 62 | <p>It will make any website editable:</p> 63 | 64 | <p><a href="https://i.giphy.com/media/iDByhJJoZGSac2RH5z/giphy.gif" class="article-body-image-wrapper"><img src="https://i.giphy.com/media/iDByhJJoZGSac2RH5z/giphy.gif" alt="preview"></a></p> 65 | 66 | 67 | chrome 68 | firefox 69 | devtools 70 | webdev 71 | 72 | 73 | Comment by Gautam Krishna R on test 74 | Gautam Krishna R 75 | Wed, 19 Apr 2017 12:24:15 +0000 76 | https://stackoverflow.com/questions/49310909/omniauth-facebook-login-does-not-work/49311637?cid=85720166#49311637 77 | https://stackoverflow.com/questions/49310909/omniauth-facebook-login-does-not-work/49311637?cid=85720166#49311637 78 | desc 79 | 80 | 81 | Comment by Gautam Krishna R on test 82 | Gautam Krishna R 83 | Wed, 19 Apr 2017 12:24:15 +0000 84 | https://stackoverflow.com/questions/49310909/omniauth-facebook-login-does-not-work/49311637?cid=85720166#49311637 85 | https://stackoverflow.com/questions/49310909/omniauth-facebook-login-does-not-work/49311637?cid=85720166#49311637 86 | desc 87 | 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /test/testUtils/test-server.js: -------------------------------------------------------------------------------- 1 | const http = require('http'); 2 | const fs = require('fs'); 3 | const path = require('path'); 4 | let failCounter = 0; 5 | const MAX_FAIL_COUNT = 5; 6 | 7 | const sendResponse = (res, statusCode, data) => { 8 | res.writeHead(statusCode, {'Content-Type': 'text/plain'}); 9 | res.write(data); 10 | res.end(); 11 | }; 12 | 13 | const xmlData = fs.readFileSync(path.join(__dirname, 'sample.xml'), 'utf-8'); 14 | const duplicateXmlData = fs.readFileSync(path.join(__dirname, 'sample.duplicate.xml'), 'utf-8'); 15 | 16 | 17 | http.createServer(function (req, res) { 18 | if (req.url === '/failtest') { 19 | const showError = failCounter !== MAX_FAIL_COUNT; 20 | sendResponse(res, showError ? 500 : 200, showError ? 'error!' : xmlData); 21 | failCounter = failCounter + 1; 22 | } else if (req.url === '/empty-tags') { 23 | const emptyTagResponse = ` 24 | 25 | 26 | 27 | Gautam krishna.R 28 | Gautam krishna.R 29 | test 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | https://dev.to/gautamkrishnar/hi-im-gautam-krishnar 38 | 39 | hello 40 | apple 41 | introductions 42 | 43 | 44 | 45 | `; 46 | sendResponse(res, 200, emptyTagResponse); 47 | } else if (req.url === '/duplicates') { 48 | sendResponse(res, 200, duplicateXmlData); 49 | } 50 | else { 51 | sendResponse(res, 200, xmlData); 52 | } 53 | }).listen(8080); 54 | -------------------------------------------------------------------------------- /test/testUtils/testUtils.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const fs = require('fs'); 3 | const { exec, escapeHTML } = require('../../src/utils'); 4 | const assert = require('assert'); 5 | 6 | // Folder with readme snapshots 7 | const TEST_SNAP_DIR = path.join(path.dirname(__dirname), 'snapshots'); 8 | // language=markdown 9 | const TEMPLATE = `# Readme test 10 | Post list example: 11 | 12 | 13 | 14 | # Other contents 15 | Test content 16 | `; 17 | const projectDir = path.dirname(path.dirname(__dirname)); 18 | 19 | const TEST_FILE = process.env.DIST ? 20 | path.join(projectDir, 'dist/blog-post-workflow') : path.join(projectDir, 'src/blog-post-workflow'); 21 | console.log('Testing: ', TEST_FILE); 22 | 23 | const runAndCompareSnap = async (README_FILE, envObj) => { 24 | const readmePath = path.join(TEST_SNAP_DIR, README_FILE); 25 | envObj = { 26 | ...envObj, 27 | INPUT_README_PATH: readmePath 28 | }; 29 | if (fs.existsSync(readmePath)) { 30 | console.log("Removing stale test readme", readmePath); 31 | fs.rmSync(readmePath); 32 | } 33 | fs.writeFileSync(readmePath, TEMPLATE); 34 | process.env = { 35 | ...process.env, 36 | ...envObj 37 | }; 38 | const workflow = await require(TEST_FILE); 39 | await workflow.runWorkflow(); 40 | const snapshot = fs.readFileSync(path.join(TEST_SNAP_DIR, README_FILE + '.snap'), 'utf-8'); 41 | const newReadme = fs.readFileSync(readmePath, 'utf-8'); 42 | assert.strictEqual(snapshot, newReadme); 43 | }; 44 | 45 | module.exports = { 46 | runAndCompareSnap, 47 | TEST_SNAP_DIR, 48 | TEMPLATE, 49 | TEST_FILE 50 | } 51 | -------------------------------------------------------------------------------- /test/truncated description.js: -------------------------------------------------------------------------------- 1 | const {DEFAULT_TEST_ENV} = require('./testUtils/default-env'); 2 | const {runAndCompareSnap} = require('./testUtils/testUtils'); 3 | describe('Generated readme with truncated description', function () { 4 | it('should match the snapshot', async function () { 5 | const envObj = { 6 | ...process.env, 7 | ...DEFAULT_TEST_ENV, 8 | INPUT_DESCRIPTION_MAX_LENGTH: '10', 9 | INPUT_TEMPLATE: '$description $newline' 10 | }; 11 | await runAndCompareSnap('Readme.truncate.description.md', envObj); 12 | }); 13 | }); 14 | -------------------------------------------------------------------------------- /test/truncated-title.js: -------------------------------------------------------------------------------- 1 | const {DEFAULT_TEST_ENV} = require('./testUtils/default-env'); 2 | const {runAndCompareSnap} = require('./testUtils/testUtils'); 3 | describe('Generated readme with truncated title', function () { 4 | it('should match the snapshot', async function () { 5 | const envObj = { 6 | ...process.env, 7 | ...DEFAULT_TEST_ENV, 8 | INPUT_TITLE_MAX_LENGTH: '10' 9 | }; 10 | await runAndCompareSnap('Readme.truncate.title.md', envObj); 11 | }); 12 | }); 13 | -------------------------------------------------------------------------------- /test/util.test.js: -------------------------------------------------------------------------------- 1 | const assert = require('assert'); 2 | const { 3 | truncateString, 4 | updateAndParseCompoundParams, 5 | getParameterisedTemplate, 6 | escapeHTML, 7 | categoriesToArray 8 | } = require("../src/utils"); 9 | // Skip utils check on dist tests because it is a bundle that do not export these functions 10 | if (process.env.DIST !== 'true') { 11 | describe('truncateString', () => { 12 | it('should return the original string if its length is less than or equal to the specified length', () => { 13 | const result = truncateString('Hello', 10); 14 | assert.strictEqual(result, 'Hello'); 15 | }); 16 | 17 | it('should truncate the string and add "..." if the string is longer than the specified length', () => { 18 | const result = truncateString('Hello, world!', 5); 19 | assert.strictEqual(result, 'Hello...'); 20 | }); 21 | 22 | it('should handle strings with leading and trailing spaces correctly', () => { 23 | const result = truncateString(' Hello, world! ', 5); 24 | assert.strictEqual(result, 'Hello...'); 25 | }); 26 | 27 | it('should return an empty string if an empty string is provided', () => { 28 | const result = truncateString('', 5); 29 | assert.strictEqual(result, ''); 30 | }); 31 | 32 | it('should return "..." if the specified length is zero', () => { 33 | const result = truncateString('Hello', 0); 34 | assert.strictEqual(result, '...'); 35 | }); 36 | 37 | it('should return "H..." if the specified length is 1 after trimming leading spaces', () => { 38 | const result = truncateString(' Hello', 1); 39 | assert.strictEqual(result, 'H...'); 40 | }); 41 | 42 | it('should correctly handle multi-byte characters', () => { 43 | const result = truncateString('こんにちは世界', 5); 44 | assert.strictEqual(result, 'こんにちは...'); 45 | }); 46 | }); 47 | 48 | describe('updateAndParseCompoundParams', () => { 49 | it('should update the object with the correct key-value pair and return the source name when the source has compound parameters', () => { 50 | const obj = {}; 51 | const result = updateAndParseCompoundParams('stackoverflow/Comment by $author/', obj); 52 | assert.strictEqual(result, 'stackoverflow'); 53 | assert.deepStrictEqual(obj, {'stackoverflow': 'Comment by $author'}); 54 | }); 55 | 56 | it('should return the original source name if the source does not contain exactly 3 parts', () => { 57 | const obj = {}; 58 | const result = updateAndParseCompoundParams('github', obj); 59 | assert.strictEqual(result, 'github'); 60 | assert.deepStrictEqual(obj, {}); // Ensure obj is not modified 61 | }); 62 | 63 | it('should handle cases where the source has only 2 parts and return the original source', () => { 64 | const obj = {}; 65 | const result = updateAndParseCompoundParams('github/Issue', obj); 66 | assert.strictEqual(result, 'github/Issue'); 67 | assert.deepStrictEqual(obj, {}); // Ensure obj is not modified 68 | }); 69 | 70 | it('should handle cases where the source has more than 3 parts and return the original source', () => { 71 | const obj = {}; 72 | const result = updateAndParseCompoundParams('stackoverflow/Comment by $author/extra/part', obj); 73 | assert.strictEqual(result, 'stackoverflow/Comment by $author/extra/part'); 74 | assert.deepStrictEqual(obj, {}); // Ensure obj is not modified 75 | }); 76 | 77 | it('should handle an empty string as the source and not update the object', () => { 78 | const obj = {}; 79 | const result = updateAndParseCompoundParams('', obj); 80 | assert.strictEqual(result, ''); 81 | assert.deepStrictEqual(obj, {}); // Ensure obj is not modified 82 | }); 83 | 84 | it('should handle cases where the object is pre-populated', () => { 85 | const obj = {existingKey: 'existingValue'}; 86 | const result = updateAndParseCompoundParams('stackoverflow/Comment by $author/', obj); 87 | assert.strictEqual(result, 'stackoverflow'); 88 | assert.deepStrictEqual(obj, {existingKey: 'existingValue', 'stackoverflow': 'Comment by $author'}); 89 | }); 90 | 91 | }); 92 | 93 | describe('getParameterisedTemplate', () => { 94 | it('should return an array of parameters when the template contains a valid key with parameters', () => { 95 | const template = '$randomEmoji(💯,🔥,💫,🚀,🌮) $emojiKey(💯,🔥,💫)'; 96 | const result = getParameterisedTemplate(template, 'randomEmoji'); 97 | assert.deepStrictEqual(result, ['💯', '🔥', '💫', '🚀', '🌮']); 98 | }); 99 | 100 | it('should return an array of parameters when the template contains another valid key with parameters', () => { 101 | const template = '$randomEmoji(💯,🔥,💫,🚀,🌮) $emojiKey(💯,🔥,💫)'; 102 | const result = getParameterisedTemplate(template, 'emojiKey'); 103 | assert.deepStrictEqual(result, ['💯', '🔥', '💫']); 104 | }); 105 | 106 | it('should return null if the key does not exist in the template', () => { 107 | const template = '$randomEmoji(💯,🔥,💫,🚀,🌮) $emojiKey(💯,🔥,💫)'; 108 | const result = getParameterisedTemplate(template, 'missingKey'); 109 | assert.strictEqual(result, null); 110 | }); 111 | 112 | it('should return null if the key exists but is not followed by an opening parenthesis', () => { 113 | const template = '$randomEmoji💯,🔥,💫,🚀,🌮 $emojiKey(💯,🔥,💫)'; 114 | const result = getParameterisedTemplate(template, 'randomEmoji'); 115 | assert.strictEqual(result, null); 116 | }); 117 | 118 | it('should handle templates with multiple occurrences of the same key', () => { 119 | const template = '$randomEmoji(💯,🔥) and again $randomEmoji(💫,🚀)'; 120 | const result = getParameterisedTemplate(template, 'randomEmoji'); 121 | assert.deepStrictEqual(result, ['💯', '🔥']); // Only the first occurrence should be processed 122 | }); 123 | 124 | it('should correctly parse keys with spaces around parameters', () => { 125 | const template = '$randomEmoji( 💯 , 🔥 , 💫 ) $emojiKey( 💯,🔥 ,💫)'; 126 | const result = getParameterisedTemplate(template, 'randomEmoji'); 127 | assert.deepStrictEqual(result, ['💯', '🔥', '💫']); // Spaces should be trimmed 128 | }); 129 | 130 | it('should return null if the template is empty', () => { 131 | const template = ''; 132 | const result = getParameterisedTemplate(template, 'randomEmoji'); 133 | assert.strictEqual(result, null); 134 | }); 135 | 136 | it('should return null if the key is empty', () => { 137 | const template = '$randomEmoji(💯,🔥,💫,🚀,🌮)'; 138 | const result = getParameterisedTemplate(template, ''); 139 | assert.strictEqual(result, null); 140 | }); 141 | }); 142 | 143 | describe('escapeHTML', () => { 144 | it('should escape the ampersand character (&)', () => { 145 | const result = escapeHTML('Rock & Roll'); 146 | assert.strictEqual(result, 'Rock & Roll'); 147 | }); 148 | 149 | it('should escape the less-than character (<)', () => { 150 | const result = escapeHTML('5 < 10'); 151 | assert.strictEqual(result, '5 < 10'); 152 | }); 153 | 154 | it('should escape the greater-than character (>)', () => { 155 | const result = escapeHTML('10 > 5'); 156 | assert.strictEqual(result, '10 > 5'); 157 | }); 158 | 159 | it('should escape the single quote character (\')', () => { 160 | const result = escapeHTML("It's a test"); 161 | assert.strictEqual(result, 'It's a test'); 162 | }); 163 | 164 | it('should escape the double quote character (")', () => { 165 | const result = escapeHTML('She said "Hello"'); 166 | assert.strictEqual(result, 'She said "Hello"'); 167 | }); 168 | 169 | it('should escape the opening parenthesis character (()', () => { 170 | const result = escapeHTML('3 * (2 + 1)'); 171 | assert.strictEqual(result, '3 * (2 + 1)'); 172 | }); 173 | 174 | it('should escape the closing parenthesis character ())', () => { 175 | const result = escapeHTML('Math.PI = 3.14'); 176 | assert.strictEqual(result, 'Math.PI = 3.14'); 177 | }); 178 | 179 | it('should escape multiple conflicting characters', () => { 180 | const result = escapeHTML('if (a < b) { return "yes"; } else { return "no"; }'); 181 | assert.strictEqual(result, 'if (a < b) { return "yes"; } else { return "no"; }'); 182 | }); 183 | 184 | it('should return the original string if there are no conflicting characters', () => { 185 | const result = escapeHTML('No special characters'); 186 | assert.strictEqual(result, 'No special characters'); 187 | }); 188 | 189 | it('should return an empty string if the input is an empty string', () => { 190 | const result = escapeHTML(''); 191 | assert.strictEqual(result, ''); 192 | }); 193 | }); 194 | 195 | describe('categoriesToArray', () => { 196 | it('should return an array of strings when the input is an array of strings', () => { 197 | const categories = ['C#', 'Controller']; 198 | const result = categoriesToArray(categories); 199 | assert.deepStrictEqual(result, ['C#', 'Controller']); 200 | }); 201 | it('should return an array of strings when the input is an array of CategoryObj objects', () => { 202 | const categories = [{_: 'C#'}, {_: 'Controller'}]; 203 | const result = categoriesToArray(categories); 204 | assert.deepStrictEqual(result, ['C#', 'Controller']); 205 | }); 206 | 207 | it('should return an array of strings when the input is a mixed array of strings and CategoryObj objects', () => { 208 | const categories = ['Programming', {_: 'C#'}, {_: 'Controller'}, 'Tech']; 209 | const result = categoriesToArray(categories); 210 | assert.deepStrictEqual(result, ['Programming', 'C#', 'Controller', 'Tech']); 211 | }); 212 | 213 | it('should return an empty array when the input is an empty array', () => { 214 | const categories = []; 215 | const result = categoriesToArray(categories); 216 | assert.deepStrictEqual(result, []); 217 | }); 218 | 219 | it('should return an empty array when the input is not an array', () => { 220 | const categories = null; 221 | const result = categoriesToArray(categories); 222 | assert.deepStrictEqual(result, []); 223 | }); 224 | 225 | it('should ignore objects without the "_" property', () => { 226 | const categories = [{_: 'C#'}, {domain: 'http://example.com'}]; 227 | const result = categoriesToArray(categories); 228 | assert.deepStrictEqual(result, ['C#']); 229 | }); 230 | 231 | it('should return an empty array when the input array contains only objects without the "_" property', () => { 232 | const categories = [{domain: 'http://example.com'}, {domain: 'http://example.org'}]; 233 | const result = categoriesToArray(categories); 234 | assert.deepStrictEqual(result, []); 235 | }); 236 | 237 | it('should handle a mix of valid and invalid objects', () => { 238 | const categories = ['Programming', {_: 'C#'}, {domain: 'http://example.com'}, 'Tech']; 239 | const result = categoriesToArray(categories); 240 | assert.deepStrictEqual(result, ['Programming', 'C#', 'Tech']); 241 | }); 242 | 243 | }); 244 | } 245 | -------------------------------------------------------------------------------- /test/validation-flag.js: -------------------------------------------------------------------------------- 1 | const {DEFAULT_TEST_ENV} = require('./testUtils/default-env'); 2 | const {runAndCompareSnap} = require('./testUtils/testUtils'); 3 | describe('Generated readme with no validation flag', function () { 4 | it('should match the snapshot', async function () { 5 | const envObj = { 6 | ...process.env, 7 | ...DEFAULT_TEST_ENV, 8 | INPUT_FEED_LIST: 'http://localhost:8080/empty-tags', 9 | INPUT_DISABLE_ITEM_VALIDATION: 'true' 10 | }; 11 | await runAndCompareSnap('Readme.emptyTags.md', envObj); 12 | }); 13 | }); 14 | -------------------------------------------------------------------------------- /test/without-custom-elements.js: -------------------------------------------------------------------------------- 1 | const {DEFAULT_TEST_ENV} = require('./testUtils/default-env'); 2 | const {runAndCompareSnap} = require('./testUtils/testUtils'); 3 | describe('Generated readme without custom elements', function () { 4 | it('should match the snapshot', async function () { 5 | const envObj = { 6 | ...process.env, 7 | ...DEFAULT_TEST_ENV, 8 | INPUT_CUSTOM_TAGS: 'testingTag/testingTag/,testingTag2/testingTag2/', 9 | INPUT_TEMPLATE: '$title $url $testingTag $testingTag2 $newline' 10 | }; 11 | await runAndCompareSnap('Readme.custom-tags.md', envObj); 12 | }); 13 | }); 14 | -------------------------------------------------------------------------------- /test/without-filters.js: -------------------------------------------------------------------------------- 1 | const {DEFAULT_TEST_ENV} = require('./testUtils/default-env'); 2 | const {runAndCompareSnap} = require('./testUtils/testUtils'); 3 | describe('Generated readme without filters', function () { 4 | it('should match the snapshot', async function () { 5 | const envObj = { 6 | ...process.env, 7 | ...DEFAULT_TEST_ENV, 8 | INPUT_FILTER_COMMENTS: '' 9 | }; 10 | await runAndCompareSnap('Readme.comments.md', envObj); 11 | }); 12 | }); 13 | --------------------------------------------------------------------------------