From f0ea241481f5248a5417c8c899e13912db5324ba Mon Sep 17 00:00:00 2001 From: Gaurav Munjal Date: Wed, 25 Oct 2023 11:56:07 -0400 Subject: [PATCH 01/11] add gaurav9576 scope --- .github/workflows/ci.yml | 14 +++++++------- package.json | 10 +++++----- .../app/instance-initializers/clear-double-boot.js | 2 +- packages/ember-cli-fastboot/app/locations/none.js | 2 +- .../ember-cli-fastboot/app/services/fastboot.js | 2 +- packages/ember-cli-fastboot/fix-node-modules.mjs | 4 ++-- packages/ember-cli-fastboot/index.js | 6 +++--- packages/ember-cli-fastboot/package.json | 6 +++--- .../fixtures/request/lib/post-middleware/index.js | 4 ++-- .../request/lib/post-middleware/package.json | 2 +- .../test/request-details-test.js | 8 ++++---- .../clear-double-boot-test.js | 2 +- packages/fastboot-app-server/package.json | 6 +++--- packages/fastboot-app-server/src/worker.js | 4 ++-- packages/fastboot-express-middleware/package.json | 4 ++-- packages/fastboot-express-middleware/src/index.js | 2 +- .../test/middleware-test.js | 2 +- packages/fastboot/package.json | 2 +- test-packages/basic-app/package.json | 2 +- test-packages/custom-fastboot-app/package.json | 2 +- test-packages/custom-sandbox-app/package.json | 2 +- .../ember-cli-fastboot-testing-app/package.json | 2 +- test-packages/hot-swap-app/package.json | 2 +- test-packages/integration-tests/package.json | 4 ++-- test-packages/test-libs/debug.js | 2 +- yarn.lock | 6 +++--- 26 files changed, 52 insertions(+), 52 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8de7bdbde..660f03fb5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,14 +41,14 @@ jobs: - name: Yarn Install run: yarn install --ignore-engines --frozen-lockfile - name: Run ember-cli-fastboot Tests - run: yarn workspace ember-cli-fastboot test:ember + run: yarn workspace @gaurav9576/ember-cli-fastboot test:ember - name: Run fastboot Tests if: ${{ matrix.os != 'windows-latest' }} - run: yarn workspace fastboot test + run: yarn workspace @gaurav9576/fastboot test - name: Run fastboot-express-middleware Tests - run: yarn workspace fastboot-express-middleware test + run: yarn workspace @gaurav9576/fastboot-express-middleware test - name: Run fastboot-app-server Tests - run: yarn workspace fastboot-app-server test:mocha + run: yarn workspace @gaurav9576/fastboot-app-server test:mocha integration-tests: name: Integration Tests @@ -124,10 +124,10 @@ jobs: yarn install --ignore-engines --frozen-lockfile - name: Precook node_modules run: | - yarn workspace ember-cli-fastboot pretest:precook + yarn workspace @gaurav9576/ember-cli-fastboot pretest:precook - name: Run Mocha Tests run: | - yarn workspace ember-cli-fastboot test:mocha + yarn workspace @gaurav9576/ember-cli-fastboot test:mocha try-scenarios: name: "${{ matrix.ember-try-scenario }} Scenario for ember-cli-fastboot" @@ -163,4 +163,4 @@ jobs: cache: yarn - run: yarn install --ignore-engines --frozen-lockfile - name: test - run: yarn workspace ember-cli-fastboot ember try:one ${{ matrix.ember-try-scenario }} --skip-cleanup + run: yarn workspace @gaurav9576/ember-cli-fastboot ember try:one ${{ matrix.ember-try-scenario }} --skip-cleanup diff --git a/package.json b/package.json index 5eb69bcdc..2f0220875 100644 --- a/package.json +++ b/package.json @@ -16,10 +16,10 @@ }, "scripts": { "test": "npm-run-all test:*", - "test:ember-cli-fastboot": "yarn workspace ember-cli-fastboot test:ember", - "test:fastboot": "yarn workspace fastboot test", - "test:fastboot-express-middleware": "yarn workspace fastboot-express-middleware test", - "test:fastboot-app-server": "yarn workspace fastboot-app-server test:mocha", + "test:ember-cli-fastboot": "yarn workspace @gaurav9576/ember-cli-fastboot test:ember", + "test:fastboot": "yarn workspace @gaurav9576/fastboot test", + "test:fastboot-express-middleware": "yarn workspace @gaurav9576/fastboot-express-middleware test", + "test:fastboot-app-server": "yarn workspace @gaurav9576/fastboot-app-server test:mocha", "test:integration": "yarn workspace integration-tests test", "test:extra": "yarn workspace basic-app test:mocha && yarn workspace custom-fastboot-app test:mocha" }, @@ -30,7 +30,7 @@ "release-it-yarn-workspaces": "^2.0.0" }, "resolutions": { - "fastboot": "4.1.1" + "@gaurav9576/fastboot": "4.1.1" }, "publishConfig": { "registry": "https://registry.npmjs.org" diff --git a/packages/ember-cli-fastboot/app/instance-initializers/clear-double-boot.js b/packages/ember-cli-fastboot/app/instance-initializers/clear-double-boot.js index bf8f015b8..41d1548a1 100644 --- a/packages/ember-cli-fastboot/app/instance-initializers/clear-double-boot.js +++ b/packages/ember-cli-fastboot/app/instance-initializers/clear-double-boot.js @@ -1 +1 @@ -export { default } from 'ember-cli-fastboot/instance-initializers/clear-double-boot'; +export { default } from '@gaurav9576/ember-cli-fastboot/instance-initializers/clear-double-boot'; diff --git a/packages/ember-cli-fastboot/app/locations/none.js b/packages/ember-cli-fastboot/app/locations/none.js index 578cc0cdc..4192d5f95 100644 --- a/packages/ember-cli-fastboot/app/locations/none.js +++ b/packages/ember-cli-fastboot/app/locations/none.js @@ -1 +1 @@ -export { default } from 'ember-cli-fastboot/locations/none'; +export { default } from '@gaurav9576/ember-cli-fastboot/locations/none'; diff --git a/packages/ember-cli-fastboot/app/services/fastboot.js b/packages/ember-cli-fastboot/app/services/fastboot.js index 1ca8b7dda..20e09afd3 100644 --- a/packages/ember-cli-fastboot/app/services/fastboot.js +++ b/packages/ember-cli-fastboot/app/services/fastboot.js @@ -1 +1 @@ -export { default } from 'ember-cli-fastboot/services/fastboot'; +export { default } from '@gaurav9576/ember-cli-fastboot/services/fastboot'; diff --git a/packages/ember-cli-fastboot/fix-node-modules.mjs b/packages/ember-cli-fastboot/fix-node-modules.mjs index 96c081172..98b3f4ab9 100644 --- a/packages/ember-cli-fastboot/fix-node-modules.mjs +++ b/packages/ember-cli-fastboot/fix-node-modules.mjs @@ -28,10 +28,10 @@ Options: } function run(shouldRestore) { - ['fastboot', 'fastboot-express-middleware'].forEach((packageName) => { + ['@gaurav9576/fastboot', '@gaurav9576/fastboot-express-middleware'].forEach((packageName) => { const nodeModulesPackageDir = path.join(nodeModulesDir, packageName); const precookedPackageDir = path.join(precookedDir, packageName); - const workspacesPackageDir = path.resolve(packagesDir, packageName); + const workspacesPackageDir = path.resolve(packagesDir, packageName.substring(packageName.indexOf('/') + 1)); if (fs.existsSync(nodeModulesPackageDir)) { console.log(chalk.blue(`remove ${nodeModulesPackageDir}`)); fs.removeSync(nodeModulesPackageDir); diff --git a/packages/ember-cli-fastboot/index.js b/packages/ember-cli-fastboot/index.js index 41c20d52b..bfca4a120 100644 --- a/packages/ember-cli-fastboot/index.js +++ b/packages/ember-cli-fastboot/index.js @@ -5,8 +5,8 @@ const path = require('path'); const fs = require('fs'); const MergeTrees = require('broccoli-merge-trees'); -const FastBootExpressMiddleware = require('fastboot-express-middleware'); -const FastBoot = require('fastboot'); +const FastBootExpressMiddleware = require('@gaurav9576/fastboot-express-middleware'); +const FastBoot = require('@gaurav9576/fastboot'); const chalk = require('chalk'); const fastbootAppBoot = require('./lib/utilities/fastboot-app-boot'); @@ -149,7 +149,7 @@ module.exports = { _processAddon(addon, fastbootTrees) { // walk through each addon and grab its fastboot tree - const currentAddonFastbootPath = path.join(addon.root, 'fastboot'); + const currentAddonFastbootPath = path.join(addon.root, '@gaurav9576/fastboot'); let fastbootTree; if (this.existsSync(currentAddonFastbootPath)) { diff --git a/packages/ember-cli-fastboot/package.json b/packages/ember-cli-fastboot/package.json index 8a670fd34..4c9727ec0 100644 --- a/packages/ember-cli-fastboot/package.json +++ b/packages/ember-cli-fastboot/package.json @@ -1,5 +1,5 @@ { - "name": "ember-cli-fastboot", + "name": "@gaurav9576/ember-cli-fastboot", "version": "4.1.1", "description": "Server-side rendering for Ember.js apps", "keywords": [ @@ -39,8 +39,8 @@ "ember-cli-lodash-subset": "^2.0.1", "ember-cli-preprocess-registry": "^3.3.0", "ember-cli-version-checker": "^5.1.2", - "fastboot": "4.1.1", - "fastboot-express-middleware": "4.1.1", + "@gaurav9576/fastboot": "4.1.1", + "@gaurav9576/fastboot-express-middleware": "4.1.1", "fastboot-transform": "^0.1.3", "fs-extra": "^10.0.0", "json-stable-stringify": "^1.0.1", diff --git a/packages/ember-cli-fastboot/test/fixtures/request/lib/post-middleware/index.js b/packages/ember-cli-fastboot/test/fixtures/request/lib/post-middleware/index.js index a6466b981..2ce415da6 100644 --- a/packages/ember-cli-fastboot/test/fixtures/request/lib/post-middleware/index.js +++ b/packages/ember-cli-fastboot/test/fixtures/request/lib/post-middleware/index.js @@ -1,6 +1,6 @@ var bodyParser = require('body-parser'); -var FastBootExpressMiddleware = require('fastboot-express-middleware'); -var FastBoot = require('fastboot'); +var FastBootExpressMiddleware = require('@gaurav9576/fastboot-express-middleware'); +var FastBoot = require('@gaurav9576/fastboot'); module.exports = { name: 'post-middleware', diff --git a/packages/ember-cli-fastboot/test/fixtures/request/lib/post-middleware/package.json b/packages/ember-cli-fastboot/test/fixtures/request/lib/post-middleware/package.json index 8f2ccbf0d..44ca36f33 100644 --- a/packages/ember-cli-fastboot/test/fixtures/request/lib/post-middleware/package.json +++ b/packages/ember-cli-fastboot/test/fixtures/request/lib/post-middleware/package.json @@ -2,7 +2,7 @@ "name": "post-middlware", "ember-addon": { "after": [ - "ember-cli-fastboot" + "@gaurav9576/ember-cli-fastboot" ] }, "keywords": [ diff --git a/packages/ember-cli-fastboot/test/request-details-test.js b/packages/ember-cli-fastboot/test/request-details-test.js index 278392cfb..0f73e2c49 100644 --- a/packages/ember-cli-fastboot/test/request-details-test.js +++ b/packages/ember-cli-fastboot/test/request-details-test.js @@ -24,18 +24,18 @@ async function injectMiddlewareAddon(app) { await app.run( 'ln', '-s', - path.resolve(__dirname, '../../fastboot'), + path.resolve(__dirname, '../../@gaurav9576/fastboot'), path.resolve(app.path, 'node_modules/fastboot') ); await app.run( 'ln', '-s', - path.resolve(__dirname, '../../fastboot-express-middleware'), + path.resolve(__dirname, '../../@gaurav9576/fastboot-express-middleware'), path.resolve(app.path, 'node_modules/fastboot-express-middleware') ); app.editPackageJSON(function (pkg) { - pkg.dependencies['fastboot'] = '*'; - pkg.dependencies['fastboot-express-middleware'] = '*'; + pkg.dependencies['@gaurav9576/fastboot'] = '*'; + pkg.dependencies['@gaurav9576/fastboot-express-middleware'] = '*'; }); } diff --git a/packages/ember-cli-fastboot/tests/integration/instance-initializers/clear-double-boot-test.js b/packages/ember-cli-fastboot/tests/integration/instance-initializers/clear-double-boot-test.js index 611dba545..d5e691792 100644 --- a/packages/ember-cli-fastboot/tests/integration/instance-initializers/clear-double-boot-test.js +++ b/packages/ember-cli-fastboot/tests/integration/instance-initializers/clear-double-boot-test.js @@ -2,7 +2,7 @@ import { module, test } from 'qunit'; import { setupRenderingTest } from 'ember-qunit'; import { render } from '@ember/test-helpers'; import hbs from 'htmlbars-inline-precompile'; -import { clearHtml } from 'ember-cli-fastboot/instance-initializers/clear-double-boot'; +import { clearHtml } from '@gaurav9576/ember-cli-fastboot/instance-initializers/clear-double-boot'; module('Instance-initializer: clear-double-boot', function(hooks) { setupRenderingTest(hooks); diff --git a/packages/fastboot-app-server/package.json b/packages/fastboot-app-server/package.json index 910085044..01ae79194 100644 --- a/packages/fastboot-app-server/package.json +++ b/packages/fastboot-app-server/package.json @@ -1,5 +1,5 @@ { - "name": "fastboot-app-server", + "name": "@gaurav9576/fastboot-app-server", "version": "4.1.1", "description": "A production-ready app server for running Ember FastBoot apps", "keywords": [ @@ -28,8 +28,8 @@ "chalk": "^4.1.2", "compression": "^1.7.4", "express": "^4.17.2", - "fastboot": "4.1.1", - "fastboot-express-middleware": "4.1.1" + "@gaurav9576/fastboot": "4.1.1", + "@gaurav9576/fastboot-express-middleware": "4.1.1" }, "devDependencies": { "chai": "^4.3.4", diff --git a/packages/fastboot-app-server/src/worker.js b/packages/fastboot-app-server/src/worker.js index ccc96fdef..635df6735 100644 --- a/packages/fastboot-app-server/src/worker.js +++ b/packages/fastboot-app-server/src/worker.js @@ -1,7 +1,7 @@ "use strict"; -const FastBoot = require('fastboot'); -const fastbootMiddleware = require('fastboot-express-middleware'); +const FastBoot = require('@gaurav9576/fastboot'); +const fastbootMiddleware = require('@gaurav9576/fastboot-express-middleware'); const ExpressHTTPServer = require('./express-http-server'); class Worker { diff --git a/packages/fastboot-express-middleware/package.json b/packages/fastboot-express-middleware/package.json index f0d59cf84..ce9400f1d 100644 --- a/packages/fastboot-express-middleware/package.json +++ b/packages/fastboot-express-middleware/package.json @@ -1,5 +1,5 @@ { - "name": "fastboot-express-middleware", + "name": "@gaurav9576/fastboot-express-middleware", "version": "4.1.1", "description": "An Express middleware for rendering Ember apps with FastBoot", "keywords": [ @@ -25,7 +25,7 @@ }, "dependencies": { "chalk": "^4.1.2", - "fastboot": "4.1.1" + "@gaurav9576/fastboot": "4.1.1" }, "devDependencies": { "chai": "^4.3.4", diff --git a/packages/fastboot-express-middleware/src/index.js b/packages/fastboot-express-middleware/src/index.js index 05ad810a7..49185d0cd 100644 --- a/packages/fastboot-express-middleware/src/index.js +++ b/packages/fastboot-express-middleware/src/index.js @@ -18,7 +18,7 @@ function fastbootExpressMiddleware(distPath, options) { let fastboot = opts.fastboot; if (!fastboot) { - let FastBoot = require('fastboot'); + let FastBoot = require('@gaurav9576/fastboot'); fastboot = new FastBoot({ distPath: opts.distPath, resilient: opts.resilient, diff --git a/packages/fastboot-express-middleware/test/middleware-test.js b/packages/fastboot-express-middleware/test/middleware-test.js index f088be48e..41dd5a01d 100644 --- a/packages/fastboot-express-middleware/test/middleware-test.js +++ b/packages/fastboot-express-middleware/test/middleware-test.js @@ -1,7 +1,7 @@ 'use strict'; const expect = require('chai').expect; -const FastBoot = require('fastboot'); +const FastBoot = require('@gaurav9576/fastboot'); const fastbootMiddleware = require('./../src/index'); const fixture = require('./helpers/fixture-path'); const TestHTTPServer = require('./helpers/test-http-server'); diff --git a/packages/fastboot/package.json b/packages/fastboot/package.json index d80ff0e19..5f2dce7a2 100644 --- a/packages/fastboot/package.json +++ b/packages/fastboot/package.json @@ -1,5 +1,5 @@ { - "name": "fastboot", + "name": "@gaurav9576/fastboot", "version": "4.1.1", "description": "Library for rendering Ember apps in node.js", "keywords": [ diff --git a/test-packages/basic-app/package.json b/test-packages/basic-app/package.json index ce04e0e0a..27b7af246 100644 --- a/test-packages/basic-app/package.json +++ b/test-packages/basic-app/package.json @@ -39,7 +39,7 @@ "ember-cli-app-version": "^6.0.0", "ember-cli-babel": "^7.20.5", "ember-cli-dependency-checker": "^3.2.0", - "ember-cli-fastboot": "4.1.1", + "@gaurav9576/ember-cli-fastboot": "4.1.1", "ember-cli-head": "^1.0.0", "ember-cli-htmlbars": "^5.1.2", "ember-cli-inject-live-reload": "^2.0.2", diff --git a/test-packages/custom-fastboot-app/package.json b/test-packages/custom-fastboot-app/package.json index dbea4363a..074e92ead 100644 --- a/test-packages/custom-fastboot-app/package.json +++ b/test-packages/custom-fastboot-app/package.json @@ -36,7 +36,7 @@ "ember-cli-app-version": "^6.0.0", "ember-cli-babel": "^7.20.5", "ember-cli-dependency-checker": "^3.2.0", - "ember-cli-fastboot": "4.1.1", + "@gaurav9576/ember-cli-fastboot": "4.1.1", "ember-cli-htmlbars": "^5.1.2", "ember-cli-inject-live-reload": "^2.0.2", "ember-cli-sri": "^2.1.1", diff --git a/test-packages/custom-sandbox-app/package.json b/test-packages/custom-sandbox-app/package.json index ae69cf3d1..f832e045b 100644 --- a/test-packages/custom-sandbox-app/package.json +++ b/test-packages/custom-sandbox-app/package.json @@ -32,7 +32,7 @@ "ember-cli-babel": "^7.20.5", "ember-cli-dependency-checker": "^3.2.0", "ember-cli-htmlbars": "^5.1.2", - "ember-cli-fastboot": "4.1.1", + "@gaurav9576/ember-cli-fastboot": "4.1.1", "ember-cli-inject-live-reload": "^2.0.2", "ember-cli-sri": "^2.1.1", "ember-cli-uglify": "^3.0.0", diff --git a/test-packages/ember-cli-fastboot-testing-app/package.json b/test-packages/ember-cli-fastboot-testing-app/package.json index c3e08fc95..9cccfae28 100644 --- a/test-packages/ember-cli-fastboot-testing-app/package.json +++ b/test-packages/ember-cli-fastboot-testing-app/package.json @@ -30,7 +30,7 @@ "ember-cli-app-version": "^6.0.0", "ember-cli-babel": "^7.20.5", "ember-cli-dependency-checker": "^3.2.0", - "ember-cli-fastboot": "4.1.1", + "@gaurav9576/ember-cli-fastboot": "4.1.1", "ember-cli-fastboot-testing": "^0.5.0", "ember-cli-htmlbars": "^5.1.2", "ember-cli-inject-live-reload": "^2.0.2", diff --git a/test-packages/hot-swap-app/package.json b/test-packages/hot-swap-app/package.json index a65939513..a6b72f74a 100644 --- a/test-packages/hot-swap-app/package.json +++ b/test-packages/hot-swap-app/package.json @@ -32,7 +32,7 @@ "ember-cli-dependency-checker": "^3.2.0", "ember-cli-htmlbars": "^5.1.2", "ember-cli-inject-live-reload": "^2.0.2", - "ember-cli-fastboot": "4.1.1", + "@gaurav9576/ember-cli-fastboot": "4.1.1", "ember-cli-sri": "^2.1.1", "ember-cli-uglify": "^3.0.0", "ember-data": "~3.28.0", diff --git a/test-packages/integration-tests/package.json b/test-packages/integration-tests/package.json index d9c1493d1..da5b3ea9d 100644 --- a/test-packages/integration-tests/package.json +++ b/test-packages/integration-tests/package.json @@ -7,8 +7,8 @@ "test": "node helpers/clean-dists.js && mocha" }, "devDependencies": { - "ember-cli-fastboot": "4.1.1", - "fastboot": "4.1.1", + "@gaurav9576/ember-cli-fastboot": "4.1.1", + "@gaurav9576/fastboot": "4.1.1", "mocha": "^9.1.2" }, "volta": { diff --git a/test-packages/test-libs/debug.js b/test-packages/test-libs/debug.js index a7f9dfa81..1dc7c5521 100644 --- a/test-packages/test-libs/debug.js +++ b/test-packages/test-libs/debug.js @@ -1,5 +1,5 @@ 'use strict'; -const debug = require('debug')('ember-cli-fastboot'); +const debug = require('debug')('@gaurav9576/ember-cli-fastboot'); module.exports = debug; diff --git a/yarn.lock b/yarn.lock index e483c680c..e1ac0fc7e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6956,14 +6956,14 @@ fastboot-transform@^0.1.3: convert-source-map "^1.5.1" fastboot@^3.0.3: - version "4.1.1" + version "3.3.2" + resolved "https://registry.yarnpkg.com/fastboot/-/fastboot-3.3.2.tgz#bf1ac7b01937846b63423a88138e13eb50406d2e" + integrity sha512-2NKTW32GvEsDyBrdw1trW1JsbS+9/7sAQuKwkht12mNitimRrSKVLP2AxsM/HSXQE+aiET4XCfKdyeIy0kQbKQ== dependencies: - abortcontroller-polyfill "^1.7.3" chalk "^4.1.2" cookie "^0.4.1" debug "^4.3.3" jsdom "^19.0.0" - node-fetch "^2.6.7" resolve "^1.22.0" simple-dom "^1.4.0" source-map-support "^0.5.21" From 15c07648a8476f83e6c952e926d6f24c59075e73 Mon Sep 17 00:00:00 2001 From: Gaurav Munjal Date: Tue, 31 Oct 2023 07:24:03 -0400 Subject: [PATCH 02/11] fix scope --- packages/ember-cli-fastboot/fix-node-modules.mjs | 2 ++ packages/ember-cli-fastboot/package.json | 2 +- yarn.lock | 5 ++--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/ember-cli-fastboot/fix-node-modules.mjs b/packages/ember-cli-fastboot/fix-node-modules.mjs index 98b3f4ab9..6b6b1e87f 100644 --- a/packages/ember-cli-fastboot/fix-node-modules.mjs +++ b/packages/ember-cli-fastboot/fix-node-modules.mjs @@ -46,10 +46,12 @@ function run(shouldRestore) { `symlink ${nodeModulesPackageDir} -> ${workspacesPackageDir}` ) ); + fs.ensureDirSync(path.dirname(nodeModulesPackageDir)); fs.symlinkSync(workspacesPackageDir, nodeModulesPackageDir, 'dir'); console.log( chalk.green(`symlink ${precookedPackageDir} -> ${workspacesPackageDir}`) ); + fs.ensureDirSync(path.dirname(precookedPackageDir)); fs.symlinkSync(workspacesPackageDir, precookedPackageDir, 'dir'); } }); diff --git a/packages/ember-cli-fastboot/package.json b/packages/ember-cli-fastboot/package.json index 4c9727ec0..03776e63c 100644 --- a/packages/ember-cli-fastboot/package.json +++ b/packages/ember-cli-fastboot/package.json @@ -69,7 +69,7 @@ "co": "4.6.0", "ember-auto-import": "^2.2.1", "ember-cli": "~4.1.0", - "ember-cli-addon-tests": "^0.11.1", + "ember-cli-addon-tests": "Gaurav0/ember-cli-addon-tests#fix_scope", "ember-cli-dependency-checker": "^3.2.0", "ember-cli-htmlbars": "^5.7.2", "ember-cli-inject-live-reload": "^2.1.0", diff --git a/yarn.lock b/yarn.lock index e1ac0fc7e..7f0dfbe42 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5349,10 +5349,9 @@ ember-cached-decorator-polyfill@^0.1.4: ember-cli-babel "^7.21.0" ember-cli-babel-plugin-helpers "^1.1.1" -ember-cli-addon-tests@^0.11.1: +ember-cli-addon-tests@Gaurav0/ember-cli-addon-tests#fix_scope: version "0.11.1" - resolved "https://registry.yarnpkg.com/ember-cli-addon-tests/-/ember-cli-addon-tests-0.11.1.tgz#70c9164cb4126b2d17bbf9588ff34d97d4bfbad1" - integrity sha512-PI3ht9NrgfAwBgh3aPCVecajndvDKltTqRdtxt5bgfQJ3+AMs6moXhijKygwuAeT5btyhhLbceTfHRL/K8pX2w== + resolved "https://codeload.github.com/Gaurav0/ember-cli-addon-tests/tar.gz/2f2dc5101db492db527a93b135110ee662259748" dependencies: chalk "^2.0.1" debug "^3.0.0" From 4a6ee0ca1fe22fb356677882e171824f08b4dc7d Mon Sep 17 00:00:00 2001 From: Gaurav Munjal Date: Tue, 31 Oct 2023 12:40:48 -0400 Subject: [PATCH 03/11] fix paths in legacy mocha tests --- .../ember-cli-fastboot/lib/path/get-path.js | 5 ++++ .../lib/path/set-fastboot-pkg-path.js | 16 ++++++++++++ .../test/fastboot-config-test.js | 26 ++++++++++--------- .../test/fastboot-location-config-test.js | 2 ++ .../test/fastboot-location-test.js | 2 ++ .../test/package-json-test.js | 2 ++ .../test/request-details-test.js | 12 +++++---- .../ember-cli-fastboot/test/root-url-test.js | 20 ++++++++++++++ 8 files changed, 68 insertions(+), 17 deletions(-) create mode 100644 packages/ember-cli-fastboot/lib/path/get-path.js create mode 100644 packages/ember-cli-fastboot/lib/path/set-fastboot-pkg-path.js diff --git a/packages/ember-cli-fastboot/lib/path/get-path.js b/packages/ember-cli-fastboot/lib/path/get-path.js new file mode 100644 index 000000000..dacadc7fc --- /dev/null +++ b/packages/ember-cli-fastboot/lib/path/get-path.js @@ -0,0 +1,5 @@ +const path = require('path'); + +module.exports = function() { + return path.resolve(__dirname, '../../../../packages/ember-cli-fastboot'); +}; diff --git a/packages/ember-cli-fastboot/lib/path/set-fastboot-pkg-path.js b/packages/ember-cli-fastboot/lib/path/set-fastboot-pkg-path.js new file mode 100644 index 000000000..08e9e6491 --- /dev/null +++ b/packages/ember-cli-fastboot/lib/path/set-fastboot-pkg-path.js @@ -0,0 +1,16 @@ +const scope = '@gaurav9576'; +const packageDir = `${__dirname}/../../../../packages`; + +module.exports = function setFastbootPkgPath(pkg) { + pkg.dependencies = pkg.dependencies ?? {}; + [pkg.dependencies, pkg.devDependencies].forEach(depList => { + ['fastboot', 'ember-cli-fastboot', 'fastboot-express-middleware'].forEach( + depName => { + const dep = `${scope}/${depName}`; + if (dep in depList) { + depList[dep] = `file:${packageDir}/${depName}`; + } + } + ); + }); +}; diff --git a/packages/ember-cli-fastboot/test/fastboot-config-test.js b/packages/ember-cli-fastboot/test/fastboot-config-test.js index 19202c763..dbc50262e 100644 --- a/packages/ember-cli-fastboot/test/fastboot-config-test.js +++ b/packages/ember-cli-fastboot/test/fastboot-config-test.js @@ -3,24 +3,26 @@ const expect = require('chai').use(require('chai-string')).expect; const RSVP = require('rsvp'); const request = RSVP.denodeify(require('request')); +const setFastbootPkgPath = require('../lib/path/set-fastboot-pkg-path'); const AddonTestApp = require('ember-cli-addon-tests').AddonTestApp; -describe('FastBoot config', function () { +describe('FastBoot config', function() { this.timeout(400000); let app; - before(function () { + before(function() { app = new AddonTestApp(); return app .create('fastboot-config', { emberVersion: '~3.28.12', - emberDataVersion: '~3.28.12', + emberDataVersion: '~3.28.12' }) - .then(function () { - app.editPackageJSON((pkg) => { + .then(function() { + app.editPackageJSON(pkg => { + setFastbootPkgPath(pkg); delete pkg.devDependencies['ember-fetch']; delete pkg.devDependencies['ember-welcome-page']; // needed because @ember-data/store does `FastBoot.require('crypto')` @@ -28,24 +30,24 @@ describe('FastBoot config', function () { }); return app.run('npm', 'install'); }) - .then(function () { + .then(function() { return app.startServer({ - command: 'serve', + command: 'serve' }); }); }); - after(function () { + after(function() { return app.stopServer(); }); - it('provides sandbox globals', function () { + it('provides sandbox globals', function() { return request({ url: 'http://localhost:49741/', headers: { - Accept: 'text/html', - }, - }).then(function (response) { + Accept: 'text/html' + } + }).then(function(response) { expect(response.statusCode).to.equal(200); expect(response.headers['content-type']).to.equalIgnoreCase( 'text/html; charset=utf-8' diff --git a/packages/ember-cli-fastboot/test/fastboot-location-config-test.js b/packages/ember-cli-fastboot/test/fastboot-location-config-test.js index 63a0797c9..efbeda611 100644 --- a/packages/ember-cli-fastboot/test/fastboot-location-config-test.js +++ b/packages/ember-cli-fastboot/test/fastboot-location-config-test.js @@ -3,6 +3,7 @@ const expect = require('chai').expect; const RSVP = require('rsvp'); const request = RSVP.denodeify(require('request')); +const setFastbootPkgPath = require('../lib/path/set-fastboot-pkg-path'); const AddonTestApp = require('ember-cli-addon-tests').AddonTestApp; @@ -21,6 +22,7 @@ describe('FastBootLocation Configuration', function () { }) .then(function () { app.editPackageJSON((pkg) => { + setFastbootPkgPath(pkg); delete pkg.devDependencies['ember-fetch']; delete pkg.devDependencies['ember-welcome-page']; // needed because @ember-data/store does `FastBoot.require('crypto')` diff --git a/packages/ember-cli-fastboot/test/fastboot-location-test.js b/packages/ember-cli-fastboot/test/fastboot-location-test.js index 99c4540b5..1ca661fc9 100644 --- a/packages/ember-cli-fastboot/test/fastboot-location-test.js +++ b/packages/ember-cli-fastboot/test/fastboot-location-test.js @@ -3,6 +3,7 @@ const expect = require('chai').expect; const RSVP = require('rsvp'); const request = RSVP.denodeify(require('request')); +const setFastbootPkgPath = require('../lib/path/set-fastboot-pkg-path'); const AddonTestApp = require('ember-cli-addon-tests').AddonTestApp; @@ -20,6 +21,7 @@ describe('FastBootLocation', function () { }) .then(function () { app.editPackageJSON((pkg) => { + setFastbootPkgPath(pkg); delete pkg.devDependencies['ember-fetch']; delete pkg.devDependencies['ember-welcome-page']; // needed because @ember-data/store does `FastBoot.require('crypto')` diff --git a/packages/ember-cli-fastboot/test/package-json-test.js b/packages/ember-cli-fastboot/test/package-json-test.js index 0f98eb677..5e10ebbfa 100644 --- a/packages/ember-cli-fastboot/test/package-json-test.js +++ b/packages/ember-cli-fastboot/test/package-json-test.js @@ -5,6 +5,7 @@ const expect = chai.expect; const fs = require('fs-extra'); const path = require('path'); const AddonTestApp = require('ember-cli-addon-tests').AddonTestApp; +const setFastbootPkgPath = require('../lib/path/set-fastboot-pkg-path'); chai.use(require('chai-fs')); @@ -23,6 +24,7 @@ describe('generating package.json', function () { }) .then(function () { customApp.editPackageJSON((pkg) => { + setFastbootPkgPath(pkg); delete pkg.devDependencies['ember-fetch']; delete pkg.devDependencies['ember-welcome-page']; // needed because @ember-data/store does `FastBoot.require('crypto')` diff --git a/packages/ember-cli-fastboot/test/request-details-test.js b/packages/ember-cli-fastboot/test/request-details-test.js index 0f73e2c49..f8162d675 100644 --- a/packages/ember-cli-fastboot/test/request-details-test.js +++ b/packages/ember-cli-fastboot/test/request-details-test.js @@ -6,15 +6,21 @@ const expect = chai.expect; const RSVP = require('rsvp'); const AddonTestApp = require('ember-cli-addon-tests').AddonTestApp; const request = RSVP.denodeify(require('request')); +const setFastbootPkgPath = require('../lib/path/set-fastboot-pkg-path'); async function injectMiddlewareAddon(app) { app.editPackageJSON(function (pkg) { + const scope = '@gaurav9576'; + pkg.dependencies = pkg.dependencies ?? {}; + ['fastboot', 'fastboot-express-middleware'].forEach(depName => { + pkg.dependencies[`${scope}/${depName}`] = '*'; + }); pkg.devDependencies['body-parser'] = process.env.npm_package_devDependencies_body_parser; - pkg.dependencies = pkg.dependencies || {}; pkg['ember-addon'] = { paths: ['lib/post-middleware'], }; + setFastbootPkgPath(pkg); delete pkg.devDependencies['ember-fetch']; delete pkg.devDependencies['ember-welcome-page']; // needed because @ember-data/store does `FastBoot.require('crypto')` @@ -33,10 +39,6 @@ async function injectMiddlewareAddon(app) { path.resolve(__dirname, '../../@gaurav9576/fastboot-express-middleware'), path.resolve(app.path, 'node_modules/fastboot-express-middleware') ); - app.editPackageJSON(function (pkg) { - pkg.dependencies['@gaurav9576/fastboot'] = '*'; - pkg.dependencies['@gaurav9576/fastboot-express-middleware'] = '*'; - }); } describe('request details', function () { diff --git a/packages/ember-cli-fastboot/test/root-url-test.js b/packages/ember-cli-fastboot/test/root-url-test.js index d787496e0..123c2389e 100644 --- a/packages/ember-cli-fastboot/test/root-url-test.js +++ b/packages/ember-cli-fastboot/test/root-url-test.js @@ -2,7 +2,11 @@ const expect = require('chai').use(require('chai-string')).expect; const RSVP = require('rsvp'); +const path = require('path'); const request = RSVP.denodeify(require('request')); +const setFastbootPkgPath = require('../lib/path/set-fastboot-pkg-path'); +const getPath = require('../lib/path/get-path'); +const exec = RSVP.denodeify(require('child_process').exec); const AddonTestApp = require('ember-cli-addon-tests').AddonTestApp; @@ -19,8 +23,17 @@ describe('rootUrl acceptance', function () { emberVersion: '~3.28.12', emberDataVersion: '~3.28.12', }) + .then(function () { + return exec(`cd ${getPath()} && npm pack`); + }) .then(function () { app.editPackageJSON((pkg) => { + const scope = '@gaurav9576'; + pkg.dependencies = pkg.dependencies ?? {}; + ['fastboot', 'fastboot-express-middleware'].forEach(depName => { + pkg.dependencies[`${scope}/${depName}`] = '*'; + }); + setFastbootPkgPath(pkg); delete pkg.devDependencies['ember-fetch']; delete pkg.devDependencies['ember-welcome-page']; // needed because @ember-data/store does `FastBoot.require('crypto')` @@ -28,6 +41,13 @@ describe('rootUrl acceptance', function () { }); return app.run('npm', 'install'); }) + .then(function () { + const file = path.resolve( + getPath(), + 'gaurav9576-ember-cli-fastboot-4.1.1.tgz' + ); + return app.run('npm', 'install', file); + }) .then(function () { return app.startServer({ command: 'serve', From a1f38fe8652f18246e511aef42d56f1da187f006 Mon Sep 17 00:00:00 2001 From: Gaurav Munjal Date: Tue, 31 Oct 2023 13:30:13 -0400 Subject: [PATCH 04/11] update npm on node 14 --- .github/workflows/ci.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 660f03fb5..fab4b9c35 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -119,6 +119,11 @@ jobs: uses: volta-cli/action@v4 with: node-version: ${{ matrix.node-version }} + - name: Update Npm + run: | + volta install npm@8 + volta pin npm@8 + npm -v - name: Yarn Install run: | yarn install --ignore-engines --frozen-lockfile From b9eb3eb503efed085a400e9f5db791e816ec2781 Mon Sep 17 00:00:00 2001 From: Gaurav Munjal Date: Thu, 2 Nov 2023 03:01:09 -0400 Subject: [PATCH 05/11] use overrides --- .../ember-cli-fastboot/lib/path/set-fastboot-pkg-path.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/ember-cli-fastboot/lib/path/set-fastboot-pkg-path.js b/packages/ember-cli-fastboot/lib/path/set-fastboot-pkg-path.js index 08e9e6491..8bea4d3f0 100644 --- a/packages/ember-cli-fastboot/lib/path/set-fastboot-pkg-path.js +++ b/packages/ember-cli-fastboot/lib/path/set-fastboot-pkg-path.js @@ -3,7 +3,10 @@ const packageDir = `${__dirname}/../../../../packages`; module.exports = function setFastbootPkgPath(pkg) { pkg.dependencies = pkg.dependencies ?? {}; - [pkg.dependencies, pkg.devDependencies].forEach(depList => { + pkg.overrides = pkg.overrides ?? {}; + pkg.overrides[`${scope}/fastboot`] = '*'; + pkg.overrides[`${scope}/fastboot-express-middleware`] = '*'; + [pkg.dependencies, pkg.devDependencies, pkg.overrides].forEach(depList => { ['fastboot', 'ember-cli-fastboot', 'fastboot-express-middleware'].forEach( depName => { const dep = `${scope}/${depName}`; From 65e3d1b7909c82f9a67fb8623d2ac24acaea9185 Mon Sep 17 00:00:00 2001 From: Gaurav Munjal Date: Thu, 2 Nov 2023 03:51:09 -0400 Subject: [PATCH 06/11] fix fastboot override --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 2f0220875..430eaa749 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "release-it-yarn-workspaces": "^2.0.0" }, "resolutions": { - "@gaurav9576/fastboot": "4.1.1" + "fastboot": "file:packages/fastboot" }, "publishConfig": { "registry": "https://registry.npmjs.org" diff --git a/yarn.lock b/yarn.lock index 7f0dfbe42..c0911ecd3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6954,15 +6954,15 @@ fastboot-transform@^0.1.3: broccoli-stew "^1.5.0" convert-source-map "^1.5.1" -fastboot@^3.0.3: - version "3.3.2" - resolved "https://registry.yarnpkg.com/fastboot/-/fastboot-3.3.2.tgz#bf1ac7b01937846b63423a88138e13eb50406d2e" - integrity sha512-2NKTW32GvEsDyBrdw1trW1JsbS+9/7sAQuKwkht12mNitimRrSKVLP2AxsM/HSXQE+aiET4XCfKdyeIy0kQbKQ== +fastboot@^3.0.3, "fastboot@file:packages/fastboot": + version "4.1.1" dependencies: + abortcontroller-polyfill "^1.7.3" chalk "^4.1.2" cookie "^0.4.1" debug "^4.3.3" jsdom "^19.0.0" + node-fetch "^2.6.7" resolve "^1.22.0" simple-dom "^1.4.0" source-map-support "^0.5.21" From b43f91abf66ea0f39a810488faba19df85bef6b0 Mon Sep 17 00:00:00 2001 From: Gaurav Munjal Date: Thu, 2 Nov 2023 04:18:44 -0400 Subject: [PATCH 07/11] fix lint --- .../fastboot-express-middleware/src/index.js | 6 +- .../test/helpers/fixture-path.js | 2 +- .../test/helpers/test-http-server.js | 2 +- .../test/middleware-test.js | 48 +++---- packages/fastboot/dev/memory-usage.js | 2 +- packages/fastboot/src/ember-app.js | 8 +- packages/fastboot/src/fastboot-request.js | 2 +- packages/fastboot/src/fastboot-schema.js | 6 +- packages/fastboot/src/index.js | 2 +- packages/fastboot/src/result.js | 18 +-- packages/fastboot/src/sandbox.js | 4 +- .../test/fastboot-dependencies-test.js | 8 +- .../fastboot/test/fastboot-headers-test.js | 30 ++--- packages/fastboot/test/fastboot-info-test.js | 16 +-- .../fastboot/test/fastboot-request-test.js | 28 ++-- .../fastboot/test/fastboot-response-test.js | 18 +-- .../fastboot/test/fastboot-shoebox-test.js | 20 +-- packages/fastboot/test/fastboot-test.js | 126 +++++++++--------- .../fastboot/test/get-package-name-test.js | 4 +- .../fastboot/test/html-entrypoint-test.js | 24 ++-- packages/fastboot/test/queue-test.js | 20 +-- packages/fastboot/test/result-test.js | 94 ++++++------- 22 files changed, 244 insertions(+), 244 deletions(-) diff --git a/packages/fastboot-express-middleware/src/index.js b/packages/fastboot-express-middleware/src/index.js index 49185d0cd..aa40d82d0 100644 --- a/packages/fastboot-express-middleware/src/index.js +++ b/packages/fastboot-express-middleware/src/index.js @@ -13,7 +13,7 @@ function fastbootExpressMiddleware(distPath, options) { opts = opts || {}; - let log = opts.log !== false ? _log : function() {}; + let log = opts.log !== false ? _log : function () {}; let fastboot = opts.fastboot; @@ -25,7 +25,7 @@ function fastbootExpressMiddleware(distPath, options) { }); } - return async function(req, res, next) { + return async function (req, res, next) { let path = req.url; try { @@ -53,7 +53,7 @@ function fastbootExpressMiddleware(distPath, options) { } else if (result.error) { res.send(body[0]); } else { - body.forEach(chunk => res.write(chunk)); + body.forEach((chunk) => res.write(chunk)); res.end(); } } catch (error) { diff --git a/packages/fastboot-express-middleware/test/helpers/fixture-path.js b/packages/fastboot-express-middleware/test/helpers/fixture-path.js index c53a6f6d8..5c392780e 100644 --- a/packages/fastboot-express-middleware/test/helpers/fixture-path.js +++ b/packages/fastboot-express-middleware/test/helpers/fixture-path.js @@ -1,5 +1,5 @@ var path = require('path'); -module.exports = function(fixturePath) { +module.exports = function (fixturePath) { return path.join(__dirname, '../fixtures/', fixturePath); }; diff --git a/packages/fastboot-express-middleware/test/helpers/test-http-server.js b/packages/fastboot-express-middleware/test/helpers/test-http-server.js index 910331fdb..997701346 100644 --- a/packages/fastboot-express-middleware/test/helpers/test-http-server.js +++ b/packages/fastboot-express-middleware/test/helpers/test-http-server.js @@ -35,7 +35,7 @@ class TestHTTPServer { }); } - return new Promise(resolve => { + return new Promise((resolve) => { let port = options.port || 3000; let host = options.host || 'localhost'; diff --git a/packages/fastboot-express-middleware/test/middleware-test.js b/packages/fastboot-express-middleware/test/middleware-test.js index 41dd5a01d..6a1645bbc 100644 --- a/packages/fastboot-express-middleware/test/middleware-test.js +++ b/packages/fastboot-express-middleware/test/middleware-test.js @@ -6,27 +6,27 @@ const fastbootMiddleware = require('./../src/index'); const fixture = require('./helpers/fixture-path'); const TestHTTPServer = require('./helpers/test-http-server'); -describe('FastBoot', function() { +describe('FastBoot', function () { let server; this.timeout(10000); - afterEach(function() { + afterEach(function () { if (server) { server.stop(); server = null; } }); - it('throws an exception if no distPath is provided', function() { - let fn = function() { + it('throws an exception if no distPath is provided', function () { + let fn = function () { fastbootMiddleware(); }; expect(fn).to.throw(/You must instantiate FastBoot with a distPath option/); }); - it('can provide distPath as the first argument', async function() { + it('can provide distPath as the first argument', async function () { let middleware = fastbootMiddleware(fixture('basic-app')); server = new TestHTTPServer(middleware); await server.start(); @@ -35,7 +35,7 @@ describe('FastBoot', function() { expect(html).to.match(/Welcome to Ember/); }); - it('can provide distPath as an option', async function() { + it('can provide distPath as an option', async function () { let middleware = fastbootMiddleware({ distPath: fixture('basic-app'), }); @@ -46,7 +46,7 @@ describe('FastBoot', function() { expect(html).to.match(/Welcome to Ember/); }); - it('can be provided with a custom FastBoot instance', async function() { + it('can be provided with a custom FastBoot instance', async function () { let fastboot = new FastBoot({ distPath: fixture('basic-app'), }); @@ -62,7 +62,7 @@ describe('FastBoot', function() { expect(html).to.match(/Welcome to Ember/); }); - it('can reload the FastBoot instance', async function() { + it('can reload the FastBoot instance', async function () { let fastboot = new FastBoot({ distPath: fixture('basic-app'), }); @@ -85,7 +85,7 @@ describe('FastBoot', function() { expect(html).to.match(/Goodbye from Ember/); }); - it('it appends multivalue headers', async function() { + it('it appends multivalue headers', async function () { let middleware = fastbootMiddleware(fixture('multivalue-headers')); server = new TestHTTPServer(middleware); await server.start(); @@ -94,7 +94,7 @@ describe('FastBoot', function() { expect(headers['x-fastboot']).to.eq('a, b, c'); }); - it('can pass metadata info to the app', async function() { + it('can pass metadata info to the app', async function () { let middleware = fastbootMiddleware({ distPath: fixture('app-with-metadata'), visitOptions: { @@ -112,7 +112,7 @@ describe('FastBoot', function() { // TODO: // https://github.com/ember-fastboot/ember-cli-fastboot/pull/840#issuecomment-894329631 // eslint-disable-next-line mocha/no-skipped-tests - xit('works without metadata passed', async function() { + xit('works without metadata passed', async function () { let middleware = fastbootMiddleware({ distPath: fixture('app-with-metadata'), }); @@ -124,10 +124,10 @@ describe('FastBoot', function() { }); /* eslint-disable mocha/no-setup-in-describe */ - [true, false].forEach(chunkedResponse => { - describe(`when chunked response is ${chunkedResponse ? 'enabled' : 'disabled'}`, function() { + [true, false].forEach((chunkedResponse) => { + describe(`when chunked response is ${chunkedResponse ? 'enabled' : 'disabled'}`, function () { if (chunkedResponse) { - it('responds with a chunked response', async function() { + it('responds with a chunked response', async function () { let middleware = fastbootMiddleware({ distPath: fixture('basic-app'), chunkedResponse, @@ -141,7 +141,7 @@ describe('FastBoot', function() { }); } - it("returns 404 when navigating to a URL that doesn't exist", async function() { + it("returns 404 when navigating to a URL that doesn't exist", async function () { let middleware = fastbootMiddleware({ distPath: fixture('basic-app'), chunkedResponse, @@ -156,7 +156,7 @@ describe('FastBoot', function() { } }); - it('returns a 500 error if an error occurs', async function() { + it('returns a 500 error if an error occurs', async function () { let middleware = fastbootMiddleware({ distPath: fixture('rejected-promise'), chunkedResponse, @@ -171,8 +171,8 @@ describe('FastBoot', function() { } }); - describe('when resilient mode is enabled', function() { - it('renders no FastBoot markup', async function() { + describe('when resilient mode is enabled', function () { + it('renders no FastBoot markup', async function () { let middleware = fastbootMiddleware({ distPath: fixture('rejected-promise'), resilient: true, @@ -185,7 +185,7 @@ describe('FastBoot', function() { expect(html).to.not.match(/error/); }); - it('propagates to error handling middleware', async function() { + it('propagates to error handling middleware', async function () { let middleware = fastbootMiddleware({ distPath: fixture('rejected-promise'), resilient: true, @@ -202,7 +202,7 @@ describe('FastBoot', function() { expect(body).to.match(/hello world/); }); - it('is does not propagate errors when and there is no error handling middleware', async function() { + it('is does not propagate errors when and there is no error handling middleware', async function () { let middleware = fastbootMiddleware({ distPath: fixture('rejected-promise'), resilient: true, @@ -220,7 +220,7 @@ describe('FastBoot', function() { expect(body).to.match(/hello world/); }); - it('allows post-fastboot middleware to recover the response when it fails', async function() { + it('allows post-fastboot middleware to recover the response when it fails', async function () { let middleware = fastbootMiddleware({ distPath: fixture('rejected-promise'), resilient: true, @@ -238,8 +238,8 @@ describe('FastBoot', function() { }); }); - describe('when resilient mode is disabled', function() { - it('propagates to error handling middleware', async function() { + describe('when resilient mode is disabled', function () { + it('propagates to error handling middleware', async function () { let middleware = fastbootMiddleware({ distPath: fixture('rejected-promise'), resilient: false, @@ -258,7 +258,7 @@ describe('FastBoot', function() { } }); - it('allows post-fastboot middleware to recover the response when it fails', async function() { + it('allows post-fastboot middleware to recover the response when it fails', async function () { let middleware = fastbootMiddleware({ distPath: fixture('rejected-promise'), resilient: false, diff --git a/packages/fastboot/dev/memory-usage.js b/packages/fastboot/dev/memory-usage.js index 0cdd88b18..c9d0bcf26 100644 --- a/packages/fastboot/dev/memory-usage.js +++ b/packages/fastboot/dev/memory-usage.js @@ -28,7 +28,7 @@ session.connect(); let file; // uses whatever the "current" file is -session.on('HeapProfiler.addHeapSnapshotChunk', m => { +session.on('HeapProfiler.addHeapSnapshotChunk', (m) => { fs.writeSync(file, m.params.chunk); }); diff --git a/packages/fastboot/src/ember-app.js b/packages/fastboot/src/ember-app.js index 5436bc85d..342c29037 100644 --- a/packages/fastboot/src/ember-app.js +++ b/packages/fastboot/src/ember-app.js @@ -165,7 +165,7 @@ class EmberApp { debug('files evaluated'); // Retrieve the application factory from within the sandbox - let AppFactory = sandbox.run(function(ctx) { + let AppFactory = sandbox.run(function (ctx) { return ctx.require('~fastboot/app-factory'); }); @@ -316,7 +316,7 @@ class EmberApp { if (destroyAppInstanceInMs > 0) { // start a timer to destroy the appInstance forcefully in the given ms. // This is a failure mechanism so that node process doesn't get wedged if the `visit` never completes. - destroyAppInstanceTimer = setTimeout(function() { + destroyAppInstanceTimer = setTimeout(function () { if (result._destroy()) { result.error = new Error( 'App instance was forcefully destroyed in ' + destroyAppInstanceInMs + 'ms' @@ -418,7 +418,7 @@ const JSON_ESCAPE = { const JSON_ESCAPE_REGEXP = /[\u2028\u2029&><]/g; function escapeJSONString(string) { - return string.replace(JSON_ESCAPE_REGEXP, function(match) { + return string.replace(JSON_ESCAPE_REGEXP, function (match) { return JSON_ESCAPE[match]; }); } @@ -432,7 +432,7 @@ function registerFastBootInfo(info, instance) { } function buildScripts(filePaths) { - return filePaths.filter(Boolean).map(filePath => { + return filePaths.filter(Boolean).map((filePath) => { let source = fs.readFileSync(filePath, { encoding: 'utf8' }); return new vm.Script(source, { filename: filePath }); diff --git a/packages/fastboot/src/fastboot-request.js b/packages/fastboot/src/fastboot-request.js index ed7a1c70f..d6cec8c61 100644 --- a/packages/fastboot/src/fastboot-request.js +++ b/packages/fastboot/src/fastboot-request.js @@ -23,7 +23,7 @@ class FastBootRequest { } var host = this.headers.get('host'); - var matchFound = this.hostWhitelist.some(function(entry) { + var matchFound = this.hostWhitelist.some(function (entry) { if (entry[0] === '/' && entry.slice(-1) === '/') { var regexp = new RegExp(entry.slice(1, -1)); return regexp.test(host); diff --git a/packages/fastboot/src/fastboot-schema.js b/packages/fastboot/src/fastboot-schema.js index d08c7b747..70b9cc1cd 100644 --- a/packages/fastboot/src/fastboot-schema.js +++ b/packages/fastboot/src/fastboot-schema.js @@ -127,7 +127,7 @@ function loadManifest(distPath, fastbootConfig, schemaVersion) { } } - let scripts = manifest.vendorFiles.concat(manifest.appFiles).map(function(file) { + let scripts = manifest.vendorFiles.concat(manifest.appFiles).map(function (file) { return path.join(distPath, file); }); let html = fs.readFileSync(path.join(distPath, manifest.htmlFile), 'utf8'); @@ -149,7 +149,7 @@ function loadManifest(distPath, fastbootConfig, schemaVersion) { * @param {boolean} isLegacyWhiteList flag to enable legacy behavior */ function buildWhitelistedRequire(whitelist, distPath, isLegacyWhitelist) { - whitelist.forEach(function(whitelistedModule) { + whitelist.forEach(function (whitelistedModule) { debug('module whitelisted; module=%s', whitelistedModule); if (isLegacyWhitelist) { @@ -161,7 +161,7 @@ function buildWhitelistedRequire(whitelist, distPath, isLegacyWhitelist) { } }); - return function(moduleName) { + return function (moduleName) { let packageName = getPackageName(moduleName); let isWhitelisted = whitelist.indexOf(packageName) > -1; diff --git a/packages/fastboot/src/index.js b/packages/fastboot/src/index.js index 4d9f795d4..d7172f2d2 100644 --- a/packages/fastboot/src/index.js +++ b/packages/fastboot/src/index.js @@ -55,7 +55,7 @@ class FastBoot { console.warn( '[DEPRECATION] Instantiating `fastboot` with a `sandboxGlobals` option has been deprecated. Please migrate to specifying `buildSandboxGlobals` instead.' ); - buildSandboxGlobals = globals => Object.assign({}, globals, options.sandboxGlobals); + buildSandboxGlobals = (globals) => Object.assign({}, globals, options.sandboxGlobals); } this.buildSandboxGlobals = buildSandboxGlobals; diff --git a/packages/fastboot/src/result.js b/packages/fastboot/src/result.js index 1c3426b30..dd4f23acb 100644 --- a/packages/fastboot/src/result.js +++ b/packages/fastboot/src/result.js @@ -80,7 +80,7 @@ class Result { this._body, this._bodyAttributes, this._bodyClass - ).then(html => { + ).then((html) => { let docParts = html.match(HTML_HEAD_REGEX); if (!docParts || docParts.length === 1) { return [html]; @@ -97,7 +97,7 @@ class Result { let [plainBody, ...shoeboxes] = body.split(SHOEBOX_TAG_PATTERN); let chunks = [head, plainBody].concat( - shoeboxes.map(shoebox => `${SHOEBOX_TAG_PATTERN}${shoebox}`) + shoeboxes.map((shoebox) => `${SHOEBOX_TAG_PATTERN}${shoebox}`) ); return chunks; @@ -203,10 +203,10 @@ function extractExtraAttributes(element) { let klass; let attributes; if (element.attributes.length > 0) { - let elementClass = element.attributes.find(attr => attr.name === 'class'); + let elementClass = element.attributes.find((attr) => attr.name === 'class'); if (elementClass) { klass = elementClass; - let otherAttrs = element.attributes.filter(attr => attr.name !== 'class'); + let otherAttrs = element.attributes.filter((attr) => attr.name !== 'class'); if (otherAttrs.length > 0) { attributes = HTMLSerializer.attributes(otherAttrs); } else { @@ -229,9 +229,9 @@ function missingTag(tag) { } function addClass(html, regex, newClass) { - return html.replace(regex, function(_, tag, attributes) { + return html.replace(regex, function (_, tag, attributes) { if (/class="([^"]*)"/i.test(attributes)) { - attributes = attributes.replace(/class="([^"]*)"/i, function(_, klass) { + attributes = attributes.replace(/class="([^"]*)"/i, function (_, klass) { return `class="${klass} ${newClass}"`; }); } else { @@ -256,7 +256,7 @@ async function insertIntoIndexHTML( let isBodyReplaced = false; let isHeadReplaced = false; - html = html.replace(//g, function(match, tag) { + html = html.replace(//g, function (match, tag) { if (tag === 'HEAD' && head && !isHeadReplaced) { isHeadReplaced = true; return head; @@ -271,7 +271,7 @@ async function insertIntoIndexHTML( html = addClass(html, /<(html)(.*)>/i, htmlClass.value); } if (htmlAttributes) { - html = html.replace(/]*/i, function(match) { + html = html.replace(/]*/i, function (match) { return match + ' ' + htmlAttributes; }); } @@ -280,7 +280,7 @@ async function insertIntoIndexHTML( html = addClass(html, /<(body)(.*)>/i, bodyClass.value); } if (bodyAttributes) { - html = html.replace(/]*/i, function(match) { + html = html.replace(/]*/i, function (match) { return match + ' ' + bodyAttributes; }); } diff --git a/packages/fastboot/src/sandbox.js b/packages/fastboot/src/sandbox.js index e462a0693..3aa2e4408 100644 --- a/packages/fastboot/src/sandbox.js +++ b/packages/fastboot/src/sandbox.js @@ -46,10 +46,10 @@ module.exports = class Sandbox { buildWrappedConsole() { let wrappedConsole = Object.create(console); - wrappedConsole.error = function(...args) { + wrappedConsole.error = function (...args) { console.error.apply( console, - args.map(function(a) { + args.map(function (a) { return typeof a === 'string' ? chalk.red(a) : a; }) ); diff --git a/packages/fastboot/test/fastboot-dependencies-test.js b/packages/fastboot/test/fastboot-dependencies-test.js index 3b8cb2b2f..beb48faa6 100644 --- a/packages/fastboot/test/fastboot-dependencies-test.js +++ b/packages/fastboot/test/fastboot-dependencies-test.js @@ -4,16 +4,16 @@ const expect = require('chai').expect; const fixture = require('./helpers/fixture-path'); const FastBoot = require('./../src/index'); -describe('FastBoot with dependencies', function() { - it('it works with dependencies', function() { +describe('FastBoot with dependencies', function () { + it('it works with dependencies', function () { var fastboot = new FastBoot({ distPath: fixture('app-with-dependencies'), }); return fastboot .visit('/') - .then(r => r.html()) - .then(html => { + .then((r) => r.html()) + .then((html) => { expect(html).to.match(/https:\/\/emberjs.com/); expect(html).to.match(/FOO/); expect(html).to.match(/BAR/); diff --git a/packages/fastboot/test/fastboot-headers-test.js b/packages/fastboot/test/fastboot-headers-test.js index 1d65353fa..b7714a7a8 100644 --- a/packages/fastboot/test/fastboot-headers-test.js +++ b/packages/fastboot/test/fastboot-headers-test.js @@ -3,8 +3,8 @@ var expect = require('chai').expect; var FastBootHeaders = require('./../src/fastboot-headers.js'); -describe('FastBootHeaders', function() { - it('lower normalizes the headers to lowercase', function() { +describe('FastBootHeaders', function () { + it('lower normalizes the headers to lowercase', function () { var headers = { 'X-Test-Header': 'value1, value2', }; @@ -13,7 +13,7 @@ describe('FastBootHeaders', function() { expect(headers.getAll('x-test-header')).to.deep.equal(['value1, value2']); }); - it('returns an array from getAll when header value is string', function() { + it('returns an array from getAll when header value is string', function () { var headers = { 'x-test-header': 'value1, value2', }; @@ -22,7 +22,7 @@ describe('FastBootHeaders', function() { expect(headers.getAll('x-test-header')).to.deep.equal(['value1, value2']); }); - it('returns an array of header values from getAll, regardless of header name casing', function() { + it('returns an array of header values from getAll, regardless of header name casing', function () { var headers = { 'x-test-header': ['value1', 'value2'], }; @@ -32,7 +32,7 @@ describe('FastBootHeaders', function() { expect(headers.getAll('x-test-header')).to.deep.equal(['value1', 'value2']); }); - it('returns an emtpy array when a header is not present', function() { + it('returns an emtpy array when a header is not present', function () { var headers = { 'x-test-header': ['value1', 'value2'], }; @@ -42,7 +42,7 @@ describe('FastBootHeaders', function() { expect(headers.getAll('host')).to.deep.equal([]); }); - it('returns the first value when using get, regardless of case', function() { + it('returns the first value when using get, regardless of case', function () { var headers = { 'x-test-header': ['value1', 'value2'], }; @@ -52,7 +52,7 @@ describe('FastBootHeaders', function() { expect(headers.get('x-test-header')).to.equal('value1'); }); - it('returns null when using get when a header is not present', function() { + it('returns null when using get when a header is not present', function () { var headers = { 'x-test-header': ['value1', 'value2'], }; @@ -62,7 +62,7 @@ describe('FastBootHeaders', function() { expect(headers.get('host')).to.be.null; }); - it('returns whether or not a header is present via has, regardless of casing', function() { + it('returns whether or not a header is present via has, regardless of casing', function () { var headers = { 'x-test-header': ['value1', 'value2'], }; @@ -74,7 +74,7 @@ describe('FastBootHeaders', function() { expect(headers.has('host')).to.be.false; }); - it('appends entries onto a header, regardless of casing', function() { + it('appends entries onto a header, regardless of casing', function () { var headers = new FastBootHeaders(); expect(headers.has('x-foo')).to.be.false; @@ -87,7 +87,7 @@ describe('FastBootHeaders', function() { expect(headers.getAll('x-foo')).to.deep.equal(['bar', 'baz']); }); - it('deletes entries onto a header, regardless of casing', function() { + it('deletes entries onto a header, regardless of casing', function () { var headers = new FastBootHeaders(); headers.append('X-Foo', 'bar'); @@ -97,7 +97,7 @@ describe('FastBootHeaders', function() { expect(headers.has('x-foo')).to.be.false; }); - it('returns an iterator for the header/value pairs when calling entries', function() { + it('returns an iterator for the header/value pairs when calling entries', function () { var headers = new FastBootHeaders(); headers.append('X-Foo', 'foo'); @@ -111,7 +111,7 @@ describe('FastBootHeaders', function() { expect(entriesIterator.next()).to.deep.equal({ value: undefined, done: true }); }); - it('returns an iterator for keys containing all the keys', function() { + it('returns an iterator for keys containing all the keys', function () { var headers = new FastBootHeaders(); headers.append('X-Foo', 'foo'); @@ -125,7 +125,7 @@ describe('FastBootHeaders', function() { expect(entriesIterator.next()).to.deep.equal({ value: undefined, done: true }); }); - it('sets a header, overwriting existing values, regardless of casing', function() { + it('sets a header, overwriting existing values, regardless of casing', function () { var headers = new FastBootHeaders(); expect(headers.getAll('x-foo')).to.deep.equal([]); @@ -141,7 +141,7 @@ describe('FastBootHeaders', function() { expect(headers.getAll('x-bar')).to.deep.equal(['baz']); }); - it('returns an iterator for values containing all the values', function() { + it('returns an iterator for values containing all the values', function () { var headers = new FastBootHeaders(); headers.append('X-Foo', 'foo'); @@ -155,7 +155,7 @@ describe('FastBootHeaders', function() { expect(entriesIterator.next()).to.deep.equal({ value: undefined, done: true }); }); - it('when mistakenly used `Ember.get` with an unknown property, it attempts to get the header with that name and warns the user to use `headers.get` instead', function() { + it('when mistakenly used `Ember.get` with an unknown property, it attempts to get the header with that name and warns the user to use `headers.get` instead', function () { var headers = { 'x-test-header': ['value1', 'value2'], }; diff --git a/packages/fastboot/test/fastboot-info-test.js b/packages/fastboot/test/fastboot-info-test.js index 67f91df94..1cf24afee 100644 --- a/packages/fastboot/test/fastboot-info-test.js +++ b/packages/fastboot/test/fastboot-info-test.js @@ -4,7 +4,7 @@ var FastBootResponse = require('./../src/fastboot-response.js'); var FastBootRequest = require('./../src/fastboot-request.js'); function delayFor(ms) { - let promise = new Promise(resolve => { + let promise = new Promise((resolve) => { setTimeout(() => { resolve(); }, ms); @@ -13,7 +13,7 @@ function delayFor(ms) { return promise; } -describe('FastBootInfo', function() { +describe('FastBootInfo', function () { var response; var request; var fastbootInfo; @@ -22,13 +22,13 @@ describe('FastBootInfo', function() { baz: 'apple', }; - beforeEach(function() { + beforeEach(function () { response = {}; request = { cookie: '', protocol: 'http', headers: {}, - get: function() { + get: function () { return this.cookie; }, }; @@ -36,19 +36,19 @@ describe('FastBootInfo', function() { fastbootInfo = new FastBootInfo(request, response, { metadata }); }); - it('has a FastBootRequest', function() { + it('has a FastBootRequest', function () { expect(fastbootInfo.request).to.be.an.instanceOf(FastBootRequest); }); - it('has a FastBootResponse', function() { + it('has a FastBootResponse', function () { expect(fastbootInfo.response).to.be.an.instanceOf(FastBootResponse); }); - it('has metadata', function() { + it('has metadata', function () { expect(fastbootInfo.metadata).to.deep.equal(metadata); }); - it('can use deferRendering', async function() { + it('can use deferRendering', async function () { let steps = []; steps.push('deferRendering called'); diff --git a/packages/fastboot/test/fastboot-request-test.js b/packages/fastboot/test/fastboot-request-test.js index 4e2b096e9..052649119 100644 --- a/packages/fastboot/test/fastboot-request-test.js +++ b/packages/fastboot/test/fastboot-request-test.js @@ -1,8 +1,8 @@ var expect = require('chai').expect; var FastBootRequest = require('./../src/fastboot-request.js'); -describe('FastBootRequest', function() { - it('throws an exception if no hostWhitelist is provided', function() { +describe('FastBootRequest', function () { + it('throws an exception if no hostWhitelist is provided', function () { var request = { protocol: 'http', headers: { @@ -11,13 +11,13 @@ describe('FastBootRequest', function() { }; var fastbootRequest = new FastBootRequest(request); - var fn = function() { + var fn = function () { fastbootRequest.host(); }; expect(fn).to.throw(/You must provide a hostWhitelist to retrieve the host/); }); - it('throws an exception if the host header does not match an entry in the hostWhitelist', function() { + it('throws an exception if the host header does not match an entry in the hostWhitelist', function () { var request = { protocol: 'http', headers: { @@ -28,7 +28,7 @@ describe('FastBootRequest', function() { var hostWhitelist = ['example.com', 'localhost:4200']; var fastbootRequest = new FastBootRequest(request, hostWhitelist); - var fn = function() { + var fn = function () { fastbootRequest.host(); }; expect(fn).to.throw( @@ -36,7 +36,7 @@ describe('FastBootRequest', function() { ); }); - it('returns the host if it is in the hostWhitelist', function() { + it('returns the host if it is in the hostWhitelist', function () { var request = { protocol: 'http', headers: { @@ -51,7 +51,7 @@ describe('FastBootRequest', function() { expect(host).to.equal('localhost:4200'); }); - it('returns the host if it matches a regex in the hostWhitelist', function() { + it('returns the host if it matches a regex in the hostWhitelist', function () { var request = { protocol: 'http', headers: { @@ -66,7 +66,7 @@ describe('FastBootRequest', function() { expect(host).to.equal('localhost:4200'); }); - it('captures the query params from the request', function() { + it('captures the query params from the request', function () { var request = { protocol: 'http', query: { @@ -81,7 +81,7 @@ describe('FastBootRequest', function() { expect(fastbootRequest.queryParams.foo).to.equal('bar'); }); - it('captures the path from the request', function() { + it('captures the path from the request', function () { var request = { protocol: 'http', url: '/foo', @@ -94,7 +94,7 @@ describe('FastBootRequest', function() { expect(fastbootRequest.path).to.equal('/foo'); }); - it('captures the headers from the request', function() { + it('captures the headers from the request', function () { var request = { protocol: 'http', url: '/foo', @@ -108,7 +108,7 @@ describe('FastBootRequest', function() { expect(fastbootRequest.headers.get('Host')).to.equal('localhost:4200'); }); - it('captures the protocol from the request', function() { + it('captures the protocol from the request', function () { var request = { protocol: 'http', url: '/foo', @@ -122,7 +122,7 @@ describe('FastBootRequest', function() { expect(fastbootRequest.protocol).to.equal('http:'); }); - it('captures the cookies from the request', function() { + it('captures the cookies from the request', function () { var request = { protocol: 'http', url: '/foo', @@ -136,7 +136,7 @@ describe('FastBootRequest', function() { expect(fastbootRequest.cookies.test).to.equal('bar'); }); - it('captures the method from the request', function() { + it('captures the method from the request', function () { var request = { protocol: 'http', url: '/foo', @@ -151,7 +151,7 @@ describe('FastBootRequest', function() { expect(fastbootRequest.method).to.equal('GET'); }); - it('captures the body from the request', function() { + it('captures the body from the request', function () { var request = { protocol: 'http', url: '/foo', diff --git a/packages/fastboot/test/fastboot-response-test.js b/packages/fastboot/test/fastboot-response-test.js index 545cf8607..426747a69 100644 --- a/packages/fastboot/test/fastboot-response-test.js +++ b/packages/fastboot/test/fastboot-response-test.js @@ -2,10 +2,10 @@ var expect = require('chai').expect; var FastBootHeaders = require('./../src/fastboot-headers.js'); var FastBootResponse = require('./../src/fastboot-response.js'); -describe('FastBootResponse', function() { +describe('FastBootResponse', function () { var fastBootResponse; - beforeEach(function() { + beforeEach(function () { var mockResponse = { getHeaders() { return { @@ -18,27 +18,27 @@ describe('FastBootResponse', function() { fastBootResponse = new FastBootResponse(mockResponse); }); - describe('headers', function() { - it('should have headers', function() { + describe('headers', function () { + it('should have headers', function () { expect(fastBootResponse).to.have.ownProperty('headers'); }); - it('should be an instance of FastBootHeaders', function() { + it('should be an instance of FastBootHeaders', function () { expect(fastBootResponse.headers).to.be.an.instanceOf(FastBootHeaders); }); - it("should contain the original response's headers", function() { + it("should contain the original response's headers", function () { var header = fastBootResponse.headers.getAll('i-am-a'); expect(header).to.deep.equal(['mock header', 'me too']); }); }); - describe('statusCode', function() { - it('should have a statusCode', function() { + describe('statusCode', function () { + it('should have a statusCode', function () { expect(fastBootResponse).to.have.ownProperty('statusCode'); }); - it('should default to 200', function() { + it('should default to 200', function () { expect(fastBootResponse.statusCode).to.equal(200); }); }); diff --git a/packages/fastboot/test/fastboot-shoebox-test.js b/packages/fastboot/test/fastboot-shoebox-test.js index e6d9afe85..f992a7b5b 100644 --- a/packages/fastboot/test/fastboot-shoebox-test.js +++ b/packages/fastboot/test/fastboot-shoebox-test.js @@ -4,16 +4,16 @@ const expect = require('chai').expect; const fixture = require('./helpers/fixture-path'); const FastBoot = require('./../src/index'); -describe('FastBootShoebox', function() { - it('can render the escaped shoebox HTML', function() { +describe('FastBootShoebox', function () { + it('can render the escaped shoebox HTML', function () { var fastboot = new FastBoot({ distPath: fixture('shoebox'), }); return fastboot .visit('/') - .then(r => r.html()) - .then(html => { + .then((r) => r.html()) + .then((html) => { expect(html).to.match( /'; var boundaryEndTag = ''; - beforeEach(function() { + beforeEach(function () { doc.head.appendChild(doc.createRawHTMLSection(HEAD)); doc.body.appendChild(doc.createRawHTMLSection(BODY)); result._finalize(); }); - it('should return the FastBoot-rendered document body', function() { + it('should return the FastBoot-rendered document body', function () { var domContents = result.domContents(); expect(domContents.head).to.include(HEAD); expect(domContents.body).to.include(BODY); From bff1684ea7795a4a8af96a006c938ce24bccab1e Mon Sep 17 00:00:00 2001 From: Gaurav Munjal Date: Thu, 2 Nov 2023 09:30:08 -0400 Subject: [PATCH 08/11] fix line endings on Windows --- .gitattributes | 1 + packages/fastboot-express-middleware/.eslintrc.js | 8 ++++++++ 2 files changed, 9 insertions(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..af19312d1 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +text=auto \ No newline at end of file diff --git a/packages/fastboot-express-middleware/.eslintrc.js b/packages/fastboot-express-middleware/.eslintrc.js index 0176f70bc..51c59a005 100644 --- a/packages/fastboot-express-middleware/.eslintrc.js +++ b/packages/fastboot-express-middleware/.eslintrc.js @@ -9,6 +9,14 @@ module.exports = { node: true, es6: true, }, + rules: { + "prettier/prettier": [ + "error", + { + endOfLine: "auto", + } + ] + }, overrides: [ { files: ['test/**/*-test.js'], From f78ceec86acfff7769431642ef1992c3e0c977db Mon Sep 17 00:00:00 2001 From: Gaurav Munjal Date: Sun, 12 Nov 2023 04:11:52 -0500 Subject: [PATCH 09/11] directory name in addons does not need scope --- packages/ember-cli-fastboot/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/ember-cli-fastboot/index.js b/packages/ember-cli-fastboot/index.js index bfca4a120..b1cdfb160 100644 --- a/packages/ember-cli-fastboot/index.js +++ b/packages/ember-cli-fastboot/index.js @@ -149,7 +149,7 @@ module.exports = { _processAddon(addon, fastbootTrees) { // walk through each addon and grab its fastboot tree - const currentAddonFastbootPath = path.join(addon.root, '@gaurav9576/fastboot'); + const currentAddonFastbootPath = path.join(addon.root, 'fastboot'); let fastbootTree; if (this.existsSync(currentAddonFastbootPath)) { From f909c1c98181263f62b9b598baf3ed624c0204a4 Mon Sep 17 00:00:00 2001 From: Gaurav Munjal Date: Sun, 12 Nov 2023 04:50:09 -0500 Subject: [PATCH 10/11] workaround for ember-cli-fastboot-testing-app --- package.json | 3 ++- .../package.json | 1 + yarn.lock | 23 +++++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 430eaa749..07547c6e1 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,8 @@ "release-it-yarn-workspaces": "^2.0.0" }, "resolutions": { - "fastboot": "file:packages/fastboot" + "fastboot": "file:packages/fastboot", + "ember-cli-fastboot": "file:packages/ember-cli-fastboot" }, "publishConfig": { "registry": "https://registry.npmjs.org" diff --git a/test-packages/ember-cli-fastboot-testing-app/package.json b/test-packages/ember-cli-fastboot-testing-app/package.json index 9cccfae28..94cdd0550 100644 --- a/test-packages/ember-cli-fastboot-testing-app/package.json +++ b/test-packages/ember-cli-fastboot-testing-app/package.json @@ -30,6 +30,7 @@ "ember-cli-app-version": "^6.0.0", "ember-cli-babel": "^7.20.5", "ember-cli-dependency-checker": "^3.2.0", + "ember-cli-fastboot": "file:packages/ember-cli-fastboot", "@gaurav9576/ember-cli-fastboot": "4.1.1", "ember-cli-fastboot-testing": "^0.5.0", "ember-cli-htmlbars": "^5.1.2", diff --git a/yarn.lock b/yarn.lock index c0911ecd3..3db2eae79 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5438,6 +5438,29 @@ ember-cli-fastboot-testing@^0.5.0: resolve "^1.10.0" whatwg-fetch "^3.0.0" +"ember-cli-fastboot@file:packages/ember-cli-fastboot", "ember-cli-fastboot@file:test-packages/ember-cli-fastboot-testing-app/packages/ember-cli-fastboot": + version "4.1.1" + dependencies: + "@gaurav9576/fastboot" "4.1.1" + "@gaurav9576/fastboot-express-middleware" "4.1.1" + broccoli-concat "^4.2.5" + broccoli-file-creator "^2.1.1" + broccoli-funnel "^3.0.8" + broccoli-merge-trees "^4.2.0" + broccoli-plugin "^4.0.7" + chalk "^4.1.2" + ember-cli-babel "^7.26.10" + ember-cli-lodash-subset "^2.0.1" + ember-cli-preprocess-registry "^3.3.0" + ember-cli-version-checker "^5.1.2" + fastboot-transform "^0.1.3" + fs-extra "^10.0.0" + json-stable-stringify "^1.0.1" + md5-hex "^3.0.1" + node-fetch "^2.6.7" + recast "^0.19.1" + silent-error "^1.1.1" + ember-cli-get-component-path-option@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/ember-cli-get-component-path-option/-/ember-cli-get-component-path-option-1.0.0.tgz#0d7b595559e2f9050abed804f1d8eff1b08bc771" From fed7ad8d8203f43bf4e32a2b2b955091e5679174 Mon Sep 17 00:00:00 2001 From: Gaurav Munjal Date: Sun, 12 Nov 2023 05:28:35 -0500 Subject: [PATCH 11/11] fix lint again --- .../fastboot-express-middleware/src/index.js | 6 +- .../test/helpers/fixture-path.js | 2 +- .../test/helpers/test-http-server.js | 2 +- .../test/middleware-test.js | 48 +++---- packages/fastboot/dev/memory-usage.js | 2 +- packages/fastboot/src/ember-app.js | 8 +- packages/fastboot/src/fastboot-request.js | 2 +- packages/fastboot/src/fastboot-schema.js | 6 +- packages/fastboot/src/index.js | 2 +- packages/fastboot/src/result.js | 18 +-- packages/fastboot/src/sandbox.js | 4 +- .../test/fastboot-dependencies-test.js | 8 +- .../fastboot/test/fastboot-headers-test.js | 30 ++--- packages/fastboot/test/fastboot-info-test.js | 16 +-- .../fastboot/test/fastboot-request-test.js | 28 ++-- .../fastboot/test/fastboot-response-test.js | 18 +-- .../fastboot/test/fastboot-shoebox-test.js | 20 +-- packages/fastboot/test/fastboot-test.js | 126 +++++++++--------- .../fastboot/test/get-package-name-test.js | 4 +- .../fastboot/test/html-entrypoint-test.js | 24 ++-- packages/fastboot/test/queue-test.js | 20 +-- packages/fastboot/test/result-test.js | 94 ++++++------- 22 files changed, 244 insertions(+), 244 deletions(-) diff --git a/packages/fastboot-express-middleware/src/index.js b/packages/fastboot-express-middleware/src/index.js index aa40d82d0..49185d0cd 100644 --- a/packages/fastboot-express-middleware/src/index.js +++ b/packages/fastboot-express-middleware/src/index.js @@ -13,7 +13,7 @@ function fastbootExpressMiddleware(distPath, options) { opts = opts || {}; - let log = opts.log !== false ? _log : function () {}; + let log = opts.log !== false ? _log : function() {}; let fastboot = opts.fastboot; @@ -25,7 +25,7 @@ function fastbootExpressMiddleware(distPath, options) { }); } - return async function (req, res, next) { + return async function(req, res, next) { let path = req.url; try { @@ -53,7 +53,7 @@ function fastbootExpressMiddleware(distPath, options) { } else if (result.error) { res.send(body[0]); } else { - body.forEach((chunk) => res.write(chunk)); + body.forEach(chunk => res.write(chunk)); res.end(); } } catch (error) { diff --git a/packages/fastboot-express-middleware/test/helpers/fixture-path.js b/packages/fastboot-express-middleware/test/helpers/fixture-path.js index 5c392780e..c53a6f6d8 100644 --- a/packages/fastboot-express-middleware/test/helpers/fixture-path.js +++ b/packages/fastboot-express-middleware/test/helpers/fixture-path.js @@ -1,5 +1,5 @@ var path = require('path'); -module.exports = function (fixturePath) { +module.exports = function(fixturePath) { return path.join(__dirname, '../fixtures/', fixturePath); }; diff --git a/packages/fastboot-express-middleware/test/helpers/test-http-server.js b/packages/fastboot-express-middleware/test/helpers/test-http-server.js index 997701346..910331fdb 100644 --- a/packages/fastboot-express-middleware/test/helpers/test-http-server.js +++ b/packages/fastboot-express-middleware/test/helpers/test-http-server.js @@ -35,7 +35,7 @@ class TestHTTPServer { }); } - return new Promise((resolve) => { + return new Promise(resolve => { let port = options.port || 3000; let host = options.host || 'localhost'; diff --git a/packages/fastboot-express-middleware/test/middleware-test.js b/packages/fastboot-express-middleware/test/middleware-test.js index 6a1645bbc..41dd5a01d 100644 --- a/packages/fastboot-express-middleware/test/middleware-test.js +++ b/packages/fastboot-express-middleware/test/middleware-test.js @@ -6,27 +6,27 @@ const fastbootMiddleware = require('./../src/index'); const fixture = require('./helpers/fixture-path'); const TestHTTPServer = require('./helpers/test-http-server'); -describe('FastBoot', function () { +describe('FastBoot', function() { let server; this.timeout(10000); - afterEach(function () { + afterEach(function() { if (server) { server.stop(); server = null; } }); - it('throws an exception if no distPath is provided', function () { - let fn = function () { + it('throws an exception if no distPath is provided', function() { + let fn = function() { fastbootMiddleware(); }; expect(fn).to.throw(/You must instantiate FastBoot with a distPath option/); }); - it('can provide distPath as the first argument', async function () { + it('can provide distPath as the first argument', async function() { let middleware = fastbootMiddleware(fixture('basic-app')); server = new TestHTTPServer(middleware); await server.start(); @@ -35,7 +35,7 @@ describe('FastBoot', function () { expect(html).to.match(/Welcome to Ember/); }); - it('can provide distPath as an option', async function () { + it('can provide distPath as an option', async function() { let middleware = fastbootMiddleware({ distPath: fixture('basic-app'), }); @@ -46,7 +46,7 @@ describe('FastBoot', function () { expect(html).to.match(/Welcome to Ember/); }); - it('can be provided with a custom FastBoot instance', async function () { + it('can be provided with a custom FastBoot instance', async function() { let fastboot = new FastBoot({ distPath: fixture('basic-app'), }); @@ -62,7 +62,7 @@ describe('FastBoot', function () { expect(html).to.match(/Welcome to Ember/); }); - it('can reload the FastBoot instance', async function () { + it('can reload the FastBoot instance', async function() { let fastboot = new FastBoot({ distPath: fixture('basic-app'), }); @@ -85,7 +85,7 @@ describe('FastBoot', function () { expect(html).to.match(/Goodbye from Ember/); }); - it('it appends multivalue headers', async function () { + it('it appends multivalue headers', async function() { let middleware = fastbootMiddleware(fixture('multivalue-headers')); server = new TestHTTPServer(middleware); await server.start(); @@ -94,7 +94,7 @@ describe('FastBoot', function () { expect(headers['x-fastboot']).to.eq('a, b, c'); }); - it('can pass metadata info to the app', async function () { + it('can pass metadata info to the app', async function() { let middleware = fastbootMiddleware({ distPath: fixture('app-with-metadata'), visitOptions: { @@ -112,7 +112,7 @@ describe('FastBoot', function () { // TODO: // https://github.com/ember-fastboot/ember-cli-fastboot/pull/840#issuecomment-894329631 // eslint-disable-next-line mocha/no-skipped-tests - xit('works without metadata passed', async function () { + xit('works without metadata passed', async function() { let middleware = fastbootMiddleware({ distPath: fixture('app-with-metadata'), }); @@ -124,10 +124,10 @@ describe('FastBoot', function () { }); /* eslint-disable mocha/no-setup-in-describe */ - [true, false].forEach((chunkedResponse) => { - describe(`when chunked response is ${chunkedResponse ? 'enabled' : 'disabled'}`, function () { + [true, false].forEach(chunkedResponse => { + describe(`when chunked response is ${chunkedResponse ? 'enabled' : 'disabled'}`, function() { if (chunkedResponse) { - it('responds with a chunked response', async function () { + it('responds with a chunked response', async function() { let middleware = fastbootMiddleware({ distPath: fixture('basic-app'), chunkedResponse, @@ -141,7 +141,7 @@ describe('FastBoot', function () { }); } - it("returns 404 when navigating to a URL that doesn't exist", async function () { + it("returns 404 when navigating to a URL that doesn't exist", async function() { let middleware = fastbootMiddleware({ distPath: fixture('basic-app'), chunkedResponse, @@ -156,7 +156,7 @@ describe('FastBoot', function () { } }); - it('returns a 500 error if an error occurs', async function () { + it('returns a 500 error if an error occurs', async function() { let middleware = fastbootMiddleware({ distPath: fixture('rejected-promise'), chunkedResponse, @@ -171,8 +171,8 @@ describe('FastBoot', function () { } }); - describe('when resilient mode is enabled', function () { - it('renders no FastBoot markup', async function () { + describe('when resilient mode is enabled', function() { + it('renders no FastBoot markup', async function() { let middleware = fastbootMiddleware({ distPath: fixture('rejected-promise'), resilient: true, @@ -185,7 +185,7 @@ describe('FastBoot', function () { expect(html).to.not.match(/error/); }); - it('propagates to error handling middleware', async function () { + it('propagates to error handling middleware', async function() { let middleware = fastbootMiddleware({ distPath: fixture('rejected-promise'), resilient: true, @@ -202,7 +202,7 @@ describe('FastBoot', function () { expect(body).to.match(/hello world/); }); - it('is does not propagate errors when and there is no error handling middleware', async function () { + it('is does not propagate errors when and there is no error handling middleware', async function() { let middleware = fastbootMiddleware({ distPath: fixture('rejected-promise'), resilient: true, @@ -220,7 +220,7 @@ describe('FastBoot', function () { expect(body).to.match(/hello world/); }); - it('allows post-fastboot middleware to recover the response when it fails', async function () { + it('allows post-fastboot middleware to recover the response when it fails', async function() { let middleware = fastbootMiddleware({ distPath: fixture('rejected-promise'), resilient: true, @@ -238,8 +238,8 @@ describe('FastBoot', function () { }); }); - describe('when resilient mode is disabled', function () { - it('propagates to error handling middleware', async function () { + describe('when resilient mode is disabled', function() { + it('propagates to error handling middleware', async function() { let middleware = fastbootMiddleware({ distPath: fixture('rejected-promise'), resilient: false, @@ -258,7 +258,7 @@ describe('FastBoot', function () { } }); - it('allows post-fastboot middleware to recover the response when it fails', async function () { + it('allows post-fastboot middleware to recover the response when it fails', async function() { let middleware = fastbootMiddleware({ distPath: fixture('rejected-promise'), resilient: false, diff --git a/packages/fastboot/dev/memory-usage.js b/packages/fastboot/dev/memory-usage.js index c9d0bcf26..0cdd88b18 100644 --- a/packages/fastboot/dev/memory-usage.js +++ b/packages/fastboot/dev/memory-usage.js @@ -28,7 +28,7 @@ session.connect(); let file; // uses whatever the "current" file is -session.on('HeapProfiler.addHeapSnapshotChunk', (m) => { +session.on('HeapProfiler.addHeapSnapshotChunk', m => { fs.writeSync(file, m.params.chunk); }); diff --git a/packages/fastboot/src/ember-app.js b/packages/fastboot/src/ember-app.js index 342c29037..5436bc85d 100644 --- a/packages/fastboot/src/ember-app.js +++ b/packages/fastboot/src/ember-app.js @@ -165,7 +165,7 @@ class EmberApp { debug('files evaluated'); // Retrieve the application factory from within the sandbox - let AppFactory = sandbox.run(function (ctx) { + let AppFactory = sandbox.run(function(ctx) { return ctx.require('~fastboot/app-factory'); }); @@ -316,7 +316,7 @@ class EmberApp { if (destroyAppInstanceInMs > 0) { // start a timer to destroy the appInstance forcefully in the given ms. // This is a failure mechanism so that node process doesn't get wedged if the `visit` never completes. - destroyAppInstanceTimer = setTimeout(function () { + destroyAppInstanceTimer = setTimeout(function() { if (result._destroy()) { result.error = new Error( 'App instance was forcefully destroyed in ' + destroyAppInstanceInMs + 'ms' @@ -418,7 +418,7 @@ const JSON_ESCAPE = { const JSON_ESCAPE_REGEXP = /[\u2028\u2029&><]/g; function escapeJSONString(string) { - return string.replace(JSON_ESCAPE_REGEXP, function (match) { + return string.replace(JSON_ESCAPE_REGEXP, function(match) { return JSON_ESCAPE[match]; }); } @@ -432,7 +432,7 @@ function registerFastBootInfo(info, instance) { } function buildScripts(filePaths) { - return filePaths.filter(Boolean).map((filePath) => { + return filePaths.filter(Boolean).map(filePath => { let source = fs.readFileSync(filePath, { encoding: 'utf8' }); return new vm.Script(source, { filename: filePath }); diff --git a/packages/fastboot/src/fastboot-request.js b/packages/fastboot/src/fastboot-request.js index d6cec8c61..ed7a1c70f 100644 --- a/packages/fastboot/src/fastboot-request.js +++ b/packages/fastboot/src/fastboot-request.js @@ -23,7 +23,7 @@ class FastBootRequest { } var host = this.headers.get('host'); - var matchFound = this.hostWhitelist.some(function (entry) { + var matchFound = this.hostWhitelist.some(function(entry) { if (entry[0] === '/' && entry.slice(-1) === '/') { var regexp = new RegExp(entry.slice(1, -1)); return regexp.test(host); diff --git a/packages/fastboot/src/fastboot-schema.js b/packages/fastboot/src/fastboot-schema.js index 70b9cc1cd..d08c7b747 100644 --- a/packages/fastboot/src/fastboot-schema.js +++ b/packages/fastboot/src/fastboot-schema.js @@ -127,7 +127,7 @@ function loadManifest(distPath, fastbootConfig, schemaVersion) { } } - let scripts = manifest.vendorFiles.concat(manifest.appFiles).map(function (file) { + let scripts = manifest.vendorFiles.concat(manifest.appFiles).map(function(file) { return path.join(distPath, file); }); let html = fs.readFileSync(path.join(distPath, manifest.htmlFile), 'utf8'); @@ -149,7 +149,7 @@ function loadManifest(distPath, fastbootConfig, schemaVersion) { * @param {boolean} isLegacyWhiteList flag to enable legacy behavior */ function buildWhitelistedRequire(whitelist, distPath, isLegacyWhitelist) { - whitelist.forEach(function (whitelistedModule) { + whitelist.forEach(function(whitelistedModule) { debug('module whitelisted; module=%s', whitelistedModule); if (isLegacyWhitelist) { @@ -161,7 +161,7 @@ function buildWhitelistedRequire(whitelist, distPath, isLegacyWhitelist) { } }); - return function (moduleName) { + return function(moduleName) { let packageName = getPackageName(moduleName); let isWhitelisted = whitelist.indexOf(packageName) > -1; diff --git a/packages/fastboot/src/index.js b/packages/fastboot/src/index.js index d7172f2d2..4d9f795d4 100644 --- a/packages/fastboot/src/index.js +++ b/packages/fastboot/src/index.js @@ -55,7 +55,7 @@ class FastBoot { console.warn( '[DEPRECATION] Instantiating `fastboot` with a `sandboxGlobals` option has been deprecated. Please migrate to specifying `buildSandboxGlobals` instead.' ); - buildSandboxGlobals = (globals) => Object.assign({}, globals, options.sandboxGlobals); + buildSandboxGlobals = globals => Object.assign({}, globals, options.sandboxGlobals); } this.buildSandboxGlobals = buildSandboxGlobals; diff --git a/packages/fastboot/src/result.js b/packages/fastboot/src/result.js index dd4f23acb..1c3426b30 100644 --- a/packages/fastboot/src/result.js +++ b/packages/fastboot/src/result.js @@ -80,7 +80,7 @@ class Result { this._body, this._bodyAttributes, this._bodyClass - ).then((html) => { + ).then(html => { let docParts = html.match(HTML_HEAD_REGEX); if (!docParts || docParts.length === 1) { return [html]; @@ -97,7 +97,7 @@ class Result { let [plainBody, ...shoeboxes] = body.split(SHOEBOX_TAG_PATTERN); let chunks = [head, plainBody].concat( - shoeboxes.map((shoebox) => `${SHOEBOX_TAG_PATTERN}${shoebox}`) + shoeboxes.map(shoebox => `${SHOEBOX_TAG_PATTERN}${shoebox}`) ); return chunks; @@ -203,10 +203,10 @@ function extractExtraAttributes(element) { let klass; let attributes; if (element.attributes.length > 0) { - let elementClass = element.attributes.find((attr) => attr.name === 'class'); + let elementClass = element.attributes.find(attr => attr.name === 'class'); if (elementClass) { klass = elementClass; - let otherAttrs = element.attributes.filter((attr) => attr.name !== 'class'); + let otherAttrs = element.attributes.filter(attr => attr.name !== 'class'); if (otherAttrs.length > 0) { attributes = HTMLSerializer.attributes(otherAttrs); } else { @@ -229,9 +229,9 @@ function missingTag(tag) { } function addClass(html, regex, newClass) { - return html.replace(regex, function (_, tag, attributes) { + return html.replace(regex, function(_, tag, attributes) { if (/class="([^"]*)"/i.test(attributes)) { - attributes = attributes.replace(/class="([^"]*)"/i, function (_, klass) { + attributes = attributes.replace(/class="([^"]*)"/i, function(_, klass) { return `class="${klass} ${newClass}"`; }); } else { @@ -256,7 +256,7 @@ async function insertIntoIndexHTML( let isBodyReplaced = false; let isHeadReplaced = false; - html = html.replace(//g, function (match, tag) { + html = html.replace(//g, function(match, tag) { if (tag === 'HEAD' && head && !isHeadReplaced) { isHeadReplaced = true; return head; @@ -271,7 +271,7 @@ async function insertIntoIndexHTML( html = addClass(html, /<(html)(.*)>/i, htmlClass.value); } if (htmlAttributes) { - html = html.replace(/]*/i, function (match) { + html = html.replace(/]*/i, function(match) { return match + ' ' + htmlAttributes; }); } @@ -280,7 +280,7 @@ async function insertIntoIndexHTML( html = addClass(html, /<(body)(.*)>/i, bodyClass.value); } if (bodyAttributes) { - html = html.replace(/]*/i, function (match) { + html = html.replace(/]*/i, function(match) { return match + ' ' + bodyAttributes; }); } diff --git a/packages/fastboot/src/sandbox.js b/packages/fastboot/src/sandbox.js index 3aa2e4408..e462a0693 100644 --- a/packages/fastboot/src/sandbox.js +++ b/packages/fastboot/src/sandbox.js @@ -46,10 +46,10 @@ module.exports = class Sandbox { buildWrappedConsole() { let wrappedConsole = Object.create(console); - wrappedConsole.error = function (...args) { + wrappedConsole.error = function(...args) { console.error.apply( console, - args.map(function (a) { + args.map(function(a) { return typeof a === 'string' ? chalk.red(a) : a; }) ); diff --git a/packages/fastboot/test/fastboot-dependencies-test.js b/packages/fastboot/test/fastboot-dependencies-test.js index beb48faa6..3b8cb2b2f 100644 --- a/packages/fastboot/test/fastboot-dependencies-test.js +++ b/packages/fastboot/test/fastboot-dependencies-test.js @@ -4,16 +4,16 @@ const expect = require('chai').expect; const fixture = require('./helpers/fixture-path'); const FastBoot = require('./../src/index'); -describe('FastBoot with dependencies', function () { - it('it works with dependencies', function () { +describe('FastBoot with dependencies', function() { + it('it works with dependencies', function() { var fastboot = new FastBoot({ distPath: fixture('app-with-dependencies'), }); return fastboot .visit('/') - .then((r) => r.html()) - .then((html) => { + .then(r => r.html()) + .then(html => { expect(html).to.match(/https:\/\/emberjs.com/); expect(html).to.match(/FOO/); expect(html).to.match(/BAR/); diff --git a/packages/fastboot/test/fastboot-headers-test.js b/packages/fastboot/test/fastboot-headers-test.js index b7714a7a8..1d65353fa 100644 --- a/packages/fastboot/test/fastboot-headers-test.js +++ b/packages/fastboot/test/fastboot-headers-test.js @@ -3,8 +3,8 @@ var expect = require('chai').expect; var FastBootHeaders = require('./../src/fastboot-headers.js'); -describe('FastBootHeaders', function () { - it('lower normalizes the headers to lowercase', function () { +describe('FastBootHeaders', function() { + it('lower normalizes the headers to lowercase', function() { var headers = { 'X-Test-Header': 'value1, value2', }; @@ -13,7 +13,7 @@ describe('FastBootHeaders', function () { expect(headers.getAll('x-test-header')).to.deep.equal(['value1, value2']); }); - it('returns an array from getAll when header value is string', function () { + it('returns an array from getAll when header value is string', function() { var headers = { 'x-test-header': 'value1, value2', }; @@ -22,7 +22,7 @@ describe('FastBootHeaders', function () { expect(headers.getAll('x-test-header')).to.deep.equal(['value1, value2']); }); - it('returns an array of header values from getAll, regardless of header name casing', function () { + it('returns an array of header values from getAll, regardless of header name casing', function() { var headers = { 'x-test-header': ['value1', 'value2'], }; @@ -32,7 +32,7 @@ describe('FastBootHeaders', function () { expect(headers.getAll('x-test-header')).to.deep.equal(['value1', 'value2']); }); - it('returns an emtpy array when a header is not present', function () { + it('returns an emtpy array when a header is not present', function() { var headers = { 'x-test-header': ['value1', 'value2'], }; @@ -42,7 +42,7 @@ describe('FastBootHeaders', function () { expect(headers.getAll('host')).to.deep.equal([]); }); - it('returns the first value when using get, regardless of case', function () { + it('returns the first value when using get, regardless of case', function() { var headers = { 'x-test-header': ['value1', 'value2'], }; @@ -52,7 +52,7 @@ describe('FastBootHeaders', function () { expect(headers.get('x-test-header')).to.equal('value1'); }); - it('returns null when using get when a header is not present', function () { + it('returns null when using get when a header is not present', function() { var headers = { 'x-test-header': ['value1', 'value2'], }; @@ -62,7 +62,7 @@ describe('FastBootHeaders', function () { expect(headers.get('host')).to.be.null; }); - it('returns whether or not a header is present via has, regardless of casing', function () { + it('returns whether or not a header is present via has, regardless of casing', function() { var headers = { 'x-test-header': ['value1', 'value2'], }; @@ -74,7 +74,7 @@ describe('FastBootHeaders', function () { expect(headers.has('host')).to.be.false; }); - it('appends entries onto a header, regardless of casing', function () { + it('appends entries onto a header, regardless of casing', function() { var headers = new FastBootHeaders(); expect(headers.has('x-foo')).to.be.false; @@ -87,7 +87,7 @@ describe('FastBootHeaders', function () { expect(headers.getAll('x-foo')).to.deep.equal(['bar', 'baz']); }); - it('deletes entries onto a header, regardless of casing', function () { + it('deletes entries onto a header, regardless of casing', function() { var headers = new FastBootHeaders(); headers.append('X-Foo', 'bar'); @@ -97,7 +97,7 @@ describe('FastBootHeaders', function () { expect(headers.has('x-foo')).to.be.false; }); - it('returns an iterator for the header/value pairs when calling entries', function () { + it('returns an iterator for the header/value pairs when calling entries', function() { var headers = new FastBootHeaders(); headers.append('X-Foo', 'foo'); @@ -111,7 +111,7 @@ describe('FastBootHeaders', function () { expect(entriesIterator.next()).to.deep.equal({ value: undefined, done: true }); }); - it('returns an iterator for keys containing all the keys', function () { + it('returns an iterator for keys containing all the keys', function() { var headers = new FastBootHeaders(); headers.append('X-Foo', 'foo'); @@ -125,7 +125,7 @@ describe('FastBootHeaders', function () { expect(entriesIterator.next()).to.deep.equal({ value: undefined, done: true }); }); - it('sets a header, overwriting existing values, regardless of casing', function () { + it('sets a header, overwriting existing values, regardless of casing', function() { var headers = new FastBootHeaders(); expect(headers.getAll('x-foo')).to.deep.equal([]); @@ -141,7 +141,7 @@ describe('FastBootHeaders', function () { expect(headers.getAll('x-bar')).to.deep.equal(['baz']); }); - it('returns an iterator for values containing all the values', function () { + it('returns an iterator for values containing all the values', function() { var headers = new FastBootHeaders(); headers.append('X-Foo', 'foo'); @@ -155,7 +155,7 @@ describe('FastBootHeaders', function () { expect(entriesIterator.next()).to.deep.equal({ value: undefined, done: true }); }); - it('when mistakenly used `Ember.get` with an unknown property, it attempts to get the header with that name and warns the user to use `headers.get` instead', function () { + it('when mistakenly used `Ember.get` with an unknown property, it attempts to get the header with that name and warns the user to use `headers.get` instead', function() { var headers = { 'x-test-header': ['value1', 'value2'], }; diff --git a/packages/fastboot/test/fastboot-info-test.js b/packages/fastboot/test/fastboot-info-test.js index 1cf24afee..67f91df94 100644 --- a/packages/fastboot/test/fastboot-info-test.js +++ b/packages/fastboot/test/fastboot-info-test.js @@ -4,7 +4,7 @@ var FastBootResponse = require('./../src/fastboot-response.js'); var FastBootRequest = require('./../src/fastboot-request.js'); function delayFor(ms) { - let promise = new Promise((resolve) => { + let promise = new Promise(resolve => { setTimeout(() => { resolve(); }, ms); @@ -13,7 +13,7 @@ function delayFor(ms) { return promise; } -describe('FastBootInfo', function () { +describe('FastBootInfo', function() { var response; var request; var fastbootInfo; @@ -22,13 +22,13 @@ describe('FastBootInfo', function () { baz: 'apple', }; - beforeEach(function () { + beforeEach(function() { response = {}; request = { cookie: '', protocol: 'http', headers: {}, - get: function () { + get: function() { return this.cookie; }, }; @@ -36,19 +36,19 @@ describe('FastBootInfo', function () { fastbootInfo = new FastBootInfo(request, response, { metadata }); }); - it('has a FastBootRequest', function () { + it('has a FastBootRequest', function() { expect(fastbootInfo.request).to.be.an.instanceOf(FastBootRequest); }); - it('has a FastBootResponse', function () { + it('has a FastBootResponse', function() { expect(fastbootInfo.response).to.be.an.instanceOf(FastBootResponse); }); - it('has metadata', function () { + it('has metadata', function() { expect(fastbootInfo.metadata).to.deep.equal(metadata); }); - it('can use deferRendering', async function () { + it('can use deferRendering', async function() { let steps = []; steps.push('deferRendering called'); diff --git a/packages/fastboot/test/fastboot-request-test.js b/packages/fastboot/test/fastboot-request-test.js index 052649119..4e2b096e9 100644 --- a/packages/fastboot/test/fastboot-request-test.js +++ b/packages/fastboot/test/fastboot-request-test.js @@ -1,8 +1,8 @@ var expect = require('chai').expect; var FastBootRequest = require('./../src/fastboot-request.js'); -describe('FastBootRequest', function () { - it('throws an exception if no hostWhitelist is provided', function () { +describe('FastBootRequest', function() { + it('throws an exception if no hostWhitelist is provided', function() { var request = { protocol: 'http', headers: { @@ -11,13 +11,13 @@ describe('FastBootRequest', function () { }; var fastbootRequest = new FastBootRequest(request); - var fn = function () { + var fn = function() { fastbootRequest.host(); }; expect(fn).to.throw(/You must provide a hostWhitelist to retrieve the host/); }); - it('throws an exception if the host header does not match an entry in the hostWhitelist', function () { + it('throws an exception if the host header does not match an entry in the hostWhitelist', function() { var request = { protocol: 'http', headers: { @@ -28,7 +28,7 @@ describe('FastBootRequest', function () { var hostWhitelist = ['example.com', 'localhost:4200']; var fastbootRequest = new FastBootRequest(request, hostWhitelist); - var fn = function () { + var fn = function() { fastbootRequest.host(); }; expect(fn).to.throw( @@ -36,7 +36,7 @@ describe('FastBootRequest', function () { ); }); - it('returns the host if it is in the hostWhitelist', function () { + it('returns the host if it is in the hostWhitelist', function() { var request = { protocol: 'http', headers: { @@ -51,7 +51,7 @@ describe('FastBootRequest', function () { expect(host).to.equal('localhost:4200'); }); - it('returns the host if it matches a regex in the hostWhitelist', function () { + it('returns the host if it matches a regex in the hostWhitelist', function() { var request = { protocol: 'http', headers: { @@ -66,7 +66,7 @@ describe('FastBootRequest', function () { expect(host).to.equal('localhost:4200'); }); - it('captures the query params from the request', function () { + it('captures the query params from the request', function() { var request = { protocol: 'http', query: { @@ -81,7 +81,7 @@ describe('FastBootRequest', function () { expect(fastbootRequest.queryParams.foo).to.equal('bar'); }); - it('captures the path from the request', function () { + it('captures the path from the request', function() { var request = { protocol: 'http', url: '/foo', @@ -94,7 +94,7 @@ describe('FastBootRequest', function () { expect(fastbootRequest.path).to.equal('/foo'); }); - it('captures the headers from the request', function () { + it('captures the headers from the request', function() { var request = { protocol: 'http', url: '/foo', @@ -108,7 +108,7 @@ describe('FastBootRequest', function () { expect(fastbootRequest.headers.get('Host')).to.equal('localhost:4200'); }); - it('captures the protocol from the request', function () { + it('captures the protocol from the request', function() { var request = { protocol: 'http', url: '/foo', @@ -122,7 +122,7 @@ describe('FastBootRequest', function () { expect(fastbootRequest.protocol).to.equal('http:'); }); - it('captures the cookies from the request', function () { + it('captures the cookies from the request', function() { var request = { protocol: 'http', url: '/foo', @@ -136,7 +136,7 @@ describe('FastBootRequest', function () { expect(fastbootRequest.cookies.test).to.equal('bar'); }); - it('captures the method from the request', function () { + it('captures the method from the request', function() { var request = { protocol: 'http', url: '/foo', @@ -151,7 +151,7 @@ describe('FastBootRequest', function () { expect(fastbootRequest.method).to.equal('GET'); }); - it('captures the body from the request', function () { + it('captures the body from the request', function() { var request = { protocol: 'http', url: '/foo', diff --git a/packages/fastboot/test/fastboot-response-test.js b/packages/fastboot/test/fastboot-response-test.js index 426747a69..545cf8607 100644 --- a/packages/fastboot/test/fastboot-response-test.js +++ b/packages/fastboot/test/fastboot-response-test.js @@ -2,10 +2,10 @@ var expect = require('chai').expect; var FastBootHeaders = require('./../src/fastboot-headers.js'); var FastBootResponse = require('./../src/fastboot-response.js'); -describe('FastBootResponse', function () { +describe('FastBootResponse', function() { var fastBootResponse; - beforeEach(function () { + beforeEach(function() { var mockResponse = { getHeaders() { return { @@ -18,27 +18,27 @@ describe('FastBootResponse', function () { fastBootResponse = new FastBootResponse(mockResponse); }); - describe('headers', function () { - it('should have headers', function () { + describe('headers', function() { + it('should have headers', function() { expect(fastBootResponse).to.have.ownProperty('headers'); }); - it('should be an instance of FastBootHeaders', function () { + it('should be an instance of FastBootHeaders', function() { expect(fastBootResponse.headers).to.be.an.instanceOf(FastBootHeaders); }); - it("should contain the original response's headers", function () { + it("should contain the original response's headers", function() { var header = fastBootResponse.headers.getAll('i-am-a'); expect(header).to.deep.equal(['mock header', 'me too']); }); }); - describe('statusCode', function () { - it('should have a statusCode', function () { + describe('statusCode', function() { + it('should have a statusCode', function() { expect(fastBootResponse).to.have.ownProperty('statusCode'); }); - it('should default to 200', function () { + it('should default to 200', function() { expect(fastBootResponse.statusCode).to.equal(200); }); }); diff --git a/packages/fastboot/test/fastboot-shoebox-test.js b/packages/fastboot/test/fastboot-shoebox-test.js index f992a7b5b..e6d9afe85 100644 --- a/packages/fastboot/test/fastboot-shoebox-test.js +++ b/packages/fastboot/test/fastboot-shoebox-test.js @@ -4,16 +4,16 @@ const expect = require('chai').expect; const fixture = require('./helpers/fixture-path'); const FastBoot = require('./../src/index'); -describe('FastBootShoebox', function () { - it('can render the escaped shoebox HTML', function () { +describe('FastBootShoebox', function() { + it('can render the escaped shoebox HTML', function() { var fastboot = new FastBoot({ distPath: fixture('shoebox'), }); return fastboot .visit('/') - .then((r) => r.html()) - .then((html) => { + .then(r => r.html()) + .then(html => { expect(html).to.match( /'; var boundaryEndTag = ''; - beforeEach(function () { + beforeEach(function() { doc.head.appendChild(doc.createRawHTMLSection(HEAD)); doc.body.appendChild(doc.createRawHTMLSection(BODY)); result._finalize(); }); - it('should return the FastBoot-rendered document body', function () { + it('should return the FastBoot-rendered document body', function() { var domContents = result.domContents(); expect(domContents.head).to.include(HEAD); expect(domContents.body).to.include(BODY);