diff --git a/packages/workbox-build/src/entry-points/generate-sw-string.js b/packages/workbox-build/src/entry-points/generate-sw-string.js index 36458bb3e..2f2f49a58 100644 --- a/packages/workbox-build/src/entry-points/generate-sw-string.js +++ b/packages/workbox-build/src/entry-points/generate-sw-string.js @@ -6,6 +6,8 @@ https://opensource.org/licenses/MIT. */ +const checkForDeprecatedOptions = + require('../lib/check-for-deprecated-options'); const generateSWStringSchema = require('./options/generate-sw-string-schema'); const getFileManifestEntries = require('../lib/get-file-manifest-entries'); const populateSWTemplate = require('../lib/populate-sw-template'); @@ -25,6 +27,10 @@ const validate = require('./options/validate'); * @memberof module:workbox-build */ async function generateSWString(config) { + // This check needs to be done before validation, since the deprecated options + // will be renamed. + const deprecationWarnings = checkForDeprecatedOptions(config); + const options = validate(config, generateSWStringSchema); const {manifestEntries, warnings} = await getFileManifestEntries(options); @@ -33,6 +39,9 @@ async function generateSWString(config) { manifestEntries, }, options)); + // Add in any deprecation warnings. + warnings.push(...deprecationWarnings); + return {swString, warnings}; } diff --git a/packages/workbox-build/src/entry-points/generate-sw.js b/packages/workbox-build/src/entry-points/generate-sw.js index c465a087e..1571363b1 100644 --- a/packages/workbox-build/src/entry-points/generate-sw.js +++ b/packages/workbox-build/src/entry-points/generate-sw.js @@ -9,6 +9,8 @@ const path = require('path'); const cdnUtils = require('../lib/cdn-utils'); +const checkForDeprecatedOptions = + require('../lib/check-for-deprecated-options'); const copyWorkboxLibraries = require('../lib/copy-workbox-libraries'); const generateSWSchema = require('./options/generate-sw-schema'); const getFileManifestEntries = require('../lib/get-file-manifest-entries'); @@ -38,14 +40,18 @@ const writeServiceWorkerUsingDefaultTemplate = * @memberof module:workbox-build */ async function generateSW(config) { + // This check needs to be done before validation, since the deprecated options + // will be renamed. + const deprecationWarnings = checkForDeprecatedOptions(config); + const options = validate(config, generateSWSchema); const destDirectory = path.dirname(options.swDest); // Do nothing if importWorkboxFrom is set to 'disabled'. Otherwise, check: if (options.importWorkboxFrom === 'cdn') { - const cdnUrl = cdnUtils.getModuleUrl('workbox-sw'); - options.workboxSWImport = cdnUrl; + const cdnURL = cdnUtils.getModuleURL('workbox-sw'); + options.workboxSWImport = cdnURL; } else if (options.importWorkboxFrom === 'local') { // Copy over the dev + prod version of all of the core libraries. const workboxDirectoryName = await copyWorkboxLibraries(destDirectory); @@ -70,6 +76,9 @@ async function generateSW(config) { manifestEntries, }, options)); + // Add in any deprecation warnings. + warnings.push(...deprecationWarnings); + return {count, size, warnings}; } diff --git a/packages/workbox-build/src/entry-points/get-manifest.js b/packages/workbox-build/src/entry-points/get-manifest.js index eea97d9d5..e24545e7d 100644 --- a/packages/workbox-build/src/entry-points/get-manifest.js +++ b/packages/workbox-build/src/entry-points/get-manifest.js @@ -6,6 +6,8 @@ https://opensource.org/licenses/MIT. */ +const checkForDeprecatedOptions = + require('../lib/check-for-deprecated-options'); const getFileManifestEntries = require('../lib/get-file-manifest-entries'); const getManifestSchema = require('./options/get-manifest-schema'); const validate = require('./options/validate'); @@ -28,10 +30,18 @@ const validate = require('./options/validate'); * @memberof module:workbox-build */ async function getManifest(config) { + // This check needs to be done before validation, since the deprecated options + // will be renamed. + const deprecationWarnings = checkForDeprecatedOptions(config); + const options = validate(config, getManifestSchema); const {manifestEntries, count, size, warnings} = await getFileManifestEntries(options); + + // Add in any deprecation warnings. + warnings.push(...deprecationWarnings); + return {manifestEntries, count, size, warnings}; } diff --git a/packages/workbox-build/src/entry-points/inject-manifest.js b/packages/workbox-build/src/entry-points/inject-manifest.js index 0f694aa23..2ba8ee086 100644 --- a/packages/workbox-build/src/entry-points/inject-manifest.js +++ b/packages/workbox-build/src/entry-points/inject-manifest.js @@ -10,6 +10,8 @@ const assert = require('assert'); const fse = require('fs-extra'); const path = require('path'); +const checkForDeprecatedOptions = + require('../lib/check-for-deprecated-options'); const defaults = require('./options/defaults'); const errors = require('../lib/errors'); const getFileManifestEntries = require('../lib/get-file-manifest-entries'); @@ -38,6 +40,10 @@ const validate = require('./options/validate'); * @memberof module:workbox-build */ async function injectManifest(config) { + // This check needs to be done before validation, since the deprecated options + // will be renamed. + const deprecationWarnings = checkForDeprecatedOptions(config); + const options = validate(config, injectManifestSchema); if (path.normalize(config.swSrc) === path.normalize(config.swDest)) { @@ -79,6 +85,9 @@ async function injectManifest(config) { await fse.writeFile(config.swDest, swFileContents); + // Add in any deprecation warnings. + warnings.push(...deprecationWarnings); + return {count, size, warnings}; } diff --git a/packages/workbox-build/src/entry-points/options/base-schema.js b/packages/workbox-build/src/entry-points/options/base-schema.js index f81c9d274..f8103cbfd 100644 --- a/packages/workbox-build/src/entry-points/options/base-schema.js +++ b/packages/workbox-build/src/entry-points/options/base-schema.js @@ -13,7 +13,7 @@ const regExpObject = require('./reg-exp-object'); // Define some common constrains used by all methods. module.exports = joi.object().keys({ - dontCacheBustUrlsMatching: regExpObject, + dontCacheBustURLsMatching: regExpObject, globFollow: joi.boolean().default(defaults.globFollow), globIgnores: joi.array().items(joi.string()).default(defaults.globIgnores), globPatterns: joi.array().items(joi.string()).default(defaults.globPatterns), @@ -21,9 +21,18 @@ module.exports = joi.object().keys({ manifestTransforms: joi.array().items(joi.func().arity(1)), maximumFileSizeToCacheInBytes: joi.number().min(1) .default(defaults.maximumFileSizeToCacheInBytes), - modifyUrlPrefix: joi.object(), - // templatedUrls is an object where any property name is valid, and the values + modifyURLPrefix: joi.object(), + // templatedURLs is an object where any property name is valid, and the values // can be either a string or an array of strings. - templatedUrls: joi.object().pattern(/./, + templatedURLs: joi.object().pattern(/./, [joi.string(), joi.array().items(joi.string())]), +}).rename('dontCacheBustUrlsMatching', 'dontCacheBustURLsMatching', { + ignoreUndefined: true, + override: true, +}).rename('modifyUrlPrefix', 'modifyURLPrefix', { + ignoreUndefined: true, + override: true, +}).rename('templatedUrls', 'templatedURLs', { + ignoreUndefined: true, + override: true, }); diff --git a/packages/workbox-build/src/entry-points/options/common-generate-schema.js b/packages/workbox-build/src/entry-points/options/common-generate-schema.js index b95f61b8d..83d6672a9 100644 --- a/packages/workbox-build/src/entry-points/options/common-generate-schema.js +++ b/packages/workbox-build/src/entry-points/options/common-generate-schema.js @@ -17,7 +17,7 @@ module.exports = baseSchema.keys({ cacheId: joi.string(), clientsClaim: joi.boolean().default(defaults.clientsClaim), directoryIndex: joi.string(), - ignoreUrlParametersMatching: joi.array().items(regExpObject), + ignoreURLParametersMatching: joi.array().items(regExpObject), navigateFallback: joi.string().default(defaults.navigateFallback), navigateFallbackBlacklist: joi.array().items(regExpObject), navigateFallbackWhitelist: joi.array().items(regExpObject), @@ -66,4 +66,7 @@ module.exports = baseSchema.keys({ }).with('expiration', 'cacheName'), }).requiredKeys('urlPattern', 'handler')), skipWaiting: joi.boolean().default(defaults.skipWaiting), +}).rename('ignoreUrlParametersMatching', 'ignoreURLParametersMatching', { + ignoreUndefined: true, + override: true, }); diff --git a/packages/workbox-build/src/index.js b/packages/workbox-build/src/index.js index 68fa02b13..b583772e3 100644 --- a/packages/workbox-build/src/index.js +++ b/packages/workbox-build/src/index.js @@ -11,7 +11,7 @@ const generateSW = require('./entry-points/generate-sw'); const generateSWString = require('./entry-points/generate-sw-string'); const getManifest = require('./entry-points/get-manifest'); const injectManifest = require('./entry-points/inject-manifest'); -const {getModuleUrl} = require('./lib/cdn-utils'); +const {getModuleURL} = require('./lib/cdn-utils'); /** * This Node module can be used to generate a list of assets that should be @@ -36,7 +36,7 @@ const {getModuleUrl} = require('./lib/cdn-utils'); * service worker file and are okay with including the manifest yourself. * See [getManifest()]{@link module:workbox-build.getManifest}. * - * @property {Array} [ignoreUrlParametersMatching=[/^utm_/]] Any + * @property {Array} [ignoreURLParametersMatching=[/^utm_/]] Any * search parameter names that match against one of the regex's in this array * will be removed before looking for a precache match. * @@ -75,6 +75,6 @@ module.exports = { generateSW, generateSWString, getManifest, - getModuleUrl, + getModuleURL, injectManifest, }; diff --git a/packages/workbox-build/src/lib/cdn-utils.js b/packages/workbox-build/src/lib/cdn-utils.js index e43780f7a..8365385b1 100644 --- a/packages/workbox-build/src/lib/cdn-utils.js +++ b/packages/workbox-build/src/lib/cdn-utils.js @@ -15,11 +15,11 @@ const getCDNOrigin = () => { return `${cdn.origin}/${cdn.bucketName}/${cdn.releasesDir}`; }; -const getVersionedCDNUrl = () => { +const getVersionedCDNURL = () => { return `${getCDNOrigin()}/${cdn.latestVersion}`; }; -const getModuleUrl = (moduleName, buildType) => { +const getModuleURL = (moduleName, buildType) => { assert(moduleName, errors['no-module-name']); if (buildType) { @@ -29,12 +29,12 @@ const getModuleUrl = (moduleName, buildType) => { // without creating an entry in errors.js. throw Error(`The 'dev' build of ${moduleName} is not available.`); } - return `${getVersionedCDNUrl()}/${moduleName}.${buildType.slice(0, 4)}.js`; + return `${getVersionedCDNURL()}/${moduleName}.${buildType.slice(0, 4)}.js`; } - return `${getVersionedCDNUrl()}/${moduleName}.js`; + return `${getVersionedCDNURL()}/${moduleName}.js`; }; module.exports = { getCDNOrigin, - getModuleUrl, + getModuleURL, }; diff --git a/packages/workbox-build/src/lib/check-for-deprecated-options.js b/packages/workbox-build/src/lib/check-for-deprecated-options.js new file mode 100644 index 000000000..e03cf3f28 --- /dev/null +++ b/packages/workbox-build/src/lib/check-for-deprecated-options.js @@ -0,0 +1,26 @@ +/* + Copyright 2019 Google LLC + + Use of this source code is governed by an MIT-style + license that can be found in the LICENSE file or at + https://opensource.org/licenses/MIT. +*/ + +const ol = require('common-tags').oneLine; + +const oldToNewOptionNames = { + dontCacheBustUrlsMatching: 'dontCacheBustURLsMatching', + ignoreUrlParametersMatching: 'ignoreURLParametersMatching', + modifyUrlPrefix: 'modifyURLPrefix', + templatedUrls: 'templatedURLs', +}; + +module.exports = (options) => { + return Object.entries(oldToNewOptionNames).map(([oldOption, newOption]) => { + if (oldOption in options) { + return ol`The '${oldOption}' option is deprecated and will be removed in a + future release of Workbox. Please update your config to use '${newOption}' + instead.`; + } + }).filter((item) => item); +}; diff --git a/packages/workbox-build/src/lib/errors.js b/packages/workbox-build/src/lib/errors.js index 947365359..824ccaab5 100644 --- a/packages/workbox-build/src/lib/errors.js +++ b/packages/workbox-build/src/lib/errors.js @@ -42,7 +42,7 @@ module.exports = { 'invalid-generate-sw-input': ol`The input to generateSW() must be an object.`, 'invalid-glob-directory': ol`The supplied globDirectory must be a path as a string.`, - 'invalid-dont-cache-bust': ol`The supplied 'dontCacheBustUrlsMatching' + 'invalid-dont-cache-bust': ol`The supplied 'dontCacheBustURLsMatching' parameter must be a RegExp.`, 'invalid-exclude-files': 'The excluded files should be an array of strings.', 'invalid-get-manifest-entries-input': ol`The input to @@ -55,15 +55,15 @@ module.exports = { generateFileManifest() must be either 'iife' (the default) or 'es'.`, 'invalid-static-file-globs': ol`The 'globPatterns' value must be an array of strings.`, - 'invalid-templated-urls': ol`The 'templatedUrls' value should be an object + 'invalid-templated-urls': ol`The 'templatedURLs' value should be an object that maps URLs to either a string, or to an array of glob patterns.`, - 'templated-url-matches-glob': ol`One of the 'templatedUrls' URLs is already + 'templated-url-matches-glob': ol`One of the 'templatedURLs' URLs is already being tracked via 'globPatterns': `, 'invalid-glob-ignores': ol`The 'globIgnores' parameter must be an array of glob pattern strings.`, 'manifest-entry-bad-url': ol`The generated manifest contains an entry without a URL string. This is likely an error with workbox-build.`, - 'modify-url-prefix-bad-prefixes': ol`The 'modifyUrlPrefix' parameter must be + 'modify-url-prefix-bad-prefixes': ol`The 'modifyURLPrefix' parameter must be an object with string key value pairs.`, 'invalid-inject-manifest-arg': ol`The input to 'injectManifest()' must be an object.`, @@ -76,13 +76,13 @@ module.exports = { 'useless-glob-pattern': ol`One of the glob patterns doesn't match any files. Please remove or fix the following: `, 'bad-template-urls-asset': ol`There was an issue using one of the provided - 'templatedUrls'.`, + 'templatedURLs'.`, 'invalid-runtime-caching': ol`The 'runtimeCaching' parameter must an an array of objects with at least a 'urlPattern' and 'handler'.`, 'static-file-globs-deprecated': ol`'staticFileGlobs' is deprecated. Please use 'globPatterns' instead.`, - 'dynamic-url-deprecated': ol`'dynamicUrlToDependencies' is deprecated. - Please use 'templatedUrls' instead.`, + 'dynamic-url-deprecated': ol`'dynamicURLToDependencies' is deprecated. + Please use 'templatedURLs' instead.`, 'urlPattern-is-required': ol`The 'urlPattern' option is required when using 'runtimeCaching'.`, 'handler-is-required': ol`The 'handler' option is required when using @@ -100,5 +100,5 @@ module.exports = { 'invalid-network-timeout-seconds': ol`When using networkTimeoutSeconds, you must set the handler to 'networkFirst'.`, 'no-module-name': ol`You must provide a moduleName parameter when calling - getModuleUrl().`, + getModuleURL().`, }; diff --git a/packages/workbox-build/src/lib/filter-files.js b/packages/workbox-build/src/lib/filter-files.js index c68e07af9..39bd39cfd 100644 --- a/packages/workbox-build/src/lib/filter-files.js +++ b/packages/workbox-build/src/lib/filter-files.js @@ -7,8 +7,8 @@ */ const maximumSizeTransform = require('./maximum-size-transform'); -const modifyUrlPrefixTranform = require('./modify-url-prefix-transform'); -const noRevisionForUrlsMatchingTransform = +const modifyURLPrefixTranform = require('./modify-url-prefix-transform'); +const noRevisionForURLsMatchingTransform = require('./no-revision-for-urls-matching-transform'); /** @@ -62,11 +62,11 @@ const noRevisionForUrlsMatchingTransform = */ module.exports = ({ - dontCacheBustUrlsMatching, + dontCacheBustURLsMatching, fileDetails, manifestTransforms, maximumFileSizeToCacheInBytes, - modifyUrlPrefix, + modifyURLPrefix, }) => { let allWarnings = []; @@ -86,13 +86,13 @@ module.exports = ({ transformsToApply.push(maximumSizeTransform(maximumFileSizeToCacheInBytes)); } - if (modifyUrlPrefix) { - transformsToApply.push(modifyUrlPrefixTranform(modifyUrlPrefix)); + if (modifyURLPrefix) { + transformsToApply.push(modifyURLPrefixTranform(modifyURLPrefix)); } - if (dontCacheBustUrlsMatching) { + if (dontCacheBustURLsMatching) { transformsToApply.push( - noRevisionForUrlsMatchingTransform(dontCacheBustUrlsMatching)); + noRevisionForURLsMatchingTransform(dontCacheBustURLsMatching)); } // Any additional manifestTransforms that were passed will be applied last. diff --git a/packages/workbox-build/src/lib/get-composite-details.js b/packages/workbox-build/src/lib/get-composite-details.js index dda3693ca..f06434360 100644 --- a/packages/workbox-build/src/lib/get-composite-details.js +++ b/packages/workbox-build/src/lib/get-composite-details.js @@ -8,7 +8,7 @@ const crypto = require('crypto'); -module.exports = (compositeUrl, dependencyDetails) => { +module.exports = (compositeURL, dependencyDetails) => { let totalSize = 0; let compositeHash = ''; @@ -22,7 +22,7 @@ module.exports = (compositeUrl, dependencyDetails) => { const hashOfHashes = md5.digest('hex'); return { - file: compositeUrl, + file: compositeURL, hash: hashOfHashes, size: totalSize, }; diff --git a/packages/workbox-build/src/lib/get-file-manifest-entries.js b/packages/workbox-build/src/lib/get-file-manifest-entries.js index 631707db8..c1c86cab4 100644 --- a/packages/workbox-build/src/lib/get-file-manifest-entries.js +++ b/packages/workbox-build/src/lib/get-file-manifest-entries.js @@ -16,7 +16,7 @@ const getFileDetails = require('./get-file-details'); const getStringDetails = require('./get-string-details'); module.exports = async ({ - dontCacheBustUrlsMatching, + dontCacheBustURLsMatching, globDirectory, globFollow, globIgnores, @@ -24,9 +24,9 @@ module.exports = async ({ globStrict, manifestTransforms, maximumFileSizeToCacheInBytes, - modifyUrlPrefix, + modifyURLPrefix, swDest, - templatedUrls, + templatedURLs, }) => { const warnings = []; // Initialize to an empty array so that we can still pass something to @@ -67,11 +67,11 @@ module.exports = async ({ } } - if (templatedUrls) { - for (let url of Object.keys(templatedUrls)) { + if (templatedURLs) { + for (let url of Object.keys(templatedURLs)) { assert(!fileSet.has(url), errors['templated-url-matches-glob']); - const dependencies = templatedUrls[url]; + const dependencies = templatedURLs[url]; if (Array.isArray(dependencies)) { const details = dependencies.reduce((previous, globPattern) => { try { @@ -99,7 +99,7 @@ module.exports = async ({ } const filteredFiles = filterFiles({fileDetails, - maximumFileSizeToCacheInBytes, modifyUrlPrefix, dontCacheBustUrlsMatching, + maximumFileSizeToCacheInBytes, modifyURLPrefix, dontCacheBustURLsMatching, manifestTransforms}); if (warnings.length > 0) { diff --git a/packages/workbox-build/src/lib/modify-url-prefix-transform.js b/packages/workbox-build/src/lib/modify-url-prefix-transform.js index cc7146a54..679c2ecf1 100644 --- a/packages/workbox-build/src/lib/modify-url-prefix-transform.js +++ b/packages/workbox-build/src/lib/modify-url-prefix-transform.js @@ -26,29 +26,29 @@ const escapeRegExp = (string) => { return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); }; -module.exports = (modifyUrlPrefix) => { - if (!modifyUrlPrefix || - typeof modifyUrlPrefix !== 'object' || - Array.isArray(modifyUrlPrefix)) { +module.exports = (modifyURLPrefix) => { + if (!modifyURLPrefix || + typeof modifyURLPrefix !== 'object' || + Array.isArray(modifyURLPrefix)) { throw new Error(errors['modify-url-prefix-bad-prefixes']); } - // If there are no entries in modifyUrlPrefix, just return an identity + // If there are no entries in modifyURLPrefix, just return an identity // function as a shortcut. - if (Object.keys(modifyUrlPrefix).length === 0) { + if (Object.keys(modifyURLPrefix).length === 0) { return (entry) => entry; } - Object.keys(modifyUrlPrefix).forEach((key) => { - if (typeof modifyUrlPrefix[key] !== 'string') { + Object.keys(modifyURLPrefix).forEach((key) => { + if (typeof modifyURLPrefix[key] !== 'string') { throw new Error(errors['modify-url-prefix-bad-prefixes']); } }); // Escape the user input so it's safe to use in a regex. - const safeModifyUrlPrefixes = Object.keys(modifyUrlPrefix).map(escapeRegExp); - // Join all the `modifyUrlPrefix` keys so a single regex can be used. - const prefixMatchesStrings = safeModifyUrlPrefixes.join('|'); + const safeModifyURLPrefixes = Object.keys(modifyURLPrefix).map(escapeRegExp); + // Join all the `modifyURLPrefix` keys so a single regex can be used. + const prefixMatchesStrings = safeModifyURLPrefixes.join('|'); // Add `^` to the front the prefix matches so it only matches the start of // a string. const modifyRegex = new RegExp(`^(${prefixMatchesStrings})`); @@ -60,7 +60,7 @@ module.exports = (modifyUrlPrefix) => { } entry.url = entry.url.replace(modifyRegex, (match) => { - return modifyUrlPrefix[match]; + return modifyURLPrefix[match]; }); return entry; diff --git a/packages/workbox-build/src/lib/populate-sw-template.js b/packages/workbox-build/src/lib/populate-sw-template.js index 50038cb1f..7dc61843e 100644 --- a/packages/workbox-build/src/lib/populate-sw-template.js +++ b/packages/workbox-build/src/lib/populate-sw-template.js @@ -17,7 +17,7 @@ module.exports = ({ cacheId, clientsClaim, directoryIndex, - ignoreUrlParametersMatching, + ignoreURLParametersMatching, importScripts, manifestEntries, modulePathPrefix, @@ -34,17 +34,17 @@ module.exports = ({ directoryIndex, // An array of RegExp objects can't be serialized by JSON.stringify()'s // default behavior, so if it's given, convert it manually. - ignoreUrlParametersMatching: ignoreUrlParametersMatching ? + ignoreURLParametersMatching: ignoreURLParametersMatching ? [] : undefined, }; let precacheOptionsString = JSON.stringify(precacheOptions, null, 2); - if (ignoreUrlParametersMatching) { + if (ignoreURLParametersMatching) { precacheOptionsString = precacheOptionsString.replace( - `"ignoreUrlParametersMatching": []`, - `"ignoreUrlParametersMatching": [` + - `${ignoreUrlParametersMatching.join(', ')}]` + `"ignoreURLParametersMatching": []`, + `"ignoreURLParametersMatching": [` + + `${ignoreURLParametersMatching.join(', ')}]` ); } diff --git a/packages/workbox-build/src/lib/write-sw-using-default-template.js b/packages/workbox-build/src/lib/write-sw-using-default-template.js index fdf30fbbb..955a70cb3 100644 --- a/packages/workbox-build/src/lib/write-sw-using-default-template.js +++ b/packages/workbox-build/src/lib/write-sw-using-default-template.js @@ -17,7 +17,7 @@ module.exports = async ({ clientsClaim, directoryIndex, handleFetch, - ignoreUrlParametersMatching, + ignoreURLParametersMatching, importScripts, manifestEntries, modulePathPrefix, @@ -42,7 +42,7 @@ module.exports = async ({ clientsClaim, directoryIndex, handleFetch, - ignoreUrlParametersMatching, + ignoreURLParametersMatching, importScripts, manifestEntries, modulePathPrefix, diff --git a/packages/workbox-cli/src/lib/run-wizard.js b/packages/workbox-cli/src/lib/run-wizard.js index a0027db51..d0a51465b 100644 --- a/packages/workbox-cli/src/lib/run-wizard.js +++ b/packages/workbox-cli/src/lib/run-wizard.js @@ -25,10 +25,10 @@ module.exports = async (options = {}) => { as part of a build process. See https://goo.gl/fdTQBf for details.`); - const configDocsUrl = options.injectManifest ? + const configDocsURL = options.injectManifest ? 'https://goo.gl/8bs14N' : 'https://goo.gl/gVo87N'; logger.log(ol`You can further customize your service worker by making changes - to ${configLocation}. See ${configDocsUrl} for details.`); + to ${configLocation}. See ${configDocsURL} for details.`); }; diff --git a/packages/workbox-webpack-plugin/src/lib/get-manifest-entries-from-compilation.js b/packages/workbox-webpack-plugin/src/lib/get-manifest-entries-from-compilation.js index 5eea4ba3d..3b4989032 100644 --- a/packages/workbox-webpack-plugin/src/lib/get-manifest-entries-from-compilation.js +++ b/packages/workbox-webpack-plugin/src/lib/get-manifest-entries-from-compilation.js @@ -9,7 +9,7 @@ const ModuleFilenameHelpers = require('webpack/lib/ModuleFilenameHelpers'); const getAssetHash = require('./get-asset-hash'); -const resolveWebpackUrl = require('./resolve-webpack-url'); +const resolveWebpackURL = require('./resolve-webpack-url'); /** * A single manifest entry that Workbox can precache. @@ -178,8 +178,8 @@ function getManifestEntriesFromCompilation(compilation, config) { continue; } - const publicUrl = resolveWebpackUrl(publicPath, file); - const manifestEntry = getEntry(knownHashes, publicUrl, metadata.hash); + const publicURL = resolveWebpackURL(publicPath, file); + const manifestEntry = getEntry(knownHashes, publicURL, metadata.hash); manifestEntries.push(manifestEntry); } return manifestEntries; diff --git a/packages/workbox-webpack-plugin/src/lib/get-workbox-sw-imports.js b/packages/workbox-webpack-plugin/src/lib/get-workbox-sw-imports.js index 67312a4d0..c3821c342 100644 --- a/packages/workbox-webpack-plugin/src/lib/get-workbox-sw-imports.js +++ b/packages/workbox-webpack-plugin/src/lib/get-workbox-sw-imports.js @@ -7,7 +7,7 @@ */ const path = require('path'); -const {copyWorkboxLibraries, getModuleUrl} = require('workbox-build'); +const {copyWorkboxLibraries, getModuleURL} = require('workbox-build'); /** * @param {Object} compilation The webpack compilation. @@ -23,7 +23,7 @@ const {copyWorkboxLibraries, getModuleUrl} = require('workbox-build'); async function getWorkboxSWImport(compilation, config) { switch (config.importWorkboxFrom) { case 'cdn': { - return [getModuleUrl('workbox-sw')]; + return [getModuleURL('workbox-sw')]; } case 'local': { diff --git a/packages/workbox-webpack-plugin/src/lib/resolve-webpack-url.js b/packages/workbox-webpack-plugin/src/lib/resolve-webpack-url.js index 4dd747114..661874d0f 100644 --- a/packages/workbox-webpack-plugin/src/lib/resolve-webpack-url.js +++ b/packages/workbox-webpack-plugin/src/lib/resolve-webpack-url.js @@ -12,7 +12,7 @@ * Use publicPath + filePath instead of url.resolve(publicPath, filePath) see: * https://webpack.js.org/configuration/output/#output-publicpath * - * @function resolveWebpackUrl + * @function resolveWebpackURL * @param {Array} paths File paths to join * @return {string} Joined file path * diff --git a/packages/workbox-webpack-plugin/src/lib/warn-about-config.js b/packages/workbox-webpack-plugin/src/lib/warn-about-config.js index 4babc959d..8836892e0 100644 --- a/packages/workbox-webpack-plugin/src/lib/warn-about-config.js +++ b/packages/workbox-webpack-plugin/src/lib/warn-about-config.js @@ -7,7 +7,7 @@ */ module.exports = (config) => { - const moreInfoUrl = 'https://goo.gl/EQ4Rhm'; + const moreInfoURL = 'https://goo.gl/EQ4Rhm'; const globOptions = [ 'globDirectory', @@ -22,14 +22,14 @@ module.exports = (config) => { return `You're using the following Workbox configuration option` + `${usedGlobOptions.length === 1 ? '' : 's'}: ` + `[${usedGlobOptions.join(', ')}]. In Workbox v3 and later, this is ` + - `usually not needed. Please see ${moreInfoUrl} for more info.`; + `usually not needed. Please see ${moreInfoURL} for more info.`; } const optionsToWarnAboutWhenGlobPatternsIsNotSet = [ - 'dontCacheBustUrlsMatching', + 'dontCacheBustURLsMatching', 'manifestTransforms', 'maximumFileSizeToCacheInBytes', - 'modifyUrlPrefix', + 'modifyURLPrefix', ]; const usedNoopOptions = optionsToWarnAboutWhenGlobPatternsIsNotSet @@ -39,7 +39,7 @@ module.exports = (config) => { `${usedGlobOptions.length === 1 ? '' : 's'}: ` + `[${usedNoopOptions.join(', ')}]. This will not have any effect, as ` + `it will only modify files that are matched via 'globPatterns'. You ` + - `can remove them from your config, and learn more at ${moreInfoUrl}`; + `can remove them from your config, and learn more at ${moreInfoURL}`; } return null; diff --git a/test/workbox-build/node/entry-points/generate-sw-string.js b/test/workbox-build/node/entry-points/generate-sw-string.js index 79f3caf01..acbd75589 100644 --- a/test/workbox-build/node/entry-points/generate-sw-string.js +++ b/test/workbox-build/node/entry-points/generate-sw-string.js @@ -25,23 +25,23 @@ describe(`[workbox-build] entry-points/generate-sw-string.js (End to End)`, func 'cacheId', 'clientsClaim', 'directoryIndex', - 'dontCacheBustUrlsMatching', + 'dontCacheBustURLsMatching', 'globDirectory', 'globFollow', 'globIgnores', 'globPatterns', 'globStrict', - 'ignoreUrlParametersMatching', + 'ignoreURLParametersMatching', 'injectionPointRegexp', 'manifestTransforms', 'maximumFileSizeToCacheInBytes', - 'modifyUrlPrefix', + 'modifyURLPrefix', 'navigateFallback', 'navigateFallbackWhitelist', 'offlineGoogleAnalytics', 'runtimeCaching', 'skipWaiting', - 'templatedUrls', + 'templatedURLs', ].concat(REQUIRED_PARAMS); const UNSUPPORTED_PARAMS = [ 'importWorkboxFrom', @@ -179,12 +179,12 @@ describe(`[workbox-build] entry-points/generate-sw-string.js (End to End)`, func it(`should use defaults when all the required parameters are present, with additional WorkboxSW() configuration`, async function() { const cacheId = 'test'; const directoryIndex = 'test.html'; - const ignoreUrlParametersMatching = [/test1/, /test2/]; + const ignoreURLParametersMatching = [/test1/, /test2/]; const workboxOptions = { cacheId, directoryIndex, - ignoreUrlParametersMatching, + ignoreURLParametersMatching, clientsClaim: true, skipWaiting: true, }; @@ -197,7 +197,7 @@ describe(`[workbox-build] entry-points/generate-sw-string.js (End to End)`, func skipWaiting: [[]], setCacheNameDetails: [[{prefix: cacheId}]], importScripts: [[...DEFAULT_IMPORT_SCRIPTS]], - precacheAndRoute: [[[], {directoryIndex, ignoreUrlParametersMatching}]], + precacheAndRoute: [[[], {directoryIndex, ignoreURLParametersMatching}]], }}); }); @@ -517,4 +517,26 @@ describe(`[workbox-build] entry-points/generate-sw-string.js (End to End)`, func } }); }); + + describe(`[workbox-build] deprecated options`, function() { + const oldOptionsToValue = { + dontCacheBustUrlsMatching: /ignored/, + ignoreUrlParametersMatching: [/ignored/], + modifyUrlPrefix: { + 'ignored': 'ignored', + }, + templatedUrls: {}, + }; + + for (const [option, value] of Object.entries(oldOptionsToValue)) { + it(`should return a warning when ${option} is used`, async function() { + const options = Object.assign({}, BASE_OPTIONS, { + [option]: value, + }); + + const {warnings} = await generateSWString(options); + expect(warnings).to.have.length(1); + }); + } + }); }); diff --git a/test/workbox-build/node/entry-points/generate-sw.js b/test/workbox-build/node/entry-points/generate-sw.js index 88e3578c1..b33298507 100644 --- a/test/workbox-build/node/entry-points/generate-sw.js +++ b/test/workbox-build/node/entry-points/generate-sw.js @@ -19,7 +19,7 @@ const generateSW = require('../../../../packages/workbox-build/src/entry-points/ const validateServiceWorkerRuntime = require('../../../../infra/testing/validator/service-worker-runtime'); describe(`[workbox-build] entry-points/generate-sw.js (End to End)`, function() { - const WORKBOX_SW_CDN_URL = cdnUtils.getModuleUrl('workbox-sw'); + const WORKBOX_SW_CDN_URL = cdnUtils.getModuleURL('workbox-sw'); const WORKBOX_DIRECTORY_PREFIX = 'workbox-'; const GLOB_DIR = path.join(__dirname, '..', '..', 'static', 'example-project-1'); const BASE_OPTIONS = { @@ -34,23 +34,23 @@ describe(`[workbox-build] entry-points/generate-sw.js (End to End)`, function() 'cacheId', 'clientsClaim', 'directoryIndex', - 'dontCacheBustUrlsMatching', + 'dontCacheBustURLsMatching', 'globFollow', 'globIgnores', 'globPatterns', 'globStrict', - 'ignoreUrlParametersMatching', + 'ignoreURLParametersMatching', 'importScripts', 'importWorkboxFrom', 'manifestTransforms', 'maximumFileSizeToCacheInBytes', - 'modifyUrlPrefix', + 'modifyURLPrefix', 'offlineGoogleAnalytics', 'navigateFallback', 'navigateFallbackWhitelist', 'runtimeCaching', 'skipWaiting', - 'templatedUrls', + 'templatedURLs', ].concat(REQUIRED_PARAMS); const UNSUPPORTED_PARAMS = [ 'injectionPointRegexp', @@ -309,12 +309,12 @@ describe(`[workbox-build] entry-points/generate-sw.js (End to End)`, function() it(`should use defaults when all the required parameters are present, with additional configuration`, async function() { const swDest = tempy.file(); const directoryIndex = 'test.html'; - const ignoreUrlParametersMatching = [/test1/, /test2/]; + const ignoreURLParametersMatching = [/test1/, /test2/]; const cacheId = 'test'; const additionalOptions = { cacheId, directoryIndex, - ignoreUrlParametersMatching, + ignoreURLParametersMatching, clientsClaim: true, skipWaiting: true, }; @@ -347,7 +347,7 @@ describe(`[workbox-build] entry-points/generate-sw.js (End to End)`, function() }, { url: 'webpackEntry.js', revision: '5b652181a25e96f255d0490203d3c47e', - }], {directoryIndex, ignoreUrlParametersMatching}]], + }], {directoryIndex, ignoreURLParametersMatching}]], }}); }); @@ -857,4 +857,26 @@ describe(`[workbox-build] entry-points/generate-sw.js (End to End)`, function() } }); }); + + describe(`[workbox-build] deprecated options`, function() { + const oldOptionsToValue = { + dontCacheBustUrlsMatching: /ignored/, + ignoreUrlParametersMatching: [/ignored/], + modifyUrlPrefix: { + 'ignored': 'ignored', + }, + templatedUrls: {}, + }; + + for (const [option, value] of Object.entries(oldOptionsToValue)) { + it(`should return a warning when ${option} is used`, async function() { + const options = Object.assign({}, BASE_OPTIONS, { + [option]: value, + }); + + const {warnings} = await generateSW(options); + expect(warnings).to.have.length(1); + }); + } + }); }); diff --git a/test/workbox-build/node/entry-points/get-manifest.js b/test/workbox-build/node/entry-points/get-manifest.js index 22ffae11e..aa45bc10d 100644 --- a/test/workbox-build/node/entry-points/get-manifest.js +++ b/test/workbox-build/node/entry-points/get-manifest.js @@ -19,7 +19,7 @@ describe(`[workbox-build] entry-points/get-manifest.js (End to End)`, function() globDirectory: SRC_DIR, }; const SUPPORTED_PARAMS = [ - 'dontCacheBustUrlsMatching', + 'dontCacheBustURLsMatching', 'globDirectory', 'globFollow', 'globIgnores', @@ -27,14 +27,14 @@ describe(`[workbox-build] entry-points/get-manifest.js (End to End)`, function() 'globStrict', 'manifestTransforms', 'maximumFileSizeToCacheInBytes', - 'modifyUrlPrefix', - 'templatedUrls', + 'modifyURLPrefix', + 'templatedURLs', ]; const UNSUPPORTED_PARAMS = [ 'cacheId', 'clientsClaim', 'directoryIndex', - 'ignoreUrlParametersMatching', + 'ignoreURLParametersMatching', 'importScripts', 'importWorkboxFrom', 'injectionPointRegexp', @@ -194,12 +194,12 @@ describe(`[workbox-build] entry-points/get-manifest.js (End to End)`, function() expect(size).to.eql(101); }); - it(`should use defaults when all the required parameters, and 'templatedUrls' are present`, async function() { + it(`should use defaults when all the required parameters, and 'templatedURLs' are present`, async function() { const url1 = 'url1'; const url2 = 'url2'; const options = Object.assign({ - templatedUrls: { + templatedURLs: { [url1]: ['**/*.html'], [url2]: 'string dependency', }, @@ -299,4 +299,25 @@ describe(`[workbox-build] entry-points/get-manifest.js (End to End)`, function() expect(size).to.eql(2535); }); }); + + describe(`[workbox-build] deprecated options`, function() { + const oldOptionsToValue = { + dontCacheBustUrlsMatching: /ignored/, + modifyUrlPrefix: { + 'ignored': 'ignored', + }, + templatedUrls: {}, + }; + + for (const [option, value] of Object.entries(oldOptionsToValue)) { + it(`should return a warning when ${option} is used`, async function() { + const options = Object.assign({}, BASE_OPTIONS, { + [option]: value, + }); + + const {warnings} = await getManifest(options); + expect(warnings).to.have.length(1); + }); + } + }); }); diff --git a/test/workbox-build/node/entry-points/inject-manifest.js b/test/workbox-build/node/entry-points/inject-manifest.js index ed178d3e6..bb7fcb31d 100644 --- a/test/workbox-build/node/entry-points/inject-manifest.js +++ b/test/workbox-build/node/entry-points/inject-manifest.js @@ -28,7 +28,7 @@ describe(`[workbox-build] entry-points/inject-manifest.js (End to End)`, functio 'swSrc', ]; const SUPPORTED_PARAMS = [ - 'dontCacheBustUrlsMatching', + 'dontCacheBustURLsMatching', 'globFollow', 'globIgnores', 'globPatterns', @@ -36,14 +36,14 @@ describe(`[workbox-build] entry-points/inject-manifest.js (End to End)`, functio 'injectionPointRegexp', 'manifestTransforms', 'maximumFileSizeToCacheInBytes', - 'modifyUrlPrefix', - 'templatedUrls', + 'modifyURLPrefix', + 'templatedURLs', ].concat(REQUIRED_PARAMS); const UNSUPPORTED_PARAMS = [ 'cacheId', 'clientsClaim', 'directoryIndex', - 'ignoreUrlParametersMatching', + 'ignoreURLParametersMatching', 'importScripts', 'importWorkboxFrom', 'navigateFallback', @@ -295,9 +295,30 @@ describe(`[workbox-build] entry-points/inject-manifest.js (End to End)`, functio url: 'webpackEntry.js', revision: '5b652181a25e96f255d0490203d3c47e', }], { - cleanUrls: true, + cleanURLs: true, }]], }}); }); }); + + describe(`[workbox-build] deprecated options`, function() { + const oldOptionsToValue = { + dontCacheBustUrlsMatching: /ignored/, + modifyUrlPrefix: { + 'ignored': 'ignored', + }, + templatedUrls: {}, + }; + + for (const [option, value] of Object.entries(oldOptionsToValue)) { + it(`should return a warning when ${option} is used`, async function() { + const options = Object.assign({}, BASE_OPTIONS, { + [option]: value, + }); + + const {warnings} = await injectManifest(options); + expect(warnings).to.have.length(1); + }); + } + }); }); diff --git a/test/workbox-build/node/entry-points/options/validate.js b/test/workbox-build/node/entry-points/options/validate.js index 619d86b87..b066b7ea5 100644 --- a/test/workbox-build/node/entry-points/options/validate.js +++ b/test/workbox-build/node/entry-points/options/validate.js @@ -54,11 +54,11 @@ describe(`[workbox-build] entry-points/options/validate.js`, function() { }); it(`should return the default options, honoring any additional options`, function() { - const dontCacheBustUrlsMatching = /test/; - const options = validate({dontCacheBustUrlsMatching}, baseSchema); + const dontCacheBustURLsMatching = /test/; + const options = validate({dontCacheBustURLsMatching}, baseSchema); expect(options).to.eql({ - dontCacheBustUrlsMatching, + dontCacheBustURLsMatching, globFollow: true, globIgnores: ['**/node_modules/**/*'], globPatterns: ['**/*.{js,css,html}'], diff --git a/test/workbox-build/node/lib/cdn-utils.js b/test/workbox-build/node/lib/cdn-utils.js index 23644d15a..cb84f572c 100644 --- a/test/workbox-build/node/lib/cdn-utils.js +++ b/test/workbox-build/node/lib/cdn-utils.js @@ -19,31 +19,31 @@ describe(`[workbox-build] lib/cdn-utils.js`, function() { expect(url).to.eql(CDN_ORIGIN); }); - it(`getModuleUrl() should throw when moduleName is undefined`, function() { + it(`getModuleURL() should throw when moduleName is undefined`, function() { expect( - () => cdnUtils.getModuleUrl() + () => cdnUtils.getModuleURL() ).to.throw(errors['no-module-name']); }); - it(`getModuleUrl('workbox-sw', 'dev') should throw`, function() { + it(`getModuleURL('workbox-sw', 'dev') should throw`, function() { expect( - () => cdnUtils.getModuleUrl('workbox-sw', 'dev') + () => cdnUtils.getModuleURL('workbox-sw', 'dev') ).to.throw('workbox-sw'); }); - it(`getModuleUrl(moduleName) should return the expected URL`, function() { + it(`getModuleURL(moduleName) should return the expected URL`, function() { const moduleName = 'workbox-sw'; - const url = cdnUtils.getModuleUrl(moduleName); + const url = cdnUtils.getModuleURL(moduleName); expect(url.startsWith(CDN_ORIGIN)).to.be.true; expect(url.includes(moduleName)).to.be.true; }); - it(`getModuleUrl('workbox-routing', buildType) should return the expected URL`, function() { + it(`getModuleURL('workbox-routing', buildType) should return the expected URL`, function() { const moduleName = 'workbox-routing'; const buildType = 'prod'; - const url = cdnUtils.getModuleUrl(moduleName, buildType); + const url = cdnUtils.getModuleURL(moduleName, buildType); expect(url.startsWith(CDN_ORIGIN)).to.be.true; expect(url.includes(moduleName)).to.be.true; diff --git a/test/workbox-build/node/lib/filter-files.js b/test/workbox-build/node/lib/filter-files.js index 99fc2ed33..5f51738df 100644 --- a/test/workbox-build/node/lib/filter-files.js +++ b/test/workbox-build/node/lib/filter-files.js @@ -46,9 +46,9 @@ describe(`[workbox-build] lib/filter-files.js`, function() { }]); }); - it(`should remove revision info based on dontCacheBustUrlsMatching`, async function() { + it(`should remove revision info based on dontCacheBustURLsMatching`, async function() { const {size, count, manifestEntries} = filterFiles({ - dontCacheBustUrlsMatching: new RegExp(ENTRY1.file), + dontCacheBustURLsMatching: new RegExp(ENTRY1.file), fileDetails: FILE_DETAILS, }); @@ -65,11 +65,11 @@ describe(`[workbox-build] lib/filter-files.js`, function() { }]); }); - it(`should modify the URLs based on modifyUrlPrefix`, async function() { + it(`should modify the URLs based on modifyURLPrefix`, async function() { const prefix = 'prefix/'; const {size, count, manifestEntries} = filterFiles({ - modifyUrlPrefix: { + modifyURLPrefix: { '': prefix, }, fileDetails: FILE_DETAILS, diff --git a/test/workbox-build/node/lib/get-file-manifest-entries.js b/test/workbox-build/node/lib/get-file-manifest-entries.js index 4463d407f..e8b624e8c 100644 --- a/test/workbox-build/node/lib/get-file-manifest-entries.js +++ b/test/workbox-build/node/lib/get-file-manifest-entries.js @@ -21,7 +21,7 @@ describe(`[workbox-build] Test getFileManifestEntries`, function() { hash: 'hash1', }; - it(`should return empty info when neither globDirectory nor templatedUrls are provided`, async function() { + it(`should return empty info when neither globDirectory nor templatedURLs are provided`, async function() { const getFileManifestEntries = require(MODULE_PATH); const {count, size, manifestEntries} = await getFileManifestEntries({}); @@ -49,7 +49,7 @@ describe(`[workbox-build] Test getFileManifestEntries`, function() { }]); }); - it(`should throw when a templatedUrl matches a globbed file`, async function() { + it(`should throw when a templatedURL matches a globbed file`, async function() { const getFileManifestEntries = proxyquire(MODULE_PATH, { './get-file-details': () => [FILE], }); @@ -58,7 +58,7 @@ describe(`[workbox-build] Test getFileManifestEntries`, function() { await getFileManifestEntries({ globDirectory: GLOB_DIRECTORY, globPatterns: GLOB_PATTERNS, - templatedUrls: { + templatedURLs: { [FILE.file]: '', }, }); @@ -79,7 +79,7 @@ describe(`[workbox-build] Test getFileManifestEntries`, function() { const {warnings} = await getFileManifestEntries({ globDirectory: GLOB_DIRECTORY, globPatterns: GLOB_PATTERNS, - templatedUrls: { + templatedURLs: { [FILE.file]: '', }, }); @@ -87,12 +87,12 @@ describe(`[workbox-build] Test getFileManifestEntries`, function() { expect(warnings).to.eql([warningMessage]); }); - it(`should throw when a templatedUrl contains a pattern that doesn't match anything`, async function() { + it(`should throw when a templatedURL contains a pattern that doesn't match anything`, async function() { const getFileManifestEntries = require(MODULE_PATH); try { await getFileManifestEntries({ - templatedUrls: { + templatedURLs: { [FILE.file]: GLOB_PATTERNS, }, }); @@ -102,7 +102,7 @@ describe(`[workbox-build] Test getFileManifestEntries`, function() { } }); - it(`should return results that take both glob patterns and templatedUrls into account`, async function() { + it(`should return results that take both glob patterns and templatedURLs into account`, async function() { const url1 = '/path/to/url1'; const url2 = '/path/to/url2'; const stringValue = 'string'; @@ -114,7 +114,7 @@ describe(`[workbox-build] Test getFileManifestEntries`, function() { const {count, size, manifestEntries} = await getFileManifestEntries({ globDirectory: GLOB_DIRECTORY, globPatterns: GLOB_PATTERNS, - templatedUrls: { + templatedURLs: { [url1]: GLOB_PATTERNS, [url2]: stringValue, }, diff --git a/test/workbox-build/node/lib/modify-url-prefix-transform.js b/test/workbox-build/node/lib/modify-url-prefix-transform.js index ece09dc84..b20b4e024 100644 --- a/test/workbox-build/node/lib/modify-url-prefix-transform.js +++ b/test/workbox-build/node/lib/modify-url-prefix-transform.js @@ -9,7 +9,7 @@ const expect = require('chai').expect; const errors = require('../../../../packages/workbox-build/src/lib/errors'); -const modifyUrlPrefix = require('../../../../packages/workbox-build/src/lib/modify-url-prefix-transform'); +const modifyURLPrefix = require('../../../../packages/workbox-build/src/lib/modify-url-prefix-transform'); describe(`[workbox-build] lib/modify-url-prefix-transform.js`, function() { function getManifest() { @@ -35,7 +35,7 @@ describe(`[workbox-build] lib/modify-url-prefix-transform.js`, function() { '/example-2/multi-section/1234': '/example-2-altered/5678', }; - const transform = modifyUrlPrefix(modifications); + const transform = modifyURLPrefix(modifications); for (const badInput of badInputs) { expect( () => transform([{url: badInput}]) @@ -43,7 +43,7 @@ describe(`[workbox-build] lib/modify-url-prefix-transform.js`, function() { } }); - it(`should handle bad modifyUrlPrefix input`, function() { + it(`should handle bad modifyURLPrefix input`, function() { const badInputs = [ null, undefined, @@ -58,7 +58,7 @@ describe(`[workbox-build] lib/modify-url-prefix-transform.js`, function() { for (const badInput of badInputs) { expect( - () => modifyUrlPrefix(badInput) + () => modifyURLPrefix(badInput) ).to.throw(errors['modify-url-prefix-bad-prefixes']); } }); @@ -68,7 +68,7 @@ describe(`[workbox-build] lib/modify-url-prefix-transform.js`, function() { '/first-match': '', }; - const transform = modifyUrlPrefix(modifications); + const transform = modifyURLPrefix(modifications); expect(transform(getManifest())).to.eql({manifest: [{ url: '/12345/hello', }, { @@ -81,7 +81,7 @@ describe(`[workbox-build] lib/modify-url-prefix-transform.js`, function() { '': '/public', }; - const transform = modifyUrlPrefix(modifications); + const transform = modifyURLPrefix(modifications); expect(transform(getManifest())).to.eql({manifest: [{ url: '/public/first-match/12345/hello', }, { @@ -95,7 +95,7 @@ describe(`[workbox-build] lib/modify-url-prefix-transform.js`, function() { '/second-match': '/third-match', }; - const transform = modifyUrlPrefix(modifications); + const transform = modifyURLPrefix(modifications); expect(transform(getManifest())).to.eql({manifest: [{ url: '/second-match/12345/hello', }, { @@ -108,7 +108,7 @@ describe(`[workbox-build] lib/modify-url-prefix-transform.js`, function() { '/hello': '/altered', }; - const transform = modifyUrlPrefix(modifications); + const transform = modifyURLPrefix(modifications); expect(transform(getManifest())).to.eql({manifest: getManifest()}); }); }); diff --git a/test/workbox-build/node/lib/no-revision-for-urls-matching-transform.js b/test/workbox-build/node/lib/no-revision-for-urls-matching-transform.js index e97e13805..ddcf29856 100644 --- a/test/workbox-build/node/lib/no-revision-for-urls-matching-transform.js +++ b/test/workbox-build/node/lib/no-revision-for-urls-matching-transform.js @@ -9,7 +9,7 @@ const expect = require('chai').expect; const errors = require('../../../../packages/workbox-build/src/lib/errors'); -const noRevisionForUrlsMatching = require('../../../../packages/workbox-build/src/lib/no-revision-for-urls-matching-transform'); +const noRevisionForURLsMatching = require('../../../../packages/workbox-build/src/lib/no-revision-for-urls-matching-transform'); describe(`[workbox-build] lib/no-revision-for-urls-matching-transform.js`, function() { const MANIFEST = [{ @@ -32,7 +32,7 @@ describe(`[workbox-build] lib/no-revision-for-urls-matching-transform.js`, funct [], ]; - const transform = noRevisionForUrlsMatching(/ignored/); + const transform = noRevisionForURLsMatching(/ignored/); for (const badInput of badInputs) { expect( () => transform([{url: badInput}]) @@ -40,7 +40,7 @@ describe(`[workbox-build] lib/no-revision-for-urls-matching-transform.js`, funct } }); - it(`should handle bad dontCacheBustUrlsMatching input`, function() { + it(`should handle bad dontCacheBustURLsMatching input`, function() { const badInputs = [ null, undefined, @@ -55,13 +55,13 @@ describe(`[workbox-build] lib/no-revision-for-urls-matching-transform.js`, funct for (const badInput of badInputs) { expect( - () => noRevisionForUrlsMatching(badInput) + () => noRevisionForURLsMatching(badInput) ).to.throw(errors['invalid-dont-cache-bust']); } }); it(`should remove revision info from a single matching entry`, function() { - const transform = noRevisionForUrlsMatching(/first-match/); + const transform = noRevisionForURLsMatching(/first-match/); expect(transform(MANIFEST)).to.eql({manifest: [{ url: '/first-match/12345/hello', }, { @@ -73,7 +73,7 @@ describe(`[workbox-build] lib/no-revision-for-urls-matching-transform.js`, funct }); it(`should remove revision info from multiple matching entries`, function() { - const transform = noRevisionForUrlsMatching(/12345/); + const transform = noRevisionForURLsMatching(/12345/); expect(transform(MANIFEST)).to.eql({manifest: [{ url: '/first-match/12345/hello', }, { @@ -84,7 +84,7 @@ describe(`[workbox-build] lib/no-revision-for-urls-matching-transform.js`, funct }); it(`should do nothing when there's a match for an entry without a revision`, function() { - const transform = noRevisionForUrlsMatching(/third-match/); + const transform = noRevisionForURLsMatching(/third-match/); expect(transform(MANIFEST)).to.eql({manifest: MANIFEST}); }); }); diff --git a/test/workbox-build/node/lib/populate-sw-template.js b/test/workbox-build/node/lib/populate-sw-template.js index 438148c7f..e7b8cfb7f 100644 --- a/test/workbox-build/node/lib/populate-sw-template.js +++ b/test/workbox-build/node/lib/populate-sw-template.js @@ -68,7 +68,7 @@ describe(`[workbox-build] lib/populate-sw-template.js`, function() { const clientsClaim = true; const directoryIndex = 'index.html'; const handleFetch = true; - const ignoreUrlParametersMatching = [/a/, /b/]; + const ignoreURLParametersMatching = [/a/, /b/]; const importScripts = ['test.js']; const manifestEntries = [{url: '/path/to/index.html', revision: '1234'}]; const modulePathPrefix = 'testing'; @@ -81,7 +81,7 @@ describe(`[workbox-build] lib/populate-sw-template.js`, function() { const runtimeCachingPlaceholder = 'runtime-caching-placeholder'; const skipWaiting = true; const swTemplate = 'template'; - const precacheOptionsString = '{\n "directoryIndex": "index.html",\n "ignoreUrlParametersMatching": [/a/, /b/]\n}'; + const precacheOptionsString = '{\n "directoryIndex": "index.html",\n "ignoreURLParametersMatching": [/a/, /b/]\n}'; const workboxSWImport = 'workbox-sw.js'; // There are two stages in templating: creating the active template function @@ -101,7 +101,7 @@ describe(`[workbox-build] lib/populate-sw-template.js`, function() { clientsClaim, directoryIndex, handleFetch, - ignoreUrlParametersMatching, + ignoreURLParametersMatching, importScripts, manifestEntries, modulePathPrefix, diff --git a/test/workbox-build/static/sw-injections/precache-and-route-options.js b/test/workbox-build/static/sw-injections/precache-and-route-options.js index fd5eb6db9..fdd23c393 100644 --- a/test/workbox-build/static/sw-injections/precache-and-route-options.js +++ b/test/workbox-build/static/sw-injections/precache-and-route-options.js @@ -6,4 +6,4 @@ https://opensource.org/licenses/MIT. */ -workbox.precaching.precacheAndRoute([], {cleanUrls: true}); +workbox.precaching.precacheAndRoute([], {cleanURLs: true}); diff --git a/test/workbox-webpack-plugin/node/generate-sw.js b/test/workbox-webpack-plugin/node/generate-sw.js index 7d4068adc..e9505132b 100644 --- a/test/workbox-webpack-plugin/node/generate-sw.js +++ b/test/workbox-webpack-plugin/node/generate-sw.js @@ -19,12 +19,12 @@ const webpack = require('webpack'); const CreateWebpackAssetPlugin = require('../../../infra/testing/create-webpack-asset-plugin'); const validateServiceWorkerRuntime = require('../../../infra/testing/validator/service-worker-runtime'); const {GenerateSW} = require('../../../packages/workbox-webpack-plugin/src/index'); -const {getModuleUrl} = require('../../../packages/workbox-build/src/lib/cdn-utils'); +const {getModuleURL} = require('../../../packages/workbox-build/src/lib/cdn-utils'); describe(`[workbox-webpack-plugin] GenerateSW (End to End)`, function() { const WEBPACK_ENTRY_FILENAME = 'webpackEntry.js'; const WORKBOX_DIRECTORY_PREFIX = 'workbox-'; - const WORKBOX_SW_FILE_NAME = getModuleUrl('workbox-sw'); + const WORKBOX_SW_FILE_NAME = getModuleURL('workbox-sw'); const SRC_DIR = path.join(__dirname, '..', 'static', 'example-project-1'); const ALL_WORKBOX_FILES = [ 'workbox-background-sync.dev.js', @@ -691,7 +691,7 @@ describe(`[workbox-webpack-plugin] GenerateSW (End to End)`, function() { clientsClaim: true, skipWaiting: true, globDirectory: SRC_DIR, - templatedUrls: { + templatedURLs: { '/shell': ['index.html', 'styles/*.css'], }, }), @@ -1363,10 +1363,10 @@ describe(`[workbox-webpack-plugin] GenerateSW (End to End)`, function() { const FILE_MANIFEST_NAME = 'precache-manifest.7e1d0d5a77c9c05655b6033e320028e3.js'; const outputDir = tempy.directory(); const optionsToWarnAboutWhenGlobPatternsIsNotSet = [ - 'dontCacheBustUrlsMatching', + 'dontCacheBustURLsMatching', 'manifestTransforms', 'maximumFileSizeToCacheInBytes', - 'modifyUrlPrefix', + 'modifyURLPrefix', ]; const config = { mode: 'production', @@ -1379,10 +1379,10 @@ describe(`[workbox-webpack-plugin] GenerateSW (End to End)`, function() { }, plugins: [ new GenerateSW({ - dontCacheBustUrlsMatching: /testing/, + dontCacheBustURLsMatching: /testing/, manifestTransforms: [], maximumFileSizeToCacheInBytes: 1000000, - modifyUrlPrefix: {abc: 'def'}, + modifyURLPrefix: {abc: 'def'}, }), ], }; diff --git a/test/workbox-webpack-plugin/node/inject-manifest.js b/test/workbox-webpack-plugin/node/inject-manifest.js index 02dc4e7ff..d07834b4d 100644 --- a/test/workbox-webpack-plugin/node/inject-manifest.js +++ b/test/workbox-webpack-plugin/node/inject-manifest.js @@ -19,11 +19,11 @@ const webpack = require('webpack'); const CreateWebpackAssetPlugin = require('../../../infra/testing/create-webpack-asset-plugin'); const validateServiceWorkerRuntime = require('../../../infra/testing/validator/service-worker-runtime'); const {InjectManifest} = require('../../../packages/workbox-webpack-plugin/src/index'); -const {getModuleUrl} = require('../../../packages/workbox-build/src/lib/cdn-utils'); +const {getModuleURL} = require('../../../packages/workbox-build/src/lib/cdn-utils'); describe(`[workbox-webpack-plugin] InjectManifest (End to End)`, function() { const WEBPACK_ENTRY_FILENAME = 'webpackEntry.js'; - const WORKBOX_SW_FILE_NAME = getModuleUrl('workbox-sw'); + const WORKBOX_SW_FILE_NAME = getModuleURL('workbox-sw'); const SRC_DIR = path.join(__dirname, '..', 'static', 'example-project-1'); const SW_SRC = path.join(__dirname, '..', 'static', 'sw-src.js'); const WORKBOX_DIRECTORY_PREFIX = 'workbox-'; @@ -910,7 +910,7 @@ describe(`[workbox-webpack-plugin] InjectManifest (End to End)`, function() { new InjectManifest({ swSrc: SW_SRC, globDirectory: SRC_DIR, - templatedUrls: { + templatedURLs: { '/shell': ['index.html', 'styles/*.css'], }, }), @@ -1529,10 +1529,10 @@ describe(`[workbox-webpack-plugin] InjectManifest (End to End)`, function() { const FILE_MANIFEST_NAME = 'precache-manifest.7e1d0d5a77c9c05655b6033e320028e3.js'; const outputDir = tempy.directory(); const optionsToWarnAboutWhenGlobPatternsIsNotSet = [ - 'dontCacheBustUrlsMatching', + 'dontCacheBustURLsMatching', 'manifestTransforms', 'maximumFileSizeToCacheInBytes', - 'modifyUrlPrefix', + 'modifyURLPrefix', ]; const config = { mode: 'production', @@ -1546,10 +1546,10 @@ describe(`[workbox-webpack-plugin] InjectManifest (End to End)`, function() { plugins: [ new InjectManifest({ swSrc: SW_SRC, - dontCacheBustUrlsMatching: /testing/, + dontCacheBustURLsMatching: /testing/, manifestTransforms: [], maximumFileSizeToCacheInBytes: 1000000, - modifyUrlPrefix: {abc: 'def'}, + modifyURLPrefix: {abc: 'def'}, }), ], };