@123ishatest/louter 0.3.0 → 0.3.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.
package/dist/node.cjs.js CHANGED
@@ -1 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("node:fs"),n=require("node:path");class l{_contentRoot;constructor(t){this._contentRoot=t}run(t){const r=this.getAllFiles(this._contentRoot);t.files=r.map(e=>({path:e,data:o.readFileSync(e,"utf-8")}))}getAllFiles(t){const r=o.readdirSync(t,{withFileTypes:!0}),e=[];for(const i of r){const c=n.join(t,i.name);i.isDirectory()&&e.push(...this.getAllFiles(c)),i.isFile()&&e.push(c)}return e}}class u{_directory;constructor(t=".louter"){this._directory=t}run(t){t.warnings.forEach(i=>{console.warn(i.path,i.message)}),o.mkdirSync(this._directory,{recursive:!0});const r=t.content,e=n.join(this._directory,"content.generated.json");o.writeFileSync(e,JSON.stringify(r,null,2))}}class a{_directory;constructor(t=".louter"){this._directory=t}run(t){o.mkdirSync(this._directory,{recursive:!0});for(const r in t.kinds){const e=t.kinds[r].toJSONSchema({io:"input"}),i=n.join(this._directory,`${r}.schema.json`);o.writeFileSync(i,JSON.stringify(e,null,2))}}}exports.LouterContentWriter=u;exports.LouterFileLoader=l;exports.LouterJsonSchemaWriter=a;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("node:fs"),a=require("node:path"),d=require("./LouterWarningType-D9owEyyk.js");class f{_contentRoot;constructor(t){this._contentRoot=t}run(t){const e=this.getAllFiles(this._contentRoot);t.files=e.map(s=>({path:s,data:o.readFileSync(s,"utf-8")}))}getAllFiles(t){const e=o.readdirSync(t,{withFileTypes:!0}),s=[];for(const n of e){const c=a.join(t,n.name);n.isDirectory()&&s.push(...this.getAllFiles(c)),n.isFile()&&s.push(c)}return s}}class g{_directory;constructor(t=".louter"){this._directory=t}run(t){t.warnings.forEach(n=>{console.warn(n.path,n.message)}),o.mkdirSync(this._directory,{recursive:!0});const e=t.content,s=a.join(this._directory,"content.generated.json");o.writeFileSync(s,JSON.stringify(e,null,2))}}class S{_directory;constructor(t=".louter"){this._directory=t}run(t){o.mkdirSync(this._directory,{recursive:!0});for(const e in t.kinds){const s=t.kinds[e].toJSONSchema({io:"input"}),n=a.join(this._directory,`${e}.schema.json`);o.writeFileSync(n,JSON.stringify(s,null,2))}}}function l(r){return r!==null&&typeof r=="object"&&!Array.isArray(r)}function p(r){return l(r)?typeof r.url=="string"&&Array.isArray(r.fileMatch)&&r.fileMatch.every(t=>typeof t=="string"):!1}class _{_settingsPath;constructor(t=".vscode/settings.json"){this._settingsPath=t}run(t){let e={};try{e=JSON.parse(o.readFileSync(this._settingsPath,"utf-8"))}catch{t.warnings.push({type:d.LouterWarningType.InvalidJson,path:this._settingsPath,message:`Could not read or parse ${this._settingsPath}. A new settings file will be created.`})}const s={},n=[];Object.keys(t.kinds).forEach(i=>{s[`.generated/${i}.schema.json`]=[`**/*.${i}.y[a]ml`],n.push({fileMatch:[`**/*.${i}.json`],url:`.generated/${i}.schema.json`})});const c=l(e["yaml.schemas"])?e["yaml.schemas"]:{};e["yaml.schemas"]={...c,...s};const h=Array.isArray(e["json.schemas"])?e["json.schemas"].filter(p):[],u=new Map(n.map(i=>[i.url,i])),y=h.filter(i=>!u.has(i.url));e["json.schemas"]=[...y,...n];const m=a.dirname(this._settingsPath);o.mkdirSync(m,{recursive:!0}),o.writeFileSync(this._settingsPath,`${JSON.stringify(e,null,2)}
2
+ `,"utf-8")}}exports.LouterContentWriter=g;exports.LouterFileLoader=f;exports.LouterJsonSchemaWriter=S;exports.LouterVsCodeSettingsWriter=_;
package/dist/node.d.ts CHANGED
@@ -7,4 +7,5 @@ export { LouterFileLoader } from './loader/LouterFileLoader';
7
7
  */
8
8
  export { LouterContentWriter } from './export/LouterContentWriter';
9
9
  export { LouterJsonSchemaWriter } from './export/LouterJsonSchemaWriter';
10
+ export { LouterVsCodeSettingsWriter } from './export/LouterVsCodeSettingsWriter';
10
11
  //# sourceMappingURL=node.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAEnE;;GAEG;AACH,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC"}
