vela 0.9.1 → 0.10.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.
package/dist/bin.js CHANGED
@@ -7,7 +7,7 @@ import { fileURLToPath as fileURLToPath2 } from "node:url";
7
7
  // package.json
8
8
  var package_default = {
9
9
  name: "vela",
10
- version: "0.9.1",
10
+ version: "0.10.0",
11
11
  type: "module",
12
12
  description: "A CLI for creating and updating SvelteKit projects",
13
13
  license: "MIT",
@@ -41,8 +41,8 @@ var package_default = {
41
41
  dependencies: {
42
42
  "@clack/prompts": "^1.7.0",
43
43
  "@faker-js/faker": "^10.6.0",
44
- "@velastack/patterns": "^0.0.61",
45
- "@velastack/pocketbase": "^0.1.0",
44
+ "@velastack/patterns": "^0.1.0",
45
+ "@velastack/pocketbase-codegen": "^0.1.0",
46
46
  "annotate-json-schema": "^0.1.0",
47
47
  commander: "^13.1.0",
48
48
  "cross-spawn": "^7.0.6",
@@ -1692,6 +1692,17 @@ async function runPattern(slug, argv, input, report) {
1692
1692
  root: workspaceRootDir,
1693
1693
  features,
1694
1694
  input,
1695
+ // Patterns no longer read the schema themselves: @velastack/pocketbase-codegen
1696
+ // takes an injected client, and only the CLI knows how to reach (or spawn)
1697
+ // a PocketBase for this workspace.
1698
+ getCollections: async () => {
1699
+ const { getCollections } = await import("@velastack/pocketbase-codegen");
1700
+ let collections2 = [];
1701
+ await withPocketbase(workspaceRootDir, async (pb) => {
1702
+ collections2 = await getCollections(pb);
1703
+ });
1704
+ return collections2;
1705
+ },
1695
1706
  logger: { info: (message) => log18.message(message) }
1696
1707
  });
1697
1708
  log18.success(report.task.success);
@@ -4892,7 +4903,7 @@ import * as p22 from "@clack/prompts";
4892
4903
  import { annotate } from "annotate-json-schema";
4893
4904
  import { createGenerator } from "json-schema-faker";
4894
4905
  import { faker } from "@faker-js/faker";
4895
- import { collectionToJsonSchema } from "@velastack/pocketbase/internal";
4906
+ import { collectionToJsonSchema } from "@velastack/pocketbase-codegen";
4896
4907
  var SKIP_TYPES = /* @__PURE__ */ new Set(["autodate", "file", "relation"]);
4897
4908
  var AUTH_OVERRIDE_FIELDS = ["email", "password", "passwordConfirm", "tokenKey"];
4898
4909
  function padZeros(num, length) {
@@ -5649,7 +5660,7 @@ var dev = new Command65("dev").description("start the development server").confi
5649
5660
  process17.env.POCKETBASE_SUPERUSER_PASSWORD
5650
5661
  );
5651
5662
  await pb.settings.update({ meta: { appURL: `http://${viteHost}:${vitePort}` } });
5652
- await startWatchingTypes(cwd);
5663
+ await startWatchingTypes(cwd, pb);
5653
5664
  });
5654
5665
  await server.listen();
5655
5666
  const hasExistingLogs = process17.stdout.bytesWritten > 0 || process17.stderr.bytesWritten > 0;
@@ -5665,25 +5676,25 @@ var dev = new Command65("dev").description("start the development server").confi
5665
5676
  server.printUrls();
5666
5677
  server.bindCLIShortcuts({ print: true });
5667
5678
  });
5668
- async function startWatchingTypes(cwd) {
5669
- const { processTypes } = await import("@velastack/pocketbase/internal");
5670
- const config = {
5671
- pocketbaseUrl: process17.env.POCKETBASE_URL,
5672
- superuserEmail: process17.env.POCKETBASE_SUPERUSER_EMAIL,
5673
- superuserPassword: process17.env.POCKETBASE_SUPERUSER_PASSWORD
5674
- };
5679
+ async function startWatchingTypes(cwd, pb) {
5680
+ const { processTypes } = await import("@velastack/pocketbase-codegen");
5675
5681
  const typesDir = path29.resolve(cwd, ".svelte-kit", "types");
5676
5682
  const pocketbaseDir = path29.join(typesDir, "pocketbase");
5677
5683
  const pocketbaseTypes = path29.join(pocketbaseDir, "$types.d.ts");
5678
- await processTypes(config, typesDir);
5679
- const watcher = fs27.promises.watch(pocketbaseDir);
5680
- (async () => {
5681
- for await (const event of watcher) {
5682
- if (event.eventType === "rename" && event.filename === "$types.d.ts" && !fs27.existsSync(pocketbaseTypes)) {
5683
- setTimeout(() => {
5684
- processTypes(config, typesDir).catch(() => {
5685
- });
5686
- }, 100);
5684
+ const regenerate = () => processTypes(pb, typesDir).catch(() => {
5685
+ });
5686
+ await regenerate();
5687
+ void (async () => {
5688
+ for (; ; ) {
5689
+ try {
5690
+ await fs27.promises.mkdir(pocketbaseDir, { recursive: true });
5691
+ for await (const event of fs27.promises.watch(pocketbaseDir)) {
5692
+ if (event.eventType === "rename" && event.filename === "$types.d.ts" && !fs27.existsSync(pocketbaseTypes)) {
5693
+ setTimeout(regenerate, 100);
5694
+ }
5695
+ }
5696
+ } catch {
5697
+ await new Promise((r) => setTimeout(r, 200));
5687
5698
  }
5688
5699
  }
5689
5700
  })();
@@ -5785,15 +5796,10 @@ var sync = new Command68("sync").description("sync types from the database").con
5785
5796
  () => runCommand(async () => {
5786
5797
  const { workspaceRootDir } = await getWorkspace();
5787
5798
  const typesDir = path32.join(workspaceRootDir, ".svelte-kit", "types");
5788
- const { processTypes } = await import("@velastack/pocketbase/internal");
5789
- await processTypes(
5790
- {
5791
- pocketbaseUrl: process.env.POCKETBASE_URL ?? "",
5792
- superuserEmail: process.env.POCKETBASE_SUPERUSER_EMAIL,
5793
- superuserPassword: process.env.POCKETBASE_SUPERUSER_PASSWORD
5794
- },
5795
- typesDir
5796
- );
5799
+ const { processTypes } = await import("@velastack/pocketbase-codegen");
5800
+ await withPocketbase(workspaceRootDir, async (pb) => {
5801
+ await processTypes(pb, typesDir);
5802
+ });
5797
5803
  console.log("types synced");
5798
5804
  }, "Failed to sync types.")
5799
5805
  );