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
package/lib/tools.js CHANGED
@@ -1,43 +1,12 @@
1
- 'use strict'
2
-
3
- var _isFunction = require('lodash.isfunction'),
4
- _noop = require('lodash.noop'),
5
- crypto = require('crypto'),
6
- _path = require('path'),
7
- fastSort = require('fast-sort/dist/sort.js'),
8
- eol = require('eol'),
9
- max_bytes = 512
10
-
11
- function mkdirp(fs, path, mode, cb, position) {
12
- if (_isFunction(mode)) {
13
- cb = mode
14
- mode = '0777'
15
- }
16
- if (!cb) cb = _noop
17
-
18
- var parts = _path.normalize(path).split(_path.sep)
19
- mode = mode || process.umask()
20
- position = position || 0
1
+ import _isFunction from 'lodash.isfunction'
2
+ import _noop from 'lodash.noop'
3
+ import crypto from 'crypto'
4
+ import _path from 'path'
5
+ import { sort } from 'fast-sort'
6
+ import eol from 'eol'
7
+ import escapeRegExp from 'escape-string-regexp'
21
8
 
22
- if (position >= parts.length) {
23
- return cb()
24
- }
25
-
26
- var directory = parts.slice(0, position + 1).join(_path.sep) || _path.sep
27
- fs.stat(directory, function (err) {
28
- if (err === null) {
29
- mkdirp(fs, path, mode, cb, position + 1)
30
- } else {
31
- fs.mkdir(directory, mode, function (err) {
32
- if (err && err.code != 'EEXIST') {
33
- return cb(err)
34
- } else {
35
- mkdirp(fs, path, mode, cb, position + 1)
36
- }
37
- })
38
- }
39
- })
40
- }
9
+ const max_bytes = 512
41
10
 
