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.
Files changed (163) hide show
  1. package/.dependency-cruiser.cjs +412 -0
  2. package/.github/workflows/ci.yml +2 -2
  3. package/.imdoneignore +2 -1
  4. package/README.md +2 -2
  5. package/_index.md +7 -0
  6. package/build.js +57 -0
  7. package/esm-migration.md +446 -0
  8. package/lib/FileProjectContext.js +13 -0
  9. package/lib/ProjectContext.js +19 -18
  10. package/lib/adapters/date-time.js +3 -8
  11. package/lib/adapters/environment.js +3 -0
  12. package/lib/adapters/file-gateway.js +133 -106
  13. package/lib/adapters/git-download.js +36 -16
  14. package/lib/adapters/index.js +9 -0
  15. package/lib/adapters/logger.js +136 -0
  16. package/lib/adapters/markdown.js +31 -19
  17. package/lib/adapters/parsers/DateLanguageParser.js +11 -9
  18. package/lib/adapters/parsers/content-transformer.js +35 -30
  19. package/lib/adapters/parsers/file/LocalFileParserFactory.js +8 -9
  20. package/lib/adapters/parsers/file/ReadStreamCodeParser.js +8 -8
  21. package/lib/adapters/parsers/file/ReadStreamMarkdownParser.js +4 -4
  22. package/lib/adapters/parsers/file/ReadStreamTaskParser.js +5 -3
  23. package/lib/adapters/parsers/file/index.js +4 -0
  24. package/lib/adapters/parsers/function-parser.js +1 -5
  25. package/lib/adapters/parsers/index.js +5 -0
  26. package/lib/adapters/parsers/task/CardContentParser.js +23 -32
  27. package/lib/adapters/parsers/task/CheckStyleTaskParser.js +2 -2
  28. package/lib/adapters/parsers/task/CodeStyleTaskParser.js +2 -2
  29. package/lib/adapters/parsers/task/HashStyleTaskParser.js +3 -3
  30. package/lib/adapters/parsers/task/MarkdownStyleTaskParser.js +2 -2
  31. package/lib/adapters/parsers/task/TaskParser.js +1 -1
  32. package/lib/adapters/parsers/task/index.js +6 -0
  33. package/lib/adapters/storage/config.js +15 -20
  34. package/lib/adapters/storage/index.js +2 -0
  35. package/lib/adapters/storage/tags.js +11 -12
  36. package/lib/adapters/yaml.js +8 -5
  37. package/lib/card.js +25 -26
  38. package/lib/checksum.js +22 -0
  39. package/lib/cli.js +114 -0
  40. package/lib/config.js +106 -71
  41. package/lib/constants.js +21 -50
  42. package/lib/context/ApplicationContext.js +7 -4
  43. package/lib/context/index.js +1 -0
  44. package/lib/default-settings.js +3 -3
  45. package/lib/domain/entities/View.js +4 -11
  46. package/lib/domain/entities/index.js +1 -0
  47. package/lib/domain/index.js +2 -0
  48. package/lib/domain/usecases/GetViewsUsecase.js +6 -12
  49. package/lib/domain/usecases/SaveViewUsecase.js +8 -14
  50. package/lib/domain/usecases/index.js +2 -0
  51. package/lib/file.js +1158 -1162
  52. package/lib/get-tasks-to-modify.js +117 -0
  53. package/lib/index.js +23 -0
  54. package/lib/languages.js +4 -5
  55. package/lib/list.js +46 -95
  56. package/lib/migrate-config.js +5 -5
  57. package/lib/mixins/index.js +2 -0
  58. package/lib/mixins/repo-fs-store.js +224 -289
  59. package/lib/mixins/repo-watched-fs-store.js +158 -147
  60. package/lib/plugins/archive-plugin.js +10 -8
  61. package/lib/plugins/default-board-actions-plugin.js +2 -2
  62. package/lib/plugins/default-board-properties-plugin.js +7 -7
  63. package/lib/plugins/default-plugins.js +7 -0
  64. package/lib/plugins/epic-plugin.js +6 -5
  65. package/lib/plugins/extension-plugin.js +24 -17
  66. package/lib/plugins/index.js +9 -0
  67. package/lib/plugins/persist-tags-plugin.js +4 -3
  68. package/lib/plugins/plugin-manager.js +89 -52
  69. package/lib/plugins/plugin-registry.js +12 -16
  70. package/lib/project-factory.js +21 -24
  71. package/lib/project.js +97 -144
  72. package/lib/repository.js +1323 -1555
  73. package/lib/task.js +562 -580
  74. package/lib/tools.js +39 -113
  75. package/lib/usecases/actions.js +32 -0
  76. package/lib/usecases/get-project-tags.js +3 -12
  77. package/lib/usecases/get-tasks-in-file.js +4 -7
  78. package/lib/usecases/index.js +4 -0
  79. package/package.json +44 -66
  80. package/scripts/delete-markdown-indexes.js +87 -0
  81. package/scripts/generate-index.js +35 -0
  82. package/{index-markdown.js → scripts/index-markdown.js} +7 -7
  83. package/tsconfig.json +15 -0
  84. package/types/FileProjectContext.d.ts +4 -0
  85. package/types/ProjectContext.d.ts +9 -0
  86. package/types/adapters/date-time.d.ts +2 -0
  87. package/types/adapters/environment.d.ts +1 -0
  88. package/types/adapters/file-gateway.d.ts +51 -0
  89. package/types/adapters/git-download.d.ts +1 -0
  90. package/types/adapters/index.d.ts +9 -0
  91. package/types/adapters/logger.d.ts +24 -0
  92. package/types/adapters/markdown.d.ts +13 -0
  93. package/types/adapters/parsers/DateLanguageParser.d.ts +1 -0
  94. package/types/adapters/parsers/content-transformer.d.ts +10 -0
  95. package/types/adapters/parsers/file/LocalFileParserFactory.d.ts +5 -0
  96. package/types/adapters/parsers/file/ReadStreamCodeParser.d.ts +13 -0
  97. package/types/adapters/parsers/file/ReadStreamMarkdownParser.d.ts +7 -0
  98. package/types/adapters/parsers/file/ReadStreamTaskParser.d.ts +19 -0
  99. package/types/adapters/parsers/file/index.d.ts +4 -0
  100. package/types/adapters/parsers/function-parser.d.ts +1 -0
  101. package/types/adapters/parsers/index.d.ts +5 -0
  102. package/types/adapters/parsers/task/CardContentParser.d.ts +45 -0
  103. package/types/adapters/parsers/task/CheckStyleTaskParser.d.ts +12 -0
  104. package/types/adapters/parsers/task/CodeStyleTaskParser.d.ts +14 -0
  105. package/types/adapters/parsers/task/HashStyleTaskParser.d.ts +13 -0
  106. package/types/adapters/parsers/task/MarkdownStyleTaskParser.d.ts +14 -0
  107. package/types/adapters/parsers/task/TaskParser.d.ts +7 -0
  108. package/types/adapters/parsers/task/index.d.ts +6 -0
  109. package/types/adapters/storage/config.d.ts +6 -0
  110. package/types/adapters/storage/index.d.ts +2 -0
  111. package/types/adapters/storage/tags.d.ts +3 -0
  112. package/types/adapters/yaml.d.ts +2 -0
  113. package/types/card.d.ts +166 -0
  114. package/types/checksum.d.ts +8 -0
  115. package/types/config.d.ts +61 -0
  116. package/types/constants.d.ts +46 -0
  117. package/types/context/ApplicationContext.d.ts +24 -0
  118. package/types/context/index.d.ts +1 -0
  119. package/types/default-settings.d.ts +2 -0
  120. package/types/domain/entities/FileProjectContext.d.ts +5 -0
  121. package/types/domain/entities/View.d.ts +17 -0
  122. package/types/domain/entities/index.d.ts +1 -0
  123. package/types/domain/index.d.ts +2 -0
  124. package/types/domain/usecases/GetViewsUsecase.d.ts +4 -0
  125. package/types/domain/usecases/SaveViewUsecase.d.ts +8 -0
  126. package/types/domain/usecases/index.d.ts +2 -0
  127. package/types/file.d.ts +344 -0
  128. package/types/get-tasks-to-modify.d.ts +3 -0
  129. package/types/index.d.ts +23 -0
  130. package/types/languages.d.ts +649 -0
  131. package/types/list.d.ts +30 -0
  132. package/types/migrate-config.d.ts +1 -0
  133. package/types/mixins/index.d.ts +2 -0
  134. package/types/mixins/repo-fs-store.d.ts +2 -0
  135. package/types/mixins/repo-watched-fs-store.d.ts +2 -0
  136. package/types/plugins/archive-plugin.d.ts +8 -0
  137. package/types/plugins/default-board-actions-plugin.d.ts +9 -0
  138. package/types/plugins/default-board-properties-plugin.d.ts +16 -0
  139. package/types/plugins/default-plugins.d.ts +6 -0
  140. package/types/plugins/epic-plugin.d.ts +19 -0
  141. package/types/plugins/extension-plugin.d.ts +15 -0
  142. package/types/plugins/index.d.ts +9 -0
  143. package/types/plugins/persist-tags-plugin.d.ts +4 -0
  144. package/types/plugins/plugin-manager.d.ts +68 -0
  145. package/types/plugins/plugin-registry.d.ts +1 -0
  146. package/types/project-factory.d.ts +14 -0
  147. package/types/project.d.ts +158 -0
  148. package/types/repository.d.ts +996 -0
  149. package/types/task.d.ts +202 -0
  150. package/types/tools.d.ts +29 -0
  151. package/types/usecases/actions.d.ts +7 -0
  152. package/types/usecases/get-imdone-url.d.ts +1 -0
  153. package/types/usecases/get-project-tags.d.ts +1 -0
  154. package/types/usecases/get-tasks-in-file.d.ts +4 -0
  155. package/types/usecases/index.d.ts +4 -0
  156. package/vitest.config.js +13 -0
  157. package/cli.js +0 -74
  158. package/index.js +0 -1
  159. package/lib/adapters/readers/FileSystemProjectReader.js +0 -45
  160. package/lib/context/StreamingApplicationContext.js +0 -31
  161. package/lib/controlers/SaveViewController.js +0 -10
  162. package/lib/domain/entities/FileProjectContext.js +0 -10
  163. package/lib/domain/usecases/OpenProjectUsecase.js +0 -13
