@c9up/echo 0.2.2 → 0.2.3

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.
@@ -12,6 +12,12 @@ interface Codemods {
12
12
  writeFile(filePath: string, content: string, options?: {
13
13
  force?: boolean;
14
14
  }): Promise<void>;
15
+ makeUsingStub(stubsRoot: string, stubPath: string, state?: Record<string, string | number | boolean>, options?: {
16
+ force?: boolean;
17
+ }): Promise<{
18
+ path: string;
19
+ contents: string;
20
+ }>;
15
21
  }
16
22
  export declare function configure(codemods: Codemods): Promise<void>;
17
23
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"configure.d.ts","sourceRoot":"","sources":["../src/configure.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,UAAU,QAAQ;IACjB,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/C,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxD,SAAS,CACR,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,GAC3B,OAAO,CAAC,IAAI,CAAC,CAAC;CACjB;AAED,wBAAsB,SAAS,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CA8BjE"}
1
+ {"version":3,"file":"configure.d.ts","sourceRoot":"","sources":["../src/configure.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,UAAU,QAAQ;IACjB,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/C,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxD,SAAS,CACR,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,GAC3B,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,aAAa,CACZ,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,EACjD,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,GAC3B,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC/C;AAED,wBAAsB,SAAS,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAUjE"}
package/dist/configure.js CHANGED
@@ -6,6 +6,7 @@
6
6
  * application wants. Writing both together is what makes `ream add` mean
7
7
  * installed AND working.
8
8
  */
9
+ import { stubsRoot } from "./stubs.js";
9
10
  export async function configure(codemods) {
10
11
  // The config below reads these, so they are declared here. Writing the file
11
12
  // without them leaves an application whose config asks the environment for
@@ -14,23 +15,6 @@ export async function configure(codemods) {
14
15
  CACHE_STORE: "memory",
15
16
  });
16
17
  await codemods.addProvider("@c9up/echo/provider");
17
- await codemods.writeFile("config/cache.ts", `import { defineConfig, drivers, store } from '@c9up/echo'
18
- import env from '#start/env'
19
-
20
- export default defineConfig({
21
- default: env.get('CACHE_STORE', 'memory'),
22
-
23
- stores: {
24
- // One layer, in this process.
25
- memory: store().useL1Layer(drivers.memory({ maxItems: 1000 })),
26
-
27
- // Two layers: memory in front of Redis, with a bus so every instance
28
- // drops its own L1 entry when another writes.
29
- tiered: store()
30
- .useL1Layer(drivers.memory({ maxItems: 1000 }))
31
- .useL2Layer(drivers.redis({ connection: 'main' }))
32
- .useBus(drivers.redisBus({ connection: 'main' })),
33
- },
34
- })`);
18
+ await codemods.makeUsingStub(stubsRoot, "config/cache.stub");
35
19
  }
36
20
  //# sourceMappingURL=configure.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"configure.js","sourceRoot":"","sources":["../src/configure.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAYH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,QAAkB;IACjD,4EAA4E;IAC5E,2EAA2E;IAC3E,oCAAoC;IACpC,MAAM,QAAQ,CAAC,UAAU,CAAC;QACzB,WAAW,EAAE,QAAQ;KACrB,CAAC,CAAC;IAEH,MAAM,QAAQ,CAAC,WAAW,CAAC,qBAAqB,CAAC,CAAC;IAClD,MAAM,QAAQ,CAAC,SAAS,CACvB,iBAAiB,EACjB;;;;;;;;;;;;;;;;;GAiBC,CACD,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"configure.js","sourceRoot":"","sources":["../src/configure.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAkBvC,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,QAAkB;IACjD,4EAA4E;IAC5E,2EAA2E;IAC3E,oCAAoC;IACpC,MAAM,QAAQ,CAAC,UAAU,CAAC;QACzB,WAAW,EAAE,QAAQ;KACrB,CAAC,CAAC;IAEH,MAAM,QAAQ,CAAC,WAAW,CAAC,qBAAqB,CAAC,CAAC;IAClD,MAAM,QAAQ,CAAC,aAAa,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;AAC9D,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Where this package's stubs live.
3
+ *
4
+ * Its own module, as upstream keeps it: a stub root is a path a package
5
+ * publishes, and a caller importing it should not have to import the
6
+ * configure hook to get it.
7
+ *
8
+ * `import.meta.dirname` rather than a URL — upstream reads it straight off
9
+ * `import.meta`, and deriving it from `import.meta.url` breaks wherever that
10
+ * is not a `file://` URL, which is what a test runner serving modules over
11
+ * HTTP hands you.
12
+ */
13
+ export declare const stubsRoot: string;
14
+ //# sourceMappingURL=stubs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stubs.d.ts","sourceRoot":"","sources":["../src/stubs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,eAAO,MAAM,SAAS,QAA2C,CAAC"}
package/dist/stubs.js ADDED
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Where this package's stubs live.
3
+ *
4
+ * Its own module, as upstream keeps it: a stub root is a path a package
5
+ * publishes, and a caller importing it should not have to import the
6
+ * configure hook to get it.
7
+ *
8
+ * `import.meta.dirname` rather than a URL — upstream reads it straight off
9
+ * `import.meta`, and deriving it from `import.meta.url` breaks wherever that
10
+ * is not a `file://` URL, which is what a test runner serving modules over
11
+ * HTTP hands you.
12
+ */
13
+ import { join } from "node:path";
14
+ export const stubsRoot = join(import.meta.dirname, "..", "stubs");
15
+ //# sourceMappingURL=stubs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stubs.js","sourceRoot":"","sources":["../src/stubs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c9up/echo",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "Cache — pluggable cache contract with memory + Redis drivers for the Ream framework",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -30,12 +30,12 @@
30
30
  },
