@123ishatest/louter 0.2.1 → 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/LouterWarningType-CR_x5jAt.mjs +4 -0
- package/dist/LouterWarningType-D9owEyyk.js +1 -0
- package/dist/export/LouterVsCodeSettingsWriter.d.ts +9 -0
- package/dist/export/LouterVsCodeSettingsWriter.d.ts.map +1 -0
- package/dist/index.cjs.js +35 -35
- package/dist/index.es.js +165 -165
- package/dist/node.cjs.js +2 -1
- package/dist/node.d.ts +1 -0
- package/dist/node.d.ts.map +1 -1
- package/dist/node.es.js +68 -25
- package/dist/util/type.d.ts +6 -0
- package/dist/util/type.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/node.cjs.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("node:fs"),
|
|
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
|
package/dist/node.d.ts.map
CHANGED
|
@@ -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
|
|
2
|
-
import
|
|
3
|
-
|
|
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
|
|
10
|
-
t.files =
|
|
10
|
+
const s = this.getAllFiles(this._contentRoot);
|
|
11
|
+
t.files = s.map((e) => ({
|
|
11
12
|
path: e,
|
|
12
|
-
data:
|
|
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
|
|
20
|
-
for (const
|
|
21
|
-
const
|
|
22
|
-
|
|
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
|
|
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((
|
|
34
|
-
console.warn(
|
|
35
|
-
}),
|
|
36
|
-
const
|
|
37
|
-
|
|
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
|
|
41
|
+
class F {
|
|
41
42
|
_directory;
|
|
42
43
|
constructor(t = ".louter") {
|
|
43
44
|
this._directory = t;
|
|
44
45
|
}
|
|
45
46
|
run(t) {
|
|
46
|
-
|
|
47
|
-
for (const
|
|
48
|
-
const e = t.kinds[
|
|
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
|
-
}),
|
|
51
|
-
|
|
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
|
-
|
|
57
|
-
|
|
58
|
-
|
|
98
|
+
P as LouterContentWriter,
|
|
99
|
+
J as LouterFileLoader,
|
|
100
|
+
F as LouterJsonSchemaWriter,
|
|
101
|
+
w as LouterVsCodeSettingsWriter
|
|
59
102
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../src/util/type.ts"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEzE;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI;IAAE,SAAS,EAAE,MAAM,EAAE,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAU/F"}
|