@dimm-city/print-md 0.5.0-rc.8 → 0.5.0

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/cli.js +67 -17
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -22703,7 +22703,7 @@ var package_default;
22703
22703
  var init_package = __esm(() => {
22704
22704
  package_default = {
22705
22705
  name: "@dimm-city/print-md-lib",
22706
- version: "0.5.0-rc.8",
22706
+ version: "0.5.0",
22707
22707
  private: true,
22708
22708
  type: "module",
22709
22709
  main: "dist/index.js",
@@ -107756,6 +107756,7 @@ __export(exports_source_provider, {
107756
107756
  snapshotWorkingTreeUnlocked: () => snapshotWorkingTreeUnlocked,
107757
107757
  restoreVersionWithBackup: () => restoreVersionWithBackup,
107758
107758
  providerFor: () => providerFor,
107759
+ listWorkdirChanges: () => listWorkdirChanges,
107759
107760
  isNoChangesError: () => isNoChangesError,
107760
107761
  isGitInternalPath: () => isGitInternalPath,
107761
107762
  hasPendingChanges: () => hasPendingChanges,
@@ -107788,23 +107789,65 @@ function gitAuthor(name) {
107788
107789
  const n = (name ?? "").trim();
107789
107790
  return { name: n || DEFAULT_AUTHOR, email: DEFAULT_EMAIL };
107790
107791
  }
107791
- async function stageAll(dir, subPath, cache2) {
107792
- const status = await import_isomorphic_git.default.statusMatrix({
107792
+ function worthWalking(filepath, root2) {
107793
+ if (filepath === "." || root2 == null || root2.length === 0 || root2 === ".") {
107794
+ return true;
107795
+ }
107796
+ if (root2.length >= filepath.length)
107797
+ return root2.startsWith(filepath);
107798
+ return filepath.startsWith(root2);
107799
+ }
107800
+ async function listWorkdirChanges(dir, subPath, cache2 = {}) {
107801
+ const adds = [];
107802
+ const removes = [];
107803
+ await import_isomorphic_git.default.walk({
107793
107804
  fs: fs5,
107794
107805
  dir,
107795
107806
  cache: cache2,
107796
- ...subPath ? { filepaths: [subPath] } : {}
107807
+ trees: [import_isomorphic_git.default.WORKDIR(), import_isomorphic_git.default.STAGE()],
107808
+ map: async (filepath, [workdir, stage]) => {
107809
+ if (filepath === ".")
107810
+ return;
107811
+ if (subPath && !worthWalking(filepath, subPath))
107812
+ return null;
107813
+ if (!stage && workdir && await import_isomorphic_git.default.isIgnored({ fs: fs5, dir, filepath })) {
107814
+ return null;
107815
+ }
107816
+ const [wType, sType] = await Promise.all([
107817
+ workdir ? workdir.type() : Promise.resolve(undefined),
107818
+ stage ? stage.type() : Promise.resolve(undefined)
107819
+ ]);
107820
+ if (wType === "tree" || sType === "tree") {
107821
+ if (sType === "blob")
107822
+ removes.push(filepath);
107823
+ else if (wType === "blob")
107824
+ adds.push(filepath);
107825
+ return;
107826
+ }
107827
+ if (wType === "blob" && !sType) {
107828
+ adds.push(filepath);
107829
+ } else if (!wType && sType === "blob") {
107830
+ removes.push(filepath);
107831
+ } else if (wType === "blob" && sType === "blob") {
107832
+ if (await workdir.oid() !== await stage.oid())
107833
+ adds.push(filepath);
107834
+ }
107835
+ return;
107836
+ }
107797
107837
  });
107798
- await Promise.all(status.map(([filepath, , worktreeStatus]) => worktreeStatus === 0 ? import_isomorphic_git.default.remove({ fs: fs5, dir, filepath, cache: cache2 }) : import_isomorphic_git.default.add({ fs: fs5, dir, filepath, cache: cache2 })));
107838
+ return { adds, removes };
107839
+ }
107840
+ async function stageChanges(dir, changes, cache2) {
107841
+ if (changes.adds.length > 0) {
107842
+ await import_isomorphic_git.default.add({ fs: fs5, dir, cache: cache2, filepath: changes.adds });
107843
+ }
107844
+ for (const filepath of changes.removes) {
107845
+ await import_isomorphic_git.default.remove({ fs: fs5, dir, cache: cache2, filepath });
107846
+ }
107799
107847
  }
107800
107848
  async function hasPendingChanges(dir, subPath, cache2 = {}) {
107801
- const status = await import_isomorphic_git.default.statusMatrix({
107802
- fs: fs5,
107803
- dir,
107804
- cache: cache2,
107805
- ...subPath ? { filepaths: [subPath] } : {}
107806
- });
107807
- return status.some(([, head, worktree, stage]) => !(head === 1 && worktree === 1 && stage === 1));
107849
+ const { adds, removes } = await listWorkdirChanges(dir, subPath, cache2);
107850
+ return adds.length > 0 || removes.length > 0;
107808
107851
  }
107809
107852
 
107810
107853
  class LocalFolderSourceProvider {
@@ -107822,7 +107865,7 @@ class LocalFolderSourceProvider {
107822
107865
  return withRepoLock(dir, async () => {
107823
107866
  const cache2 = {};
107824
107867
  await import_isomorphic_git.default.init({ fs: fs5, dir, defaultBranch: DEFAULT_BRANCH });
107825
- await stageAll(dir, undefined, cache2);
107868
+ await stageChanges(dir, await listWorkdirChanges(dir, undefined, cache2), cache2);
107826
107869
  await import_isomorphic_git.default.commit({
107827
107870
  fs: fs5,
107828
107871
  dir,
@@ -107909,7 +107952,13 @@ class LocalGitSourceProvider {
107909
107952
  }
107910
107953
  throw e;
107911
107954
  }
107912
- let filtered = before ? commits.filter((c) => c.oid !== before) : commits;
107955
+ const seen = new Set;
107956
+ let filtered = commits.filter((c) => {
107957
+ if (c.oid === before || seen.has(c.oid))
107958
+ return false;
107959
+ seen.add(c.oid);
107960
+ return true;
107961
+ });
107913
107962
  const hasMore = filtered.length > limit;
107914
107963
  if (hasMore)
107915
107964
  filtered = filtered.slice(0, limit);
@@ -107943,10 +107992,11 @@ async function snapshotWorkingTreeUnlocked(options) {
107943
107992
  const dir = options.repoRoot ?? options.projectDir;
107944
107993
  const subPath = options.subPath || undefined;
107945
107994
  const cache2 = {};
107946
- if (!await hasPendingChanges(dir, subPath, cache2)) {
107995
+ const changes = await listWorkdirChanges(dir, subPath, cache2);
107996
+ if (changes.adds.length === 0 && changes.removes.length === 0) {
107947
107997
  throw new Error("No changes since the last snapshot — there is nothing new to save.");
107948
107998
  }
107949
- await stageAll(dir, subPath, cache2);
107999
+ await stageChanges(dir, changes, cache2);
107950
108000
  const author = gitAuthor(options.authorName);
107951
108001
  const id2 = await import_isomorphic_git.default.commit({
107952
108002
  fs: fs5,
@@ -108928,7 +108978,7 @@ var SUBCOMMANDS = {
108928
108978
  audit: () => Promise.resolve().then(() => (init_audit(), exports_audit)).then((m) => m.default),
108929
108979
  preflight: () => Promise.resolve().then(() => (init_preflight(), exports_preflight)).then((m) => m.default)
108930
108980
  };
108931
- var VERSION = "0.5.0-rc.8";
108981
+ var VERSION = "0.5.0";
108932
108982
  var main = defineCommand8({
108933
108983
  meta: {
108934
108984
  name: "print-md",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dimm-city/print-md",
3
- "version": "0.5.0-rc.8",
3
+ "version": "0.5.0",
4
4
  "description": "Markdown-to-PDF converter for professional print layout using Paged.js and Ghostscript.",
5
5
  "author": "itlackey",
6
6
  "license": "MPL-2.0",