imdone-core 1.41.0 → 1.41.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/file.js CHANGED
@@ -788,9 +788,9 @@ const trimBlankLines = File.trimBlankLines = function (content, isCodeFile) {
788
788
  }
789
789
 
790
790
  File.prototype.modifyDescription = function (task, config) {
791
- // DOING This should be split out by type (code, markdown, etc)
791
+ // TODO This should be split out by type (code, markdown, etc)
792
792
  // #urgent
793
- // <!-- order:-10 -->
793
+ // <!-- order:-70 -->
794
794
  const taskStart = this.getLinePos(task.line)
795
795
  const descStart = this.getLinePos(task.line + 1)
796
796
  const contentWithTask = this.getContent().substring(taskStart)
package/lib/project.js CHANGED
@@ -443,34 +443,27 @@ module.exports = class WorkerProject extends Project {
443
443
  const filePath = cardData.path
444
444
  if (addTemplate) content += cardData.template
445
445
 
446
- content = this.addOrderMetaToContent(content, list)
447
446
  content = this.addTagsToContent(tags, content)
448
447
  content = this.addContextsToContent(contexts, content)
449
448
  content = this.addMetaToContent(meta, content)
450
449
 
451
450
  return new Promise((resolve, reject) => {
452
- this.repo.addTaskToFile(filePath, list, content, (err, file) => {
451
+ this.repo.addTaskToFile(filePath, list, content, (err, file, task) => {
453
452
  if (err) return reject(err)
454
- resolve(file)
453
+
454
+ const newList = task.list
455
+ const list = this.lists.find(l => l.name === newList)
456
+ const newPos = this.config.isAddNewCardsToTop() ? 0 : list.tasks.length - 1
457
+
458
+ this.repo.moveTask({ task, newList, newPos }, (err) => {
459
+ if (err) return reject(err)
460
+
461
+ resolve({ file, task })
462
+ })
455
463
  })
456
464
  })
457
465
  }
458
466
 
459
- addOrderMetaToContent(content, _list) {
460
- const list = this.lists.find(l => l.name === _list)
461
- let order
462
- if (this.config.isAddNewCardsToTop()) {
463
- order = list.tasks.length
464
- ? list.tasks[0].order - 1
465
- : 0
466
- } else {
467
- order = list.tasks.length
468
- ? list.tasks[list.tasks.length - 1].order + 1
469
- : 0
470
- }
471
- return Task.addToLastCommentInContent(content, `order${this.config.getMetaSep()}${order}`, this.config.isMetaNewLine())
472
- }
473
-
474
467
  addMetaToContent(meta, content) {
475
468
  if (meta && meta.length > 0) {
476
469
  let metaContent = ''
package/lib/repository.js CHANGED
@@ -1115,8 +1115,13 @@ Repository.prototype.appendTask = function({file, content, list}, cb) {
1115
1115
  appendContent = `${taskPrefix}#${list}${inLineOrder} ${text}${eol.lf}${taskContent}`
1116
1116
  }
1117
1117
  appendContent = File.trimBlankLines(appendContent)
1118
- file.setContent(`${fileContent}${sep}${appendContent}${"\n".repeat(2)}`)
1119
- this.writeAndExtract(file, true, cb)
1118
+ fileContent = `${fileContent}${sep}`
1119
+ file.setContent(`${fileContent}${appendContent}${"\n".repeat(2)}`)
1120
+ this.writeAndExtract(file, true, (err, file) => {
1121
+ if (err) return cb(err)
1122
+ const task = file.getTasks().find(task => task.text === text && task.list === list)
1123
+ cb(null, file, task)
1124
+ })
1120
1125
  }
1121
1126
 
1122
1127
  Repository.prototype.addTaskToFile = function (filePath, list, content, cb) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "imdone-core",
3
- "version": "1.41.0",
3
+ "version": "1.41.1",
4
4
  "description": "imdone-core",
5
5
  "main": "index.js",
6
6
  "bin": {