Skip to content

Commit 469e36c

Browse files
authored
Mercure demo (#66)
* Mercure demo * Finish Mercure integration * Allow to build GYP modules * Headers * Upgrade composer.json * Disable invalidation * Upgrade AliceBundle * Fix ci/test.sh * Try to Fix alice * Try to make the test green * Try to make the test green * Try to fix tests * Fix tests * Try to fix tests * Fix Behat
1 parent 282b02c commit 469e36c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+13044
-8206
lines changed

.editorconfig

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# EditorConfig helps developers define and maintain consistent
2+
# coding styles between different editors and IDEs
3+
# editorconfig.org
4+
5+
root = true
6+
7+
[*]
8+
# Change these settings to your own preference
9+
indent_style = space
10+
indent_size = 4
11+
12+
# We recommend you to keep these unchanged
13+
end_of_line = lf
14+
charset = utf-8
15+
trim_trailing_whitespace = true
16+
insert_final_newline = true
17+
18+
[*.feature]
19+
indent_style = space
20+
indent_size = 2
21+
22+
[*.js]
23+
indent_style = space
24+
indent_size = 2
25+
26+
[*.json]
27+
indent_style = space
28+
indent_size = 2
29+
30+
[*.md]
31+
trim_trailing_whitespace = false
32+
33+
[*.php]
34+
indent_style = space
35+
indent_size = 4
36+
37+
[*.sh]
38+
indent_style = tab
39+
indent_size = 4
40+
41+
[*.xml]
42+
indent_style = space
43+
indent_size = 4
44+
45+
[*.{yaml,yml}]
46+
indent_style = space
47+
indent_size = 4
48+
trim_trailing_whitespace = false
49+
50+
[.gitmodules]
51+
indent_style = tab
52+
indent_size = 4
53+
54+
[.php_cs{,.dist}]
55+
indent_style = space
56+
indent_size = 4
57+
58+
[.travis.yml]
59+
indent_style = space
60+
indent_size = 2
61+
62+
[composer.json]
63+
indent_style = space
64+
indent_size = 4
65+
66+
[docker-compose{,.override}.{yaml,yml}]
67+
indent_style = space
68+
indent_size = 2
69+
70+
[Dockerfile]
71+
indent_style = tab
72+
indent_size = 4
73+
74+
[package.json]
75+
indent_style = space
76+
indent_size = 2
77+
78+
[phpunit.xml{,.dist}]
79+
indent_style = space
80+
indent_size = 4

.gitattributes

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
* text=auto eol=lf
2+
3+
*.conf text eol=lf
4+
*.html text eol=lf
5+
*.ini text eol=lf
6+
*.js text eol=lf
7+
*.json text eol=lf
8+
*.md text eol=lf
9+
*.php text eol=lf
10+
*.sh text eol=lf
11+
*.yaml text eol=lf
12+
*.yml text eol=lf
13+
bin/console text eol=lf
14+
15+
*.ico binary
16+
*.png binary
17+
18+
.github export-ignore
19+
.travis.yml export-ignore
20+
LICENSE export-ignore
21+
README.md export-ignore
22+
update-deps.sh export-ignore

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/docker-compose.override.yaml
2+
/docker-compose.override.yml

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2015 Kévin Dunglas
1+
Copyright (c) 2015-present Kévin Dunglas
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy
44
of this software and associated documentation files (the "Software"), to deal

admin/Dockerfile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1-
FROM node:9.11-alpine
1+
FROM node:11.5-alpine
22

33
RUN mkdir -p /usr/src/admin
44

55
WORKDIR /usr/src/admin
66

77
# Prevent the reinstallation of node modules at every changes in the source code
88
COPY package.json yarn.lock ./
9-
RUN yarn install
9+
10+
RUN apk add --no-cache --virtual .gyp \
11+
python \
12+
make \
13+
g++ \
14+
&& yarn install \
15+
&& apk del .gyp
1016

1117
COPY . ./
1218

admin/package.json

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,22 @@
33
"version": "0.1.0",
44
"private": true,
55
"dependencies": {
6-
"@api-platform/admin": "^0.5.0",
6+
"@api-platform/admin": "^0.6.1",
7+
"@babel/runtime": "7.0.0-beta.55",
78
"react": "^16.3.0",
8-
"react-dom": "^16.3.0"
9-
},
10-
"devDependencies": {
11-
"react-scripts": "^1.1.0"
9+
"react-dom": "^16.3.0",
10+
"react-scripts": "^2.1.2"
1211
},
1312
"scripts": {
1413
"start": "react-scripts start",
1514
"build": "react-scripts build",
16-
"test": "react-scripts test --env=jsdom",
15+
"test": "react-scripts test",
1716
"eject": "react-scripts eject"
18-
}
17+
},
18+
"browserslist": [
19+
">0.2%",
20+
"not dead",
21+
"not ie <= 11",
22+
"not op_mini all"
23+
]
1924
}

admin/src/App.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ import App from './App';
55
it('renders without crashing', () => {
66
const div = document.createElement('div');
77
ReactDOM.render(<App />, div);
8+
ReactDOM.unmountComponentAtNode(div);
89
});

admin/src/index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import React from 'react';
22
import ReactDOM from 'react-dom';
33
import App from './App';
4-
import registerServiceWorker from './registerServiceWorker';
4+
import * as serviceWorker from './serviceWorker';
55

66
ReactDOM.render(<App />, document.getElementById('root'));
7-
registerServiceWorker();
7+
8+
// If you want your app to work offline and load faster, you can change
9+
// unregister() to register() below. Note this comes with some pitfalls.
10+
// Learn more about service workers: http://bit.ly/CRA-PWA
11+
serviceWorker.unregister();

