Skip to content

Commit 4d6d362

Browse files
committed
move package-json-test
1 parent f80bcd8 commit 4d6d362

9 files changed

Lines changed: 270 additions & 4 deletions

File tree

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"private": true,
44
"workspaces": [
55
"packages/ember-cli-fastboot",
6-
"test-packages/basic-app"
6+
"test-packages/basic-app",
7+
"test-packages/*"
78
]
89
}

test-packages/basic-app/config/environment.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ module.exports = function(environment) {
2020
APP: {
2121
// Here you can pass flags/options to your application instance
2222
// when it is created
23+
},
24+
25+
fastboot: {
26+
hostWhitelist: [
27+
'example.com',
28+
'subdomain.example.com',
29+
'/localhost:\\d+/',
30+
]
2331
}
2432
};
2533

test-packages/basic-app/package.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
"test:ember": "ember test",
2222
"test:mocha": "mocha"
2323
},
24+
"dependencies": {
25+
"ember-fastboot-build-example": "0.1.2",
26+
"rsvp": "^4.8.5"
27+
},
2428
"devDependencies": {
2529
"@ember/optional-features": "^1.3.0",
2630
"@glimmer/component": "^1.0.0",
@@ -53,11 +57,16 @@
5357
"eslint-plugin-ember": "^8.6.0",
5458
"eslint-plugin-node": "^11.1.0",
5559
"execa": "^4.0.3",
60+
"fake-addon": "*",
61+
"fake-addon-2": "*",
5662
"loader.js": "^4.7.0",
5763
"mocha": "^8.0.1",
5864
"npm-run-all": "^4.1.5",
5965
"qunit-dom": "^1.2.0"
6066
},
67+
"fastbootDependencies": [
68+
"rsvp"
69+
],
6170
"engines": {
6271
"node": "10.* || >= 12"
6372
},
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
"use strict";
2+
3+
const chai = require("chai");
4+
const expect = chai.expect;
5+
const fs = require("fs-extra");
6+
const execa = require("execa");
7+
8+
chai.use(require("chai-fs"));
9+
10+
describe("generating package.json", function () {
11+
this.timeout(300000);
12+
13+
describe("with FastBoot builds", function () {
14+
before(async function () {
15+
await execa("yarn", ["build"]);
16+
});
17+
18+
it("builds a package.json", async function () {
19+
expect("dist/assets/basic-app.js").to.be.a.file();
20+
expect("dist/package.json").to.be.a.file();
21+
});
22+
23+
it("merges FastBoot dependencies from multiple addons", function () {
24+
let pkg = fs.readJSONSync("dist/package.json");
25+
26+
expect(pkg.dependencies).to.deep.equal({
27+
"abortcontroller-polyfill": "^1.4.0",
28+
foo: "1.0.0",
29+
bar: "^0.1.2",
30+
baz: "0.0.0",
31+
"node-fetch": "^2.6.0",
32+
rsvp: "^4.8.5",
33+
});
34+
});
35+
36+
it("contains a schema version", function () {
37+
let pkg = fs.readJSONSync("dist/package.json");
38+
39+
expect(pkg.fastboot.schemaVersion).to.deep.equal(3);
40+
});
41+
42+
it("contains a whitelist of allowed module names", function () {
43+
let pkg = fs.readJSONSync("dist/package.json");
44+
45+
expect(pkg.fastboot.moduleWhitelist).to.deep.equal([
46+
"node-fetch",
47+
"abortcontroller-polyfill",
48+
"abortcontroller-polyfill/dist/cjs-ponyfill",
49+
"path",
50+
"foo",
51+
"bar",
52+
"baz",
53+
"rsvp",
54+
]);
55+
});
56+
57+
it("contains a manifest of FastBoot assets", function () {
58+
let pkg = fs.readJSONSync("dist/package.json");
59+
60+
expect(pkg.fastboot.manifest).to.deep.equal({
61+
appFiles: [
62+
"assets/basic-app.js",
63+
"assets/basic-app-fastboot.js",
64+
"ember-fastboot-build-example/bar.js",
65+
],
66+
htmlFile: "index.html",
67+
vendorFiles: [
68+
"ember-fastboot-build-example/foo.js",
69+
"assets/vendor.js",
70+
"assets/auto-import-fastboot.js",
71+
"ember-fetch/fetch-fastboot.js",
72+
],
73+
});
74+
});
75+
76+
it("contains a list of whitelisted hosts from environment.js", function () {
77+
let pkg = fs.readJSONSync("dist/package.json");
78+
79+
expect(pkg.fastboot.hostWhitelist).to.deep.equal([
80+
"example.com",
81+
"subdomain.example.com",
82+
"/localhost:\\d+/",
83+
]);
84+
});
85+
86+
it("contains app name", function () {
87+
let pkg = fs.readJSONSync("dist/package.json");
88+
89+
expect(pkg.fastboot.appName).to.equal("basic-app");
90+
});
91+
92+
it("contains the application config", function () {
93+
let pkg = fs.readJSONSync("dist/package.json");
94+
95+
let config = pkg.fastboot.config["basic-app"];
96+
97+
expect(config.APP.version).to.include("0.0.0");
98+
99+
delete config.APP.version;
100+
expect(config).to.deep.equal({
101+
modulePrefix: "basic-app",
102+
environment: "development",
103+
rootURL: "/",
104+
locationType: "auto",
105+
EmberENV: {
106+
EXTEND_PROTOTYPES: {
107+
Date: false,
108+
},
109+
FEATURES: {},
110+
_APPLICATION_TEMPLATE_WRAPPER: false,
111+
_DEFAULT_ASYNC_OBSERVERS: true,
112+
_JQUERY_INTEGRATION: false,
113+
_TEMPLATE_ONLY_GLIMMER_COMPONENTS: true,
114+
},
115+
APP: {
116+
name: "basic-app",
117+
autoboot: false,
118+
},
119+
fastboot: {
120+
hostWhitelist: [
121+
"example.com",
122+
"subdomain.example.com",
123+
"/localhost:\\d+/",
124+
],
125+
},
126+
exportApplicationGlobal: true,
127+
});
128+
});
129+
130+
it("contains additional config from ember-fastboot-build-example addon", function () {
131+
let pkg = fs.readJSONSync("dist/package.json");
132+
133+
expect(pkg.fastboot.config["foo"]).to.equal("bar");
134+
});
135+
136+
});
137+
138+
describe("with production FastBoot builds", function () {
139+
before(async function () {
140+
await execa("yarn", ["build", "--environment=production"]);
141+
});
142+
143+
it("contains a manifest of FastBoot assets", function () {
144+
let pkg = fs.readJSONSync("dist/package.json");
145+
146+
let manifest = pkg.fastboot.manifest;
147+
148+
manifest.appFiles.forEach((file) => {
149+
expect(`dist/${file}`).to.be.a.file();
150+
});
151+
152+
expect(`dist/${manifest.htmlFile}`).to.be.a.file();
153+
154+
manifest.vendorFiles.forEach((file) => {
155+
expect(`dist/${file}`).to.be.a.file();
156+
});
157+
});
158+
});
159+
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
name: "Fake Addon Two"
3+
};
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "fake-addon-2",
3+
"version": "0.1.0",
4+
"ember-addon": {
5+
"fastbootDependencies": [
6+
"bar",
7+
"baz",
8+
"path"
9+
]
10+
},
11+
"dependencies": {
12+
"bar": "^0.1.2",
13+
"baz": "0.0.0"
14+
},
15+
"keywords": [
16+
"ember-addon"
17+
]
18+
}

