Skip to content
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

chore: Removing ambient typing files #1032

Merged
merged 2 commits into from
Sep 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 3 additions & 9 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ module.exports = {
// Disabled checks
'@typescript-eslint/no-explicit-any': 0,
'@typescript-eslint/no-use-before-define': 0,
'@typescript-eslint/no-unused-vars': 0,

// Required checks
'indent': ['error', 2],
Expand All @@ -54,12 +53,7 @@ module.exports = {
'allowHigherOrderFunctions': true
}
],
'@typescript-eslint/no-unused-vars-experimental': 2,
},
// Required by the @typescript-eslint/no-unused-vars-experimental rule.
// We use a separate tsconfig file for linting to reduce the time complexity of the operation.
// See github.com/typescript-eslint/typescript-eslint/issues/1320
parserOptions: {
project: './tsconfig.eslint.json',
},
'no-unused-vars': 'off', // Must be disabled to enable the next rule
'@typescript-eslint/no-unused-vars': ['error']
}
};
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,4 @@ jobs:
run: |
npm ci
npm run build
npm run build:tests
npm test
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
[![Build Status](https://github.com/firebase/firebase-admin-node/workflows/Continuous%20Integration/badge.svg)](https://github.com/firebase/firebase-admin-node/actions)

# TODO

* Copy generated d.ts files to the build directory.
* Re-enable the `npm run build:tests` in CI.

# Firebase Admin Node.js SDK


Expand Down
74 changes: 10 additions & 64 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,14 @@
/**************/
/* REQUIRES */
/**************/
var fs = require('fs');
var _ = require('lodash');
var gulp = require('gulp');
var pkg = require('./package.json');

// File I/O
var fs = require('fs');
var ts = require('gulp-typescript');
var del = require('del');
var header = require('gulp-header');
var replace = require('gulp-replace');
var filter = require('gulp-filter');


Expand All @@ -46,42 +43,15 @@ var paths = {
'!test/integration/typescript/src/example*.ts',
],

databaseSrc: [
'src/**/*.js'
],

build: 'lib/',

curatedTypings: [
'src/*.d.ts',
'!src/credential.d.ts',
'!src/database.d.ts',
'!src/instance-id.d.ts',
'!src/messaging.d.ts',
'!src/project-management.d.ts',
'!src/remote-config.d.ts',
'!src/security-rules.d.ts',
'!src/storage.d.ts',
],
};

const TEMPORARY_TYPING_EXCLUDES = [
'!lib/default-namespace.d.ts',
'!lib/firebase-namespace.d.ts',
'!lib/firebase-app.d.ts',
'!lib/firebase-service.d.ts',
'!lib/auth/*.d.ts',
'!lib/machine-learning/*.d.ts',
'!lib/utils/*.d.ts',
];

// Create a separate project for buildProject that overrides the rootDir.
// This ensures that the generated production files are in their own root
// rather than including both src and test in the lib dir. Declaration
// is used by TypeScript to determine if auto-generated typings should be
// emitted.
const declaration = process.env.TYPE_GENERATION_MODE === 'auto';
var buildProject = ts.createProject('tsconfig.json', { rootDir: 'src', declaration });
var buildProject = ts.createProject('tsconfig.json', { rootDir: 'src' });

var buildTest = ts.createProject('tsconfig.json');

Expand Down Expand Up @@ -111,19 +81,11 @@ gulp.task('compile', function() {
// Add header
.pipe(header(banner));

// Exclude typings that are unintended (currently excludes all auto-generated
// typings, but as services are refactored to auto-generate typings this will
// change). Moreover, all *-internal.d.ts typings should not be exposed to
// developers as it denotes internally used types.
if (declaration) {
const configuration = [
'lib/**/*.js',
'lib/**/*.d.ts',
'!lib/**/*-internal.d.ts',
].concat(TEMPORARY_TYPING_EXCLUDES);
const configuration = [
'lib/**/*.js',
];

workflow = workflow.pipe(filter(configuration));
}
workflow = workflow.pipe(filter(configuration));

// Write to build directory
return workflow.pipe(gulp.dest(paths.build))
Expand All @@ -139,38 +101,22 @@ gulp.task('compile_test', function() {
.pipe(buildTest())
});

gulp.task('copyDatabase', function() {
return gulp.src(paths.databaseSrc)
// Add headers
.pipe(header(fs.readFileSync('third_party/database-license.txt', 'utf8')))
.pipe(header(banner))

// Write to build directory
.pipe(gulp.dest(paths.build))
});

gulp.task('copyTypings', function() {
let workflow = gulp.src('src/*.d.ts')
return gulp.src(['src/index.d.ts', 'src/firebase-namespace.d.ts'])
// Add header
.pipe(header(banner));

if (declaration) {
workflow = workflow.pipe(filter(paths.curatedTypings));
}

// Write to build directory
return workflow.pipe(gulp.dest(paths.build))
.pipe(header(banner))
.pipe(gulp.dest(paths.build))
});

gulp.task('compile_all', gulp.series('compile', 'copyDatabase', 'copyTypings', 'compile_test'));
gulp.task('compile_all', gulp.series('compile', 'copyTypings', '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', 'copyDatabase', 'copyTypings'));
gulp.task('build', gulp.series('cleanup', 'compile', 'copyTypings'));

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