imdone-core 2.0.0 → 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 (160) hide show
  1. package/.dependency-cruiser.cjs +412 -0
  2. package/.github/ISSUE_TEMPLATE/bug_report.md +37 -0
  3. package/.github/workflows/ci.yml +24 -0
  4. package/.imdoneignore +13 -0
  5. package/.mocharc.json +10 -0
  6. package/.prettierrc +6 -0
  7. package/CHANGELOG.md +160 -0
  8. package/_index.md +7 -0
  9. package/_navbar.md +1 -0
  10. package/build.js +57 -0
  11. package/esm-migration.md +446 -0
  12. package/index.html +184 -0
  13. package/lib/FileProjectContext.js +13 -0
  14. package/lib/ProjectContext.js +43 -0
  15. package/lib/adapters/date-time.js +15 -0
  16. package/lib/adapters/environment.js +3 -0
  17. package/lib/adapters/file-gateway.js +154 -0
  18. package/lib/adapters/git-download.js +55 -0
  19. package/lib/adapters/index.js +9 -0
  20. package/lib/adapters/logger.js +136 -0
  21. package/lib/adapters/markdown.js +180 -0
  22. package/lib/adapters/parsers/DateLanguageParser.js +12 -0
  23. package/lib/adapters/parsers/content-transformer.js +116 -0
  24. package/lib/adapters/parsers/file/LocalFileParserFactory.js +36 -0
  25. package/lib/adapters/parsers/file/ReadStreamCodeParser.js +126 -0
  26. package/lib/adapters/parsers/file/ReadStreamMarkdownParser.js +17 -0
  27. package/lib/adapters/parsers/file/ReadStreamTaskParser.js +106 -0
  28. package/lib/adapters/parsers/file/index.js +4 -0
  29. package/lib/adapters/parsers/function-parser.js +25 -0
  30. package/lib/adapters/parsers/index.js +5 -0
  31. package/lib/adapters/parsers/task/CardContentParser.js +367 -0
  32. package/lib/adapters/parsers/task/CheckStyleTaskParser.js +28 -0
  33. package/lib/adapters/parsers/task/CodeStyleTaskParser.js +24 -0
  34. package/lib/adapters/parsers/task/HashStyleTaskParser.js +27 -0
  35. package/lib/adapters/parsers/task/MarkdownStyleTaskParser.js +24 -0
  36. package/lib/adapters/parsers/task/TaskParser.js +38 -0
  37. package/lib/adapters/parsers/task/index.js +6 -0
  38. package/lib/adapters/storage/config.js +44 -0
  39. package/lib/adapters/storage/index.js +2 -0
  40. package/lib/adapters/storage/tags.js +29 -0
  41. package/lib/adapters/yaml.js +9 -0
  42. package/lib/card.js +299 -0
  43. package/lib/checksum.js +22 -0
  44. package/lib/config.js +249 -0
  45. package/lib/constants.js +68 -0
  46. package/lib/context/ApplicationContext.js +35 -0
  47. package/lib/context/index.js +1 -0
  48. package/lib/default-settings.js +37 -0
  49. package/lib/domain/entities/View.js +23 -0
  50. package/lib/domain/entities/index.js +1 -0
  51. package/lib/domain/index.js +2 -0
  52. package/lib/domain/usecases/GetViewsUsecase.js +44 -0
  53. package/lib/domain/usecases/SaveViewUsecase.js +51 -0
  54. package/lib/domain/usecases/index.js +2 -0
  55. package/lib/file.js +1391 -0
  56. package/lib/get-tasks-to-modify.js +117 -0
  57. package/lib/languages.js +113 -0
  58. package/lib/list.js +56 -0
  59. package/lib/migrate-config.js +165 -0
  60. package/lib/mixins/index.js +2 -0
  61. package/lib/mixins/repo-fs-store.js +359 -0
  62. package/lib/mixins/repo-watched-fs-store.js +206 -0
  63. package/lib/plugins/archive-plugin.js +72 -0
  64. package/lib/plugins/default-board-actions-plugin.js +56 -0
  65. package/lib/plugins/default-board-properties-plugin.js +101 -0
  66. package/lib/plugins/default-plugins.js +7 -0
  67. package/lib/plugins/epic-plugin.js +177 -0
  68. package/lib/plugins/extension-plugin.js +94 -0
  69. package/lib/plugins/index.js +9 -0
  70. package/lib/plugins/persist-tags-plugin.js +14 -0
  71. package/lib/plugins/plugin-manager.js +458 -0
  72. package/lib/plugins/plugin-registry.js +57 -0
  73. package/lib/project-factory.js +42 -0
  74. package/lib/project.js +864 -0
  75. package/lib/repository.js +1514 -0
  76. package/lib/task.js +780 -0
  77. package/lib/tools.js +176 -0
  78. package/lib/usecases/actions.js +32 -0
  79. package/lib/usecases/get-imdone-url.js +6 -0
  80. package/lib/usecases/get-project-tags.js +7 -0
  81. package/lib/usecases/get-tasks-in-file.js +26 -0
  82. package/lib/usecases/index.js +4 -0
  83. package/package.json +2 -6
  84. package/scripts/delete-markdown-indexes.js +87 -0
  85. package/scripts/generate-index.js +35 -0
  86. package/scripts/index-markdown.js +55 -0
  87. package/tsconfig.json +15 -0
  88. package/types/FileProjectContext.d.ts +4 -0
  89. package/types/ProjectContext.d.ts +9 -0
  90. package/types/adapters/date-time.d.ts +2 -0
  91. package/types/adapters/environment.d.ts +1 -0
  92. package/types/adapters/file-gateway.d.ts +51 -0
  93. package/types/adapters/git-download.d.ts +1 -0
  94. package/types/adapters/index.d.ts +9 -0
  95. package/types/adapters/logger.d.ts +24 -0
  96. package/types/adapters/markdown.d.ts +13 -0
  97. package/types/adapters/parsers/DateLanguageParser.d.ts +1 -0
  98. package/types/adapters/parsers/content-transformer.d.ts +10 -0
  99. package/types/adapters/parsers/file/LocalFileParserFactory.d.ts +5 -0
  100. package/types/adapters/parsers/file/ReadStreamCodeParser.d.ts +13 -0
  101. package/types/adapters/parsers/file/ReadStreamMarkdownParser.d.ts +7 -0
  102. package/types/adapters/parsers/file/ReadStreamTaskParser.d.ts +19 -0
  103. package/types/adapters/parsers/file/index.d.ts +4 -0
  104. package/types/adapters/parsers/function-parser.d.ts +1 -0
  105. package/types/adapters/parsers/index.d.ts +5 -0
  106. package/types/adapters/parsers/task/CardContentParser.d.ts +45 -0
  107. package/types/adapters/parsers/task/CheckStyleTaskParser.d.ts +12 -0
  108. package/types/adapters/parsers/task/CodeStyleTaskParser.d.ts +14 -0
  109. package/types/adapters/parsers/task/HashStyleTaskParser.d.ts +13 -0
  110. package/types/adapters/parsers/task/MarkdownStyleTaskParser.d.ts +14 -0
  111. package/types/adapters/parsers/task/TaskParser.d.ts +7 -0
  112. package/types/adapters/parsers/task/index.d.ts +6 -0
  113. package/types/adapters/storage/config.d.ts +6 -0
  114. package/types/adapters/storage/index.d.ts +2 -0
  115. package/types/adapters/storage/tags.d.ts +3 -0
  116. package/types/adapters/yaml.d.ts +2 -0
  117. package/types/card.d.ts +166 -0
  118. package/types/checksum.d.ts +8 -0
  119. package/types/config.d.ts +61 -0
  120. package/types/constants.d.ts +46 -0
  121. package/types/context/ApplicationContext.d.ts +24 -0
  122. package/types/context/index.d.ts +1 -0
  123. package/types/default-settings.d.ts +2 -0
  124. package/types/domain/entities/FileProjectContext.d.ts +5 -0
  125. package/types/domain/entities/View.d.ts +17 -0
  126. package/types/domain/entities/index.d.ts +1 -0
  127. package/types/domain/index.d.ts +2 -0
  128. package/types/domain/usecases/GetViewsUsecase.d.ts +4 -0
  129. package/types/domain/usecases/SaveViewUsecase.d.ts +8 -0
  130. package/types/domain/usecases/index.d.ts +2 -0
  131. package/types/file.d.ts +344 -0
  132. package/types/get-tasks-to-modify.d.ts +3 -0
  133. package/types/index.d.ts +23 -0
  134. package/types/languages.d.ts +649 -0
  135. package/types/list.d.ts +30 -0
  136. package/types/migrate-config.d.ts +1 -0
  137. package/types/mixins/index.d.ts +2 -0
  138. package/types/mixins/repo-fs-store.d.ts +2 -0
  139. package/types/mixins/repo-watched-fs-store.d.ts +2 -0
  140. package/types/plugins/archive-plugin.d.ts +8 -0
  141. package/types/plugins/default-board-actions-plugin.d.ts +9 -0
  142. package/types/plugins/default-board-properties-plugin.d.ts +16 -0
  143. package/types/plugins/default-plugins.d.ts +6 -0
  144. package/types/plugins/epic-plugin.d.ts +19 -0
  145. package/types/plugins/extension-plugin.d.ts +15 -0
  146. package/types/plugins/index.d.ts +9 -0
  147. package/types/plugins/persist-tags-plugin.d.ts +4 -0
  148. package/types/plugins/plugin-manager.d.ts +68 -0
  149. package/types/plugins/plugin-registry.d.ts +1 -0
  150. package/types/project-factory.d.ts +14 -0
  151. package/types/project.d.ts +158 -0
  152. package/types/repository.d.ts +996 -0
  153. package/types/task.d.ts +202 -0
  154. package/types/tools.d.ts +29 -0
  155. package/types/usecases/actions.d.ts +7 -0
  156. package/types/usecases/get-imdone-url.d.ts +1 -0
  157. package/types/usecases/get-project-tags.d.ts +1 -0
  158. package/types/usecases/get-tasks-in-file.d.ts +4 -0
  159. package/types/usecases/index.d.ts +4 -0
  160. package/vitest.config.js +13 -0
