create-astrale-domain 0.2.11 → 0.2.12

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 +20 -2
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -857,6 +857,20 @@ function packageRoot(pkg) {
857
857
  entry.error === void 0 ? void 0 : { cause: entry.error }
858
858
  );
859
859
  }
860
+ function installedPackageRange(pkg) {
861
+ const manifestPath = join(packageRoot(pkg), "package.json");
862
+ const manifest = JSON.parse(readFileSync(manifestPath, "utf-8"));
863
+ if (typeof manifest.version !== "string") {
864
+ throw new Error(`Could not determine ${pkg}'s version from ${manifestPath}.`);
865
+ }
866
+ const match = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/.exec(
867
+ manifest.version
868
+ );
869
+ if (!match) {
870
+ throw new Error(`Could not derive a compatibility range for ${pkg}@${manifest.version}.`);
871
+ }
872
+ return `>=${manifest.version} <${Number(match[1]) + 1}.0.0`;
873
+ }
860
874
  function templateDir(pkg) {
861
875
  return join(packageRoot(pkg), "template");
862
876
  }
@@ -921,8 +935,12 @@ async function materializeAdapter(opts) {
921
935
  async function setAdapterDep(dir, from, to) {
922
936
  const path = join(dir, "package.json");
923
937
  const pkg = JSON.parse(await readFile(path, "utf-8"));
924
- if (!pkg.dependencies || !(from in pkg.dependencies)) return;
925
- const range = pkg.dependencies[from];
938
+ if (!pkg.dependencies || !(from in pkg.dependencies)) {
939
+ throw new Error(
940
+ `Could not materialize ${to}: the scaffold body does not declare its ${from} dependency.`
941
+ );
942
+ }
943
+ const range = installedPackageRange(to);
926
944
  delete pkg.dependencies[from];
927
945
  pkg.dependencies[to] = range;
928
946
  pkg.dependencies = Object.fromEntries(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-astrale-domain",
3
- "version": "0.2.11",
3
+ "version": "0.2.12",
4
4
  "description": "Scaffold a standalone Astrale domain — npm create astrale-domain",
5
5
  "keywords": [
6
6
  "astrale",
@@ -19,8 +19,8 @@
19
19
  "type": "module",
20
20
  "dependencies": {
21
21
  "@clack/prompts": "^0.11.0",
22
- "@astrale-os/adapter-astrale": "^0.4.1",
23
- "@astrale-os/adapter-cloudflare": "^0.4.9"
22
+ "@astrale-os/adapter-cloudflare": "^0.4.9",
23
+ "@astrale-os/adapter-astrale": "^0.4.1"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@astrale-os/ox": ">=0.1.0 <1.0.0",