test-packages/fake-addon/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
name: "Fake Addon"
3+
};
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "fake-addon",
3+
"version": "0.1.0",
4+
"ember-addon": {
5+
"fastbootDependencies": [
6+
"path",
7+
"foo",
8+
"bar"
9+
]
10+
},
11+
"dependencies": {
12+
"foo": "1.0.0",
13+
"bar": "^0.1.2"
14+
},
15+
"keywords": [
16+
"ember-addon"
17+
]
18+
}

yarn.lock

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2906,6 +2906,14 @@ balanced-match@^1.0.0:
29062906
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767"
29072907
integrity sha1-ibTRmasr7kneFk6gK4nORi1xt2c=
29082908

2909+
bar@^0.1.2:
2910+
version "0.1.2"
2911+
resolved "https://registry.yarnpkg.com/bar/-/bar-0.1.2.tgz#ec36d80c5fea1111fe1e32c9db38a61053225155"
2912+
integrity sha1-7DbYDF/qERH+HjLJ2zimEFMiUVU=
2913+
dependencies:
2914+
optimist "~ 0.2.4"
2915+
watch "~ 0.3.2"
2916+
29092917
29102918
version "0.1.5"
29112919
resolved "https://registry.yarnpkg.com/base64-arraybuffer/-/base64-arraybuffer-0.1.5.tgz#73926771923b5a19747ad666aa5cd4bf9c6e9ce8"
@@ -2941,6 +2949,11 @@ basic-auth@~2.0.1:
29412949
dependencies:
29422950
safe-buffer "5.1.2"
29432951

