Skip to content

Commit a824a07

Browse files
committed
Moved generation files to .operations
1 parent 250a401 commit a824a07

File tree

12 files changed

+21
-17
lines changed

12 files changed

+21
-17
lines changed
File renamed without changes.

gen-html.js renamed to .operations/gen-html.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const imageminPngquant = require('imagemin-pngquant');
1010

1111
const converter = new showdown.Converter();
1212

13-
const templateFilePath = './res/template.html';
13+
const templateFilePath = './.operations/res/template.html';
1414

1515
const imageminOpts = {
1616
plugins: [
@@ -19,6 +19,8 @@ const imageminOpts = {
1919
]
2020
};
2121

22+
console.info(`Working in [${process.cwd()}]`);
23+
2224
const { GITHUB_TOKEN, TRAVIS_BRANCH, TRAVIS, TRAVIS_REPO_SLUG } = process.env;
2325
const isCI = !!TRAVIS;
2426

@@ -36,7 +38,7 @@ readDirPromise('./')
3638
console.info(`Completed Generation in [${(Date.now() - startTime) / 1000}s]`);
3739

3840
const outFileName = path.parse(fileName).name + '.html';
39-
const outFilePath = path.join('out', outFileName);
41+
const outFilePath = path.join('.operations', 'out', outFileName);
4042
console.info(`Writing output to [${outFilePath}]`);
4143
await writeFilePromise(outFilePath, outputHTML);
4244

@@ -69,7 +71,7 @@ async function processMDFile(filePath = '/', templateHTML = null) {
6971
nexHTML = $.html();
7072
}
7173

72-
const fileDir = path.parse(filePath).dir.replace(__dirname, '/') || '/';
74+
const fileDir = path.parse(filePath).dir.replace(process.cwd(), '/') || '/';
7375

7476
console.log(`Processing file [${filePath}]`);
7577
const outHtml = await (
@@ -191,7 +193,7 @@ async function inlineResources(html, filePath = '/') {
191193

192194
function readFilePromise(filePath, encoding = 'utf8') {
193195
return new Promise((resolve, reject) => {
194-
readFile(path.resolve(__dirname, './' + filePath), encoding, (err, content) => {
196+
readFile(path.resolve(process.cwd(), './' + filePath), encoding, (err, content) => {
195197
if (err) reject(err);
196198
else resolve(content);
197199
});
@@ -200,7 +202,7 @@ function readFilePromise(filePath, encoding = 'utf8') {
200202

201203
function writeFilePromise(filePath, encoding = 'utf8') {
202204
return new Promise((resolve, reject) => {
203-
writeFile(path.resolve(__dirname, './' + filePath), encoding, (err, content) => {
205+
writeFile(path.resolve(process.cwd(), './' + filePath), encoding, (err, content) => {
204206
if (err) reject(err);
205207
else resolve(content);
206208
});
@@ -209,7 +211,7 @@ function writeFilePromise(filePath, encoding = 'utf8') {
209211

210212
function readDirPromise(dirPath) {
211213
return new Promise((resolve, reject) => {
212-
readdir(path.resolve(__dirname, dirPath), (err, files) => {
214+
readdir(path.resolve(process.cwd(), dirPath), (err, files) => {
213215
if (err) reject(err);
214216
else resolve(files);
215217
});
File renamed without changes.

package.json renamed to .operations/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "[✔]: assets/images/checkbox-small-blue.png",
55
"main": "gen-html.js",
66
"scripts": {
7-
"build": "node gen-html.js",
7+
"build": "cd .. && node .operations/gen-html.js",
88
"test": "echo \"Error: no test specified\" && exit 1"
99
},
1010
"repository": {
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

res/template.html renamed to .operations/res/template.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@
3232
<div class="content"></div>
3333
<div class="references"></div>
3434
</div>
35-
<link rel="stylesheet" href="./res/normalize.css">
36-
<link rel="stylesheet" href="./res/skeleton.css">
35+
<link rel="stylesheet" href="./.operations/res/normalize.css">
36+
<link rel="stylesheet" href="./.operations/res/skeleton.css">
3737

38-
<link rel="stylesheet" href="./res/github.css">
39-
<script src="./res/highlight.pack.js"></script>
38+
<link rel="stylesheet" href="./.operations/res/github.css">
39+
<script src="./.operations/res/highlight.pack.js"></script>
4040
<script>
4141
window.onload = function () {
4242
hljs.initHighlighting();

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
language: node_js
22
node_js: 8
33
script:
4+
- cd .operations
5+
- npm i
46
- export PR=https://api.github.com/repos/$TRAVIS_REPO_SLUG/pulls/$TRAVIS_PULL_REQUEST
57
- export BRANCH=$(if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then echo $TRAVIS_BRANCH; else echo `curl -s $PR | jq -r .head.ref`; fi)
68
- echo "TRAVIS_BRANCH=$TRAVIS_BRANCH, PR=$PR, BRANCH=$BRANCH"

README.chinese.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ null == undefined // true
666666

667667
**Otherwise:** 在开发过程中, 可能一个直白的安全隐患, 成为生产环境中一个严重问题。此外, 项目可能没有遵循一致的安全规范, 而导致引入漏洞, 或敏感信息被提交到远程仓库中。
668668

669-
🔗 [**更多: Lint 规范**](sections/security/lintrules.md)
669+
🔗 [**更多: Lint 规范**](/sections/security/lintrules.md)
670670

671671
<br/><br/>
672672

@@ -678,7 +678,7 @@ null == undefined // true
678678

679679
**否则:** 应用程序可能受到攻击, 导致拒绝服务, 在这种情况下, 真实用户会遭受服务降级或不可用。
680680

681-
🔗 [**更多: 实施速率限制**](sections/security/limitrequests.md)
681+
🔗 [**更多: 实施速率限制**](/sections/security/limitrequests.md)
682682

683683
<br/><br/>
684684

@@ -690,7 +690,7 @@ null == undefined // true
690690

691691
**否则:** 源代码管理, 即使对于私有仓库, 也可能会被错误地公开, 此时所有的秘密信息都会被公开。外部组织的源代码管理的访问权限将无意中提供对相关系统 (数据库、api、服务等) 的访问。
692692

693-
🔗 [**更多: 安全管理**](sections/security/secretmanagement.md)
693+
🔗 [**更多: 安全管理**](/sections/security/secretmanagement.md)
694694

695695
<br/><br/>
696696

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ All statements above will return false if used with `===`
677677

678678
**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
679679

680-
🔗 [**Read More: Lint rules**](sections/security/lintrules.md)
680+
🔗 [**Read More: Lint rules**](/sections/security/lintrules.md)
681681

682682
<br/><br/>
683683

@@ -689,7 +689,7 @@ All statements above will return false if used with `===`
689689

690690
**Otherwise:** An application could be subject to an attack resulting in a denial of service where real users receive a degraded or unavailable service.
691691

692-
🔗 [**Read More: Implement rate limiting**](sections/security/limitrequests.md)
692+
🔗 [**Read More: Implement rate limiting**](/sections/security/limitrequests.md)
693693

694694
<br/><br/>
695695

@@ -701,7 +701,7 @@ All statements above will return false if used with `===`
701701

702702
**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).
703703

704-
🔗 [**Read More: Secret management**](sections/security/secretmanagement.md)
704+
🔗 [**Read More: Secret management**](/sections/security/secretmanagement.md)
705705

706706
<br/><br/>
707707

0 commit comments

Comments
 (0)