Skip to content

Commit

Permalink
Template files: Removed enviroment directory
Browse files Browse the repository at this point in the history
  • Loading branch information
JumpLink committed Jul 19, 2024
1 parent aebfcfc commit 7713ab2
Show file tree
Hide file tree
Showing 15 changed files with 20 additions and 37 deletions.
5 changes: 2 additions & 3 deletions .ts-for-gir.packages-gtk4.rc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import allPackagesConfig from './.ts-for-gir.packages-all.rc.js';
import gtk4PackagesConfig from './.ts-for-gir.gtk4.rc.js';

export default {
...allPackagesConfig,
modules: ['Gtk-4.0', 'Adw-1.0'],
...gtk4PackagesConfig,
package: true,
}
18 changes: 1 addition & 17 deletions packages/generator-typescript/src/template-processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import type { OptionsGeneration, Dependency, TemplateData } from '@ts-for-gir/li
const TEMPLATE_DIR = join(__dirname, './templates')

export class TemplateProcessor {
protected environmentTemplateDir: string
protected log: Logger
protected transformation: Transformation
constructor(
Expand Down Expand Up @@ -56,24 +55,9 @@ export class TemplateProcessor {
join,
dirname,
}
this.environmentTemplateDir = this.getEnvironmentDir(TEMPLATE_DIR)
this.log = new Logger(config.verbose, `TemplateProcessor (${this.packageName})`)
}

/**
* Get the output or input directory of the environment
* @param environment The environment to get the directory for
* @param baseDir The base directory
* @returns The path to the directory
*/
protected getEnvironmentDir = (baseDir: string): string => {
if (!baseDir.endsWith('/gjs')) {
return join(baseDir, 'gjs')
}

return baseDir
}

protected getAppendTemplateName(templateFilename: string) {
let appendTemplateFilename = templateFilename

Expand Down Expand Up @@ -252,7 +236,7 @@ export class TemplateProcessor {
* @param templateFilename
*/
public async exists(templateFilename: string): Promise<string | null> {
const fullEnvironmentTemplatePath = join(this.environmentTemplateDir, templateFilename)
const fullEnvironmentTemplatePath = join(TEMPLATE_DIR, templateFilename)
const fullGeneralTemplatePath = join(TEMPLATE_DIR, templateFilename)
if (await fileExists(fullEnvironmentTemplatePath)) {
return fullEnvironmentTemplatePath
Expand Down
34 changes: 17 additions & 17 deletions packages/generator-typescript/src/type-definition-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,55 +49,55 @@ export class TypeDefinitionGenerator implements Generator {
name: gjs.importName,
})

await templateProcessor.create('gjs.d.ts', config.outdir, 'gjs.d.ts')
await templateProcessor.create('gjs.js', config.outdir, 'gjs.js')
await templateProcessor.create('gjs/gjs.d.ts', config.outdir, 'gjs.d.ts')
await templateProcessor.create('gjs/gjs.js', config.outdir, 'gjs.js')

// Additional DOM types supported by GJS
await templateProcessor.create('dom.d.ts', config.outdir, 'dom.d.ts')
await templateProcessor.create('dom.js', config.outdir, 'dom.js')
await templateProcessor.create('gjs/dom.d.ts', config.outdir, 'dom.d.ts')
await templateProcessor.create('gjs/dom.js', config.outdir, 'dom.js')

await templateProcessor.create('gettext.d.ts', config.outdir, 'gettext.d.ts')
await templateProcessor.create('gettext.js', config.outdir, 'gettext.js')
await templateProcessor.create('gjs/gettext.d.ts', config.outdir, 'gettext.d.ts')
await templateProcessor.create('gjs/gettext.js', config.outdir, 'gettext.js')

await templateProcessor.create('system.d.ts', config.outdir, 'system.d.ts')
await templateProcessor.create('system.js', config.outdir, 'system.js')
await templateProcessor.create('gjs/system.d.ts', config.outdir, 'system.d.ts')
await templateProcessor.create('gjs/system.js', config.outdir, 'system.js')

await templateProcessor.create('cairo.d.ts', config.outdir, 'cairo.d.ts')
await templateProcessor.create('cairo.js', config.outdir, 'cairo.js')
await templateProcessor.create('gjs/cairo.d.ts', config.outdir, 'cairo.d.ts')
await templateProcessor.create('gjs/cairo.js', config.outdir, 'cairo.js')

// Import ambient types
await templateProcessor.create('gjs-ambient.d.ts', config.outdir, 'gjs-ambient.d.ts')
await templateProcessor.create('gjs-ambient.js', config.outdir, 'gjs-ambient.js')
await templateProcessor.create('gjs/gjs-ambient.d.ts', config.outdir, 'gjs-ambient.d.ts')
await templateProcessor.create('gjs/gjs-ambient.js', config.outdir, 'gjs-ambient.js')

const pkg = new NpmPackage(config, dependencyManager, gjs, await dependencyManager.core())
await pkg.exportNPMPackage()
} else {
const gjsContent = await templateProcessor.load('gjs.d.ts')
const gjsContent = await templateProcessor.load('gjs/gjs.d.ts')
await templateProcessor.write(gjsContent.prepend + '\n' + gjsContent.append, config.outdir, 'gjs.d.ts')

const gettextContent = await templateProcessor.load('gettext.d.ts')
const gettextContent = await templateProcessor.load('gjs/gettext.d.ts')
const gettextContentAmbient = wrapIntoAmbientModule('gettext', null, [
gettextContent.prepend,
gettextContent.append,
])
await templateProcessor.write(gettextContentAmbient.join('\n'), config.outdir, 'gettext.d.ts')

const systemContent = await templateProcessor.load('system.d.ts')
const systemContent = await templateProcessor.load('gjs/system.d.ts')
const systemContentAmbient = wrapIntoAmbientModule('system', null, [
systemContent.prepend,
systemContent.append,
])
await templateProcessor.write(systemContentAmbient.join('\n'), config.outdir, 'system.d.ts')

const cairoContent = await templateProcessor.load('cairo.d.ts')
const cairoContent = await templateProcessor.load('gjs/cairo.d.ts')
const cairoContentAmbient = wrapIntoAmbientModule('cairo', null, [
cairoContent.prepend,
cairoContent.append,
])
await templateProcessor.write(cairoContentAmbient.join('\n'), config.outdir, 'cairo.d.ts')

// Additional DOM types supported by GJS
const domContent = await templateProcessor.load('dom.d.ts')
const domContent = await templateProcessor.load('gjs/dom.d.ts')
await templateProcessor.write(domContent.prepend + '\n' + domContent.append, config.outdir, 'dom.d.ts')
}
}
Expand Down

0 comments on commit 7713ab2

Please sign in to comment.