@lindorm/typewriter 0.1.6 → 0.2.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 +117 -0
- package/dist/cli.js +17 -19
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -17
- package/dist/index.js.map +1 -1
- package/dist/internal/absolute-path.d.ts.map +1 -0
- package/dist/internal/absolute-path.js +17 -0
- package/dist/internal/absolute-path.js.map +1 -0
- package/dist/internal/get-files.d.ts.map +1 -0
- package/dist/internal/get-files.js +14 -0
- package/dist/internal/get-files.js.map +1 -0
- package/dist/internal/get-logger.d.ts +3 -0
- package/dist/internal/get-logger.d.ts.map +1 -0
- package/dist/internal/get-logger.js +12 -0
- package/dist/internal/get-logger.js.map +1 -0
- package/dist/{utils/private → internal}/get-types.d.ts +2 -2
- package/dist/internal/get-types.d.ts.map +1 -0
- package/dist/internal/get-types.js +20 -0
- package/dist/internal/get-types.js.map +1 -0
- package/dist/internal/index.d.ts +7 -0
- package/dist/internal/index.d.ts.map +1 -0
- package/dist/internal/index.js +7 -0
- package/dist/internal/index.js.map +1 -0
- package/dist/{utils/private → internal}/load-samples.d.ts +1 -1
- package/dist/internal/load-samples.d.ts.map +1 -0
- package/dist/{utils/private → internal}/load-samples.js +9 -13
- package/dist/internal/load-samples.js.map +1 -0
- package/dist/{utils/private → internal}/write-lines-to-file.d.ts +1 -1
- package/dist/internal/write-lines-to-file.d.ts.map +1 -0
- package/dist/internal/write-lines-to-file.js +25 -0
- package/dist/internal/write-lines-to-file.js.map +1 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -17
- package/dist/types/index.js.map +1 -1
- package/dist/types/types.js +1 -2
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -17
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/typewriter.d.ts +1 -1
- package/dist/utils/typewriter.d.ts.map +1 -1
- package/dist/utils/typewriter.js +6 -10
- package/dist/utils/typewriter.js.map +1 -1
- package/package.json +18 -9
- package/tsconfig.build.tsbuildinfo +1 -1
- package/vitest.config.mjs +3 -0
- package/dist/utils/private/absolute-path.d.ts.map +0 -1
- package/dist/utils/private/absolute-path.js +0 -21
- package/dist/utils/private/absolute-path.js.map +0 -1
- package/dist/utils/private/get-files.d.ts.map +0 -1
- package/dist/utils/private/get-files.js +0 -18
- package/dist/utils/private/get-files.js.map +0 -1
- package/dist/utils/private/get-logger.d.ts +0 -3
- package/dist/utils/private/get-logger.d.ts.map +0 -1
- package/dist/utils/private/get-logger.js +0 -16
- package/dist/utils/private/get-logger.js.map +0 -1
- package/dist/utils/private/get-types.d.ts.map +0 -1
- package/dist/utils/private/get-types.js +0 -24
- package/dist/utils/private/get-types.js.map +0 -1
- package/dist/utils/private/index.d.ts +0 -7
- package/dist/utils/private/index.d.ts.map +0 -1
- package/dist/utils/private/index.js +0 -23
- package/dist/utils/private/index.js.map +0 -1
- package/dist/utils/private/load-samples.d.ts.map +0 -1
- package/dist/utils/private/load-samples.js.map +0 -1
- package/dist/utils/private/write-lines-to-file.d.ts.map +0 -1
- package/dist/utils/private/write-lines-to-file.js +0 -29
- package/dist/utils/private/write-lines-to-file.js.map +0 -1
- /package/dist/{utils/private → internal}/absolute-path.d.ts +0 -0
- /package/dist/{utils/private → internal}/get-files.d.ts +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [0.2.0](https://github.com/lindorm-io/monorepo/compare/@lindorm/typewriter@0.1.7...@lindorm/typewriter@0.2.0) (2026-05-02)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- migrate 13 utility packages + drop jest configs from types/enums ([3eab5ab](https://github.com/lindorm-io/monorepo/commit/3eab5ab9d89cd529553a2aded3c311d3f393ca0f))
|
|
11
|
+
|
|
12
|
+
## [0.1.7](https://github.com/lindorm-io/monorepo/compare/@lindorm/typewriter@0.1.6...@lindorm/typewriter@0.1.7) (2026-04-19)
|
|
13
|
+
|
|
14
|
+
**Note:** Version bump only for package @lindorm/typewriter
|
|
15
|
+
|
|
6
16
|
## [0.1.6](https://github.com/lindorm-io/monorepo/compare/@lindorm/typewriter@0.1.5...@lindorm/typewriter@0.1.6) (2026-04-15)
|
|
7
17
|
|
|
8
18
|
**Note:** Version bump only for package @lindorm/typewriter
|
package/README.md
CHANGED
|
@@ -1 +1,118 @@
|
|
|
1
1
|
# @lindorm/typewriter
|
|
2
|
+
|
|
3
|
+
Generate TypeScript types (or Zod schemas) from JSON and YAML samples, via a CLI or a programmatic API.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @lindorm/typewriter
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
This package is **ESM-only**. All examples use `import` syntax; `require()` is not supported.
|
|
12
|
+
|
|
13
|
+
## Features
|
|
14
|
+
|
|
15
|
+
- Generate TypeScript interfaces from JSON or YAML files.
|
|
16
|
+
- Generate `typescript-zod` output as an alternative target.
|
|
17
|
+
- Accept individual files or whole directories as input (mixing `.json`, `.yml`, and `.yaml`).
|
|
18
|
+
- Combine multiple samples to widen inferred types.
|
|
19
|
+
- Optionally write the generated source to disk as `<name>.typewriter.ts`.
|
|
20
|
+
- Ships a `typewriter` CLI binary for use in scripts and `package.json` commands.
|
|
21
|
+
|
|
22
|
+
## CLI
|
|
23
|
+
|
|
24
|
+
After installing the package, the `typewriter` binary is available. Example:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npx typewriter --files ./schemas/user.json --name User --write ./src/generated
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Files are emitted to `<write>/<PascalCaseName>.typewriter.ts`.
|
|
31
|
+
|
|
32
|
+
### CLI Options
|
|
33
|
+
|
|
34
|
+
| Flag | Description |
|
|
35
|
+
| ------------------------- | -------------------------------------------------------------------------- |
|
|
36
|
+
| `-f, --files <paths>` | Comma-separated list of input file or directory paths. Required. |
|
|
37
|
+
| `-n, --name <name>` | Type name to generate. Pascal-cased automatically. Required. |
|
|
38
|
+
| `-w, --write <directory>` | Directory to write the generated type into. Required. |
|
|
39
|
+
| `-o, --output <type>` | Output target: `typescript` or `typescript-zod`. Defaults to `typescript`. |
|
|
40
|
+
| `-v, --verbose` | Enable verbose logging. Defaults to `false`. |
|
|
41
|
+
|
|
42
|
+
Inputs may be:
|
|
43
|
+
|
|
44
|
+
- A `.json` file.
|
|
45
|
+
- A `.yml` or `.yaml` file.
|
|
46
|
+
- A directory containing any combination of the above (non-matching extensions are ignored).
|
|
47
|
+
|
|
48
|
+
## Programmatic Usage
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
import { typewriter } from "@lindorm/typewriter";
|
|
52
|
+
|
|
53
|
+
const source = await typewriter({
|
|
54
|
+
input: ["./schemas/user.json", "./schemas/extras"],
|
|
55
|
+
typeName: "User",
|
|
56
|
+
output: "typescript",
|
|
57
|
+
writeToDirectory: "./src/generated",
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
console.log(source);
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Calling `typewriter` without `writeToDirectory` returns the generated source as a string without touching the filesystem:
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
import { typewriter } from "@lindorm/typewriter";
|
|
67
|
+
|
|
68
|
+
const source = await typewriter({
|
|
69
|
+
input: ["./schemas/user.json"],
|
|
70
|
+
typeName: "User",
|
|
71
|
+
});
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
You can also pass pre-loaded JSON sample strings directly through `samples`, which are merged with anything loaded from `input`:
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
import { typewriter } from "@lindorm/typewriter";
|
|
78
|
+
|
|
79
|
+
const source = await typewriter({
|
|
80
|
+
input: [],
|
|
81
|
+
samples: [JSON.stringify({ id: "abc", count: 1 })],
|
|
82
|
+
typeName: "Event",
|
|
83
|
+
});
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## API
|
|
87
|
+
|
|
88
|
+
### `typewriter(options)`
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
type Options = {
|
|
92
|
+
fileName?: string;
|
|
93
|
+
input: Array<string>;
|
|
94
|
+
logger?: ILogger | LoggerOptions;
|
|
95
|
+
output?: "typescript" | "typescript-zod";
|
|
96
|
+
samples?: Array<string>;
|
|
97
|
+
typeName: string;
|
|
98
|
+
writeToDirectory?: string;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const typewriter: (options: Options) => Promise<string>;
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Resolves with the generated source as a single string (lines joined with `\n`).
|
|
105
|
+
|
|
106
|
+
| Option | Type | Description |
|
|
107
|
+
| ------------------ | ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
108
|
+
| `input` | `Array<string>` | File or directory paths to read samples from. Each entry must exist; otherwise an error is thrown. |
|
|
109
|
+
| `typeName` | `string` | Name of the root type to emit. |
|
|
110
|
+
| `output` | `"typescript" \| "typescript-zod"` | Target language. Defaults to `"typescript"`. |
|
|
111
|
+
| `samples` | `Array<string>` | Additional JSON-encoded samples merged with files loaded from `input`. |
|
|
112
|
+
| `writeToDirectory` | `string` | If provided, the generated source is written to `<writeToDirectory>/<fileName ?? typeName>.typewriter.ts`. The directory is created if it does not exist. |
|
|
113
|
+
| `fileName` | `string` | File name (without extension) for the written file. Defaults to `typeName`. |
|
|
114
|
+
| `logger` | `ILogger \| LoggerOptions` | Either an existing `@lindorm/logger` instance (a child scoped to `Typewriter` is used) or options to construct a new one. Defaults to a fresh `Logger` scoped to `Typewriter`. |
|
|
115
|
+
|
|
116
|
+
## License
|
|
117
|
+
|
|
118
|
+
AGPL-3.0-or-later
|
package/dist/cli.js
CHANGED
|
@@ -1,44 +1,42 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const private_1 = require("./utils/private");
|
|
9
|
-
commander_1.program
|
|
2
|
+
import { pascalCase } from "@lindorm/case";
|
|
3
|
+
import { isArray, isString } from "@lindorm/is";
|
|
4
|
+
import { program } from "commander";
|
|
5
|
+
import { typewriter } from "./utils/index.js";
|
|
6
|
+
import { absolutePath } from "./internal/index.js";
|
|
7
|
+
program
|
|
10
8
|
.name("typewriter")
|
|
11
9
|
.description("CLI for generating TypeScript types from JSON and YAML files");
|
|
12
|
-
|
|
10
|
+
program
|
|
13
11
|
.option("-f, --files <paths>", "input file(s) path (comma separated)", (v) => v.split(","))
|
|
14
12
|
.option("-o, --output <type>", "output type (typescript or typescript-zod)", "typescript")
|
|
15
13
|
.option("-n, --name <name>", "type name to generate")
|
|
16
14
|
.option("-w, --write <directory>", "directory to write generated type")
|
|
17
15
|
.option("-v, --verbose", "enable verbose logging", false);
|
|
18
|
-
|
|
19
|
-
const options =
|
|
20
|
-
if (!
|
|
16
|
+
program.parse();
|
|
17
|
+
const options = program.opts();
|
|
18
|
+
if (!isArray(options.files)) {
|
|
21
19
|
console.error("Please provide either a file or a directory path. Use typewriter --help for more info");
|
|
22
20
|
process.exit(1);
|
|
23
21
|
}
|
|
24
|
-
if (!
|
|
22
|
+
if (!isString(options.output)) {
|
|
25
23
|
console.error("Please provide an output type (typescript or typescript-zod). Use typewriter --help for more info");
|
|
26
24
|
process.exit(1);
|
|
27
25
|
}
|
|
28
|
-
if (!
|
|
26
|
+
if (!isString(options.name)) {
|
|
29
27
|
console.error("Please provide a type name to generate. Use typewriter --help for more info");
|
|
30
28
|
process.exit(1);
|
|
31
29
|
}
|
|
32
|
-
if (!
|
|
30
|
+
if (!isString(options.write)) {
|
|
33
31
|
console.error("Please provide a directory to write the generated type. Use typewriter --help for more info");
|
|
34
32
|
process.exit(1);
|
|
35
33
|
}
|
|
36
|
-
const input = options.files.map(
|
|
34
|
+
const input = options.files.map(absolutePath);
|
|
37
35
|
const output = options.output.toLowerCase();
|
|
38
|
-
const typeName =
|
|
36
|
+
const typeName = pascalCase(options.name);
|
|
39
37
|
const verbose = options.verbose ?? false;
|
|
40
|
-
const writeToDirectory =
|
|
41
|
-
|
|
38
|
+
const writeToDirectory = absolutePath(options.write);
|
|
39
|
+
typewriter({
|
|
42
40
|
input,
|
|
43
41
|
logger: verbose ? { level: "verbose", readable: true } : undefined,
|
|
44
42
|
output,
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,OAAO;KACJ,IAAI,CAAC,YAAY,CAAC;KAClB,WAAW,CAAC,8DAA8D,CAAC,CAAC;AAE/E,OAAO;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,OAAO,CAAC,KAAK,EAAE,CAAC;AAEhB,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;AAE/B,IAAI,CAAC,OAAO,CAAS,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,QAAQ,CAAmB,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,QAAQ,CAAC,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,QAAQ,CAAC,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,YAAY,CAAC,CAAC;AAC9C,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,WAAW,EAAqC,CAAC;AAC/E,MAAM,QAAQ,GAAG,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAC1C,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,KAAK,CAAC;AACzC,MAAM,gBAAgB,GAAG,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAErD,UAAU,CAAC;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
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./utils";
|
|
1
|
+
export * from "./utils/index.js";
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,18 +1,2 @@
|
|
|
1
|
-
|
|
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);
|
|
1
|
+
export * from "./utils/index.js";
|
|
18
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"absolute-path.d.ts","sourceRoot":"","sources":["../../src/internal/absolute-path.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,YAAY,GAAI,MAAM,MAAM,KAAG,MAc3C,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { isString } from "@lindorm/is";
|
|
2
|
+
import { join } from "path";
|
|
3
|
+
export const absolutePath = (path) => {
|
|
4
|
+
if (!isString(path)) {
|
|
5
|
+
throw new Error("No input path provided");
|
|
6
|
+
}
|
|
7
|
+
if (path === ".")
|
|
8
|
+
return process.cwd();
|
|
9
|
+
if (path === "~")
|
|
10
|
+
return process.env.HOME || "";
|
|
11
|
+
if (path.startsWith("/"))
|
|
12
|
+
return path;
|
|
13
|
+
if (path.startsWith("~"))
|
|
14
|
+
return join(process.env.HOME || "", path.slice(1));
|
|
15
|
+
return join(process.cwd(), path);
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=absolute-path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"absolute-path.js","sourceRoot":"","sources":["../../src/internal/absolute-path.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAY,EAAU,EAAE;IACnD,IAAI,CAAC,QAAQ,CAAC,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,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAE7E,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,CAAC;AACnC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-files.d.ts","sourceRoot":"","sources":["../../src/internal/get-files.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,QAAQ,GAAI,OAAO,MAAM,KAAG,KAAK,CAAC,MAAM,CAYpD,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { existsSync, readdirSync } from "fs";
|
|
2
|
+
import { extname, join } from "path";
|
|
3
|
+
export const getFiles = (input) => {
|
|
4
|
+
const isDirectory = existsSync(input) && !extname(input);
|
|
5
|
+
const isFile = existsSync(input) && extname(input);
|
|
6
|
+
if (isDirectory) {
|
|
7
|
+
return readdirSync(input).map((file) => join(input, file));
|
|
8
|
+
}
|
|
9
|
+
if (isFile) {
|
|
10
|
+
return [input];
|
|
11
|
+
}
|
|
12
|
+
throw new Error(`Input must be a directory or a file: ${input}`);
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=get-files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-files.js","sourceRoot":"","sources":["../../src/internal/get-files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,IAAI,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAErC,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,KAAa,EAAiB,EAAE;IACvD,MAAM,WAAW,GAAG,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACzD,MAAM,MAAM,GAAG,UAAU,CAAC,KAAK,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC;IAEnD,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO,WAAW,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-logger.d.ts","sourceRoot":"","sources":["../../src/internal/get-logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAU,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAE3E,eAAO,MAAM,SAAS,GAAI,SAAS,OAAO,GAAG,aAAa,GAAG,SAAS,KAAG,OAYxE,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Logger } from "@lindorm/logger";
|
|
2
|
+
export const getLogger = (options) => {
|
|
3
|
+
const scope = ["Typewriter"];
|
|
4
|
+
if (!options) {
|
|
5
|
+
return new Logger({ scope });
|
|
6
|
+
}
|
|
7
|
+
if (options.__instanceof === "Logger") {
|
|
8
|
+
return options.child(scope);
|
|
9
|
+
}
|
|
10
|
+
return new Logger({ ...options, scope });
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=get-logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-logger.js","sourceRoot":"","sources":["../../src/internal/get-logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,MAAM,EAAsB,MAAM,iBAAiB,CAAC;AAE3E,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,OAA4C,EAAW,EAAE;IACjF,MAAM,KAAK,GAAG,CAAC,YAAY,CAAC,CAAC;IAE7B,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,IAAI,MAAM,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,MAAM,CAAC,EAAE,GAAG,OAAO,EAAE,KAAK,EAAmB,CAAC,CAAC;AAC5D,CAAC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ILogger } from "@lindorm/logger";
|
|
2
|
-
import { SerializedRenderResult } from "quicktype-core";
|
|
1
|
+
import type { ILogger } from "@lindorm/logger";
|
|
2
|
+
import { type SerializedRenderResult } from "quicktype-core";
|
|
3
3
|
type Options = {
|
|
4
4
|
logger: ILogger;
|
|
5
5
|
output?: "typescript" | "typescript-zod";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-types.d.ts","sourceRoot":"","sources":["../../src/internal/get-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAIL,KAAK,sBAAsB,EAC5B,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,20 @@
|
|
|
1
|
+
import { InputData, jsonInputForTargetLanguage, quicktype, } from "quicktype-core";
|
|
2
|
+
export const getTypes = async (options) => {
|
|
3
|
+
const lang = options.output ?? "typescript";
|
|
4
|
+
const jsonInput = jsonInputForTargetLanguage(lang);
|
|
5
|
+
await jsonInput.addSource({
|
|
6
|
+
name: options.typeName,
|
|
7
|
+
samples: options.samples,
|
|
8
|
+
});
|
|
9
|
+
const inputData = new InputData();
|
|
10
|
+
inputData.addInput(jsonInput);
|
|
11
|
+
options.logger.verbose(`Generating types for [ ${options.typeName} ] in [ ${lang} ]`);
|
|
12
|
+
return await quicktype({
|
|
13
|
+
inputData,
|
|
14
|
+
indentation: " ",
|
|
15
|
+
lang,
|
|
16
|
+
alphabetizeProperties: true,
|
|
17
|
+
rendererOptions: { "just-types": "true" },
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=get-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-types.js","sourceRoot":"","sources":["../../src/internal/get-types.ts"],"names":[],"mappings":"AACA,OAAO,EACL,SAAS,EACT,0BAA0B,EAC1B,SAAS,GAEV,MAAM,gBAAgB,CAAC;AASxB,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,EAAE,OAAgB,EAAmC,EAAE;IAClF,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,IAAI,YAAY,CAAC;IAE5C,MAAM,SAAS,GAAG,0BAA0B,CAAC,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,SAAS,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,SAAS,CAAC;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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/internal/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/internal/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-samples.d.ts","sourceRoot":"","sources":["../../src/internal/load-samples.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAM/C,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"}
|
|
@@ -1,23 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const js_yaml_1 = require("js-yaml");
|
|
6
|
-
const path_1 = require("path");
|
|
7
|
-
const get_files_1 = require("./get-files");
|
|
1
|
+
import { existsSync, readFileSync } from "fs";
|
|
2
|
+
import { load } from "js-yaml";
|
|
3
|
+
import { extname } from "path";
|
|
4
|
+
import { getFiles } from "./get-files.js";
|
|
8
5
|
const loadJsonSample = (file) => JSON.stringify(require(file));
|
|
9
|
-
const loadYamlSample = (file) => JSON.stringify(
|
|
10
|
-
const loadSamples = (options) => {
|
|
6
|
+
const loadYamlSample = (file) => JSON.stringify(load(readFileSync(file, "utf-8")));
|
|
7
|
+
export const loadSamples = (options) => {
|
|
11
8
|
const samples = options.samples ?? [];
|
|
12
9
|
for (const input of options.input) {
|
|
13
10
|
options.logger.verbose(`Loading samples from input [ ${input} ]`);
|
|
14
|
-
if (!
|
|
11
|
+
if (!existsSync(input)) {
|
|
15
12
|
throw new Error(`${input} does not exist`);
|
|
16
13
|
}
|
|
17
|
-
const files =
|
|
14
|
+
const files = getFiles(input);
|
|
18
15
|
for (const file of files) {
|
|
19
16
|
options.logger.verbose(`Loading sample from file [ ${file} ]`);
|
|
20
|
-
const ext =
|
|
17
|
+
const ext = extname(file);
|
|
21
18
|
if (ext === ".json") {
|
|
22
19
|
samples.push(loadJsonSample(file));
|
|
23
20
|
continue;
|
|
@@ -31,5 +28,4 @@ const loadSamples = (options) => {
|
|
|
31
28
|
options.logger.verbose(`Loaded [ ${samples.length} ] samples`);
|
|
32
29
|
return samples;
|
|
33
30
|
};
|
|
34
|
-
exports.loadSamples = loadSamples;
|
|
35
31
|
//# sourceMappingURL=load-samples.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-samples.js","sourceRoot":"","sources":["../../src/internal/load-samples.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAQ1C,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,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;AAEpD,MAAM,CAAC,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,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,iBAAiB,CAAC,CAAC;QAC7C,CAAC;QAED,MAAM,KAAK,GAAG,QAAQ,CAAC,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,OAAO,CAAC,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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write-lines-to-file.d.ts","sourceRoot":"","sources":["../../src/internal/write-lines-to-file.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAI/C,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,25 @@
|
|
|
1
|
+
import { createWriteStream, existsSync, mkdirSync } from "fs";
|
|
2
|
+
import { join } from "path";
|
|
3
|
+
export const writeLinesToFile = (options) => {
|
|
4
|
+
return new Promise((resolve, reject) => {
|
|
5
|
+
const file = join(options.writeToDirectory, `${options.fileName}.typewriter.ts`);
|
|
6
|
+
options.logger.verbose(`Writing type to file [ ${file} ]`);
|
|
7
|
+
if (!existsSync(options.writeToDirectory)) {
|
|
8
|
+
mkdirSync(options.writeToDirectory);
|
|
9
|
+
}
|
|
10
|
+
const stream = createWriteStream(file);
|
|
11
|
+
stream.on("finish", () => {
|
|
12
|
+
options.logger.verbose(`Type written to file [ ${file} ]`);
|
|
13
|
+
resolve();
|
|
14
|
+
});
|
|
15
|
+
stream.on("error", (err) => {
|
|
16
|
+
options.logger.error(`Failed to write type to file [ ${file} ]`, err);
|
|
17
|
+
reject(err);
|
|
18
|
+
});
|
|
19
|
+
for (const line of options.lines) {
|
|
20
|
+
stream.write(line + "\n");
|
|
21
|
+
}
|
|
22
|
+
stream.end();
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=write-lines-to-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write-lines-to-file.js","sourceRoot":"","sources":["../../src/internal/write-lines-to-file.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAS5B,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,OAAgB,EAAiB,EAAE;IAClE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,IAAI,GAAG,IAAI,CAAC,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,UAAU,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAE,CAAC;YAC1C,SAAS,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;QACtC,CAAC;QAED,MAAM,MAAM,GAAG,iBAAiB,CAAC,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"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./types";
|
|
1
|
+
export * from "./types.js";
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
|
package/dist/types/index.js
CHANGED
|
@@ -1,18 +1,2 @@
|
|
|
1
|
-
|
|
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);
|
|
1
|
+
export * from "./types.js";
|
|
18
2
|
//# sourceMappingURL=index.js.map
|
package/dist/types/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
|
package/dist/types/types.js
CHANGED
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./typewriter";
|
|
1
|
+
export * from "./typewriter.js";
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
|
package/dist/utils/index.js
CHANGED
|
@@ -1,18 +1,2 @@
|
|
|
1
|
-
|
|
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);
|
|
1
|
+
export * from "./typewriter.js";
|
|
18
2
|
//# sourceMappingURL=index.js.map
|
package/dist/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
|
|
@@ -1 +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;
|
|
1
|
+
{"version":3,"file":"typewriter.d.ts","sourceRoot":"","sources":["../../src/utils/typewriter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAG9D,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"}
|
package/dist/utils/typewriter.js
CHANGED
|
@@ -1,22 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const typewriter = async (options) => {
|
|
6
|
-
const logger = (0, private_1.getLogger)(options.logger);
|
|
7
|
-
const samples = (0, private_1.loadSamples)({
|
|
1
|
+
import { getLogger, getTypes, loadSamples, writeLinesToFile } from "../internal/index.js";
|
|
2
|
+
export const typewriter = async (options) => {
|
|
3
|
+
const logger = getLogger(options.logger);
|
|
4
|
+
const samples = loadSamples({
|
|
8
5
|
input: options.input,
|
|
9
6
|
logger,
|
|
10
7
|
samples: options.samples,
|
|
11
8
|
});
|
|
12
|
-
const { lines } = await
|
|
9
|
+
const { lines } = await getTypes({
|
|
13
10
|
logger,
|
|
14
11
|
output: options.output,
|
|
15
12
|
samples,
|
|
16
13
|
typeName: options.typeName,
|
|
17
14
|
});
|
|
18
15
|
if (options.writeToDirectory) {
|
|
19
|
-
await
|
|
16
|
+
await writeLinesToFile({
|
|
20
17
|
fileName: options.fileName ?? options.typeName,
|
|
21
18
|
lines,
|
|
22
19
|
logger,
|
|
@@ -25,5 +22,4 @@ const typewriter = async (options) => {
|
|
|
25
22
|
}
|
|
26
23
|
return lines.join("\n");
|
|
27
24
|
};
|
|
28
|
-
exports.typewriter = typewriter;
|
|
29
25
|
//# sourceMappingURL=typewriter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typewriter.js","sourceRoot":"","sources":["../../src/utils/typewriter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"typewriter.js","sourceRoot":"","sources":["../../src/utils/typewriter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAY1F,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,EAAE,OAAgB,EAAmB,EAAE;IACpE,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAEzC,MAAM,OAAO,GAAG,WAAW,CAAC;QAC1B,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,MAAM;QACN,OAAO,EAAE,OAAO,CAAC,OAAO;KACzB,CAAC,CAAC;IAEH,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,QAAQ,CAAC;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,gBAAgB,CAAC;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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lindorm/typewriter",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"license": "AGPL-3.0-or-later",
|
|
5
5
|
"author": "Jonn Nilsson",
|
|
6
6
|
"repository": {
|
|
@@ -11,15 +11,15 @@
|
|
|
11
11
|
"publishConfig": {
|
|
12
12
|
"access": "public"
|
|
13
13
|
},
|
|
14
|
-
"
|
|
14
|
+
"type": "module",
|
|
15
15
|
"typings": "dist/index.d.ts",
|
|
16
16
|
"scripts": {
|
|
17
17
|
"build": "rimraf dist && tsc -b ./tsconfig.build.json && chmod +x dist/cli.js",
|
|
18
18
|
"example": "ts-node example",
|
|
19
19
|
"prettier": "prettier --write ./src/*",
|
|
20
|
-
"test": "
|
|
21
|
-
"test:
|
|
22
|
-
"test:watch": "
|
|
20
|
+
"test": "vitest run",
|
|
21
|
+
"test:unit": "vitest run --exclude '**/*.integration.test.ts'",
|
|
22
|
+
"test:watch": "vitest",
|
|
23
23
|
"typecheck": "tsc",
|
|
24
24
|
"typecheck:watch": "tsc --watch",
|
|
25
25
|
"update": "ncu -i",
|
|
@@ -30,12 +30,21 @@
|
|
|
30
30
|
"typewriter": "dist/cli.js"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@lindorm/case": "^0.
|
|
34
|
-
"@lindorm/is": "^0.
|
|
35
|
-
"@lindorm/logger": "^0.
|
|
33
|
+
"@lindorm/case": "^0.2.0",
|
|
34
|
+
"@lindorm/is": "^0.2.0",
|
|
35
|
+
"@lindorm/logger": "^0.6.0",
|
|
36
36
|
"commander": "^14.0.3",
|
|
37
37
|
"js-yaml": "^4.1.1",
|
|
38
38
|
"quicktype-core": "^23.2.6"
|
|
39
39
|
},
|
|
40
|
-
"
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"zod": "^4.3.6"
|
|
42
|
+
},
|
|
43
|
+
"exports": {
|
|
44
|
+
".": {
|
|
45
|
+
"types": "./dist/index.d.ts",
|
|
46
|
+
"default": "./dist/index.js"
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"gitHead": "a2b0a53295aebda806b4057f34707e8583570265"
|
|
41
50
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["./src/cli.ts","./src/index.ts","./src/
|
|
1
|
+
{"root":["./src/cli.ts","./src/index.ts","./src/internal/absolute-path.ts","./src/internal/get-files.ts","./src/internal/get-logger.ts","./src/internal/get-types.ts","./src/internal/index.ts","./src/internal/load-samples.ts","./src/internal/write-lines-to-file.ts","./src/types/index.ts","./src/types/types.ts","./src/utils/index.ts","./src/utils/typewriter.ts"],"version":"6.0.3"}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,21 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,18 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,16 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,24 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,23 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,29 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
File without changes
|
|
File without changes
|