imdone-core 2.0.13 → 2.0.15

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/lib/config.js CHANGED
@@ -145,6 +145,10 @@ export class Config {
145
145
  return this?.cards?.commentTagsOnly ?? false
146
146
  }
147
147
 
148
+ getCommentMetaOnly() {
149
+ return this?.cards?.commentMetaOnly ?? false
150
+ }
151
+
148
152
  getTaskPrefix() {
149
153
  return this?.cards?.taskPrefix ?? '##'
150
154
  }
@@ -20,11 +20,10 @@ import _ignore from 'ignore'
20
20
  import { sort } from 'fast-sort'
21
21
  import { buildMigrateConfig } from '../migrate-config.js'
22
22
  import { loadYAML, dumpYAML } from '../adapters/yaml.js';
23
- import realFs, { readFileSync } from 'fs'
23
+ import realFs from 'fs'
24
24
  import { preparePathForWriting, readFile, writeFile, stat, lstat, unlink } from '../adapters/file-gateway.js'
25
25
 
26
26
  const {
27
- CONFIG_FILE,
28
27
  CONFIG_FILE_YML,
29
28
  ASYNC_LIMIT,
30
29
  DEFAULT_IGNORE_PATHS,
@@ -198,11 +197,6 @@ export function fileSystemStoreMixin(repo, fs = realFs) {
198
197
  return repo.config
199
198
  }
200
199
 
201
- // READY Refactor loadConfig to use async/await
202
- // #esm-migration
203
- // <!--
204
- // order:-255
205
- // -->
206
200
  repo.loadConfig = async function (cb) {
207
201
  // BACKLOG If a config is bad move it to config.json.bak and save a new one with defaults gh:2 id:9 +enhancement +standup +chore
208
202
  // <!--
@@ -217,7 +211,7 @@ export function fileSystemStoreMixin(repo, fs = realFs) {
217
211
  }
218
212
 
219
213
  repo.getConfigFile = function () {
220
- return repo.getFullPath(CONFIG_FILE)
214
+ return repo.getFullPath(CONFIG_FILE_YML)
221
215
  }
222
216
 
223
217
  repo.getYamlConfig = async function () {
@@ -151,8 +151,11 @@ export function watchedFileSystemStoreMixin(repo, fs = realFs) {
151
151
  atomic: true,
152
152
  ignoreInitial: true,
153
153
  ignored: (file) => {
154
- const ignored = !repo.shouldInclude(file)
155
- if (ignored) logger.log('Ignoring file:', file)
154
+ if (file === repo.path) return false
155
+ const relPath = repo.getRelativePath(file)
156
+ const ignored = !repo.shouldInclude(relPath)
157
+ if (ignored) logger.log('Ignoring file:', relPath)
158
+
156
159
  return ignored
157
160
  }
158
161
  }).on('error', (err) => {
@@ -196,6 +199,11 @@ export function watchedFileSystemStoreMixin(repo, fs = realFs) {
196
199
  stat.mtime
197
200
  )
198
201
  if (!path || stat.isDirectory()) return
202
+
203
+ const relPath = repo.getRelativePath(path)
204
+ if (!initializing && _isImdoneConfig(relPath)) onConfigChange(relPath)
205
+ if (!initializing && _isImdoneIgnore(relPath)) onIgnoreChange(relPath)
206
+
199
207
  var file = repo.getFile(path) || path
200
208
  const isFile = File.isFile(file)
201
209
  // BACKLOG ## Handle the case where the file is not in the repo
@@ -207,8 +215,6 @@ export function watchedFileSystemStoreMixin(repo, fs = realFs) {
207
215
  // logger.log("File update already applied. Change ignored.")
208
216
  return
209
217
  }
210
- if (_isImdoneConfig(path)) return onConfigChange(path)
211
- if (_isImdoneIgnore(path)) return onIgnoreChange(path)
212
218
 
213
219
  const ok = await repo.fileOK((file && file.path) || path)
214
220
  if (!ok) return
@@ -12,7 +12,13 @@ export default class PersistTagsPlugin extends Plugin {
12
12
  }
13
13
 
14
14
  async onBoardUpdate() {
15
+ if (!this.persistTags) {
16
+ return
17
+ }
15
18
  await save(this.project.allTags.sort(), this.project.path)
16
19
  }
17
-
20
+
21
+ get persistTags() {
22
+ return this.getSettings()?.persistTags ?? true
23
+ }
18
24
  }
package/lib/repository.js CHANGED
@@ -634,12 +634,12 @@ export class Repository extends Emitter {
634
634
  shouldInclude (relPath) {
635
635
  relPath = this.getRelativePath(relPath)
636
636
  let include = true
637
- if (this.config.markdownOnly && relPath) {
638
- include = File.isMarkdown(relPath)
639
- }
640
637
  if (this.ignore) {
641
638
  try {
642
- include = include && (relPath === '' || !this.ignore.ignores(relPath))
639
+ include = relPath && !this.ignore.ignores(relPath)
640
+ if (this.config.markdownOnly && include && relPath) {
641
+ include = File.isMarkdown(relPath)
642
+ }
643
643
  } catch (e) {
644
644
  logger.error(
645
645
  `Failed to check ignore status for dir: [${relPath}] in: [${this.path}]. It will be included.`,
package/lib/task.js CHANGED
@@ -339,59 +339,7 @@ export class Task {
339
339
  return tags;
340
340
  };
341
341
 
342
- static getMarkdownLinkLabelPositions (text) {
343
- const positions = [];
344
- const re = /\[([^\]]+)\]\([^\)]+\)/g;
345
- let match;
346
-
347
- while ((match = re.exec(text)) !== null) {
348
- positions.push({ start: match.index, end: re.lastIndex });
349
- }
350
-
351
- return positions;
352
- };
353
-
354
- static isResultInMarkdownLinkLabel (linkLabelPositions, index) {
355
- return linkLabelPositions.some(pos => index >= pos.start && index < pos.end);
356
- };
357
-
358
- static getCommentPositions (text) {
359
- const positions = [];
360
- const re = /<!--[\s\S]*?-->/g;
361
- let match;
362
-
363
- while ((match = re.exec(text)) !== null) {
364
- positions.push({ start: match.index, end: re.lastIndex });
365
- }
366
-
367
- return positions;
368
- }
369
-
370
- static isResultInComment (commentPositions, index) {
371
- return commentPositions.some(pos => index >= pos.start && index < pos.end);
372
- }
373
-
374
- static ContextRegExp = new RegExp(
375
- `(^|\\s)@([${Task.AnyLanguageGroup}${Task.EmojiGroup}]+)`,
376
- 'gmiu'
377
- )
378
-
379
- static getContext (text) {
380
- const context = []
381
- var codePositions = Task.getMarkdownCodePositions(text)
382
- var result,
383
- re = new RegExp(Task.ContextRegExp)
384
-
385
- while ((result = re.exec(text)) !== null) {
386
- if (Task.isResultInMarkdownCode(codePositions, result.index)) continue
387
- const con = result[2]
388
- if (!context.includes(con)) context.push(con)
389
- }
390
-
391
- return context
392
- }
393
-
394
- static MetaRegExp = new RegExp(
342
+ static MetaRegExp = new RegExp(
395
343
  `(^|\\s)([a-zA-Z-_]+?):(?!\\/\\/)([${Task.AnyLanguageGroup}${Task.EmojiGroup}]+)`,
396
344
  'gu'
397
345
  )
@@ -413,8 +361,15 @@ export class Task {
413
361
  }
414
362
 
415
363
  static parseMetaData (config, content) {
364
+ const commentMetaOnly = config.getCommentMetaOnly()
365
+ const commentPositions = Task.getCommentPositions(content);
416
366
  var meta = {}
417
367
  Task.eachMetaInContent(config, content, (result) => {
368
+ if (
369
+ commentMetaOnly
370
+ && !Task.isResultInComment(commentPositions, result.index)
371
+ ) return;;
372
+
418
373
  var key = result[2]
419
374
  var val = result[3]
420
375
  if (!meta[key]) meta[key] = []
@@ -425,8 +380,9 @@ export class Task {
425
380
  }
426
381
 
427
382
  static getMetaData (config, task) {
428
- var text = Task.isTask(task) ? task.getRawTextAndDescription() : task
429
- var meta = Task.parseMetaData(config, text)
383
+ const text = Task.isTask(task) ? task.getRawTextAndDescription() : task
384
+
385
+ const meta = Task.parseMetaData(config, text)
430
386
  Object.entries(meta).forEach(([key, val]) => {
431
387
  if (Task.DATE_META_KEYS.includes(key)) {
432
388
  try {
@@ -462,6 +418,60 @@ export class Task {
462
418
  )
463
419
  }
464
420
 
421
+ static getMarkdownLinkLabelPositions (text) {
422
+ const positions = [];
423
+ const re = /\[([^\]]+)\]\([^\)]+\)/g;
424
+ let match;
425
+
426
+ while ((match = re.exec(text)) !== null) {
427
+ positions.push({ start: match.index, end: re.lastIndex });
428
+ }
429
+
430
+ return positions;
431
+ };
432
+
433
+ static isResultInMarkdownLinkLabel (linkLabelPositions, index) {
434
+ return linkLabelPositions.some(pos => index >= pos.start && index < pos.end);
435
+ };
436
+
437
+ static getCommentPositions (text) {
438
+ const positions = [];
439
+ const re = /<!--[\s\S]*?-->/g;
440
+ let match;
441
+
442
+ while ((match = re.exec(text)) !== null) {
443
+ positions.push({ start: match.index, end: re.lastIndex });
444
+ }
445
+
446
+ return positions;
447
+ }
448
+
449
+ static isResultInComment (commentPositions, index) {
450
+ return commentPositions.some(pos => index >= pos.start && index < pos.end);
451
+ }
452
+
453
+ static ContextRegExp = new RegExp(
454
+ `(^|\\s)@([${Task.AnyLanguageGroup}${Task.EmojiGroup}]+)`,
455
+ 'gmiu'
456
+ )
457
+
458
+ static getContext (text, commentTagsOnly = false) {
459
+ const context = []
460
+ const commentPositions = Task.getCommentPositions(text);
461
+ const codePositions = Task.getMarkdownCodePositions(text)
462
+ var result,
463
+ re = new RegExp(Task.ContextRegExp)
464
+
465
+ while ((result = re.exec(text)) !== null) {
466
+ if (commentTagsOnly && !Task.isResultInComment(commentPositions, result.index)) continue
467
+ if (Task.isResultInMarkdownCode(codePositions, result.index)) continue
468
+ const con = result[2]
469
+ if (!context.includes(con)) context.push(con)
470
+ }
471
+
472
+ return context
473
+ }
474
+
465
475
  static hasWindowsEOL (content) {
466
476
  return /\r\n|\r/.test(content)
467
477
  }
@@ -590,7 +600,7 @@ export class Task {
590
600
 
591
601
  parseTodoTxt () {
592
602
  this.tags = Task.getTags(this.getRawTextAndDescription(), this.getTagPrefix(), this.getCommentTagsOnly())
593
- this.context = Task.getContext(this.getRawTextAndDescription())
603
+ this.context = Task.getContext(this.getRawTextAndDescription(), this.getCommentTagsOnly())
594
604
  this.meta = Task.getMetaData(this.config, this)
595
605
  }
596
606
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "imdone-core",
3
- "version": "2.0.13",
3
+ "version": "2.0.15",
4
4
  "description": "imdone-core",
5
5
  "repository": {
6
6
  "type": "git",
@@ -48,7 +48,7 @@
48
48
  "async-es": "^3.2.6",
49
49
  "chalk": "^5.4.1",
50
50
  "chokidar": "^4.0.3",
51
- "chrono-node": "^2.7.8",
51
+ "chrono-node": "~2.7.8",
52
52
  "commander": "^13.1.0",
53
53
  "debug": ">=4.3.4",
54
54
  "eol": "^0.9.1",
@@ -101,8 +101,8 @@
101
101
  },
102
102
  "devDependencies": {
103
103
  "@types/node": "^22.13.13",
104
- "@vitest/coverage-istanbul": "^3.0.8",
105
- "@vitest/coverage-v8": "^3.0.8",
104
+ "@vitest/coverage-istanbul": "^3.1.1",
105
+ "@vitest/coverage-v8": "^3.1.1",
106
106
  "chai": "^5.2.0",
107
107
  "colors": "^1.4.0",
108
108
  "dependency-cruiser": "^16.10.0",
@@ -114,6 +114,6 @@
114
114
  "json-stringify-safe": "~5.0.0",
115
115
  "prettier": "^2.5.1",
116
116
  "typescript": "^5.8.2",
117
- "vitest": "^3.0.8"
117
+ "vitest": "^3.1.1"
118
118
  }
119
119
  }
@@ -2,13 +2,13 @@ export function exists(path: any): Promise<false | _fs.Stats>;
2
2
  export function statSync(path: any): _fs.Stats | undefined;
3
3
  export function init(fileSystem?: typeof _fs): void;
4
4
  export function existsSync(...args: any[]): boolean;
5
- export function readFileSync(...args: any[]): string | Buffer<ArrayBufferLike>;
5
+ export function readFileSync(...args: any[]): string | NonSharedBuffer;
6
6
  export function appendFileSync(...args: any[]): void;
7
7
  export function writeFileSync(...args: any[]): void;
8
- export function readdir(...args: any[]): Promise<_fs.Dirent[]>;
8
+ export function readdir(...args: any[]): Promise<_fs.Dirent<Buffer<ArrayBufferLike>>[]>;
9
9
  export function unlinkSync(...args: any[]): void;
10
10
  export function readdirSyncRecursive(path: any): any[];
11
- export function readdirSync(path: any): _fs.Dirent[];
11
+ export function readdirSync(path: any): _fs.Dirent<string>[];
12
12
  export function sanitizeFileName(fileName: any, replaceSpacesWith: any): any;
13
13
  export function preparePathForWriting(path: any, directory?: boolean): Promise<{
14
14
  isFile: any;
package/types/card.d.ts CHANGED
@@ -100,7 +100,7 @@ export function newCard(task: any, _project: any, dontParse: any): {
100
100
  beforeText: any;
101
101
  text: any;
102
102
  list: any;
103
- order: any;
103
+ order: number | undefined;
104
104
  hasColon: any;
105
105
  line: any;
106
106
  id: any;
package/types/config.d.ts CHANGED
@@ -33,6 +33,7 @@ export class Config {
33
33
  isMetaNewLine(): any;
34
34
  getTagPrefix(): any;
35
35
  getCommentTagsOnly(): any;
36
+ getCommentMetaOnly(): any;
36
37
  getTaskPrefix(): any;
37
38
  isAddCheckBoxTasks(): any;
38
39
  isAddCompletedMeta(): any;
package/types/file.d.ts CHANGED
@@ -198,7 +198,7 @@ export class File extends Emitter<[never]> {
198
198
  beforeText: any;
199
199
  text: any;
200
200
  list: any;
201
- order: any;
201
+ order: number | undefined;
202
202
  hasColon: any;
203
203
  line: any;
204
204
  id: any;
@@ -2,4 +2,5 @@ export default class PersistTagsPlugin {
2
2
  static get pluginName(): string;
3
3
  constructor(project: any);
4
4
  onBoardUpdate(): Promise<void>;
5
+ get persistTags(): any;
5
6
  }
package/types/task.d.ts CHANGED
@@ -19,6 +19,13 @@ export class Task {
19
19
  static EmojiGroup: string;
20
20
  static getTagRegexp(prefix?: string): RegExp;
21
21
  static getTags(text: any, prefix?: string, commentTagsOnly?: boolean): string[];
22
+ static MetaRegExp: RegExp;
23
+ static getMetaRegExp(config: any): RegExp;
24
+ static getMetaRegExpQuotes(config: any): RegExp;
25
+ static parseMetaData(config: any, content: any): {};
26
+ static getMetaData(config: any, task: any): {};
27
+ static execMetaRegex(re: any, content: any, codePositions: any, cb: any): void;
28
+ static eachMetaInContent(config: any, content: any, cb: any): void;
22
29
  static getMarkdownLinkLabelPositions(text: any): {
23
30
  start: number;
24
31
  end: number;
@@ -30,14 +37,7 @@ export class Task {
30
37
  }[];
31
38
  static isResultInComment(commentPositions: any, index: any): any;
32
39
  static ContextRegExp: RegExp;
33
- static getContext(text: any): string[];
34
- static MetaRegExp: RegExp;
35
- static getMetaRegExp(config: any): RegExp;
36
- static getMetaRegExpQuotes(config: any): RegExp;
37
- static parseMetaData(config: any, content: any): {};
38
- static getMetaData(config: any, task: any): {};
39
- static execMetaRegex(re: any, content: any, codePositions: any, cb: any): void;
40
- static eachMetaInContent(config: any, content: any, cb: any): void;
40
+ static getContext(text: any, commentTagsOnly?: boolean): string[];
41
41
  static hasWindowsEOL(content: any): boolean;
42
42
  static getLinePos(content: any, lineNo: any): any;
43
43
  static getLineNumber(content: any, pos: any): number;
@@ -70,8 +70,8 @@ export class Task {
70
70
  beforeText: any;
71
71
  text: any;
72
72
  list: any;
73
- set order(val: any);
74
- get order(): any;
73
+ set order(val: number | undefined);
74
+ get order(): number | undefined;
75
75
  hasColon: any;
76
76
  line: any;
77
77
  id: any;