mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-13 20:36:35 +00:00
Convert remaining gulp modules to ESM (#16430)
This commit is contained in:
parent
aa3fd70966
commit
586079917d
@ -1,16 +1,16 @@
|
|||||||
import gulp from "gulp";
|
import gulp from "gulp";
|
||||||
import env from "../env.cjs";
|
import env from "../env.cjs";
|
||||||
import "./clean.cjs";
|
import "./clean.js";
|
||||||
import "./compress.cjs";
|
import "./compress.js";
|
||||||
import "./entry-html.cjs";
|
import "./entry-html.js";
|
||||||
import "./gather-static.cjs";
|
import "./gather-static.js";
|
||||||
import "./gen-icons-json.cjs";
|
import "./gen-icons-json.js";
|
||||||
import "./locale-data.cjs";
|
import "./locale-data.js";
|
||||||
import "./rollup.cjs";
|
import "./rollup.js";
|
||||||
import "./service-worker.cjs";
|
import "./service-worker.js";
|
||||||
import "./translations.cjs";
|
import "./translations.js";
|
||||||
import "./wds.cjs";
|
import "./wds.js";
|
||||||
import "./webpack.cjs";
|
import "./webpack.js";
|
||||||
|
|
||||||
gulp.task(
|
gulp.task(
|
||||||
"develop-app",
|
"develop-app",
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import gulp from "gulp";
|
import gulp from "gulp";
|
||||||
import env from "../env.cjs";
|
import env from "../env.cjs";
|
||||||
import "./clean.cjs";
|
import "./clean.js";
|
||||||
import "./entry-html.cjs";
|
import "./entry-html.js";
|
||||||
import "./gather-static.cjs";
|
import "./gather-static.js";
|
||||||
import "./rollup.cjs";
|
import "./rollup.js";
|
||||||
import "./service-worker.cjs";
|
import "./service-worker.js";
|
||||||
import "./translations.cjs";
|
import "./translations.js";
|
||||||
import "./webpack.cjs";
|
import "./webpack.js";
|
||||||
|
|
||||||
gulp.task(
|
gulp.task(
|
||||||
"develop-cast",
|
"develop-cast",
|
||||||
|
@ -1,37 +1,37 @@
|
|||||||
const del = import("del");
|
import { deleteSync } from "del";
|
||||||
const gulp = require("gulp");
|
import gulp from "gulp";
|
||||||
const paths = require("../paths.cjs");
|
import paths from "../paths.cjs";
|
||||||
require("./translations.cjs");
|
import "./translations.js";
|
||||||
|
|
||||||
gulp.task(
|
gulp.task(
|
||||||
"clean",
|
"clean",
|
||||||
gulp.parallel("clean-translations", async () =>
|
gulp.parallel("clean-translations", async () =>
|
||||||
(await del).deleteSync([paths.app_output_root, paths.build_dir])
|
deleteSync([paths.app_output_root, paths.build_dir])
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
gulp.task(
|
gulp.task(
|
||||||
"clean-demo",
|
"clean-demo",
|
||||||
gulp.parallel("clean-translations", async () =>
|
gulp.parallel("clean-translations", async () =>
|
||||||
(await del).deleteSync([paths.demo_output_root, paths.build_dir])
|
deleteSync([paths.demo_output_root, paths.build_dir])
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
gulp.task(
|
gulp.task(
|
||||||
"clean-cast",
|
"clean-cast",
|
||||||
gulp.parallel("clean-translations", async () =>
|
gulp.parallel("clean-translations", async () =>
|
||||||
(await del).deleteSync([paths.cast_output_root, paths.build_dir])
|
deleteSync([paths.cast_output_root, paths.build_dir])
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
gulp.task("clean-hassio", async () =>
|
gulp.task("clean-hassio", async () =>
|
||||||
(await del).deleteSync([paths.hassio_output_root, paths.build_dir])
|
deleteSync([paths.hassio_output_root, paths.build_dir])
|
||||||
);
|
);
|
||||||
|
|
||||||
gulp.task(
|
gulp.task(
|
||||||
"clean-gallery",
|
"clean-gallery",
|
||||||
gulp.parallel("clean-translations", async () =>
|
gulp.parallel("clean-translations", async () =>
|
||||||
(await del).deleteSync([
|
deleteSync([
|
||||||
paths.gallery_output_root,
|
paths.gallery_output_root,
|
||||||
paths.gallery_build,
|
paths.gallery_build,
|
||||||
paths.build_dir,
|
paths.build_dir,
|
@ -1,10 +1,10 @@
|
|||||||
// Tasks to compress
|
// Tasks to compress
|
||||||
|
|
||||||
const gulp = require("gulp");
|
import gulp from "gulp";
|
||||||
const zopfli = require("gulp-zopfli-green");
|
import zopfli from "gulp-zopfli-green";
|
||||||
const merge = require("merge-stream");
|
import merge from "merge-stream";
|
||||||
const path = require("path");
|
import path from "path";
|
||||||
const paths = require("../paths.cjs");
|
import paths from "../paths.cjs";
|
||||||
|
|
||||||
const zopfliOptions = { threshold: 150 };
|
const zopfliOptions = { threshold: 150 };
|
||||||
|
|
@ -1,13 +1,13 @@
|
|||||||
import gulp from "gulp";
|
import gulp from "gulp";
|
||||||
import env from "../env.cjs";
|
import env from "../env.cjs";
|
||||||
import "./clean.cjs";
|
import "./clean.js";
|
||||||
import "./entry-html.cjs";
|
import "./entry-html.js";
|
||||||
import "./gather-static.cjs";
|
import "./gather-static.js";
|
||||||
import "./gen-icons-json.cjs";
|
import "./gen-icons-json.js";
|
||||||
import "./rollup.cjs";
|
import "./rollup.js";
|
||||||
import "./service-worker.cjs";
|
import "./service-worker.js";
|
||||||
import "./translations.cjs";
|
import "./translations.js";
|
||||||
import "./webpack.cjs";
|
import "./webpack.js";
|
||||||
|
|
||||||
gulp.task(
|
gulp.task(
|
||||||
"develop-demo",
|
"develop-demo",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
const gulp = require("gulp");
|
import fs from "fs/promises";
|
||||||
const fs = require("fs/promises");
|
import gulp from "gulp";
|
||||||
const mapStream = require("map-stream");
|
import mapStream from "map-stream";
|
||||||
|
|
||||||
const inDirFrontend = "translations/frontend";
|
const inDirFrontend = "translations/frontend";
|
||||||
const inDirBackend = "translations/backend";
|
const inDirBackend = "translations/backend";
|
@ -1,12 +1,13 @@
|
|||||||
// Tasks to generate entry HTML
|
// Tasks to generate entry HTML
|
||||||
const gulp = require("gulp");
|
|
||||||
const fs = require("fs-extra");
|
import fs from "fs-extra";
|
||||||
const path = require("path");
|
import gulp from "gulp";
|
||||||
const template = require("lodash.template");
|
import { minify } from "html-minifier-terser";
|
||||||
const { minify } = require("html-minifier-terser");
|
import template from "lodash.template";
|
||||||
const paths = require("../paths.cjs");
|
import path from "path";
|
||||||
const env = require("../env.cjs");
|
import { htmlMinifierOptions, terserOptions } from "../bundle.cjs";
|
||||||
const { htmlMinifierOptions, terserOptions } = require("../bundle.cjs");
|
import env from "../env.cjs";
|
||||||
|
import paths from "../paths.cjs";
|
||||||
|
|
||||||
const renderTemplate = (templateFile, data = {}) => {
|
const renderTemplate = (templateFile, data = {}) => {
|
||||||
const compiled = template(
|
const compiled = template(
|
||||||
@ -89,9 +90,11 @@ const genPagesProdTask =
|
|||||||
inputSub = "src/html"
|
inputSub = "src/html"
|
||||||
) =>
|
) =>
|
||||||
async () => {
|
async () => {
|
||||||
const latestManifest = require(path.resolve(outputLatest, "manifest.json"));
|
const latestManifest = fs.readJsonSync(
|
||||||
|
path.resolve(outputLatest, "manifest.json")
|
||||||
|
);
|
||||||
const es5Manifest = outputES5
|
const es5Manifest = outputES5
|
||||||
? require(path.resolve(outputES5, "manifest.json"))
|
? fs.readJsonSync(path.resolve(outputES5, "manifest.json"))
|
||||||
: {};
|
: {};
|
||||||
const minifiedHTML = [];
|
const minifiedHTML = [];
|
||||||
for (const [page, entries] of Object.entries(pageEntries)) {
|
for (const [page, entries] of Object.entries(pageEntries)) {
|
@ -1,15 +1,15 @@
|
|||||||
// Task to download the latest Lokalise translations from the nightly workflow artifacts
|
// Task to download the latest Lokalise translations from the nightly workflow artifacts
|
||||||
|
|
||||||
const del = import("del");
|
import { createOAuthDeviceAuth } from "@octokit/auth-oauth-device";
|
||||||
const fs = require("fs/promises");
|
import { retry } from "@octokit/plugin-retry";
|
||||||
const path = require("path");
|
import { Octokit } from "@octokit/rest";
|
||||||
const process = require("process");
|
import { deleteAsync } from "del";
|
||||||
const gulp = require("gulp");
|
import { mkdir, readFile, writeFile } from "fs/promises";
|
||||||
const jszip = require("jszip");
|
import gulp from "gulp";
|
||||||
const tar = require("tar");
|
import jszip from "jszip";
|
||||||
const { Octokit } = require("@octokit/rest");
|
import path from "path";
|
||||||
const { retry } = require("@octokit/plugin-retry");
|
import process from "process";
|
||||||
const { createOAuthDeviceAuth } = require("@octokit/auth-oauth-device");
|
import tar from "tar";
|
||||||
|
|
||||||
const MAX_AGE = 24; // hours
|
const MAX_AGE = 24; // hours
|
||||||
const OWNER = "home-assistant";
|
const OWNER = "home-assistant";
|
||||||
@ -38,7 +38,7 @@ gulp.task("fetch-nightly-translations", async function () {
|
|||||||
// and stop if they are not old enough
|
// and stop if they are not old enough
|
||||||
let currentArtifact;
|
let currentArtifact;
|
||||||
try {
|
try {
|
||||||
currentArtifact = JSON.parse(await fs.readFile(ARTIFACT_FILE, "utf-8"));
|
currentArtifact = JSON.parse(await readFile(ARTIFACT_FILE, "utf-8"));
|
||||||
const currentAge =
|
const currentAge =
|
||||||
(Date.now() - Date.parse(currentArtifact.created_at)) / 3600000;
|
(Date.now() - Date.parse(currentArtifact.created_at)) / 3600000;
|
||||||
if (currentAge < MAX_AGE) {
|
if (currentAge < MAX_AGE) {
|
||||||
@ -53,7 +53,7 @@ gulp.task("fetch-nightly-translations", async function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// To store file writing promises
|
// To store file writing promises
|
||||||
const createExtractDir = fs.mkdir(EXTRACT_DIR, { recursive: true });
|
const createExtractDir = mkdir(EXTRACT_DIR, { recursive: true });
|
||||||
const writings = [];
|
const writings = [];
|
||||||
|
|
||||||
// Authenticate to GitHub using GitHub action token if it exists,
|
// Authenticate to GitHub using GitHub action token if it exists,
|
||||||
@ -63,7 +63,7 @@ gulp.task("fetch-nightly-translations", async function () {
|
|||||||
tokenAuth = { token: process.env.GITHUB_TOKEN };
|
tokenAuth = { token: process.env.GITHUB_TOKEN };
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
tokenAuth = JSON.parse(await fs.readFile(TOKEN_FILE, "utf-8"));
|
tokenAuth = JSON.parse(await readFile(TOKEN_FILE, "utf-8"));
|
||||||
} catch {
|
} catch {
|
||||||
if (!allowTokenSetup) {
|
if (!allowTokenSetup) {
|
||||||
console.log("No token found so build wil continue with English only");
|
console.log("No token found so build wil continue with English only");
|
||||||
@ -88,7 +88,7 @@ gulp.task("fetch-nightly-translations", async function () {
|
|||||||
tokenAuth = await auth({ type: "oauth" });
|
tokenAuth = await auth({ type: "oauth" });
|
||||||
writings.push(
|
writings.push(
|
||||||
createExtractDir.then(
|
createExtractDir.then(
|
||||||
fs.writeFile(TOKEN_FILE, JSON.stringify(tokenAuth, null, 2))
|
writeFile(TOKEN_FILE, JSON.stringify(tokenAuth, null, 2))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -132,17 +132,13 @@ gulp.task("fetch-nightly-translations", async function () {
|
|||||||
}
|
}
|
||||||
writings.push(
|
writings.push(
|
||||||
createExtractDir.then(
|
createExtractDir.then(
|
||||||
fs.writeFile(ARTIFACT_FILE, JSON.stringify(latestArtifact, null, 2))
|
writeFile(ARTIFACT_FILE, JSON.stringify(latestArtifact, null, 2))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Remove the current translations
|
// Remove the current translations
|
||||||
const deleteCurrent = Promise.all(writings).then(
|
const deleteCurrent = Promise.all(writings).then(
|
||||||
(await del).deleteAsync([
|
deleteAsync([`${EXTRACT_DIR}/*`, `!${ARTIFACT_FILE}`, `!${TOKEN_FILE}`])
|
||||||
`${EXTRACT_DIR}/*`,
|
|
||||||
`!${ARTIFACT_FILE}`,
|
|
||||||
`!${TOKEN_FILE}`,
|
|
||||||
])
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Get the download URL and follow the redirect to download (stored as ArrayBuffer)
|
// Get the download URL and follow the redirect to download (stored as ArrayBuffer)
|
@ -6,14 +6,14 @@ import { marked } from "marked";
|
|||||||
import path from "path";
|
import path from "path";
|
||||||
import env from "../env.cjs";
|
import env from "../env.cjs";
|
||||||
import paths from "../paths.cjs";
|
import paths from "../paths.cjs";
|
||||||
import "./clean.cjs";
|
import "./clean.js";
|
||||||
import "./entry-html.cjs";
|
import "./entry-html.js";
|
||||||
import "./gather-static.cjs";
|
import "./gather-static.js";
|
||||||
import "./gen-icons-json.cjs";
|
import "./gen-icons-json.js";
|
||||||
import "./rollup.cjs";
|
import "./rollup.js";
|
||||||
import "./service-worker.cjs";
|
import "./service-worker.js";
|
||||||
import "./translations.cjs";
|
import "./translations.js";
|
||||||
import "./webpack.cjs";
|
import "./webpack.js";
|
||||||
|
|
||||||
gulp.task("gather-gallery-pages", async function gatherPages() {
|
gulp.task("gather-gallery-pages", async function gatherPages() {
|
||||||
const pageDir = path.resolve(paths.gallery_dir, "src/pages");
|
const pageDir = path.resolve(paths.gallery_dir, "src/pages");
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
// Gulp task to gather all static files.
|
// Gulp task to gather all static files.
|
||||||
|
|
||||||
const gulp = require("gulp");
|
import fs from "fs-extra";
|
||||||
const path = require("path");
|
import gulp from "gulp";
|
||||||
const fs = require("fs-extra");
|
import path from "path";
|
||||||
const paths = require("../paths.cjs");
|
import paths from "../paths.cjs";
|
||||||
|
|
||||||
const npmPath = (...parts) =>
|
const npmPath = (...parts) =>
|
||||||
path.resolve(paths.polymer_dir, "node_modules", ...parts);
|
path.resolve(paths.polymer_dir, "node_modules", ...parts);
|
@ -1,17 +1,15 @@
|
|||||||
const gulp = require("gulp");
|
import fs from "fs";
|
||||||
const path = require("path");
|
import gulp from "gulp";
|
||||||
const fs = require("fs");
|
import hash from "object-hash";
|
||||||
const hash = require("object-hash");
|
import path from "path";
|
||||||
|
import paths from "../paths.cjs";
|
||||||
|
|
||||||
const ICON_PACKAGE_PATH = path.resolve(
|
const ICON_PACKAGE_PATH = path.resolve("node_modules/@mdi/svg/");
|
||||||
__dirname,
|
|
||||||
"../../node_modules/@mdi/svg/"
|
|
||||||
);
|
|
||||||
const META_PATH = path.resolve(ICON_PACKAGE_PATH, "meta.json");
|
const META_PATH = path.resolve(ICON_PACKAGE_PATH, "meta.json");
|
||||||
const PACKAGE_PATH = path.resolve(ICON_PACKAGE_PATH, "package.json");
|
const PACKAGE_PATH = path.resolve(ICON_PACKAGE_PATH, "package.json");
|
||||||
const ICON_PATH = path.resolve(ICON_PACKAGE_PATH, "svg");
|
const ICON_PATH = path.resolve(ICON_PACKAGE_PATH, "svg");
|
||||||
const OUTPUT_DIR = path.resolve(__dirname, "../../build/mdi");
|
const OUTPUT_DIR = path.resolve(paths.build_dir, "mdi");
|
||||||
const REMOVED_ICONS_PATH = path.resolve(__dirname, "../removedIcons.json");
|
const REMOVED_ICONS_PATH = new URL("../removedIcons.json", import.meta.url);
|
||||||
|
|
||||||
const encoding = "utf8";
|
const encoding = "utf8";
|
||||||
|
|
@ -1,13 +1,13 @@
|
|||||||
import gulp from "gulp";
|
import gulp from "gulp";
|
||||||
import env from "../env.cjs";
|
import env from "../env.cjs";
|
||||||
import "./clean.cjs";
|
import "./clean.js";
|
||||||
import "./compress.cjs";
|
import "./compress.js";
|
||||||
import "./entry-html.cjs";
|
import "./entry-html.js";
|
||||||
import "./gather-static.cjs";
|
import "./gather-static.js";
|
||||||
import "./gen-icons-json.cjs";
|
import "./gen-icons-json.js";
|
||||||
import "./rollup.cjs";
|
import "./rollup.js";
|
||||||
import "./translations.cjs";
|
import "./translations.js";
|
||||||
import "./webpack.cjs";
|
import "./webpack.js";
|
||||||
|
|
||||||
gulp.task(
|
gulp.task(
|
||||||
"develop-hassio",
|
"develop-hassio",
|
||||||
|
@ -1,18 +1,15 @@
|
|||||||
const del = import("del");
|
import { deleteSync } from "del";
|
||||||
const path = require("path");
|
import fs from "fs";
|
||||||
const gulp = require("gulp");
|
import gulp from "gulp";
|
||||||
const fs = require("fs");
|
import path from "path";
|
||||||
const paths = require("../paths.cjs");
|
import paths from "../paths.cjs";
|
||||||
|
|
||||||
const outDir = "build/locale-data";
|
const outDir = "build/locale-data";
|
||||||
|
|
||||||
gulp.task("clean-locale-data", async () => (await del).deleteSync([outDir]));
|
gulp.task("clean-locale-data", async () => deleteSync([outDir]));
|
||||||
|
|
||||||
gulp.task("ensure-locale-data-build-dir", (done) => {
|
gulp.task("ensure-locale-data-build-dir", async () => {
|
||||||
if (!fs.existsSync(outDir)) {
|
fs.mkdirSync(outDir, { recursive: true });
|
||||||
fs.mkdirSync(outDir, { recursive: true });
|
|
||||||
}
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const modules = {
|
const modules = {
|
||||||
@ -31,11 +28,14 @@ gulp.task("create-locale-data", (done) => {
|
|||||||
Object.entries(modules).forEach(([module, className]) => {
|
Object.entries(modules).forEach(([module, className]) => {
|
||||||
Object.keys(translationMeta).forEach((lang) => {
|
Object.keys(translationMeta).forEach((lang) => {
|
||||||
try {
|
try {
|
||||||
const localeData = String(
|
const localeData = fs
|
||||||
fs.readFileSync(
|
.readFileSync(
|
||||||
require.resolve(`@formatjs/${module}/locale-data/${lang}.js`)
|
path.resolve(
|
||||||
|
paths.polymer_dir,
|
||||||
|
`node_modules/@formatjs/${module}/locale-data/${lang}.js`
|
||||||
|
),
|
||||||
|
"utf-8"
|
||||||
)
|
)
|
||||||
)
|
|
||||||
.replace(
|
.replace(
|
||||||
new RegExp(
|
new RegExp(
|
||||||
`\\/\\*\\s*@generated\\s*\\*\\/\\s*\\/\\/\\s*prettier-ignore\\s*if\\s*\\(Intl\\.${className}\\s*&&\\s*typeof\\s*Intl\\.${className}\\.__addLocaleData\\s*===\\s*'function'\\)\\s*{\\s*Intl\\.${className}\\.__addLocaleData\\(`,
|
`\\/\\*\\s*@generated\\s*\\*\\/\\s*\\/\\/\\s*prettier-ignore\\s*if\\s*\\(Intl\\.${className}\\s*&&\\s*typeof\\s*Intl\\.${className}\\.__addLocaleData\\s*===\\s*'function'\\)\\s*{\\s*Intl\\.${className}\\.__addLocaleData\\(`,
|
||||||
@ -46,15 +46,13 @@ gulp.task("create-locale-data", (done) => {
|
|||||||
.replace(/\)\s*}/im, "");
|
.replace(/\)\s*}/im, "");
|
||||||
// make sure we have valid JSON
|
// make sure we have valid JSON
|
||||||
JSON.parse(localeData);
|
JSON.parse(localeData);
|
||||||
if (!fs.existsSync(path.join(outDir, module))) {
|
fs.mkdirSync(path.join(outDir, module), { recursive: true });
|
||||||
fs.mkdirSync(path.join(outDir, module), { recursive: true });
|
|
||||||
}
|
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(
|
||||||
path.join(outDir, `${module}/${lang}.json`),
|
path.join(outDir, `${module}/${lang}.json`),
|
||||||
localeData
|
localeData
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e.code !== "MODULE_NOT_FOUND") {
|
if (e.code !== "ENOENT") {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,13 +1,14 @@
|
|||||||
// Tasks to run Rollup
|
// Tasks to run Rollup
|
||||||
const path = require("path");
|
|
||||||
const gulp = require("gulp");
|
import log from "fancy-log";
|
||||||
const rollup = require("rollup");
|
import gulp from "gulp";
|
||||||
const handler = require("serve-handler");
|
import http from "http";
|
||||||
const http = require("http");
|
import open from "open";
|
||||||
const log = require("fancy-log");
|
import path from "path";
|
||||||
const open = require("open");
|
import { rollup } from "rollup";
|
||||||
const rollupConfig = require("../rollup.cjs");
|
import handler from "serve-handler";
|
||||||
const paths = require("../paths.cjs");
|
import paths from "../paths.cjs";
|
||||||
|
import rollupConfig from "../rollup.cjs";
|
||||||
|
|
||||||
const bothBuilds = (createConfigFunc, params) =>
|
const bothBuilds = (createConfigFunc, params) =>
|
||||||
gulp.series(
|
gulp.series(
|
@ -1,11 +1,12 @@
|
|||||||
// Generate service worker.
|
// Generate service worker.
|
||||||
// Based on manifest, create a file with the content as service_worker.js
|
// Based on manifest, create a file with the content as service_worker.js
|
||||||
const gulp = require("gulp");
|
|
||||||
const path = require("path");
|
import fs from "fs-extra";
|
||||||
const fs = require("fs-extra");
|
import gulp from "gulp";
|
||||||
const workboxBuild = require("workbox-build");
|
import path from "path";
|
||||||
const sourceMapUrl = require("source-map-url");
|
import sourceMapUrl from "source-map-url";
|
||||||
const paths = require("../paths.cjs");
|
import workboxBuild from "workbox-build";
|
||||||
|
import paths from "../paths.cjs";
|
||||||
|
|
||||||
const swDest = path.resolve(paths.app_output_root, "service_worker.js");
|
const swDest = path.resolve(paths.app_output_root, "service_worker.js");
|
||||||
|
|
||||||
@ -28,10 +29,9 @@ self.addEventListener('install', (event) => {
|
|||||||
|
|
||||||
gulp.task("gen-service-worker-app-prod", async () => {
|
gulp.task("gen-service-worker-app-prod", async () => {
|
||||||
// Read bundled source file
|
// Read bundled source file
|
||||||
const bundleManifestLatest = require(path.resolve(
|
const bundleManifestLatest = fs.readJsonSync(
|
||||||
paths.app_output_latest,
|
path.resolve(paths.app_output_latest, "manifest.json")
|
||||||
"manifest.json"
|
);
|
||||||
));
|
|
||||||
let serviceWorkerContent = fs.readFileSync(
|
let serviceWorkerContent = fs.readFileSync(
|
||||||
paths.app_output_root + bundleManifestLatest["service_worker.js"],
|
paths.app_output_root + bundleManifestLatest["service_worker.js"],
|
||||||
"utf-8"
|
"utf-8"
|
||||||
@ -46,10 +46,9 @@ gulp.task("gen-service-worker-app-prod", async () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Remove ES5
|
// Remove ES5
|
||||||
const bundleManifestES5 = require(path.resolve(
|
const bundleManifestES5 = fs.readJsonSync(
|
||||||
paths.app_output_es5,
|
path.resolve(paths.app_output_es5, "manifest.json")
|
||||||
"manifest.json"
|
);
|
||||||
));
|
|
||||||
fs.removeSync(paths.app_output_root + bundleManifestES5["service_worker.js"]);
|
fs.removeSync(paths.app_output_root + bundleManifestES5["service_worker.js"]);
|
||||||
fs.removeSync(
|
fs.removeSync(
|
||||||
paths.app_output_root + bundleManifestES5["service_worker.js.map"]
|
paths.app_output_root + bundleManifestES5["service_worker.js.map"]
|
@ -1,19 +1,24 @@
|
|||||||
const del = import("del");
|
import { createHash } from "crypto";
|
||||||
const crypto = require("crypto");
|
import { deleteSync } from "del";
|
||||||
const path = require("path");
|
import {
|
||||||
const source = require("vinyl-source-stream");
|
mkdirSync,
|
||||||
const vinylBuffer = require("vinyl-buffer");
|
readdirSync,
|
||||||
const gulp = require("gulp");
|
readFileSync,
|
||||||
const fs = require("fs");
|
renameSync,
|
||||||
const flatmap = require("gulp-flatmap");
|
writeFile,
|
||||||
const merge = require("gulp-merge-json");
|
} from "fs";
|
||||||
const rename = require("gulp-rename");
|
import gulp from "gulp";
|
||||||
const transform = require("gulp-json-transform");
|
import flatmap from "gulp-flatmap";
|
||||||
const { mapFiles } = require("../util.cjs");
|
import transform from "gulp-json-transform";
|
||||||
const env = require("../env.cjs");
|
import merge from "gulp-merge-json";
|
||||||
const paths = require("../paths.cjs");
|
import rename from "gulp-rename";
|
||||||
|
import path from "path";
|
||||||
require("./fetch-nightly-translations.cjs");
|
import vinylBuffer from "vinyl-buffer";
|
||||||
|
import source from "vinyl-source-stream";
|
||||||
|
import env from "../env.cjs";
|
||||||
|
import paths from "../paths.cjs";
|
||||||
|
import { mapFiles } from "../util.cjs";
|
||||||
|
import "./fetch-nightly-translations.js";
|
||||||
|
|
||||||
const inFrontendDir = "translations/frontend";
|
const inFrontendDir = "translations/frontend";
|
||||||
const inBackendDir = "translations/backend";
|
const inBackendDir = "translations/backend";
|
||||||
@ -33,7 +38,12 @@ gulp.task(
|
|||||||
|
|
||||||
// Panel translations which should be split from the core translations.
|
// Panel translations which should be split from the core translations.
|
||||||
const TRANSLATION_FRAGMENTS = Object.keys(
|
const TRANSLATION_FRAGMENTS = Object.keys(
|
||||||
require("../../src/translations/en.json").ui.panel
|
JSON.parse(
|
||||||
|
readFileSync(
|
||||||
|
path.resolve(paths.polymer_dir, "src/translations/en.json"),
|
||||||
|
"utf-8"
|
||||||
|
)
|
||||||
|
).ui.panel
|
||||||
);
|
);
|
||||||
|
|
||||||
function recursiveFlatten(prefix, data) {
|
function recursiveFlatten(prefix, data) {
|
||||||
@ -120,17 +130,14 @@ function lokaliseTransform(data, original, file) {
|
|||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
gulp.task("clean-translations", async () => (await del).deleteSync([workDir]));
|
gulp.task("clean-translations", async () => deleteSync([workDir]));
|
||||||
|
|
||||||
gulp.task("ensure-translations-build-dir", (done) => {
|
gulp.task("ensure-translations-build-dir", async () => {
|
||||||
if (!fs.existsSync(workDir)) {
|
mkdirSync(workDir, { recursive: true });
|
||||||
fs.mkdirSync(workDir, { recursive: true });
|
|
||||||
}
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task("create-test-metadata", (cb) => {
|
gulp.task("create-test-metadata", (cb) => {
|
||||||
fs.writeFile(
|
writeFile(
|
||||||
workDir + "/testMetadata.json",
|
workDir + "/testMetadata.json",
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
test: {
|
test: {
|
||||||
@ -303,15 +310,14 @@ const fingerprints = {};
|
|||||||
|
|
||||||
gulp.task("build-translation-fingerprints", () => {
|
gulp.task("build-translation-fingerprints", () => {
|
||||||
// Fingerprint full file of each language
|
// Fingerprint full file of each language
|
||||||
const files = fs.readdirSync(fullDir);
|
const files = readdirSync(fullDir);
|
||||||
|
|
||||||
for (let i = 0; i < files.length; i++) {
|
for (let i = 0; i < files.length; i++) {
|
||||||
fingerprints[files[i].split(".")[0]] = {
|
fingerprints[files[i].split(".")[0]] = {
|
||||||
// In dev we create fake hashes
|
// In dev we create fake hashes
|
||||||
hash: env.isProdBuild()
|
hash: env.isProdBuild()
|
||||||
? crypto
|
? createHash("md5")
|
||||||
.createHash("md5")
|
.update(readFileSync(path.join(fullDir, files[i]), "utf-8"))
|
||||||
.update(fs.readFileSync(path.join(fullDir, files[i]), "utf-8"))
|
|
||||||
.digest("hex")
|
.digest("hex")
|
||||||
: "dev",
|
: "dev",
|
||||||
};
|
};
|
||||||
@ -327,7 +333,7 @@ gulp.task("build-translation-fingerprints", () => {
|
|||||||
throw new Error(`Unable to find hash for ${filename}`);
|
throw new Error(`Unable to find hash for ${filename}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
fs.renameSync(
|
renameSync(
|
||||||
filename,
|
filename,
|
||||||
`${parsed.dir}/${parsed.name}-${fingerprints[parsed.name].hash}${
|
`${parsed.dir}/${parsed.name}-${fingerprints[parsed.name].hash}${
|
||||||
parsed.ext
|
parsed.ext
|
@ -1,11 +0,0 @@
|
|||||||
// Tasks to run Rollup
|
|
||||||
const gulp = require("gulp");
|
|
||||||
const { startDevServer } = require("@web/dev-server");
|
|
||||||
|
|
||||||
gulp.task("wds-watch-app", () => {
|
|
||||||
startDevServer({
|
|
||||||
config: {
|
|
||||||
watch: true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
});
|
|
10
build-scripts/gulp/wds.js
Normal file
10
build-scripts/gulp/wds.js
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import gulp from "gulp";
|
||||||
|
import { startDevServer } from "@web/dev-server";
|
||||||
|
|
||||||
|
gulp.task("wds-watch-app", async () => {
|
||||||
|
startDevServer({
|
||||||
|
config: {
|
||||||
|
watch: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
@ -1,19 +1,20 @@
|
|||||||
// Tasks to run webpack.
|
// Tasks to run webpack.
|
||||||
const fs = require("fs");
|
|
||||||
const gulp = require("gulp");
|
import log from "fancy-log";
|
||||||
const webpack = require("webpack");
|
import fs from "fs";
|
||||||
const WebpackDevServer = require("webpack-dev-server");
|
import gulp from "gulp";
|
||||||
const log = require("fancy-log");
|
import path from "path";
|
||||||
const path = require("path");
|
import webpack from "webpack";
|
||||||
const env = require("../env.cjs");
|
import WebpackDevServer from "webpack-dev-server";
|
||||||
const paths = require("../paths.cjs");
|
import env from "../env.cjs";
|
||||||
const {
|
import paths from "../paths.cjs";
|
||||||
|
import {
|
||||||
createAppConfig,
|
createAppConfig,
|
||||||
createDemoConfig,
|
|
||||||
createCastConfig,
|
createCastConfig,
|
||||||
createHassioConfig,
|
createDemoConfig,
|
||||||
createGalleryConfig,
|
createGalleryConfig,
|
||||||
} = require("../webpack.cjs");
|
createHassioConfig,
|
||||||
|
} from "../webpack.cjs";
|
||||||
|
|
||||||
const bothBuilds = (createConfigFunc, params) => [
|
const bothBuilds = (createConfigFunc, params) => [
|
||||||
createConfigFunc({ ...params, latestBuild: true }),
|
createConfigFunc({ ...params, latestBuild: true }),
|
Loading…
x
Reference in New Issue
Block a user