@vaadin/hilla-generator-cli 24.4.0-alpha1
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/.lintstagedrc.js +6 -0
- package/GeneratorIO.d.ts +33 -0
- package/GeneratorIO.d.ts.map +1 -0
- package/GeneratorIO.js +126 -0
- package/GeneratorIO.js.map +7 -0
- package/GeneratorIOException.d.ts +4 -0
- package/GeneratorIOException.d.ts.map +1 -0
- package/GeneratorIOException.js +9 -0
- package/GeneratorIOException.js.map +7 -0
- package/LICENSE +201 -0
- package/README.md +1 -0
- package/bin/index.js +2 -0
- package/index.d.ts +2 -0
- package/index.d.ts.map +1 -0
- package/index.js +54 -0
- package/index.js.map +7 -0
- package/package.json +75 -0
- package/utils.d.ts +3 -0
- package/utils.d.ts.map +1 -0
- package/utils.js +19 -0
- package/utils.js.map +7 -0
package/.lintstagedrc.js
ADDED
package/GeneratorIO.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type File from '@vaadin/hilla-generator-core/File.js';
|
|
2
|
+
import { type PluginConstructor } from '@vaadin/hilla-generator-core/Plugin.js';
|
|
3
|
+
import type LoggerFactory from '@vaadin/hilla-generator-utils/LoggerFactory.js';
|
|
4
|
+
export default class GeneratorIO {
|
|
5
|
+
#private;
|
|
6
|
+
static readonly INDEX_FILENAME = "generated-file-list.txt";
|
|
7
|
+
['constructor']: typeof GeneratorIO;
|
|
8
|
+
readonly cwd: string;
|
|
9
|
+
constructor(outputDir: string, logger: LoggerFactory);
|
|
10
|
+
/**
|
|
11
|
+
* Gets the list of files generated the last time. The info is found in {@link INDEX_FILENAME}.
|
|
12
|
+
* @returns a list of files that have been generated by us
|
|
13
|
+
*/
|
|
14
|
+
getGeneratedFiles(): Promise<Set<string>>;
|
|
15
|
+
/**
|
|
16
|
+
* Cleans the output directory by keeping the generated files and deleting the rest of the given files.
|
|
17
|
+
*
|
|
18
|
+
* @returns a set containing deleted filenames
|
|
19
|
+
*/
|
|
20
|
+
cleanOutputDir(generatedFiles: string[], filesToDelete: Set<string>): Promise<Set<string>>;
|
|
21
|
+
createFileIndex(filenames: string[]): Promise<void>;
|
|
22
|
+
writeGeneratedFiles(files: readonly File[]): Promise<string[]>;
|
|
23
|
+
/**
|
|
24
|
+
* Checks that a file exists (is visible)
|
|
25
|
+
* @param path - the file path to check
|
|
26
|
+
*/
|
|
27
|
+
static exists(path: string): Promise<boolean>;
|
|
28
|
+
loadPlugin(modulePath: string): Promise<PluginConstructor>;
|
|
29
|
+
resolveGeneratedFile(filename: string): string;
|
|
30
|
+
read(path: string): Promise<string>;
|
|
31
|
+
write(filename: string, content: string): Promise<void>;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=GeneratorIO.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GeneratorIO.d.ts","sourceRoot":"","sources":["src/GeneratorIO.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,IAAI,MAAM,sCAAsC,CAAC;AAC7D,OAAe,EAAE,KAAK,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AACxF,OAAO,KAAK,aAAa,MAAM,gDAAgD,CAAC;AAShF,MAAM,CAAC,OAAO,OAAO,WAAW;;IAC9B,MAAM,CAAC,QAAQ,CAAC,cAAc,6BAA6B;IACnD,CAAC,aAAa,CAAC,EAAE,OAAO,WAAW,CAAC;IAC5C,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;gBAIT,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa;IAQpD;;;OAGG;IACG,iBAAiB,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAiB/C;;;;OAIG;IACG,cAAc,CAAC,cAAc,EAAE,MAAM,EAAE,EAAE,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAyB1F,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAInD,mBAAmB,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAuBpE;;;OAGG;WAEU,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAS7C,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAYhE,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAIxC,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAKnC,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAO9D"}
|
package/GeneratorIO.js
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { constants } from "node:fs";
|
|
2
|
+
import { access, mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
3
|
+
import { createRequire } from "node:module";
|
|
4
|
+
import { dirname, isAbsolute, join, resolve } from "node:path";
|
|
5
|
+
import { pathToFileURL } from "node:url";
|
|
6
|
+
import Plugin, {} from "@vaadin/hilla-generator-core/Plugin.js";
|
|
7
|
+
import GeneratorIOException from "./GeneratorIOException.js";
|
|
8
|
+
const require2 = createRequire(import.meta.url);
|
|
9
|
+
class GeneratorIO {
|
|
10
|
+
static INDEX_FILENAME = "generated-file-list.txt";
|
|
11
|
+
cwd;
|
|
12
|
+
#logger;
|
|
13
|
+
#outputDir;
|
|
14
|
+
constructor(outputDir, logger) {
|
|
15
|
+
this.cwd = process.cwd();
|
|
16
|
+
this.#outputDir = isAbsolute(outputDir) ? outputDir : resolve(this.cwd, outputDir);
|
|
17
|
+
this.#logger = logger;
|
|
18
|
+
logger.global.debug(`Output directory: ${this.#outputDir}`);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Gets the list of files generated the last time. The info is found in {@link INDEX_FILENAME}.
|
|
22
|
+
* @returns a list of files that have been generated by us
|
|
23
|
+
*/
|
|
24
|
+
async getGeneratedFiles() {
|
|
25
|
+
const files = /* @__PURE__ */ new Set();
|
|
26
|
+
try {
|
|
27
|
+
const indexFileContents = await this.read(this.resolveGeneratedFile(this.constructor.INDEX_FILENAME));
|
|
28
|
+
indexFileContents.split("\n").filter((n) => n.length).forEach((fileName) => files.add(fileName));
|
|
29
|
+
} catch (e) {
|
|
30
|
+
if (!(e instanceof Error && "code" in e && e.code === "ENOENT")) {
|
|
31
|
+
throw e;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return files;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Cleans the output directory by keeping the generated files and deleting the rest of the given files.
|
|
38
|
+
*
|
|
39
|
+
* @returns a set containing deleted filenames
|
|
40
|
+
*/
|
|
41
|
+
async cleanOutputDir(generatedFiles, filesToDelete) {
|
|
42
|
+
this.#logger.global.debug(`Cleaning ${this.#outputDir}`);
|
|
43
|
+
await mkdir(this.#outputDir, { recursive: true });
|
|
44
|
+
generatedFiles.forEach((filename) => {
|
|
45
|
+
this.#logger.global.debug(`File ${filename} was re-written, should not delete it`);
|
|
46
|
+
filesToDelete.delete(filename);
|
|
47
|
+
});
|
|
48
|
+
const deletedFiles = new Set(
|
|
49
|
+
await Promise.all(
|
|
50
|
+
[...filesToDelete].map(async (filename) => {
|
|
51
|
+
const resolved = this.resolveGeneratedFile(filename);
|
|
52
|
+
if (await GeneratorIO.exists(resolved)) {
|
|
53
|
+
this.#logger.global.debug(`Deleting file ${filename}.`);
|
|
54
|
+
await rm(resolved);
|
|
55
|
+
}
|
|
56
|
+
return filename;
|
|
57
|
+
})
|
|
58
|
+
)
|
|
59
|
+
);
|
|
60
|
+
return deletedFiles;
|
|
61
|
+
}
|
|
62
|
+
async createFileIndex(filenames) {
|
|
63
|
+
await this.write(this.constructor.INDEX_FILENAME, filenames.join("\n"));
|
|
64
|
+
}
|
|
65
|
+
async writeGeneratedFiles(files) {
|
|
66
|
+
await this.createFileIndex(files.map((file) => file.name));
|
|
67
|
+
this.#logger.global.debug(`created index`);
|
|
68
|
+
return Promise.all(
|
|
69
|
+
files.map(async (file) => {
|
|
70
|
+
const newFileContent = await file.text();
|
|
71
|
+
let oldFileContent;
|
|
72
|
+
try {
|
|
73
|
+
oldFileContent = await this.read(this.resolveGeneratedFile(file.name));
|
|
74
|
+
} catch (_e) {
|
|
75
|
+
}
|
|
76
|
+
if (newFileContent !== oldFileContent) {
|
|
77
|
+
this.#logger.global.debug(`writing file ${file.name}`);
|
|
78
|
+
await this.write(file.name, await file.text());
|
|
79
|
+
} else {
|
|
80
|
+
this.#logger.global.debug(`File ${file.name} stayed the same`);
|
|
81
|
+
}
|
|
82
|
+
return file.name;
|
|
83
|
+
})
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Checks that a file exists (is visible)
|
|
88
|
+
* @param path - the file path to check
|
|
89
|
+
*/
|
|
90
|
+
// eslint-disable-next-line class-methods-use-this
|
|
91
|
+
static async exists(path) {
|
|
92
|
+
try {
|
|
93
|
+
await access(path, constants.F_OK);
|
|
94
|
+
return true;
|
|
95
|
+
} catch {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
async loadPlugin(modulePath) {
|
|
100
|
+
this.#logger.global.debug(`Loading plugin: ${modulePath}`);
|
|
101
|
+
const module = await import(pathToFileURL(require2.resolve(modulePath)).toString());
|
|
102
|
+
const ctr = module.default;
|
|
103
|
+
if (!Object.prototype.isPrototypeOf.call(Plugin, ctr)) {
|
|
104
|
+
throw new GeneratorIOException(`Plugin '${modulePath}' is not an instance of a Plugin class`);
|
|
105
|
+
}
|
|
106
|
+
return ctr;
|
|
107
|
+
}
|
|
108
|
+
resolveGeneratedFile(filename) {
|
|
109
|
+
return resolve(this.#outputDir, filename);
|
|
110
|
+
}
|
|
111
|
+
async read(path) {
|
|
112
|
+
this.#logger.global.debug(`Reading file: ${path}`);
|
|
113
|
+
return readFile(path, "utf8");
|
|
114
|
+
}
|
|
115
|
+
async write(filename, content) {
|
|
116
|
+
const filePath = join(this.#outputDir, filename);
|
|
117
|
+
this.#logger.global.debug(`Writing file ${filePath}.`);
|
|
118
|
+
const dir = dirname(filePath);
|
|
119
|
+
await mkdir(dir, { recursive: true });
|
|
120
|
+
return writeFile(filePath, content, "utf-8");
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
export {
|
|
124
|
+
GeneratorIO as default
|
|
125
|
+
};
|
|
126
|
+
//# sourceMappingURL=GeneratorIO.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["src/GeneratorIO.ts"],
|
|
4
|
+
"sourcesContent": ["import { constants } from 'node:fs';\nimport { access, mkdir, readFile, rm, writeFile } from 'node:fs/promises';\nimport { createRequire } from 'node:module';\nimport { dirname, isAbsolute, join, resolve } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport type File from '@vaadin/hilla-generator-core/File.js';\nimport Plugin, { type PluginConstructor } from '@vaadin/hilla-generator-core/Plugin.js';\nimport type LoggerFactory from '@vaadin/hilla-generator-utils/LoggerFactory.js';\nimport GeneratorIOException from './GeneratorIOException.js';\n\nconst require = createRequire(import.meta.url);\n\ntype PluginConstructorModule = Readonly<{\n default: PluginConstructor;\n}>;\n\nexport default class GeneratorIO {\n static readonly INDEX_FILENAME = 'generated-file-list.txt';\n declare ['constructor']: typeof GeneratorIO;\n readonly cwd: string;\n readonly #logger: LoggerFactory;\n readonly #outputDir: string;\n\n constructor(outputDir: string, logger: LoggerFactory) {\n this.cwd = process.cwd();\n this.#outputDir = isAbsolute(outputDir) ? outputDir : resolve(this.cwd, outputDir);\n this.#logger = logger;\n\n logger.global.debug(`Output directory: ${this.#outputDir}`);\n }\n\n /**\n * Gets the list of files generated the last time. The info is found in {@link INDEX_FILENAME}.\n * @returns a list of files that have been generated by us\n */\n async getGeneratedFiles(): Promise<Set<string>> {\n const files = new Set<string>();\n try {\n const indexFileContents = await this.read(this.resolveGeneratedFile(this.constructor.INDEX_FILENAME));\n indexFileContents\n .split('\\n')\n .filter((n) => n.length)\n .forEach((fileName) => files.add(fileName));\n } catch (e) {\n // non-existing file is OK, all other errors must be rethrown\n if (!(e instanceof Error && 'code' in e && e.code === 'ENOENT')) {\n throw e;\n }\n }\n return files;\n }\n\n /**\n * Cleans the output directory by keeping the generated files and deleting the rest of the given files.\n *\n * @returns a set containing deleted filenames\n */\n async cleanOutputDir(generatedFiles: string[], filesToDelete: Set<string>): Promise<Set<string>> {\n this.#logger.global.debug(`Cleaning ${this.#outputDir}`);\n await mkdir(this.#outputDir, { recursive: true });\n\n generatedFiles.forEach((filename) => {\n this.#logger.global.debug(`File ${filename} was re-written, should not delete it`);\n filesToDelete.delete(filename);\n });\n\n const deletedFiles = new Set(\n await Promise.all(\n [...filesToDelete].map(async (filename) => {\n const resolved = this.resolveGeneratedFile(filename);\n if (await GeneratorIO.exists(resolved)) {\n this.#logger.global.debug(`Deleting file ${filename}.`);\n await rm(resolved);\n }\n return filename;\n }),\n ),\n );\n\n return deletedFiles;\n }\n\n async createFileIndex(filenames: string[]): Promise<void> {\n await this.write(this.constructor.INDEX_FILENAME, filenames.join('\\n'));\n }\n\n async writeGeneratedFiles(files: readonly File[]): Promise<string[]> {\n await this.createFileIndex(files.map((file) => file.name));\n this.#logger.global.debug(`created index`);\n\n return Promise.all(\n files.map(async (file) => {\n const newFileContent = await file.text();\n let oldFileContent;\n try {\n oldFileContent = await this.read(this.resolveGeneratedFile(file.name));\n } catch (_e) {}\n\n if (newFileContent !== oldFileContent) {\n this.#logger.global.debug(`writing file ${file.name}`);\n await this.write(file.name, await file.text());\n } else {\n this.#logger.global.debug(`File ${file.name} stayed the same`);\n }\n return file.name;\n }),\n );\n }\n\n /**\n * Checks that a file exists (is visible)\n * @param path - the file path to check\n */\n // eslint-disable-next-line class-methods-use-this\n static async exists(path: string): Promise<boolean> {\n try {\n await access(path, constants.F_OK);\n return true;\n } catch {\n return false;\n }\n }\n\n async loadPlugin(modulePath: string): Promise<PluginConstructor> {\n this.#logger.global.debug(`Loading plugin: ${modulePath}`);\n const module: PluginConstructorModule = await import(pathToFileURL(require.resolve(modulePath)).toString());\n const ctr: PluginConstructor = module.default;\n\n if (!Object.prototype.isPrototypeOf.call(Plugin, ctr)) {\n throw new GeneratorIOException(`Plugin '${modulePath}' is not an instance of a Plugin class`);\n }\n\n return ctr;\n }\n\n resolveGeneratedFile(filename: string): string {\n return resolve(this.#outputDir, filename);\n }\n\n async read(path: string): Promise<string> {\n this.#logger.global.debug(`Reading file: ${path}`);\n return readFile(path, 'utf8');\n }\n\n async write(filename: string, content: string): Promise<void> {\n const filePath = join(this.#outputDir, filename);\n this.#logger.global.debug(`Writing file ${filePath}.`);\n const dir = dirname(filePath);\n await mkdir(dir, { recursive: true });\n return writeFile(filePath, content, 'utf-8');\n }\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["require"]
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GeneratorIOException.d.ts","sourceRoot":"","sources":["src/GeneratorIOException.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,OAAO,oBAAqB,SAAQ,KAAK;gBACzC,OAAO,EAAE,MAAM;CAG5B"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["src/GeneratorIOException.ts"],
|
|
4
|
+
"sourcesContent": ["export default class GeneratorIOException extends Error {\n constructor(message: string) {\n super(`[GeneratorIOException]: ${message}`);\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,MAAO,6BAA2C,MAAM;AAAA,EACtD,YAAY,SAAiB;AAC3B,UAAM,2BAA2B,OAAO,EAAE;AAAA,EAC5C;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Hilla TypeScript Generator
|
package/bin/index.js
ADDED
package/index.d.ts
ADDED
package/index.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":""}
|
package/index.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import Generator from "@vaadin/hilla-generator-core/Generator.js";
|
|
2
|
+
import LoggerFactory from "@vaadin/hilla-generator-utils/LoggerFactory.js";
|
|
3
|
+
import meow from "meow";
|
|
4
|
+
import GeneratorIO from "./GeneratorIO.js";
|
|
5
|
+
import { processInput } from "./utils.js";
|
|
6
|
+
const {
|
|
7
|
+
flags: { outputDir, plugin: plugins, verbose },
|
|
8
|
+
input: [input]
|
|
9
|
+
} = meow(
|
|
10
|
+
`
|
|
11
|
+
Usage:
|
|
12
|
+
tsgen
|
|
13
|
+
(will read JSON from stdin)
|
|
14
|
+
tsgen <OpenAPI JSON string>
|
|
15
|
+
tsgen <OpenAPI file path>
|
|
16
|
+
|
|
17
|
+
Options:
|
|
18
|
+
-h, --help Show this screen
|
|
19
|
+
-o, --output-dir Output directory
|
|
20
|
+
-p, --plugin <path> Use the plugin loadable by <path>.
|
|
21
|
+
--version Show the app version
|
|
22
|
+
`,
|
|
23
|
+
{
|
|
24
|
+
flags: {
|
|
25
|
+
outputDir: {
|
|
26
|
+
default: "frontend/generated",
|
|
27
|
+
shortFlag: "o",
|
|
28
|
+
type: "string"
|
|
29
|
+
},
|
|
30
|
+
plugin: {
|
|
31
|
+
default: [],
|
|
32
|
+
isMultiple: true,
|
|
33
|
+
shortFlag: "p",
|
|
34
|
+
type: "string"
|
|
35
|
+
},
|
|
36
|
+
verbose: {
|
|
37
|
+
shortFlag: "v",
|
|
38
|
+
type: "boolean"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
importMeta: import.meta
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
const logger = new LoggerFactory({ verbose });
|
|
45
|
+
const io = new GeneratorIO(outputDir, logger);
|
|
46
|
+
const resolvedPlugins = await Promise.all(
|
|
47
|
+
Array.from(new Set(plugins), async (pluginPath) => io.loadPlugin(pluginPath))
|
|
48
|
+
);
|
|
49
|
+
const generator = new Generator(resolvedPlugins, { logger, outputDir });
|
|
50
|
+
const files = await generator.process(await processInput(io, input));
|
|
51
|
+
const filesToDelete = await io.getGeneratedFiles();
|
|
52
|
+
const generatedFiles = await io.writeGeneratedFiles(files);
|
|
53
|
+
await io.cleanOutputDir(generatedFiles, filesToDelete);
|
|
54
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["src/index.ts"],
|
|
4
|
+
"sourcesContent": ["import Generator from '@vaadin/hilla-generator-core/Generator.js';\nimport LoggerFactory from '@vaadin/hilla-generator-utils/LoggerFactory.js';\nimport meow from 'meow';\nimport GeneratorIO from './GeneratorIO.js';\nimport { processInput } from './utils.js';\n\nconst {\n flags: { outputDir, plugin: plugins, verbose },\n input: [input],\n} = meow(\n `\nUsage:\n tsgen\n (will read JSON from stdin)\n tsgen <OpenAPI JSON string>\n tsgen <OpenAPI file path>\n\nOptions:\n -h, --help Show this screen\n -o, --output-dir Output directory\n -p, --plugin <path> Use the plugin loadable by <path>.\n --version Show the app version\n`,\n {\n flags: {\n outputDir: {\n default: 'frontend/generated',\n shortFlag: 'o',\n type: 'string',\n },\n plugin: {\n default: [],\n isMultiple: true,\n shortFlag: 'p',\n type: 'string',\n },\n verbose: {\n shortFlag: 'v',\n type: 'boolean',\n },\n },\n importMeta: import.meta,\n },\n);\n\nconst logger = new LoggerFactory({ verbose });\n\nconst io = new GeneratorIO(outputDir, logger);\n\nconst resolvedPlugins = await Promise.all(\n Array.from(new Set(plugins), async (pluginPath) => io.loadPlugin(pluginPath)),\n);\nconst generator = new Generator(resolvedPlugins, { logger, outputDir });\n\nconst files = await generator.process(await processInput(io, input));\nconst filesToDelete = await io.getGeneratedFiles();\nconst generatedFiles = await io.writeGeneratedFiles(files);\n\nawait io.cleanOutputDir(generatedFiles, filesToDelete);\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,eAAe;AACtB,OAAO,mBAAmB;AAC1B,OAAO,UAAU;AACjB,OAAO,iBAAiB;AACxB,SAAS,oBAAoB;AAE7B,MAAM;AAAA,EACJ,OAAO,EAAE,WAAW,QAAQ,SAAS,QAAQ;AAAA,EAC7C,OAAO,CAAC,KAAK;AACf,IAAI;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaA;AAAA,IACE,OAAO;AAAA,MACL,WAAW;AAAA,QACT,SAAS;AAAA,QACT,WAAW;AAAA,QACX,MAAM;AAAA,MACR;AAAA,MACA,QAAQ;AAAA,QACN,SAAS,CAAC;AAAA,QACV,YAAY;AAAA,QACZ,WAAW;AAAA,QACX,MAAM;AAAA,MACR;AAAA,MACA,SAAS;AAAA,QACP,WAAW;AAAA,QACX,MAAM;AAAA,MACR;AAAA,IACF;AAAA,IACA,YAAY;AAAA,EACd;AACF;AAEA,MAAM,SAAS,IAAI,cAAc,EAAE,QAAQ,CAAC;AAE5C,MAAM,KAAK,IAAI,YAAY,WAAW,MAAM;AAE5C,MAAM,kBAAkB,MAAM,QAAQ;AAAA,EACpC,MAAM,KAAK,IAAI,IAAI,OAAO,GAAG,OAAO,eAAe,GAAG,WAAW,UAAU,CAAC;AAC9E;AACA,MAAM,YAAY,IAAI,UAAU,iBAAiB,EAAE,QAAQ,UAAU,CAAC;AAEtE,MAAM,QAAQ,MAAM,UAAU,QAAQ,MAAM,aAAa,IAAI,KAAK,CAAC;AACnE,MAAM,gBAAgB,MAAM,GAAG,kBAAkB;AACjD,MAAM,iBAAiB,MAAM,GAAG,oBAAoB,KAAK;AAEzD,MAAM,GAAG,eAAe,gBAAgB,aAAa;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vaadin/hilla-generator-cli",
|
|
3
|
+
"version": "24.4.0-alpha1",
|
|
4
|
+
"description": "A Hilla tool to generate TypeScript code from the OpenAPI document",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">= 16.13"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"clean:build": "git clean -fx . -e .vite -e node_modules",
|
|
12
|
+
"build": "concurrently npm:build:*",
|
|
13
|
+
"build:esbuild": "tsx ../../../scripts/build.ts",
|
|
14
|
+
"build:dts": "tsc --isolatedModules -p tsconfig.build.json",
|
|
15
|
+
"build:copy": "cd src && copyfiles **/*.d.ts ..",
|
|
16
|
+
"lint": "eslint src test",
|
|
17
|
+
"lint:fix": "eslint src test --fix",
|
|
18
|
+
"test": "mocha test/**/*.spec.ts --config ../../../.mocharc.cjs",
|
|
19
|
+
"test:coverage": "c8 -c ../../../.c8rc.json npm test",
|
|
20
|
+
"typecheck": "tsc --noEmit"
|
|
21
|
+
},
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "https://github.com/vaadin/hilla.git",
|
|
25
|
+
"directory": "packages/ts/generator-cli"
|
|
26
|
+
},
|
|
27
|
+
"keywords": [
|
|
28
|
+
"hilla",
|
|
29
|
+
"typescript",
|
|
30
|
+
"generator"
|
|
31
|
+
],
|
|
32
|
+
"author": "Vaadin Ltd.",
|
|
33
|
+
"license": "Apache 2.0",
|
|
34
|
+
"bugs": {
|
|
35
|
+
"url": "https://github.com/vaadin/hilla/issues"
|
|
36
|
+
},
|
|
37
|
+
"homepage": "https://hilla.dev",
|
|
38
|
+
"files": [
|
|
39
|
+
"*.{d.ts.map,d.ts,js.map,js}"
|
|
40
|
+
],
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public"
|
|
43
|
+
},
|
|
44
|
+
"bin": {
|
|
45
|
+
"tsgen": "bin/index.js"
|
|
46
|
+
},
|
|
47
|
+
"peerDependencies": {
|
|
48
|
+
"@vaadin/hilla-generator-core": "24.4.0-alpha1"
|
|
49
|
+
},
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"@vaadin/hilla-generator-utils": "24.4.0-alpha1",
|
|
52
|
+
"get-stdin": "^9.0.0",
|
|
53
|
+
"meow": "^12.1.1"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@vaadin/hilla-generator-core": "24.4.0-alpha1",
|
|
57
|
+
"@types/chai": "^4.3.6",
|
|
58
|
+
"@types/chai-as-promised": "^7.1.6",
|
|
59
|
+
"@types/mocha": "^10.0.2",
|
|
60
|
+
"@types/node": "^20.7.1",
|
|
61
|
+
"@types/sinon": "^10.0.17",
|
|
62
|
+
"@types/sinon-chai": "^3.2.10",
|
|
63
|
+
"c8": "^8.0.1",
|
|
64
|
+
"chai": "^4.3.10",
|
|
65
|
+
"chai-as-promised": "^7.1.1",
|
|
66
|
+
"concurrently": "^8.2.1",
|
|
67
|
+
"copyfiles": "^2.4.1",
|
|
68
|
+
"mocha": "^10.2.0",
|
|
69
|
+
"pino": "^8.15.1",
|
|
70
|
+
"rimraf": "^5.0.5",
|
|
71
|
+
"sinon": "^16.0.0",
|
|
72
|
+
"sinon-chai": "^3.7.0",
|
|
73
|
+
"type-fest": "^4.3.2"
|
|
74
|
+
}
|
|
75
|
+
}
|
package/utils.d.ts
ADDED
package/utils.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["src/utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAC;AAEhD,wBAAsB,YAAY,CAAC,EAAE,EAAE,WAAW,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAgBjF"}
|
package/utils.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { isAbsolute, resolve } from "path";
|
|
2
|
+
import getStdin from "get-stdin";
|
|
3
|
+
async function processInput(io, raw) {
|
|
4
|
+
if (raw) {
|
|
5
|
+
let result = raw;
|
|
6
|
+
if (result.startsWith("'") || result.startsWith('"')) {
|
|
7
|
+
result = raw.substring(1, raw.length - 1);
|
|
8
|
+
}
|
|
9
|
+
if (result.startsWith("{")) {
|
|
10
|
+
return result;
|
|
11
|
+
}
|
|
12
|
+
return io.read(isAbsolute(result) ? result : resolve(io.cwd, result));
|
|
13
|
+
}
|
|
14
|
+
return getStdin();
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
processInput
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=utils.js.map
|
package/utils.js.map
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["src/utils.ts"],
|
|
4
|
+
"sourcesContent": ["import { isAbsolute, resolve } from 'path';\nimport getStdin from 'get-stdin';\nimport type GeneratorIO from './GeneratorIO.js';\n\nexport async function processInput(io: GeneratorIO, raw?: string): Promise<string> {\n if (raw) {\n let result = raw;\n\n if (result.startsWith(\"'\") || result.startsWith('\"')) {\n result = raw.substring(1, raw.length - 1);\n }\n\n if (result.startsWith('{')) {\n return result;\n }\n\n return io.read(isAbsolute(result) ? result : resolve(io.cwd, result));\n }\n\n return getStdin();\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,YAAY,eAAe;AACpC,OAAO,cAAc;AAGrB,eAAsB,aAAa,IAAiB,KAA+B;AACjF,MAAI,KAAK;AACP,QAAI,SAAS;AAEb,QAAI,OAAO,WAAW,GAAG,KAAK,OAAO,WAAW,GAAG,GAAG;AACpD,eAAS,IAAI,UAAU,GAAG,IAAI,SAAS,CAAC;AAAA,IAC1C;AAEA,QAAI,OAAO,WAAW,GAAG,GAAG;AAC1B,aAAO;AAAA,IACT;AAEA,WAAO,GAAG,KAAK,WAAW,MAAM,IAAI,SAAS,QAAQ,GAAG,KAAK,MAAM,CAAC;AAAA,EACtE;AAEA,SAAO,SAAS;AAClB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|