imdone-core 1.47.1 → 1.47.2
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.
|
@@ -4,6 +4,7 @@ const path = require('path')
|
|
|
4
4
|
const languages = require('../../../languages')
|
|
5
5
|
const ReadStreamCodeParser = require('./ReadStreamCodeParser')
|
|
6
6
|
|
|
7
|
+
|
|
7
8
|
function getLang(languages, filePath) {
|
|
8
9
|
var lang = languages[path.extname(filePath)]
|
|
9
10
|
return lang || { name: 'text', symbol: '' }
|
|
@@ -14,10 +15,6 @@ function getLanguages(config) {
|
|
|
14
15
|
return { ...languages, ...configLanguages }
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
// DOING Use task line parsers for vs code extension and obsidian plugin
|
|
18
|
-
// <!--
|
|
19
|
-
// order:-10000030
|
|
20
|
-
// -->
|
|
21
18
|
|
|
22
19
|
module.exports.getFileParser = async function getFileParser (filePath, config, readStream) {
|
|
23
20
|
if (!readStream) {
|
|
@@ -287,16 +287,26 @@ function getTaskContent ({
|
|
|
287
287
|
getTextFileTaskContent({ config, content, beforeText, fileType })
|
|
288
288
|
}
|
|
289
289
|
|
|
290
|
-
function getRawTask ({
|
|
290
|
+
function getRawTask ({
|
|
291
|
+
tokenPrefix = DEFAULT_TOKEN_PREFIX,
|
|
292
|
+
orderMeta = true,
|
|
293
|
+
beforeText = '',
|
|
294
|
+
hasColon = false,
|
|
295
|
+
list,
|
|
296
|
+
order = '',
|
|
297
|
+
text,
|
|
298
|
+
type = TASK_TYPES.HASHTAG
|
|
299
|
+
}) {
|
|
291
300
|
if (type === TASK_TYPES.MARKDOWN) {
|
|
292
|
-
return `${beforeText}[${text}](${tokenPrefix}${list}:${
|
|
301
|
+
return `${beforeText || ''}[${text}](${tokenPrefix}${list}:${
|
|
293
302
|
orderMeta ? '' : order
|
|
294
303
|
})`
|
|
304
|
+
} else {
|
|
305
|
+
const colon = hasColon || (isNumber(order) && !orderMeta) ? ':' : '';
|
|
306
|
+
return `${beforeText || ''}${tokenPrefix}${list}${colon}${
|
|
307
|
+
orderMeta ? '' : order
|
|
308
|
+
} ${text}`
|
|
295
309
|
}
|
|
296
|
-
const colon = hasColon || (isNumber(order) && !orderMeta) ? ':' : '';
|
|
297
|
-
return `${beforeText}${tokenPrefix}${list}${colon}${
|
|
298
|
-
orderMeta ? '' : order
|
|
299
|
-
} ${text}`
|
|
300
310
|
}
|
|
301
311
|
|
|
302
312
|
function isNumber (value) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const Plugin = require('imdone-api')
|
|
2
2
|
const path = require('path')
|
|
3
|
+
const { getRawTask } = require('../adapters/parsers/task/CardContentParser')
|
|
3
4
|
|
|
4
5
|
module.exports = class ArchivePlugin extends Plugin {
|
|
5
6
|
constructor(project) {
|
|
@@ -14,24 +15,28 @@ module.exports = class ArchivePlugin extends Plugin {
|
|
|
14
15
|
return this.project.fileGateway
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
onBeforeBoardUpdate() {
|
|
18
|
+
async onBeforeBoardUpdate() {
|
|
18
19
|
const config = this.config
|
|
19
20
|
if (!config || !config.archiveCompleted || this.archivingTasks) return
|
|
20
21
|
this.archivingTasks = true
|
|
21
22
|
const cards = this.project.getAllCards(`meta.archived != "true" and list = ${config.doneList}`)
|
|
22
23
|
const messageUser = cards.length > 1
|
|
24
|
+
|
|
23
25
|
if (!cards.length) {
|
|
24
26
|
this.archivingTasks = false
|
|
25
27
|
return
|
|
26
28
|
} else {
|
|
27
29
|
if (messageUser) this.project.snackBar({message: `Archiving ${cards.length} card(s)...`})
|
|
28
30
|
}
|
|
31
|
+
|
|
29
32
|
cards.forEach(card => this.archiveTask(card))
|
|
33
|
+
|
|
30
34
|
if (messageUser) this.project.snackBar({message: ` Done archiving ${cards.length} card(s). Deleting original(s)...`})
|
|
31
|
-
this.project.deleteTasks(cards)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
})
|
|
35
|
+
await this.project.deleteTasks(cards)
|
|
36
|
+
|
|
37
|
+
this.archivingTasks = false
|
|
38
|
+
if (messageUser) this.project.snackBar({message: `Done deleting original card(s).`})
|
|
39
|
+
|
|
35
40
|
}
|
|
36
41
|
|
|
37
42
|
archiveTask (task, config = this.config) {
|
|
@@ -57,8 +62,11 @@ module.exports = class ArchivePlugin extends Plugin {
|
|
|
57
62
|
// #imdone-1.47.0
|
|
58
63
|
// order:-110
|
|
59
64
|
// -->
|
|
60
|
-
const
|
|
61
|
-
|
|
65
|
+
const { tokenPrefix } = config
|
|
66
|
+
const { beforeText, list } = task
|
|
67
|
+
const taskStart = getRawTask({tokenPrefix, beforeText, list, text: ''})
|
|
68
|
+
const taskContent = `${taskStart} ${content}\n\n\n`
|
|
69
|
+
|
|
62
70
|
this.fileGateway.preparePathForWriting(newPath)
|
|
63
71
|
this.fileGateway.appendFileSync(newPath, taskContent)
|
|
64
72
|
}
|
package/lib/repository.js
CHANGED
|
@@ -465,6 +465,7 @@ Repository.prototype.addFile = function (file, cb) {
|
|
|
465
465
|
if (this.destroyed) return cb(new Error('destroyed'))
|
|
466
466
|
var self = this
|
|
467
467
|
this.fileOK(file, function (err, ok) {
|
|
468
|
+
if (err) return cb(err)
|
|
468
469
|
if (ok) {
|
|
469
470
|
var index = self.files.findIndex(({ path }) => path === file.path)
|
|
470
471
|
if (index > -1) {
|
|
@@ -945,10 +946,10 @@ Repository.prototype.writeAndExtract = function (file, emit, cb) {
|
|
|
945
946
|
if (err)
|
|
946
947
|
return cb(new Error('Unable to extract tasks for file:' + file.path))
|
|
947
948
|
this.addFile(file, (err) => {
|
|
948
|
-
if (err)
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
949
|
+
if (err) {
|
|
950
|
+
err.message = `Unable to add file after extracting tasks: #{file.path}\n${err.message}`
|
|
951
|
+
return cb(err)
|
|
952
|
+
}
|
|
952
953
|
cb(null, file)
|
|
953
954
|
})
|
|
954
955
|
})
|
|
@@ -2,19 +2,15 @@ const Config = require('../config')
|
|
|
2
2
|
const { getFileParser } = require('../adapters/parsers/file/LocalFileParserFactory')
|
|
3
3
|
const { Readable } = require('stream');
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
// <!--
|
|
7
|
-
// order:-10000030
|
|
8
|
-
// -->
|
|
5
|
+
|
|
9
6
|
export async function getTasks({filePath, content}) {
|
|
10
7
|
const projectPath = await Config.findImdonePath(filePath)
|
|
11
8
|
const config = await Config.load(projectPath)
|
|
12
9
|
|
|
13
|
-
// create a readstream from the content and pass it to getFileParser
|
|
14
10
|
const readStream = new Readable({
|
|
15
11
|
read() {
|
|
16
12
|
this.push(content);
|
|
17
|
-
this.push(null);
|
|
13
|
+
this.push(null);
|
|
18
14
|
}
|
|
19
15
|
});
|
|
20
16
|
|