42
11
  function isBinaryCheck(bytes, size) {
43
12
  if (size === 0) return false
@@ -86,18 +55,39 @@ function isBinaryCheck(bytes, size) {
86
55
  return false
87
56
  }
88
57
 
89
- module.exports = {
90
- escapeRegExp: require('escape-string-regexp'),
91
- userHome: function () {
58
+ function deepEqual(a, b) {
59
+ if (a === b) return true; // Same reference
60
+
61
+ if (typeof a !== 'object' || typeof b !== 'object' || a === null || b === null) {
62
+ return false; // Different types or one is null
63
+ }
64
+
65
+ if (Array.isArray(a) !== Array.isArray(b)) return false; // One is array, one is object
66
+
67
+ const keysA = Object.keys(a);
68
+ const keysB = Object.keys(b);
69
+ if (keysA.length !== keysB.length) return false; // Different number of keys
70
+
71
+ return keysA.every((key) => keysB.includes(key) && deepEqual(a[key], b[key]));
72
+ }
73
+
74
+ export const tools = {
75
+ union(...arrays) {
76
+ return [...new Set(arrays.flat())];
77
+ },
78
+ escapeRegExp(str) {
79
+ return escapeRegExp(str)
80
+ },
81
+ userHome() {
92
82
  return process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE
93
83
  },
94
-
84
+ deepEqual,
95
85
  /**
96
86
  * Description
97
87
  * @method user
98
88
  * @return LogicalExpression
99
89
  */
100
- user: function () {
90
+ user() {
101
91
  return process.env.USER || process.env.USERNAME
102
92
  },
103
93
 
@@ -107,13 +97,14 @@ module.exports = {
107
97
  * @param {} cb
108
98
  * @return ConditionalExpression
109
99
  */
110
- cb: function (cb) {
100
+ cb(cb) {
111
101
  return _isFunction(cb) ? cb : _noop
112
102
  },
113
103
 
114
- inMixinsNoop: function (cb) {
104
+ inMixinsNoop(cb) {
115
105
  cb = this.cb(cb)
116
- cb(new Error('Implemented in mixins'))
106
+ if (cb) return cb(new Error('Implemented in mixins'))
107
+ throw new Error('Implemented in mixins')
117
108
  },
118
109
 
119
110
  /**
@@ -176,73 +167,8 @@ module.exports = {
176
167
  },
177
168
 
178
169
  isBinaryCheck: isBinaryCheck,
179
-
180
- readdirSyncRecursive: function (fs, baseDir) {
181
- baseDir = baseDir.replace(/\/$/, '')
182
-
183
- var readdirSyncRecursive = function (baseDir) {
184
- var files = [],
185
- curFiles,
186
- nextDirs,
187
- isDir = function (fname) {
188
- return fs.existsSync(_path.join(baseDir, fname))
189
- ? fs.statSync(_path.join(baseDir, fname)).isDirectory()
190
- : false
191
- },
192
- prependBaseDir = function (fname) {
193
- return _path.join(baseDir, fname)
194
- }
195
-
196
- curFiles = fs.readdirSync(baseDir)
197
- nextDirs = curFiles.filter(isDir)
198
- curFiles = curFiles.map(prependBaseDir)
199
-
200
- files = files.concat(curFiles)
201
-
202
- while (nextDirs.length) {
203
- files = files.concat(
204
- readdirSyncRecursive(_path.join(baseDir, nextDirs.shift()))
205
- )
206
- }
207
-
208
- return files
209
- }
210
-
211
- // convert absolute paths to relative
212
- var fileList = readdirSyncRecursive(baseDir).map(function (val) {
213
- return _path.relative(baseDir, val)
214
- })
215
-
216
- return fileList
217
- },
218
-
219
- mkdirSyncRecursive: function (fs, path, mode) {
220
- var self = this
221
- path = _path.normalize(path)
222
-
223
- try {
224
- fs.mkdirSync(path, mode)
225
- } catch (err) {
226
- if (err.code == 'ENOENT') {
227
- var slashIdx = path.lastIndexOf(_path.sep)
228
-
229
- if (slashIdx > 0) {
230
- var parentPath = path.substring(0, slashIdx)
231
- this.mkdirSyncRecursive(parentPath, mode)
232
- this.mkdirSyncRecursive(path, mode)
233
- } else {
234
- throw err
235
- }
236
- } else if (err.code == 'EEXIST') {
237
- return
238
- } else {
239
- throw err
240
- }
241
- }
242
- },
243
- mkdirp: mkdirp,
244
170
  sortTasks(tasks) {
245
- return fastSort(tasks).asc([u => u.order, u => u.text])
171
+ return sort(tasks).asc([u => u.order, u => u.text])
246
172
  },
247
173
  hasBlankLines(content) {
248
174
  return new RegExp(`^\\s*${String(eol.auto)}`, 'gm').test(content)
@@ -0,0 +1,32 @@
1
+ import { createFileSystemProject } from '../project-factory.js';
2
+ import { load } from '../adapters/storage/config.js';
3
+ import { logger } from '../adapters/logger.js';
4
+
5
+ /**
6
+ * Initializes and returns a project instance.
7
+ * @param {string} projectPath - The path to the project.
8
+ * @param {string} configPath - The path to the configuration file.
9
+ * @returns {Promise<Object>} - The initialized project instance.
10
+ */
11
+ async function initializeProject(projectPath, configPath) {
12
+ const path = projectPath;
13
+ const config = await load(projectPath, configPath);
14
+ const project = createFileSystemProject({ path, config });
15
+ await project.init();
16
+ await project.toImdoneJSON();
17
+
18
+ return project;
19
+ }
20
+
21
+ export async function executeBoardAction({ projectPath, configPath, task, action }) {
22
+ const project = await initializeProject(projectPath, configPath);
23
+ const file = task && project.getFile(task.filePath);
24
+ const activeTask = file && task.line > -1 && file.getTaskAtLine(task.line);
25
+ await project.performBoardAction(action, activeTask);
26
+ }
27
+
28
+ export async function listAvailableActions(projectPath, configPath, plugin) {
29
+ const project = await initializeProject(projectPath, configPath);
30
+ logger.log('\nAvailable actions:');
31
+ logger.log(JSON.stringify(project.boardActions, null, 2));
32
+ }
@@ -1,16 +1,7 @@
1
- const {
2
- load
3
- } = require('../adapters/storage/tags.js')
1
+ import { load } from '../adapters/storage/tags.js'
2
+ import { findImdonePath } from '../adapters/storage/config.js'
4
3
 
5
- const {
6
- findImdonePath
7
- } = require('../adapters/storage/config.js')
8
-
9
- module.exports = {
10
- getTags
11
- }
12
-
13
- async function getTags(filePath) {
4
+ export async function getTags(filePath) {
14
5
  const projectPath = await findImdonePath(filePath)
15
6
  return await load(projectPath)
16
7
  }
@@ -1,12 +1,9 @@
1
- const { loadForFilePath } = require('../adapters/storage/config')
2
- const { getFileParser } = require('../adapters/parsers/file/LocalFileParserFactory')
3
- const { Readable } = require('stream');
1
+ import { loadForFilePath } from '../adapters/storage/config.js';
2
+ import { getFileParser } from '../adapters/parsers/file/LocalFileParserFactory.js';
3
+ import { Readable } from 'node:stream';
4
4
 
5
- module.exports = {
6
- getTasks
7
- }
8
5
 
9
- async function getTasks({filePath, content}) {
6
+ export async function getTasks({filePath, content}) {
10
7
  const config = await loadForFilePath(filePath)
11
8
 
12
9
  const readStream = new Readable({
@@ -0,0 +1,4 @@
1
+ export * from './actions.js';
2
+ export * from './get-imdone-url.js';
3
+ export * from './get-project-tags.js';
4
+ export * from './get-tasks-in-file.js';
package/package.json CHANGED
@@ -1,24 +1,29 @@
1
1
  {
2
2
  "name": "imdone-core",
3
- "version": "1.54.10",
3
+ "version": "2.0.1",
4
4
  "description": "imdone-core",
5
- "main": "index.js",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/imdone/imdone-core.git"
8
+ },
9
+ "main": "lib/index.js",
10
+ "types": "types/index.d.ts",
11
+ "type": "module",
6
12
  "bin": {
7
- "imdone-cli": "./cli.js"
13
+ "imdone-cli": "lib/cli.js"
8
14
  },
9
15
  "scripts": {
10
- "build": "doctoc --github --notitle README.md && npm test",
11
- "coverage": "nyc --reporter=lcov --reporter=text --reporter=html mocha --exit",
12
- "lint": "jshint ./lib",
13
- "mocha": "mocha --exit",
14
- "test": "export NODE_ENV=test && npm run coverage",
15
- "test-debug": "mocha debug",
16
+ "prepublishOnly": "npm run build",
17
+ "build": "npm run build:docs && npm run build:docs:index && npm run coverage && npm run build:index && npm run build:types",
18
+ "build:docs": "doctoc --github --notitle README.md",
19
+ "build:docs:index": "node scripts/index-markdown.js",
20
+ "build:index": "node scripts/generate-index.js",
21
+ "build:types": "tsc --noEmit false",
22
+ "coverage": "vitest --run --coverage",
23
+ "test": "vitest --run",
24
+ "test-ci": "vitest --run",
16
25
  "serve": "npx docsify-cli serve"
17
26
  },
18
- "repository": {
19
- "type": "git",
20
- "url": "https://github.com/imdone/imdone-core.git"
21
- },
22
27
  "keywords": [
23
28
  "imdone",
24
29
  "TODO",
@@ -34,33 +39,24 @@
34
39
  "url": "https://github.com/imdone/imdone-core/issues"
35
40
  },
36
41
  "homepage": "https://github.com/imdone/imdone-core",
37
- "jshintConfig": {
38
- "strict": true,
39
- "node": true,
40
- "globals": {
41
- "jQuery": true,
42
- "console": false,
43
- "module": true,
44
- "document": true
45
- }
46
- },
47
42
  "dependencies": {
48
- "async": "~1.5.0",
49
- "chalk": "^4.1.2",
50
- "checksum": "^0.1.1",
51
- "chrono-node": "^2.6.4",
52
- "command-exists": "^1.2.9",
53
- "commander": "^11.1.0",
43
+ "adm-zip": "^0.5.16",
44
+ "async": "^3.2.6",
45
+ "async-es": "^3.2.6",
46
+ "chalk": "^5.4.1",
47
+ "chokidar": "^4.0.3",
48
+ "chrono-node": "^2.7.8",
49
+ "commander": "^13.1.0",
54
50
  "debug": ">=4.3.4",
55
- "download": "^8.0.0",
56
51
  "eol": "^0.9.1",
57
52
  "escape-string-regexp": "^1.0.5",
58
- "fast-sort": "^2.2.0",
59
- "find-up": "^5.0.0",
53
+ "eta": "^3.5.0",
54
+ "fast-sort": "^3.4.1",
55
+ "find-up-simple": "^1.0.1",
60
56
  "gray-matter": "^4.0.2",
61
57
  "ignore": "^5.2.0",
62
58
  "imdone-api": "^1.54.0",
63
- "isbinaryfile": "^3.0.2",
59
+ "isbinaryfile": "^5.0.4",
64
60
  "js-yaml": "^3.14.1",
65
61
  "json-fns": "^1.0.0",
66
62
  "lodash.assign": "^4.2.0",
@@ -82,69 +78,51 @@
82
78
  "lodash.reject": "^4.6.0",
83
79
  "lodash.remove": "^4.7.0",
84
80
  "lodash.some": "^4.6.0",
85
- "lodash.template": "^4.5.0",
86
81
  "lodash.union": "^4.6.0",
87
82
  "lodash.uniq": "^4.5.0",
88
83
  "lodash.where": "^3.1.0",
89
84
  "lodash.without": "^4.4.0",
90
- "markdown-it": "^12.3.2",
85
+ "markdown-it": "^14.1.0",
91
86
  "markdown-it-checkbox": "^1.1.0",
92
87
  "markdown-it-emoji": "^2.0.0",
93
88
  "markdown-it-imsize": "^2.0.1",
94
89
  "markdown-it-mark": "^3.0.1",
95
- "mkdirp": "^1.0.4",
96
90
  "moment": "^2.29.1",
97
91
  "monquery": "github:imdone/node-monquery#0.2.1",
98
92
  "multilang-extract-comments": "^0.4.0",
93
+ "node-fetch": "^3.3.2",
99
94
  "open": "^9.1.0",
100
- "ora": "^5.4.1",
95
+ "ora": "^8.2.0",
101
96
  "parse-code-context": "^1.0.0",
102
97
  "prompts": "^2.4.2",
103
- "readdirp": "^3.6.0",
98
+ "readdirp": "^4.1.2",
104
99
  "remove-markdown": "^0.3.0",
105
100
  "rimraf": "^3.0.2",
106
- "sane": "^5.0.1",
107
101
  "sanitize-filename": "^1.6.3",
108
102
  "sift": "^17.1.3",
109
103
  "simple-git": "^3.19.1",
110
104
  "uniqid": "^5.4.0",
111
- "xregexp": "^5.1.0"
105
+ "xregexp": "^5.1.2"
112
106
  },
113
107
  "devDependencies": {
114
- "chai": "^4.3.6",
108
+ "@types/node": "^22.13.13",
109
+ "@vitest/coverage-istanbul": "^3.0.8",
110
+ "@vitest/coverage-v8": "^3.0.8",
111
+ "chai": "^5.2.0",
115
112
  "colors": "^1.4.0",
113
+ "dependency-cruiser": "^16.10.0",
116
114
  "doctoc": "^2.1.0",
115
+ "esbuild": "^0.25.1",
117
116
  "expect.js": "~0.3.1",
118
117
  "fs-extra": "^11.1.0",
119
- "jshint": "^2.9.4",
120
118
  "json-stringify-safe": "~5.0.0",
121
119
  "mocha": "^11.1.0",
122
120
  "mocha-each": "^2.0.1",
123
- "nyc": "^15.1.0",
124
121
  "prettier": "^2.5.1",
125
122
  "should": "13.1.3",
126
- "sinon": "^13.0.0",
127
- "sinon-chai": "^3.7.0",
128
- "wrench": "~1.5.8"
129
- },
130
- "mocha": {
131
- "diff": true,
132
- "extension": [
133
- "js",
134
- "cjs",
135
- "mjs"
136
- ],
137
- "package": "./package.json",
138
- "reporter": "spec",
139
- "slow": "75",
140
- "timeout": "2000",
141
- "spec": [
142
- "lib/**/__tests__/**/*.spec.js",
143
- "test/**/*spec.js"
144
- ],
145
- "watch-files": [
146
- "lib/**/__tests__/**/*.spec.js",
147
- "test/**/*spec.js"
148
- ]
123
+ "sinon": "^19.0.2",
124
+ "sinon-chai": "^4.0.0",
125
+ "typescript": "^5.8.2",
126
+ "vitest": "^3.0.8"
149
127
  }
150
128
  }
@@ -0,0 +1,87 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import { fileURLToPath } from 'url';
4
+
5
+ // Get the current directory name in ESM
6
+ const __filename = fileURLToPath(import.meta.url);
7
+ const __dirname = path.dirname(__filename);
8
+
9
+ const sidebar = '_index.md';
10
+
11
+ function getMarkdownFiles(files = []) {
12
+ return files.filter(file => file.endsWith('.md') && file !== sidebar && file !== '_navbar.md');
13
+ }
14
+
15
+ function getFileLinks(files) {
16
+ return files.map(file => `- [${file.replace('.md', '')}](${file})`).join('\n');
17
+ }
18
+
19
+ function getSubDirLinks(files, directory) {
20
+ const subDirs = files.filter(file => fs.statSync(path.join(directory, file)).isDirectory());
21
+ const subDirsContainingMarkdown = subDirs.filter(subDir => fs.readdirSync(path.join(directory, subDir)).find(file => file.endsWith('.md')));
22
+ return subDirsContainingMarkdown.map(subDir => {
23
+ const resource = fs.readdirSync(path.join(directory, subDir)).find(file => file.toLowerCase() === 'readme.md')
24
+ ? 'README'
25
+ : sidebar;
26
+ return `- [:file_folder: **${subDir}**](${subDir}/${resource})`;
27
+ }).join('\n');
28
+ }
29
+
30
+ function getBreadCrumb(parentDir) {
31
+ const homeLink = '[:house: **Home**](/README)';
32
+ return parentDir ? `- ${homeLink}\n- [:arrow_heading_up: **Parent Directory**](${parentDir}${sidebar})` : '';
33
+ }
34
+
35
+ function createIndexes(directory, parentDir, title) {
36
+ const basename = path.basename(directory);
37
+ if (basename.startsWith('.')) {
38
+ return;
39
+ }
40
+
41
+ title = title || basename;
42
+
43
+ const files = fs.readdirSync(directory);
44
+ const markdownFiles = getMarkdownFiles(files);
45
+
46
+ if (markdownFiles.length > 0) {
47
+ const subDirLinks = getSubDirLinks(files, directory);
48
+ const fileLinks = getFileLinks(markdownFiles);
49
+ const breadcrumb = getBreadCrumb(parentDir);
50
+
51
+ fs.writeFileSync(path.join(directory, sidebar), `# ${title}\n${breadcrumb}\n${subDirLinks}\n${fileLinks}\n`);
52
+ }
53
+
54
+ files
55
+ .filter(file => fs.statSync(path.join(directory, file)).isDirectory())
56
+ .forEach(subDir => createIndexes(path.join(directory, subDir), parentDir ? path.join(parentDir, basename) + '/' : '/'));
57
+ }
58
+
59
+ createIndexes(process.cwd(), undefined, 'imdone-core');
60
+ console.log('Indexes created successfully!');
61
+
62
+ function deleteIndexFiles(dir) {
63
+ // Read the directory and filter for _index.md files
64
+ const files = fs.readdirSync(dir);
65
+
66
+ files.forEach(file => {
67
+ const filePath = path.join(dir, file);
68
+ const stat = fs.statSync(filePath);
69
+
70
+ // If it's a file and matches the _index.md pattern, delete it
71
+ if (stat.isFile() && file === '_index.md') {
72
+ console.log(`Deleting file: ${filePath}`);
73
+ fs.unlinkSync(filePath);
74
+ }
75
+
76
+ // If it's a directory, recurse
77
+ if (stat.isDirectory()) {
78
+ deleteIndexFiles(filePath);
79
+ }
80
+ });
81
+ }
82
+
83
+ // Path to your test directory
84
+ const testDirectory = path.join(__dirname, '..', 'test');
85
+
86
+ // Call the function to delete _index.md files
87
+ deleteIndexFiles(testDirectory);
@@ -0,0 +1,35 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+
4
+ const LIB_DIR = './lib';
5
+
6
+ // Recursively generates index.js files
7
+ function generateIndexes(dir) {
8
+ const entries = fs.readdirSync(dir, { withFileTypes: true });
9
+
10
+ const files = entries
11
+ .filter(entry => entry.isFile() && entry.name !== 'index.js' && entry.name !== 'cli.js' && entry.name.endsWith('.js'))
12
+ .map(entry => `export * from './${entry.name}';`);
13
+
14
+ const subdirs = entries
15
+ .filter(entry => entry.isDirectory() && entry.name !== '__tests__')
16
+ .map(entry => entry.name);
17
+
18
+ // Generate index.js in each subdirectory
19
+ subdirs.forEach(subdir => generateIndexes(path.join(dir, subdir)));
20
+
21
+ // Add namespace exports for subdirectories
22
+ const namespaceExports = subdirs.map(subdir => `export * as ${subdir} from './${subdir}/index.js';`);
23
+
24
+ // Write the index.js file
25
+ if (files.length || namespaceExports.length) {
26
+ const indexPath = path.join(dir, 'index.js');
27
+ const content = [...files, ...namespaceExports].join('\n') + '\n';
28
+ fs.writeFileSync(indexPath, content);
29
+ console.log(`Generated: ${indexPath}`);
30
+ }
31
+ }
32
+
33
+ // Run the script
34
+ generateIndexes(LIB_DIR);
35
+ console.log('✅ Index files generated successfully!');
@@ -1,5 +1,6 @@
1
- const fs = require('fs');
2
- const path = require('path');
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+
3
4
  const sidebar = '_index.md';
4
5
 
5
6
  function getMarkdownFiles(files = []) {
@@ -12,12 +13,11 @@ function getFileLinks(files) {
12
13
 
13
14
  function getSubDirLinks(files, directory) {
14
15
  const subDirs = files.filter(file => fs.statSync(path.join(directory, file)).isDirectory());
15
- const subDirsContainingMarkdown = subDirs.filter(subDir => fs.readdirSync(path.join(directory, subDir)).find(file => file.endsWith('.md'))
16
- );
16
+ const subDirsContainingMarkdown = subDirs.filter(subDir => fs.readdirSync(path.join(directory, subDir)).find(file => file.endsWith('.md')));
17
17
  return subDirsContainingMarkdown.map(subDir => {
18
18
  const resource = fs.readdirSync(path.join(directory, subDir)).find(file => file.toLowerCase() === 'readme.md')
19
19
  ? 'README'
20
- : sidebar
20
+ : sidebar;
21
21
  return `- [:file_folder: **${subDir}**](${subDir}/${resource})`;
22
22
  }).join('\n');
23
23
  }
@@ -29,7 +29,7 @@ function getBreadCrumb(parentDir) {
29
29
 
30
30
  function createIndexes(directory, parentDir, title) {
31
31
  const basename = path.basename(directory);
32
- if (basename.startsWith('.')) {
32
+ if (basename.startsWith('.') || basename === 'test') {
33
33
  return;
34
34
  }
35
35
 
@@ -52,4 +52,4 @@ function createIndexes(directory, parentDir, title) {
52
52
  }
53
53
 
54
54
  createIndexes(process.cwd(), undefined, 'imdone-core');
55
- console.log('Indexes created successfully!');
55
+ console.log('Indexes created successfully!');
package/tsconfig.json ADDED
@@ -0,0 +1,15 @@
1
+ {
2
+ "compilerOptions": {
3
+ "declaration": true,
4
+ "emitDeclarationOnly": true,
5
+ "allowJs": true,
6
+ "outDir": "types",
7
+ "module": "NodeNext",
8
+ "moduleResolution": "NodeNext",
9
+ "target": "ESNext",
10
+ "esModuleInterop": true,
11
+ "strict": true
12
+ },
13
+ "include": ["lib/**/index.js"],
14
+ "exclude": ["node_modules", "__tests__"]
15
+ }
@@ -0,0 +1,4 @@
1
+ export class FileProjectContext {
2
+ getOrder(list: any, order: any): number | undefined;
3
+ getProject(): void;
4
+ }
@@ -0,0 +1,9 @@
1
+ export class ProjectContext extends FileProjectContext {
2
+ constructor(repo: any);
3
+ repo: any;
4
+ getOrder(list: any, order: any): any;
5
+ get config(): any;
6
+ toJSON(): null;
7
+ determineOrder(config: any, order: any, tasks: any): any;
8
+ }
9
+ import { FileProjectContext } from './FileProjectContext.js';
@@ -0,0 +1,2 @@
1
+ export function setNoDST(noDST: any): void;
2
+ export function getIsoDateWithOffset(date: any): string;
@@ -0,0 +1 @@
1
+ export function isDev(): boolean;