diff --git a/.npmignore b/.npmignore deleted file mode 100644 index 3edcba2..0000000 --- a/.npmignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!dist/**/** diff --git a/package.json b/package.json index 924854c..7d4d24f 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,6 @@ "@actions/exec": "^1.0.4", "@actions/core": "^1.2.6", "@actions/github": "^4.0.0", - "dotenv": "^8.2.0", "ejs": "^3.1.5", "got": "^11.8.1", "remark": "^13.0.0", @@ -64,4 +63,4 @@ "volta": { "node": "14.15.4" } -} \ No newline at end of file +} diff --git a/src/index.ts b/src/index.ts index 0fa9c55..4da27b0 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,4 @@ -import dotnenv from 'dotenv'; import fs from 'fs'; - import ejs from 'ejs'; import remark from 'remark'; import toc from 'remark-toc'; @@ -8,8 +6,7 @@ import GithubApi from './api'; import link from './link'; import git from './git'; import * as core from '@actions/core'; - -const fsp = fs.promises; +import path from 'path'; import type { SortedLanguageList, @@ -19,6 +16,8 @@ import type { ApiGetStarResponse, } from './types'; +const fsp = fs.promises; + const REPO_USERNAME = process.env.GITHUB_REPOSITORY?.split('/')[0]; const OUTPUT_FILENAME: string = core.getInput('output-filename') || 'README.md'; @@ -26,7 +25,8 @@ const API_STARRED_URL = `https://api.github.com/users/${REPO_USERNAME}/starred`; const renderer = async (data: any) => { try { - const MD_TEMPLATE = await fsp.readFile('fixtures/template.md.ejs', 'utf-8'); + const p = path.resolve(process.cwd(), 'template.ejs'); + const MD_TEMPLATE = await fsp.readFile(p, 'utf-8'); return ejs.render(MD_TEMPLATE, data); } catch (error) { core.error('#renderer'); diff --git a/template.ejs b/template.ejs new file mode 100644 index 0000000..d400add --- /dev/null +++ b/template.ejs @@ -0,0 +1,11 @@ +# <%= username %> Awesome List [![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://github.com/sindresorhus/awesome) + +## Table of Contents + +<% for(let [language, repositories] of stars) { %> +## <%= language %> + +<% for(let repo of repositories) { %>- [<%= repo.full_name %>](<%= repo.html_url %>) - <%= repo.description %> +<% } %> + +<% } %>