imdone-core 1.54.10 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dependency-cruiser.cjs +412 -0
- package/.github/workflows/ci.yml +2 -2
- package/.imdoneignore +2 -1
- package/README.md +2 -2
- package/_index.md +7 -0
- package/build.js +57 -0
- package/esm-migration.md +446 -0
- package/lib/FileProjectContext.js +13 -0
- package/lib/ProjectContext.js +19 -18
- package/lib/adapters/date-time.js +3 -8
- package/lib/adapters/environment.js +3 -0
- package/lib/adapters/file-gateway.js +133 -106
- package/lib/adapters/git-download.js +36 -16
- package/lib/adapters/index.js +9 -0
- package/lib/adapters/logger.js +136 -0
- package/lib/adapters/markdown.js +31 -19
- package/lib/adapters/parsers/DateLanguageParser.js +11 -9
- package/lib/adapters/parsers/content-transformer.js +35 -30
- package/lib/adapters/parsers/file/LocalFileParserFactory.js +8 -9
- package/lib/adapters/parsers/file/ReadStreamCodeParser.js +8 -8
- package/lib/adapters/parsers/file/ReadStreamMarkdownParser.js +4 -4
- package/lib/adapters/parsers/file/ReadStreamTaskParser.js +5 -3
- package/lib/adapters/parsers/file/index.js +4 -0
- package/lib/adapters/parsers/function-parser.js +1 -5
- package/lib/adapters/parsers/index.js +5 -0
- package/lib/adapters/parsers/task/CardContentParser.js +23 -32
- package/lib/adapters/parsers/task/CheckStyleTaskParser.js +2 -2
- package/lib/adapters/parsers/task/CodeStyleTaskParser.js +2 -2
- package/lib/adapters/parsers/task/HashStyleTaskParser.js +3 -3
- package/lib/adapters/parsers/task/MarkdownStyleTaskParser.js +2 -2
- package/lib/adapters/parsers/task/TaskParser.js +1 -1
- package/lib/adapters/parsers/task/index.js +6 -0
- package/lib/adapters/storage/config.js +15 -20
- package/lib/adapters/storage/index.js +2 -0
- package/lib/adapters/storage/tags.js +11 -12
- package/lib/adapters/yaml.js +8 -5
- package/lib/card.js +25 -26
- package/lib/checksum.js +22 -0
- package/lib/cli.js +114 -0
- package/lib/config.js +106 -71
- package/lib/constants.js +21 -50
- package/lib/context/ApplicationContext.js +7 -4
- package/lib/context/index.js +1 -0
- package/lib/default-settings.js +3 -3
- package/lib/domain/entities/View.js +4 -11
- package/lib/domain/entities/index.js +1 -0
- package/lib/domain/index.js +2 -0
- package/lib/domain/usecases/GetViewsUsecase.js +6 -12
- package/lib/domain/usecases/SaveViewUsecase.js +8 -14
- package/lib/domain/usecases/index.js +2 -0
- package/lib/file.js +1158 -1162
- package/lib/get-tasks-to-modify.js +117 -0
- package/lib/index.js +23 -0
- package/lib/languages.js +4 -5
- package/lib/list.js +46 -95
- package/lib/migrate-config.js +5 -5
- package/lib/mixins/index.js +2 -0
- package/lib/mixins/repo-fs-store.js +224 -289
- package/lib/mixins/repo-watched-fs-store.js +158 -147
- package/lib/plugins/archive-plugin.js +10 -8
- package/lib/plugins/default-board-actions-plugin.js +2 -2
- package/lib/plugins/default-board-properties-plugin.js +7 -7
- package/lib/plugins/default-plugins.js +7 -0
- package/lib/plugins/epic-plugin.js +6 -5
- package/lib/plugins/extension-plugin.js +24 -17
- package/lib/plugins/index.js +9 -0
- package/lib/plugins/persist-tags-plugin.js +4 -3
- package/lib/plugins/plugin-manager.js +89 -52
- package/lib/plugins/plugin-registry.js +12 -16
- package/lib/project-factory.js +21 -24
- package/lib/project.js +97 -144
- package/lib/repository.js +1323 -1555
- package/lib/task.js +562 -580
- package/lib/tools.js +39 -113
- package/lib/usecases/actions.js +32 -0
- package/lib/usecases/get-project-tags.js +3 -12
- package/lib/usecases/get-tasks-in-file.js +4 -7
- package/lib/usecases/index.js +4 -0
- package/package.json +44 -66
- package/scripts/delete-markdown-indexes.js +87 -0
- package/scripts/generate-index.js +35 -0
- package/{index-markdown.js → scripts/index-markdown.js} +7 -7
- package/tsconfig.json +15 -0
- package/types/FileProjectContext.d.ts +4 -0
- package/types/ProjectContext.d.ts +9 -0
- package/types/adapters/date-time.d.ts +2 -0
- package/types/adapters/environment.d.ts +1 -0
- package/types/adapters/file-gateway.d.ts +51 -0
- package/types/adapters/git-download.d.ts +1 -0
- package/types/adapters/index.d.ts +9 -0
- package/types/adapters/logger.d.ts +24 -0
- package/types/adapters/markdown.d.ts +13 -0
- package/types/adapters/parsers/DateLanguageParser.d.ts +1 -0
- package/types/adapters/parsers/content-transformer.d.ts +10 -0
- package/types/adapters/parsers/file/LocalFileParserFactory.d.ts +5 -0
- package/types/adapters/parsers/file/ReadStreamCodeParser.d.ts +13 -0
- package/types/adapters/parsers/file/ReadStreamMarkdownParser.d.ts +7 -0
- package/types/adapters/parsers/file/ReadStreamTaskParser.d.ts +19 -0
- package/types/adapters/parsers/file/index.d.ts +4 -0
- package/types/adapters/parsers/function-parser.d.ts +1 -0
- package/types/adapters/parsers/index.d.ts +5 -0
- package/types/adapters/parsers/task/CardContentParser.d.ts +45 -0
- package/types/adapters/parsers/task/CheckStyleTaskParser.d.ts +12 -0
- package/types/adapters/parsers/task/CodeStyleTaskParser.d.ts +14 -0
- package/types/adapters/parsers/task/HashStyleTaskParser.d.ts +13 -0
- package/types/adapters/parsers/task/MarkdownStyleTaskParser.d.ts +14 -0
- package/types/adapters/parsers/task/TaskParser.d.ts +7 -0
- package/types/adapters/parsers/task/index.d.ts +6 -0
- package/types/adapters/storage/config.d.ts +6 -0
- package/types/adapters/storage/index.d.ts +2 -0
- package/types/adapters/storage/tags.d.ts +3 -0
- package/types/adapters/yaml.d.ts +2 -0
- package/types/card.d.ts +166 -0
- package/types/checksum.d.ts +8 -0
- package/types/config.d.ts +61 -0
- package/types/constants.d.ts +46 -0
- package/types/context/ApplicationContext.d.ts +24 -0
- package/types/context/index.d.ts +1 -0
- package/types/default-settings.d.ts +2 -0
- package/types/domain/entities/FileProjectContext.d.ts +5 -0
- package/types/domain/entities/View.d.ts +17 -0
- package/types/domain/entities/index.d.ts +1 -0
- package/types/domain/index.d.ts +2 -0
- package/types/domain/usecases/GetViewsUsecase.d.ts +4 -0
- package/types/domain/usecases/SaveViewUsecase.d.ts +8 -0
- package/types/domain/usecases/index.d.ts +2 -0
- package/types/file.d.ts +344 -0
- package/types/get-tasks-to-modify.d.ts +3 -0
- package/types/index.d.ts +23 -0
- package/types/languages.d.ts +649 -0
- package/types/list.d.ts +30 -0
- package/types/migrate-config.d.ts +1 -0
- package/types/mixins/index.d.ts +2 -0
- package/types/mixins/repo-fs-store.d.ts +2 -0
- package/types/mixins/repo-watched-fs-store.d.ts +2 -0
- package/types/plugins/archive-plugin.d.ts +8 -0
- package/types/plugins/default-board-actions-plugin.d.ts +9 -0
- package/types/plugins/default-board-properties-plugin.d.ts +16 -0
- package/types/plugins/default-plugins.d.ts +6 -0
- package/types/plugins/epic-plugin.d.ts +19 -0
- package/types/plugins/extension-plugin.d.ts +15 -0
- package/types/plugins/index.d.ts +9 -0
- package/types/plugins/persist-tags-plugin.d.ts +4 -0
- package/types/plugins/plugin-manager.d.ts +68 -0
- package/types/plugins/plugin-registry.d.ts +1 -0
- package/types/project-factory.d.ts +14 -0
- package/types/project.d.ts +158 -0
- package/types/repository.d.ts +996 -0
- package/types/task.d.ts +202 -0
- package/types/tools.d.ts +29 -0
- package/types/usecases/actions.d.ts +7 -0
- package/types/usecases/get-imdone-url.d.ts +1 -0
- package/types/usecases/get-project-tags.d.ts +1 -0
- package/types/usecases/get-tasks-in-file.d.ts +4 -0
- package/types/usecases/index.d.ts +4 -0
- package/vitest.config.js +13 -0
- package/cli.js +0 -74
- package/index.js +0 -1
- package/lib/adapters/readers/FileSystemProjectReader.js +0 -45
- package/lib/context/StreamingApplicationContext.js +0 -31
- package/lib/controlers/SaveViewController.js +0 -10
- package/lib/domain/entities/FileProjectContext.js +0 -10
- package/lib/domain/usecases/OpenProjectUsecase.js +0 -13
package/lib/card.js
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { Task } from './task.js'
|
|
2
|
+
import _path from 'path'
|
|
3
|
+
import _pick from 'lodash.pick'
|
|
4
|
+
import _isFunction from 'lodash.isfunction'
|
|
5
|
+
import _isObject from 'lodash.isobject'
|
|
6
|
+
import _isEmpty from 'lodash.isempty'
|
|
7
|
+
import eol from 'eol'
|
|
8
|
+
import { getFunctionSignature } from './adapters/parsers/function-parser.js'
|
|
9
|
+
import { format, encodeMarkdownLinks, interpolate } from './adapters/parsers/content-transformer.js'
|
|
10
|
+
import { removeMD } from './adapters/markdown.js'
|
|
11
|
+
import { createRequire } from 'node:module';
|
|
12
|
+
import { logger } from './adapters/logger.js'
|
|
13
|
+
|
|
14
|
+
const require = createRequire(import.meta.url);
|
|
15
|
+
export const allEmoji = require("markdown-it-emoji/lib/data/full.json")
|
|
14
16
|
|
|
15
17
|
const CONTENT_TOKEN = '__CONTENT__'
|
|
16
18
|
const lf = String(eol.lf)
|
|
17
19
|
|
|
18
|
-
|
|
20
|
+
export function newCard(task, _project, dontParse) {
|
|
19
21
|
const project = _project
|
|
20
22
|
const pluginManager = _project && _project.pluginManager
|
|
21
23
|
|
|
@@ -68,14 +70,14 @@ module.exports = function newCard(task, _project, dontParse) {
|
|
|
68
70
|
}
|
|
69
71
|
|
|
70
72
|
initProps() {
|
|
71
|
-
const props =
|
|
73
|
+
const props = this?.settings?.cards?.props ?? {}
|
|
72
74
|
this.props = this.frontMatter.props
|
|
73
75
|
? { ...props, ...this.frontMatter.props }
|
|
74
76
|
: { ...props }
|
|
75
77
|
}
|
|
76
78
|
|
|
77
79
|
initComputed() {
|
|
78
|
-
const computed =
|
|
80
|
+
const computed = this?.settings?.cards?.computed ?? {}
|
|
79
81
|
this.computed = this.frontMatter.computed
|
|
80
82
|
? { ...computed, ...this.frontMatter.computed }
|
|
81
83
|
: { ...computed }
|
|
@@ -92,11 +94,11 @@ module.exports = function newCard(task, _project, dontParse) {
|
|
|
92
94
|
}
|
|
93
95
|
|
|
94
96
|
get relPath() {
|
|
95
|
-
return this.source ? this.source.path :
|
|
97
|
+
return this.source ? this.source.path : undefined
|
|
96
98
|
}
|
|
97
99
|
|
|
98
100
|
get fullPath() {
|
|
99
|
-
return this.source ? _path.join(project.path, this.source.path) :
|
|
101
|
+
return this.source ? _path.join(project.path, this.source.path) : undefined
|
|
100
102
|
}
|
|
101
103
|
|
|
102
104
|
get defaultData() {
|
|
@@ -152,7 +154,7 @@ module.exports = function newCard(task, _project, dontParse) {
|
|
|
152
154
|
// Call the computed function for a value
|
|
153
155
|
computedValue = value.call(computedProps)
|
|
154
156
|
} catch (e) {
|
|
155
|
-
|
|
157
|
+
logger.info(
|
|
156
158
|
`Unable to compute key: ${key} with value: ${computedValue}`,
|
|
157
159
|
e.message
|
|
158
160
|
)
|
|
@@ -160,9 +162,9 @@ module.exports = function newCard(task, _project, dontParse) {
|
|
|
160
162
|
} else {
|
|
161
163
|
try {
|
|
162
164
|
// Use template for the computed value
|
|
163
|
-
computedValue =
|
|
165
|
+
computedValue = interpolate(value, computedProps, { tags: ['${', '}'] })
|
|
164
166
|
} catch (e) {
|
|
165
|
-
|
|
167
|
+
logger.info(
|
|
166
168
|
`Unable to compute key: ${key} with value: ${computedValue}`,
|
|
167
169
|
e.message
|
|
168
170
|
)
|
|
@@ -171,7 +173,7 @@ module.exports = function newCard(task, _project, dontParse) {
|
|
|
171
173
|
computed[key] = computedValue
|
|
172
174
|
}
|
|
173
175
|
} catch (e) {
|
|
174
|
-
|
|
176
|
+
logger.error(e)
|
|
175
177
|
}
|
|
176
178
|
|
|
177
179
|
const pluginData = pluginManager
|
|
@@ -234,13 +236,10 @@ module.exports = function newCard(task, _project, dontParse) {
|
|
|
234
236
|
}
|
|
235
237
|
|
|
236
238
|
getCardMarkdown() {
|
|
237
|
-
// - eliminate <!--[ ]--> wrappers
|
|
238
239
|
let taskMD = this.interpretedContent
|
|
239
240
|
.replace(/%%[\s\S]*?%%/g, '')
|
|
240
241
|
.replace(/<\!--\s*?-->/gs, '')
|
|
241
242
|
.trim()
|
|
242
|
-
// taskMD = this.replaceImagePaths(taskMD)
|
|
243
|
-
// - Split on eol and append lines until visible line count equals lines
|
|
244
243
|
const displayContent = []
|
|
245
244
|
const rawContent = []
|
|
246
245
|
const mdArray = eol.split(taskMD)
|
|
@@ -263,7 +262,7 @@ module.exports = function newCard(task, _project, dontParse) {
|
|
|
263
262
|
getHtml(content) {
|
|
264
263
|
const html = project.renderMarkdown(content, this.fullPath)
|
|
265
264
|
const mdArray = eol.split(content)
|
|
266
|
-
let truncHtml
|
|
265
|
+
let truncHtml
|
|
267
266
|
if (mdArray.length > this.truncLines) {
|
|
268
267
|
mdArray.length = this.truncLines
|
|
269
268
|
truncHtml = project.renderMarkdown(mdArray.join(eol.lf), this.fullPath)
|
package/lib/checksum.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { createHash } from 'crypto';
|
|
2
|
+
import { readFile } from 'fs/promises';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Compute a checksum for a given string or file.
|
|
6
|
+
* @param {string} input - The string or file path to hash.
|
|
7
|
+
* @param {string} algorithm - The hash algorithm to use (default: 'sha1').
|
|
8
|
+
* @param {boolean} isFile - Whether the input is a file path.
|
|
9
|
+
* @returns {Promise<string>} The computed checksum.
|
|
10
|
+
*/
|
|
11
|
+
export async function computeChecksum(input, algorithm = 'sha1', isFile = false) {
|
|
12
|
+
const hash = createHash(algorithm);
|
|
13
|
+
|
|
14
|
+
if (isFile) {
|
|
15
|
+
const fileBuffer = await readFile(input);
|
|
16
|
+
hash.update(fileBuffer);
|
|
17
|
+
} else {
|
|
18
|
+
hash.update(input);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return hash.digest('hex');
|
|
22
|
+
}
|
package/lib/cli.js
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// DOING Modernize cli to esm
|
|
4
|
+
// <!--
|
|
5
|
+
// order:-40
|
|
6
|
+
// -->
|
|
7
|
+
import { Command } from 'commander';
|
|
8
|
+
import ora from 'ora';
|
|
9
|
+
import chalk from 'chalk';
|
|
10
|
+
import * as fs from 'node:fs/promises'; // Use fs/promises for async read
|
|
11
|
+
import { fileURLToPath } from 'node:url';
|
|
12
|
+
import path from 'node:path';
|
|
13
|
+
import { executeBoardAction, listAvailableActions } from './usecases/actions.js';
|
|
14
|
+
import { logger } from './adapters/logger.js';
|
|
15
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
16
|
+
const __dirname = path.dirname(__filename);
|
|
17
|
+
|
|
18
|
+
async function getPackageJson() {
|
|
19
|
+
try {
|
|
20
|
+
const data = await fs.readFile(path.join(__dirname, '..', 'package.json'), 'utf8');
|
|
21
|
+
return JSON.parse(data);
|
|
22
|
+
} catch (error) {
|
|
23
|
+
logger.error("Error reading package.json:", error);
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const _package = await getPackageJson();
|
|
29
|
+
// const { log } = hideLogs();
|
|
30
|
+
const spinner = ora('Loading unicorns');
|
|
31
|
+
|
|
32
|
+
setTimeout(() => {
|
|
33
|
+
spinner.color = 'yellow';
|
|
34
|
+
spinner.text = 'Loading rainbows';
|
|
35
|
+
}, 1000);
|
|
36
|
+
|
|
37
|
+
function actionCancelled() {
|
|
38
|
+
logger.log(chalk.bgRed('Action canceled'));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const program = new Command();
|
|
42
|
+
program.version(_package.version, '-v, --version', 'output the current version');
|
|
43
|
+
|
|
44
|
+
const actionCmd = program.command('action')
|
|
45
|
+
.description('Manage board actions');
|
|
46
|
+
|
|
47
|
+
actionCmd
|
|
48
|
+
.command('run <title>')
|
|
49
|
+
.option('-p, --plugin <plugin>', 'Plugin name', 'ExtensionPlugin')
|
|
50
|
+
.option('-t, --task <task>', 'Task filePath:line')
|
|
51
|
+
.option('-w, --working-dir <workingDir>', 'Working directory', '.')
|
|
52
|
+
.option('-c, --config <configPath>', 'Config file path', path.join('.imdone', 'config.yml'))
|
|
53
|
+
.description('Run a board action')
|
|
54
|
+
.action(async (title, {
|
|
55
|
+
plugin = 'ExtensionPlugin',
|
|
56
|
+
task,
|
|
57
|
+
workingDir,
|
|
58
|
+
configPath
|
|
59
|
+
}) => {
|
|
60
|
+
spinner.start();
|
|
61
|
+
const action = { plugin, title };
|
|
62
|
+
const [filePath, line] = task ? task.split(':') : [];
|
|
63
|
+
// DOING: Move this CLI command to a usecase
|
|
64
|
+
try {
|
|
65
|
+
await executeBoardAction({
|
|
66
|
+
projectPath: workingDir,
|
|
67
|
+
configPath,
|
|
68
|
+
task: filePath && line && { filePath, line },
|
|
69
|
+
action
|
|
70
|
+
});
|
|
71
|
+
} catch (e) {
|
|
72
|
+
logger.error(e);
|
|
73
|
+
actionCancelled();
|
|
74
|
+
} finally {
|
|
75
|
+
spinner.stop();
|
|
76
|
+
process.exit(0);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
actionCmd
|
|
81
|
+
.command('list')
|
|
82
|
+
.option('-p, --plugin <plugin>', 'Plugin name', 'ExtensionPlugin')
|
|
83
|
+
.option('-w, --working-dir <workingDir>', 'Working directory')
|
|
84
|
+
.option('-c, --config <configPath>', 'Config file path')
|
|
85
|
+
.description('List available actions')
|
|
86
|
+
.action(async ({ workingDir = path.resolve('.'), configPath, plugin}) => {
|
|
87
|
+
spinner.start();
|
|
88
|
+
try {
|
|
89
|
+
await listAvailableActions(workingDir, configPath, plugin);
|
|
90
|
+
} catch (e) {
|
|
91
|
+
logger.error(e);
|
|
92
|
+
actionCancelled();
|
|
93
|
+
} finally {
|
|
94
|
+
spinner.stop();
|
|
95
|
+
process.exit(0);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
program.parse();
|
|
100
|
+
|
|
101
|
+
function hideLogs() {
|
|
102
|
+
const log = logger.log;
|
|
103
|
+
const info = logger.info;
|
|
104
|
+
const warn = logger.warn;
|
|
105
|
+
const logQueue = { warn: [], info: [], log: [] };
|
|
106
|
+
if (!process.env.DEBUG) {
|
|
107
|
+
Object.keys(logQueue).forEach((key) => {
|
|
108
|
+
console[key] = function(...args) {
|
|
109
|
+
logQueue[key].push(args);
|
|
110
|
+
};
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
return { log, info, warn, logQueue };
|
|
114
|
+
}
|
package/lib/config.js
CHANGED
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const _cloneDeep = require('lodash.clonedeep')
|
|
4
|
-
const _assign = require('lodash.assign')
|
|
5
|
-
const _get = require('lodash.get')
|
|
6
|
-
const {
|
|
7
|
-
JOURNAL_TYPE,
|
|
8
|
-
DEFAULT_CONFIG,
|
|
9
|
-
} = require('./constants')
|
|
10
|
-
|
|
11
1
|
/**
|
|
12
2
|
* Description
|
|
13
3
|
* @method Config
|
|
@@ -18,16 +8,75 @@ const COLON = ':'
|
|
|
18
8
|
const DOUBLE_COLON = '::'
|
|
19
9
|
const META_SEPS = [COLON, DOUBLE_COLON]
|
|
20
10
|
|
|
21
|
-
|
|
11
|
+
const JOURNAL_TYPE = {
|
|
12
|
+
SINGLE_FILE: 'Single File',
|
|
13
|
+
FOLDER: 'Folder',
|
|
14
|
+
NEW_FILE: 'New File',
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const DEFAULT_CONFIG = {
|
|
18
|
+
keepEmptyPriority: false,
|
|
19
|
+
code: {
|
|
20
|
+
include_lists: [
|
|
21
|
+
'TODO',
|
|
22
|
+
'DOING',
|
|
23
|
+
'DONE',
|
|
24
|
+
'PLANNING',
|
|
25
|
+
'FIXME',
|
|
26
|
+
'ARCHIVE',
|
|
27
|
+
'HACK',
|
|
28
|
+
'CHANGED',
|
|
29
|
+
'XXX',
|
|
30
|
+
'IDEA',
|
|
31
|
+
'NOTE',
|
|
32
|
+
'REVIEW',
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
lists: [
|
|
36
|
+
{
|
|
37
|
+
hidden: false,
|
|
38
|
+
name: 'TODO',
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
hidden: false,
|
|
42
|
+
name: 'DOING',
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
hidden: false,
|
|
46
|
+
name: 'DONE',
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export class Config {
|
|
22
52
|
constructor(opts) {
|
|
23
|
-
|
|
53
|
+
Object.assign(this, opts)
|
|
24
54
|
if (!this.settings) this.settings = {}
|
|
25
55
|
if (!this.settings.views) this.settings.views = []
|
|
26
56
|
if (!this.settings.cards) this.settings.cards = {}
|
|
27
57
|
}
|
|
28
58
|
|
|
59
|
+
static DEFAULT_CONFIG = DEFAULT_CONFIG
|
|
60
|
+
static JOURNAL_TYPE = JOURNAL_TYPE
|
|
61
|
+
|
|
62
|
+
static newDefaultConfig(config = {}) {
|
|
63
|
+
return new Config(
|
|
64
|
+
{
|
|
65
|
+
...DEFAULT_CONFIG,
|
|
66
|
+
lists: [
|
|
67
|
+
...DEFAULT_CONFIG.lists
|
|
68
|
+
],
|
|
69
|
+
...config
|
|
70
|
+
}
|
|
71
|
+
)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
get cards () {
|
|
75
|
+
return this?.settings?.cards
|
|
76
|
+
}
|
|
77
|
+
|
|
29
78
|
get defaultFilter() {
|
|
30
|
-
return
|
|
79
|
+
return this?.settings?.defaultFilter ?? ''
|
|
31
80
|
}
|
|
32
81
|
|
|
33
82
|
set defaultFilter(filter) {
|
|
@@ -35,7 +84,7 @@ class Config {
|
|
|
35
84
|
}
|
|
36
85
|
|
|
37
86
|
get name() {
|
|
38
|
-
|
|
87
|
+
return this?.settings?.name ?? ''
|
|
39
88
|
}
|
|
40
89
|
|
|
41
90
|
set name(name) {
|
|
@@ -43,71 +92,69 @@ class Config {
|
|
|
43
92
|
}
|
|
44
93
|
|
|
45
94
|
includeList(name) {
|
|
46
|
-
return (
|
|
47
|
-
this.code &&
|
|
48
|
-
this.code.include_lists &&
|
|
49
|
-
this.code.include_lists.slice &&
|
|
50
|
-
this.code.include_lists.includes(name)
|
|
51
|
-
)
|
|
95
|
+
return this?.code?.include_lists?.includes(name)
|
|
52
96
|
}
|
|
53
97
|
|
|
54
98
|
ignoreList(name) {
|
|
55
|
-
const list = this
|
|
99
|
+
const list = this?.lists?.find((list) => name === list.name)
|
|
56
100
|
return !list || (list && list.ignore)
|
|
57
101
|
}
|
|
58
102
|
|
|
59
103
|
listExists(name) {
|
|
60
|
-
return this
|
|
104
|
+
return this?.lists?.findIndex((list) => list.name === name) > -1
|
|
61
105
|
}
|
|
62
106
|
|
|
63
107
|
getDefaultList() {
|
|
64
|
-
return
|
|
108
|
+
return this?.cards?.defaultList ?? this.lists[0].name
|
|
65
109
|
}
|
|
66
110
|
|
|
67
111
|
getDoneList() {
|
|
68
|
-
const lists =
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
112
|
+
const lists = structuredClone(this.lists).reverse().filter((list) => !list.filter)
|
|
113
|
+
return this?.cards?.doneList
|
|
114
|
+
|| lists?.find(list => /dene|completed|finished/i.test(list?.name ?? ''))?.name
|
|
115
|
+
|| lists[0]?.name
|
|
116
|
+
|| ''
|
|
117
|
+
}
|
|
72
118
|
|
|
73
119
|
getDoingList() {
|
|
74
|
-
const lists =
|
|
75
|
-
.reverse()
|
|
76
|
-
|
|
77
|
-
lists
|
|
78
|
-
|
|
120
|
+
const lists = structuredClone(this.lists).filter((list) => !list.filter)
|
|
121
|
+
.reverse()
|
|
122
|
+
return this?.cards?.doingList
|
|
123
|
+
|| lists?.find(list => /doing|progress/i.test(list?.name ?? ''))?.name
|
|
124
|
+
|| lists[1]?.name
|
|
125
|
+
|| ''
|
|
79
126
|
}
|
|
80
127
|
|
|
81
128
|
isAddNewCardsToTop() {
|
|
82
|
-
return
|
|
129
|
+
return this?.cards?.addNewCardsToTop ?? false
|
|
83
130
|
}
|
|
84
131
|
|
|
85
132
|
getNewCardSyntax() {
|
|
86
|
-
return
|
|
133
|
+
return this?.settings?.newCardSyntax?? 'MARKDOWN'
|
|
87
134
|
}
|
|
88
135
|
|
|
89
136
|
isMetaNewLine() {
|
|
90
|
-
return
|
|
137
|
+
return this?.cards?.metaNewLine ?? false
|
|
91
138
|
}
|
|
92
139
|
|
|
93
140
|
getTagPrefix() {
|
|
94
|
-
return
|
|
141
|
+
return this?.cards?.tagPrefix ?? '+'
|
|
95
142
|
}
|
|
96
143
|
|
|
97
144
|
getTaskPrefix() {
|
|
98
|
-
return
|
|
145
|
+
return this?.cards?.taskPrefix ?? '##'
|
|
99
146
|
}
|
|
100
147
|
|
|
101
148
|
isAddCheckBoxTasks() {
|
|
102
|
-
return
|
|
149
|
+
return this?.cards?.addCheckBoxTasks ?? false
|
|
103
150
|
}
|
|
104
151
|
|
|
105
152
|
isAddCompletedMeta() {
|
|
106
|
-
return
|
|
153
|
+
return this?.cards?.addCompletedMeta ?? false
|
|
107
154
|
}
|
|
108
155
|
|
|
109
156
|
get customCardTerminator() {
|
|
110
|
-
return
|
|
157
|
+
return this?.cards?.customCardTerminator
|
|
111
158
|
}
|
|
112
159
|
|
|
113
160
|
set customCardTerminator(terminator) {
|
|
@@ -115,27 +162,27 @@ class Config {
|
|
|
115
162
|
}
|
|
116
163
|
|
|
117
164
|
get markdownOnly() {
|
|
118
|
-
return this
|
|
165
|
+
return this?.settings?.markdownOnly
|
|
119
166
|
}
|
|
120
167
|
|
|
121
168
|
get views() {
|
|
122
|
-
return this
|
|
169
|
+
return this?.settings?.views
|
|
123
170
|
}
|
|
124
171
|
|
|
125
172
|
get appendNewCardsTo() {
|
|
126
|
-
return
|
|
173
|
+
return this?.settings?.appendNewCardsTo ?? false
|
|
127
174
|
}
|
|
128
175
|
|
|
129
176
|
get ignoreFrontMatter() {
|
|
130
|
-
return
|
|
177
|
+
return this?.settings?.ignoreFrontMatter ?? false
|
|
131
178
|
}
|
|
132
179
|
|
|
133
180
|
get ignoreFrontMatterTags() {
|
|
134
|
-
return
|
|
181
|
+
return this?.settings?.ignoreFrontMatterTags ?? false
|
|
135
182
|
}
|
|
136
183
|
|
|
137
184
|
get journalPath() {
|
|
138
|
-
return
|
|
185
|
+
return this?.settings?.journalPath ?? ''
|
|
139
186
|
}
|
|
140
187
|
|
|
141
188
|
set journalPath(path) {
|
|
@@ -143,52 +190,52 @@ class Config {
|
|
|
143
190
|
}
|
|
144
191
|
|
|
145
192
|
get journalTemplate() {
|
|
146
|
-
const template =
|
|
193
|
+
const template = this?.settings?.journalTemplate ?? ''
|
|
147
194
|
return template === 'null' ? '' : template || ''
|
|
148
195
|
}
|
|
149
196
|
|
|
150
197
|
get journalType() {
|
|
151
|
-
return
|
|
198
|
+
return this?.settings?.journalType ?? JOURNAL_TYPE.FOLDER
|
|
152
199
|
}
|
|
153
200
|
|
|
154
201
|
get journalFilePrefix() {
|
|
155
|
-
return
|
|
202
|
+
return this?.settings?.journalFilePrefix ?? ''
|
|
156
203
|
}
|
|
157
204
|
|
|
158
205
|
get journalFileSuffix() {
|
|
159
|
-
return
|
|
206
|
+
return this?.settings?.journalFileSuffix ?? ''
|
|
160
207
|
}
|
|
161
208
|
|
|
162
209
|
get replaceSpacesWith() {
|
|
163
|
-
return
|
|
210
|
+
return this?.settings?.replaceSpacesWith
|
|
164
211
|
}
|
|
165
212
|
|
|
166
213
|
get devMode() {
|
|
167
|
-
return
|
|
214
|
+
return this?.settings?.plugins?.devMode ?? false
|
|
168
215
|
}
|
|
169
216
|
|
|
170
217
|
get plugins() {
|
|
171
|
-
return
|
|
218
|
+
return this?.settings?.plugins ?? { devMode: this.devMode }
|
|
172
219
|
}
|
|
173
220
|
|
|
174
221
|
get orderMeta() {
|
|
175
|
-
return
|
|
222
|
+
return this?.cards?.orderMeta ?? false
|
|
176
223
|
}
|
|
177
224
|
|
|
178
225
|
get maxLines() {
|
|
179
|
-
return
|
|
226
|
+
return this?.cards?.maxLines ?? 1
|
|
180
227
|
}
|
|
181
228
|
|
|
182
229
|
get archiveFolder() {
|
|
183
|
-
return
|
|
230
|
+
return this?.cards?.archiveFolder ?? 'archive'
|
|
184
231
|
}
|
|
185
232
|
|
|
186
233
|
get archiveCompleted() {
|
|
187
|
-
return
|
|
234
|
+
return this?.cards?.archiveCompleted ?? false
|
|
188
235
|
}
|
|
189
236
|
|
|
190
237
|
get tokenPrefix() {
|
|
191
|
-
return
|
|
238
|
+
return this?.cards?.tokenPrefix ?? '#'
|
|
192
239
|
}
|
|
193
240
|
|
|
194
241
|
get doneList() {
|
|
@@ -196,19 +243,7 @@ class Config {
|
|
|
196
243
|
}
|
|
197
244
|
|
|
198
245
|
getMetaSep() {
|
|
199
|
-
const metaSep =
|
|
246
|
+
const metaSep = this?.cards?.metaSep ?? COLON
|
|
200
247
|
return META_SEPS.includes(metaSep) ? metaSep : COLON
|
|
201
248
|
}
|
|
202
249
|
}
|
|
203
|
-
|
|
204
|
-
Config.newDefaultConfig = (config = {}) => new Config(
|
|
205
|
-
{
|
|
206
|
-
...DEFAULT_CONFIG,
|
|
207
|
-
lists: [
|
|
208
|
-
...DEFAULT_CONFIG.lists
|
|
209
|
-
],
|
|
210
|
-
...config
|
|
211
|
-
}
|
|
212
|
-
)
|
|
213
|
-
|
|
214
|
-
module.exports = Config
|
package/lib/constants.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import path from 'path'
|
|
2
|
+
import { Config } from './config.js'
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var DEFAULT_IGNORE_PATHS = `
|
|
5
5
|
node_modules
|
|
6
6
|
bower_components
|
|
7
7
|
target
|
|
@@ -15,6 +15,7 @@ flow-typed
|
|
|
15
15
|
.npmignore
|
|
16
16
|
.obsidian
|
|
17
17
|
.imdone/templates
|
|
18
|
+
.imdone/tags.yml
|
|
18
19
|
`
|
|
19
20
|
var DEFAULT_IGNORE_EXTS = `
|
|
20
21
|
*.jpg
|
|
@@ -32,27 +33,29 @@ var DEFAULT_IGNORE_EXTS = `
|
|
|
32
33
|
*.pot*
|
|
33
34
|
`
|
|
34
35
|
|
|
35
|
-
|
|
36
|
-
${
|
|
36
|
+
const DEFAULT_IGNORE = `
|
|
37
|
+
${DEFAULT_IGNORE_PATHS}
|
|
37
38
|
${DEFAULT_IGNORE_EXTS}
|
|
38
39
|
`
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
40
|
+
const CONFIG_DIR = '.imdone'
|
|
41
|
+
const CONFIG_FILE = path.join(CONFIG_DIR, 'config.json')
|
|
42
|
+
const CONFIG_FILE_YML = path.join(CONFIG_DIR, 'config.yml')
|
|
43
|
+
const SORT_FILE = path.join(CONFIG_DIR, 'sort.json')
|
|
44
|
+
const TEMPLATES_DIR = path.join(CONFIG_DIR, 'templates')
|
|
45
|
+
const { JOURNAL_TYPE, DEFAULT_CONFIG } = Config
|
|
46
|
+
|
|
47
|
+
export const constants = {
|
|
48
|
+
JOURNAL_TYPE,
|
|
46
49
|
ASYNC_LIMIT: 512,
|
|
47
50
|
CONFIG_DIR,
|
|
48
|
-
CONFIG_FILE
|
|
49
|
-
CONFIG_FILE_YML
|
|
50
|
-
SORT_FILE
|
|
51
|
-
TEMPLATES_DIR
|
|
51
|
+
CONFIG_FILE,
|
|
52
|
+
CONFIG_FILE_YML,
|
|
53
|
+
SORT_FILE,
|
|
54
|
+
TEMPLATES_DIR,
|
|
52
55
|
IGNORE_FILE: '.imdoneignore',
|
|
53
56
|
DEFAULT_FILE_PATTERN: '^(readme\\.md|home\\.md|readme\\.w+|home\\.w+)$',
|
|
54
57
|
DEFAULT_IGNORE,
|
|
55
|
-
|
|
58
|
+
DEFAULT_IGNORE_PATHS,
|
|
56
59
|
DEFAULT_IGNORE_EXTS,
|
|
57
60
|
ERRORS: {
|
|
58
61
|
NOT_A_FILE: 'file must be of type File',
|
|
@@ -61,37 +64,5 @@ module.exports = {
|
|
|
61
64
|
LIST_NOT_FOUND: 'List not found',
|
|
62
65
|
TASK_NOT_FOUND: 'Task not found',
|
|
63
66
|
},
|
|
64
|
-
DEFAULT_CONFIG
|
|
65
|
-
keepEmptyPriority: false,
|
|
66
|
-
code: {
|
|
67
|
-
include_lists: [
|
|
68
|
-
'TODO',
|
|
69
|
-
'DOING',
|
|
70
|
-
'DONE',
|
|
71
|
-
'PLANNING',
|
|
72
|
-
'FIXME',
|
|
73
|
-
'ARCHIVE',
|
|
74
|
-
'HACK',
|
|
75
|
-
'CHANGED',
|
|
76
|
-
'XXX',
|
|
77
|
-
'IDEA',
|
|
78
|
-
'NOTE',
|
|
79
|
-
'REVIEW',
|
|
80
|
-
],
|
|
81
|
-
},
|
|
82
|
-
lists: [
|
|
83
|
-
{
|
|
84
|
-
hidden: false,
|
|
85
|
-
name: 'TODO',
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
hidden: false,
|
|
89
|
-
name: 'DOING',
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
hidden: false,
|
|
93
|
-
name: 'DONE',
|
|
94
|
-
},
|
|
95
|
-
],
|
|
96
|
-
},
|
|
67
|
+
DEFAULT_CONFIG,
|
|
97
68
|
}
|