@pattern-stack/codegen 0.9.2 → 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/src/index.js CHANGED
@@ -11,8 +11,30 @@ var __decorateClass = (decorators, target, key, kind) => {
11
11
  var __decorateParam = (index2, decorator) => (target, key) => decorator(target, key, index2);
12
12
 
13
13
  // src/parser/load-entities.ts
14
+ import { resolve as resolve2 } from "path";
15
+
16
+ // src/utils/find-yaml-files.ts
14
17
  import { readdirSync } from "fs";
15
18
  import { join, resolve } from "path";
19
+ function isYaml(name) {
20
+ return name.endsWith(".yaml") || name.endsWith(".yml");
21
+ }
22
+ function findYamlFiles(dir) {
23
+ const root = resolve(dir);
24
+ const out = [];
25
+ const walk = (current) => {
26
+ for (const entry of readdirSync(current, { withFileTypes: true })) {
27
+ if (entry.isDirectory()) {
28
+ if (entry.name.startsWith(".")) continue;
29
+ walk(join(current, entry.name));
30
+ } else if (isYaml(entry.name)) {
31
+ out.push(join(current, entry.name));
32
+ }
33
+ }
34
+ };
35
+ walk(root);
36
+ return out.sort();
37
+ }
16
38
 
17
39
  // src/utils/yaml-loader.ts
18
40
  import { readFileSync, existsSync } from "fs";
@@ -2136,10 +2158,10 @@ function loadErrorToIssue(error) {
2136
2158
  function loadEntities(entitiesDir) {
2137
2159
  const entities = [];
2138
2160
  const issues = [];
2139
- const resolvedDir = resolve(entitiesDir);
2161
+ const resolvedDir = resolve2(entitiesDir);
2140
2162
  let files;
2141
2163
  try {
2142
- files = readdirSync(resolvedDir).filter((f) => f.endsWith(".yaml") || f.endsWith(".yml")).map((f) => join(resolvedDir, f));
2164
+ files = findYamlFiles(resolvedDir);
2143
2165
  } catch (err) {
2144
2166
  issues.push({
2145
2167
  severity: "error",
@@ -2309,10 +2331,10 @@ function resolveTypeDirections(types) {
2309
2331
  function loadRelationships(relationshipsDir) {
2310
2332
  const relationships = [];
2311
2333
  const issues = [];
2312
- const resolvedDir = resolve(relationshipsDir);
2334
+ const resolvedDir = resolve2(relationshipsDir);
2313
2335
  let files;
2314
2336
  try {
2315
- files = readdirSync(resolvedDir).filter((f) => f.endsWith(".yaml") || f.endsWith(".yml")).map((f) => join(resolvedDir, f));
2337
+ files = findYamlFiles(resolvedDir);
2316
2338
  } catch {
2317
2339
  return { relationships, issues };
2318
2340
  }