generated from CoCreate-app/CoCreate-boilerplate
-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9c55e8d
commit 119f7f2
Showing
7 changed files
with
182 additions
and
114 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,48 @@ | ||
module.exports = { | ||
socket: { | ||
config: { | ||
apiKey: "c2b08663-06e3-440c-ef6f-13978b42883a", | ||
securityKey: "f26baf68-e3a9-45fc-effe-502e47116265", | ||
organization_Id: "5de0387b12e200ea63204d6c" | ||
}, | ||
config: { | ||
apiKey: "c2b08663-06e3-440c-ef6f-13978b42883a", | ||
securityKey: "f26baf68-e3a9-45fc-effe-502e47116265", | ||
organization_Id: "5de0387b12e200ea63204d6c", | ||
host: "server.cocreate.app:8088" | ||
}, | ||
|
||
sources: [{ | ||
|
||
sources: [ | ||
{ | ||
path: "./test_files/test.html", | ||
collection: "static_html", | ||
document_id: "5f08bf3da588c11bf8ead4b3", | ||
name: "html", | ||
data:{ | ||
name: "html", | ||
description:"test descrition" | ||
} | ||
}, | ||
], | ||
|
||
crud: [ | ||
{ | ||
collection: "test", | ||
document_id: "", | ||
domains: ["cocreate.app"], | ||
route: "/docs/boilerplate", | ||
document_id: "6010e012f80ce138be7eed01", | ||
data:{ | ||
// collection: "test", | ||
// document_id: "", | ||
domains: ["cocreate.app"], | ||
route: "/docs/boilerplate", | ||
} | ||
} | ||
], | ||
|
||
directory: "./test_files/", | ||
extensions: [ | ||
"js", | ||
"css", | ||
"html" | ||
], | ||
ignores: [ | ||
"node_modules", | ||
"vendor", | ||
"bower_components", | ||
"archive" | ||
] | ||
|
||
extract: { | ||
directory: "./test_files/", | ||
extensions: [ | ||
"js", | ||
"css", | ||
"html" | ||
], | ||
ignores: [ | ||
"node_modules", | ||
"vendor", | ||
"bower_components", | ||
"archive" | ||
], | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
const CoCreateExtract = require('./extract') | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
let config; | ||
|
||
let jsConfig = path.resolve(process.cwd(), 'CoCreate.config.js'); | ||
let jsonConfig = path.resolve(process.cwd(), 'CoCreate.config.json') | ||
if (fs.existsSync(jsConfig)) | ||
config = require(jsConfig); | ||
else if (fs.existsSync(jsonConfig)) { | ||
// let content = fs.readFileSync(jsonConfig, 'utf8').toString(); | ||
// console.log(jsonConfig, content); | ||
config = require(jsonConfig) | ||
// config = JSON.parse(content); | ||
} | ||
else { | ||
console.log('config not found.') | ||
} | ||
|
||
|
||
const { directory, ignores, extensions, socket, sources } = config; | ||
const { CoCreateSocketInit, CoCreateUpdateDocument, CoCreateCreateDocument } = require("./socket_process.js") | ||
/** | ||
* Socket init | ||
*/ | ||
CoCreateSocketInit(socket) | ||
|
||
/** | ||
* Extract comments | ||
*/ | ||
let result = CoCreateExtract(directory, ignores, extensions); | ||
fs.writeFileSync('result.json', JSON.stringify(result), 'utf8') | ||
|
||
|
||
/** | ||
* Store data into db | ||
*/ | ||
// result.forEach((docs) => { | ||
// docs.forEach((doc) => { | ||
// if (!doc.document_id) { | ||
// CoCreateCreateDocument(doc, socket.config); | ||
// } else { | ||
// CoCreateUpdateDocument(doc, socket.config); | ||
// } | ||
// }) | ||
// }) | ||
|
||
/** | ||
* update document by config sources | ||
*/ | ||
|
||
|
||
|
||
sources.forEach(({ path, collection, document_id, name, category, ...rest }) => { | ||
if (!path) return; | ||
// let content = fs.readFileSync(path, 'utf8'); | ||
// console.log(content) | ||
process.exit() | ||
if (content) { | ||
CoCreateUpdateDocument({ | ||
collection, | ||
document_id, | ||
data: { | ||
[name]: content, | ||
category, | ||
...rest | ||
}, | ||
upsert: true | ||
}, socket.config); | ||
} | ||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters