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

Updates to latest dependencies, and transpilation targets #1658

Merged
merged 8 commits into from
Oct 3, 2018
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
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ module.exports = {
rules: {
"jsdoc/check-types": 2,
"jsdoc/newline-after-description": 2,
'indent': ['error', 2],
Copy link
Member

Choose a reason for hiding this comment

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

What's this being added for?

Copy link
Member

Choose a reason for hiding this comment

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

Oh, now that I'm looking at the rest of the changes, I see what you're doing. But technically this isn't consistent with Google style because in some cases Google style recommends indenting 4 spaces (e.g. line continuations and stuff like that).

The google eslint package v0.10.0 adds an indentation rule more inline with what's recommended by Google JS style. It's probably worth just upgrading to that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As discussed in person, there are going to be a lot of additional files that need whitespace adjustment if we don't include this.

We're already using "eslint-config-google": "^0.10.0" as part of this PR.

Let's do separate PR to remove this override and get all the whitespace consistent rather than including any more changes in this PR.

Copy link
Member

Choose a reason for hiding this comment

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

SGTM

},
plugins: [
'jsdoc',
],
parser: 'babel-eslint',
overrides: [{
files: ['test/**/*.{js,mjs}'],
parser: 'babel-eslint',
env: {
mocha: true,
},
Expand Down
2 changes: 1 addition & 1 deletion demos/functions/cdn-details.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"latestUrl":"https://storage.googleapis.com/workbox-cdn/releases/3.6.1"}
{"latestUrl":"https://storage.googleapis.com/workbox-cdn/releases/3.6.2"}
6,110 changes: 3,480 additions & 2,630 deletions demos/functions/package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions demos/functions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"name": "functions",
"description": "Cloud Functions for Firebase",
"dependencies": {
"express": "^4.16.2",
"express": "^4.16.3",
"express-handlebars": "^3.0.0",
"firebase-admin": "~5.4.0",
"firebase-functions": "^0.7.0",
"fs-extra": "^4.0.2"
"firebase-admin": "^6.0.0",
"firebase-functions": "^2.0.5",
"fs-extra": "^7.0.0"
},
"private": true
}
10 changes: 5 additions & 5 deletions gulp-tasks/build-packages.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ const cleanPackage = (packagePath) => {
};

gulp.task('build-packages:clean', gulp.series(
packageRunnner(
'build-packages:clean',
'all',
cleanPackage
)
packageRunnner(
'build-packages:clean',
'all',
cleanPackage
)
));

gulp.task('build-packages:build', gulp.parallel(
Expand Down
26 changes: 8 additions & 18 deletions gulp-tasks/docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const fs = require('fs-extra');
const path = require('path');
const gulp = require('gulp');
const getNpmCmd = require('./utils/get-npm-cmd');
const browserSync = require('browser-sync').create();

const spawn = require('./utils/spawn-promise-wrapper');
const logHelper = require('../infra/utils/log-helper');
Expand Down Expand Up @@ -54,14 +53,13 @@ You can view a friendlier UI by running
return spawn(getNpmCmd(), params, {
cwd: path.join(__dirname, '..'),
})
.then(() => {
logHelper.log(`Docs built successfully`);
browserSync.reload();
})
.catch((err) => {
logHelper.error(`Docs failed to build: `, err);
throw err;
});
.then(() => {
logHelper.log(`Docs built successfully`);
})
.catch((err) => {
logHelper.error(`Docs failed to build: `, err);
throw err;
});
};
};

Expand All @@ -83,15 +81,7 @@ gulp.task('docs:watch', () => {
});
});

gulp.task('docs:serve', () => {
browserSync.init({
server: {
baseDir: DOCS_DIRECTORY,
},
});
});

gulp.task('docs', gulp.series([
'docs:build',
gulp.parallel(['docs:serve', 'docs:watch']),
'docs:watch',
]));
8 changes: 4 additions & 4 deletions gulp-tasks/lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ const logHelper = require('../infra/utils/log-helper');
// Use npm run lint to ensure we are using local eslint
gulp.task('lint', () => {
return spawn(getNpmCmd(), ['run', 'lint'])
.catch((err) => {
logHelper.error(err);
throw new Error(`[Workbox Error Msg] 'gulp lint' discovered errors.`);
});
.catch((err) => {
logHelper.error(err);
throw new Error(`[Workbox Error Msg] 'gulp lint' discovered errors.`);
});
});
56 changes: 28 additions & 28 deletions gulp-tasks/publish-github.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,36 @@ const logHelper = require('../infra/utils/log-helper');

