fix: better template management
This commit is contained in:
@@ -1,2 +0,0 @@
|
|||||||
*
|
|
||||||
!dist/**/**
|
|
@@ -55,7 +55,6 @@
|
|||||||
"@actions/exec": "^1.0.4",
|
"@actions/exec": "^1.0.4",
|
||||||
"@actions/core": "^1.2.6",
|
"@actions/core": "^1.2.6",
|
||||||
"@actions/github": "^4.0.0",
|
"@actions/github": "^4.0.0",
|
||||||
"dotenv": "^8.2.0",
|
|
||||||
"ejs": "^3.1.5",
|
"ejs": "^3.1.5",
|
||||||
"got": "^11.8.1",
|
"got": "^11.8.1",
|
||||||
"remark": "^13.0.0",
|
"remark": "^13.0.0",
|
||||||
@@ -64,4 +63,4 @@
|
|||||||
"volta": {
|
"volta": {
|
||||||
"node": "14.15.4"
|
"node": "14.15.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
10
src/index.ts
10
src/index.ts
@@ -1,6 +1,4 @@
|
|||||||
import dotnenv from 'dotenv';
|
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
|
|
||||||
import ejs from 'ejs';
|
import ejs from 'ejs';
|
||||||
import remark from 'remark';
|
import remark from 'remark';
|
||||||
import toc from 'remark-toc';
|
import toc from 'remark-toc';
|
||||||
@@ -8,8 +6,7 @@ import GithubApi from './api';
|
|||||||
import link from './link';
|
import link from './link';
|
||||||
import git from './git';
|
import git from './git';
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
|
import path from 'path';
|
||||||
const fsp = fs.promises;
|
|
||||||
|
|
||||||
import type {
|
import type {
|
||||||
SortedLanguageList,
|
SortedLanguageList,
|
||||||
@@ -19,6 +16,8 @@ import type {
|
|||||||
ApiGetStarResponse,
|
ApiGetStarResponse,
|
||||||
} from './types';
|
} from './types';
|
||||||
|
|
||||||
|
const fsp = fs.promises;
|
||||||
|
|
||||||
const REPO_USERNAME = process.env.GITHUB_REPOSITORY?.split('/')[0];
|
const REPO_USERNAME = process.env.GITHUB_REPOSITORY?.split('/')[0];
|
||||||
const OUTPUT_FILENAME: string = core.getInput('output-filename') || 'README.md';
|
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) => {
|
const renderer = async (data: any) => {
|
||||||
try {
|
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);
|
return ejs.render(MD_TEMPLATE, data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.error('#renderer');
|
core.error('#renderer');
|
||||||
|
11
template.ejs
Normal file
11
template.ejs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
# <%= username %> Awesome List [](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 %>
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
<% } %>
|
Reference in New Issue
Block a user