Skip to content

Commit 2e2977b

Browse files
committed
0
0 parents  commit 2e2977b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+14924
-0
lines changed

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
dist
2+
.idea
3+
node_modules
4+
__debug__
5+
yarn-error.log
6+
.DS_Store
7+
RefreshAndPredload.log
8+
secret.json

.prettierrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"printWidth": 120,
3+
"tabWidth": 4,
4+
"bracketSpacing":true,
5+
"semi":false
6+
}
7+

build/publish.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Created on 2023/03/26 - 00:39
2+
import { publish } from "@moonvy/deploy"
3+
4+
publish("web", "./dist", "apps/ops")

data/build.js

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import csv from "csvtojson"
2+
import fs from "fs"
3+
import { fromNotion } from "./src/notion/fromNotion.js"
4+
import localCommandDesc from "./src/localCommandDesc.js"
5+
6+
const __dirname = new URL(".", import.meta.url).pathname
7+
8+
let localPromptDefineMap = {}
9+
10+
// Add notion database https://www.notion.so/moonvy/5ac19c115d11488f95847c9e2d789dff?v=5ce9b783b4504c23bb7b492aa70c1cfc
11+
let notionPromptDescMap = await fromNotion()
12+
Object.assign(localPromptDefineMap, notionPromptDescMap)
13+
14+
// Add src/dict/*.csv
15+
let pathLang = `${__dirname}src/dict`
16+
for (let file of fs.readdirSync(pathLang, { withFileTypes: true })) {
17+
if (file.isFile() && file.name.toLowerCase().endsWith(".csv")) {
18+
let re = await csv().fromFile(`${pathLang}/${file.name}`)
19+
re.forEach((item) => addToMap(item))
20+
console.log(`Add src/dict/${file.name}`)
21+
}
22+
}
23+
console.log(`Add src/dict/*.csv`)
24+
25+
// src/localCommandDesc.js
26+
localCommandDesc().forEach((item) => addToMap(item))
27+
console.log(`Add src/localCommandDesc.js`)
28+
29+
// ------------------------------------
30+
31+
Object.values(localPromptDefineMap).forEach((item) => {
32+
if (item?.tags?.length == 0) delete item.tags
33+
})
34+
35+
let jsonText = JSON.stringify(localPromptDefineMap, null, 1)
36+
fs.writeFileSync(__dirname + "localPromptDefineMap.json", jsonText)
37+
fs.writeFileSync(__dirname + "../web/public/localPromptDefineMap.json", jsonText)
38+
39+
let finSize = fs.statSync(__dirname + "/localPromptDefineMap.json").size
40+
let itemsLength = Object.keys(localPromptDefineMap).length
41+
42+
console.log(`[generated] localPromptDescMap.json ( ${itemsLength} items | ${(finSize / 1024).toFixed(1)}KB )`)
43+
44+
// --------------------------
45+
46+
function addToMap(item) {
47+
const subTypeMap = {
48+
普通: "normal",
49+
风格: "style",
50+
质量: "quality",
51+
命令: "command",
52+
负面: "eg",
53+
}
54+
// console.log("item", item)
55+
let key = item.text.toLowerCase()
56+
if (item.subType && subTypeMap[item.subType]) {
57+
item.subType = subTypeMap[item.subType]
58+
}
59+
60+
if (localPromptDefineMap[key]) {
61+
Object.assign(localPromptDefineMap[key], item)
62+
} else {
63+
localPromptDefineMap[key] = item
64+
}
65+
}

0 commit comments

Comments
 (0)