create-eigen-game 0.13.0 → 0.13.1

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.
@@ -7,8 +7,10 @@
7
7
  * is not tested. `src/index.ts` uses it; the package `exports` map does not
8
8
  * expose it, so it is internal despite being importable by the tests.
9
9
  */
10
+
10
11
  /** The dependency whose version the scaffolder emits into the generated server. */
11
- export declare const ENGINE_PACKAGE = "@eigeninteractive/server";
12
+ export const ENGINE_PACKAGE = "@eigeninteractive/server";
13
+
12
14
  /**
13
15
  * The engine range for a scaffolded project, from this package's own
14
16
  * `@eigeninteractive/server` devDependency.
@@ -36,4 +38,23 @@ export declare const ENGINE_PACKAGE = "@eigeninteractive/server";
36
38
  * @param declared the raw `@eigeninteractive/server` devDependency value
37
39
  * @param readSiblingVersion consulted only for the `workspace:` protocol
38
40
  */
39
- export declare function engineRange(declared: string | undefined, readSiblingVersion: () => string | undefined): string;
41
+ export function engineRange(declared: string | undefined, readSiblingVersion: () => string | undefined): string {
42
+ if (!declared) {
43
+ throw new Error(`create-eigen-game has no ${ENGINE_PACKAGE} devDependency, which is where the engine range it emits comes from`);
44
+ }
45
+
46
+ const version = declared.startsWith("workspace:") ? readSiblingVersion() : declared;
47
+
48
+ if (!version) {
49
+ throw new Error(`create-eigen-game declares ${ENGINE_PACKAGE} as "${declared}" but the workspace package could not be read, so there is no engine version to emit`);
50
+ }
51
+
52
+ // pnpm packs `workspace:*` as a bare version, which is what makes the caret
53
+ // below correct. Asserting it means a change in that behaviour fails here
54
+ // rather than emitting something like `^^0.3.0` into a real project.
55
+ if (!/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/.test(version)) {
56
+ throw new Error(`expected an exact ${ENGINE_PACKAGE} version to build a range from, got "${version}"`);
57
+ }
58
+
59
+ return `^${version}`;
60
+ }