imdone-core 2.0.17 → 2.0.19

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.
@@ -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
- stats = await exists(dir)
117
- if (stats) return statsProps(stats)
118
-
119
- await mkdir(dir, { recursive: true })
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.config.settings || {}
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
- getEncodedContent(content) {
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
- const encodedText = encodeURIComponent(plainDescription)
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.getEncodedContent(this.format(content, mustache))
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
  }
@@ -77,10 +77,10 @@ export default class ExtensionPlugin extends Plugin {
77
77
  // delete require.cache[extensionPath]
78
78
  extension = await import(extensionPath)
79
79
  } catch (e) {
80
- if (e.code === 'ENOENT') {
80
+ if (['ENOENT', 'ERR_MODULE_NOT_FOUND'].includes(e.code)) {
81
81
  logger.log('No extension found at:', extensionPath)
82
82
  } else {
83
- logger.warn('Error loading extension:', e.message)
83
+ logger.warn(`Error loading extension with error code ${e.code}`, e.message)
84
84
  }
85
85
  }
86
86
 
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) {
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "imdone-core",
3
- "version": "2.0.17",
3
+ "version": "2.0.19",
4
4
  "description": "imdone-core",
5
5
  "repository": {
6
6
  "type": "git",
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
- getEncodedContent(content: any): {
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
@@ -18,6 +18,8 @@ export class Config {
18
18
  constructor(opts: any);
19
19
  settings: {};
20
20
  get cards(): any;
21
+ set fields(fields: any);
22
+ get fields(): any;
21
23
  set defaultFilter(filter: any);
22
24
  get defaultFilter(): any;
23
25
  set name(name: any);
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
- getEncodedContent(content: any): {
163
+ getEncodedText(content: any): string;
164
+ getContentData(content: any): {
163
165
  encodedMD: string;
164
166
  encodedText: string;
165
167
  content: any;