imdone-core 1.41.1 → 1.42.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/lib/adapters/date-time.js +17 -8
- package/lib/adapters/parsers/DateLanguageParser.js +10 -0
- package/lib/adapters/yaml.js +6 -0
- package/lib/card.js +1 -1
- package/lib/cli/ProjectConfigFactory.js +1 -1
- package/lib/config.js +0 -4
- package/lib/default-settings.js +1 -4
- package/lib/file.js +2 -2
- package/lib/mixins/repo-fs-store.js +5 -3
- package/lib/repository.js +4 -3
- package/lib/tools.js +0 -10
- package/package.json +1 -1
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
const moment = require('moment');
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
let innerNoDST = false;
|
|
3
|
+
|
|
4
|
+
function setNoDST(noDST) {
|
|
5
|
+
innerNoDST = noDST;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
function getIsoDateWithOffset (date) {
|
|
9
|
+
const momentDate = moment(date);
|
|
10
|
+
if (momentDate.isDST() && innerNoDST) {
|
|
11
|
+
const offset = momentDate.utcOffset();
|
|
12
|
+
momentDate.utcOffset(offset - 60);
|
|
10
13
|
}
|
|
14
|
+
return momentDate.format();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
module.exports = {
|
|
18
|
+
setNoDST,
|
|
19
|
+
getIsoDateWithOffset
|
|
11
20
|
}
|
package/lib/card.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const DefaultApplicationContext = require('./adapters/ApplicationContext')
|
|
2
|
-
const { loadYAML, dumpYAML } = require('../
|
|
2
|
+
const { loadYAML, dumpYAML } = require('../adapters/yaml')
|
|
3
3
|
const Config = require('../config')
|
|
4
4
|
const { readFile, mkdir, cp, rm, writeFile, access } = require('fs').promises
|
|
5
5
|
const { resolve } = path = require('path')
|
package/lib/config.js
CHANGED
package/lib/default-settings.js
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
const { loadYAML } = require(
|
|
1
|
+
const { loadYAML } = require('./adapters/yaml')
|
|
2
2
|
|
|
3
3
|
const defaultSettingsString = `openIn: default #override
|
|
4
|
-
editorTheme: blackboard
|
|
5
4
|
journalType: New File
|
|
6
5
|
journalPath: imdone-tasks #override
|
|
7
6
|
appendNewCardsTo: imdone-tasks.md
|
|
8
7
|
newCardSyntax: HASHTAG #override
|
|
9
8
|
replaceSpacesWith: '-' #override
|
|
10
|
-
noDST: false
|
|
11
9
|
plugins:
|
|
12
10
|
devMode: false
|
|
13
11
|
cards:
|
|
@@ -31,7 +29,6 @@ cards:
|
|
|
31
29
|
addNewCardsToTop: true #override
|
|
32
30
|
showTagsAndMeta: true #override
|
|
33
31
|
journalTemplate: #override
|
|
34
|
-
theme: 'dark'
|
|
35
32
|
markdownOnly: false #override
|
|
36
33
|
`
|
|
37
34
|
module.exports = loadYAML(defaultSettingsString)
|
package/lib/file.js
CHANGED
|
@@ -149,7 +149,7 @@ File.addCompleted = function ({ task, content, config }) {
|
|
|
149
149
|
if (task.list !== doneList) return content
|
|
150
150
|
if (task.completed || task.meta.completed) return content
|
|
151
151
|
if (content.includes(`completed${config.getMetaSep()}`)) return content
|
|
152
|
-
const now = getIsoDateWithOffset(
|
|
152
|
+
const now = getIsoDateWithOffset()
|
|
153
153
|
content = task.addToLastCommentInContent(
|
|
154
154
|
content,
|
|
155
155
|
`completed${config.getMetaSep()}${now}`,
|
|
@@ -167,7 +167,7 @@ File.parseDueDate = function (config, text) {
|
|
|
167
167
|
try {
|
|
168
168
|
const due = chrono.parseDate(dueMatch, new Date(), {forwardDate: true})
|
|
169
169
|
if (!due) return dueMatch
|
|
170
|
-
dueString = getIsoDateWithOffset(
|
|
170
|
+
dueString = getIsoDateWithOffset(due)
|
|
171
171
|
return `${p1.toLowerCase()}${config.getMetaSep()}${dueString}`
|
|
172
172
|
} catch (e) {
|
|
173
173
|
console.log(`Unable to parse due date for ${text}`)
|
|
@@ -22,7 +22,9 @@ var _path = require('path'),
|
|
|
22
22
|
_ignore = require('ignore'),
|
|
23
23
|
fastSort = require('fast-sort/dist/sort.js'),
|
|
24
24
|
Repository = require('../repository'),
|
|
25
|
-
buildMigrateConfig = require('../migrate-config')
|
|
25
|
+
buildMigrateConfig = require('../migrate-config'),
|
|
26
|
+
{ loadYAML, dumpYAML } = require('../adapters/yaml')
|
|
27
|
+
|
|
26
28
|
|
|
27
29
|
module.exports = mixin
|
|
28
30
|
|
|
@@ -196,7 +198,7 @@ function mixin(repo, fs = require('fs')) {
|
|
|
196
198
|
delete data.cardPropertiesFunction
|
|
197
199
|
delete data.path
|
|
198
200
|
if (data.lists) data.lists.forEach((list) => delete list.tasks)
|
|
199
|
-
var yaml =
|
|
201
|
+
var yaml = dumpYAML(data)
|
|
200
202
|
if (exists) {
|
|
201
203
|
fs.writeFile(file, yaml, _cb)
|
|
202
204
|
} else {
|
|
@@ -277,7 +279,7 @@ function mixin(repo, fs = require('fs')) {
|
|
|
277
279
|
const configData = fs.readFileSync(filePath, 'utf-8')
|
|
278
280
|
let configLike = {}
|
|
279
281
|
try {
|
|
280
|
-
configLike =
|
|
282
|
+
configLike = loadYAML(configData.toString())
|
|
281
283
|
Repository.trimFunctionsInSettings(configLike)
|
|
282
284
|
if (configLike.exclude) delete configLike.exclude
|
|
283
285
|
if (configLike.watcher) delete configLike.watcher
|
package/lib/repository.js
CHANGED
|
@@ -36,7 +36,8 @@ var _get = require('lodash.get'),
|
|
|
36
36
|
JSONfns = require('json-fns'),
|
|
37
37
|
functionRegex = require('function-regex'),
|
|
38
38
|
Task = require('./task'),
|
|
39
|
-
newCard = require('./card')
|
|
39
|
+
newCard = require('./card'),
|
|
40
|
+
{ replaceDateLanguage } = require('./adapters/parsers/DateLanguageParser')
|
|
40
41
|
|
|
41
42
|
const appContext = require('./context/ApplicationContext')
|
|
42
43
|
|
|
@@ -1615,7 +1616,7 @@ Repository.parseSortFromMongoQuery = function (mongoQuery) {
|
|
|
1615
1616
|
}
|
|
1616
1617
|
|
|
1617
1618
|
Repository.sortByQuery = function (tasks, queryString = '') {
|
|
1618
|
-
queryString =
|
|
1619
|
+
queryString = replaceDateLanguage(queryString)
|
|
1619
1620
|
let { sort } = Repository.parseSortFromQueryString(queryString)
|
|
1620
1621
|
if (!sort || sort.length === 0) sort = DEFAULT_SORT
|
|
1621
1622
|
fastSort(tasks).by(sort)
|
|
@@ -1624,7 +1625,7 @@ Repository.sortByQuery = function (tasks, queryString = '') {
|
|
|
1624
1625
|
Repository.query = function (tasks, queryString = '') {
|
|
1625
1626
|
let query
|
|
1626
1627
|
let sort
|
|
1627
|
-
queryString =
|
|
1628
|
+
queryString = replaceDateLanguage(queryString)
|
|
1628
1629
|
const resp = Repository.parseSortFromQueryString(queryString)
|
|
1629
1630
|
try {
|
|
1630
1631
|
query = monquery(resp.queryString)
|
package/lib/tools.js
CHANGED
|
@@ -5,11 +5,9 @@ var _isFunction = require('lodash.isfunction'),
|
|
|
5
5
|
crypto = require('crypto'),
|
|
6
6
|
_path = require('path'),
|
|
7
7
|
markdown = require('markdown-it')().use(require('markdown-it-checkbox')),
|
|
8
|
-
YAML = require('js-yaml'),
|
|
9
8
|
fastSort = require('fast-sort/dist/sort.js'),
|
|
10
9
|
eol = require('eol'),
|
|
11
10
|
max_bytes = 512
|
|
12
|
-
const chrono = require('chrono-node')
|
|
13
11
|
|
|
14
12
|
function mkdirp(fs, path, mode, cb, position) {
|
|
15
13
|
if (_isFunction(mode)) {
|
|
@@ -255,15 +253,7 @@ module.exports = {
|
|
|
255
253
|
}
|
|
256
254
|
}
|
|
257
255
|
},
|
|
258
|
-
replaceDateLanguage(text, asDate) {
|
|
259
|
-
return text.replace(/\(?\${(.*?)}\)?/g, (match, p1) => {
|
|
260
|
-
const date = chrono.parseDate(p1)
|
|
261
|
-
return date ? date.toISOString() : p1
|
|
262
|
-
})
|
|
263
|
-
},
|
|
264
256
|
mkdirp: mkdirp,
|
|
265
|
-
dumpYAML: YAML.dump,
|
|
266
|
-
loadYAML: YAML.load,
|
|
267
257
|
sortTasks(tasks) {
|
|
268
258
|
return fastSort(tasks).asc([u => u.order, u => u.text])
|
|
269
259
|
},
|