imdone-core 1.54.10 → 2.0.1
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/.dependency-cruiser.cjs +412 -0
- package/.github/workflows/ci.yml +2 -2
- package/.imdoneignore +2 -1
- package/README.md +2 -2
- package/_index.md +7 -0
- package/build.js +57 -0
- package/esm-migration.md +446 -0
- package/lib/FileProjectContext.js +13 -0
- package/lib/ProjectContext.js +19 -18
- package/lib/adapters/date-time.js +3 -8
- package/lib/adapters/environment.js +3 -0
- package/lib/adapters/file-gateway.js +133 -106
- package/lib/adapters/git-download.js +36 -16
- package/lib/adapters/index.js +9 -0
- package/lib/adapters/logger.js +136 -0
- package/lib/adapters/markdown.js +31 -19
- package/lib/adapters/parsers/DateLanguageParser.js +11 -9
- package/lib/adapters/parsers/content-transformer.js +35 -30
- package/lib/adapters/parsers/file/LocalFileParserFactory.js +8 -9
- package/lib/adapters/parsers/file/ReadStreamCodeParser.js +8 -8
- package/lib/adapters/parsers/file/ReadStreamMarkdownParser.js +4 -4
- package/lib/adapters/parsers/file/ReadStreamTaskParser.js +5 -3
- package/lib/adapters/parsers/file/index.js +4 -0
- package/lib/adapters/parsers/function-parser.js +1 -5
- package/lib/adapters/parsers/index.js +5 -0
- package/lib/adapters/parsers/task/CardContentParser.js +23 -32
- package/lib/adapters/parsers/task/CheckStyleTaskParser.js +2 -2
- package/lib/adapters/parsers/task/CodeStyleTaskParser.js +2 -2
- package/lib/adapters/parsers/task/HashStyleTaskParser.js +3 -3
- package/lib/adapters/parsers/task/MarkdownStyleTaskParser.js +2 -2
- package/lib/adapters/parsers/task/TaskParser.js +1 -1
- package/lib/adapters/parsers/task/index.js +6 -0
- package/lib/adapters/storage/config.js +15 -20
- package/lib/adapters/storage/index.js +2 -0
- package/lib/adapters/storage/tags.js +11 -12
- package/lib/adapters/yaml.js +8 -5
- package/lib/card.js +25 -26
- package/lib/checksum.js +22 -0
- package/lib/cli.js +114 -0
- package/lib/config.js +106 -71
- package/lib/constants.js +21 -50
- package/lib/context/ApplicationContext.js +7 -4
- package/lib/context/index.js +1 -0
- package/lib/default-settings.js +3 -3
- package/lib/domain/entities/View.js +4 -11
- package/lib/domain/entities/index.js +1 -0
- package/lib/domain/index.js +2 -0
- package/lib/domain/usecases/GetViewsUsecase.js +6 -12
- package/lib/domain/usecases/SaveViewUsecase.js +8 -14
- package/lib/domain/usecases/index.js +2 -0
- package/lib/file.js +1158 -1162
- package/lib/get-tasks-to-modify.js +117 -0
- package/lib/index.js +23 -0
- package/lib/languages.js +4 -5
- package/lib/list.js +46 -95
- package/lib/migrate-config.js +5 -5
- package/lib/mixins/index.js +2 -0
- package/lib/mixins/repo-fs-store.js +224 -289
- package/lib/mixins/repo-watched-fs-store.js +158 -147
- package/lib/plugins/archive-plugin.js +10 -8
- package/lib/plugins/default-board-actions-plugin.js +2 -2
- package/lib/plugins/default-board-properties-plugin.js +7 -7
- package/lib/plugins/default-plugins.js +7 -0
- package/lib/plugins/epic-plugin.js +6 -5
- package/lib/plugins/extension-plugin.js +24 -17
- package/lib/plugins/index.js +9 -0
- package/lib/plugins/persist-tags-plugin.js +4 -3
- package/lib/plugins/plugin-manager.js +89 -52
- package/lib/plugins/plugin-registry.js +12 -16
- package/lib/project-factory.js +21 -24
- package/lib/project.js +97 -144
- package/lib/repository.js +1323 -1555
- package/lib/task.js +562 -580
- package/lib/tools.js +39 -113
- package/lib/usecases/actions.js +32 -0
- package/lib/usecases/get-project-tags.js +3 -12
- package/lib/usecases/get-tasks-in-file.js +4 -7
- package/lib/usecases/index.js +4 -0
- package/package.json +44 -66
- package/scripts/delete-markdown-indexes.js +87 -0
- package/scripts/generate-index.js +35 -0
- package/{index-markdown.js → scripts/index-markdown.js} +7 -7
- package/tsconfig.json +15 -0
- package/types/FileProjectContext.d.ts +4 -0
- package/types/ProjectContext.d.ts +9 -0
- package/types/adapters/date-time.d.ts +2 -0
- package/types/adapters/environment.d.ts +1 -0
- package/types/adapters/file-gateway.d.ts +51 -0
- package/types/adapters/git-download.d.ts +1 -0
- package/types/adapters/index.d.ts +9 -0
- package/types/adapters/logger.d.ts +24 -0
- package/types/adapters/markdown.d.ts +13 -0
- package/types/adapters/parsers/DateLanguageParser.d.ts +1 -0
- package/types/adapters/parsers/content-transformer.d.ts +10 -0
- package/types/adapters/parsers/file/LocalFileParserFactory.d.ts +5 -0
- package/types/adapters/parsers/file/ReadStreamCodeParser.d.ts +13 -0
- package/types/adapters/parsers/file/ReadStreamMarkdownParser.d.ts +7 -0
- package/types/adapters/parsers/file/ReadStreamTaskParser.d.ts +19 -0
- package/types/adapters/parsers/file/index.d.ts +4 -0
- package/types/adapters/parsers/function-parser.d.ts +1 -0
- package/types/adapters/parsers/index.d.ts +5 -0
- package/types/adapters/parsers/task/CardContentParser.d.ts +45 -0
- package/types/adapters/parsers/task/CheckStyleTaskParser.d.ts +12 -0
- package/types/adapters/parsers/task/CodeStyleTaskParser.d.ts +14 -0
- package/types/adapters/parsers/task/HashStyleTaskParser.d.ts +13 -0
- package/types/adapters/parsers/task/MarkdownStyleTaskParser.d.ts +14 -0
- package/types/adapters/parsers/task/TaskParser.d.ts +7 -0
- package/types/adapters/parsers/task/index.d.ts +6 -0
- package/types/adapters/storage/config.d.ts +6 -0
- package/types/adapters/storage/index.d.ts +2 -0
- package/types/adapters/storage/tags.d.ts +3 -0
- package/types/adapters/yaml.d.ts +2 -0
- package/types/card.d.ts +166 -0
- package/types/checksum.d.ts +8 -0
- package/types/config.d.ts +61 -0
- package/types/constants.d.ts +46 -0
- package/types/context/ApplicationContext.d.ts +24 -0
- package/types/context/index.d.ts +1 -0
- package/types/default-settings.d.ts +2 -0
- package/types/domain/entities/FileProjectContext.d.ts +5 -0
- package/types/domain/entities/View.d.ts +17 -0
- package/types/domain/entities/index.d.ts +1 -0
- package/types/domain/index.d.ts +2 -0
- package/types/domain/usecases/GetViewsUsecase.d.ts +4 -0
- package/types/domain/usecases/SaveViewUsecase.d.ts +8 -0
- package/types/domain/usecases/index.d.ts +2 -0
- package/types/file.d.ts +344 -0
- package/types/get-tasks-to-modify.d.ts +3 -0
- package/types/index.d.ts +23 -0
- package/types/languages.d.ts +649 -0
- package/types/list.d.ts +30 -0
- package/types/migrate-config.d.ts +1 -0
- package/types/mixins/index.d.ts +2 -0
- package/types/mixins/repo-fs-store.d.ts +2 -0
- package/types/mixins/repo-watched-fs-store.d.ts +2 -0
- package/types/plugins/archive-plugin.d.ts +8 -0
- package/types/plugins/default-board-actions-plugin.d.ts +9 -0
- package/types/plugins/default-board-properties-plugin.d.ts +16 -0
- package/types/plugins/default-plugins.d.ts +6 -0
- package/types/plugins/epic-plugin.d.ts +19 -0
- package/types/plugins/extension-plugin.d.ts +15 -0
- package/types/plugins/index.d.ts +9 -0
- package/types/plugins/persist-tags-plugin.d.ts +4 -0
- package/types/plugins/plugin-manager.d.ts +68 -0
- package/types/plugins/plugin-registry.d.ts +1 -0
- package/types/project-factory.d.ts +14 -0
- package/types/project.d.ts +158 -0
- package/types/repository.d.ts +996 -0
- package/types/task.d.ts +202 -0
- package/types/tools.d.ts +29 -0
- package/types/usecases/actions.d.ts +7 -0
- package/types/usecases/get-imdone-url.d.ts +1 -0
- package/types/usecases/get-project-tags.d.ts +1 -0
- package/types/usecases/get-tasks-in-file.d.ts +4 -0
- package/types/usecases/index.d.ts +4 -0
- package/vitest.config.js +13 -0
- package/cli.js +0 -74
- package/index.js +0 -1
- package/lib/adapters/readers/FileSystemProjectReader.js +0 -45
- package/lib/context/StreamingApplicationContext.js +0 -31
- package/lib/controlers/SaveViewController.js +0 -10
- package/lib/domain/entities/FileProjectContext.js +0 -10
- package/lib/domain/usecases/OpenProjectUsecase.js +0 -13
|
@@ -1,35 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
module.exports = {
|
|
5
|
-
format,
|
|
6
|
-
encodeMarkdownLinks
|
|
7
|
-
}
|
|
1
|
+
import { Eta } from "eta"
|
|
2
|
+
import uniqid from 'uniqid';
|
|
8
3
|
|
|
9
4
|
function removeDisplayComments(description) {
|
|
10
|
-
return description.replace(/<!--\s*\[([\s\S]*?)\]\s*-->/g, '$1')
|
|
5
|
+
return description.replace(/<!--\s*\[([\s\S]*?)\]\s*-->/g, '$1');
|
|
11
6
|
}
|
|
12
7
|
|
|
13
8
|
function escapeCodeBlocks(content) {
|
|
14
|
-
const codeBlockRegex = /(```[\s\S]*?```|`[^`]*`)/g
|
|
15
|
-
let codeBlocks = []
|
|
16
|
-
|
|
9
|
+
const codeBlockRegex = /(```[\s\S]*?```|`[^`]*`)/g;
|
|
10
|
+
let codeBlocks = [];
|
|
11
|
+
|
|
17
12
|
// Replace code blocks with unique keys
|
|
18
13
|
content = content.replace(codeBlockRegex, (match) => {
|
|
19
|
-
const key = `__CODE_BLOCK_${codeBlocks.length}__
|
|
20
|
-
codeBlocks.push(match) // Maintain order
|
|
21
|
-
return key
|
|
22
|
-
})
|
|
14
|
+
const key = `__CODE_BLOCK_${codeBlocks.length}__`;
|
|
15
|
+
codeBlocks.push(match); // Maintain order
|
|
16
|
+
return key;
|
|
17
|
+
});
|
|
23
18
|
|
|
24
|
-
return { content, codeBlocks }
|
|
19
|
+
return { content, codeBlocks };
|
|
25
20
|
}
|
|
26
21
|
|
|
27
22
|
function restoreCodeBlocks(content, codeBlocks) {
|
|
28
23
|
// Restore code blocks in order using stored array
|
|
29
24
|
codeBlocks.forEach((code, index) => {
|
|
30
|
-
content = content.replace(`__CODE_BLOCK_${index}__`, code)
|
|
31
|
-
})
|
|
32
|
-
return content
|
|
25
|
+
content = content.replace(`__CODE_BLOCK_${index}__`, code);
|
|
26
|
+
});
|
|
27
|
+
return content;
|
|
33
28
|
}
|
|
34
29
|
|
|
35
30
|
/**
|
|
@@ -39,39 +34,50 @@ function restoreCodeBlocks(content, codeBlocks) {
|
|
|
39
34
|
* @param {object} opts - The options for interpolation.
|
|
40
35
|
* @returns {object} - The interpolated content, whether there was interpolation, and error tokens.
|
|
41
36
|
*/
|
|
42
|
-
function interpolate(content, data, opts) {
|
|
37
|
+
export function interpolate(content, data, opts = { tags: ['${', '}'] }) {
|
|
43
38
|
const errorTokens = {};
|
|
39
|
+
const { tags } = opts;
|
|
40
|
+
// /(?<![`\\])\${([\s\S]+?)}/g
|
|
41
|
+
const regex = new RegExp(`(?<![\`\\\\])\\${tags[0]}([\\s\\S]+?)${tags[1]}`, 'g');
|
|
44
42
|
let hasInterpolation = false;
|
|
45
43
|
|
|
46
|
-
content = content.replace(
|
|
44
|
+
content = content.replace(regex, (match, p1) => {
|
|
47
45
|
try {
|
|
48
|
-
const
|
|
46
|
+
const eta = new Eta({ tags, useWith: true, autoEscape: false });
|
|
47
|
+
const [startTag, endTag] = opts.tags;
|
|
48
|
+
const template = `${startTag}= ${p1} ${endTag}`;
|
|
49
|
+
const result = eta.renderString(template, data);
|
|
49
50
|
if (result !== match) {
|
|
50
51
|
hasInterpolation = true;
|
|
51
52
|
}
|
|
52
|
-
return result;
|
|
53
|
+
return result || '';
|
|
53
54
|
} catch (e) {
|
|
54
55
|
const token = `__ERROR_TOKEN_${uniqid()}__`;
|
|
55
56
|
errorTokens[token] = match;
|
|
56
|
-
return token;
|
|
57
|
+
return token || '';
|
|
57
58
|
}
|
|
58
59
|
});
|
|
59
60
|
|
|
60
61
|
return { content, hasInterpolation, errorTokens };
|
|
61
62
|
}
|
|
62
63
|
|
|
63
|
-
function encodeMarkdownLinks(content) {
|
|
64
|
+
export function encodeMarkdownLinks(content) {
|
|
64
65
|
return content.replace(/(?<!!)\[(.*?)\]\((.*?)( ".*?")?\)/g, (match, p1, p2, p3) => {
|
|
65
66
|
// URI encode file links
|
|
66
67
|
const title = p3 || '';
|
|
67
68
|
const encodedUrl = p2.replace(/\s/g, '%20').replace(/\)/g, '%29').replace(/\(/g, '%28');
|
|
68
69
|
const link = `[${p1}](${encodedUrl}${title})`;
|
|
70
|
+
|
|
71
|
+
// If there is more than one space in the URL, assume there's no title
|
|
72
|
+
if ((p2.match(/\s/g) || []).length > 1) {
|
|
73
|
+
return `[${p1}](${encodedUrl})`;
|
|
74
|
+
}
|
|
75
|
+
|
|
69
76
|
return link.replace(/%20(".*?"\))$/, ' $1');
|
|
70
77
|
});
|
|
71
78
|
}
|
|
72
79
|
|
|
73
|
-
function format(content, data, mustache) {
|
|
74
|
-
const opts = { interpolate: /(?<![`\\])\${([\s\S]+?)}/g };
|
|
80
|
+
export function format(content, data, mustache) {
|
|
75
81
|
const errorTokens = {};
|
|
76
82
|
|
|
77
83
|
if (mustache) content = removeDisplayComments(content);
|
|
@@ -83,17 +89,16 @@ function format(content, data, mustache) {
|
|
|
83
89
|
let hasInterpolation = true;
|
|
84
90
|
|
|
85
91
|
while (hasInterpolation) {
|
|
86
|
-
const interpolationResult = interpolate(result, data,
|
|
92
|
+
const interpolationResult = interpolate(result, data, { tags: ['${', '}'] });
|
|
87
93
|
result = interpolationResult.content;
|
|
88
94
|
hasInterpolation = interpolationResult.hasInterpolation;
|
|
89
95
|
Object.assign(errorTokens, interpolationResult.errorTokens);
|
|
90
96
|
}
|
|
91
97
|
|
|
92
98
|
if (mustache) {
|
|
93
|
-
const mustacheOpts = { interpolate: /(?<!`){{([\s\S]+?)}}/g };
|
|
94
99
|
hasInterpolation = true;
|
|
95
100
|
while (hasInterpolation) {
|
|
96
|
-
const interpolationResult = interpolate(result, data,
|
|
101
|
+
const interpolationResult = interpolate(result, data, { tags: ['{{', '}}'] });
|
|
97
102
|
result = interpolationResult.content;
|
|
98
103
|
hasInterpolation = interpolationResult.hasInterpolation;
|
|
99
104
|
Object.assign(errorTokens, interpolationResult.errorTokens);
|
|
@@ -1,23 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { createReadStream } from 'node:fs'
|
|
2
|
+
import { ReadStreamMarkdownParser } from './ReadStreamMarkdownParser.js'
|
|
3
|
+
import path from 'node:path'
|
|
4
|
+
import { languages } from '../../../languages.js'
|
|
5
|
+
import { ReadStreamCodeParser } from './ReadStreamCodeParser.js'
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
function getLang(config, filePath) {
|
|
8
|
+
export function getLang(config, filePath) {
|
|
9
9
|
const languages = getLanguages(config)
|
|
10
10
|
var lang = languages[path.extname(filePath)]
|
|
11
11
|
return lang || { name: 'text', symbol: '' }
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
function getLanguages(config) {
|
|
14
|
+
export function getLanguages(config) {
|
|
15
15
|
const configLanguages = config.languages || {}
|
|
16
16
|
return { ...languages, ...configLanguages }
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
module.exports.getFileParser = async function getFileParser (filePath, config, readStream) {
|
|
19
|
+
export async function getFileParser (filePath, config, readStream) {
|
|
21
20
|
if (!readStream) {
|
|
22
21
|
readStream = createReadStream(filePath)
|
|
23
22
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import path from 'node:path'
|
|
2
|
+
import { ReadStreamTaskParser } from './ReadStreamTaskParser.js'
|
|
3
|
+
import { CodeStyleTaskParser } from '../task/CodeStyleTaskParser.js'
|
|
4
|
+
import { languages } from '../../../languages.js'
|
|
5
|
+
import extractComments from 'multilang-extract-comments'
|
|
6
|
+
import eol from 'eol'
|
|
7
|
+
import { Readable } from 'node:stream'
|
|
8
8
|
|
|
9
9
|
// TODO Move to readstream parsing for code to improve performance
|
|
10
10
|
// <!--
|
|
@@ -12,7 +12,7 @@ const { Readable } = require('stream')
|
|
|
12
12
|
// #imdone-1.55.0
|
|
13
13
|
// order:-205
|
|
14
14
|
// -->
|
|
15
|
-
|
|
15
|
+
export class ReadStreamCodeParser extends ReadStreamTaskParser {
|
|
16
16
|
constructor(readStream, filePath, lang, lists) {
|
|
17
17
|
super(readStream)
|
|
18
18
|
this.lists = lists
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { ReadStreamTaskParser } from './ReadStreamTaskParser.js'
|
|
2
|
+
import { HashStyleTaskParser } from '../task/HashStyleTaskParser.js'
|
|
3
|
+
import { MarkdownStyleTaskParser } from '../task/MarkdownStyleTaskParser.js'
|
|
4
4
|
// const CheckStyleTaskParser = require('../task/CheckStyleTaskParser')
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
export class ReadStreamMarkdownParser extends ReadStreamTaskParser {
|
|
7
7
|
constructor(readStream, config) {
|
|
8
8
|
super(readStream, config)
|
|
9
9
|
this.taskParsers = [
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import * as ReadLine from 'node:readline/promises';
|
|
2
|
+
import { logger } from '../../logger.js';
|
|
3
|
+
|
|
2
4
|
const blankLinesToEndTask = 2
|
|
3
5
|
|
|
4
|
-
|
|
6
|
+
export class ReadStreamTaskParser {
|
|
5
7
|
constructor(readStream) {
|
|
6
8
|
this.readStream = readStream
|
|
7
9
|
this.task = null
|
|
@@ -40,7 +42,7 @@ module.exports = class ReadStreamTaskParser {
|
|
|
40
42
|
}
|
|
41
43
|
}
|
|
42
44
|
} catch (error) {
|
|
43
|
-
|
|
45
|
+
logger.log('Error reading line')
|
|
44
46
|
throw error
|
|
45
47
|
}
|
|
46
48
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import eol from 'eol'
|
|
2
|
+
import XRegExp from 'xregexp'
|
|
3
3
|
|
|
4
|
-
const FILE_TYPES = {
|
|
4
|
+
export const FILE_TYPES = {
|
|
5
5
|
MARKDOWN: 'markdown',
|
|
6
6
|
CODE: 'code',
|
|
7
7
|
}
|
|
8
|
-
const TASK_TYPES = {
|
|
8
|
+
export const TASK_TYPES = {
|
|
9
9
|
CODE: 'CODE',
|
|
10
10
|
HASHTAG: 'HASHTAG',
|
|
11
11
|
MARKDOWN: 'MARKDOWN',
|
|
@@ -15,15 +15,16 @@ const DEFAULT_TOKEN_PREFIX = '#'
|
|
|
15
15
|
const START_TAG = '<card>'
|
|
16
16
|
const END_TAG = '</card>'
|
|
17
17
|
const CODE_STYLE_PATTERN = '([A-Z]+[A-Z-_]+?)((:)(-?[\\d.]+(?:e-?\\d+)?)?)?[ \\t]+(.+)$'
|
|
18
|
-
|
|
19
|
-
const
|
|
18
|
+
|
|
19
|
+
export const LIST_NAME_PATTERN = '[\\p{L}0-9-_]{2,}' // [a-zA-Z-_]+?
|
|
20
|
+
export const LINK_STYLE_REGEX = new XRegExp(
|
|
20
21
|
`(\\[.*\\]\\s?)?(\\[(.+)\\]\\(#(${LIST_NAME_PATTERN})(:)(-?[\\d.]+(?:e-?\\d+)?)?\\))`,
|
|
21
22
|
'gm'
|
|
22
23
|
)
|
|
23
24
|
|
|
24
|
-
const CHECK_REGEX = /^(\s*- )\[([x ])\]/
|
|
25
|
+
export const CHECK_REGEX = /^(\s*- )\[([x ])\]/
|
|
25
26
|
|
|
26
|
-
function getHashStyleRegex(tokenPrefix = DEFAULT_TOKEN_PREFIX, orderMeta = false) {
|
|
27
|
+
export function getHashStyleRegex(tokenPrefix = DEFAULT_TOKEN_PREFIX, orderMeta = false) {
|
|
27
28
|
return orderMeta ?
|
|
28
29
|
new XRegExp(
|
|
29
30
|
`${tokenPrefix}(${LIST_NAME_PATTERN})[ \\t]+(.+)$`, 'gm'
|
|
@@ -34,7 +35,7 @@ function getHashStyleRegex(tokenPrefix = DEFAULT_TOKEN_PREFIX, orderMeta = false
|
|
|
34
35
|
)
|
|
35
36
|
}
|
|
36
37
|
|
|
37
|
-
function getCheckedData(content) {
|
|
38
|
+
export function getCheckedData(content) {
|
|
38
39
|
const taskRegex = new RegExp(CHECK_REGEX)
|
|
39
40
|
const result = taskRegex.exec(content)
|
|
40
41
|
return result
|
|
@@ -73,7 +74,7 @@ function isCheckBoxTask (config, line, beforeText) {
|
|
|
73
74
|
return lineCheckData.pad <= beforeTextCheckData.pad
|
|
74
75
|
}
|
|
75
76
|
|
|
76
|
-
function hasTaskInText(config, text, isCodeFile) {
|
|
77
|
+
export function hasTaskInText(config, text, isCodeFile) {
|
|
77
78
|
const hashStyleRegex = new XRegExp(getHashStyleRegex(config.tokenPrefix));
|
|
78
79
|
const linkStyleRegex = new XRegExp(LINK_STYLE_REGEX);
|
|
79
80
|
|
|
@@ -97,18 +98,18 @@ function hasTaskInText(config, text, isCodeFile) {
|
|
|
97
98
|
// Check for hash style tasks
|
|
98
99
|
let result;
|
|
99
100
|
if ((result = hashStyleRegex.exec(text)) !== null && !isWithinInlineCode(result.index)) {
|
|
100
|
-
return config.lists.find((list) => text.includes(`${config.tokenPrefix}${list.name}`));
|
|
101
|
+
return !!config.lists.find((list) => text.includes(`${config.tokenPrefix}${list.name}`));
|
|
101
102
|
}
|
|
102
103
|
|
|
103
104
|
// Check for link style tasks
|
|
104
105
|
if ((result = linkStyleRegex.exec(text)) !== null && !isWithinInlineCode(result.index)) {
|
|
105
|
-
return config.lists.find((list) => text.includes(`${config.tokenPrefix}${list.name}`));
|
|
106
|
+
return !!config.lists.find((list) => text.includes(`${config.tokenPrefix}${list.name}`));
|
|
106
107
|
}
|
|
107
108
|
|
|
108
109
|
return false;
|
|
109
110
|
}
|
|
110
111
|
|
|
111
|
-
function isBeforeTextMarkdownList(beforeText) {
|
|
112
|
+
export function isBeforeTextMarkdownList(beforeText) {
|
|
112
113
|
return /^\s*(\*|-|- \[[x| ]\]|\d+\.|[a-zA-Z]\.)\s$/.test(beforeText)
|
|
113
114
|
}
|
|
114
115
|
|
|
@@ -116,7 +117,7 @@ function isMarkdownListItem(line) {
|
|
|
116
117
|
return /^\s*(\*|-|- \[[x| ]\]|\d+\.|[a-zA-Z]\.)\s/.test(line)
|
|
117
118
|
}
|
|
118
119
|
|
|
119
|
-
function padDescription(description = [], beforeText = '') {
|
|
120
|
+
export function padDescription(description = [], beforeText = '') {
|
|
120
121
|
if (!isBeforeTextMarkdownList(beforeText)) return description
|
|
121
122
|
return description.map((line) => {
|
|
122
123
|
return line.padStart(line.length + beforeText.length)
|
|
@@ -320,7 +321,7 @@ function getTextFileTaskContent ({
|
|
|
320
321
|
}
|
|
321
322
|
}
|
|
322
323
|
|
|
323
|
-
function getTaskContent ({
|
|
324
|
+
export function getTaskContent ({
|
|
324
325
|
config,
|
|
325
326
|
content,
|
|
326
327
|
inBlockComment,
|
|
@@ -333,7 +334,7 @@ function getTaskContent ({
|
|
|
333
334
|
getTextFileTaskContent({ config, content, beforeText, fileType })
|
|
334
335
|
}
|
|
335
336
|
|
|
336
|
-
function getRawTask ({
|
|
337
|
+
export function getRawTask ({
|
|
337
338
|
tokenPrefix = DEFAULT_TOKEN_PREFIX,
|
|
338
339
|
orderMeta = true,
|
|
339
340
|
beforeText = '',
|
|
@@ -355,22 +356,12 @@ function getRawTask ({
|
|
|
355
356
|
}
|
|
356
357
|
}
|
|
357
358
|
|
|
358
|
-
function isNumber
|
|
359
|
-
return !isNaN(
|
|
359
|
+
export function isNumber(value) {
|
|
360
|
+
return !isNaN(value) && isFinite(Number(value));
|
|
360
361
|
}
|
|
361
362
|
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
getRawTask,
|
|
367
|
-
isBeforeTextMarkdownList,
|
|
368
|
-
padDescription,
|
|
369
|
-
getCheckedData,
|
|
370
|
-
hasTaskInText,
|
|
371
|
-
isNumber,
|
|
372
|
-
getHashStyleRegex,
|
|
373
|
-
CHECK_REGEX,
|
|
374
|
-
LIST_NAME_PATTERN,
|
|
375
|
-
LINK_STYLE_REGEX
|
|
363
|
+
export function toNumber(value) {
|
|
364
|
+
if (value == null || value == undefined) return undefined; // Convert null or undefined to undefined
|
|
365
|
+
const num = Number(value);
|
|
366
|
+
return isNaN(num) ? undefined : num; // Return 0 if conversion fails, otherwise return the number
|
|
376
367
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { TaskParser } from './TaskParser.js'
|
|
2
|
+
import { getHashStyleRegex } from './CardContentParser.js'
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
export class HashStyleTaskParser extends TaskParser {
|
|
5
5
|
constructor(config) {
|
|
6
6
|
super('HASHTAG', config)
|
|
7
7
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { TaskParser } from './TaskParser.js'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
export class MarkdownStyleTaskParser extends TaskParser {
|
|
4
4
|
constructor(config) {
|
|
5
5
|
super('MARKDOWN', config)
|
|
6
6
|
}
|
|
@@ -1,33 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
loadForFilePath,
|
|
12
|
-
findImdonePath
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
async function load(projectPath, configPath = _path.join(projectPath, CONFIG_FILE_YML)) {
|
|
1
|
+
import { readFile, writeFile, exists } from '../file-gateway.js'
|
|
2
|
+
import { constants } from '../../constants.js'
|
|
3
|
+
import { loadYAML, dumpYAML } from '../yaml.js'
|
|
4
|
+
import { findUp } from 'find-up-simple'
|
|
5
|
+
import _path from 'path'
|
|
6
|
+
import { Config } from '../../config.js'
|
|
7
|
+
import { logger } from '../logger.js'
|
|
8
|
+
|
|
9
|
+
const { CONFIG_DIR, CONFIG_FILE_YML } = constants
|
|
10
|
+
export async function load(projectPath, configPath = _path.join(projectPath, CONFIG_FILE_YML)) {
|
|
16
11
|
const configLike = await loadYamlConfig(configPath)
|
|
17
12
|
return configLike && new Config(configLike)
|
|
18
13
|
}
|
|
19
14
|
|
|
20
|
-
async function save(config, projectPath) {
|
|
15
|
+
export async function save(config, projectPath) {
|
|
21
16
|
const configPath = _path.join(projectPath, CONFIG_FILE_YML)
|
|
22
17
|
await writeFile(configPath, dumpYAML(config))
|
|
23
18
|
}
|
|
24
19
|
|
|
25
|
-
async function loadForFilePath(filePath) {
|
|
20
|
+
export async function loadForFilePath(filePath) {
|
|
26
21
|
const projectPath = await findImdonePath(filePath)
|
|
27
22
|
return load(projectPath)
|
|
28
23
|
}
|
|
29
24
|
|
|
30
|
-
async function loadYamlConfig(filePath) {
|
|
25
|
+
export async function loadYamlConfig(filePath) {
|
|
31
26
|
if (!(await exists(filePath))) return
|
|
32
27
|
const configData = await readFile(filePath, 'utf-8')
|
|
33
28
|
let configLike = {}
|
|
@@ -37,12 +32,12 @@ async function loadYamlConfig(filePath) {
|
|
|
37
32
|
if (configLike.watcher) delete configLike.watcher
|
|
38
33
|
|
|
39
34
|
} catch (e) {
|
|
40
|
-
|
|
35
|
+
logger.error(`Error parsing config file: ${filePath}`)
|
|
41
36
|
}
|
|
42
37
|
return configLike
|
|
43
38
|
}
|
|
44
39
|
|
|
45
|
-
async function findImdonePath(cwd) {
|
|
40
|
+
export async function findImdonePath(cwd) {
|
|
46
41
|
const configDir = await findUp(CONFIG_DIR, { cwd, type: 'directory' })
|
|
47
42
|
return _path.dirname(configDir)
|
|
48
43
|
}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const {
|
|
4
|
-
|
|
1
|
+
import { readFile, writeFile, exists } from '../file-gateway.js'
|
|
2
|
+
import { constants } from '../../constants.js'
|
|
3
|
+
const { CONFIG_DIR } = constants
|
|
4
|
+
import { loadYAML, dumpYAML } from '../yaml.js'
|
|
5
|
+
import _path from 'path'
|
|
6
|
+
import { logger } from '../logger.js'
|
|
5
7
|
|
|
6
|
-
|
|
7
|
-
load,
|
|
8
|
-
save
|
|
9
|
-
}
|
|
8
|
+
export const TAGS_FILE_PATH = _path.join(CONFIG_DIR, 'tags.yml')
|
|
10
9
|
|
|
11
|
-
async function load(projectPath) {
|
|
10
|
+
export async function load(projectPath) {
|
|
12
11
|
const tagsPath = getTagsPath(projectPath)
|
|
13
12
|
if (!(await exists(tagsPath))) return
|
|
14
13
|
const tagsData = await readFile(tagsPath, 'utf-8')
|
|
@@ -16,15 +15,15 @@ async function load(projectPath) {
|
|
|
16
15
|
const { tags } = loadYAML(tagsData)
|
|
17
16
|
return tags
|
|
18
17
|
} catch (e) {
|
|
19
|
-
|
|
18
|
+
logger.error(e)
|
|
20
19
|
return
|
|
21
20
|
}
|
|
22
21
|
}
|
|
23
22
|
|
|
24
|
-
async function save(tags, projectPath) {
|
|
23
|
+
export async function save(tags, projectPath) {
|
|
25
24
|
await writeFile(getTagsPath(projectPath), dumpYAML({ tags }))
|
|
26
25
|
}
|
|
27
26
|
|
|
28
27
|
function getTagsPath(projectPath) {
|
|
29
|
-
return _path.join(projectPath,
|
|
28
|
+
return _path.join(projectPath, TAGS_FILE_PATH)
|
|
30
29
|
}
|
package/lib/adapters/yaml.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import YAML from 'js-yaml'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
export function dumpYAML(obj, opts) {
|
|
4
|
+
return YAML.dump(obj, opts)
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function loadYAML(str, opts) {
|
|
8
|
+
return YAML.load(str, opts)
|
|
9
|
+
}
|