@realiizlabs/admin 0.15.9 → 0.16.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.
@@ -416,6 +416,10 @@ function makeReaders(config, registry, pending) {
416
416
  const entries = await listDirectory(repo(), e.folder);
417
417
  return entries.find((x) => registry.slugOf(e, x.name) === slug)?.path ?? null;
418
418
  };
419
+ const listSlugs = async (typeId) => {
420
+ const items = await listItems(typeId);
421
+ return items.filter((i) => !i.isNew).map((i) => i.slug).sort();
422
+ };
419
423
  const listItems = async (typeId) => {
420
424
  const e = need(typeId);
421
425
  const ctx = repo();
@@ -491,7 +495,7 @@ function makeReaders(config, registry, pending) {
491
495
  }
492
496
  };
493
497
  const prStatus = (number) => getPullRequestStatus(repo(), number);
494
- return { pathOf, listItems, countItems, readItem, lastAuthor, getPullRequest: getPullRequest2, prStatus };
498
+ return { pathOf, listItems, listSlugs, countItems, readItem, lastAuthor, getPullRequest: getPullRequest2, prStatus };
495
499
  }
496
500
 
497
501
  // src/git/branch.ts
@@ -613,18 +617,22 @@ ${input.body.trim()}
613
617
  if (!pictures.ok) return { ok: false, error: pictures.error };
614
618
  const files = [{ path, content }, ...pictures.files];
615
619
  const repo = config.env().repo;
620
+ const oldPath = input.replaces ? await readers.pathOf(entry.id, input.replaces).catch(() => null) : null;
621
+ const remove = oldPath && oldPath !== path ? [oldPath] : [];
622
+ const renamed = remove.length ? `
623
+ Renamed from \`${oldPath}\` to \`${path}\`` : "";
616
624
  if (input.existing && await stillOpen(input.existing.number)) {
617
- await writeFiles(repo, input.existing.branch, files, `Update: ${title}`);
625
+ await writeFiles(repo, input.existing.branch, files, `Update: ${title}`, { remove });
618
626
  navigation.redirect(`/admin/pr/${input.existing.number}`);
619
627
  }
620
628
  const branch = `admin/${entry.id}/${fileName.replace(/\.mdx$/, "")}-${stamp()}`;
621
629
  await createBranch(repo, branch);
622
- await writeFiles(repo, branch, files, `Publish: ${title}`);
630
+ await writeFiles(repo, branch, files, `Publish: ${title}`, { remove });
623
631
  const pr = await openPullRequest(repo, branch, {
624
632
  title: `Publish: ${title}`,
625
633
  body: `Published from the dashboard by ${user.email ?? user.id}.
626
634
 
627
- File: \`${path}\``
635
+ File: \`${path}\`${renamed}`
628
636
  });
629
637
  navigation.redirect(`/admin/pr/${pr.number}`);
630
638
  };
@@ -1115,7 +1123,7 @@ function makeHandlers(ctx) {
1115
1123
  }
1116
1124
 
1117
1125
  // src/version.ts
1118
- var ADMIN_VERSION = "0.15.9" ;
1126
+ var ADMIN_VERSION = "0.16.0" ;
1119
1127
 
1120
1128
  // src/studio/update.ts
1121
1129
  var PACKAGE_NAME = "@realiizlabs/admin";