Skip to content

Fixes for database and analytics exp release #4321

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 6 commits into from
Jan 21, 2021
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages-exp/analytics-exp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
"lint": "eslint -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
"lint:fix": "eslint --fix -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
"build": "rollup -c && yarn api-report",
"build:release": "rollup -c rollup.config.release.js && yarn api-report",
"build:deps": "lerna run --scope @firebase/analytics-exp --include-dependencies build",
"dev": "rollup -c -w",
"test": "run-p lint test:all",
"test:all": "run-p test:browser test:integration",
"test:ci": "node ../../scripts/run_tests_in_ci.js -s test:all",
"test:browser": "karma start --single-run --nocache",
"test:integration": "karma start ./karma.integration.conf.js --single-run --nocache",
"prepare": "yarn build",
"api-report": "api-extractor run --local --verbose",
"predoc": "node ../../scripts/exp/remove-exp.js temp",
"doc": "api-documenter markdown --input temp --output docs",
Expand Down
40 changes: 13 additions & 27 deletions packages-exp/analytics-exp/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import json from '@rollup/plugin-json';
import typescriptPlugin from 'rollup-plugin-typescript2';
import typescript from 'typescript';
import pkg from './package.json';
import { es2017BuildsNoPlugin, es5BuildsNoPlugin } from './rollup.shared';

const deps = Object.keys(
Object.assign({}, pkg.peerDependencies, pkg.dependencies)
Expand All @@ -34,20 +35,13 @@ const es5BuildPlugins = [
json()
];

const es5Builds = [
/**
* Browser Builds
*/
{
input: './src/index.ts',
output: [
{ file: pkg.main, format: 'cjs', sourcemap: true },
{ file: pkg.module, format: 'es', sourcemap: true }
],
plugins: es5BuildPlugins,
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
const es5Builds = es5BuildsNoPlugin.map(build => ({
...build,
plugins: es5BuildPlugins,
treeshake: {
moduleSideEffects: false
}
];
}));

/**
* ES2017 Builds
Expand All @@ -64,20 +58,12 @@ const es2017BuildPlugins = [
json({ preferConst: true })
];

const es2017Builds = [
/**
* Browser Builds
*/
{
input: './src/index.ts',
output: {
file: pkg.esm2017,
format: 'es',
sourcemap: true
},
plugins: es2017BuildPlugins,
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
const es2017Builds = es2017BuildsNoPlugin.map(build => ({
...build,
plugins: es2017BuildPlugins,
treeshake: {
moduleSideEffects: false
}
];
}));

export default [...es5Builds, ...es2017Builds];
73 changes: 73 additions & 0 deletions packages-exp/analytics-exp/rollup.config.release.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/**
* @license
* Copyright 2019 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 json from '@rollup/plugin-json';
import { importPathTransformer } from '../../scripts/exp/ts-transform-import-path';
import { es2017BuildsNoPlugin, es5BuildsNoPlugin } from './rollup.shared';

/**
* ES5 Builds
*/
const es5BuildPlugins = [
typescriptPlugin({
typescript,
clean: true,
abortOnError: false,
transformers: [importPathTransformer]
}),
json()
];

const es5Builds = es5BuildsNoPlugin.map(build => ({
...build,
plugins: es5BuildPlugins,
treeshake: {
moduleSideEffects: false
}
}));

/**
* ES2017 Builds
*/
const es2017BuildPlugins = [
typescriptPlugin({
typescript,
tsconfigOverride: {
compilerOptions: {
target: 'es2017'
}
},
abortOnError: false,
clean: true,
transformers: [importPathTransformer]
}),
json({
preferConst: true
})
];

const es2017Builds = es2017BuildsNoPlugin.map(build => ({
...build,
plugins: es2017BuildPlugins,
treeshake: {
moduleSideEffects: false
}
}));

export default [...es5Builds, ...es2017Builds];
53 changes: 53 additions & 0 deletions packages-exp/analytics-exp/rollup.shared.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* @license
* Copyright 2018 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 pkg from './package.json';

const deps = Object.keys(
Object.assign({}, pkg.peerDependencies, pkg.dependencies)
);

export const es5BuildsNoPlugin = [
/**
* Browser Builds
*/
{
input: 'src/index.ts',
output: [
{ file: pkg.main, format: 'cjs', sourcemap: true },
{ file: pkg.module, format: 'es', sourcemap: true }
],
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
}
];

/**
* ES2017 Builds
*/
export const es2017BuildsNoPlugin = [
{
/**
* Browser Build
*/
input: 'src/index.ts',
output: {
file: pkg.esm2017,
format: 'es',
sourcemap: true
},
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
}
];
18 changes: 18 additions & 0 deletions packages-exp/firebase-exp/database/index.ts
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 * from '@firebase/database';
8 changes: 8 additions & 0 deletions packages-exp/firebase-exp/database/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "firebase-exp/database",
"main": "dist/index.cjs.js",
"browser": "dist/index.esm.js",
"module": "dist/index.esm.js",
"typings": "dist/firestore/index.d.ts"
}

3 changes: 2 additions & 1 deletion packages-exp/firebase-exp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"storage",
"performance",
"remote-config",
"messaging"
"messaging",
"database"
]
}
2 changes: 2 additions & 0 deletions packages/database/rollup.config.exp.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const deps = Object.keys(
const es5BuildPlugins = [
typescriptPlugin({
typescript,
abortOnError: false,
transformers: [importPathTransformer]
}),
json()
Expand Down Expand Up @@ -74,6 +75,7 @@ const es2017BuildPlugins = [
target: 'es2017'
}
},
abortOnError: false,
transformers: [importPathTransformer]
}),
json({ preferConst: true })
Expand Down
62 changes: 62 additions & 0 deletions scripts/exp/prepare-database-for-exp-release.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/**
* @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 { projectRoot, readPackageJson } from '../utils';
import { writeFile as _writeFile, readFile as _readFile } from 'fs';
import { promisify } from 'util';

const writeFile = promisify(_writeFile);
const packagePath = `${projectRoot}/packages/database`;

/**
* Transform package.json in @firebase/database so that we can use scripts/exp/release.ts to release Database exp.
* It does following things:
* 1. Update package.json to point to exp binaries
* 2. Update version to '0.0.900', the version number we choose for releasing exp packages
* (9 stands for v9, 900 to avoid conflict with official versions).
* The release script will append commit hash to it and release the package with that version.
* e.g. 0.0.900-exp.fe85035e1
* 3. Replace peerDependencies with the exp version, so the release script can match and update them to the correct version.
*/
export async function prepare() {
// Update package.json
const packageJson = await readPackageJson(packagePath);
const expPackageJson = await readPackageJson(`${packagePath}/exp`);
packageJson.version = '0.0.900';

packageJson.peerDependencies = {
'@firebase/app-exp': '0.x',
'@firebase/app-types-exp': '0.x'
};

packageJson.main = expPackageJson.main.replace('../', '');
packageJson.module = expPackageJson.module.replace('../', '');
packageJson.browser = expPackageJson.browser.replace('../', '');
packageJson.esm2017 = expPackageJson.esm2017.replace('../', '');

packageJson.typings = expPackageJson.typings.replace('../', '');

// include files to be published
packageJson.files = [...packageJson.files, packageJson.typings];

// update package.json files
await writeFile(
`${packagePath}/package.json`,
`${JSON.stringify(packageJson, null, 2)}\n`,
{ encoding: 'utf-8' }
);
}
16 changes: 16 additions & 0 deletions scripts/exp/release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import chalk from 'chalk';
import Listr from 'listr';
import { prepare as prepareFirestoreForRelease } from './prepare-firestore-for-exp-release';
import { prepare as prepareStorageForRelease } from './prepare-storage-for-exp-release';
import { prepare as prepareDatabaseForRelease } from './prepare-database-for-exp-release';
import * as yargs from 'yargs';

