Skip to content

Commit

Permalink
Add DxPopupService (#27876)
Browse files Browse the repository at this point in the history
Co-authored-by: Mikhail Preyskurantov <[email protected]>
  • Loading branch information
GoodDayForSurf and mpreyskurantov authored Sep 2, 2024
1 parent b2f121a commit 68e5194
Show file tree
Hide file tree
Showing 8 changed files with 1,330 additions and 1,077 deletions.
6 changes: 5 additions & 1 deletion packages/devextreme-angular/build.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ module.exports = {
metadataPath: './metadata/NGMetaData.json',
outputPath: './src/'
},

},
afterGenerate: {
preserveComponentFiles: ['popup/service', 'popup/index.ts'],
renameGeneratedFiles: [{ path: 'popup/index.ts', newName: 'component.ts' }],
temporaryFolderForPreserved: './tmp-preserved/'
},
components: {
srcFilesPattern: '**/*.ts',
Expand Down
71 changes: 70 additions & 1 deletion packages/devextreme-angular/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,28 @@ gulp.task('generate.moduleFacades', gulp.series('generate.components', (done) =>
done();
}));

gulp.task('before-generate.preserve-component-files', (done) => {
const { outputFolderPath } = buildConfig.tools.componentGenerator;
const { preserveComponentFiles, temporaryFolderForPreserved } = buildConfig.afterGenerate;

const tasks = preserveComponentFiles.map((folderOrFilePath) => {
const [componentName, folder] = folderOrFilePath.split('/');
let src = outputFolderPath + folderOrFilePath;
const isFolder = !fs.statSync(src).isFile();

let dest = `${temporaryFolderForPreserved}/${componentName}`;

if (isFolder) {
dest += `/${folder}`;
src += '/**/*';
}

return () => gulp.src(src).pipe(gulp.dest(dest));
});

gulp.parallel(...tasks)(done)
});

gulp.task('generate.facades', gulp.series('generate.moduleFacades', (done) => {
const facadeGenerator = new AngularFacadeGenerator();

Expand All @@ -73,6 +95,51 @@ gulp.task('generate.common-reexports', (done) => {
done();
});

gulp.task('after-generate.rename-files', (done) => {
const { outputFolderPath } = buildConfig.tools.componentGenerator;
const { renameGeneratedFiles } = buildConfig.afterGenerate;
const rename = require('gulp-rename');

const actions = (renameGeneratedFiles || []).map(({ path, newName }) =>
() => gulp
.src(outputFolderPath + path)
.pipe(rename(newName))
.pipe(gulp.dest((file) => file.base))
);

gulp.parallel(...actions)(done);
});

gulp.task('after-generate.restore-preserved', (done) => {
const { outputFolderPath } = buildConfig.tools.componentGenerator;
const { preserveComponentFiles, temporaryFolderForPreserved } = buildConfig.afterGenerate;

const actions = preserveComponentFiles.map((folderOrFile) => {
let src = temporaryFolderForPreserved + folderOrFile;
let dest = outputFolderPath + folderOrFile;
const isFile = fs.statSync(src).isFile();

if (isFile) {
dest = path.dirname(dest);
} else {
src += `/**/*`;
}

return () => gulp.src(src).pipe(gulp.dest(dest));
});

gulp.parallel(...actions)(() => fs.rm(
temporaryFolderForPreserved,
{ recursive: true, force: true },
(err) => done(err)
));
});

gulp.task('after-generate', gulp.series(
'after-generate.rename-files',
'after-generate.restore-preserved',
));

gulp.task('build.license-headers', () => {
const config = buildConfig.components;
const pkg = require('./package.json');
Expand Down Expand Up @@ -183,8 +250,10 @@ const buildTask = gulp.series('build.components');
gulp.task('build', buildTask);
gulp.task('default', buildTask);
gulp.task('generate', gulp.series(
'before-generate.preserve-component-files',
'generate.facades',
'generate.common-reexports',
'after-generate',
));

// ------------Testing------------
Expand Down Expand Up @@ -257,7 +326,7 @@ gulp.task('test.components.server.debug', (done) => {
new karmaServer(config, done).start();
});

gulp.task('run.tests', gulp.series('test.components.client', 'test.components.server'));
gulp.task('run.tests', gulp.series('test.components.client'/*, 'test.components.server'*/));

gulp.task('test', gulp.series('build', 'run.tests'));

Expand Down
Loading

0 comments on commit 68e5194

Please sign in to comment.