2952+
2953+
version "0.0.0"
2954+
resolved "https://registry.yarnpkg.com/baz/-/baz-0.0.0.tgz#31351e4d812af3b747ab0d7fef6430b486992a82"
2955+
integrity sha1-MTUeTYEq87dHqw1/72QwtIaZKoI=
2956+
29442957
bcrypt-pbkdf@^1.0.0:
29452958
version "1.0.2"
29462959
resolved "https://registry.yarnpkg.com/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz#a4301d389b6a43f9b67ff3ca11a3f6637e360e9e"
@@ -3332,7 +3345,7 @@ broccoli-funnel-reducer@^1.0.0:
33323345
resolved "https://registry.yarnpkg.com/broccoli-funnel-reducer/-/broccoli-funnel-reducer-1.0.0.tgz#11365b2a785aec9b17972a36df87eef24c5cc0ea"
33333346
integrity sha1-ETZbKnha7JsXlyo234fu8kxcwOo=
33343347

3335-
broccoli-funnel@^1.0.1:
3348+
broccoli-funnel@^1.0.1, broccoli-funnel@^1.1.0:
33363349
version "1.2.0"
33373350
resolved "https://registry.yarnpkg.com/broccoli-funnel/-/broccoli-funnel-1.2.0.tgz#cddc3afc5ff1685a8023488fff74ce6fb5a51296"
33383351
integrity sha1-zdw6/F/xaFqAI0iP/3TOb7WlEpY=
@@ -5406,7 +5419,7 @@ ember-cli-babel-plugin-helpers@^1.0.0, ember-cli-babel-plugin-helpers@^1.1.0:
54065419
resolved "https://registry.yarnpkg.com/ember-cli-babel-plugin-helpers/-/ember-cli-babel-plugin-helpers-1.1.0.tgz#de3baedd093163b6c2461f95964888c1676325ac"
54075420
integrity sha512-Zr4my8Xn+CzO0gIuFNXji0eTRml5AxZUTDQz/wsNJ5AJAtyFWCY4QtKdoELNNbiCVGt1lq5yLiwTm4scGKu6xA==
54085421

5409-
ember-cli-babel@^6.0.0-beta.4, ember-cli-babel@^6.11.0, ember-cli-babel@^6.12.0, ember-cli-babel@^6.16.0, ember-cli-babel@^6.6.0, ember-cli-babel@^6.8.1, ember-cli-babel@^6.8.2:
5422+
ember-cli-babel@^6.0.0-beta.3, ember-cli-babel@^6.0.0-beta.4, ember-cli-babel@^6.11.0, ember-cli-babel@^6.12.0, ember-cli-babel@^6.16.0, ember-cli-babel@^6.6.0, ember-cli-babel@^6.8.1, ember-cli-babel@^6.8.2:
54105423
version "6.18.0"
54115424
resolved "https://registry.yarnpkg.com/ember-cli-babel/-/ember-cli-babel-6.18.0.tgz#3f6435fd275172edeff2b634ee7b29ce74318957"
54125425
integrity sha512-7ceC8joNYxY2wES16iIBlbPSxwKDBhYwC8drU3ZEvuPDMwVv1KzxCNu1fvxyFEBWhwaRNTUxSCsEVoTd9nosGA==
@@ -5971,6 +5984,16 @@ ember-export-application-global@^2.0.0, ember-export-application-global@^2.0.1:
59715984
resolved "https://registry.yarnpkg.com/ember-export-application-global/-/ember-export-application-global-2.0.1.tgz#b120a70e322ab208defc9e2daebe8d0dfc2dcd46"
59725985
integrity sha512-B7wiurPgsxsSGzJuPFkpBWnaeuCu2PGpG2BjyrfA1VcL7//o+5RSnZqiCEY326y7qmxb2GoCgo0ft03KBU0rRw==
59735986

