@codeandmoney/jargal 0.0.0-rc.0 → 0.0.0-rc.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.
@@ -3,20 +3,22 @@ import { readdir, readFile } from "node:fs/promises";
3
3
  import path from "node:path";
4
4
 
5
5
  export function loadTemplates(templatesPath: string, scope?: string): ContextAction {
6
- return async function execute() {
7
- const templates: Map<string, { fullPath: string; realativePath: string; content: string }> = new Map();
6
+ return async function execute(params) {
7
+ const record = { ...params.context.templates } as Record<string, Map<string, { fullPath: string; realativePath: string; content: string }>>;
8
+
9
+ if (scope) {
10
+ Object.assign(record, { [scope]: new Map() });
11
+ }
8
12
 
9
13
  for await (const fullPath of walkDir(templatesPath)) {
10
14
  const realativePath = path.relative(templatesPath, fullPath);
11
15
 
12
16
  const contentRaw = await readFile(path.resolve(templatesPath, fullPath));
13
17
 
14
- const key = scope ? `${scope}::${realativePath}` : realativePath;
15
-
16
- templates.set(key, { content: new TextDecoder().decode(contentRaw), fullPath, realativePath });
18
+ record[scope ? scope : "templates"]?.set(realativePath, { content: new TextDecoder().decode(contentRaw), fullPath, realativePath });
17
19
  }
18
20
 
19
- return { templates };
21
+ return record;
20
22
  };
21
23
  }
22
24
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codeandmoney/jargal",
3
- "version": "0.0.0-rc.0",
3
+ "version": "0.0.0-rc.1",
4
4
  "description": "Renderer",
5
5
  "license": "MIT",
6
6
  "author": "Code & Money Team",
package/types.ts CHANGED
@@ -7,6 +7,7 @@ export interface Config {
7
7
  export interface Context extends Record<string, unknown> {
8
8
  answers: Record<string, string | boolean | (string | boolean)[]>;
9
9
  errors: Error[];
10
+ context: Record<string, any>;
10
11
  }
11
12
 
12
13
  export type DeepReadonly<T> = {