@zinn-dev/core 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/index.ts +30 -2
- package/package.json +7 -1
package/README.md
ADDED
package/index.ts
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// TODO: do not initialize before the first "valid" command
|
|
2
|
+
import "./src/config";
|
|
3
|
+
import { db, addProject, getProjectByKey, deleteProjectByKey } from "./src/db";
|
|
4
|
+
|
|
5
|
+
function standardizeKey(key: string) {
|
|
6
|
+
// TODO: maybe force latin characters only to prevent unexpected stuff from charaters like Ğ, İ, etc.
|
|
7
|
+
return key.toUpperCase();
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// TODO: switch to object param
|
|
11
|
+
export function createProject(key: string, name: string) {
|
|
12
|
+
const standardizedKey = standardizeKey(key);
|
|
13
|
+
const project = getProjectByKey(standardizedKey);
|
|
14
|
+
|
|
15
|
+
if (project != null) {
|
|
16
|
+
throw new Error(`Project with key "${standardizedKey}" already exists!`);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
addProject(standardizedKey, name);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function deleteProject(key: string) {
|
|
23
|
+
const standardizedKey = standardizeKey(key);
|
|
24
|
+
const project = getProjectByKey(standardizedKey);
|
|
25
|
+
|
|
26
|
+
if (project == null) {
|
|
27
|
+
throw new Error(`Project with key "${standardizedKey}" does not exist!`);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
deleteProjectByKey(standardizedKey);
|
|
3
31
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zinn-dev/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
|
+
"description": "Shared logic for zinn, a kanban workflow in the terminal.",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/yethranayeh/zinn.git",
|
|
8
|
+
"directory": "packages/core"
|
|
9
|
+
},
|
|
4
10
|
"private": false,
|
|
5
11
|
"type": "module",
|
|
6
12
|
"module": "index.ts",
|