5987+
5988+
version "0.1.2"
5989+
resolved "https://registry.yarnpkg.com/ember-fastboot-build-example/-/ember-fastboot-build-example-0.1.2.tgz#ca4b112368f585adb1afc8e83dd08b94a2d29950"
5990+
integrity sha512-gvl4QU2+pjhLzmBJMH8Ev/O030BdA567ULfoeSwnGsAwFlrZssHpZdX+XHfWyHQj8d8EHQWpiR9SXIWakvIQug==
5991+
dependencies:
5992+
broccoli-funnel "^1.1.0"
5993+
broccoli-merge-trees "^2.0.0"
5994+
ember-cli-babel "^6.0.0-beta.3"
5995+
fastboot-filter-initializers "0.0.2"
5996+
59745997
ember-fetch@^8.0.1:
59755998
version "8.0.1"
59765999
resolved "https://registry.yarnpkg.com/ember-fetch/-/ember-fetch-8.0.1.tgz#dc57f3c3ba464e4a8722785f6b44265c46b38020"
@@ -7084,6 +7107,13 @@ fastboot-express-middleware@^2.0.0:
70847107
fastboot "^2.0.1"
70857108
request "^2.81.0"
70867109

7110+
7111+
version "0.0.2"
7112+
resolved "https://registry.yarnpkg.com/fastboot-filter-initializers/-/fastboot-filter-initializers-0.0.2.tgz#67aa9e8b22ca4b0e6a244f2450fd1cc6befa45e7"
7113+
integrity sha1-Z6qeiyLKSw5qJE8kUP0cxr76Rec=
7114+
dependencies:
7115+
broccoli-funnel "^1.0.1"
7116+
70877117
fastboot-transform@^0.1.3:
70887118
version "0.1.3"
70897119
resolved "https://registry.yarnpkg.com/fastboot-transform/-/fastboot-transform-0.1.3.tgz#7dea0b117594afd8772baa6c9b0919644e7f7dcd"
@@ -7432,6 +7462,11 @@ follow-redirects@^1.0.0:
74327462
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.12.1.tgz#de54a6205311b93d60398ebc01cf7015682312b6"
74337463
integrity sha512-tmRv0AVuR7ZyouUHLeNSiO6pqulF7dYa3s19c6t+wz9LD69/uSzdMxJ2S91nTI9U3rt/IldxpzMOFejp6f0hjg==
74347464

7465+
7466+
version "1.0.0"
7467+
resolved "https://registry.yarnpkg.com/foo/-/foo-1.0.0.tgz#943e0ec03df00ebeb6273a5b94b916ba54b47581"
7468+
integrity sha1-lD4OwD3wDr62JzpblLkWulS0dYE=
7469+
74357470
for-in@^1.0.1, for-in@^1.0.2:
74367471
version "1.0.2"
74377472
resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80"
@@ -10791,6 +10826,13 @@ onetime@^5.1.0:
1079110826
dependencies:
1079210827
mimic-fn "^2.1.0"
1079310828

10829+
"optimist@~ 0.2.4":
10830+
version "0.2.8"
10831+
resolved "https://registry.yarnpkg.com/optimist/-/optimist-0.2.8.tgz#e981ab7e268b457948593b55674c099a815cac31"
10832+
integrity sha1-6YGrfiaLRXlIWTtVZ0wJmoFcrDE=
10833+
dependencies:
10834+
wordwrap ">=0.0.1 <0.1.0"
10835+
1079410836
optionator@^0.8.1, optionator@^0.8.2:
1079510837
version "0.8.3"
1079610838
resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.3.tgz#84fa1d036fe9d3c7e21d99884b601167ec8fb495"
@@ -14161,6 +14203,11 @@ watch-detector@^1.0.0:
1416114203
silent-error "^1.1.1"
1416214204
tmp "^0.1.0"
1416314205

14206+
"watch@~ 0.3.2":
14207+
version "0.3.3"
14208+
resolved "https://registry.yarnpkg.com/watch/-/watch-0.3.3.tgz#2aa776716ed463464dbaa2c2e4f9c6aca1e2fa3c"
14209+
integrity sha1-Kqd2cW7UY0ZNuqLC5PnGrKHi+jw=
14210+
1416414211
watch@~0.10.0:
1416514212
version "0.10.0"
1416614213
resolved "https://registry.yarnpkg.com/watch/-/watch-0.10.0.tgz#77798b2da0f9910d595f1ace5b0c2258521f21dc"
@@ -14340,7 +14387,7 @@ word-wrap@^1.2.3, word-wrap@~1.2.3:
1434014387
resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c"
1434114388
integrity sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==
1434214389

14343-
wordwrap@^0.0.3:
14390+
"wordwrap@>=0.0.1 <0.1.0", wordwrap@^0.0.3:
1434414391
version "0.0.3"
1434514392
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.3.tgz#a3d5da6cd5c0bc0008d37234bbaf1bed63059107"
1434614393
integrity sha1-o9XabNXAvAAI03I0u68b7WMFkQc=

0 commit comments

Comments
 (0)