create-kvitton 0.4.1 → 0.4.2

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.
Files changed (2) hide show
  1. package/dist/index.js +12 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -994,15 +994,23 @@ async function syncJournalEntries2(client2, repoPath, options, onProgress) {
994
994
  break;
995
995
  page++;
996
996
  }
997
- let entriesWithFilesDownloaded = 0;
998
- const downloader = createBokioDownloader(client2);
997
+ const entryDirs = new Map;
999
998
  for (const entry of allEntries) {
1000
999
  const fiscalYear = findFiscalYear(entry.date, fiscalYears);
1001
1000
  if (!fiscalYear)
1002
1001
  continue;
1003
1002
  const fyYear = parseInt(fiscalYear.startDate.slice(0, 4), 10);
1004
1003
  const entryDir = await writeJournalEntry(storage2, fyYear, entry);
1005
- if (options.downloadFiles !== false && entryDir) {
1004
+ entryDirs.set(entry.id, entryDir);
1005
+ }
1006
+ await writeFiscalYearsMetadata(storage2, fiscalYears);
1007
+ let entriesWithFilesDownloaded = 0;
1008
+ if (options.downloadFiles !== false) {
1009
+ const downloader = createBokioDownloader(client2);
1010
+ for (const entry of allEntries) {
1011
+ const entryDir = entryDirs.get(entry.id);
1012
+ if (!entryDir)
1013
+ continue;
1006
1014
  const filesDownloaded = await downloadFilesForEntry({
1007
1015
  storage: storage2,
1008
1016
  repoPath,
@@ -1016,7 +1024,6 @@ async function syncJournalEntries2(client2, repoPath, options, onProgress) {
1016
1024
  }
1017
1025
  }
1018
1026
  }
1019
- await writeFiscalYearsMetadata(storage2, fiscalYears);
1020
1027
  return {
1021
1028
  entriesCount: allEntries.length,
1022
1029
  fiscalYearsCount: fiscalYears.length,
@@ -1244,7 +1251,7 @@ async function createBookkeepingRepo(name, options = {}) {
1244
1251
  console.log(" Sync complete!");
1245
1252
  }
1246
1253
  const commitSpinner = ora("Creating initial commit...").start();
1247
- await commitAll(targetDir, "Initial sync from Bokio");
1254
+ await commitAll(targetDir, "Initial commit");
1248
1255
  commitSpinner.succeed("Initial commit created");
1249
1256
  console.log(`
1250
1257
  Success! Created ${folderName} at ${targetDir}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-kvitton",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "Create a new kvitton bookkeeping repository",
5
5
  "type": "module",
6
6
  "bin": {