create-kvitton 0.4.0 → 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 +15 -6
  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,
@@ -1074,7 +1081,9 @@ async function syncChartOfAccounts(client2, repoPath) {
1074
1081
  var __filename2 = fileURLToPath(import.meta.url);
1075
1082
  var __dirname2 = path5.dirname(__filename2);
1076
1083
  async function createAgentsFile(targetDir, options) {
1077
- const templatePath = path5.join(__dirname2, "../templates/AGENTS.md");
1084
+ const bundledPath = path5.join(__dirname2, "templates/AGENTS.md");
1085
+ const devPath = path5.join(__dirname2, "../templates/AGENTS.md");
1086
+ const templatePath = await fs5.access(bundledPath).then(() => bundledPath).catch(() => devPath);
1078
1087
  let template = await fs5.readFile(templatePath, "utf-8");
1079
1088
  template = template.replace(/\{\{COMPANY_NAME\}\}/g, options.companyName);
1080
1089
  template = template.replace(/\{\{PROVIDER\}\}/g, options.provider);
@@ -1242,7 +1251,7 @@ async function createBookkeepingRepo(name, options = {}) {
1242
1251
  console.log(" Sync complete!");
1243
1252
  }
1244
1253
  const commitSpinner = ora("Creating initial commit...").start();
1245
- await commitAll(targetDir, "Initial sync from Bokio");
1254
+ await commitAll(targetDir, "Initial commit");
1246
1255
  commitSpinner.succeed("Initial commit created");
1247
1256
  console.log(`
1248
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.0",
3
+ "version": "0.4.2",
4
4
  "description": "Create a new kvitton bookkeeping repository",
5
5
  "type": "module",
6
6
  "bin": {