Skip to content

Commit

Permalink
fix: (merge html and commit extractor to one with one config)
Browse files Browse the repository at this point in the history
  • Loading branch information
frankpagan committed Jan 16, 2021
1 parent 88d5ace commit 24be390
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 118 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/automation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ jobs:
# NODE_AUTH_TOKEN: ${{secrets.GITHUB}}


# overwrite description and keyworkds
# Overwrite description and keyworkds
- name: Jaid/action-sync-node-meta
uses: jaid/[email protected]
with:
direction: overwrite-github # default is overwrite-file
githubToken: ${{ secrets.GITHUB }}

# Auto Changog generator
# Auto Changlog generator
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v2
with:
Expand Down
36 changes: 14 additions & 22 deletions CoCreate.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,21 @@
"document_id":"",
"name":"html",
"domains":["ws.cocreate.app"],
"route":"/signup",}
"route":"/signup",
},
]

/* Comment parse and upload to CoCreate */

// Directory to parse for comments and upload to CoCreate
// "directory": "./test_files/",
// "extensions": [
// "js",
// "css",
// "html"
// ],
// "ignores": [
// "node_modules",
// "vendor",
// "bower_components",
// "archive"
// ],

// "permissions": {
// "apiKey": "c2b08663-06e3-440c-ef6f-13978b42883a",
// "securityKey": "f26baf68-e3a9-45fc-effe-502e47116265",
// "organization_Id": "5de0387b12e200ea63204d6c"
// },
// Directory to parse for comments and upload to CoCreate
"directory": "./test_files/",
"extensions": [
"js",
"css",
"html"
],
"ignores": [
"node_modules",
"vendor",
"bower_components",
"archive"
],
}
29 changes: 0 additions & 29 deletions config.json

This file was deleted.

31 changes: 0 additions & 31 deletions html_config.json

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node src/index.js",
"html": "node src/html_store.js",
"docs": "node src/html_store.js",
"build": "node src/index.js"
},
"private": false,
Expand Down
2 changes: 1 addition & 1 deletion release.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = {
[
"@semantic-release/git",
{
assets: ["CHANGELOG.md"],
assets: ["CHANGELOG.md", "package.json"],
},
],
],
Expand Down
1 change: 0 additions & 1 deletion result.json

This file was deleted.

29 changes: 0 additions & 29 deletions src/html_store.js

This file was deleted.

25 changes: 23 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const CoCreateExtract = require('./extract')
const fs = require('fs');
const { directory, ignores, extensions, socket} = require('../config.json');
const path = require('path');
const { directory, ignores, extensions, socket, sources} = require(path.resolve(process.cwd(), 'CoCreate.config.json'));

const {CoCreateSocketInit, CoCreateUpdateDocument, CoCreateCreateDocument } = require("./socket_process.js")
/**
* Socket init
Expand All @@ -15,7 +17,7 @@ fs.writeFileSync('result.json', JSON.stringify(result), 'utf8')


/**
* Store data into dab
* Store data into db
*/
result.forEach((docs) => {
docs.forEach((doc) => {
Expand All @@ -27,3 +29,22 @@ result.forEach((docs) => {
})
})

/**
* update document by config sources
*/
sources.forEach(({path, collection, document_id, name, category, ...rest}) => {
let content = fs.readFileSync(path, 'utf8');
if (content) {
CoCreateUpdateDocument({
collection,
document_id,
data: {
[name]: content,
category,
...rest
},
upsert: true
}, socket.config);
}
})

0 comments on commit 24be390

Please sign in to comment.