Skip to content

Commit

Permalink
feat!: stop matching noteId & report unmodified
Browse files Browse the repository at this point in the history
  • Loading branch information
timgreen committed Mar 13, 2023
1 parent 19692da commit 8226956
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 70 deletions.
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"/oclif.manifest.json"
],
"dependencies": {
"@anki.md/core": "^0.10.4",
"@anki.md/core": "0.11.0",
"@autoanki/anki-connect": "^0.1.2",
"@oclif/core": "^2.0.3",
"@oclif/plugin-autocomplete": "^2.1.2",
Expand Down
35 changes: 0 additions & 35 deletions packages/cli/src/commands/rmids.ts

This file was deleted.

48 changes: 14 additions & 34 deletions packages/cli/src/commands/sync.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import chalk from "chalk";
import {
ankiConnectSync,
Parser,
updateNoteId,
Reporter,
model,
} from "@anki.md/core";
import { ankiConnectSync, Parser, Reporter, model } from "@anki.md/core";
import { Args, Command, Flags } from "@oclif/core";
import * as fs from "fs";
import fetch from "node-fetch";
Expand Down Expand Up @@ -42,14 +36,6 @@ export default class Sync extends Command {
"update-model-styling": Flags.boolean({
description: "update the styling for the existing note models.",
}),
"save-note-ids": Flags.boolean({
description:
"save the note IDs in markdown after sync. \nIt will be used to update note instead insert on next sync",
default: false,
required: false,
allowNo: true,
aliases: ["save-note-id"],
}),
"overwrite-existing-medias": Flags.boolean({
description:
"Replace the existing medias with the same name during sync.",
Expand All @@ -68,6 +54,7 @@ export default class Sync extends Command {
var mediaCount = 0;
var modelCount = 0;
var notesUpdatedCount = 0;
var notesUnmodifiedCount = 0;
const reporter: Reporter = {
startModelCreation: () => {
spinnies.add("modelCreation", { text: "model:", indent: 2 });
Expand Down Expand Up @@ -130,7 +117,15 @@ export default class Sync extends Command {
spinnies.succeed("notes", {
text: `${chalk.reset("notes:")} ${chalk.green(
`+${newInserted}`,
)} ${chalk.yellow(`~${notesUpdatedCount}`)}`,
)} ${chalk.yellow(`~${notesUpdatedCount}`)} ${chalk.reset(
`=${notesUnmodifiedCount}`,
)}`,
});
},
unmodifiedNotes: (count: number) => {
notesUnmodifiedCount = count;
spinnies.update("notes", {
text: `note: ${chalk.reset(`=${notesUnmodifiedCount}`)}`,
});
},
increaseUpdatedNote: (total: number) => {
Expand All @@ -141,7 +136,9 @@ export default class Sync extends Command {
},
insertingNotes: (total: number) => {
spinnies.update("notes", {
text: `note: ${chalk.yellow(`~${notesUpdatedCount}`)}`,
text: `note: ${chalk.yellow(`~${notesUpdatedCount}`)} ${chalk.reset(
`=${notesUnmodifiedCount}`,
)}`,
});
spinnies.update("noteUpdate", { text: `inserting ${total}` });
},
Expand Down Expand Up @@ -170,23 +167,6 @@ export default class Sync extends Command {
reporter,
);

if (flags["save-note-ids"]) {
if (isRemote) {
// TODO: warning about skip save note ids for remote files.
} else {
// TODO: check if the source if readonly.
noteIds.forEach((noteId, index) => {
if (noteId) {
deck.notes[index].noteId = noteId;
}
});
const updatedContent = updateNoteId(content, deck.notes);
if (content != updatedContent) {
fs.writeFileSync(input, updatedContent);
}
}
}

spinnies.succeed(input, { text: chalk.reset(input) });
}
}
Expand Down

0 comments on commit 8226956

Please sign in to comment.