const prompt = createPromptModule();
Expand Down Expand Up @@ -60,6 +61,7 @@ async function publishExpPackages({ dryRun }: { dryRun: boolean }) {
*/
await prepareFirestoreForRelease();
await prepareStorageForRelease();
await prepareDatabaseForRelease();

/**
* build packages
Expand All @@ -73,6 +75,7 @@ async function publishExpPackages({ dryRun }: { dryRun: boolean }) {

packagePaths.push(`${projectRoot}/packages/firestore`);
packagePaths.push(`${projectRoot}/packages/storage`);
packagePaths.push(`${projectRoot}/packages/database`);

/**
* It does 2 things:
Expand Down Expand Up @@ -195,6 +198,9 @@ async function buildPackages() {
// the same reason above
'@firebase/remote-config',
'--scope',
// the same reason above
'@firebase/analytics',
'--scope',
'@firebase/util',
'--scope',
'@firebase/component',
Expand Down Expand Up @@ -258,6 +264,16 @@ async function buildPackages() {
}
);

// Database
await spawn(
'yarn',
['lerna', 'run', '--scope', '@firebase/database', 'build:exp'],
{
cwd: projectRoot,
stdio: 'inherit'
}
);

// remove packages/installations/dist, otherwise packages that depend on packages-exp/installations-exp (e.g. Perf, FCM)
// will incorrectly reference packages/installations.
const installationsDistDirPath = resolve(
Expand Down