const publishReleaseOnGithub =
async (tagName, releaseInfo, tarPath, zipPath) => {
if (!releaseInfo) {
const releaseData = await githubHelper.createRelease({
tag_name: tagName,
draft: true,
name: `Workbox ${tagName}`,
prerelease: semver.prerelease(tagName) !== null,
});
releaseInfo = releaseData.data;
}
if (!releaseInfo) {
const releaseData = await githubHelper.createRelease({
tag_name: tagName,
draft: true,
name: `Workbox ${tagName}`,
prerelease: semver.prerelease(tagName) !== null,
});
releaseInfo = releaseData.data;
}

const tarBuffer = await fs.readFile(tarPath);
await githubHelper.uploadAsset({
url: releaseInfo.upload_url,
file: tarBuffer,
contentType: 'application/gzip',
contentLength: tarBuffer.length,
name: path.basename(tarPath),
label: path.basename(tarPath),
});
const tarBuffer = await fs.readFile(tarPath);
await githubHelper.uploadAsset({
url: releaseInfo.upload_url,
file: tarBuffer,
contentType: 'application/gzip',
contentLength: tarBuffer.length,
name: path.basename(tarPath),
label: path.basename(tarPath),
});

const zipBuffer = await fs.readFile(zipPath);
await githubHelper.uploadAsset({
url: releaseInfo.upload_url,
file: zipBuffer,
contentType: 'application/zip',
contentLength: zipBuffer.length,
name: path.basename(zipPath),
label: path.basename(zipPath),
});
};
const zipBuffer = await fs.readFile(zipPath);
await githubHelper.uploadAsset({
url: releaseInfo.upload_url,
file: zipBuffer,
contentType: 'application/zip',
contentLength: zipBuffer.length,
name: path.basename(zipPath),
label: path.basename(zipPath),
});
};

const handleGithubRelease = async (tagName, gitBranch, releaseInfo) => {
logHelper.log(`Creating GitHub release ${logHelper.highlight(tagName)}.`);
Expand Down
28 changes: 14 additions & 14 deletions gulp-tasks/test-integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const runFiles = (filePaths) => {
};

const runIntegrationTestSuite = async (testPath, nodeEnv, seleniumBrowser,
webdriver) => {
webdriver) => {
logHelper.log(oneLine`
Running Integration test on ${logHelper.highlight(testPath)}
with NODE_ENV '${nodeEnv}'
Expand Down Expand Up @@ -116,19 +116,19 @@ gulp.task('test-integration', async () => {
const localBrowsers = seleniumAssistant.getLocalBrowsers();
for (const localBrowser of localBrowsers) {
switch (localBrowser.getId()) {
case 'chrome':
case 'firefox':
if (localBrowser.getReleaseName() !== 'unstable') {
await runIntegrationForBrowser(localBrowser);
}
break;
case 'safari':
if (localBrowser.getReleaseName() === 'stable') {
await runIntegrationForBrowser(localBrowser);
}
break;
default:
logHelper.warn(oneLine`
case 'chrome':
case 'firefox':
if (localBrowser.getReleaseName() !== 'unstable') {
await runIntegrationForBrowser(localBrowser);
}
break;
case 'safari':
if (localBrowser.getReleaseName() === 'stable') {
await runIntegrationForBrowser(localBrowser);
}
break;
default:
logHelper.warn(oneLine`
Skipping integration tests for ${localBrowser.getPrettyName()}.
`);
}
Expand Down
16 changes: 8 additions & 8 deletions gulp-tasks/utils/analyse-properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,18 @@ class AnalyseBuildForProperties {
// either not important or it's already been minified.
return entry.propertyCount > 1 && entry.propertyName.length > 1;
})
.filter((entry) => {
switch (entry.propertyName) {
.filter((entry) => {
switch (entry.propertyName) {
case 'await':
case 'async':
return false;
default:
return true;
}
})
.sort((a, b) => {
return b.propertyCount - a.propertyCount;
});
}
})
.sort((a, b) => {
return b.propertyCount - a.propertyCount;
});
}

printDetails({filePath, analysis}) {
Expand All @@ -105,7 +105,7 @@ class AnalyseBuildForProperties {
logHelper.log(` ${entry.propertyName} ` +
`${extraSpace} ${entry.propertyCount}`);
});
logHelper.log();
logHelper.log();
}
}