@@ -1,35 +1,30 @@
1
- const template = require('lodash.template')
2
- const uniqid = require('uniqid');
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(opts.interpolate, (match, p1) => {
44
+ content = content.replace(regex, (match, p1) => {
47
45
  try {
48
- const result = template(match, opts)(data);
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, opts);
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, mustacheOpts);
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
- const { createReadStream } = require('fs')
2
- const ReadStreamMarkdownParser = require('./ReadStreamMarkdownParser')
3
- const path = require('path')
4
- const languages = require('../../../languages')
5
- const ReadStreamCodeParser = require('./ReadStreamCodeParser')
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
- module.exports.getLang = getLang
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
- const path = require('path')
2
- const ReadStreamTaskParser = require('./ReadStreamTaskParser')
3
- const CodeStyleTaskParser = require('../task/CodeStyleTaskParser')
4
- const languages = require('../../../languages')
5
- const extractComments = require('multilang-extract-comments')
6
- const eol = require('eol')
7
- const { Readable } = require('stream')
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
- module.exports = class ReadStreamCodeParser extends ReadStreamTaskParser {
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
- const ReadStreamTaskParser = require('./ReadStreamTaskParser')
2
- const HashStyleTaskParser = require('../task/HashStyleTaskParser')
3
- const MarkdownStyleTaskParser = require('../task/MarkdownStyleTaskParser')
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
- module.exports = class ReadStreamMarkdownParser extends ReadStreamTaskParser {
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
- const ReadLine = require('readline')
1
+ import * as ReadLine from 'node:readline/promises';
2
+ import { logger } from '../../logger.js';
3
+
2
4
  const blankLinesToEndTask = 2
3
5
 
4
- module.exports = class ReadStreamTaskParser {
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
- console.log('Error reading line')
45
+ logger.log('Error reading line')
44
46
  throw error
45
47
  }
46
48
 
@@ -0,0 +1,4 @@
1
+ export * from './LocalFileParserFactory.js';
2
+ export * from './ReadStreamCodeParser.js';
3
+ export * from './ReadStreamMarkdownParser.js';
4
+ export * from './ReadStreamTaskParser.js';
@@ -1,8 +1,4 @@
1
- module.exports = {
2
- getFunctionSignature
3
- };
4
-
5
- function getFunctionSignature(fn) {
1
+ export function getFunctionSignature(fn) {
6
2
  if (typeof fn !== "function") {
7
3
  throw new TypeError("Expected a function");
8
4
  }
@@ -0,0 +1,5 @@
1
+ export * from './DateLanguageParser.js';
2
+ export * from './content-transformer.js';
3
+ export * from './function-parser.js';
4
+ export * as file from './file/index.js';
5
+ export * as task from './task/index.js';
@@ -1,11 +1,11 @@
1
- const eol = require('eol')
2
- const XRegExp = require('xregexp')
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
- const LIST_NAME_PATTERN = '[\\p{L}0-9-_]{2,}' // [a-zA-Z-_]+?
19
- const LINK_STYLE_REGEX = new XRegExp(
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 (value) {
359
- return !isNaN(parseFloat(value)) && isFinite(value)
359
+ export function isNumber(value) {
360
+ return !isNaN(value) && isFinite(Number(value));
360
361
  }
361
362
 
362
- module.exports = {
363
- FILE_TYPES,
364
- TASK_TYPES,
365
- getTaskContent,
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,6 +1,6 @@
1
- const TaskParser = require('./TaskParser')
1
+ import { TaskParser } from "./TaskParser.js"
2
2
 
3
- module.exports = class CheckStyleTaskParser extends TaskParser {
3
+ export class CheckStyleTaskParser extends TaskParser {
4
4
  constructor() {
5
5
  super()
6
6
  }
@@ -1,6 +1,6 @@
1
- const TaskParser = require('./TaskParser')
1
+ import { TaskParser } from './TaskParser.js'
2
2
 
3
- module.exports = class CodeStyleTaskParser extends TaskParser {
3
+ export class CodeStyleTaskParser extends TaskParser {
4
4
  constructor(config) {
5
5
  super('CODE', config)
6
6
  }
@@ -1,7 +1,7 @@
1
- const TaskParser = require('./TaskParser')
2
- const { getHashStyleRegex } = require('./CardContentParser')
1
+ import { TaskParser } from './TaskParser.js'
2
+ import { getHashStyleRegex } from './CardContentParser.js'
3
3
 
4
- module.exports = class HashStyleTaskParser extends TaskParser {
4
+ export class HashStyleTaskParser extends TaskParser {
5
5
  constructor(config) {
6
6
  super('HASHTAG', config)
7
7
  }
@@ -1,6 +1,6 @@
1
- const TaskParser = require('./TaskParser')
1
+ import { TaskParser } from './TaskParser.js'
2
2
 
3
- module.exports = class MarkdownStyleTaskParser extends TaskParser {
3
+ export class MarkdownStyleTaskParser extends TaskParser {
4
4
  constructor(config) {
5
5
  super('MARKDOWN', config)
6
6
  }
@@ -14,7 +14,7 @@ class Task {
14
14
  }
15
15
  }
16
16
 
17
- module.exports = class TaskParser {
17
+ export class TaskParser {
18
18
  constructor(type, config) {
19
19
  this.config = config
20
20
  this.type = type
@@ -0,0 +1,6 @@
1
+ export * from './CardContentParser.js';
2
+ export * from './CheckStyleTaskParser.js';
3
+ export * from './CodeStyleTaskParser.js';
4
+ export * from './HashStyleTaskParser.js';
5
+ export * from './MarkdownStyleTaskParser.js';
6
+ export * from './TaskParser.js';
@@ -1,33 +1,28 @@
1
- const { readFile, writeFile, exists } = require('../file-gateway')
2
- const { CONFIG_DIR, CONFIG_FILE_YML } = require('../../constants')
3
- const { loadYAML, dumpYAML } = require('../yaml')
4
- const findUp = require('find-up')
5
- const _path = require('path')
6
- const Config = require('../../config')
7
-
8
- module.exports = {
9
- load,
10
- save,
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
- console.error(`Error parsing config file: ${filePath}`)
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
  }
@@ -0,0 +1,2 @@
1
+ export * from './config.js';
2
+ export * from './tags.js';
@@ -1,14 +1,13 @@
1
- const { readFile, writeFile, exists } = require('../file-gateway')
2
- const { CONFIG_DIR } = require('../../constants')
3
- const { loadYAML, dumpYAML } = require('../yaml')
4
- const _path = require('path')
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
- module.exports = {
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
- console.error(e)
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, CONFIG_DIR, 'tags.yml')
28
+ return _path.join(projectPath, TAGS_FILE_PATH)
30
29
  }
@@ -1,6 +1,9 @@
1
- const YAML = require('js-yaml')
1
+ import YAML from 'js-yaml'
2
2
 
3
- module.exports = {
4
- dumpYAML: YAML.dump,
5
- loadYAML: YAML.load,
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
+ }