@lindorm/typewriter 0.1.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/CHANGELOG.md +10 -0
- package/README.md +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +55 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +18 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/types.d.ts +2 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/types.js +3 -0
- package/dist/types/types.js.map +1 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +18 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/private/absolute-path.d.ts +2 -0
- package/dist/utils/private/absolute-path.d.ts.map +1 -0
- package/dist/utils/private/absolute-path.js +21 -0
- package/dist/utils/private/absolute-path.js.map +1 -0
- package/dist/utils/private/get-files.d.ts +2 -0
- package/dist/utils/private/get-files.d.ts.map +1 -0
- package/dist/utils/private/get-files.js +18 -0
- package/dist/utils/private/get-files.js.map +1 -0
- package/dist/utils/private/get-logger.d.ts +3 -0
- package/dist/utils/private/get-logger.d.ts.map +1 -0
- package/dist/utils/private/get-logger.js +16 -0
- package/dist/utils/private/get-logger.js.map +1 -0
- package/dist/utils/private/get-types.d.ts +11 -0
- package/dist/utils/private/get-types.d.ts.map +1 -0
- package/dist/utils/private/get-types.js +24 -0
- package/dist/utils/private/get-types.js.map +1 -0
- package/dist/utils/private/index.d.ts +7 -0
- package/dist/utils/private/index.d.ts.map +1 -0
- package/dist/utils/private/index.js +23 -0
- package/dist/utils/private/index.js.map +1 -0
- package/dist/utils/private/load-samples.d.ts +9 -0
- package/dist/utils/private/load-samples.d.ts.map +1 -0
- package/dist/utils/private/load-samples.js +35 -0
- package/dist/utils/private/load-samples.js.map +1 -0
- package/dist/utils/private/write-lines-to-file.d.ts +10 -0
- package/dist/utils/private/write-lines-to-file.d.ts.map +1 -0
- package/dist/utils/private/write-lines-to-file.js +29 -0
- package/dist/utils/private/write-lines-to-file.js.map +1 -0
- package/dist/utils/typewriter.d.ts +13 -0
- package/dist/utils/typewriter.d.ts.map +1 -0
- package/dist/utils/typewriter.js +29 -0
- package/dist/utils/typewriter.js.map +1 -0
- package/package.json +43 -0
- package/tsconfig.build.tsbuildinfo +1 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
# 0.1.0 (2025-09-18)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- initialise typewriter package ([cb1c9f6](https://github.com/lindorm-io/monorepo/commit/cb1c9f630685ad9843c2b515f85055acb71981e2))
|
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# @lindorm/typewriter
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const case_1 = require("@lindorm/case");
|
|
4
|
+
const is_1 = require("@lindorm/is");
|
|
5
|
+
const commander_1 = require("commander");
|
|
6
|
+
const utils_1 = require("./utils");
|
|
7
|
+
const private_1 = require("./utils/private");
|
|
8
|
+
commander_1.program
|
|
9
|
+
.name("typewriter")
|
|
10
|
+
.description("CLI for generating TypeScript types from JSON and YAML files");
|
|
11
|
+
commander_1.program
|
|
12
|
+
.option("-f, --files <paths>", "input file(s) path (comma separated)", (v) => v.split(","))
|
|
13
|
+
.option("-o, --output <type>", "output type (typescript or typescript-zod)", "typescript")
|
|
14
|
+
.option("-n, --name <name>", "type name to generate")
|
|
15
|
+
.option("-w, --write <directory>", "directory to write generated type")
|
|
16
|
+
.option("-v, --verbose", "enable verbose logging", false);
|
|
17
|
+
commander_1.program.parse();
|
|
18
|
+
const options = commander_1.program.opts();
|
|
19
|
+
if (!(0, is_1.isArray)(options.files)) {
|
|
20
|
+
console.error("Please provide either a file or a directory path. Use typewriter --help for more info");
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
if (!(0, is_1.isString)(options.output)) {
|
|
24
|
+
console.error("Please provide an output type (typescript or typescript-zod). Use typewriter --help for more info");
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
if (!(0, is_1.isString)(options.name)) {
|
|
28
|
+
console.error("Please provide a type name to generate. Use typewriter --help for more info");
|
|
29
|
+
process.exit(1);
|
|
30
|
+
}
|
|
31
|
+
if (!(0, is_1.isString)(options.write)) {
|
|
32
|
+
console.error("Please provide a directory to write the generated type. Use typewriter --help for more info");
|
|
33
|
+
process.exit(1);
|
|
34
|
+
}
|
|
35
|
+
const input = options.files.map(private_1.absolutePath);
|
|
36
|
+
const output = options.output.toLowerCase();
|
|
37
|
+
const typeName = (0, case_1.pascalCase)(options.name);
|
|
38
|
+
const verbose = options.verbose ?? false;
|
|
39
|
+
const writeToDirectory = (0, private_1.absolutePath)(options.write);
|
|
40
|
+
(0, utils_1.typewriter)({
|
|
41
|
+
input,
|
|
42
|
+
logger: verbose ? { level: "verbose", readable: true } : undefined,
|
|
43
|
+
output,
|
|
44
|
+
typeName,
|
|
45
|
+
writeToDirectory,
|
|
46
|
+
})
|
|
47
|
+
.then(() => {
|
|
48
|
+
console.log("Typewriter successful", { typeName, input, writeToDirectory });
|
|
49
|
+
process.exit(0);
|
|
50
|
+
})
|
|
51
|
+
.catch((error) => {
|
|
52
|
+
console.error("Typewriter error", error);
|
|
53
|
+
process.exit(1);
|
|
54
|
+
});
|
|
55
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;AAAA,wCAA2C;AAC3C,oCAAgD;AAChD,yCAAoC;AAEpC,mCAAqC;AACrC,6CAA+C;AAE/C,mBAAO;KACJ,IAAI,CAAC,YAAY,CAAC;KAClB,WAAW,CAAC,8DAA8D,CAAC,CAAC;AAE/E,mBAAO;KACJ,MAAM,CACL,qBAAqB,EACrB,sCAAsC,EACtC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CACpB;KACA,MAAM,CACL,qBAAqB,EACrB,4CAA4C,EAC5C,YAAY,CACb;KACA,MAAM,CAAC,mBAAmB,EAAE,uBAAuB,CAAC;KACpD,MAAM,CAAC,yBAAyB,EAAE,mCAAmC,CAAC;KACtE,MAAM,CAAC,eAAe,EAAE,wBAAwB,EAAE,KAAK,CAAC,CAAC;AAE5D,mBAAO,CAAC,KAAK,EAAE,CAAC;AAEhB,MAAM,OAAO,GAAG,mBAAO,CAAC,IAAI,EAAE,CAAC;AAE/B,IAAI,CAAC,IAAA,YAAO,EAAS,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;IACpC,OAAO,CAAC,KAAK,CACX,uFAAuF,CACxF,CAAC;IACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,IAAI,CAAC,IAAA,aAAQ,EAAmB,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;IAChD,OAAO,CAAC,KAAK,CACX,mGAAmG,CACpG,CAAC;IACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,IAAI,CAAC,IAAA,aAAQ,EAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;IAC5B,OAAO,CAAC,KAAK,CACX,6EAA6E,CAC9E,CAAC;IACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,IAAI,CAAC,IAAA,aAAQ,EAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;IAC7B,OAAO,CAAC,KAAK,CACX,6FAA6F,CAC9F,CAAC;IACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,sBAAY,CAAC,CAAC;AAC9C,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,WAAW,EAAqC,CAAC;AAC/E,MAAM,QAAQ,GAAG,IAAA,iBAAU,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAC1C,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,KAAK,CAAC;AACzC,MAAM,gBAAgB,GAAG,IAAA,sBAAY,EAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAErD,IAAA,kBAAU,EAAC;IACT,KAAK;IACL,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS;IAClE,MAAM;IACN,QAAQ;IACR,gBAAgB;CACjB,CAAC;KACC,IAAI,CAAC,GAAG,EAAE;IACT,OAAO,CAAC,GAAG,CAAC,uBAAuB,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,gBAAgB,EAAE,CAAC,CAAC;IAC5E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC;KACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACf,OAAO,CAAC,KAAK,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC;IACzC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./utils"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./types"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG,YAAY,GAAG,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./typewriter"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"absolute-path.d.ts","sourceRoot":"","sources":["../../../src/utils/private/absolute-path.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,YAAY,GAAI,MAAM,MAAM,KAAG,MAc3C,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.absolutePath = void 0;
|
|
4
|
+
const is_1 = require("@lindorm/is");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const absolutePath = (path) => {
|
|
7
|
+
if (!(0, is_1.isString)(path)) {
|
|
8
|
+
throw new Error("No input path provided");
|
|
9
|
+
}
|
|
10
|
+
if (path === ".")
|
|
11
|
+
return process.cwd();
|
|
12
|
+
if (path === "~")
|
|
13
|
+
return process.env.HOME || "";
|
|
14
|
+
if (path.startsWith("/"))
|
|
15
|
+
return path;
|
|
16
|
+
if (path.startsWith("~"))
|
|
17
|
+
return (0, path_1.join)(process.env.HOME || "", path.slice(1));
|
|
18
|
+
return (0, path_1.join)(process.cwd(), path);
|
|
19
|
+
};
|
|
20
|
+
exports.absolutePath = absolutePath;
|
|
21
|
+
//# sourceMappingURL=absolute-path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"absolute-path.js","sourceRoot":"","sources":["../../../src/utils/private/absolute-path.ts"],"names":[],"mappings":";;;AAAA,oCAAuC;AACvC,+BAA4B;AAErB,MAAM,YAAY,GAAG,CAAC,IAAY,EAAU,EAAE;IACnD,IAAI,CAAC,IAAA,aAAQ,EAAC,IAAI,CAAC,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAC5C,CAAC;IAED,IAAI,IAAI,KAAK,GAAG;QAAE,OAAO,OAAO,CAAC,GAAG,EAAE,CAAC;IAEvC,IAAI,IAAI,KAAK,GAAG;QAAE,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC;IAEhD,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IAEtC,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAE7E,OAAO,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,CAAC;AACnC,CAAC,CAAC;AAdW,QAAA,YAAY,gBAcvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-files.d.ts","sourceRoot":"","sources":["../../../src/utils/private/get-files.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,QAAQ,GAAI,OAAO,MAAM,KAAG,KAAK,CAAC,MAAM,CAYpD,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getFiles = void 0;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const getFiles = (input) => {
|
|
7
|
+
const isDirectory = (0, fs_1.existsSync)(input) && !(0, path_1.extname)(input);
|
|
8
|
+
const isFile = (0, fs_1.existsSync)(input) && (0, path_1.extname)(input);
|
|
9
|
+
if (isDirectory) {
|
|
10
|
+
return (0, fs_1.readdirSync)(input).map((file) => (0, path_1.join)(input, file));
|
|
11
|
+
}
|
|
12
|
+
if (isFile) {
|
|
13
|
+
return [input];
|
|
14
|
+
}
|
|
15
|
+
throw new Error(`Input must be a directory or a file: ${input}`);
|
|
16
|
+
};
|
|
17
|
+
exports.getFiles = getFiles;
|
|
18
|
+
//# sourceMappingURL=get-files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-files.js","sourceRoot":"","sources":["../../../src/utils/private/get-files.ts"],"names":[],"mappings":";;;AAAA,2BAA6C;AAC7C,+BAAqC;AAE9B,MAAM,QAAQ,GAAG,CAAC,KAAa,EAAiB,EAAE;IACvD,MAAM,WAAW,GAAG,IAAA,eAAU,EAAC,KAAK,CAAC,IAAI,CAAC,IAAA,cAAO,EAAC,KAAK,CAAC,CAAC;IACzD,MAAM,MAAM,GAAG,IAAA,eAAU,EAAC,KAAK,CAAC,IAAI,IAAA,cAAO,EAAC,KAAK,CAAC,CAAC;IAEnD,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO,IAAA,gBAAW,EAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAA,WAAI,EAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;IAC7D,CAAC;IACD,IAAI,MAAM,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,wCAAwC,KAAK,EAAE,CAAC,CAAC;AACnE,CAAC,CAAC;AAZW,QAAA,QAAQ,YAYnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-logger.d.ts","sourceRoot":"","sources":["../../../src/utils/private/get-logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAU,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEjE,eAAO,MAAM,SAAS,GAAI,SAAS,OAAO,GAAG,aAAa,GAAG,SAAS,KAAG,OAYxE,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getLogger = void 0;
|
|
4
|
+
const logger_1 = require("@lindorm/logger");
|
|
5
|
+
const getLogger = (options) => {
|
|
6
|
+
const scope = ["Typewriter"];
|
|
7
|
+
if (!options) {
|
|
8
|
+
return new logger_1.Logger({ scope });
|
|
9
|
+
}
|
|
10
|
+
if (options.__instanceof === "Logger") {
|
|
11
|
+
return options.child(scope);
|
|
12
|
+
}
|
|
13
|
+
return new logger_1.Logger({ ...options, scope });
|
|
14
|
+
};
|
|
15
|
+
exports.getLogger = getLogger;
|
|
16
|
+
//# sourceMappingURL=get-logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-logger.js","sourceRoot":"","sources":["../../../src/utils/private/get-logger.ts"],"names":[],"mappings":";;;AAAA,4CAAiE;AAE1D,MAAM,SAAS,GAAG,CAAC,OAA4C,EAAW,EAAE;IACjF,MAAM,KAAK,GAAG,CAAC,YAAY,CAAC,CAAC;IAE7B,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,IAAI,eAAM,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IAC/B,CAAC;IAED,IAAK,OAAmB,CAAC,YAAY,KAAK,QAAQ,EAAE,CAAC;QACnD,OAAQ,OAAmB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC;IAED,OAAO,IAAI,eAAM,CAAC,EAAE,GAAG,OAAO,EAAE,KAAK,EAAmB,CAAC,CAAC;AAC5D,CAAC,CAAC;AAZW,QAAA,SAAS,aAYpB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ILogger } from "@lindorm/logger";
|
|
2
|
+
import { SerializedRenderResult } from "quicktype-core";
|
|
3
|
+
type Options = {
|
|
4
|
+
logger: ILogger;
|
|
5
|
+
output?: "typescript" | "typescript-zod";
|
|
6
|
+
samples: Array<string>;
|
|
7
|
+
typeName: string;
|
|
8
|
+
};
|
|
9
|
+
export declare const getTypes: (options: Options) => Promise<SerializedRenderResult>;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=get-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-types.d.ts","sourceRoot":"","sources":["../../../src/utils/private/get-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAIL,sBAAsB,EACvB,MAAM,gBAAgB,CAAC;AAExB,KAAK,OAAO,GAAG;IACb,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,YAAY,GAAG,gBAAgB,CAAC;IACzC,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,QAAQ,GAAU,SAAS,OAAO,KAAG,OAAO,CAAC,sBAAsB,CAqB/E,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getTypes = void 0;
|
|
4
|
+
const quicktype_core_1 = require("quicktype-core");
|
|
5
|
+
const getTypes = async (options) => {
|
|
6
|
+
const lang = options.output ?? "typescript";
|
|
7
|
+
const jsonInput = (0, quicktype_core_1.jsonInputForTargetLanguage)(lang);
|
|
8
|
+
await jsonInput.addSource({
|
|
9
|
+
name: options.typeName,
|
|
10
|
+
samples: options.samples,
|
|
11
|
+
});
|
|
12
|
+
const inputData = new quicktype_core_1.InputData();
|
|
13
|
+
inputData.addInput(jsonInput);
|
|
14
|
+
options.logger.verbose(`Generating types for [ ${options.typeName} ] in [ ${lang} ]`);
|
|
15
|
+
return await (0, quicktype_core_1.quicktype)({
|
|
16
|
+
inputData,
|
|
17
|
+
indentation: " ",
|
|
18
|
+
lang,
|
|
19
|
+
alphabetizeProperties: true,
|
|
20
|
+
rendererOptions: { "just-types": "true" },
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
exports.getTypes = getTypes;
|
|
24
|
+
//# sourceMappingURL=get-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-types.js","sourceRoot":"","sources":["../../../src/utils/private/get-types.ts"],"names":[],"mappings":";;;AACA,mDAKwB;AASjB,MAAM,QAAQ,GAAG,KAAK,EAAE,OAAgB,EAAmC,EAAE;IAClF,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,IAAI,YAAY,CAAC;IAE5C,MAAM,SAAS,GAAG,IAAA,2CAA0B,EAAC,IAAI,CAAC,CAAC;IACnD,MAAM,SAAS,CAAC,SAAS,CAAC;QACxB,IAAI,EAAE,OAAO,CAAC,QAAQ;QACtB,OAAO,EAAE,OAAO,CAAC,OAAO;KACzB,CAAC,CAAC;IAEH,MAAM,SAAS,GAAG,IAAI,0BAAS,EAAE,CAAC;IAClC,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IAE9B,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,0BAA0B,OAAO,CAAC,QAAQ,WAAW,IAAI,IAAI,CAAC,CAAC;IAEtF,OAAO,MAAM,IAAA,0BAAS,EAAC;QACrB,SAAS;QACT,WAAW,EAAE,IAAI;QACjB,IAAI;QACJ,qBAAqB,EAAE,IAAI;QAC3B,eAAe,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE;KAC1C,CAAC,CAAC;AACL,CAAC,CAAC;AArBW,QAAA,QAAQ,YAqBnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/private/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./absolute-path"), exports);
|
|
18
|
+
__exportStar(require("./get-files"), exports);
|
|
19
|
+
__exportStar(require("./get-logger"), exports);
|
|
20
|
+
__exportStar(require("./get-types"), exports);
|
|
21
|
+
__exportStar(require("./load-samples"), exports);
|
|
22
|
+
__exportStar(require("./write-lines-to-file"), exports);
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/private/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAgC;AAChC,8CAA4B;AAC5B,+CAA6B;AAC7B,8CAA4B;AAC5B,iDAA+B;AAC/B,wDAAsC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ILogger } from "@lindorm/logger";
|
|
2
|
+
type Options = {
|
|
3
|
+
input: Array<string>;
|
|
4
|
+
logger: ILogger;
|
|
5
|
+
samples?: Array<string>;
|
|
6
|
+
};
|
|
7
|
+
export declare const loadSamples: (options: Options) => Array<string>;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=load-samples.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-samples.d.ts","sourceRoot":"","sources":["../../../src/utils/private/load-samples.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAM1C,KAAK,OAAO,GAAG;IACb,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACrB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CACzB,CAAC;AASF,eAAO,MAAM,WAAW,GAAI,SAAS,OAAO,KAAG,KAAK,CAAC,MAAM,CAgC1D,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadSamples = void 0;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const js_yaml_1 = require("js-yaml");
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
const get_files_1 = require("./get-files");
|
|
8
|
+
const loadJsonSample = (file) => JSON.stringify(require(file));
|
|
9
|
+
const loadYamlSample = (file) => JSON.stringify((0, js_yaml_1.load)((0, fs_1.readFileSync)(file, "utf-8")));
|
|
10
|
+
const loadSamples = (options) => {
|
|
11
|
+
const samples = options.samples ?? [];
|
|
12
|
+
for (const input of options.input) {
|
|
13
|
+
options.logger.verbose(`Loading samples from input [ ${input} ]`);
|
|
14
|
+
if (!(0, fs_1.existsSync)(input)) {
|
|
15
|
+
throw new Error(`${input} does not exist`);
|
|
16
|
+
}
|
|
17
|
+
const files = (0, get_files_1.getFiles)(input);
|
|
18
|
+
for (const file of files) {
|
|
19
|
+
options.logger.verbose(`Loading sample from file [ ${file} ]`);
|
|
20
|
+
const ext = (0, path_1.extname)(file);
|
|
21
|
+
if (ext === ".json") {
|
|
22
|
+
samples.push(loadJsonSample(file));
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
if (ext === ".yml" || ext === ".yaml") {
|
|
26
|
+
samples.push(loadYamlSample(file));
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
options.logger.verbose(`Loaded [ ${samples.length} ] samples`);
|
|
32
|
+
return samples;
|
|
33
|
+
};
|
|
34
|
+
exports.loadSamples = loadSamples;
|
|
35
|
+
//# sourceMappingURL=load-samples.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-samples.js","sourceRoot":"","sources":["../../../src/utils/private/load-samples.ts"],"names":[],"mappings":";;;AACA,2BAA8C;AAC9C,qCAA+B;AAC/B,+BAA+B;AAC/B,2CAAuC;AAQvC,MAAM,cAAc,GAAG,CAAC,IAAY,EAAU,EAAE,CAE9C,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;AAEhC,MAAM,cAAc,GAAG,CAAC,IAAY,EAAU,EAAE,CAC9C,IAAI,CAAC,SAAS,CAAC,IAAA,cAAI,EAAC,IAAA,iBAAY,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;AAE7C,MAAM,WAAW,GAAG,CAAC,OAAgB,EAAiB,EAAE;IAC7D,MAAM,OAAO,GAAkB,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC;IAErD,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;QAClC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,gCAAgC,KAAK,IAAI,CAAC,CAAC;QAElE,IAAI,CAAC,IAAA,eAAU,EAAC,KAAK,CAAC,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,iBAAiB,CAAC,CAAC;QAC7C,CAAC;QAED,MAAM,KAAK,GAAG,IAAA,oBAAQ,EAAC,KAAK,CAAC,CAAC;QAE9B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,8BAA8B,IAAI,IAAI,CAAC,CAAC;YAE/D,MAAM,GAAG,GAAG,IAAA,cAAO,EAAC,IAAI,CAAC,CAAC;YAE1B,IAAI,GAAG,KAAK,OAAO,EAAE,CAAC;gBACpB,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC;gBACnC,SAAS;YACX,CAAC;YAED,IAAI,GAAG,KAAK,MAAM,IAAI,GAAG,KAAK,OAAO,EAAE,CAAC;gBACtC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC;gBACnC,SAAS;YACX,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,YAAY,OAAO,CAAC,MAAM,YAAY,CAAC,CAAC;IAE/D,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAhCW,QAAA,WAAW,eAgCtB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ILogger } from "@lindorm/logger";
|
|
2
|
+
type Options = {
|
|
3
|
+
fileName: string;
|
|
4
|
+
lines: Array<string>;
|
|
5
|
+
logger: ILogger;
|
|
6
|
+
writeToDirectory: string;
|
|
7
|
+
};
|
|
8
|
+
export declare const writeLinesToFile: (options: Options) => Promise<void>;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=write-lines-to-file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write-lines-to-file.d.ts","sourceRoot":"","sources":["../../../src/utils/private/write-lines-to-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAI1C,KAAK,OAAO,GAAG;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACrB,MAAM,EAAE,OAAO,CAAC;IAChB,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,SAAS,OAAO,KAAG,OAAO,CAAC,IAAI,CA4B/D,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.writeLinesToFile = void 0;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const writeLinesToFile = (options) => {
|
|
7
|
+
return new Promise((resolve, reject) => {
|
|
8
|
+
const file = (0, path_1.join)(options.writeToDirectory, `${options.fileName}.typewriter.ts`);
|
|
9
|
+
options.logger.verbose(`Writing type to file [ ${file} ]`);
|
|
10
|
+
if (!(0, fs_1.existsSync)(options.writeToDirectory)) {
|
|
11
|
+
(0, fs_1.mkdirSync)(options.writeToDirectory);
|
|
12
|
+
}
|
|
13
|
+
const stream = (0, fs_1.createWriteStream)(file);
|
|
14
|
+
stream.on("finish", () => {
|
|
15
|
+
options.logger.verbose(`Type written to file [ ${file} ]`);
|
|
16
|
+
resolve();
|
|
17
|
+
});
|
|
18
|
+
stream.on("error", (err) => {
|
|
19
|
+
options.logger.error(`Failed to write type to file [ ${file} ]`, err);
|
|
20
|
+
reject(err);
|
|
21
|
+
});
|
|
22
|
+
for (const line of options.lines) {
|
|
23
|
+
stream.write(line + "\n");
|
|
24
|
+
}
|
|
25
|
+
stream.end();
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
exports.writeLinesToFile = writeLinesToFile;
|
|
29
|
+
//# sourceMappingURL=write-lines-to-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write-lines-to-file.js","sourceRoot":"","sources":["../../../src/utils/private/write-lines-to-file.ts"],"names":[],"mappings":";;;AACA,2BAA8D;AAC9D,+BAA4B;AASrB,MAAM,gBAAgB,GAAG,CAAC,OAAgB,EAAiB,EAAE;IAClE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,IAAI,GAAG,IAAA,WAAI,EAAC,OAAO,CAAC,gBAAgB,EAAE,GAAG,OAAO,CAAC,QAAQ,gBAAgB,CAAC,CAAC;QAEjF,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,0BAA0B,IAAI,IAAI,CAAC,CAAC;QAE3D,IAAI,CAAC,IAAA,eAAU,EAAC,OAAO,CAAC,gBAAgB,CAAC,EAAE,CAAC;YAC1C,IAAA,cAAS,EAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;QACtC,CAAC;QAED,MAAM,MAAM,GAAG,IAAA,sBAAiB,EAAC,IAAI,CAAC,CAAC;QAEvC,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;YACvB,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,0BAA0B,IAAI,IAAI,CAAC,CAAC;YAC3D,OAAO,EAAE,CAAC;QACZ,CAAC,CAAC,CAAC;QAEH,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;YACzB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,kCAAkC,IAAI,IAAI,EAAE,GAAG,CAAC,CAAC;YACtE,MAAM,CAAC,GAAG,CAAC,CAAC;QACd,CAAC,CAAC,CAAC;QAEH,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;YACjC,MAAM,CAAC,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;QAC5B,CAAC;QAED,MAAM,CAAC,GAAG,EAAE,CAAC;IACf,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AA5BW,QAAA,gBAAgB,oBA4B3B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ILogger, LoggerOptions } from "@lindorm/logger";
|
|
2
|
+
type Options = {
|
|
3
|
+
fileName?: string;
|
|
4
|
+
input: Array<string>;
|
|
5
|
+
logger?: ILogger | LoggerOptions;
|
|
6
|
+
output?: "typescript" | "typescript-zod";
|
|
7
|
+
samples?: Array<string>;
|
|
8
|
+
typeName: string;
|
|
9
|
+
writeToDirectory?: string;
|
|
10
|
+
};
|
|
11
|
+
export declare const typewriter: (options: Options) => Promise<string>;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=typewriter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typewriter.d.ts","sourceRoot":"","sources":["../../src/utils/typewriter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGzD,KAAK,OAAO,GAAG;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACrB,MAAM,CAAC,EAAE,OAAO,GAAG,aAAa,CAAC;IACjC,MAAM,CAAC,EAAE,YAAY,GAAG,gBAAgB,CAAC;IACzC,OAAO,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,eAAO,MAAM,UAAU,GAAU,SAAS,OAAO,KAAG,OAAO,CAAC,MAAM,CA0BjE,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.typewriter = void 0;
|
|
4
|
+
const private_1 = require("./private");
|
|
5
|
+
const typewriter = async (options) => {
|
|
6
|
+
const logger = (0, private_1.getLogger)(options.logger);
|
|
7
|
+
const samples = (0, private_1.loadSamples)({
|
|
8
|
+
input: options.input,
|
|
9
|
+
logger,
|
|
10
|
+
samples: options.samples,
|
|
11
|
+
});
|
|
12
|
+
const { lines } = await (0, private_1.getTypes)({
|
|
13
|
+
logger,
|
|
14
|
+
output: options.output,
|
|
15
|
+
samples,
|
|
16
|
+
typeName: options.typeName,
|
|
17
|
+
});
|
|
18
|
+
if (options.writeToDirectory) {
|
|
19
|
+
await (0, private_1.writeLinesToFile)({
|
|
20
|
+
fileName: options.fileName ?? options.typeName,
|
|
21
|
+
lines,
|
|
22
|
+
logger,
|
|
23
|
+
writeToDirectory: options.writeToDirectory,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return lines.join("\n");
|
|
27
|
+
};
|
|
28
|
+
exports.typewriter = typewriter;
|
|
29
|
+
//# sourceMappingURL=typewriter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typewriter.js","sourceRoot":"","sources":["../../src/utils/typewriter.ts"],"names":[],"mappings":";;;AACA,uCAA+E;AAYxE,MAAM,UAAU,GAAG,KAAK,EAAE,OAAgB,EAAmB,EAAE;IACpE,MAAM,MAAM,GAAG,IAAA,mBAAS,EAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAEzC,MAAM,OAAO,GAAG,IAAA,qBAAW,EAAC;QAC1B,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,MAAM;QACN,OAAO,EAAE,OAAO,CAAC,OAAO;KACzB,CAAC,CAAC;IAEH,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAA,kBAAQ,EAAC;QAC/B,MAAM;QACN,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,OAAO;QACP,QAAQ,EAAE,OAAO,CAAC,QAAQ;KAC3B,CAAC,CAAC;IAEH,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;QAC7B,MAAM,IAAA,0BAAgB,EAAC;YACrB,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,QAAQ;YAC9C,KAAK;YACL,MAAM;YACN,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;SAC3C,CAAC,CAAC;IACL,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC,CAAC;AA1BW,QAAA,UAAU,cA0BrB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lindorm/typewriter",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"license": "AGPL-3.0-or-later",
|
|
5
|
+
"author": "Jonn Nilsson",
|
|
6
|
+
"repository": {
|
|
7
|
+
"url": "https://github.com/lindorm-io/monorepo",
|
|
8
|
+
"directory": "packages/typewriter"
|
|
9
|
+
},
|
|
10
|
+
"bugs": "https://github.com/lindorm-io/monorepo/issues",
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public"
|
|
13
|
+
},
|
|
14
|
+
"main": "dist/index.js",
|
|
15
|
+
"typings": "dist/index.d.ts",
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "rimraf dist && tsc -b ./tsconfig.build.json && chmod +x dist/cli.js",
|
|
18
|
+
"example": "ts-node example",
|
|
19
|
+
"integration": "compd --file docker-compose.yml jest --config jest.config.integration.js --watch",
|
|
20
|
+
"integration:focus": "compd --file docker-compose.yml jest --config jest.config.integration.js --watch $1",
|
|
21
|
+
"prettier": "prettier --write ./src/*",
|
|
22
|
+
"test": "jest --watch --",
|
|
23
|
+
"test:ci": "npm run test:unit",
|
|
24
|
+
"test:integration": "jest --config jest.config.integration.js --",
|
|
25
|
+
"test:unit": "jest --config jest.config.js --",
|
|
26
|
+
"typecheck": "tsc --watch",
|
|
27
|
+
"typecheck:ci": "tsc",
|
|
28
|
+
"update": "ncu -i",
|
|
29
|
+
"update:auto": "ncu -u"
|
|
30
|
+
},
|
|
31
|
+
"bin": {
|
|
32
|
+
"typewriter": "dist/cli.js"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@lindorm/case": "^0.1.11",
|
|
36
|
+
"@lindorm/is": "^0.1.11",
|
|
37
|
+
"@lindorm/logger": "^0.3.4",
|
|
38
|
+
"commander": "^13.1.0",
|
|
39
|
+
"js-yaml": "^4.1.0",
|
|
40
|
+
"quicktype-core": "^23.2.6"
|
|
41
|
+
},
|
|
42
|
+
"gitHead": "3302fa2c4d75f2832959018d9e089d11af4a35fc"
|
|
43
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"root":["./src/cli.ts","./src/index.ts","./src/types/index.ts","./src/types/types.ts","./src/utils/index.ts","./src/utils/typewriter.ts","./src/utils/private/absolute-path.ts","./src/utils/private/get-files.ts","./src/utils/private/get-logger.ts","./src/utils/private/get-types.ts","./src/utils/private/index.ts","./src/utils/private/load-samples.ts","./src/utils/private/write-lines-to-file.ts"],"version":"5.9.2"}
|