Expand Down
43 changes: 19 additions & 24 deletions gulp-tasks/utils/build-browser-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const globals = (moduleId) => {
if (namespacePathParts[0] !== '_private' || namespacePathParts.length > 2) {
// Tried to pull in default export of module - this isn't allowed.
// A specific file must be referenced
throw new Error(oneLine`
throw new Error(oneLine`
You cannot use nested files. It must be a top level (and public) file
or a file under '_private' in a module. Please fix the import:
'${moduleId}'
Expand All @@ -77,10 +77,10 @@ const globals = (moduleId) => {
pkg.workbox.browserNamespace,
additionalNamespace,
]
.filter((value) => {
return (value && value.length > 0);
})
.join('.');
.filter((value) => {
return (value && value.length > 0);
})
.join('.');
} catch (err) {
logHelper.error(`Unable to get browserNamespace for package: ` +
`'${packageName}'`);
Expand Down Expand Up @@ -136,18 +136,13 @@ module.exports = (packagePath, buildType) => {

const plugins = rollupHelper.getDefaultPlugins(buildType);

const banner = pkgJson.workbox.includeBabelHelpers ?
fs.readFileSync(path.join(__dirname, 'external-helpers.js')) :
'';

return rollupStream({
input: moduleBrowserPath,
rollup,
output: {
name: namespace,
sourcemap: true,
format: 'iife',
banner,
globals,
},
external: externalAndPure,
Expand All @@ -172,24 +167,24 @@ module.exports = (packagePath, buildType) => {
}
},
})
.on('error', (err) => {
const args = [];
Object.keys(err).forEach((key) => {
args.push(`${key}: ${err[key]}`);
});
logHelper.error(err, `\n\n${args.join('\n')}`);
throw err;
})
.on('error', (err) => {
const args = [];
Object.keys(err).forEach((key) => {
args.push(`${key}: ${err[key]}`);
});
logHelper.error(err, `\n\n${args.join('\n')}`);
throw err;
})
// We must give the generated stream the same name as the entry file
// for the sourcemaps to work correctly
.pipe(source(moduleBrowserPath))
.pipe(source(moduleBrowserPath))
// gulp-sourcemaps don't work with streams so we need
.pipe(buffer())
.pipe(buffer())
// This tells gulp-sourcemaps to load the inline sourcemap
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(sourcemaps.init({loadMaps: true}))
// This renames the output file
.pipe(rename(outputFilename))
.pipe(rename(outputFilename))
// This writes the sourcemap alongside the final build file
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(outputDirectory));
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(outputDirectory));
};
8 changes: 4 additions & 4 deletions gulp-tasks/utils/build-node-package.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ module.exports = (packagePath) => {
`);

return gulp.src(`${packagePath}/src/**`).pipe(babel({
only: /\.js$/,
only: [/\.js$/],
presets: [
['env', {
['@babel/preset-env', {
targets: {
// Change this when our minimum required node version changes.
node: '4.0',
node: '6.0',
},
}],
],
Expand All @@ -32,7 +32,7 @@ module.exports = (packagePath) => {
// are only included in our Rollup bundles once, even if they're used
// in multiple source files.
// See https://github.com/rollup/rollup-plugin-babel#helpers
'transform-runtime',
'@babel/transform-runtime',
Copy link
Member

Choose a reason for hiding this comment

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

BTW, if we're getting rid of the regenerator runtime polyfill, we may not need this at all anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We still need it for the node libraries, since we're targeting node 6, and that doesn't support async/await.

],
})).pipe(gulp.dest(outputDirectory));
};
2 changes: 1 addition & 1 deletion gulp-tasks/utils/get-npm-cmd.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
module.exports = () => process.platform === 'win32' ?
'npm.cmd' : 'npm';
'npm.cmd' : 'npm';
3 changes: 1 addition & 2 deletions gulp-tasks/utils/lerna-wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ const spawnPromiseWrapper = require('./spawn-promise-wrapper');
// Use require.resolve() to find the lerna module, then get the lerna
// binary from that. This allows the use of lerna with command line
// flags.
const lernaBinPath = path.join(
require.resolve('lerna'), '..', '..', 'bin', 'lerna.js');
const lernaBinPath = path.join(require.resolve('lerna'), '..', 'cli.js');

module.exports = {
bootstrap: (...args) => {
Expand Down
Loading