Skip to content

Commit

Permalink
CI: make generator buildable locally (#1436)
Browse files Browse the repository at this point in the history
* CI: make generator buildable locally

* review fixes

---------

Co-authored-by: Alexander Bulychev <git@bulychev.net>
  • Loading branch information
iBat and Alexander Bulychev authored Aug 18, 2023
1 parent c1d3edb commit 59f2900
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 13 deletions.
9 changes: 5 additions & 4 deletions packages/devextreme-angular-generator/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,18 @@ gulp.task('npm.pack', gulp.series(

//------------Main------------

var buildTask = gulp.series(
var buildTask = (tsProject = 'tsconfig.json') => gulp.series(
() => gulp.src(TEMPLATES_FILES_PATTERN).pipe(gulp.dest(path.join(DIST_PATH, 'templates'))),
() => gulp.src(SRC_FILES_PATTERN)
.pipe(sourcemaps.init())
.pipe(typescript('tsconfig.json'))
.pipe(typescript(tsProject))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(DIST_PATH))
);

gulp.task('build', buildTask);
gulp.task('default', buildTask);
gulp.task('build', buildTask());
gulp.task('build:local', buildTask('tsconfig.local.json'));
gulp.task('default', buildTask());


//------------Testing------------
Expand Down
5 changes: 3 additions & 2 deletions packages/devextreme-angular-generator/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"author": "Developer Express Inc.",
"name": "devextreme-angular-generator",
"version": "2.1.1",
"version": "2.1.2",
"description": "Angular UI and visualization components based on DevExtreme widgets",
"repository": {
"type": "git",
Expand All @@ -15,6 +15,7 @@
"scripts": {
"gulp": "npx --node-options='--max_old_space_size=8048' gulp",
"build": "npm run gulp -- build",
"build:local": "npm run gulp -- build:local",
"test": "npm run gulp -- test",
"test:dev": "npm run gulp -- run.tests",
"pack": "npm run gulp -- build && npm run gulp -- npm.pack"
Expand All @@ -36,7 +37,7 @@
"@types/dot": "^1.1.5",
"@types/jasmine": "2.8.19",
"@types/mkdirp": "^0.5.2",
"@types/node": "~8.10.66",
"@types/node": "^18.17.5",
"@types/yargs": "^6.6.0",
"del": "^2.2.2",
"gulp": "^4.0.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import fs = require('fs');
import path = require('path');

export default class ComponentNamesGenerator {
private _encoding = 'utf8';
private _encoding: BufferEncoding = 'utf8';

private _config;

Expand Down
4 changes: 2 additions & 2 deletions packages/devextreme-angular-generator/src/dot-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function createTemplateFromString(templateString: string) {
}

export default class DoTGenerator {
private _encoding = 'utf8';
private _encoding: BufferEncoding = 'utf8';
createTemplate(templateFilePath: string) {
logger('Create doT template from ' + templateFilePath);
let templateString = fs.readFileSync(templateFilePath, this._encoding);
Expand Down Expand Up @@ -63,7 +63,7 @@ export default class DoTGenerator {
let filePath = path.join(metadataFolderPath, fileName);

logger('Read data from ' + filePath);
let data = fs.readFileSync(filePath, this._encoding);
let data = fs.readFileSync(filePath, { encoding: this._encoding });
logger('Apply template');
let result = template(JSON.parse(data));
const widgetName = path.parse(filePath).name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import logger from './logger';
import inflector = require('inflector-js');

export default class FacadeGenerator {
private _encoding = 'utf8';
private _encoding: BufferEncoding = 'utf8';
generate(config) {
Object.keys(config.facades).forEach(facadeFilePath => {
logger('Generate facade: ' + facadeFilePath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@ export interface IObjectStore {
}

export class FSObjectStore implements IObjectStore {
private _encoding = 'utf8';
private _encoding: BufferEncoding = 'utf8';
read(filePath) {
logger(`Read from file: ${filePath}`);
let dataString = fs.readFileSync(filePath, this._encoding);
let dataString = fs.readFileSync(filePath, { encoding: this._encoding });
logger('Parse data');
return JSON.parse(dataString);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import logger from './logger';
let inflector = require('inflector-js');

export default class FacadeGenerator {
private _encoding = 'utf8';
private _encoding: BufferEncoding = 'utf8';

prepareModuleName(fileName: string) {
fileName = fileName.replace(/-/g, '_');
Expand Down
17 changes: 17 additions & 0 deletions packages/devextreme-angular-generator/tsconfig.local.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"compilerOptions": {
"baseUrl": "./",
"skipLibCheck": true,
"target": "ES5",
"module": "commonjs",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"sourceMap": true,
"inlineSources": true,
"removeComments": false,
"declaration": true,
"noUnusedParameters": true,
"noUnusedLocals": true
}
}

0 comments on commit 59f2900

Please sign in to comment.