-
Notifications
You must be signed in to change notification settings - Fork 597
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Angular and React generators #12352
Merged
roman-simionov
merged 12 commits into
DevExpress:preact-button
from
roman-simionov:playground
Mar 19, 2020
Merged
Changes from 7 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
a1c727b
add generate-angular, generate-react gulp tasks
roman-simionov b60b112
import click and hover
roman-simionov 01d1b04
add angular and react apps to playground
roman-simionov 22414fc
add readme and tsconfig
roman-simionov f84acaf
fix support import in pointer module
roman-simionov e56f672
update generator-version
roman-simionov f8faebf
rollback extra change
roman-simionov 4faed3f
rename parameter
roman-simionov 36db984
extract base tsconfig
roman-simionov 3418be5
fix remark
roman-simionov 1d3dddb
add eslintignore for react and angular
roman-simionov 16f4e1a
rework ignoring eslint rules for playground
roman-simionov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
const gulp = require('gulp'); | ||
const { generateComponents } = require('devextreme-generator/component-compiler'); | ||
const generator = require('devextreme-generator/preact-generator').default; | ||
const ts = require('gulp-typescript'); | ||
const lint = require('gulp-eslint'); | ||
const plumber = require('gulp-plumber'); | ||
const gulpIf = require('gulp-if'); | ||
const merge = require('merge-stream'); | ||
const babel = require('gulp-babel'); | ||
|
||
const SRC = 'js/renovation/**/*.tsx'; | ||
const DEST = 'js/renovation/'; | ||
|
||
const GLOB_TS = require('../ts').GLOB_TS; | ||
const COMMON_SRC = ['js/**/*.*', '!' + GLOB_TS]; | ||
|
||
const knownErrors = [ | ||
'Cannot find module \'preact\'.', | ||
'Cannot find module \'preact/hooks\'.' | ||
]; | ||
|
||
gulp.task('generate-components', function() { | ||
const tsProject = ts.createProject('build/gulp/generator/ts-configs/preact.tsconfig.json'); | ||
generator.defaultOptionsModule = 'js/core/options/utils'; | ||
|
||
return gulp.src(SRC) | ||
.pipe(generateComponents(generator)) | ||
.pipe(plumber(()=>null)) | ||
.pipe(tsProject({ | ||
error(e) { | ||
if(!knownErrors.some(i => e.message.endsWith(i))) { | ||
console.log(e.message); | ||
} | ||
}, | ||
finish() {} | ||
})) | ||
.pipe(gulpIf(file => file.extname === '.js', | ||
lint({ | ||
quiet: true, | ||
fix: true, | ||
useEslintrc: true | ||
}) | ||
)) | ||
.pipe(lint.format()) | ||
.pipe(gulp.dest(DEST)); | ||
}); | ||
|
||
function addGenerationTask(approach, knownErrors = []) { | ||
const generator = require(`devextreme-generator/${approach}-generator`).default; | ||
gulp.task(`generate-${approach}`, function() { | ||
const tsProject = ts.createProject(`build/gulp/generator/ts-configs/${approach}.tsconfig.json`); | ||
generator.defaultOptionsModule = 'js/core/options/utils'; | ||
|
||
return merge( | ||
gulp.src(COMMON_SRC), | ||
gulp.src('js/**/*.tsx') | ||
.pipe(generateComponents(generator)) | ||
.pipe(plumber(() => null)) | ||
.pipe(tsProject({ | ||
error(e) { | ||
if(!knownErrors.some(i => e.message.endsWith(i))) { | ||
console.log(e.message); | ||
} | ||
}, | ||
finish() { } | ||
})) | ||
).pipe(babel()) | ||
.pipe(gulp.dest(`artifacts/${approach}`)); | ||
}); | ||
} | ||
|
||
addGenerationTask('react', ['Cannot find module \'csstype\'.']); | ||
addGenerationTask('angular', [ | ||
'Cannot find module \'@angular/core\'.', | ||
'Cannot find module \'@angular/common\'.' | ||
]); | ||
|
||
gulp.task('generate-components-watch', gulp.series('generate-components', function() { | ||
gulp.watch([SRC], gulp.series('generate-components')); | ||
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ES2016", | ||
"module": "ESNext", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can extract the base part as it did here |
||
"strict": false, | ||
"jsx": "react", | ||
"esModuleInterop": false, | ||
"typeRoots": ["node_modules/@types"], | ||
"forceConsistentCasingInFileNames": true, | ||
"experimentalDecorators": true | ||
}, | ||
"exclude": [ | ||
"node_modules" | ||
] | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ES2016", | ||
"module": "ESNext", | ||
"strict": false, | ||
"esModuleInterop": false, | ||
"typeRoots": ["node_modules/@types"], | ||
"forceConsistentCasingInFileNames": true, | ||
"allowSyntheticDefaultImports": true, | ||
"jsx": "react", | ||
"declaration": true | ||
}, | ||
"exclude": [ | ||
"node_modules" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# README | ||
|
||
## Run Example | ||
|
||
Install packages using the following command: | ||
|
||
npm install | ||
|
||
After instalation generate components and build scripts | ||
|
||
npx gulp generate-angular | ||
|
||
Setup a local web server and run this application in it. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<dx-button | ||
text="Click Me!" | ||
(onClick)="onClick($event)" | ||
icon="download" | ||
iconPosition="right" | ||
> | ||
</dx-button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { NgModule, Component } from '@angular/core'; | ||
import { BrowserModule } from '@angular/platform-browser'; | ||
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; | ||
import { DxButtonModule } from 'devextreme/renovation/button'; | ||
|
||
@Component({ | ||
providers: [], | ||
selector: 'demo-app', | ||
styleUrls: [], | ||
templateUrl: './app/app.component.html', | ||
}) | ||
export class AppComponent { | ||
onClick() { | ||
alert('clicked'); | ||
} | ||
} | ||
@NgModule({ | ||
imports: [ | ||
BrowserModule, | ||
DxButtonModule, | ||
], | ||
declarations: [AppComponent], | ||
bootstrap: [AppComponent], | ||
}) | ||
export class AppModule {} | ||
|
||
platformBrowserDynamic().bootstrapModule(AppModule); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
System.config({ | ||
transpiler: 'ts', | ||
typescriptOptions: { | ||
module: 'commonjs', | ||
emitDecoratorMetadata: true, | ||
experimentalDecorators: true | ||
}, | ||
meta: { | ||
'typescript': { | ||
'exports': 'ts' | ||
} | ||
}, | ||
paths: { | ||
'npm:': 'https://unpkg.com/' | ||
}, | ||
map: { | ||
'ts': 'npm:[email protected]/lib/plugin.js', | ||
'typescript': 'npm:[email protected]/lib/typescript.js', | ||
|
||
'@angular/core': 'npm:@angular/[email protected]/bundles/core.umd.js', | ||
'@angular/common': 'npm:@angular/[email protected]/bundles/common.umd.js', | ||
'@angular/compiler': 'npm:@angular/[email protected]/bundles/compiler.umd.js', | ||
'@angular/platform-browser': 'npm:@angular/[email protected]/bundles/platform-browser.umd.js', | ||
'@angular/platform-browser-dynamic': 'npm:@angular/[email protected]/bundles/platform-browser-dynamic.umd.js', | ||
'@angular/router': 'npm:@angular/[email protected]/bundles/router.umd.js', | ||
'@angular/forms': 'npm:@angular/[email protected]/bundles/forms.umd.js', | ||
'@angular/common/http': 'npm:@angular/[email protected]/bundles/common-http.umd.js', | ||
'tslib': 'npm:tslib/tslib.js', | ||
|
||
'rxjs': 'npm:[email protected]', | ||
'rxjs/operators': 'npm:[email protected]/operators', | ||
|
||
'jszip': 'npm:[email protected]/dist/jszip.min.js', | ||
'quill': 'npm:[email protected]/dist/quill.js', | ||
'devextreme': '../../artifacts/angular' | ||
}, | ||
packages: { | ||
'app': { | ||
main: './app.component.ts', | ||
defaultExtension: 'ts' | ||
}, | ||
'devextreme': { | ||
defaultExtension: 'js', | ||
}, | ||
'devextreme/events': { | ||
defaultExtension: 'js', | ||
main: 'index.js' | ||
}, | ||
'devextreme/events/utils': { | ||
defaultExtension: 'js', | ||
main: 'index.js' | ||
}, | ||
'rxjs': { main: 'index.js', defaultExtension: 'js' }, | ||
'rxjs/operators': { main: 'index.js', defaultExtension: 'js' }, | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<!DOCTYPE html> | ||
<html xmlns="http://www.w3.org/1999/xhtml"> | ||
|
||
<head> | ||
<title>DevExtreme Demo</title> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" /> | ||
|
||
<link rel="stylesheet" type="text/css" href="../../artifacts/css/dx.spa.css" /> | ||
<link rel="stylesheet" type="text/css" href="../../artifacts/css/dx.common.css" /> | ||
<link rel="stylesheet" type="text/css" href="../../artifacts/css/dx.light.css" /> | ||
|
||
<script src="https://unpkg.com/[email protected]/client/shim.min.js"></script> | ||
<script src="https://unpkg.com/[email protected]/dist/zone.js"></script> | ||
<script src="https://unpkg.com/[email protected]/Reflect.js"></script> | ||
<script src="https://unpkg.com/[email protected]/dist/system.js"></script> | ||
|
||
<script src="config.js"></script> | ||
<script> | ||
System.import('app').catch(console.error.bind(console)); | ||
</script> | ||
|
||
</head> | ||
|
||
<body class="dx-viewport"> | ||
<div class="demo-app"> | ||
<demo-app>Loading...</demo-app> | ||
</div> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"compileOnSave": false, | ||
"compilerOptions": { | ||
"baseUrl": "./", | ||
"outDir": "./dist/out-tsc", | ||
"sourceMap": true, | ||
"declaration": false, | ||
"downlevelIteration": true, | ||
"experimentalDecorators": true, | ||
"module": "esnext", | ||
"moduleResolution": "node", | ||
"importHelpers": true, | ||
"target": "es2015", | ||
"typeRoots": [ | ||
"node_modules/@types" | ||
], | ||
"lib": [ | ||
"es2018", | ||
"dom" | ||
] | ||
}, | ||
"include": [ | ||
"app/**/*.ts" | ||
], | ||
"angularCompilerOptions": { | ||
"fullTemplateTypeCheck": true, | ||
"strictInjectionParameters": true | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
approach -> frameworkName?