imdone-core 2.0.18 → 2.0.20
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/lib/adapters/file-gateway.js +14 -4
- package/lib/card.js +14 -4
- package/lib/config.js +9 -0
- package/lib/project.js +2 -1
- package/lib/repository.js +2 -2
- package/package.json +1 -1
- package/types/card.d.ts +3 -1
- package/types/config.d.ts +2 -0
- package/types/file.d.ts +3 -1
- package/types/project.d.ts +19 -1
|
@@ -109,14 +109,24 @@ function statsProps(stats) {
|
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
export async function preparePathForWriting(path, directory = false) {
|
|
112
|
+
// This is the fixed implementation
|
|
112
113
|
let stats = await exists(path)
|
|
113
114
|
if (stats) return statsProps(stats)
|
|
114
115
|
|
|
115
116
|
let { dir } = directory ? { dir: path } : _path.parse(path)
|
|
116
|
-
|
|
117
|
-
if
|
|
118
|
-
|
|
119
|
-
|
|
117
|
+
|
|
118
|
+
// Create directory if it doesn't exist - mkdir with recursive: true
|
|
119
|
+
// is safe to call even if directory already exists
|
|
120
|
+
try {
|
|
121
|
+
await mkdir(dir, { recursive: true })
|
|
122
|
+
} catch (error) {
|
|
123
|
+
// Only throw if it's not an "already exists" error
|
|
124
|
+
if (error.code !== 'EEXIST') {
|
|
125
|
+
throw error
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Verify the directory was created/exists
|
|
120
130
|
stats = await exists(dir)
|
|
121
131
|
return statsProps(stats)
|
|
122
132
|
}
|
package/lib/card.js
CHANGED
|
@@ -24,7 +24,11 @@ export function newCard(task, _project, dontParse) {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
get settings() {
|
|
27
|
-
return project
|
|
27
|
+
return project?.config?.settings || {}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
get fields() {
|
|
31
|
+
return this?.settings?.cards?.fields || {}
|
|
28
32
|
}
|
|
29
33
|
|
|
30
34
|
get maxLines() {
|
|
@@ -238,14 +242,20 @@ export function newCard(task, _project, dontParse) {
|
|
|
238
242
|
this.data = { ...this.data, ...this.desc }
|
|
239
243
|
}
|
|
240
244
|
|
|
241
|
-
|
|
245
|
+
getEncodedText(content) {
|
|
242
246
|
const linkRegex = /\[([^[]+)\](\((.*)\))/gm
|
|
243
247
|
const plainDescription = removeMD(content.replace(linkRegex, '$3'), {
|
|
244
248
|
stripListLeaders: false,
|
|
245
249
|
}).replace(/:(\w+):/g, (match, p1) => {
|
|
246
250
|
return allEmoji[p1]
|
|
247
251
|
})
|
|
248
|
-
|
|
252
|
+
return encodeURIComponent(plainDescription)
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
getContentData(content) {
|
|
256
|
+
const encodedText = this.fields?.encodedText
|
|
257
|
+
? this.getEncodedText(content)
|
|
258
|
+
: ''
|
|
249
259
|
const encodedMD = encodeURIComponent(content)
|
|
250
260
|
content = content.replace(CONTENT_TOKEN, encodedText)
|
|
251
261
|
content = encodeMarkdownLinks(content)
|
|
@@ -253,7 +263,7 @@ export function newCard(task, _project, dontParse) {
|
|
|
253
263
|
}
|
|
254
264
|
|
|
255
265
|
formatContent(content, mustache) {
|
|
256
|
-
return this.
|
|
266
|
+
return this.getContentData(this.format(content, mustache))
|
|
257
267
|
}
|
|
258
268
|
|
|
259
269
|
format(content, mustache) {
|
package/lib/config.js
CHANGED
|
@@ -75,6 +75,15 @@ export class Config {
|
|
|
75
75
|
return this?.settings?.cards
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
get fields() {
|
|
79
|
+
return this?.settings?.cards?.fields ?? {}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
set fields(fields) {
|
|
83
|
+
if (!this.settings.cards) this.settings.cards = {}
|
|
84
|
+
this.settings.cards.fields = fields
|
|
85
|
+
}
|
|
86
|
+
|
|
78
87
|
get defaultFilter() {
|
|
79
88
|
return this?.settings?.defaultFilter ?? ''
|
|
80
89
|
}
|
package/lib/project.js
CHANGED
|
@@ -452,7 +452,7 @@ export class WorkerProject extends Project {
|
|
|
452
452
|
}
|
|
453
453
|
|
|
454
454
|
async moveTask(task, newList, newPos) {
|
|
455
|
-
return this.repo.moveTask({task, newList, newPos})
|
|
455
|
+
return await this.repo.moveTask({task, newList, newPos})
|
|
456
456
|
}
|
|
457
457
|
|
|
458
458
|
getFile(filePath) {
|
|
@@ -878,6 +878,7 @@ export class WorkerProject extends Project {
|
|
|
878
878
|
async refresh() {
|
|
879
879
|
await this.repo.refresh()
|
|
880
880
|
await this.pluginManager.reloadPlugins()
|
|
881
|
+
return await this.toImdoneJSON()
|
|
881
882
|
}
|
|
882
883
|
|
|
883
884
|
renderMarkdown(content, filePath) {
|
package/lib/repository.js
CHANGED
|
@@ -1284,7 +1284,7 @@ export class Repository extends Emitter {
|
|
|
1284
1284
|
|
|
1285
1285
|
if (file) {
|
|
1286
1286
|
await this.readFileContent(file)
|
|
1287
|
-
return this.appendTask({file, content, list})
|
|
1287
|
+
return await this.appendTask({file, content, list})
|
|
1288
1288
|
} else {
|
|
1289
1289
|
const modifiedTime = new Date()
|
|
1290
1290
|
const createdTime = new Date()
|
|
@@ -1296,7 +1296,7 @@ export class Repository extends Emitter {
|
|
|
1296
1296
|
createdTime,
|
|
1297
1297
|
project: this.project,
|
|
1298
1298
|
})
|
|
1299
|
-
return this.appendTask({file, content, list})
|
|
1299
|
+
return await this.appendTask({file, content, list})
|
|
1300
1300
|
}
|
|
1301
1301
|
}
|
|
1302
1302
|
|
package/package.json
CHANGED
package/types/card.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export function newCard(task: any, _project: any, dontParse: any): {
|
|
2
2
|
readonly settings: any;
|
|
3
|
+
readonly fields: any;
|
|
3
4
|
readonly maxLines: any;
|
|
4
5
|
interpretedContent: any;
|
|
5
6
|
innerInterpretedContent: any;
|
|
@@ -61,7 +62,8 @@ export function newCard(task: any, _project: any, dontParse: any): {
|
|
|
61
62
|
htmlTruncLength: any;
|
|
62
63
|
isOverMaxLines: any;
|
|
63
64
|
} | undefined;
|
|
64
|
-
|
|
65
|
+
getEncodedText(content: any): string;
|
|
66
|
+
getContentData(content: any): {
|
|
65
67
|
encodedMD: string;
|
|
66
68
|
encodedText: string;
|
|
67
69
|
content: any;
|
package/types/config.d.ts
CHANGED
package/types/file.d.ts
CHANGED
|
@@ -98,6 +98,7 @@ export class File extends Emitter<[never]> {
|
|
|
98
98
|
pos: any;
|
|
99
99
|
}): {
|
|
100
100
|
readonly settings: any;
|
|
101
|
+
readonly fields: any;
|
|
101
102
|
readonly maxLines: any;
|
|
102
103
|
interpretedContent: any;
|
|
103
104
|
innerInterpretedContent: any;
|
|
@@ -159,7 +160,8 @@ export class File extends Emitter<[never]> {
|
|
|
159
160
|
htmlTruncLength: any;
|
|
160
161
|
isOverMaxLines: any;
|
|
161
162
|
} | undefined;
|
|
162
|
-
|
|
163
|
+
getEncodedText(content: any): string;
|
|
164
|
+
getContentData(content: any): {
|
|
163
165
|
encodedMD: string;
|
|
164
166
|
encodedText: string;
|
|
165
167
|
content: any;
|
package/types/project.d.ts
CHANGED
|
@@ -151,7 +151,25 @@ export class WorkerProject {
|
|
|
151
151
|
version: any;
|
|
152
152
|
}): Promise<void>;
|
|
153
153
|
uninstallPlugin(name: any): Promise<void>;
|
|
154
|
-
refresh(): Promise<
|
|
154
|
+
refresh(): Promise<{
|
|
155
|
+
path: any;
|
|
156
|
+
config: any;
|
|
157
|
+
lists: any;
|
|
158
|
+
files: any;
|
|
159
|
+
totals: {};
|
|
160
|
+
totalCards: any;
|
|
161
|
+
tags: any[];
|
|
162
|
+
allMeta: any;
|
|
163
|
+
allContexts: any[];
|
|
164
|
+
allTags: any[];
|
|
165
|
+
filter: string;
|
|
166
|
+
defaultFilter: any;
|
|
167
|
+
actions: any[];
|
|
168
|
+
plugins: any[];
|
|
169
|
+
data: {};
|
|
170
|
+
dataKeys: string[];
|
|
171
|
+
queryProps: any[];
|
|
172
|
+
}>;
|
|
155
173
|
renderMarkdown(content: any, filePath: any): any;
|
|
156
174
|
extractWikilinkTopics(markdown: any): string[];
|
|
157
175
|
}
|