Skip to content

Commit 616627c

Browse files
authored
Merge branch 'home-assistant:dev' into ui-date-bugfixes
2 parents 62f7498 + 24f1677 commit 616627c

Some content is hidden

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

53 files changed

+789
-554
lines changed

build-scripts/bundle.js

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@ const path = require("path");
22
const env = require("./env.js");
33
const paths = require("./paths.js");
44

5+
// GitHub base URL to use for production source maps
6+
// Nightly builds use the commit SHA, otherwise assumes there is a tag that matches the version
7+
module.exports.sourceMapURL = () => {
8+
const ref = env.version().endsWith("dev")
9+
? process.env.GITHUB_SHA || "dev"
10+
: env.version();
11+
return `https://raw.githubusercontent.com/home-assistant/frontend/${ref}`;
12+
};
13+
514
// Files from NPM Packages that should not be imported
615
// eslint-disable-next-line unused-imports/no-unused-vars
716
module.exports.ignorePackages = ({ latestBuild }) => [
@@ -65,13 +74,14 @@ const htmlMinifierOptions = {
6574
},
6675
};
6776

68-
module.exports.terserOptions = (latestBuild) => ({
77+
module.exports.terserOptions = ({ latestBuild, isTestBuild }) => ({
6978
safari10: !latestBuild,
7079
ecma: latestBuild ? undefined : 5,
71-
output: { comments: false },
80+
format: { comments: false },
81+
sourceMap: !isTestBuild,
7282
});
7383

74-
module.exports.babelOptions = ({ latestBuild, isProdBuild }) => ({
84+
module.exports.babelOptions = ({ latestBuild, isProdBuild, isTestBuild }) => ({
7585
babelrc: false,
7686
compact: false,
7787
presets: [
@@ -135,8 +145,11 @@ module.exports.babelOptions = ({ latestBuild, isProdBuild }) => ({
135145
/node_modules[\\/]core-js/,
136146
/node_modules[\\/]webpack[\\/]buildin/,
137147
],
148+
sourceMaps: !isTestBuild,
138149
});
139150

151+
const nameSuffix = (latestBuild) => (latestBuild ? "-latest" : "-es5");
152+
140153
const outputPath = (outputRoot, latestBuild) =>
141154
path.resolve(outputRoot, latestBuild ? "frontend_latest" : "frontend_es5");
142155

@@ -159,14 +172,17 @@ BundleConfig {
159172
latestBuild: boolean,
160173
// If we're doing a stats build (create nice chunk names)
161174
isStatsBuild: boolean,
175+
// If it's just a test build in CI, skip time on source map generation
176+
isTestBuild: boolean,
162177
// Names of entrypoints that should not be hashed
163178
dontHash: Set<string>
164179
}
165180
*/
166181

167182
module.exports.config = {
168-
app({ isProdBuild, latestBuild, isStatsBuild, isWDS }) {
183+
app({ isProdBuild, latestBuild, isStatsBuild, isTestBuild, isWDS }) {
169184
return {
185+
name: "app" + nameSuffix(latestBuild),
170186
entry: {
171187
service_worker: "./src/entrypoints/service_worker.ts",
172188
app: "./src/entrypoints/app.ts",
@@ -180,12 +196,14 @@ module.exports.config = {
180196
isProdBuild,
181197
latestBuild,
182198
isStatsBuild,
199+
isTestBuild,
183200
isWDS,
184201
};
185202
},
186203

187204
demo({ isProdBuild, latestBuild, isStatsBuild }) {
188205
return {
206+
name: "demo" + nameSuffix(latestBuild),
189207
entry: {
190208
main: path.resolve(paths.demo_dir, "src/entrypoint.ts"),
191209
},
@@ -215,6 +233,7 @@ module.exports.config = {
215233
}
216234

217235
return {
236+
name: "cast" + nameSuffix(latestBuild),
218237
entry,
219238
outputPath: outputPath(paths.cast_output_root, latestBuild),
220239
publicPath: publicPath(latestBuild),
@@ -226,15 +245,18 @@ module.exports.config = {
226245
};
227246
},
228247

229-
hassio({ isProdBuild, latestBuild }) {
248+
hassio({ isProdBuild, latestBuild, isStatsBuild, isTestBuild }) {
230249
return {
250+
name: "supervisor" + nameSuffix(latestBuild),
231251
entry: {
232252
entrypoint: path.resolve(paths.hassio_dir, "src/entrypoint.ts"),
233253
},
234254
outputPath: outputPath(paths.hassio_output_root, latestBuild),
235255
publicPath: publicPath(latestBuild, paths.hassio_publicPath),
236256
isProdBuild,
237257
latestBuild,
258+
isStatsBuild,
259+
isTestBuild,
238260
isHassioBuild: true,
239261
defineOverlay: {
240262
__SUPERVISOR__: true,
@@ -244,6 +266,7 @@ module.exports.config = {
244266

245267
gallery({ isProdBuild, latestBuild }) {
246268
return {
269+
name: "gallery" + nameSuffix(latestBuild),
247270
entry: {
248271
entrypoint: path.resolve(paths.gallery_dir, "src/entrypoint.js"),
249272
},

build-scripts/env.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module.exports = {
1717
isStatsBuild() {
1818
return process.env.STATS === "1";
1919
},
20-
isTest() {
20+
isTestBuild() {
2121
return process.env.IS_TEST === "true";
2222
},
2323
isNetlify() {

build-scripts/gulp/app.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
// Run HA develop mode
2-
const gulp = require("gulp");
32

3+
const gulp = require("gulp");
44
const env = require("../env");
5-
65
require("./clean.js");
76
require("./translations.js");
87
require("./locale-data.js");
@@ -50,7 +49,7 @@ gulp.task(
5049
"copy-static-app",
5150
env.useRollup() ? "rollup-prod-app" : "webpack-prod-app",
5251
// Don't compress running tests
53-
...(env.isTest() ? [] : ["compress-app"]),
52+
...(env.isTestBuild() ? [] : ["compress-app"]),
5453
gulp.parallel(
5554
"gen-pages-prod",
5655
"gen-index-app-prod",

build-scripts/gulp/hassio.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
const gulp = require("gulp");
2-
32
const env = require("../env");
4-
53
require("./clean.js");
64
require("./gen-icons-json.js");
75
require("./webpack.js");
@@ -43,6 +41,6 @@ gulp.task(
4341
env.useRollup() ? "rollup-prod-hassio" : "webpack-prod-hassio",
4442
"gen-index-hassio-prod",
4543
...// Don't compress running tests
46-
(env.isTest() ? [] : ["compress-hassio"])
44+
(env.isTestBuild() ? [] : ["compress-hassio"])
4745
)
4846
);

build-scripts/gulp/webpack.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const webpack = require("webpack");
55
const WebpackDevServer = require("webpack-dev-server");
66
const log = require("fancy-log");
77
const path = require("path");
8+
const env = require("../env");
89
const paths = require("../paths");
910
const {
1011
createAppConfig,
@@ -104,6 +105,8 @@ gulp.task("webpack-prod-app", () =>
104105
prodBuild(
105106
bothBuilds(createAppConfig, {
106107
isProdBuild: true,
108+
isStatsBuild: env.isStatsBuild(),
109+
isTestBuild: env.isTestBuild(),
107110
})
108111
)
109112
);
@@ -161,6 +164,8 @@ gulp.task("webpack-prod-hassio", () =>
161164
prodBuild(
162165
bothBuilds(createHassioConfig, {
163166
isProdBuild: true,
167+
isStatsBuild: env.isStatsBuild(),
168+
isTestBuild: env.isTestBuild(),
164169
})
165170
)
166171
);

build-scripts/removedIcons.json

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1 @@
1-
[
2-
{
3-
"path": "M20,20H7A2,2 0 0,1 5,18V8.94L2.23,5.64C2.09,5.47 2,5.24 2,5A1,1 0 0,1 3,4H20A2,2 0 0,1 22,6V18A2,2 0 0,1 20,20M8.5,7A0.5,0.5 0 0,0 8,7.5V8.5A0.5,0.5 0 0,0 8.5,9H18.5A0.5,0.5 0 0,0 19,8.5V7.5A0.5,0.5 0 0,0 18.5,7H8.5M8.5,11A0.5,0.5 0 0,0 8,11.5V12.5A0.5,0.5 0 0,0 8.5,13H18.5A0.5,0.5 0 0,0 19,12.5V11.5A0.5,0.5 0 0,0 18.5,11H8.5M8.5,15A0.5,0.5 0 0,0 8,15.5V16.5A0.5,0.5 0 0,0 8.5,17H13.5A0.5,0.5 0 0,0 14,16.5V15.5A0.5,0.5 0 0,0 13.5,15H8.5Z",
4-
"name": "android-messages"
5-
},
6-
{
7-
"path": "M4,6H2V20A2,2 0 0,0 4,22H18V20H4V6M20,2H8A2,2 0 0,0 6,4V16A2,2 0 0,0 8,18H20A2,2 0 0,0 22,16V4A2,2 0 0,0 20,2M20,12L17.5,10.5L15,12V4H20V12Z",
8-
"name": "book-variant-multiple"
9-
},
10-
{
11-
"path": "M21,14H3V4H21M21,2H3C1.89,2 1,2.89 1,4V16A2,2 0 0,0 3,18H10L8,21V22H16V21L14,18H21A2,2 0 0,0 23,16V4C23,2.89 22.1,2 21,2Z",
12-
"name": "desktop-mac"
13-
},
14-
{
15-
"path": "M21,14V4H3V14H21M21,2A2,2 0 0,1 23,4V16A2,2 0 0,1 21,18H14L16,21V22H8V21L10,18H3C1.89,18 1,17.1 1,16V4C1,2.89 1.89,2 3,2H21M4,5H15V10H4V5M16,5H20V7H16V5M20,8V13H16V8H20M4,11H9V13H4V11M10,11H15V13H10V11Z",
16-
"name": "desktop-mac-dashboard"
17-
},
18-
{
19-
"path": "M22,24L16.75,19L17.38,21H4.5A2.5,2.5 0 0,1 2,18.5V3.5A2.5,2.5 0 0,1 4.5,1H19.5A2.5,2.5 0 0,1 22,3.5V24M12,6.8C9.32,6.8 7.44,7.95 7.44,7.95C8.47,7.03 10.27,6.5 10.27,6.5L10.1,6.33C8.41,6.36 6.88,7.53 6.88,7.53C5.16,11.12 5.27,14.22 5.27,14.22C6.67,16.03 8.75,15.9 8.75,15.9L9.46,15C8.21,14.73 7.42,13.62 7.42,13.62C7.42,13.62 9.3,14.9 12,14.9C14.7,14.9 16.58,13.62 16.58,13.62C16.58,13.62 15.79,14.73 14.54,15L15.25,15.9C15.25,15.9 17.33,16.03 18.73,14.22C18.73,14.22 18.84,11.12 17.12,7.53C17.12,7.53 15.59,6.36 13.9,6.33L13.73,6.5C13.73,6.5 15.53,7.03 16.56,7.95C16.56,7.95 14.68,6.8 12,6.8M9.93,10.59C10.58,10.59 11.11,11.16 11.1,11.86C11.1,12.55 10.58,13.13 9.93,13.13C9.29,13.13 8.77,12.55 8.77,11.86C8.77,11.16 9.28,10.59 9.93,10.59M14.1,10.59C14.75,10.59 15.27,11.16 15.27,11.86C15.27,12.55 14.75,13.13 14.1,13.13C13.46,13.13 12.94,12.55 12.94,11.86C12.94,11.16 13.45,10.59 14.1,10.59Z",
20-
"name": "discord"
21-
},
22-
{
23-
"path": "M8.06,7.78C7.5,7.78 7.17,7.73 7.08,7.64L6.66,13.73C7.19,14.05 7.88,14.3 8.72,14.5C9.56,14.71 10.78,14.77 12.38,14.67C13.97,14.58 15.63,14.23 17.34,13.64L16.55,4.22C15.67,5.09 14.38,5.91 12.66,6.66C11.13,7.31 9.81,7.69 8.72,7.78H8.06M7.97,5.34C7.28,5.94 7,6.34 7.13,6.56C7.22,6.78 7.7,6.84 8.58,6.75C9.67,6.66 10.91,6.31 12.28,5.72C13.22,5.31 14.03,4.88 14.72,4.41C15.41,3.94 15.88,3.55 16.13,3.23C16.38,2.92 16.47,2.7 16.41,2.58C16.34,2.42 16.03,2.34 15.47,2.34C14.34,2.34 12.94,2.7 11.25,3.42C9.81,4.05 8.72,4.69 7.97,5.34M17.34,2.2C17.41,2.33 17.44,2.47 17.44,2.63L18.61,17C18.61,18.73 18,20.09 16.83,21.07C15.64,22.05 14.03,22.55 12,22.55C10,22.55 8.4,22.04 7.2,21C6,20 5.39,18.64 5.39,16.92L6.09,6.47C6.09,6.22 6.2,5.94 6.42,5.63C6.64,5.31 6.84,5.06 7.03,4.88L7.36,4.59C8.33,3.78 9.5,3.08 10.88,2.5C11.81,2.08 12.73,1.77 13.62,1.57C14.5,1.37 15.3,1.3 16,1.38C16.71,1.46 17.16,1.73 17.34,2.2Z",
24-
"name": "google-home"
25-
},
26-
{
27-
"path": "M19.25,19H4.75V3H19.25M14,22H10V21H14M18,0H6A3,3 0 0,0 3,3V21A3,3 0 0,0 6,24H18A3,3 0 0,0 21,21V3A3,3 0 0,0 18,0Z",
28-
"name": "tablet-android"
29-
}
30-
]
1+
[]

build-scripts/rollup.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ const createRollupConfig = ({
7676
}),
7777
!isWDS && worker(),
7878
!isWDS && dontHashPlugin({ dontHash }),
79-
!isWDS && isProdBuild && terser(bundle.terserOptions(latestBuild)),
79+
!isWDS && isProdBuild && terser(bundle.terserOptions({ latestBuild })),
8080
!isWDS &&
8181
isStatsBuild &&
8282
visualizer({

build-scripts/webpack.js

Lines changed: 49 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@ class LogStartCompilePlugin {
2222
}
2323

2424
const createWebpackConfig = ({
25+
name,
2526
entry,
2627
outputPath,
2728
publicPath,
2829
defineOverlay,
2930
isProdBuild,
3031
latestBuild,
3132
isStatsBuild,
33+
isTestBuild,
3234
isHassioBuild,
3335
dontHash,
3436
}) => {
@@ -37,10 +39,16 @@ const createWebpackConfig = ({
3739
}
3840
const ignorePackages = bundle.ignorePackages({ latestBuild });
3941
return {
42+
name,
4043
mode: isProdBuild ? "production" : "development",
4144
target: ["web", latestBuild ? "es2017" : "es5"],
42-
devtool: isProdBuild
43-
? "cheap-module-source-map"
45+
// For tests/CI, source maps are skipped to gain build speed
46+
// For production, generate source maps for accurate stack traces without source code
47+
// For development, generate "cheap" versions that can map to original line numbers
48+
devtool: isTestBuild
49+
? false
50+
: isProdBuild
51+
? "nosources-source-map"
4452
: "eval-cheap-module-source-map",
4553
entry,
4654
node: false,
@@ -51,7 +59,7 @@ const createWebpackConfig = ({
5159
use: {
5260
loader: "babel-loader",
5361
options: {
54-
...bundle.babelOptions({ latestBuild, isProdBuild }),
62+
...bundle.babelOptions({ latestBuild, isProdBuild, isTestBuild }),
5563
cacheDirectory: !isProdBuild,
5664
cacheCompression: false,
5765
},
@@ -68,7 +76,7 @@ const createWebpackConfig = ({
6876
new TerserPlugin({
6977
parallel: true,
7078
extractComments: true,
71-
terserOptions: bundle.terserOptions(latestBuild),
79+
terserOptions: bundle.terserOptions({ latestBuild, isTestBuild }),
7280
}),
7381
],
7482
moduleIds: isProdBuild && !isStatsBuild ? "deterministic" : "named",
@@ -153,16 +161,37 @@ const createWebpackConfig = ({
153161
publicPath,
154162
// To silence warning in worker plugin
155163
globalObject: "self",
164+
// Since production source maps don't include sources, we need to point to them elsewhere
165+
// For dependencies, just provide the path (no source in browser)
166+
// Otherwise, point to the raw code on GitHub for browser to load
167+
devtoolModuleFilenameTemplate:
168+
!isTestBuild && isProdBuild
169+
? (info) => {
170+
const sourcePath = info.resourcePath.replace(/^\.\//, "");
171+
if (
172+
sourcePath.startsWith("node_modules") ||
173+
sourcePath.startsWith("webpack")
174+
) {
175+
return `no-source/${sourcePath}`;
176+
}
177+
return `${bundle.sourceMapURL()}/${sourcePath}`;
178+
}
179+
: undefined,
156180
},
157181
experiments: {
158182
topLevelAwait: true,
159183
},
160184
};
161185
};
162186

163-
const createAppConfig = ({ isProdBuild, latestBuild, isStatsBuild }) =>
187+
const createAppConfig = ({
188+
isProdBuild,
189+
latestBuild,
190+
isStatsBuild,
191+
isTestBuild,
192+
}) =>
164193
createWebpackConfig(
165-
bundle.config.app({ isProdBuild, latestBuild, isStatsBuild })
194+
bundle.config.app({ isProdBuild, latestBuild, isStatsBuild, isTestBuild })
166195
);
167196

168197
const createDemoConfig = ({ isProdBuild, latestBuild, isStatsBuild }) =>
@@ -173,8 +202,20 @@ const createDemoConfig = ({ isProdBuild, latestBuild, isStatsBuild }) =>
173202
const createCastConfig = ({ isProdBuild, latestBuild }) =>
174203
createWebpackConfig(bundle.config.cast({ isProdBuild, latestBuild }));
175204

176-
const createHassioConfig = ({ isProdBuild, latestBuild }) =>
177-
createWebpackConfig(bundle.config.hassio({ isProdBuild, latestBuild }));
205+
const createHassioConfig = ({
206+
isProdBuild,
207+
latestBuild,
208+
isStatsBuild,
209+
isTestBuild,
210+
}) =>
211+
createWebpackConfig(
212+
bundle.config.hassio({
213+
isProdBuild,
214+
latestBuild,
215+
isStatsBuild,
216+
isTestBuild,
217+
})
218+
);
178219

179220
const createGalleryConfig = ({ isProdBuild, latestBuild }) =>
180221
createWebpackConfig(bundle.config.gallery({ isProdBuild, latestBuild }));

hassio/src/dialogs/backup/dialog-hassio-backup.ts

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { getSignedPath } from "../../../../src/data/auth";
1616
import {
1717
fetchHassioBackupInfo,
1818
HassioBackupDetail,
19+
removeBackup,
1920
} from "../../../../src/data/hassio/backup";
2021
import { extractApiErrorMessage } from "../../../../src/data/hassio/common";
2122
import {
@@ -286,24 +287,15 @@ class HassioBackupDialog
286287
return;
287288
}
288289

289-
this.hass!.callApi(
290-
atLeastVersion(this.hass!.config.version, 2021, 9) ? "DELETE" : "POST",
291-
`hassio/${
292-
atLeastVersion(this.hass!.config.version, 2021, 9)
293-
? `backups/${this._backup!.slug}`
294-
: `snapshots/${this._backup!.slug}/remove`
295-
}`
296-
).then(
297-
() => {
298-
if (this._dialogParams!.onDelete) {
299-
this._dialogParams!.onDelete();
300-
}
301-
this.closeDialog();
302-
},
303-
(error) => {
304-
this._error = error.body.message;
290+
try {
291+
await removeBackup(this.hass!, this._backup!.slug);
292+
if (this._dialogParams!.onDelete) {
293+
this._dialogParams!.onDelete();
305294
}
306-
);
295+
this.closeDialog();
296+
} catch (err: any) {
297+
this._error = err.body.message;
298+
}
307299
}
308300

309301
private async _downloadClicked() {

0 commit comments

Comments
 (0)