Skip to content

Commit

Permalink
add contributing and config settings
Browse files Browse the repository at this point in the history
  • Loading branch information
tuanthanh2067 committed Nov 2, 2021
1 parent d1e0f28 commit 6a068cf
Show file tree
Hide file tree
Showing 16 changed files with 1,042 additions and 82 deletions.
15 changes: 15 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
env: {
browser: true,
commonjs: true,
es2021: true,
},
extends: "eslint:recommended",
parserOptions: {
ecmaVersion: 13,
},
rules: {
semi: ["error", "always"],
quotes: ["error", "double"],
},
};
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
node_modules/
.env
dist
testing/
test.json
dist
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run pre-commit
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Ignore artifacts:
build
coverage
1 change: 1 addition & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["esbenp.prettier-vscode", "dbaeumer.vscode-eslint"]
}
8 changes: 8 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll": true
},
"eslint.validate": ["javascript"]
}
91 changes: 91 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Usage

1. Clone this project
2. Install [node](https://nodejs.org/en/) on your machine
3. Redirect to the project folder
4. Install cv-ssg globally by using `npm install -g .`
5. Use command line tool and type `cv-ssg -i <file name> -s <stylesheet link>` or `cv-ssg -c <path-to-config-file>`
6. The dist folder will be placed right where you're at

# Before working on the project

`npm i`

# Prettier script

npm

`npx prettier --write .`

yarn

`yarn prettier --write .`

# ESlint script

`npx eslint .`

# Example

**./example/files/sample.txt**

```
This is line 1
This is line 2
This is line 3
```

After running `cv--ssg -i ./example/files -s default`

**./dist/sample.html**

```
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Filename</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/water.css@2/out/water.css'>
</head>
<body>
<p>This is line 1</p>
<p>This is line 2</p>
<p>This is line 3</p>
</body>
</html>
```

**config.json**

```
{
"input": "./example/files/sample.txt",
"output": "./build",
"lang": "fr"
}
```

After running `cv--ssg -c config.json`

**./dist/sample.html**

```
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Filename</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<p>This is line 1</p>
<p>This is line 2</p>
<p>This is line 3</p>
</body>
</html>
```
74 changes: 0 additions & 74 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,80 +23,6 @@ CV-SSG is a command line tool that will produce **.html** files from **.txt** an
| -s or --stylesheet | accepts a url link to the stylesheet |
| -c or --config | accepts a config.json file containing other options' values |

# Usage

1. Clone this project
2. Install [node](https://nodejs.org/en/) on your machine
3. Redirect to the project folder
4. Install cv-ssg globally by using `npm install -g .`
5. Use command line tool and type `cv-ssg -i <file name> -s <stylesheet link>` or `cv-ssg -c <path-to-config-file>`
6. The dist folder will be placed right where you're at

# Example

**./example/files/sample.txt**

```
This is line 1
This is line 2
This is line 3
```

After running `cv--ssg -i ./example/files -s default`

**./dist/sample.html**

```
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Filename</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/water.css@2/out/water.css'>
</head>
<body>
<p>This is line 1</p>
<p>This is line 2</p>
<p>This is line 3</p>
</body>
</html>
```

**config.json**

```
{
"input": "./example/files/sample.txt",
"output": "./build",
"lang": "fr"
}
```

After running `cv--ssg -c config.json`

**./dist/sample.html**

```
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Filename</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<p>This is line 1</p>
<p>This is line 2</p>
<p>This is line 3</p>
</body>
</html>
```

# License

[MIT](https://choosealicense.com/licenses/mit/)
6 changes: 5 additions & 1 deletion bin/cv-ssg.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/usr/bin/env node

/* global process */

const chalk = require("chalk");
const { program } = require("commander");

Expand Down Expand Up @@ -84,7 +87,8 @@ const main = async () => {

// assets available here or null
// copy assets folder to dist folder
if (returnResult) {
console.log(returnResult);
if (returnResult && returnResult.assets) {
const copyFolder = new CopyFolder(returnResult.assets);
try {
await copyFolder.copy("./dist/assets");
Expand Down
2 changes: 0 additions & 2 deletions bin/helpers/handleFile.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const showdown = require("showdown");
const path = require("path");
const ReadPath = require("../helpers/readPath");

module.exports = class HandleFile {
Expand Down Expand Up @@ -75,7 +74,6 @@ module.exports = class HandleFile {
}
if (ext === ".json") {
const jsonData = await this.handleJson(results);
console.log(jsonData, "json data");

// in case input in config file is a folder
// which will give back an array of promises
Expand Down
3 changes: 2 additions & 1 deletion bin/helpers/produceFile.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* global process */
const fs = require("fs");
const chalk = require("chalk");

Expand All @@ -19,7 +20,7 @@ module.exports = class ProduceFile {
try {
// remove full path first and then extension
const filename = this.path
.replace(/^.*[\\\/]/, "")
.replace(/^.*[\\/]/, "")
.replace(/\.[^/.]+$/, "");

// write the html to the dist folder
Expand Down
1 change: 1 addition & 0 deletions bin/helpers/produceFolder.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* global process */
const fs = require("fs");

module.exports = class ProduceFolder {
Expand Down
1 change: 1 addition & 0 deletions bin/helpers/readPath.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* global process */
const fs = require("fs").promises;
const path = require("path");
const dir = require("node-dir");
Expand Down
Loading

0 comments on commit 6a068cf

Please sign in to comment.