-
Notifications
You must be signed in to change notification settings - Fork 929
Add tooling to verify dependency chain #3033
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
Changes from all commits
f21776b
ea41857
7df1038
035091c
2124354
73ea558
9544284
040f141
ea361a4
4701cde
a0e8c26
f8995f0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** | ||
* @license | ||
* Copyright 2020 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
export function foo(): string; | ||
export function bar(): string; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* @license | ||
* Copyright 2020 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
export { foo, bar } from './src/api/foobar'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** | ||
* @license | ||
* Copyright 2020 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
export function foo(): string { | ||
return bar(); | ||
} | ||
|
||
export function bar(): string { | ||
return 'bar'; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"bar": { | ||
"dependencies": { | ||
"functions": [ | ||
"bar" | ||
], | ||
"classes": [], | ||
"variables": [] | ||
}, | ||
"sizeInBytes": 39 | ||
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. this is per function? seems like a pain to always update 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. It is auto-updated via the script, but the script is not run automatically. I'll send this to @Feiyang1 and we can ponder how we can automate this step. |
||
}, | ||
"foo": { | ||
"dependencies": { | ||
"functions": [ | ||
"bar", | ||
"foo" | ||
], | ||
"classes": [], | ||
"variables": [] | ||
}, | ||
"sizeInBytes": 67 | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/** | ||
* @license | ||
* Copyright 2020 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { expect } from 'chai'; | ||
|
||
import { extractDependencies } from '../../../../../scripts/exp/extract-deps.helpers'; | ||
|
||
import * as dependencies from './dependencies.json'; | ||
import * as pkg from '../../../package.json'; | ||
import { forEach } from '../../../src/util/obj'; | ||
|
||
describe('Dependencies', () => { | ||
forEach(dependencies, (api, { dependencies }) => { | ||
it(api, () => { | ||
return extractDependencies(api, pkg.exp).then(extractedDependencies => { | ||
expect(extractedDependencies.classes).to.have.members( | ||
dependencies.classes, | ||
'for classes' | ||
); | ||
expect(extractedDependencies.functions).to.have.members( | ||
dependencies.functions, | ||
'for functions' | ||
); | ||
expect(extractedDependencies.variables).to.have.members( | ||
dependencies.variables, | ||
'for variables' | ||
); | ||
}); | ||
}); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,15 +7,20 @@ | |
"description": "The Cloud Firestore component of the Firebase JS SDK.", | ||
"author": "Firebase <[email protected]> (https://firebase.google.com/)", | ||
"scripts": { | ||
"prebuild": "tsc -d --downlevelIteration --declarationDir dist/lib --emitDeclarationOnly && tsc -m es2015 --moduleResolution node scripts/*.ts ", | ||
"prebuild": "tsc -m es2015 --moduleResolution node scripts/*.ts ", | ||
"build": "rollup -c rollup.config.es2017.js && rollup -c rollup.config.es5.js", | ||
"build:deps": "lerna run --scope @firebase/'{app,firestore}' --include-dependencies build", | ||
"build:console": "node tools/console.build.js", | ||
"build:exp": "rollup -c rollup.config.exp.js", | ||
"predev": "yarn prebuild", | ||
"dev": "rollup -c -w", | ||
"lint": "eslint -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'", | ||
"lint:fix": "eslint --fix -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'", | ||
"prettier": "prettier --write '*.ts' '*.js' 'src/**/*.js' 'test/**/*.js' 'src/**/*.ts' 'test/**/*.ts'", | ||
"prettier": "prettier --write '*.ts' '*.js' 'exp/**/*.ts' 'src/**/*.js' 'test/**/*.js' 'src/**/*.ts' 'test/**/*.ts'", | ||
"pregendeps:exp": "yarn build:exp", | ||
"gendeps:exp": "../../scripts/exp/extract-deps.sh --types ./exp/index.d.ts --bundle ./dist/exp/index.js --output ./exp/test/deps/dependencies.json", | ||
"pretest:exp": "yarn build:exp", | ||
"test:exp": "TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'exp/test/**/*.test.ts' --file exp/index.node.ts --config ../../config/mocharc.node.js", | ||
"test": "run-s lint test:all", | ||
"test:ci": "node ../../scripts/run_tests_in_ci.js", | ||
"test:all": "run-p test:browser test:travis test:minified", | ||
|
@@ -34,6 +39,7 @@ | |
"browser": "dist/index.cjs.js", | ||
"module": "dist/index.esm.js", | ||
"esm2017": "dist/index.esm2017.js", | ||
"exp": "dist/exp/index.js", | ||
"license": "Apache-2.0", | ||
"files": [ | ||
"dist", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** | ||
* @license | ||
* Copyright 2020 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import typescriptPlugin from 'rollup-plugin-typescript2'; | ||
import typescript from 'typescript'; | ||
|
||
import { resolveNodeExterns } from './rollup.shared'; | ||
|
||
import pkg from './package.json'; | ||
|
||
const defaultPlugins = [ | ||
typescriptPlugin({ | ||
typescript, | ||
tsconfigOverride: { | ||
compilerOptions: { | ||
target: 'es2017' | ||
} | ||
}, | ||
clean: true | ||
}) | ||
]; | ||
|
||
const nodeBuilds = [ | ||
{ | ||
input: './exp/index.node.ts', | ||
output: { | ||
file: pkg.exp, | ||
format: 'es' | ||
}, | ||
plugins: defaultPlugins, | ||
external: resolveNodeExterns, | ||
treeshake: { | ||
tryCatchDeoptimization: false | ||
} | ||
} | ||
]; | ||
|
||
export default [...nodeBuilds]; |
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.
Note: This file is generated by the Node CLI tool and then used in the unit test as the source of truth. It is checked in and as such provides a nice diff as we make changes.
"sizeInBytes" is for reference only.