@@ -0,0 +1,117 @@
1
+ import { isNumber } from "./adapters/parsers/task/CardContentParser.js";
2
+
3
+ export function getPreviousIndexWithDifferentOrder(tasks, pos) {
4
+ let closestIndexWithOrder = -1
5
+
6
+ if (pos === 0) return closestIndexWithOrder
7
+
8
+ let lastTask = tasks[pos] || tasks [pos - 1]
9
+
10
+ for (
11
+ let index = pos - 1;
12
+ index >= 0 && closestIndexWithOrder < 0;
13
+ index--
14
+ ) {
15
+ const t = tasks[index]
16
+ if (!tasksHaveSameOrder(lastTask, t)) closestIndexWithOrder = index
17
+ lastTask = t
18
+ }
19
+ return closestIndexWithOrder
20
+ }
21
+
22
+ export function getNextIndexWithDifferentOrder(tasks, pos) {
23
+ let closestIndexWithOrder = -1
24
+
25
+ let lastTask = tasks[pos]
26
+
27
+ for (
28
+ let index = pos;
29
+ index < tasks.length && closestIndexWithOrder < 0;
30
+ index++
31
+ ) {
32
+ const t = tasks[index]
33
+ if (!tasksHaveSameOrder(lastTask, t)) closestIndexWithOrder = index
34
+ lastTask = t
35
+ }
36
+ return closestIndexWithOrder
37
+ }
38
+
39
+ function taskBeforeAndAfterHaveDifferentOrder(taskList, newPos) {
40
+ const taskBefore = taskList[newPos - 1]
41
+ const taskAfter = taskList[newPos]
42
+ return taskBeforeHasOrder(taskList, newPos)
43
+ && taskAfterHasOrder(taskList, newPos)
44
+ && parseFloat(taskBefore.order) !== parseFloat(taskAfter.order)
45
+ }
46
+
47
+ function taskBeforeHasOrder(taskList, newPos) {
48
+ const taskBefore = taskList[newPos - 1]
49
+ return taskBefore && isNumber(taskBefore.order)
50
+ }
51
+
52
+ function taskAfterHasOrder(taskList, newPos) {
53
+ const taskAfter = taskList[newPos]
54
+ return taskAfter && isNumber(taskAfter.order)
55
+ }
56
+ function lastTaskHasOrder(taskList) {
57
+ const lastTask = taskList[taskList.length - 1]
58
+ return lastTask && isNumber(lastTask.order)
59
+ }
60
+
61
+ export function getTasksToModify(task, taskList, newPos) {
62
+ const previousIndexWithDifferentOrder = getPreviousIndexWithDifferentOrder(taskList, newPos)
63
+ const nextIndexWithDifferentOrder = getNextIndexWithDifferentOrder(taskList, newPos)
64
+ const previousTaskWithOrder = taskList[previousIndexWithDifferentOrder]
65
+ const nextTaskWithOrder = taskList[nextIndexWithDifferentOrder]
66
+
67
+ const startingOrder = previousTaskWithOrder
68
+ ? isNumber(previousTaskWithOrder.order) && previousTaskWithOrder.order || 0
69
+ : 0;
70
+ const endingOrder = nextTaskWithOrder
71
+ ? nextTaskWithOrder.order
72
+ : undefined;
73
+
74
+ const start = previousIndexWithDifferentOrder > -1 ? previousIndexWithDifferentOrder + 1 : 0;
75
+ const end = nextIndexWithDifferentOrder > -1 ? nextIndexWithDifferentOrder : newPos + 1;
76
+ const changes = nextIndexWithDifferentOrder - previousIndexWithDifferentOrder + 1
77
+ const increment = isNumber(endingOrder) ? (endingOrder - startingOrder) / changes : 10
78
+ const tasksToModify = []
79
+ let newOrder = startingOrder
80
+ let order = 0
81
+ if (taskList.length === 0) {
82
+ order = 0
83
+ } else if (newPos === 0) {
84
+ order = taskList[0].order - 10
85
+ } else if (newPos === taskList.length && lastTaskHasOrder(taskList)) {
86
+ order = taskList[taskList.length - 1].order + 10
87
+ } else if (taskBeforeAndAfterHaveDifferentOrder(taskList, newPos)) {
88
+ order = (taskList[newPos].order - taskList[newPos - 1].order) / 2 + taskList[newPos - 1].order
89
+ } else if (taskBeforeHasOrder(taskList, newPos) && !taskAfterHasOrder(taskList, newPos)) {
90
+ order = taskList[newPos - 1].order + 10
91
+ } else {
92
+ for (let index = start; index < end; index++) {
93
+ newOrder += increment
94
+ if (index === newPos) {
95
+ task.order = newOrder
96
+ tasksToModify.push(task)
97
+ newOrder += increment
98
+ }
99
+
100
+ if (!taskList[index]) continue
101
+ taskList[index].order = newOrder
102
+ tasksToModify.push(taskList[index])
103
+ }
104
+ }
105
+
106
+ if (tasksToModify.length === 0) {
107
+ task.order = order
108
+ tasksToModify.push(task)
109
+ }
110
+
111
+ return tasksToModify
112
+ }
113
+
114
+ function tasksHaveSameOrder(taskA, taskB) {
115
+ return taskA && taskB && taskA.order + "" === taskB.order + ""
116
+ }
117
+
@@ -0,0 +1,113 @@
1
+ const cBlock = {"start":"/*", "end":"*/", "ignore":"*"};
2
+ const htmlBlock = {"start": "<!--", "end": "-->", "ignore": "-"};
3
+ const gamsBlock = {"start": "$ontext", "end": "$offtext", "ignore": "-"};
4
+
5
+ export const languages = {
6
+ ".boot": {"name": "boot", "symbol": ";"},
7
+ ".coffee": {"name": "coffeescript", "symbol": "#"},
8
+ ".litcoffee": {"name": "coffeescript", "symbol": "#", "literate": true},
9
+ "Cakefile": {"name": "coffeescript", "symbol": "#"},
10
+ ".rb": {"name": "ruby", "symbol": "#"},
11
+ ".py": {"name": "python", "symbol": "#"},
12
+ ".jl": {"name": "julia", "symbol": "#", "block": {"start": "#=", "end": "=#", "ignore": "#"}},
13
+ ".tex": {"name": "tex", "symbol": "%"},
14
+ ".latex": {"name": "tex", "symbol": "%"},
15
+ ".swift": {"name": "swift", "symbol": "//", "block": cBlock},
16
+ ".js": {"name": "javascript", "symbol": "//", "block": cBlock},
17
+ ".es6": {"name": "javascript", "symbol": "//", "block": cBlock},
18
+ ".es": {"name": "javascript", "symbol": "//", "block": cBlock},
19
+ ".ex": {"name": "elixir", "symbol": "#"},
20
+ ".exs": {"name": "elixir", "symbol": "#"},
21
+ ".jsx": {"name": "jsx", "symbol": "//", "block": cBlock},
22
+ ".java": {"name": "java", "symbol": "//", "block": cBlock},
23
+ ".properties": {"name": "properties", "symbol": "#"},
24
+ ".sbt": {"name": "sbt", "symbol": "//", "block": cBlock},
25
+ ".groovy": {"name": "groovy", "symbol": "//", "block": cBlock},
26
+ ".scss": {"name": "scss", "symbol": "//"},
27
+ ".css": {"name": "css", "symbol": "//", "block": cBlock},
28
+ ".cpp": {"name": "cpp", "symbol": "//", "block": cBlock},
29
+ ".cxx": {"name": "cpp", "symbol": "//", "block": cBlock},
30
+ ".cc": {"name": "cpp", "symbol": "//", "block": cBlock},
31
+ ".hpp": {"name": "cpp", "symbol": "//", "block": cBlock},
32
+ ".hxx": {"name": "cpp", "symbol": "//", "block": cBlock},
33
+ ".hh": {"name": "cpp", "symbol": "//", "block": cBlock},
34
+ ".ino": {"name": "cpp", "symbol": "//", "block": cBlock},
35
+ ".php": {"name": "php", "symbol": "//", "block": htmlBlock},
36
+ ".idr": {"name": "idris", "symbol": "--"},
37
+ ".hs": {"name": "haskell", "symbol": "--"},
38
+ ".lhs": {"name": "haskell", "symbol": "--"},
39
+ ".elm": {"name": "elm", "symbol": "--"},
40
+ ".erl": {"name": "erlang", "symbol": "%"},
41
+ ".hrl": {"name": "erlang", "symbol": "%"},
42
+ ".less": {"name": "less", "symbol": "//", "block": cBlock},
43
+ ".c": {"name": "c", "symbol":"//", "block": cBlock},
44
+ ".h": {"name": "objectivec", "symbol": "//", "block": cBlock},
45
+ ".m": {"name": "objectivec", "symbol": "//", "block": cBlock},
46
+ ".mm": {"name": "objectivec", "symbol": "//", "block": cBlock},
47
+ ".m4": {"name": "m4", "symbol": "#"},
48
+ ".scala": {"name": "scala", "symbol": "//", "block": cBlock},
49
+ ".cs": {"name": "cs", "symbol": "//", "block": cBlock},
50
+ ".as": {"name": "actionscript", "symbol": "//"},
51
+ ".scpt": {"name": "applescript", "symbol": "--"},
52
+ ".applescript": {"name": "applescript", "symbol": "--"},
53
+ ".sh": {"name": "bash", "symbol": "#"},
54
+ ".clj": {"name": "clojure", "symbol": ";"},
55
+ ".cljc": {"name": "clojure", "symbol": ";"},
56
+ ".cljs": {"name": "clojurescript", "symbol": ";"},
57
+ ".cmake": {"name": "cmake", "symbol": "#"},
58
+ ".d": {"name": "d", "symbol": "//"},
59
+ ".p": {"name": "delphi", "symbol": "//"},
60
+ ".pp": {"name": "delphi", "symbol": "//"},
61
+ ".pas": {"name": "delphi", "symbol": "//"},
62
+ ".bat": {"name": "dos", "symbol": "@?rem"},
63
+ ".btm": {"name": "dos", "symbol": "@?rem"},
64
+ ".cmd": {"name": "dos", "symbol": "@?rem"},
65
+ ".gms": {"name": "gams", "symbol": "*", "block": gamsBlock},
66
+ ".go": {"name": "go", "symbol": "//", "block": cBlock},
67
+ ".ini": {"name": "ini", "symbol": ";"},
68
+ ".lisp": {"name": "lisp", "symbol": ";"},
69
+ ".mel": {"name": "mel", "symbol": "//"},
70
+ ".pl": {"name": "perl", "symbol": "#"},
71
+ ".pm": {"name": "perl", "symbol": "#"},
72
+ ".pod": {"name": "perl", "symbol": "#"},
73
+ ".t": {"name": "perl", "symbol": "#"},
74
+ ".pl6": {"name": "perl6", "symbol": "#"},
75
+ ".pm6": {"name": "perl6", "symbol": "#"},
76
+ ".r": {"name": "r", "symbol": "#"},
77
+ ".rc": {"name": "rust", "symbol": "//"},
78
+ ".rs": {"name": "rust", "symbol": "//"},
79
+ ".sql": {"name": "sql", "symbol": "--"},
80
+ ".pks": {"name": "pks", "symbol": "--", "block": cBlock},
81
+ ".pkb": {"name": "pkb", "symbol": "--", "block": cBlock},
82
+ ".vala": {"name": "vala", "symbol": "//"},
83
+ ".vapi": {"name": "vala", "symbol": "//"},
84
+ ".vbe": {"name": "vbscript", "symbol": "'"},
85
+ ".vbs": {"name": "vbscript", "symbol": "'"},
86
+ ".wsc": {"name": "vbscript", "symbol": "'"},
87
+ ".wsf": {"name": "vbscript", "symbol": "'"},
88
+ ".vhdl": {"name": "vhdl", "symbol": "--"},
89
+ ".bas": {"name": "basic", "symbol": "REM"},
90
+ ".ps1": {"name": "powershell", "symbol": "#", "block": {"start":"<#", "end":"#>", "ignore":"#"} },
91
+ ".lua": {"name": "lua", "symbol": "--", "block": {"start": "--[[", "end":"--]]"} },
92
+ ".hx": {"name": "haxe", "symbol": "//", "block": cBlock},
93
+ ".eg": {"name": "earl-grey", "symbol": ";;"},
94
+ ".jade": {"name": "jade", "symbol": "//-"},
95
+ ".pug": {"name": "jade", "symbol": "//-"},
96
+ ".styl": {"name": "stylus", "symbol": "//"},
97
+ ".ts": {"name": "typescript", "symbol": "//", "block": cBlock},
98
+ ".html": {"name": "html", "symbol": "//", "block": htmlBlock },
99
+ ".haml": {"name": "haml", "symbol": "-#"},
100
+ ".yaml": {"name": "yaml", "symbol": "#"},
101
+ ".yml": {"name": "yaml", "symbol": "#"},
102
+ ".cls": {"name": "apex class", "symbol": "//", "block": cBlock},
103
+ ".trigger": {"name": "apex trigger", "symbol": "//", "block": cBlock},
104
+ ".page": {"name": "visualforce page", "symbol": "//", "block": htmlBlock },
105
+ ".component": {"name": "visualforce component", "symbol": "//", "block": htmlBlock },
106
+ ".cmp": {"name": "lightning component", "symbol": "//", "block": htmlBlock },
107
+ ".vm": {"name": "velocity", "symbol": "##", "block": {"start": "#**", "end": "*#", "ignore": "*"} },
108
+ ".vue": {"name": "vue component", "symbol": "//-", "block": cBlock},
109
+ ".lock": {"name": "yarn lock", "symbol": "#"},
110
+ ".re": {"name": "reasonml", "block": cBlock},
111
+ ".kt": {"name": "kotlin", "symbol": "//", "block": cBlock},
112
+ ".dart": {"name": "dart", "symbol": "//", "block": cBlock},
113
+ };
package/lib/list.js ADDED
@@ -0,0 +1,56 @@
1
+ import uniqid from 'uniqid';
2
+
3
+ /**
4
+ * Description
5
+ * @method List
6
+ * @param {} name
7
+ * @param {} hidden
8
+ * @return
9
+ */
10
+ export class List {
11
+ constructor({ name, hidden, ignore, filter, id }) {
12
+ this.name = name;
13
+ this.hidden = hidden || false
14
+ this.ignore = ignore || false
15
+ this.id = id || uniqid()
16
+ if (filter) this.filter = filter
17
+ this.tasks = [];
18
+ }
19
+
20
+ static isList(list) {
21
+ return list instanceof List;
22
+ };
23
+
24
+ isHidden() {
25
+ return this.hidden;
26
+ };
27
+
28
+ getName() {
29
+ return this.name;
30
+ };
31
+
32
+ getTasks() {
33
+ return this.tasks;
34
+ };
35
+
36
+ addTask(task) {
37
+ if (!this.tasks.find(_task => _task.equals(task))) {
38
+ this.tasks.push(task);
39
+ }
40
+ };
41
+
42
+ setTasks(tasks) {
43
+ this.tasks = tasks;
44
+ };
45
+
46
+ hasTasks() {
47
+ return this.tasks.length > 0;
48
+ };
49
+
50
+ toConfig() {
51
+ const list = { ...this }
52
+ delete list.tasks
53
+ if (list.filter == null) delete list.filter
54
+ return list
55
+ };
56
+ }
@@ -0,0 +1,165 @@
1
+ import _cloneDeep from 'lodash.clonedeep'
2
+ import _path from 'path'
3
+ import uniqid from 'uniqid'
4
+ import { defaultSettings as _defaultSettings } from './default-settings.js'
5
+
6
+ export function buildMigrateConfig (repo, defaultSettings = _defaultSettings) {
7
+ const path = repo.path
8
+ return function (config = repo.config) {
9
+ const settings = config.settings
10
+ if (!settings) {
11
+ config.settings = defaultSettings
12
+ }
13
+ if (config && config.settings) {
14
+ const lists = config.lists
15
+ .filter((list) => !list.filter)
16
+ .map((list) => list.name)
17
+
18
+ // Set the default journalType
19
+ if (config.settings.appendNewCardsTo && !config.settings.journalType) {
20
+ config.settings.journalType = 'Single File'
21
+ }
22
+
23
+ // convert exports to actions
24
+ if (config.settings.exports) {
25
+ config.settings.actions = config.settings.exports
26
+ delete config.settings.exports
27
+ }
28
+
29
+ // Make sure all all-caps lists are available in code
30
+ config.lists.forEach((list) => {
31
+ if (
32
+ config.code.include_lists.includes(list.name) ||
33
+ list.name !== list.name.toUpperCase()
34
+ )
35
+ return
36
+ config.code.include_lists.push(list.name)
37
+ })
38
+
39
+ if (!config.settings.cards) {
40
+ config.settings.cards = {}
41
+ }
42
+ // metaSep
43
+ if (config.settings.metaSep) {
44
+ config.settings.cards.metaSep = config.settings.metaSep
45
+ delete config.settings.metaSep
46
+ }
47
+ // defaultList
48
+ if (config.settings.defaultList) {
49
+ config.settings.cards.defaultList = config.settings.defaultList
50
+ delete config.settings.defaultList
51
+ }
52
+
53
+ if (config.settings.cards.defaultList === undefined) {
54
+ config.settings.cards.defaultList = lists ? lists.find(list => /todo/i.test(list)) :
55
+ lists[0] || '';
56
+ }
57
+
58
+ // archiveCompleted
59
+ if (config.settings.cards.archiveCompleted === undefined) {
60
+ config.settings.cards.archiveCompleted = true
61
+ }
62
+
63
+ // archiveFolder
64
+ if (config.settings.cards.archiveFolder === undefined) {
65
+ config.settings.cards.archiveFolder = config.settings.journalPath ? _path.join(config.settings.journalPath, 'archive') : 'archive'
66
+ }
67
+
68
+ // showTagsAndMeta
69
+ if (config.settings.cards.showTagsAndMeta === undefined) {
70
+ config.settings.cards.showTagsAndMeta = true
71
+ }
72
+
73
+ if (!repo.listExists(config.settings.cards.defaultList) && lists) {
74
+ config.settings.cards.defaultList = lists[0]
75
+ }
76
+
77
+ // taskPrefix (move to cards)
78
+ if (config.settings.taskPrefix) {
79
+ config.settings.cards.taskPrefix = config.settings.taskPrefix
80
+ delete config.settings.taskPrefix
81
+ }
82
+ // maxLines (move to cards)
83
+ if (config.settings.maxLines) {
84
+ config.settings.cards.maxLines = config.settings.maxLines
85
+ delete config.settings.maxLines
86
+ }
87
+ // tagPrefix (move to cards)
88
+ if (config.settings.tagPrefix) {
89
+ config.settings.cards.tagPrefix = config.settings.tagPrefix
90
+ delete config.settings.tagPrefix
91
+ }
92
+ // addCheckBoxTasks (move to cards)
93
+ if (config.settings.addCheckBoxTasks) {
94
+ config.settings.cards.addCheckBoxTasks =
95
+ config.settings.addCheckBoxTasks
96
+ delete config.settings.addCheckBoxTasks
97
+ }
98
+ // addNewCardsToTop (move to cards)
99
+ if (config.settings.addNewCardsToTop) {
100
+ config.settings.cards.addNewCardsToTop =
101
+ config.settings.addNewCardsToTop
102
+ delete config.settings.addNewCardsToTop
103
+ }
104
+ // doneList (move to cards)
105
+ if (config.settings.doneList) {
106
+ config.settings.cards.doneList = config.settings.doneList
107
+ delete config.settings.doneList
108
+ }
109
+ // Set up default doneList
110
+ if (config.settings.cards.doneList === undefined) {
111
+ config.settings.cards.doneList = lists ? lists.find(list => /done/i.test(list)) :
112
+ lists[lists.length - 1] || '';
113
+ }
114
+ // Set up default doingList
115
+ if (config.settings.cards.doingList === undefined) {
116
+ config.settings.cards.doingList = lists ? lists.find(list => /doing|progress/i.test(list)) :
117
+ lists[lists.length - 2] || '';
118
+ }
119
+ // Add name
120
+ if (config.settings.name === undefined) {
121
+ config.settings.name = _path.basename(path)
122
+ }
123
+
124
+ // Remove HASH_META_ORDER
125
+ if (config.settings.newCardSyntax && config.settings.newCardSyntax === 'HASH_META_ORDER') {
126
+ config.settings.newCardSyntax = 'HASHTAG'
127
+ config.settings.cards.orderMeta = true
128
+ }
129
+
130
+ // Move defaultFilter out of views
131
+ if (config.settings.views && config.settings.views.length > 0) {
132
+ const defaultView = config.settings.views.find(({id}) => id === 'default')
133
+ config.settings.defaultFilter = defaultView ? defaultView.filter : ''
134
+ config.settings.views = config.settings.views.filter(({id}) => id !== 'default')
135
+ }
136
+
137
+ // Remove settings.filteredLists
138
+ if (config.settings.filteredLists) {
139
+ delete config.settings.filteredLists
140
+ }
141
+
142
+ // make sure all lists have an id
143
+ config.lists.forEach((list) => {
144
+ if (!list.id || (list.id + "").length < 4) list.id = uniqid()
145
+ })
146
+
147
+ // Make sure kudosProbability is set
148
+ if (config.settings.kudosProbability === undefined) {
149
+ config.settings.kudosProbability = 0.33
150
+ }
151
+
152
+ const defaultCardsSettings = _cloneDeep(defaultSettings.cards)
153
+ const cardsSettings = _cloneDeep(config.settings.cards)
154
+
155
+ delete defaultSettings.cards
156
+ delete config.settings.cards
157
+
158
+ config.settings = { ...defaultSettings, ...config.settings }
159
+ config.settings.cards = {
160
+ ...defaultCardsSettings,
161
+ ...cardsSettings,
162
+ }
163
+ }
164
+ }
165
+ }
@@ -0,0 +1,2 @@
1
+ export * from './repo-fs-store.js';
2
+ export * from './repo-watched-fs-store.js';