imdone-core 1.54.10 → 2.0.0

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 (71) hide show
  1. package/README.md +2 -2
  2. package/lib/cli.js +114 -0
  3. package/lib/index.js +23 -0
  4. package/package.json +48 -66
  5. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -37
  6. package/.github/workflows/ci.yml +0 -24
  7. package/.imdoneignore +0 -12
  8. package/.mocharc.json +0 -10
  9. package/.prettierrc +0 -6
  10. package/CHANGELOG.md +0 -160
  11. package/_navbar.md +0 -1
  12. package/cli.js +0 -74
  13. package/index-markdown.js +0 -55
  14. package/index.html +0 -184
  15. package/index.js +0 -1
  16. package/lib/ProjectContext.js +0 -42
  17. package/lib/adapters/date-time.js +0 -20
  18. package/lib/adapters/file-gateway.js +0 -127
  19. package/lib/adapters/git-download.js +0 -35
  20. package/lib/adapters/markdown.js +0 -168
  21. package/lib/adapters/parsers/DateLanguageParser.js +0 -10
  22. package/lib/adapters/parsers/content-transformer.js +0 -111
  23. package/lib/adapters/parsers/file/LocalFileParserFactory.js +0 -37
  24. package/lib/adapters/parsers/file/ReadStreamCodeParser.js +0 -126
  25. package/lib/adapters/parsers/file/ReadStreamMarkdownParser.js +0 -17
  26. package/lib/adapters/parsers/file/ReadStreamTaskParser.js +0 -104
  27. package/lib/adapters/parsers/function-parser.js +0 -29
  28. package/lib/adapters/parsers/task/CardContentParser.js +0 -376
  29. package/lib/adapters/parsers/task/CheckStyleTaskParser.js +0 -28
  30. package/lib/adapters/parsers/task/CodeStyleTaskParser.js +0 -24
  31. package/lib/adapters/parsers/task/HashStyleTaskParser.js +0 -27
  32. package/lib/adapters/parsers/task/MarkdownStyleTaskParser.js +0 -24
  33. package/lib/adapters/parsers/task/TaskParser.js +0 -38
  34. package/lib/adapters/readers/FileSystemProjectReader.js +0 -45
  35. package/lib/adapters/storage/config.js +0 -49
  36. package/lib/adapters/storage/tags.js +0 -30
  37. package/lib/adapters/yaml.js +0 -6
  38. package/lib/card.js +0 -300
  39. package/lib/config.js +0 -214
  40. package/lib/constants.js +0 -97
  41. package/lib/context/ApplicationContext.js +0 -32
  42. package/lib/context/StreamingApplicationContext.js +0 -31
  43. package/lib/controlers/SaveViewController.js +0 -10
  44. package/lib/default-settings.js +0 -37
  45. package/lib/domain/entities/FileProjectContext.js +0 -10
  46. package/lib/domain/entities/View.js +0 -30
  47. package/lib/domain/usecases/GetViewsUsecase.js +0 -50
  48. package/lib/domain/usecases/OpenProjectUsecase.js +0 -13
  49. package/lib/domain/usecases/SaveViewUsecase.js +0 -57
  50. package/lib/file.js +0 -1395
  51. package/lib/languages.js +0 -114
  52. package/lib/list.js +0 -105
  53. package/lib/migrate-config.js +0 -165
  54. package/lib/mixins/repo-fs-store.js +0 -424
  55. package/lib/mixins/repo-watched-fs-store.js +0 -195
  56. package/lib/plugins/archive-plugin.js +0 -70
  57. package/lib/plugins/default-board-actions-plugin.js +0 -56
  58. package/lib/plugins/default-board-properties-plugin.js +0 -101
  59. package/lib/plugins/epic-plugin.js +0 -176
  60. package/lib/plugins/extension-plugin.js +0 -87
  61. package/lib/plugins/persist-tags-plugin.js +0 -13
  62. package/lib/plugins/plugin-manager.js +0 -421
  63. package/lib/plugins/plugin-registry.js +0 -61
  64. package/lib/project-factory.js +0 -45
  65. package/lib/project.js +0 -911
  66. package/lib/repository.js +0 -1746
  67. package/lib/task.js +0 -798
  68. package/lib/tools.js +0 -250
  69. package/lib/usecases/get-imdone-url.js +0 -6
  70. package/lib/usecases/get-project-tags.js +0 -16
  71. package/lib/usecases/get-tasks-in-file.js +0 -29
