Skip to content

Commit

Permalink
Remove ember-fetch add-on
Browse files Browse the repository at this point in the history
  • Loading branch information
bobisjan authored and mansona committed May 25, 2023
1 parent a5bfdfd commit 11ca6b0
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 246 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ function initialize(instance) {
}

export default {
name: 'fastboot:fetch', // `ember-fetch` addon registers as `fetch`
initialize,
};
10 changes: 8 additions & 2 deletions packages/ember-cli-fastboot/test/request-details-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,14 @@ function injectMiddlewareAddon(app) {
pkg.devDependencies['body-parser'] =
process.env.npm_package_devDependencies_body_parser;
pkg.dependencies = pkg.dependencies || {};
pkg.dependencies['fastboot'] = `file:${path.resolve(__dirname, '../../fastboot')}`
pkg.dependencies['fastboot-express-middleware'] = `file:${path.resolve(__dirname, '../../fastboot-express-middleware')}`
pkg.dependencies['fastboot'] = `file:${path.resolve(
__dirname,
'../../fastboot'
)}`;
pkg.dependencies['fastboot-express-middleware'] = `file:${path.resolve(
__dirname,
'../../fastboot-express-middleware'
)}`;
pkg['ember-addon'] = {
paths: ['lib/post-middleware'],
};
Expand Down
1 change: 0 additions & 1 deletion test-packages/basic-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
"ember-cli-uglify": "^3.0.0",
"ember-data": "~3.19.0",
"ember-export-application-global": "^2.0.1",
"ember-fetch": "^8.0.1",
"ember-load-initializers": "^2.1.1",
"ember-maybe-import-regenerator": "^0.1.6",
"ember-qunit": "^4.6.0",
Expand Down
137 changes: 56 additions & 81 deletions test-packages/basic-app/test/package-json-test.js
Original file line number Diff line number Diff line change
@@ -1,107 +1,87 @@
"use strict";
'use strict';

const chai = require("chai");
const chai = require('chai');
const expect = chai.expect;
const fs = require("fs-extra");
const execa = require("execa");
const fs = require('fs-extra');
const execa = require('execa');

chai.use(require("chai-fs"));
chai.use(require('chai-fs'));

describe("generating package.json", function () {
describe('generating package.json', function() {
this.timeout(300000);

describe("with FastBoot builds", function () {
before(async function () {
await execa("yarn", ["build"]);
describe('with FastBoot builds', function() {
before(async function() {
await execa('yarn', ['build']);
});

it("builds a package.json", async function () {
expect("dist/assets/basic-app.js").to.be.a.file();
expect("dist/package.json").to.be.a.file();
it('builds a package.json', async function() {
expect('dist/assets/basic-app.js').to.be.a.file();
expect('dist/package.json').to.be.a.file();
});

it("merges FastBoot dependencies from multiple addons", function () {
let pkg = fs.readJSONSync("dist/package.json");
it('merges FastBoot dependencies from multiple addons', function() {
let pkg = fs.readJSONSync('dist/package.json');

expect(pkg.dependencies).to.deep.equal({
"abortcontroller-polyfill": "^1.4.0",
foo: "1.0.0",
bar: "^0.1.2",
baz: "0.0.0",
"node-fetch": "^2.6.0",
rsvp: "^4.8.5",
foo: '1.0.0',
bar: '^0.1.2',
baz: '0.0.0',
rsvp: '^4.8.5',
});
});

it("contains a schema version", function () {
let pkg = fs.readJSONSync("dist/package.json");
it('contains a schema version', function() {
let pkg = fs.readJSONSync('dist/package.json');

expect(pkg.fastboot.schemaVersion).to.deep.equal(3);
});

it("contains a whitelist of allowed module names", function () {
let pkg = fs.readJSONSync("dist/package.json");

expect(pkg.fastboot.moduleWhitelist).to.deep.equal([
"node-fetch",
"abortcontroller-polyfill",
"abortcontroller-polyfill/dist/cjs-ponyfill",
"path",
"foo",
"bar",
"baz",
"rsvp",
]);
it('contains a whitelist of allowed module names', function() {
let pkg = fs.readJSONSync('dist/package.json');

expect(pkg.fastboot.moduleWhitelist).to.deep.equal(['path', 'foo', 'bar', 'baz', 'rsvp']);
});

it("contains a manifest of FastBoot assets", function () {
let pkg = fs.readJSONSync("dist/package.json");
it('contains a manifest of FastBoot assets', function() {
let pkg = fs.readJSONSync('dist/package.json');

expect(pkg.fastboot.manifest).to.deep.equal({
appFiles: [
"assets/basic-app.js",
"assets/basic-app-fastboot.js",
"example-addon/bar.js",
],
htmlFile: "index.html",
vendorFiles: [
"example-addon/foo.js",
"assets/vendor.js",
"assets/auto-import-fastboot.js",
"ember-fetch/fetch-fastboot.js",
],
appFiles: ['assets/basic-app.js', 'assets/basic-app-fastboot.js', 'example-addon/bar.js'],
htmlFile: 'index.html',
vendorFiles: ['example-addon/foo.js', 'assets/vendor.js', 'assets/auto-import-fastboot.js'],
});
});

it("contains a list of whitelisted hosts from environment.js", function () {
let pkg = fs.readJSONSync("dist/package.json");
it('contains a list of whitelisted hosts from environment.js', function() {
let pkg = fs.readJSONSync('dist/package.json');

expect(pkg.fastboot.hostWhitelist).to.deep.equal([
"example.com",
"subdomain.example.com",
"/localhost:\\d+/",
'example.com',
'subdomain.example.com',
'/localhost:\\d+/',
]);
});

it("contains app name", function () {
let pkg = fs.readJSONSync("dist/package.json");
it('contains app name', function() {
let pkg = fs.readJSONSync('dist/package.json');

expect(pkg.fastboot.appName).to.equal("basic-app");
expect(pkg.fastboot.appName).to.equal('basic-app');
});

it("contains the application config", function () {
let pkg = fs.readJSONSync("dist/package.json");
it('contains the application config', function() {
let pkg = fs.readJSONSync('dist/package.json');

let config = pkg.fastboot.config["basic-app"];
let config = pkg.fastboot.config['basic-app'];

expect(config.APP.version).to.be;

delete config.APP.version;
expect(config).to.deep.equal({
modulePrefix: "basic-app",
environment: "development",
rootURL: "/",
locationType: "auto",
modulePrefix: 'basic-app',
environment: 'development',
rootURL: '/',
locationType: 'auto',
EmberENV: {
EXTEND_PROTOTYPES: {
Date: false,
Expand All @@ -113,45 +93,40 @@ describe("generating package.json", function () {
_TEMPLATE_ONLY_GLIMMER_COMPONENTS: true,
},
APP: {
name: "basic-app",
name: 'basic-app',
autoboot: false,
},
fastboot: {
hostWhitelist: [
"example.com",
"subdomain.example.com",
"/localhost:\\d+/",
],
hostWhitelist: ['example.com', 'subdomain.example.com', '/localhost:\\d+/'],
},
exportApplicationGlobal: true,
});
});

it("contains additional config from example-addon", function () {
let pkg = fs.readJSONSync("dist/package.json");
it('contains additional config from example-addon', function() {
let pkg = fs.readJSONSync('dist/package.json');

expect(pkg.fastboot.config["foo"]).to.equal("bar");
expect(pkg.fastboot.config['foo']).to.equal('bar');
});

});

describe("with production FastBoot builds", function () {
before(async function () {
await execa("yarn", ["build", "--environment=production"]);
describe('with production FastBoot builds', function() {
before(async function() {
await execa('yarn', ['build', '--environment=production']);
});

it("contains a manifest of FastBoot assets", function () {
let pkg = fs.readJSONSync("dist/package.json");
it('contains a manifest of FastBoot assets', function() {
let pkg = fs.readJSONSync('dist/package.json');

let manifest = pkg.fastboot.manifest;

manifest.appFiles.forEach((file) => {
manifest.appFiles.forEach(file => {
expect(`dist/${file}`).to.be.a.file();
});

expect(`dist/${manifest.htmlFile}`).to.be.a.file();

manifest.vendorFiles.forEach((file) => {
manifest.vendorFiles.forEach(file => {
expect(`dist/${file}`).to.be.a.file();
});
});
Expand Down
1 change: 0 additions & 1 deletion test-packages/custom-fastboot-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
"ember-cli-uglify": "^3.0.0",
"ember-data": "~3.19.0",
"ember-export-application-global": "^2.0.1",
"ember-fetch": "^8.0.1",
"ember-load-initializers": "^2.1.1",
"ember-maybe-import-regenerator": "^0.1.6",
"ember-qunit": "^4.6.0",
Expand Down
1 change: 0 additions & 1 deletion test-packages/custom-sandbox-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
"ember-cli-uglify": "^3.0.0",
"ember-data": "~3.19.0",
"ember-export-application-global": "^2.0.1",
"ember-fetch": "^8.0.1",
"ember-load-initializers": "^2.1.1",
"ember-maybe-import-regenerator": "^0.1.6",
"ember-qunit": "^4.6.0",
Expand Down
1 change: 0 additions & 1 deletion test-packages/ember-cli-fastboot-testing-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
"ember-cli-uglify": "^3.0.0",
"ember-data": "~3.19.0",
"ember-export-application-global": "^2.0.1",
"ember-fetch": "^8.0.1",
"ember-load-initializers": "^2.1.1",
"ember-maybe-import-regenerator": "^0.1.6",
"ember-qunit": "^4.6.0",
Expand Down
1 change: 0 additions & 1 deletion test-packages/hot-swap-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
"ember-cli-uglify": "^3.0.0",
"ember-data": "~3.19.0",
"ember-export-application-global": "^2.0.1",
"ember-fetch": "^8.0.1",
"ember-load-initializers": "^2.1.1",
"ember-maybe-import-regenerator": "^0.1.6",
"ember-qunit": "^4.6.0",
Expand Down
Loading

0 comments on commit 11ca6b0

Please sign in to comment.