1
+ {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAEnE;;GAEG;AACH,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EAAE,0BAA0B,EAAE,MAAM,2CAA2C,CAAC"}
package/dist/node.es.js CHANGED
@@ -1,59 +1,102 @@
1
- import { readFileSync as u, readdirSync as a, mkdirSync as c, writeFileSync as l } from "node:fs";
2
- import i from "node:path";
3
- class f {
1
+ import { readFileSync as l, readdirSync as d, mkdirSync as a, writeFileSync as h } from "node:fs";
2
+ import c from "node:path";
3
+ import { L as p } from "./LouterWarningType-CR_x5jAt.mjs";
4
+ class J {
4
5
  _contentRoot;
5
6
  constructor(t) {
6
7
  this._contentRoot = t;
7
8
  }
8
9
  run(t) {
9
- const r = this.getAllFiles(this._contentRoot);
10
- t.files = r.map((e) => ({
10
+ const s = this.getAllFiles(this._contentRoot);
11
+ t.files = s.map((e) => ({
11
12
  path: e,
12
- data: u(e, "utf-8")
13
+ data: l(e, "utf-8")
13
14
  }));
14
15
  }
15
16
  /**
16
17
  * Recursively read all files
17
18
  */
18
19
  getAllFiles(t) {
19
- const r = a(t, { withFileTypes: !0 }), e = [];
20
- for (const o of r) {
21
- const s = i.join(t, o.name);
22
- o.isDirectory() && e.push(...this.getAllFiles(s)), o.isFile() && e.push(s);
20
+ const s = d(t, { withFileTypes: !0 }), e = [];
21
+ for (const n of s) {
22
+ const o = c.join(t, n.name);
23
+ n.isDirectory() && e.push(...this.getAllFiles(o)), n.isFile() && e.push(o);
23
24
  }
24
25
  return e;
25
26
  }
26
27
  }
27
- class y {
28
+ class P {
28
29
  _directory;
29
30
  constructor(t = ".louter") {
30
31
  this._directory = t;
31
32
  }
32
33
  run(t) {
33
- t.warnings.forEach((o) => {
34
- console.warn(o.path, o.message);
35
- }), c(this._directory, { recursive: !0 });
36
- const r = t.content, e = i.join(this._directory, "content.generated.json");
37
- l(e, JSON.stringify(r, null, 2));
34
+ t.warnings.forEach((n) => {
35
+ console.warn(n.path, n.message);
36
+ }), a(this._directory, { recursive: !0 });
37
+ const s = t.content, e = c.join(this._directory, "content.generated.json");
38
+ h(e, JSON.stringify(s, null, 2));
38
39
  }
39
40
  }
40
- class m {
41
+ class F {
41
42
  _directory;
42
43
  constructor(t = ".louter") {
43
44
  this._directory = t;
44
45
  }
45
46
  run(t) {
46
- c(this._directory, { recursive: !0 });
47
- for (const r in t.kinds) {
48
- const e = t.kinds[r].toJSONSchema({
47
+ a(this._directory, { recursive: !0 });
48
+ for (const s in t.kinds) {
49
+ const e = t.kinds[s].toJSONSchema({
49
50
  io: "input"
50
- }), o = i.join(this._directory, `${r}.schema.json`);
51
- l(o, JSON.stringify(e, null, 2));
51
+ }), n = c.join(this._directory, `${s}.schema.json`);
52
+ h(n, JSON.stringify(e, null, 2));
52
53
  }
53
54
  }
54
55
  }
56
+ function u(r) {
57
+ return r !== null && typeof r == "object" && !Array.isArray(r);
58
+ }
59
+ function S(r) {
60
+ return u(r) ? typeof r.url == "string" && Array.isArray(r.fileMatch) && r.fileMatch.every((t) => typeof t == "string") : !1;
61
+ }
62
+ class w {
63
+ _settingsPath;
64
+ constructor(t = ".vscode/settings.json") {
65
+ this._settingsPath = t;
66
+ }
67
+ run(t) {
68
+ let s = {};
69
+ try {
70
+ s = JSON.parse(l(this._settingsPath, "utf-8"));
71
+ } catch {
72
+ t.warnings.push({
73
+ type: p.InvalidJson,
74
+ path: this._settingsPath,
75
+ message: `Could not read or parse ${this._settingsPath}. A new settings file will be created.`
76
+ });
77
+ }
78
+ const e = {}, n = [];
79
+ Object.keys(t.kinds).forEach((i) => {
80
+ e[`.generated/${i}.schema.json`] = [`**/*.${i}.y[a]ml`], n.push({
81
+ fileMatch: [`**/*.${i}.json`],
82
+ url: `.generated/${i}.schema.json`
83
+ });
84
+ });
85
+ const o = u(s["yaml.schemas"]) ? s["yaml.schemas"] : {};
86
+ s["yaml.schemas"] = {
87
+ ...o,
88
+ ...e
89
+ };
90
+ const m = Array.isArray(s["json.schemas"]) ? s["json.schemas"].filter(S) : [], y = new Map(n.map((i) => [i.url, i])), f = m.filter((i) => !y.has(i.url));
91
+ s["json.schemas"] = [...f, ...n];
92
+ const g = c.dirname(this._settingsPath);
93
+ a(g, { recursive: !0 }), h(this._settingsPath, `${JSON.stringify(s, null, 2)}
94
+ `, "utf-8");
95
+ }
96
+ }
55
97
  export {
56
- y as LouterContentWriter,
57
- f as LouterFileLoader,
58
- m as LouterJsonSchemaWriter
98
+ P as LouterContentWriter,
99
+ J as LouterFileLoader,
100
+ F as LouterJsonSchemaWriter,
101
+ w as LouterVsCodeSettingsWriter
59
102
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@123ishatest/louter",
3
3
  "private": false,
4
- "version": "0.3.0",
4
+ "version": "0.3.1",
5
5
  "publishConfig": {
6
6
  "access": "public",
7
7
  "provenance": true