@@ -1,111 +0,0 @@
1
- const template = require('lodash.template')
2
- const uniqid = require('uniqid');
3
-
4
- module.exports = {
5
- format,
6
- encodeMarkdownLinks
7
- }
8
-
9
- function removeDisplayComments(description) {
10
- return description.replace(/<!--\s*\[([\s\S]*?)\]\s*-->/g, '$1')
11
- }
12
-
13
- function escapeCodeBlocks(content) {
14
- const codeBlockRegex = /(```[\s\S]*?```|`[^`]*`)/g
15
- let codeBlocks = []
16
-
17
- // Replace code blocks with unique keys
18
- content = content.replace(codeBlockRegex, (match) => {
19
- const key = `__CODE_BLOCK_${codeBlocks.length}__`
20
- codeBlocks.push(match) // Maintain order
21
- return key
22
- })
23
-
24
- return { content, codeBlocks }
25
- }
26
-
27
- function restoreCodeBlocks(content, codeBlocks) {
28
- // Restore code blocks in order using stored array
29
- codeBlocks.forEach((code, index) => {
30
- content = content.replace(`__CODE_BLOCK_${index}__`, code)
31
- })
32
- return content
33
- }
34
-
35
- /**
36
- * Interpolates the content with the provided data.
37
- * @param {string} content - The content to interpolate.
38
- * @param {object} data - The data to use for interpolation.
39
- * @param {object} opts - The options for interpolation.
40
- * @returns {object} - The interpolated content, whether there was interpolation, and error tokens.
41
- */
42
- function interpolate(content, data, opts) {
43
- const errorTokens = {};
44
- let hasInterpolation = false;
45
-
46
- content = content.replace(opts.interpolate, (match, p1) => {
47
- try {
48
- const result = template(match, opts)(data);
49
- if (result !== match) {
50
- hasInterpolation = true;
51
- }
52
- return result;
53
- } catch (e) {
54
- const token = `__ERROR_TOKEN_${uniqid()}__`;
55
- errorTokens[token] = match;
56
- return token;
57
- }
58
- });
59
-
60
- return { content, hasInterpolation, errorTokens };
61
- }
62
-
63
- function encodeMarkdownLinks(content) {
64
- return content.replace(/(?<!!)\[(.*?)\]\((.*?)( ".*?")?\)/g, (match, p1, p2, p3) => {
65
- // URI encode file links
66
- const title = p3 || '';
67
- const encodedUrl = p2.replace(/\s/g, '%20').replace(/\)/g, '%29').replace(/\(/g, '%28');
68
- const link = `[${p1}](${encodedUrl}${title})`;
69
- return link.replace(/%20(".*?"\))$/, ' $1');
70
- });
71
- }
72
-
73
- function format(content, data, mustache) {
74
- const opts = { interpolate: /(?<![`\\])\${([\s\S]+?)}/g };
75
- const errorTokens = {};
76
-
77
- if (mustache) content = removeDisplayComments(content);
78
-
79
- // Escape code blocks before processing interpolation
80
- const { content: escapedContent, codeBlocks } = escapeCodeBlocks(content);
81
-
82
- let result = escapedContent;
83
- let hasInterpolation = true;
84
-
85
- while (hasInterpolation) {
86
- const interpolationResult = interpolate(result, data, opts);
87
- result = interpolationResult.content;
88
- hasInterpolation = interpolationResult.hasInterpolation;
89
- Object.assign(errorTokens, interpolationResult.errorTokens);
90
- }
91
-
92
- if (mustache) {
93
- const mustacheOpts = { interpolate: /(?<!`){{([\s\S]+?)}}/g };
94
- hasInterpolation = true;
95
- while (hasInterpolation) {
96
- const interpolationResult = interpolate(result, data, mustacheOpts);
97
- result = interpolationResult.content;
98
- hasInterpolation = interpolationResult.hasInterpolation;
99
- Object.assign(errorTokens, interpolationResult.errorTokens);
100
- }
101
- }
102
-
103
- result = restoreCodeBlocks(result, codeBlocks);
104
-
105
- // Restore error tokens
106
- Object.keys(errorTokens).forEach(token => {
107
- result = result.replace(new RegExp(token, 'g'), errorTokens[token]);
108
- });
109
-
110
- return result;
111
- }
@@ -1,37 +0,0 @@
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')
6
-
7
-
8
- function getLang(config, filePath) {
9
- const languages = getLanguages(config)
10
- var lang = languages[path.extname(filePath)]
11
- return lang || { name: 'text', symbol: '' }
12
- }
13
-
14
- function getLanguages(config) {
15
- const configLanguages = config.languages || {}
16
- return { ...languages, ...configLanguages }
17
- }
18
-
19
- module.exports.getLang = getLang
20
- module.exports.getFileParser = async function getFileParser (filePath, config, readStream) {
21
- if (!readStream) {
22
- readStream = createReadStream(filePath)
23
- }
24
- const lang = getLang(config, filePath)
25
- if (lang.name === 'text') {
26
- return new ReadStreamMarkdownParser(readStream, config)
27
- } else {
28
- const parser = new ReadStreamCodeParser(
29
- readStream,
30
- filePath,
31
- lang,
32
- config.lists
33
- )
34
- await parser.init()
35
- return parser
36
- }
37
- }
@@ -1,126 +0,0 @@
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')
8
-
9
- // TODO Move to readstream parsing for code to improve performance
10
- // <!--
11
- // #important
12
- // #imdone-1.55.0
13
- // order:-205
14
- // -->
15
- module.exports = class ReadStreamCodeParser extends ReadStreamTaskParser {
16
- constructor(readStream, filePath, lang, lists) {
17
- super(readStream)
18
- this.lists = lists
19
- this.filePath = filePath
20
- this.lang = lang
21
- this.taskParsers = [new CodeStyleTaskParser()]
22
- }
23
-
24
- async init() {
25
- const code = await streamToString(this.readStream)
26
- // TODO Getting tokens from lists should be done higher up in the controller
27
- // <!--
28
- // order:-10
29
- // -->
30
- const tokens = this.lists.filter(list => !list.filter).map(list => list.name)
31
- this.cards = this.parseCards(code, tokens)
32
- }
33
-
34
- async readTask() {
35
- return this.cards.shift()
36
- }
37
-
38
- parseCards(code, tokens = ['TODO']) {
39
- const comments = this.parseComments(code);
40
- const cards = [];
41
-
42
- Object.keys(comments).forEach((comment) => {
43
- const { begin, end, content } = comments[comment];
44
- const line = begin;
45
- const lastLine = end; // TODO lastLine should not be - 1
46
- // <!--
47
- // order:-140
48
- // -->
49
- const lines = content.split('\n');
50
-
51
- // Check if the comment contains "TODO"
52
- lines.forEach(codeLine => {
53
- if (tokens.find((token) => codeLine.includes(token))) {
54
- // Get all lines from start to end
55
-
56
- cards.push({
57
- content,
58
- line,
59
- lastLine,
60
- });
61
- }
62
- });
63
- });
64
- return cards;
65
- }
66
-
67
- parseComments(code) {
68
- const options = getLanguageOptions(this.filePath);
69
- const comments = extractComments(code, options);
70
- return comments;
71
- }
72
-
73
- }
74
-
75
-
76
- function getLanguageOptions(filePath) {
77
- const extension = path.extname(filePath)
78
- const language = languages[extension]
79
-
80
-
81
- const {
82
- name,
83
- symbol,
84
- block,
85
- } = language ||
86
- {
87
- name: 'text',
88
- symbol: '',
89
- block: {
90
- start: undefined,
91
- end: undefined,
92
- ignore: undefined,
93
- }
94
- };
95
- // Use lang to get comment patterns
96
-
97
- const {
98
- start,
99
- ignore: middle,
100
- end
101
- } = block || {};
102
-
103
- return language && {
104
- pattern: {
105
- name,
106
- nameMatchers: extension && [extension] || [],
107
- singleLineComment: symbol && [{ start: symbol }] || [],
108
- multiLineComment: start && end && [{ start, middle, end }] || [],
109
- },
110
- };
111
- }
112
-
113
- async function streamToString(stream) {
114
- const chunks = []
115
-
116
- for await (const chunk of stream) {
117
- chunks.push(Buffer.from(chunk))
118
- }
119
-
120
- return Buffer.concat(chunks).toString('utf-8')
121
- }
122
-
123
- function stringToStream(string) {
124
- const lines = eol.split(string).map((line) => line + String(eol.auto))
125
- return Readable.from(lines)
126
- }
@@ -1,17 +0,0 @@
1
- const ReadStreamTaskParser = require('./ReadStreamTaskParser')
2
- const HashStyleTaskParser = require('../task/HashStyleTaskParser')
3
- const MarkdownStyleTaskParser = require('../task/MarkdownStyleTaskParser')
4
- // const CheckStyleTaskParser = require('../task/CheckStyleTaskParser')
5
-
6
- module.exports = class ReadStreamMarkdownParser extends ReadStreamTaskParser {
7
- constructor(readStream, config) {
8
- super(readStream, config)
9
- this.taskParsers = [
10
- new HashStyleTaskParser(config),
11
- new MarkdownStyleTaskParser(config),
12
- ]
13
- // if (config.isAddCheckBoxTasks()) {
14
- // this.taskParsers.push(new CheckStyleTaskParser())
15
- // }
16
- }
17
- }
@@ -1,104 +0,0 @@
1
- const ReadLine = require('readline')
2
- const blankLinesToEndTask = 2
3
-
4
- module.exports = class ReadStreamTaskParser {
5
- constructor(readStream) {
6
- this.readStream = readStream
7
- this.task = null
8
- this.line = null
9
- this.taskParsers = []
10
- this.lineNo = 0
11
- this.blankLines = 0
12
- this.readInterface = ReadLine.createInterface({
13
- input: this.readStream,
14
- crlfDelay: Infinity,
15
- console: false,
16
- })
17
- }
18
-
19
- async readTask() {
20
- let taskOrStreamDone = false
21
- this.task = this.nextTask || null
22
- this.blankLines = 0
23
-
24
- try {
25
- while (!taskOrStreamDone) {
26
- this.line = await this.readLine()
27
- let { value, done } = this.line
28
- if (this.line && !done) {
29
- this.lineNo++
30
- const endOfTask = this.isEndOfTask(value)
31
- if (this.task && endOfTask) {
32
- taskOrStreamDone = true
33
- } else if (this.task) {
34
- this.addLineToTask(value)
35
- } else {
36
- this.task = this.getTaskFromLine(value)
37
- }
38
- } else {
39
- taskOrStreamDone = true
40
- }
41
- }
42
- } catch (error) {
43
- console.log('Error reading line')
44
- throw error
45
- }
46
-
47
- this.trimLinesToEndTask()
48
- return this.task
49
- }
50
-
51
- async readLine() {
52
- return this.readInterface[Symbol.asyncIterator]().next()
53
- }
54
-
55
- isEndOfTask(line) {
56
- if (line.trim() === '') {
57
- this.blankLines++
58
- } else {
59
- this.blankLines = 0
60
- }
61
-
62
- this.nextTask = this.getTaskFromLine(line)
63
-
64
- if (this.blankLines > blankLinesToEndTask - 1) {
65
- this.nextTask = undefined
66
- return true
67
- }
68
-
69
- if (this.nextTask) {
70
- return true
71
- }
72
-
73
- return false
74
- }
75
-
76
- getTaskFromLine(line) {
77
- let task
78
- this.taskParsers.find((taskParser) => {
79
- task = taskParser.parseLine(line, this.lineNo, this.task)
80
- return task
81
- })
82
- return task
83
- }
84
-
85
- addLineToTask(line) {
86
- this.task.description.push(line)
87
- this.task.lastLine = this.lineNo
88
- }
89
-
90
- trimLinesToEndTask() {
91
- if (!this.task) return
92
-
93
- // Remove the empty strings from the end of the task description
94
- while (this.task.description[this.task.description.length - 1] === '') {
95
- this.task.description.pop()
96
- }
97
- this.task.lastLine = this.task.line + this.task.description.length
98
- }
99
-
100
- close() {
101
- this.readInterface.close()
102
- if (this.readStream.close) this.readStream.close()
103
- }
104
- }
@@ -1,29 +0,0 @@
1
- module.exports = {
2
- getFunctionSignature
3
- };
4
-
5
- function getFunctionSignature(fn) {
6
- if (typeof fn !== "function") {
7
- throw new TypeError("Expected a function");
8
- }
9
-
10
- const fnString = fn.toString().trim();
11
- let name = fn.name || "anonymous";
12
- let params = "";
13
-
14
- // Match function parameters
15
- const paramMatch = fnString.match(/\(([^)]*)\)/);
16
- if (paramMatch) {
17
- params = paramMatch[1].trim();
18
- } else {
19
- // Handle arrow functions without parentheses
20
- const arrowMatch = fnString.match(/^(?:\S+\s+)?(\w+)?\s*=?\s*(?:async\s*)?\(?([^)=]*)\)?\s*=>/);
21
- if (arrowMatch) {
22
- name = name || arrowMatch[1] || "anonymous";
23
- params = arrowMatch[2].trim();
24
- }
25
- }
26
-
27
- return `${name}(${params})`;
28
- }
29
-