Skip to content

Commit 24be390

Browse files
committed
fix: (merge html and commit extractor to one with one config)
1 parent 88d5ace commit 24be390

File tree

9 files changed

+41
-118
lines changed

9 files changed

+41
-118
lines changed

.github/workflows/automation.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ jobs:
2727
# NODE_AUTH_TOKEN: ${{secrets.GITHUB}}
2828

2929

30-
# overwrite description and keyworkds
30+
# Overwrite description and keyworkds
3131
- name: Jaid/action-sync-node-meta
3232
uses: jaid/action-sync-node-meta@v1.4.0
3333
with:
3434
direction: overwrite-github # default is overwrite-file
3535
githubToken: ${{ secrets.GITHUB }}
3636

37-
# Auto Changog generator
37+
# Auto Changlog generator
3838
- name: Semantic Release
3939
uses: cycjimmy/semantic-release-action@v2
4040
with:

CoCreate.config.json

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,29 +21,21 @@
2121
"document_id":"",
2222
"name":"html",
2323
"domains":["ws.cocreate.app"],
24-
"route":"/signup",}
24+
"route":"/signup",
2525
},
2626
]
2727

28-
/* Comment parse and upload to CoCreate */
29-
30-
// Directory to parse for comments and upload to CoCreate
31-
// "directory": "./test_files/",
32-
// "extensions": [
33-
// "js",
34-
// "css",
35-
// "html"
36-
// ],
37-
// "ignores": [
38-
// "node_modules",
39-
// "vendor",
40-
// "bower_components",
41-
// "archive"
42-
// ],
43-
44-
// "permissions": {
45-
// "apiKey": "c2b08663-06e3-440c-ef6f-13978b42883a",
46-
// "securityKey": "f26baf68-e3a9-45fc-effe-502e47116265",
47-
// "organization_Id": "5de0387b12e200ea63204d6c"
48-
// },
28+
// Directory to parse for comments and upload to CoCreate
29+
"directory": "./test_files/",
30+
"extensions": [
31+
"js",
32+
"css",
33+
"html"
34+
],
35+
"ignores": [
36+
"node_modules",
37+
"vendor",
38+
"bower_components",
39+
"archive"
40+
],
4941
}

config.json

Lines changed: 0 additions & 29 deletions
This file was deleted.

html_config.json

Lines changed: 0 additions & 31 deletions
This file was deleted.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"scripts": {
1313
"test": "echo \"Error: no test specified\" && exit 1",
1414
"start": "node src/index.js",
15-
"html": "node src/html_store.js",
15+
"docs": "node src/html_store.js",
1616
"build": "node src/index.js"
1717
},
1818
"private": false,

release.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module.exports = {
1515
[
1616
"@semantic-release/git",
1717
{
18-
assets: ["CHANGELOG.md"],
18+
assets: ["CHANGELOG.md", "package.json"],
1919
},
2020
],
2121
],

result.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/html_store.js

Lines changed: 0 additions & 29 deletions
This file was deleted.

src/index.js

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
const CoCreateExtract = require('./extract')
22
const fs = require('fs');
3-
const { directory, ignores, extensions, socket} = require('../config.json');
3+
const path = require('path');
4+
const { directory, ignores, extensions, socket, sources} = require(path.resolve(process.cwd(), 'CoCreate.config.json'));
5+
46
const {CoCreateSocketInit, CoCreateUpdateDocument, CoCreateCreateDocument } = require("./socket_process.js")
57
/**
68
* Socket init
@@ -15,7 +17,7 @@ fs.writeFileSync('result.json', JSON.stringify(result), 'utf8')
1517

1618

1719
/**
18-
* Store data into dab
20+
* Store data into db
1921
*/
2022
result.forEach((docs) => {
2123
docs.forEach((doc) => {
@@ -27,3 +29,22 @@ result.forEach((docs) => {
2729
})
2830
})
2931

32+
/**
33+
* update document by config sources
34+
*/
35+
sources.forEach(({path, collection, document_id, name, category, ...rest}) => {
36+
let content = fs.readFileSync(path, 'utf8');
37+
if (content) {
38+
CoCreateUpdateDocument({
39+
collection,
40+
document_id,
41+
data: {
42+
[name]: content,
43+
category,
44+
...rest
45+
},
46+
upsert: true
47+
}, socket.config);
48+
}
49+
})
50+

0 commit comments

Comments
 (0)