mirror of
https://github.com/goldbergyoni/nodebestpractices.git
synced 2025-10-27 19:17:13 +08:00
Moved generation files to .operations
This commit is contained in:
@ -10,7 +10,7 @@ const imageminPngquant = require('imagemin-pngquant');
|
||||
|
||||
const converter = new showdown.Converter();
|
||||
|
||||
const templateFilePath = './res/template.html';
|
||||
const templateFilePath = './.operations/res/template.html';
|
||||
|
||||
const imageminOpts = {
|
||||
plugins: [
|
||||
@ -19,6 +19,8 @@ const imageminOpts = {
|
||||
]
|
||||
};
|
||||
|
||||
console.info(`Working in [${process.cwd()}]`);
|
||||
|
||||
const { GITHUB_TOKEN, TRAVIS_BRANCH, TRAVIS, TRAVIS_REPO_SLUG } = process.env;
|
||||
const isCI = !!TRAVIS;
|
||||
|
||||
@ -36,7 +38,7 @@ readDirPromise('./')
|
||||
console.info(`Completed Generation in [${(Date.now() - startTime) / 1000}s]`);
|
||||
|
||||
const outFileName = path.parse(fileName).name + '.html';
|
||||
const outFilePath = path.join('out', outFileName);
|
||||
const outFilePath = path.join('.operations', 'out', outFileName);
|
||||
console.info(`Writing output to [${outFilePath}]`);
|
||||
await writeFilePromise(outFilePath, outputHTML);
|
||||
|
||||
@ -69,7 +71,7 @@ async function processMDFile(filePath = '/', templateHTML = null) {
|
||||
nexHTML = $.html();
|
||||
}
|
||||
|
||||
const fileDir = path.parse(filePath).dir.replace(__dirname, '/') || '/';
|
||||
const fileDir = path.parse(filePath).dir.replace(process.cwd(), '/') || '/';
|
||||
|
||||
console.log(`Processing file [${filePath}]`);
|
||||
const outHtml = await (
|
||||
@ -191,7 +193,7 @@ async function inlineResources(html, filePath = '/') {
|
||||
|
||||
function readFilePromise(filePath, encoding = 'utf8') {
|
||||
return new Promise((resolve, reject) => {
|
||||
readFile(path.resolve(__dirname, './' + filePath), encoding, (err, content) => {
|
||||
readFile(path.resolve(process.cwd(), './' + filePath), encoding, (err, content) => {
|
||||
if (err) reject(err);
|
||||
else resolve(content);
|
||||
});
|
||||
@ -200,7 +202,7 @@ function readFilePromise(filePath, encoding = 'utf8') {
|
||||
|
||||
function writeFilePromise(filePath, encoding = 'utf8') {
|
||||
return new Promise((resolve, reject) => {
|
||||
writeFile(path.resolve(__dirname, './' + filePath), encoding, (err, content) => {
|
||||
writeFile(path.resolve(process.cwd(), './' + filePath), encoding, (err, content) => {
|
||||
if (err) reject(err);
|
||||
else resolve(content);
|
||||
});
|
||||
@ -209,7 +211,7 @@ function writeFilePromise(filePath, encoding = 'utf8') {
|
||||
|
||||
function readDirPromise(dirPath) {
|
||||
return new Promise((resolve, reject) => {
|
||||
readdir(path.resolve(__dirname, dirPath), (err, files) => {
|
||||
readdir(path.resolve(process.cwd(), dirPath), (err, files) => {
|
||||
if (err) reject(err);
|
||||
else resolve(files);
|
||||
});
|
||||
@ -4,7 +4,7 @@
|
||||
"description": "[✔]: assets/images/checkbox-small-blue.png",
|
||||
"main": "gen-html.js",
|
||||
"scripts": {
|
||||
"build": "node gen-html.js",
|
||||
"build": "cd .. && node .operations/gen-html.js",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"repository": {
|
||||
@ -32,11 +32,11 @@
|
||||
<div class="content"></div>
|
||||
<div class="references"></div>
|
||||
</div>
|
||||
<link rel="stylesheet" href="./res/normalize.css">
|
||||
<link rel="stylesheet" href="./res/skeleton.css">
|
||||
<link rel="stylesheet" href="./.operations/res/normalize.css">
|
||||
<link rel="stylesheet" href="./.operations/res/skeleton.css">
|
||||
|
||||
<link rel="stylesheet" href="./res/github.css">
|
||||
<script src="./res/highlight.pack.js"></script>
|
||||
<link rel="stylesheet" href="./.operations/res/github.css">
|
||||
<script src="./.operations/res/highlight.pack.js"></script>
|
||||
<script>
|
||||
window.onload = function () {
|
||||
hljs.initHighlighting();
|
||||
@ -1,6 +1,8 @@
|
||||
language: node_js
|
||||
node_js: 8
|
||||
script:
|
||||
- cd .operations
|
||||
- npm i
|
||||
- export PR=https://api.github.com/repos/$TRAVIS_REPO_SLUG/pulls/$TRAVIS_PULL_REQUEST
|
||||
- export BRANCH=$(if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then echo $TRAVIS_BRANCH; else echo `curl -s $PR | jq -r .head.ref`; fi)
|
||||
- echo "TRAVIS_BRANCH=$TRAVIS_BRANCH, PR=$PR, BRANCH=$BRANCH"
|
||||
|
||||
@ -666,7 +666,7 @@ null == undefined // true
|
||||
|
||||
**Otherwise:** 在开发过程中, 可能一个直白的安全隐患, 成为生产环境中一个严重问题。此外, 项目可能没有遵循一致的安全规范, 而导致引入漏洞, 或敏感信息被提交到远程仓库中。
|
||||
|
||||
🔗 [**更多: Lint 规范**](sections/security/lintrules.md)
|
||||
🔗 [**更多: Lint 规范**](/sections/security/lintrules.md)
|
||||
|
||||
<br/><br/>
|
||||
|
||||
@ -678,7 +678,7 @@ null == undefined // true
|
||||
|
||||
**否则:** 应用程序可能受到攻击, 导致拒绝服务, 在这种情况下, 真实用户会遭受服务降级或不可用。
|
||||
|
||||
🔗 [**更多: 实施速率限制**](sections/security/limitrequests.md)
|
||||
🔗 [**更多: 实施速率限制**](/sections/security/limitrequests.md)
|
||||
|
||||
<br/><br/>
|
||||
|
||||
@ -690,7 +690,7 @@ null == undefined // true
|
||||
|
||||
**否则:** 源代码管理, 即使对于私有仓库, 也可能会被错误地公开, 此时所有的秘密信息都会被公开。外部组织的源代码管理的访问权限将无意中提供对相关系统 (数据库、api、服务等) 的访问。
|
||||
|
||||
🔗 [**更多: 安全管理**](sections/security/secretmanagement.md)
|
||||
🔗 [**更多: 安全管理**](/sections/security/secretmanagement.md)
|
||||
|
||||
<br/><br/>
|
||||
|
||||
|
||||
@ -677,7 +677,7 @@ All statements above will return false if used with `===`
|
||||
|
||||
**Otherwise:** What could have been a straightforward security weakness during development becomes a major issue in production. Also, the project may not follow consistent code security practices, leading to vulnerabilities being introduced, or sensitive secrets committed into remote repositories
|
||||
|
||||
🔗 [**Read More: Lint rules**](sections/security/lintrules.md)
|
||||
🔗 [**Read More: Lint rules**](/sections/security/lintrules.md)
|
||||
|
||||
<br/><br/>
|
||||
|
||||
@ -689,7 +689,7 @@ All statements above will return false if used with `===`
|
||||
|
||||
**Otherwise:** An application could be subject to an attack resulting in a denial of service where real users receive a degraded or unavailable service.
|
||||
|
||||
🔗 [**Read More: Implement rate limiting**](sections/security/limitrequests.md)
|
||||
🔗 [**Read More: Implement rate limiting**](/sections/security/limitrequests.md)
|
||||
|
||||
<br/><br/>
|
||||
|
||||
@ -701,7 +701,7 @@ All statements above will return false if used with `===`
|
||||
|
||||
**Otherwise:** Source control, even for private repositories, can mistakenly be made public, at which point all secrets are exposed. Access to source control for an external party will inadvertently provide access to related systems (databases, apis, services, etc).
|
||||
|
||||
🔗 [**Read More: Secret management**](sections/security/secretmanagement.md)
|
||||
🔗 [**Read More: Secret management**](/sections/security/secretmanagement.md)
|
||||
|
||||
<br/><br/>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user