Skip to content

Update Gulpfile to copy files required for generated client to properly run #1353

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

Merged
merged 3 commits into from
Jul 2, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,21 +106,35 @@ gulp.task('compile_test', function() {
});

gulp.task('copyTypings', function() {
return gulp.src(['src/index.d.ts', 'src/firebase-namespace.d.ts'])
return gulp.src([
'src/index.d.ts',
'src/firebase-namespace.d.ts',
'src/**/protos/*.d.ts',
])
// Add header
.pipe(header(banner))
.pipe(gulp.dest(paths.build))
});

gulp.task('compile_all', gulp.series('compile', 'copyTypings', 'compile_test'));
gulp.task('copyJSON', function() {
return gulp.src([
// This isn't ideal, but doing something like
// 'src/generated/**/*.json' results in incorrect paths in the /lib dir
'src/**/*.json'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we say src/generated/**/*.json instead?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see. It ends up copying them into lib/messaging instead of lib/generated/messaging. I guess it only matches path segments after src/generated when the pattern is specified this way. Then I think the way you've implemented this is correct.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, doing the more general wildcard is less "comfortable" than doing the specific src/generated/**/*.json, but it's (as far as I could tell) the only way for the generated path to be structured properly.

])
.pipe(gulp.dest(paths.build))
});

gulp.task('compile_all', gulp.series('compile', 'copyTypings',
'copyJSON', 'compile_test'));

// Regenerates js every time a source file changes
gulp.task('watch', function() {
gulp.watch(paths.src.concat(paths.test), { ignoreInitial: false }, gulp.series('compile_all'));
});

// Build task
gulp.task('build', gulp.series('cleanup', 'compile', 'copyTypings'));
gulp.task('build', gulp.series('cleanup', 'compile', 'copyTypings', 'copyJSON'));

// Default task
gulp.task('default', gulp.series('build'));