@ts-for-gir/generator-typescript 3.0.0 → 3.0.2
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/lib/index.d.ts +2 -0
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/lib/package-data-parser.d.ts +13 -0
- package/lib/package-data-parser.js +68 -0
- package/lib/package-data-parser.js.map +1 -0
- package/lib/template-processor.d.ts +113 -0
- package/lib/template-processor.js +249 -0
- package/lib/template-processor.js.map +1 -0
- package/lib/type-definition-generator.d.ts +4 -2
- package/lib/type-definition-generator.js +3 -1
- package/lib/type-definition-generator.js.map +1 -1
- package/lib/utils.d.ts +2 -0
- package/lib/utils.js +7 -0
- package/lib/utils.js.map +1 -0
- package/package.json +9 -8
- package/packages.xml +1213 -0
- package/templates/README.md +102 -0
- package/templates/cogl-2-0.d.ts +0 -0
- package/templates/gjs/README-GJS.md +109 -0
- package/templates/gjs/ambient.d.ts +59 -0
- package/templates/gjs/cairo-1.0.d.ts +9 -0
- package/templates/gjs/cairo.d.ts +8 -0
- package/templates/gjs/cairo.js +11 -0
- package/templates/gjs/gettext.d.ts +41 -0
- package/templates/gjs/gettext.js +11 -0
- package/templates/gjs/gio-2.0.d.ts +101 -0
- package/templates/gjs/gjs.d.ts +757 -0
- package/templates/gjs/gjs.js +10 -0
- package/templates/gjs/gobject-2.0.d.ts +238 -0
- package/templates/gjs/module-ambient.d.ts +31 -0
- package/templates/gjs/module-import.d.ts +33 -0
- package/templates/gjs/module.append.d.ts +1 -0
- package/templates/gjs/module.d.ts +12 -0
- package/templates/gjs/module.js +17 -0
- package/templates/gjs/system.d.ts +32 -0
- package/templates/gjs/system.js +11 -0
- package/templates/gjs/tsconfig.alias.json +12 -0
- package/templates/granite-1.0.d.ts +7 -0
- package/templates/granite-7.0.d.ts +7 -0
- package/templates/gstbase-0.10.d.ts +5 -0
- package/templates/node-gtk/README-NODE-GTK.md +71 -0
- package/templates/node-gtk/ambient.d.ts +19 -0
- package/templates/node-gtk/gobject-2.0.d.ts +57 -0
- package/templates/node-gtk/module-import.d.ts +29 -0
- package/templates/node-gtk/module.append.d.ts +1 -0
- package/templates/node-gtk/module.d.ts +10 -0
- package/templates/node-gtk/module.js +18 -0
- package/templates/node-gtk/node-gtk.d.ts +25 -0
- package/templates/node-gtk/node-gtk.js +7 -0
- package/templates/package.json +177 -0
- package/templates/rygelserver-2.6.d.ts +3 -0
- package/templates/tsconfig.doc.json +30 -0
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gCAAgC,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAA;AACvC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,0BAA0B,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Logger } from '@ts-for-gir/lib';
|
|
2
|
+
import type { GenerateConfig, PackageSectionParsed, PackageDataParsed, PackageData } from '@ts-for-gir/lib';
|
|
3
|
+
export declare class PackageDataParser {
|
|
4
|
+
protected readonly config: GenerateConfig;
|
|
5
|
+
protected log: Logger;
|
|
6
|
+
protected packages: PackageData[];
|
|
7
|
+
constructor(config: GenerateConfig);
|
|
8
|
+
get(name: string): PackageData | undefined;
|
|
9
|
+
protected parseSections(sections: PackageSectionParsed[]): void;
|
|
10
|
+
protected transformPackageData(pkg: PackageDataParsed, parentSection?: PackageSectionParsed): PackageData;
|
|
11
|
+
protected parsePackages(packages: PackageDataParsed[], parentSection?: PackageSectionParsed): void;
|
|
12
|
+
start(): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { parseStringPromise } from 'xml2js';
|
|
2
|
+
import { readFile } from 'fs/promises';
|
|
3
|
+
import { resolve } from 'path';
|
|
4
|
+
import { Logger, splitModuleName, cleanString } from '@ts-for-gir/lib';
|
|
5
|
+
import { __dirname } from './utils.js';
|
|
6
|
+
export class PackageDataParser {
|
|
7
|
+
config;
|
|
8
|
+
log;
|
|
9
|
+
packages = [];
|
|
10
|
+
constructor(config) {
|
|
11
|
+
this.config = config;
|
|
12
|
+
this.log = new Logger('', config.verbose, 'ModuleLoader');
|
|
13
|
+
}
|
|
14
|
+
get(name) {
|
|
15
|
+
return this.packages.find((pkg) => pkg.gir === name);
|
|
16
|
+
}
|
|
17
|
+
parseSections(sections) {
|
|
18
|
+
for (const section of sections) {
|
|
19
|
+
this.log.log(`Found section`, section.$.name);
|
|
20
|
+
if (section.package) {
|
|
21
|
+
this.parsePackages(section.package);
|
|
22
|
+
}
|
|
23
|
+
if (section.section) {
|
|
24
|
+
this.parseSections(section.section);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
transformPackageData(pkg, parentSection) {
|
|
29
|
+
const { gir, home, gallery, 'c-docs': cDocs, deprecated, maintainers, maintainer } = pkg.$;
|
|
30
|
+
const description = cleanString(pkg._);
|
|
31
|
+
if (!gir) {
|
|
32
|
+
throw new Error(`No gir name specified for package "${pkg.$.name}"`);
|
|
33
|
+
}
|
|
34
|
+
const { namespace, version } = splitModuleName(gir);
|
|
35
|
+
const trans = {
|
|
36
|
+
description,
|
|
37
|
+
namespace,
|
|
38
|
+
version,
|
|
39
|
+
gir,
|
|
40
|
+
home,
|
|
41
|
+
gallery,
|
|
42
|
+
cDocs,
|
|
43
|
+
deprecated: deprecated === 'true',
|
|
44
|
+
maintainers: maintainers || maintainer,
|
|
45
|
+
section: parentSection,
|
|
46
|
+
};
|
|
47
|
+
return trans;
|
|
48
|
+
}
|
|
49
|
+
parsePackages(packages, parentSection) {
|
|
50
|
+
for (const pkg of packages) {
|
|
51
|
+
this.log.log(`Found package "${pkg.$.name}"`);
|
|
52
|
+
if (pkg.$.ignore === 'true' || !pkg.$.gir) {
|
|
53
|
+
this.log.warn(`Ignoring package "${pkg.$.name}"`);
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
const transPgk = this.transformPackageData(pkg, parentSection);
|
|
57
|
+
this.packages.push(transPgk);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
async start() {
|
|
61
|
+
const filePath = resolve(__dirname, '../packages.xml');
|
|
62
|
+
console.log(`Parsing ${filePath}...`);
|
|
63
|
+
const fileContents = await readFile(filePath, 'utf8');
|
|
64
|
+
const result = (await parseStringPromise(fileContents));
|
|
65
|
+
this.parseSections(result.packages.section);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=package-data-parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-data-parser.js","sourceRoot":"","sources":["../src/package-data-parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAA;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAC9B,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAUtC,MAAM,OAAO,iBAAiB;IAIK;IAHrB,GAAG,CAAQ;IACX,QAAQ,GAAkB,EAAE,CAAA;IAEtC,YAA+B,MAAsB;QAAtB,WAAM,GAAN,MAAM,CAAgB;QACjD,IAAI,CAAC,GAAG,GAAG,IAAI,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,OAAO,EAAE,cAAc,CAAC,CAAA;IAC7D,CAAC;IAEM,GAAG,CAAC,IAAY;QACnB,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,KAAK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,CAAC,kBAAkB,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAA;YAC7C,IAAI,GAAG,CAAC,CAAC,CAAC,MAAM,KAAK,MAAM,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE;gBACvC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,qBAAqB,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAA;gBACjD,SAAQ;aACX;YACD,MAAM,QAAQ,GAAG,IAAI,CAAC,oBAAoB,CAAC,GAAG,EAAE,aAAa,CAAC,CAAA;YAC9D,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;SAC/B;IACL,CAAC;IAED,KAAK,CAAC,KAAK;QACP,MAAM,QAAQ,GAAG,OAAO,CAAC,SAAS,EAAE,iBAAiB,CAAC,CAAA;QACtD,OAAO,CAAC,GAAG,CAAC,WAAW,QAAQ,KAAK,CAAC,CAAA;QACrC,MAAM,YAAY,GAAG,MAAM,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;QACrD,MAAM,MAAM,GAAG,CAAC,MAAM,kBAAkB,CAAC,YAAY,CAAC,CAAsB,CAAA;QAC5E,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;IAC/C,CAAC;CACJ"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The TemplateProcessor is used generate strings from templates files or template strings
|
|
3
|
+
* For example, the signal methods are generated here
|
|
4
|
+
*/
|
|
5
|
+
import ejs from 'ejs';
|
|
6
|
+
import { Logger, Transformation } from '@ts-for-gir/lib';
|
|
7
|
+
import type { GenerateConfig, Dependency, TemplateData, Environment } from '@ts-for-gir/lib';
|
|
8
|
+
export declare class TemplateProcessor {
|
|
9
|
+
protected readonly data: TemplateData | undefined;
|
|
10
|
+
protected readonly packageName: string;
|
|
11
|
+
protected readonly deps: Dependency[];
|
|
12
|
+
protected readonly config: GenerateConfig;
|
|
13
|
+
protected environmentTemplateDir: string;
|
|
14
|
+
protected log: Logger;
|
|
15
|
+
protected transformation: Transformation;
|
|
16
|
+
constructor(data: TemplateData | undefined, packageName: string, deps: Dependency[], config: GenerateConfig);
|
|
17
|
+
/**
|
|
18
|
+
* Get the output or input directory of the environment
|
|
19
|
+
* @param environment The environment to get the directory for
|
|
20
|
+
* @param baseDir The base directory
|
|
21
|
+
* @returns The path to the directory
|
|
22
|
+
*/
|
|
23
|
+
protected getEnvironmentDir: (environment: Environment, baseDir: string) => string;
|
|
24
|
+
protected getAppendTemplateName(templateFilename: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* Loads and renders a template and gets the rendered templates back
|
|
27
|
+
* @param templateFilename
|
|
28
|
+
*/
|
|
29
|
+
load(templateFilename: string, options?: Partial<ejs.Options>, overrideTemplateData?: TemplateData): Promise<{
|
|
30
|
+
prepend: string;
|
|
31
|
+
append: string;
|
|
32
|
+
}>;
|
|
33
|
+
/**
|
|
34
|
+
* Loads and renders all templates in a directory and gets the rendered templates back
|
|
35
|
+
* @param templateDirname
|
|
36
|
+
* @param fileExtension
|
|
37
|
+
* @param options EJS options
|
|
38
|
+
* @param overrideTemplateData Override template data if you want
|
|
39
|
+
* @returns The rendered templates
|
|
40
|
+
*/
|
|
41
|
+
loadAll(templateDirname: string, fileExtension: string, options?: Partial<ejs.Options>, overrideTemplateData?: TemplateData): Promise<{
|
|
42
|
+
[path: string]: string;
|
|
43
|
+
}>;
|
|
44
|
+
/**
|
|
45
|
+
* Loads an template, render the template and write the template to the filesystem
|
|
46
|
+
* @param templateFilename The filename of the template
|
|
47
|
+
* @param baseOutputPath The base output directory path where the templates should be written to
|
|
48
|
+
* @param outputFilename The filename of the output file
|
|
49
|
+
* @param prependEnv A (optional) boolean that indicates if the environment should be prepended to the output path
|
|
50
|
+
* @param content A (optional) string that should be appended to the rendered template
|
|
51
|
+
* @param options EJS options
|
|
52
|
+
* @param overrideTemplateData Override template data if you want
|
|
53
|
+
* @return The rendered template string
|
|
54
|
+
*/
|
|
55
|
+
create(templateFilename: string, baseOutputPath: string, outputFilename: string, prependEnv?: boolean, content?: string, options?: Partial<ejs.Options>, overrideTemplateData?: TemplateData): Promise<string>;
|
|
56
|
+
/**
|
|
57
|
+
* Loads all templates with file extension in dir, render the templates and write the template to the filesystem
|
|
58
|
+
* @param fileExtension The file extension of the templates
|
|
59
|
+
* @param templateDirname The directory where the templates are located
|
|
60
|
+
* @param baseOutputPath The base output directory path where the templates should be written to
|
|
61
|
+
* @param outputDirname The child output directory of the base output directory where the templates should be written to
|
|
62
|
+
* @param prependEnv A (optional) boolean that indicates if the environment should be prepended to the output path
|
|
63
|
+
* @param append A (optional) string that should be appended to the rendered template
|
|
64
|
+
* @param options EJS options
|
|
65
|
+
* @param overrideTemplateData Override template data if you want
|
|
66
|
+
* @return The rendered (and if possible prettified) templates
|
|
67
|
+
*/
|
|
68
|
+
createAll(fileExtension: string, templateDirname: string, baseOutputPath: string, outputDirname: string, prependEnv?: boolean, append?: string, options?: Partial<ejs.Options>, overrideTemplateData?: TemplateData): Promise<{
|
|
69
|
+
[path: string]: string;
|
|
70
|
+
}>;
|
|
71
|
+
getOutputPath(baseOutputPath: string, outputFilename: string, prependEnv?: boolean): string;
|
|
72
|
+
/**
|
|
73
|
+
* Writes the `content` to the filesystem
|
|
74
|
+
* @param content The content (normally the content of a rendered template file) that should be written to the filesystem
|
|
75
|
+
* @param baseOutputPath The base output directory path where the templates should be written to
|
|
76
|
+
* @param outputFilename The filename of the output file
|
|
77
|
+
* @param prependEnv A (optional) boolean that indicates if the environment should be prepended to the output path
|
|
78
|
+
* @returns
|
|
79
|
+
*/
|
|
80
|
+
protected write(content: string, baseOutputPath: string, outputFilename: string, prependEnv?: boolean): Promise<string>;
|
|
81
|
+
/**
|
|
82
|
+
*
|
|
83
|
+
* @param templateString The template content string that should be rendered
|
|
84
|
+
* @param options EJS options
|
|
85
|
+
* @param overrideTemplateData Override template data if you want
|
|
86
|
+
* @returns
|
|
87
|
+
*/
|
|
88
|
+
protected render(templateString: string, options?: Partial<ejs.Options>, overrideTemplateData?: TemplateData): Promise<string>;
|
|
89
|
+
/**
|
|
90
|
+
* Checks if the template file or directory exists and returns the path if found
|
|
91
|
+
* Tries first to load the file / directory from the environment-specific template folder and otherwise looks for it in the general template folder
|
|
92
|
+
* @param templateFilename
|
|
93
|
+
*/
|
|
94
|
+
exists(templateFilename: string): string | null;
|
|
95
|
+
/**
|
|
96
|
+
* Reads a template file from filesystem and gets the raw string back
|
|
97
|
+
* @param templateFilename
|
|
98
|
+
* @return The raw template content
|
|
99
|
+
*/
|
|
100
|
+
protected read(templateFilename: string): Promise<string>;
|
|
101
|
+
/**
|
|
102
|
+
* Reads all template files from a directory and gets the raw strings back
|
|
103
|
+
* @param templateDirname
|
|
104
|
+
* @param fileExtension
|
|
105
|
+
* @return The raw template contents
|
|
106
|
+
* @throws Error if the template directory does not exist
|
|
107
|
+
* @throws Error if the template directory is empty
|
|
108
|
+
*/
|
|
109
|
+
protected readAll(templateDirname: string, fileExtension: string): Promise<{
|
|
110
|
+
[path: string]: string;
|
|
111
|
+
}>;
|
|
112
|
+
}
|
|
113
|
+
export default TemplateProcessor;
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The TemplateProcessor is used generate strings from templates files or template strings
|
|
3
|
+
* For example, the signal methods are generated here
|
|
4
|
+
*/
|
|
5
|
+
import { existsSync } from 'fs';
|
|
6
|
+
import { readFile, writeFile, mkdir, readdir } from 'fs/promises';
|
|
7
|
+
import { join, dirname, relative, extname } from 'path';
|
|
8
|
+
import ejs from 'ejs';
|
|
9
|
+
import { __dirname } from './utils.js';
|
|
10
|
+
import { Logger, APP_NAME, APP_USAGE, APP_SOURCE, APP_VERSION, PACKAGE_DESC, PACKAGE_KEYWORDS, getDestPath, DependencyManager, Transformation, } from '@ts-for-gir/lib';
|
|
11
|
+
const TEMPLATE_DIR = join(__dirname, '../templates');
|
|
12
|
+
export class TemplateProcessor {
|
|
13
|
+
data;
|
|
14
|
+
packageName;
|
|
15
|
+
deps;
|
|
16
|
+
config;
|
|
17
|
+
environmentTemplateDir;
|
|
18
|
+
log;
|
|
19
|
+
transformation;
|
|
20
|
+
constructor(data, packageName, deps, config) {
|
|
21
|
+
this.data = data;
|
|
22
|
+
this.packageName = packageName;
|
|
23
|
+
this.deps = deps;
|
|
24
|
+
this.config = config;
|
|
25
|
+
this.transformation = new Transformation(config);
|
|
26
|
+
const dep = DependencyManager.getInstance(config);
|
|
27
|
+
let outdir = config.outdir || './';
|
|
28
|
+
// Make outdir relative to the root directory
|
|
29
|
+
outdir = relative(config.root, outdir);
|
|
30
|
+
const typeDir = getDestPath(outdir);
|
|
31
|
+
this.data = {
|
|
32
|
+
...this.data,
|
|
33
|
+
APP_NAME,
|
|
34
|
+
APP_USAGE,
|
|
35
|
+
APP_SOURCE,
|
|
36
|
+
APP_VERSION,
|
|
37
|
+
PACKAGE_DESC: PACKAGE_DESC(packageName, this.config.environment, this.data?.girModule?.libraryVersion),
|
|
38
|
+
PACKAGE_KEYWORDS: PACKAGE_KEYWORDS(packageName, this.config.environment),
|
|
39
|
+
importName: this.transformation.transformImportName(packageName),
|
|
40
|
+
dep,
|
|
41
|
+
deps,
|
|
42
|
+
typeDir,
|
|
43
|
+
join,
|
|
44
|
+
dirname,
|
|
45
|
+
};
|
|
46
|
+
this.environmentTemplateDir = this.getEnvironmentDir(config.environment, TEMPLATE_DIR);
|
|
47
|
+
this.log = new Logger(config.environment, config.verbose, this.packageName);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Get the output or input directory of the environment
|
|
51
|
+
* @param environment The environment to get the directory for
|
|
52
|
+
* @param baseDir The base directory
|
|
53
|
+
* @returns The path to the directory
|
|
54
|
+
*/
|
|
55
|
+
getEnvironmentDir = (environment, baseDir) => {
|
|
56
|
+
if (!baseDir.endsWith(environment))
|
|
57
|
+
if (environment === 'gjs' && !baseDir.endsWith('/gjs')) {
|
|
58
|
+
return join(baseDir, 'gjs');
|
|
59
|
+
}
|
|
60
|
+
if (environment === 'node' && !baseDir.endsWith('/node-gtk')) {
|
|
61
|
+
return join(baseDir, 'node-gtk');
|
|
62
|
+
}
|
|
63
|
+
return baseDir;
|
|
64
|
+
};
|
|
65
|
+
getAppendTemplateName(templateFilename) {
|
|
66
|
+
let appendTemplateFilename = templateFilename;
|
|
67
|
+
if (appendTemplateFilename.endsWith('.d.ts')) {
|
|
68
|
+
appendTemplateFilename = appendTemplateFilename.replace('.d.ts', '.append.d.ts');
|
|
69
|
+
}
|
|
70
|
+
else if (extname(appendTemplateFilename)) {
|
|
71
|
+
const ext = extname(appendTemplateFilename);
|
|
72
|
+
appendTemplateFilename = appendTemplateFilename.replace(ext, '.append' + ext);
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
appendTemplateFilename += '.append';
|
|
76
|
+
}
|
|
77
|
+
return appendTemplateFilename;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Loads and renders a template and gets the rendered templates back
|
|
81
|
+
* @param templateFilename
|
|
82
|
+
*/
|
|
83
|
+
async load(templateFilename, options = {}, overrideTemplateData = {}) {
|
|
84
|
+
const fileContent = await this.read(templateFilename);
|
|
85
|
+
const prepend = await this.render(fileContent, options, overrideTemplateData);
|
|
86
|
+
let append = '';
|
|
87
|
+
const appendTemplateFilename = this.getAppendTemplateName(templateFilename);
|
|
88
|
+
if (this.exists(appendTemplateFilename)) {
|
|
89
|
+
const appendFileContent = await this.read(appendTemplateFilename);
|
|
90
|
+
append = await this.render(appendFileContent, options, overrideTemplateData);
|
|
91
|
+
}
|
|
92
|
+
return { prepend, append };
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Loads and renders all templates in a directory and gets the rendered templates back
|
|
96
|
+
* @param templateDirname
|
|
97
|
+
* @param fileExtension
|
|
98
|
+
* @param options EJS options
|
|
99
|
+
* @param overrideTemplateData Override template data if you want
|
|
100
|
+
* @returns The rendered templates
|
|
101
|
+
*/
|
|
102
|
+
async loadAll(templateDirname, fileExtension, options = {}, overrideTemplateData = {}) {
|
|
103
|
+
const fileContents = await this.readAll(templateDirname, fileExtension);
|
|
104
|
+
for (const file of Object.keys(fileContents)) {
|
|
105
|
+
fileContents[file] = await this.render(fileContents[file], options, overrideTemplateData);
|
|
106
|
+
}
|
|
107
|
+
return fileContents;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Loads an template, render the template and write the template to the filesystem
|
|
111
|
+
* @param templateFilename The filename of the template
|
|
112
|
+
* @param baseOutputPath The base output directory path where the templates should be written to
|
|
113
|
+
* @param outputFilename The filename of the output file
|
|
114
|
+
* @param prependEnv A (optional) boolean that indicates if the environment should be prepended to the output path
|
|
115
|
+
* @param content A (optional) string that should be appended to the rendered template
|
|
116
|
+
* @param options EJS options
|
|
117
|
+
* @param overrideTemplateData Override template data if you want
|
|
118
|
+
* @return The rendered template string
|
|
119
|
+
*/
|
|
120
|
+
async create(templateFilename, baseOutputPath, outputFilename, prependEnv = true, content = '', options = {}, overrideTemplateData = {}) {
|
|
121
|
+
const { prepend, append } = await this.load(templateFilename, options, overrideTemplateData);
|
|
122
|
+
const code = prepend + '\n' + content + '\n' + append;
|
|
123
|
+
await this.write(code, baseOutputPath, outputFilename, prependEnv);
|
|
124
|
+
return code;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Loads all templates with file extension in dir, render the templates and write the template to the filesystem
|
|
128
|
+
* @param fileExtension The file extension of the templates
|
|
129
|
+
* @param templateDirname The directory where the templates are located
|
|
130
|
+
* @param baseOutputPath The base output directory path where the templates should be written to
|
|
131
|
+
* @param outputDirname The child output directory of the base output directory where the templates should be written to
|
|
132
|
+
* @param prependEnv A (optional) boolean that indicates if the environment should be prepended to the output path
|
|
133
|
+
* @param append A (optional) string that should be appended to the rendered template
|
|
134
|
+
* @param options EJS options
|
|
135
|
+
* @param overrideTemplateData Override template data if you want
|
|
136
|
+
* @return The rendered (and if possible prettified) templates
|
|
137
|
+
*/
|
|
138
|
+
async createAll(fileExtension, templateDirname, baseOutputPath, outputDirname, prependEnv = true, append = '', options = {}, overrideTemplateData = {}) {
|
|
139
|
+
const rendered = await this.loadAll(templateDirname, fileExtension, options, overrideTemplateData);
|
|
140
|
+
const result = {};
|
|
141
|
+
for (const filename of Object.keys(rendered)) {
|
|
142
|
+
const destPath = getDestPath(baseOutputPath, outputDirname, filename);
|
|
143
|
+
result[destPath] = rendered[filename] + '\n' + append;
|
|
144
|
+
await this.write(result[destPath], baseOutputPath, join(outputDirname, filename), prependEnv);
|
|
145
|
+
}
|
|
146
|
+
return result;
|
|
147
|
+
}
|
|
148
|
+
getOutputPath(baseOutputPath, outputFilename, prependEnv = true) {
|
|
149
|
+
const filePath = this.config.package
|
|
150
|
+
? join(this.data?.importName || this.packageName, outputFilename)
|
|
151
|
+
: outputFilename;
|
|
152
|
+
const outputPath = prependEnv ? getDestPath(baseOutputPath, filePath) : join(baseOutputPath, filePath);
|
|
153
|
+
return outputPath;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Writes the `content` to the filesystem
|
|
157
|
+
* @param content The content (normally the content of a rendered template file) that should be written to the filesystem
|
|
158
|
+
* @param baseOutputPath The base output directory path where the templates should be written to
|
|
159
|
+
* @param outputFilename The filename of the output file
|
|
160
|
+
* @param prependEnv A (optional) boolean that indicates if the environment should be prepended to the output path
|
|
161
|
+
* @returns
|
|
162
|
+
*/
|
|
163
|
+
async write(content, baseOutputPath, outputFilename, prependEnv = true) {
|
|
164
|
+
const outputPath = this.getOutputPath(baseOutputPath, outputFilename, prependEnv);
|
|
165
|
+
// write template result file
|
|
166
|
+
await mkdir(dirname(outputPath), { recursive: true });
|
|
167
|
+
await writeFile(outputPath, content, { encoding: 'utf8', flag: 'w' });
|
|
168
|
+
return Promise.resolve(outputPath);
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
*
|
|
172
|
+
* @param templateString The template content string that should be rendered
|
|
173
|
+
* @param options EJS options
|
|
174
|
+
* @param overrideTemplateData Override template data if you want
|
|
175
|
+
* @returns
|
|
176
|
+
*/
|
|
177
|
+
async render(templateString, options = {}, overrideTemplateData = {}) {
|
|
178
|
+
try {
|
|
179
|
+
const renderedTpl = await ejs.render(templateString, {
|
|
180
|
+
...this.config,
|
|
181
|
+
...this.data,
|
|
182
|
+
packageName: this.packageName,
|
|
183
|
+
...overrideTemplateData,
|
|
184
|
+
}, {
|
|
185
|
+
async: true,
|
|
186
|
+
...options,
|
|
187
|
+
});
|
|
188
|
+
return renderedTpl;
|
|
189
|
+
}
|
|
190
|
+
catch (error) {
|
|
191
|
+
console.error(error);
|
|
192
|
+
this.log.error('Error on render', error);
|
|
193
|
+
return '';
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Checks if the template file or directory exists and returns the path if found
|
|
198
|
+
* Tries first to load the file / directory from the environment-specific template folder and otherwise looks for it in the general template folder
|
|
199
|
+
* @param templateFilename
|
|
200
|
+
*/
|
|
201
|
+
exists(templateFilename) {
|
|
202
|
+
const fullEnvironmentTemplatePath = join(this.environmentTemplateDir, templateFilename);
|
|
203
|
+
const fullGeneralTemplatePath = join(TEMPLATE_DIR, templateFilename);
|
|
204
|
+
if (existsSync(fullEnvironmentTemplatePath)) {
|
|
205
|
+
return fullEnvironmentTemplatePath;
|
|
206
|
+
}
|
|
207
|
+
if (existsSync(fullGeneralTemplatePath)) {
|
|
208
|
+
return fullGeneralTemplatePath;
|
|
209
|
+
}
|
|
210
|
+
return null;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Reads a template file from filesystem and gets the raw string back
|
|
214
|
+
* @param templateFilename
|
|
215
|
+
* @return The raw template content
|
|
216
|
+
*/
|
|
217
|
+
async read(templateFilename) {
|
|
218
|
+
const path = this.exists(templateFilename);
|
|
219
|
+
if (path) {
|
|
220
|
+
return await readFile(path, 'utf8');
|
|
221
|
+
}
|
|
222
|
+
throw new Error(`Template '${templateFilename}' not found'`);
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Reads all template files from a directory and gets the raw strings back
|
|
226
|
+
* @param templateDirname
|
|
227
|
+
* @param fileExtension
|
|
228
|
+
* @return The raw template contents
|
|
229
|
+
* @throws Error if the template directory does not exist
|
|
230
|
+
* @throws Error if the template directory is empty
|
|
231
|
+
*/
|
|
232
|
+
async readAll(templateDirname, fileExtension) {
|
|
233
|
+
const path = this.exists(templateDirname);
|
|
234
|
+
if (path) {
|
|
235
|
+
const files = (await readdir(path)).filter((file) => file.endsWith(fileExtension));
|
|
236
|
+
if (files.length === 0) {
|
|
237
|
+
throw new Error(`Template directory '${templateDirname}' is empty'`);
|
|
238
|
+
}
|
|
239
|
+
const results = {};
|
|
240
|
+
for (const file of files) {
|
|
241
|
+
results[file] = await readFile(join(path, file), 'utf8');
|
|
242
|
+
}
|
|
243
|
+
return results;
|
|
244
|
+
}
|
|
245
|
+
throw new Error(`Template directory '${templateDirname}' not found'`);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
export default TemplateProcessor;
|
|
249
|
+
//# sourceMappingURL=template-processor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template-processor.js","sourceRoot":"","sources":["../src/template-processor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAA;AAC/B,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AACjE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AACvD,OAAO,GAAG,MAAM,KAAK,CAAA;AACrB,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACtC,OAAO,EACH,MAAM,EACN,QAAQ,EACR,SAAS,EACT,UAAU,EACV,WAAW,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AAuB,eAAe,aAAa,CAAC,CAAA;aACvE;YACD,MAAM,OAAO,GAA+B,EAAE,CAAA;YAC9C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;gBACtB,OAAO,CAAC,IAAI,CAAC,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,CAAA;aAC3D;YACD,OAAO,OAAO,CAAA;SACjB;QACD,MAAM,IAAI,KAAK,CAAC,uBAAuB,eAAe,cAAc,CAAC,CAAA;IACzE,CAAC;CACJ;AAED,eAAe,iBAAiB,CAAA"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Generator } from '@ts-for-gir/generator-base';
|
|
2
|
-
import { Logger,
|
|
3
|
-
import {
|
|
2
|
+
import { Logger, Dependency, DependencyManager } from '@ts-for-gir/lib';
|
|
3
|
+
import { TemplateProcessor } from './template-processor.js';
|
|
4
|
+
import { PackageDataParser } from './package-data-parser.js';
|
|
5
|
+
import type { GenerateConfig, GirClassElement, GirCallableParamElement, GirSignalElement, GirEnumElement, GirAliasElement, GirInterfaceElement, GirUnionElement, GirModulesGrouped, GirRecordElement, GirBitfieldElement, GirInstanceParameter, GirModule, TsGenericParameter, TsType, TsDoc, TsFunction, TsCallback, TsSignal, TsMember, TsVar, TsProperty, TsParameter } from '@ts-for-gir/lib';
|
|
4
6
|
export declare class TypeDefinitionGenerator implements Generator {
|
|
5
7
|
protected readonly _config: GenerateConfig;
|
|
6
8
|
protected log: Logger;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { Logger, generateIndent, removeNamespace, removeClassModule, girElementIsIntrospectable, typesContainsOptional, typesContainsNullable,
|
|
1
|
+
import { Logger, generateIndent, removeNamespace, removeClassModule, girElementIsIntrospectable, typesContainsOptional, typesContainsNullable, DependencyManager, NO_TSDATA, WARN_NOT_FOUND_DEPENDENCY_GIR_FILE, WARN_IGNORE_MULTIPLE_CALLBACKS, WARN_IGNORE_MULTIPLE_FUNC_DESC, } from '@ts-for-gir/lib';
|
|
2
|
+
import { TemplateProcessor } from './template-processor.js';
|
|
3
|
+
import { PackageDataParser } from './package-data-parser.js';
|
|
2
4
|
export class TypeDefinitionGenerator {
|
|
3
5
|
_config;
|
|
4
6
|
log;
|