client/src/registerServiceWorker.js renamed to admin/src/serviceWorker.js

Lines changed: 55 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,93 @@
1-
// In production, we register a service worker to serve assets from local cache.
1+
// This optional code is used to register a service worker.
2+
// register() is not called by default.
23

34
// This lets the app load faster on subsequent visits in production, and gives
45
// it offline capabilities. However, it also means that developers (and users)
5-
// will only see deployed updates on the "N+1" visit to a page, since previously
6-
// cached resources are updated in the background.
6+
// will only see deployed updates on subsequent visits to a page, after all the
7+
// existing tabs open on the page have been closed, since previously cached
8+
// resources are updated in the background.
79

8-
// To learn more about the benefits of this model, read https://goo.gl/KwvDNy.
9-
// This link also includes instructions on opting out of this behavior.
10+
// To learn more about the benefits of this model and instructions on how to
11+
// opt-in, read http://bit.ly/CRA-PWA
1012

1113
const isLocalhost = Boolean(
1214
window.location.hostname === 'localhost' ||
13-
// [::1] is the IPv6 localhost address.
14-
window.location.hostname === '[::1]' ||
15-
// 127.0.0.1/8 is considered localhost for IPv4.
16-
window.location.hostname.match(
17-
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
18-
)
15+
// [::1] is the IPv6 localhost address.
16+
window.location.hostname === '[::1]' ||
17+
// 127.0.0.1/8 is considered localhost for IPv4.
18+
window.location.hostname.match(
19+
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
20+
)
1921
);
2022

21-
export default function register() {
23+
export function register(config) {
2224
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
2325
// The URL constructor is available in all browsers that support SW.
24-
const publicUrl = new URL(process.env.PUBLIC_URL, window.location);
26+
const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);
2527
if (publicUrl.origin !== window.location.origin) {
2628
// Our service worker won't work if PUBLIC_URL is on a different origin
2729
// from what our page is served on. This might happen if a CDN is used to
28-
// serve assets; see https://github.com/facebookincubator/create-react-app/issues/2374
30+
// serve assets; see https://github.com/facebook/create-react-app/issues/2374
2931
return;
3032
}
3133

3234
window.addEventListener('load', () => {
3335
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
3436

35-
if (!isLocalhost) {
36-
// Is not local host. Just register service worker
37-
registerValidSW(swUrl);
37+
if (isLocalhost) {
38+
// This is running on localhost. Let's check if a service worker still exists or not.
39+
checkValidServiceWorker(swUrl, config);
40+
41+
// Add some additional logging to localhost, pointing developers to the
42+
// service worker/PWA documentation.
43+
navigator.serviceWorker.ready.then(() => {
44+
console.log(
45+
'This web app is being served cache-first by a service ' +
46+
'worker. To learn more, visit http://bit.ly/CRA-PWA'
47+
);
48+
});
3849
} else {
39-
// This is running on localhost. Lets check if a service worker still exists or not.
40-
checkValidServiceWorker(swUrl);
50+
// Is not localhost. Just register service worker
51+
registerValidSW(swUrl, config);
4152
}
4253
});
4354
}
4455
}
4556

46-
function registerValidSW(swUrl) {
57+
function registerValidSW(swUrl, config) {
4758
navigator.serviceWorker
4859
.register(swUrl)
4960
.then(registration => {
5061
registration.onupdatefound = () => {
5162
const installingWorker = registration.installing;
63+
if (installingWorker == null) {
64+
return;
65+
}
5266
installingWorker.onstatechange = () => {
5367
if (installingWorker.state === 'installed') {
5468
if (navigator.serviceWorker.controller) {
55-
// At this point, the old content will have been purged and
56-
// the fresh content will have been added to the cache.
57-
// It's the perfect time to display a "New content is
58-
// available; please refresh." message in your web app.
59-
console.log('New content is available; please refresh.');
69+
// At this point, the updated precached content has been fetched,
70+
// but the previous service worker will still serve the older
71+
// content until all client tabs are closed.
72+
console.log(
73+
'New content is available and will be used when all ' +
74+
'tabs for this page are closed. See http://bit.ly/CRA-PWA.'
75+
);
76+
77+
// Execute callback
78+
if (config && config.onUpdate) {
79+
config.onUpdate(registration);
80+
}
6081
} else {
6182
// At this point, everything has been precached.
6283
// It's the perfect time to display a
6384
// "Content is cached for offline use." message.
6485
console.log('Content is cached for offline use.');
86+
87+
// Execute callback
88+
if (config && config.onSuccess) {
89+
config.onSuccess(registration);
90+
}
6591
}
6692
}
6793
};
@@ -72,14 +98,15 @@ function registerValidSW(swUrl) {
7298
});
7399
}
74100

75-
function checkValidServiceWorker(swUrl) {
101+
function checkValidServiceWorker(swUrl, config) {
76102
// Check if the service worker can be found. If it can't reload the page.
77103
fetch(swUrl)
78104
.then(response => {
79105
// Ensure service worker exists, and that we really are getting a JS file.
106+
const contentType = response.headers.get('content-type');
80107
if (
81108
response.status === 404 ||
82-
response.headers.get('content-type').indexOf('javascript') === -1
109+
(contentType != null && contentType.indexOf('javascript') === -1)
83110
) {
84111
// No service worker found. Probably a different app. Reload the page.
85112
navigator.serviceWorker.ready.then(registration => {
@@ -89,7 +116,7 @@ function checkValidServiceWorker(swUrl) {
89116
});
90117
} else {
91118
// Service worker found. Proceed as normal.
92-
registerValidSW(swUrl);
119+
registerValidSW(swUrl, config);
93120
}
94121
})
95122
.catch(() => {

0 commit comments

Comments
 (0)