31
31
  "peerDependencies": {
32
32
  "@c9up/quasar": "^0.1.0 || ^0.2.0",
33
- "@c9up/ream": "^0.2.0"
33
+ "@c9up/ream": "^0.2.26"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@biomejs/biome": "^2.5.12",
37
37
  "@c9up/quasar": "^0.1.0 || ^0.2.0",
38
- "@c9up/ream": "^0.2.0",
38
+ "@c9up/ream": "^0.2.25",
39
39
  "@types/node": "^22.20.1",
40
40
  "@vitest/coverage-v8": "4.1.11",
41
41
  "typescript": "^6.0.3",
@@ -48,6 +48,7 @@
48
48
  "files": [
49
49
  "src",
50
50
  "dist",
51
+ "stubs",
51
52
  "README.md",
52
53
  "LICENSE"
53
54
  ],
package/src/configure.ts CHANGED
@@ -7,6 +7,8 @@
7
7
  * installed AND working.
8
8
  */
9
9
 
10
+ import { stubsRoot } from "./stubs.js";
11
+
10
12
  interface Codemods {
11
13
  addProvider(importPath: string): Promise<void>;
12
14
  addEnvVars(vars: Record<string, string>): Promise<void>;
@@ -15,6 +17,12 @@ interface Codemods {
15
17
  content: string,
16
18
  options?: { force?: boolean },
17
19
  ): Promise<void>;
20
+ makeUsingStub(
21
+ stubsRoot: string,
22
+ stubPath: string,
23
+ state?: Record<string, string | number | boolean>,
24
+ options?: { force?: boolean },
25
+ ): Promise<{ path: string; contents: string }>;
18
26
  }
19
27
 
20
28
  export async function configure(codemods: Codemods): Promise<void> {
@@ -26,25 +34,5 @@ export async function configure(codemods: Codemods): Promise<void> {
26
34
  });
27
35
 
28
36
  await codemods.addProvider("@c9up/echo/provider");
29
- await codemods.writeFile(
30
- "config/cache.ts",
31
- `import { defineConfig, drivers, store } from '@c9up/echo'
32
- import env from '#start/env'
33
-
34
- export default defineConfig({
35
- default: env.get('CACHE_STORE', 'memory'),
36
-
37
- stores: {
38
- // One layer, in this process.
39
- memory: store().useL1Layer(drivers.memory({ maxItems: 1000 })),
40
-
41
- // Two layers: memory in front of Redis, with a bus so every instance
42
- // drops its own L1 entry when another writes.
43
- tiered: store()
44
- .useL1Layer(drivers.memory({ maxItems: 1000 }))
45
- .useL2Layer(drivers.redis({ connection: 'main' }))
46
- .useBus(drivers.redisBus({ connection: 'main' })),
47
- },
48
- })`,
49
- );
37
+ await codemods.makeUsingStub(stubsRoot, "config/cache.stub");
50
38
  }
package/src/stubs.ts ADDED
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Where this package's stubs live.
3
+ *
4
+ * Its own module, as upstream keeps it: a stub root is a path a package
5
+ * publishes, and a caller importing it should not have to import the
6
+ * configure hook to get it.
7
+ *
8
+ * `import.meta.dirname` rather than a URL — upstream reads it straight off
9
+ * `import.meta`, and deriving it from `import.meta.url` breaks wherever that
10
+ * is not a `file://` URL, which is what a test runner serving modules over
11
+ * HTTP hands you.
12
+ */
13
+
14
+ import { join } from "node:path";
15
+
16
+ export const stubsRoot = join(import.meta.dirname, "..", "stubs");
@@ -0,0 +1,21 @@
1
+ ---
2
+ to: config/cache.ts
3
+ ---
4
+ import { defineConfig, drivers, store } from '@c9up/echo'
5
+ import env from '#start/env'
6
+
7
+ export default defineConfig({
8
+ default: env.get('CACHE_STORE', 'memory'),
9
+
10
+ stores: {
11
+ // One layer, in this process.
12
+ memory: store().useL1Layer(drivers.memory({ maxItems: 1000 })),
13
+
14
+ // Two layers: memory in front of Redis, with a bus so every instance
15
+ // drops its own L1 entry when another writes.
16
+ tiered: store()
17
+ .useL1Layer(drivers.memory({ maxItems: 1000 }))
18
+ .useL2Layer(drivers.redis({ connection: 'main' }))
19
+ .useBus(drivers.redisBus({ connection: 'main' })),
20
+ },
21
+ })