mirror of
https://github.com/home-assistant/frontend.git
synced 2025-11-05 00:49:53 +00:00
Use tsx to run gulp
This commit is contained in:
@@ -1,57 +1,54 @@
|
||||
import { parallel, series, task } from "gulp";
|
||||
import { parallel, series } from "gulp";
|
||||
import { isStatsBuild, isTestBuild } from "../env.ts";
|
||||
import "./clean.ts";
|
||||
import "./compress.ts";
|
||||
import "./entry-html.ts";
|
||||
import "./gather-static.ts";
|
||||
import "./gen-icons-json.ts";
|
||||
import "./locale-data.ts";
|
||||
import "./rspack.ts";
|
||||
import "./service-worker.ts";
|
||||
import "./translations.ts";
|
||||
import { clean } from "./clean.ts";
|
||||
import { compressApp } from "./compress.ts";
|
||||
import { genPagesAppDev, genPagesAppProd } from "./entry-html.ts";
|
||||
import { copyStaticApp } from "./gather-static.ts";
|
||||
import { genIconsJson } from "./gen-icons-json.ts";
|
||||
import { buildLocaleData } from "./locale-data.ts";
|
||||
import { rspackProdApp, rspackWatchApp } from "./rspack.ts";
|
||||
import {
|
||||
genServiceWorkerAppDev,
|
||||
genServiceWorkerAppProd,
|
||||
} from "./service-worker.ts";
|
||||
import { buildTranslations } from "./translations.ts";
|
||||
|
||||
task(
|
||||
"develop-app",
|
||||
series(
|
||||
async () => {
|
||||
process.env.NODE_ENV = "development";
|
||||
},
|
||||
"clean",
|
||||
parallel(
|
||||
"gen-service-worker-app-dev",
|
||||
"gen-icons-json",
|
||||
"gen-pages-app-dev",
|
||||
"build-translations",
|
||||
"build-locale-data"
|
||||
),
|
||||
"copy-static-app",
|
||||
"rspack-watch-app"
|
||||
)
|
||||
// develop-app
|
||||
export const developApp = series(
|
||||
async () => {
|
||||
process.env.NODE_ENV = "development";
|
||||
},
|
||||
clean,
|
||||
parallel(
|
||||
genServiceWorkerAppDev,
|
||||
genIconsJson,
|
||||
genPagesAppDev,
|
||||
buildTranslations,
|
||||
buildLocaleData
|
||||
),
|
||||
copyStaticApp,
|
||||
rspackWatchApp
|
||||
);
|
||||
|
||||
task(
|
||||
"build-app",
|
||||
series(
|
||||
async () => {
|
||||
process.env.NODE_ENV = "production";
|
||||
},
|
||||
"clean",
|
||||
parallel("gen-icons-json", "build-translations", "build-locale-data"),
|
||||
"copy-static-app",
|
||||
"rspack-prod-app",
|
||||
parallel("gen-pages-app-prod", "gen-service-worker-app-prod"),
|
||||
// Don't compress running tests
|
||||
...(isTestBuild() || isStatsBuild() ? [] : ["compress-app"])
|
||||
)
|
||||
// build-app
|
||||
export const buildApp = series(
|
||||
async () => {
|
||||
process.env.NODE_ENV = "production";
|
||||
},
|
||||
clean,
|
||||
parallel(genIconsJson, buildTranslations, buildLocaleData),
|
||||
copyStaticApp,
|
||||
rspackProdApp,
|
||||
parallel(genPagesAppProd, genServiceWorkerAppProd),
|
||||
// Don't compress running tests
|
||||
...(isTestBuild() || isStatsBuild() ? [] : [compressApp])
|
||||
);
|
||||
|
||||
task(
|
||||
"analyze-app",
|
||||
series(
|
||||
async () => {
|
||||
process.env.STATS = "1";
|
||||
},
|
||||
"clean",
|
||||
"rspack-prod-app"
|
||||
)
|
||||
// analyze-app
|
||||
export const analyzeApp = series(
|
||||
async () => {
|
||||
process.env.STATS = "1";
|
||||
},
|
||||
clean,
|
||||
rspackProdApp
|
||||
);
|
||||
|
||||
@@ -1,37 +1,38 @@
|
||||
import { parallel, series, task } from "gulp";
|
||||
import "./clean.ts";
|
||||
import "./entry-html.ts";
|
||||
import "./gather-static.ts";
|
||||
import "./rspack.ts";
|
||||
import { parallel, series } from "gulp";
|
||||
import { cleanCast } from "./clean.ts";
|
||||
import { genPagesCastDev, genPagesCastProd } from "./entry-html.ts";
|
||||
import { copyStaticCast } from "./gather-static.ts";
|
||||
import { genIconsJson } from "./gen-icons-json.ts";
|
||||
import { buildLocaleData } from "./locale-data.ts";
|
||||
import { rspackDevServerCast, rspackProdCast } from "./rspack.ts";
|
||||
import "./service-worker.ts";
|
||||
import "./translations.ts";
|
||||
import {
|
||||
buildTranslations,
|
||||
translationsEnableMergeBackend,
|
||||
} from "./translations.ts";
|
||||
|
||||
task(
|
||||
"develop-cast",
|
||||
series(
|
||||
async () => {
|
||||
process.env.NODE_ENV = "development";
|
||||
},
|
||||
"clean-cast",
|
||||
"translations-enable-merge-backend",
|
||||
parallel("gen-icons-json", "build-translations", "build-locale-data"),
|
||||
"copy-static-cast",
|
||||
"gen-pages-cast-dev",
|
||||
"rspack-dev-server-cast"
|
||||
)
|
||||
// develop-cast
|
||||
export const developCast = series(
|
||||
async () => {
|
||||
process.env.NODE_ENV = "development";
|
||||
},
|
||||
cleanCast,
|
||||
translationsEnableMergeBackend,
|
||||
parallel(genIconsJson, buildTranslations, buildLocaleData),
|
||||
copyStaticCast,
|
||||
genPagesCastDev,
|
||||
rspackDevServerCast
|
||||
);
|
||||
|
||||
task(
|
||||
"build-cast",
|
||||
series(
|
||||
async () => {
|
||||
process.env.NODE_ENV = "production";
|
||||
},
|
||||
"clean-cast",
|
||||
"translations-enable-merge-backend",
|
||||
parallel("gen-icons-json", "build-translations", "build-locale-data"),
|
||||
"copy-static-cast",
|
||||
"rspack-prod-cast",
|
||||
"gen-pages-cast-prod"
|
||||
)
|
||||
// build-cast
|
||||
export const buildCast = series(
|
||||
async () => {
|
||||
process.env.NODE_ENV = "production";
|
||||
},
|
||||
cleanCast,
|
||||
translationsEnableMergeBackend,
|
||||
parallel(genIconsJson, buildTranslations, buildLocaleData),
|
||||
copyStaticCast,
|
||||
rspackProdCast,
|
||||
genPagesCastProd
|
||||
);
|
||||
|
||||
@@ -1,51 +1,31 @@
|
||||
import { deleteSync } from "del";
|
||||
import { parallel, task } from "gulp";
|
||||
import { parallel } from "gulp";
|
||||
import paths from "../paths.ts";
|
||||
import "./translations.ts";
|
||||
import { cleanTranslations } from "./translations.ts";
|
||||
|
||||
task(
|
||||
"clean",
|
||||
parallel("clean-translations", async () =>
|
||||
deleteSync([paths.app_output_root, paths.build_dir])
|
||||
)
|
||||
export const clean = parallel(cleanTranslations, async () =>
|
||||
deleteSync([paths.app_output_root, paths.build_dir])
|
||||
);
|
||||
|
||||
task(
|
||||
"clean-demo",
|
||||
parallel("clean-translations", async () =>
|
||||
deleteSync([paths.demo_output_root, paths.build_dir])
|
||||
)
|
||||
export const cleanDemo = parallel(cleanTranslations, async () =>
|
||||
deleteSync([paths.demo_output_root, paths.build_dir])
|
||||
);
|
||||
|
||||
task(
|
||||
"clean-cast",
|
||||
parallel("clean-translations", async () =>
|
||||
deleteSync([paths.cast_output_root, paths.build_dir])
|
||||
)
|
||||
export const cleanCast = parallel(cleanTranslations, async () =>
|
||||
deleteSync([paths.cast_output_root, paths.build_dir])
|
||||
);
|
||||
|
||||
task("clean-hassio", async () =>
|
||||
deleteSync([paths.hassio_output_root, paths.build_dir])
|
||||
export const cleanHassio = async () =>
|
||||
deleteSync([paths.hassio_output_root, paths.build_dir]);
|
||||
|
||||
export const cleanGallery = parallel(cleanTranslations, async () =>
|
||||
deleteSync([paths.gallery_output_root, paths.gallery_build, paths.build_dir])
|
||||
);
|
||||
|
||||
task(
|
||||
"clean-gallery",
|
||||
parallel("clean-translations", async () =>
|
||||
deleteSync([
|
||||
paths.gallery_output_root,
|
||||
paths.gallery_build,
|
||||
paths.build_dir,
|
||||
])
|
||||
)
|
||||
);
|
||||
|
||||
task(
|
||||
"clean-landing-page",
|
||||
parallel("clean-translations", async () =>
|
||||
deleteSync([
|
||||
paths.landingPage_output_root,
|
||||
paths.landingPage_build,
|
||||
paths.build_dir,
|
||||
])
|
||||
)
|
||||
export const cleanLandingPage = parallel(cleanTranslations, async () =>
|
||||
deleteSync([
|
||||
paths.landingPage_output_root,
|
||||
paths.landingPage_build,
|
||||
paths.build_dir,
|
||||
])
|
||||
);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Tasks to compress
|
||||
|
||||
import { dest, parallel, src, task } from "gulp";
|
||||
import { dest, parallel, src } from "gulp";
|
||||
import brotli from "gulp-brotli";
|
||||
import zopfli from "gulp-zopfli-green";
|
||||
import { constants } from "node:zlib";
|
||||
@@ -64,21 +64,16 @@ const compressHassioOtherBrotli = () =>
|
||||
const compressHassioOtherZopfli = () =>
|
||||
compressOther(paths.hassio_output_root, paths.hassio_output_latest, "zopfli");
|
||||
|
||||
task(
|
||||
"compress-app",
|
||||
parallel(
|
||||
compressAppModernBrotli,
|
||||
compressAppOtherBrotli,
|
||||
compressAppModernZopfli,
|
||||
compressAppOtherZopfli
|
||||
)
|
||||
export const compressApp = parallel(
|
||||
compressAppModernBrotli,
|
||||
compressAppOtherBrotli,
|
||||
compressAppModernZopfli,
|
||||
compressAppOtherZopfli
|
||||
);
|
||||
task(
|
||||
"compress-hassio",
|
||||
parallel(
|
||||
compressHassioModernBrotli,
|
||||
compressHassioOtherBrotli,
|
||||
compressHassioModernZopfli,
|
||||
compressHassioOtherZopfli
|
||||
)
|
||||
|
||||
export const compressHassio = parallel(
|
||||
compressHassioModernBrotli,
|
||||
compressHassioOtherBrotli,
|
||||
compressHassioModernZopfli,
|
||||
compressHassioOtherZopfli
|
||||
);
|
||||
|
||||
@@ -1,54 +1,47 @@
|
||||
import { parallel, series, task } from "gulp";
|
||||
import "./clean.ts";
|
||||
import "./entry-html.ts";
|
||||
import "./gather-static.ts";
|
||||
import "./gen-icons-json.ts";
|
||||
import "./rspack.ts";
|
||||
import { parallel, series } from "gulp";
|
||||
import { clean, cleanDemo } from "./clean.ts";
|
||||
import { genPagesDemoDev, genPagesDemoProd } from "./entry-html.ts";
|
||||
import { copyStaticDemo } from "./gather-static.ts";
|
||||
import { genIconsJson } from "./gen-icons-json.ts";
|
||||
import { buildLocaleData } from "./locale-data.ts";
|
||||
import { rspackDevServerDemo, rspackProdDemo } from "./rspack.ts";
|
||||
import "./service-worker.ts";
|
||||
import "./translations.ts";
|
||||
import {
|
||||
buildTranslations,
|
||||
translationsEnableMergeBackend,
|
||||
} from "./translations.ts";
|
||||
|
||||
task(
|
||||
"develop-demo",
|
||||
series(
|
||||
async function setEnv() {
|
||||
process.env.NODE_ENV = "development";
|
||||
},
|
||||
"clean-demo",
|
||||
"translations-enable-merge-backend",
|
||||
parallel(
|
||||
"gen-icons-json",
|
||||
"gen-pages-demo-dev",
|
||||
"build-translations",
|
||||
"build-locale-data"
|
||||
),
|
||||
"copy-static-demo",
|
||||
"rspack-dev-server-demo"
|
||||
)
|
||||
// develop-demo
|
||||
export const developDemo = series(
|
||||
async function setEnv() {
|
||||
process.env.NODE_ENV = "development";
|
||||
},
|
||||
cleanDemo,
|
||||
translationsEnableMergeBackend,
|
||||
parallel(genIconsJson, genPagesDemoDev, buildTranslations, buildLocaleData),
|
||||
copyStaticDemo,
|
||||
rspackDevServerDemo
|
||||
);
|
||||
|
||||
task(
|
||||
"build-demo",
|
||||
series(
|
||||
async function setEnv() {
|
||||
process.env.NODE_ENV = "production";
|
||||
},
|
||||
"clean-demo",
|
||||
// Cast needs to be backwards compatible and older HA has no translations
|
||||
"translations-enable-merge-backend",
|
||||
parallel("gen-icons-json", "build-translations", "build-locale-data"),
|
||||
"copy-static-demo",
|
||||
"rspack-prod-demo",
|
||||
"gen-pages-demo-prod"
|
||||
)
|
||||
// build-demo
|
||||
export const buildDemo = series(
|
||||
async function setEnv() {
|
||||
process.env.NODE_ENV = "production";
|
||||
},
|
||||
cleanDemo,
|
||||
// Cast needs to be backwards compatible and older HA has no translations
|
||||
translationsEnableMergeBackend,
|
||||
parallel(genIconsJson, buildTranslations, buildLocaleData),
|
||||
copyStaticDemo,
|
||||
rspackProdDemo,
|
||||
genPagesDemoProd
|
||||
);
|
||||
|
||||
task(
|
||||
"analyze-demo",
|
||||
series(
|
||||
async function setEnv() {
|
||||
process.env.STATS = "1";
|
||||
},
|
||||
"clean",
|
||||
"rspack-prod-demo"
|
||||
)
|
||||
// analyze-demo
|
||||
export const analyzeDemo = series(
|
||||
async function setEnv() {
|
||||
process.env.STATS = "1";
|
||||
},
|
||||
clean,
|
||||
rspackProdDemo
|
||||
);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { LokaliseApi } from "@lokalise/node-api";
|
||||
import fs from "node:fs/promises";
|
||||
import { dest, series, src, task } from "gulp";
|
||||
import { dest, series, src } from "gulp";
|
||||
import transform from "gulp-json-transform";
|
||||
import JSZip from "jszip";
|
||||
import mapStream from "map-stream";
|
||||
import fs from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
|
||||
const inDir = "translations";
|
||||
@@ -12,11 +12,14 @@ const inDirBackend = `${inDir}/backend`;
|
||||
const srcMeta = "src/translations/translationMetadata.json";
|
||||
const encoding = "utf8";
|
||||
|
||||
function hasHtml(data) {
|
||||
return /<\S*>/i.test(data);
|
||||
}
|
||||
const hasHtml = (data) => /<\S*>/i.test(data);
|
||||
|
||||
function recursiveCheckHasHtml(file, data, errors: string[], recKey?: string) {
|
||||
const recursiveCheckHasHtml = (
|
||||
file,
|
||||
data,
|
||||
errors: string[],
|
||||
recKey?: string
|
||||
) => {
|
||||
Object.keys(data).forEach(function (key) {
|
||||
if (typeof data[key] === "object") {
|
||||
const nextRecKey = recKey ? `${recKey}.${key}` : key;
|
||||
@@ -25,9 +28,9 @@ function recursiveCheckHasHtml(file, data, errors: string[], recKey?: string) {
|
||||
errors.push(`HTML found in ${file.path} at key ${recKey}.${key}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
function checkHtml() {
|
||||
const checkHtml = () => {
|
||||
const errors = [];
|
||||
|
||||
return mapStream(function (file, cb) {
|
||||
@@ -44,9 +47,9 @@ function checkHtml() {
|
||||
}
|
||||
cb(error, file);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
function convertBackendTranslations(data, _file) {
|
||||
const convertBackendTranslationsTransform = (data, _file) => {
|
||||
const output = { component: {} };
|
||||
if (!data.component) {
|
||||
return output;
|
||||
@@ -62,21 +65,19 @@ function convertBackendTranslations(data, _file) {
|
||||
});
|
||||
});
|
||||
return output;
|
||||
}
|
||||
};
|
||||
|
||||
task("convert-backend-translations", function () {
|
||||
return src([`${inDirBackend}/*.json`])
|
||||
.pipe(transform((data, file) => convertBackendTranslations(data, file)))
|
||||
const convertBackendTranslations = () =>
|
||||
src([`${inDirBackend}/*.json`])
|
||||
.pipe(
|
||||
transform((data, file) => convertBackendTranslationsTransform(data, file))
|
||||
)
|
||||
.pipe(dest(inDirBackend));
|
||||
});
|
||||
|
||||
task("check-translations-html", function () {
|
||||
return src([`${inDirFrontend}/*.json`, `${inDirBackend}/*.json`]).pipe(
|
||||
checkHtml()
|
||||
);
|
||||
});
|
||||
const checkTranslationsHtml = () =>
|
||||
src([`${inDirFrontend}/*.json`, `${inDirBackend}/*.json`]).pipe(checkHtml());
|
||||
|
||||
task("check-all-files-exist", async function () {
|
||||
const checkAllFilesExist = async () => {
|
||||
const file = await fs.readFile(srcMeta, { encoding });
|
||||
const meta = JSON.parse(file);
|
||||
const writings: Promise<void>[] = [];
|
||||
@@ -91,14 +92,14 @@ task("check-all-files-exist", async function () {
|
||||
);
|
||||
});
|
||||
await Promise.allSettled(writings);
|
||||
});
|
||||
};
|
||||
|
||||
const lokaliseProjects = {
|
||||
backend: "130246255a974bd3b5e8a1.51616605",
|
||||
frontend: "3420425759f6d6d241f598.13594006",
|
||||
};
|
||||
|
||||
task("fetch-lokalise", async function () {
|
||||
const fetchLokalise = async () => {
|
||||
let apiKey;
|
||||
try {
|
||||
apiKey =
|
||||
@@ -167,14 +168,11 @@ task("fetch-lokalise", async function () {
|
||||
})
|
||||
)
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
task(
|
||||
"download-translations",
|
||||
series(
|
||||
"fetch-lokalise",
|
||||
"convert-backend-translations",
|
||||
"check-translations-html",
|
||||
"check-all-files-exist"
|
||||
)
|
||||
export const downloadTranslations = series(
|
||||
fetchLokalise,
|
||||
convertBackendTranslations,
|
||||
checkTranslationsHtml,
|
||||
checkAllFilesExist
|
||||
);
|
||||
|
||||
@@ -6,7 +6,6 @@ import {
|
||||
getPreUserAgentRegexes,
|
||||
} from "browserslist-useragent-regexp";
|
||||
import fs from "fs-extra";
|
||||
import { task } from "gulp";
|
||||
import { minify } from "html-minifier-terser";
|
||||
import template from "lodash.template";
|
||||
import { dirname, extname, resolve } from "node:path";
|
||||
@@ -171,20 +170,18 @@ const APP_PAGE_ENTRIES = {
|
||||
"index.html": ["core", "app"],
|
||||
};
|
||||
|
||||
task(
|
||||
"gen-pages-app-dev",
|
||||
genPagesDevTask(APP_PAGE_ENTRIES, paths.root_dir, paths.app_output_root)
|
||||
export const genPagesAppDev = genPagesDevTask(
|
||||
APP_PAGE_ENTRIES,
|
||||
paths.root_dir,
|
||||
paths.app_output_root
|
||||
);
|
||||
|
||||
task(
|
||||
"gen-pages-app-prod",
|
||||
genPagesProdTask(
|
||||
APP_PAGE_ENTRIES,
|
||||
paths.root_dir,
|
||||
paths.app_output_root,
|
||||
paths.app_output_latest,
|
||||
paths.app_output_es5
|
||||
)
|
||||
export const genPagesAppProd = genPagesProdTask(
|
||||
APP_PAGE_ENTRIES,
|
||||
paths.root_dir,
|
||||
paths.app_output_root,
|
||||
paths.app_output_latest,
|
||||
paths.app_output_es5
|
||||
);
|
||||
|
||||
const CAST_PAGE_ENTRIES = {
|
||||
@@ -194,104 +191,82 @@ const CAST_PAGE_ENTRIES = {
|
||||
"receiver.html": ["receiver"],
|
||||
};
|
||||
|
||||
task(
|
||||
"gen-pages-cast-dev",
|
||||
genPagesDevTask(CAST_PAGE_ENTRIES, paths.cast_dir, paths.cast_output_root)
|
||||
export const genPagesCastDev = genPagesDevTask(
|
||||
CAST_PAGE_ENTRIES,
|
||||
paths.cast_dir,
|
||||
paths.cast_output_root
|
||||
);
|
||||
|
||||
task(
|
||||
"gen-pages-cast-prod",
|
||||
genPagesProdTask(
|
||||
CAST_PAGE_ENTRIES,
|
||||
paths.cast_dir,
|
||||
paths.cast_output_root,
|
||||
paths.cast_output_latest,
|
||||
paths.cast_output_es5
|
||||
)
|
||||
export const genPagesCastProd = genPagesProdTask(
|
||||
CAST_PAGE_ENTRIES,
|
||||
paths.cast_dir,
|
||||
paths.cast_output_root,
|
||||
paths.cast_output_latest,
|
||||
paths.cast_output_es5
|
||||
);
|
||||
|
||||
const DEMO_PAGE_ENTRIES = { "index.html": ["main"] };
|
||||
|
||||
task(
|
||||
"gen-pages-demo-dev",
|
||||
genPagesDevTask(DEMO_PAGE_ENTRIES, paths.demo_dir, paths.demo_output_root)
|
||||
export const genPagesDemoDev = genPagesDevTask(
|
||||
DEMO_PAGE_ENTRIES,
|
||||
paths.demo_dir,
|
||||
paths.demo_output_root
|
||||
);
|
||||
|
||||
task(
|
||||
"gen-pages-demo-prod",
|
||||
genPagesProdTask(
|
||||
DEMO_PAGE_ENTRIES,
|
||||
paths.demo_dir,
|
||||
paths.demo_output_root,
|
||||
paths.demo_output_latest,
|
||||
paths.demo_output_es5
|
||||
)
|
||||
export const genPagesDemoProd = genPagesProdTask(
|
||||
DEMO_PAGE_ENTRIES,
|
||||
paths.demo_dir,
|
||||
paths.demo_output_root,
|
||||
paths.demo_output_latest,
|
||||
paths.demo_output_es5
|
||||
);
|
||||
|
||||
const GALLERY_PAGE_ENTRIES = { "index.html": ["entrypoint"] };
|
||||
|
||||
task(
|
||||
"gen-pages-gallery-dev",
|
||||
genPagesDevTask(
|
||||
GALLERY_PAGE_ENTRIES,
|
||||
paths.gallery_dir,
|
||||
paths.gallery_output_root
|
||||
)
|
||||
export const genPagesGalleryDev = genPagesDevTask(
|
||||
GALLERY_PAGE_ENTRIES,
|
||||
paths.gallery_dir,
|
||||
paths.gallery_output_root
|
||||
);
|
||||
|
||||
task(
|
||||
"gen-pages-gallery-prod",
|
||||
genPagesProdTask(
|
||||
GALLERY_PAGE_ENTRIES,
|
||||
paths.gallery_dir,
|
||||
paths.gallery_output_root,
|
||||
paths.gallery_output_latest
|
||||
)
|
||||
export const genPagesGalleryProd = genPagesProdTask(
|
||||
GALLERY_PAGE_ENTRIES,
|
||||
paths.gallery_dir,
|
||||
paths.gallery_output_root,
|
||||
paths.gallery_output_latest
|
||||
);
|
||||
|
||||
const LANDING_PAGE_PAGE_ENTRIES = { "index.html": ["entrypoint"] };
|
||||
|
||||
task(
|
||||
"gen-pages-landing-page-dev",
|
||||
genPagesDevTask(
|
||||
LANDING_PAGE_PAGE_ENTRIES,
|
||||
paths.landingPage_dir,
|
||||
paths.landingPage_output_root
|
||||
)
|
||||
export const genPagesLandingPageDev = genPagesDevTask(
|
||||
LANDING_PAGE_PAGE_ENTRIES,
|
||||
paths.landingPage_dir,
|
||||
paths.landingPage_output_root
|
||||
);
|
||||
|
||||
task(
|
||||
"gen-pages-landing-page-prod",
|
||||
genPagesProdTask(
|
||||
LANDING_PAGE_PAGE_ENTRIES,
|
||||
paths.landingPage_dir,
|
||||
paths.landingPage_output_root,
|
||||
paths.landingPage_output_latest,
|
||||
paths.landingPage_output_es5
|
||||
)
|
||||
export const genPagesLandingPageProd = genPagesProdTask(
|
||||
LANDING_PAGE_PAGE_ENTRIES,
|
||||
paths.landingPage_dir,
|
||||
paths.landingPage_output_root,
|
||||
paths.landingPage_output_latest,
|
||||
paths.landingPage_output_es5
|
||||
);
|
||||
|
||||
const HASSIO_PAGE_ENTRIES = { "entrypoint.js": ["entrypoint"] };
|
||||
|
||||
task(
|
||||
"gen-pages-hassio-dev",
|
||||
genPagesDevTask(
|
||||
HASSIO_PAGE_ENTRIES,
|
||||
paths.hassio_dir,
|
||||
paths.hassio_output_root,
|
||||
"src",
|
||||
paths.hassio_publicPath
|
||||
)
|
||||
export const genPagesHassioDev = genPagesDevTask(
|
||||
HASSIO_PAGE_ENTRIES,
|
||||
paths.hassio_dir,
|
||||
paths.hassio_output_root,
|
||||
"src",
|
||||
paths.hassio_publicPath
|
||||
);
|
||||
|
||||
task(
|
||||
"gen-pages-hassio-prod",
|
||||
genPagesProdTask(
|
||||
HASSIO_PAGE_ENTRIES,
|
||||
paths.hassio_dir,
|
||||
paths.hassio_output_root,
|
||||
paths.hassio_output_latest,
|
||||
paths.hassio_output_es5,
|
||||
"src"
|
||||
)
|
||||
export const genPagesHassioProd = genPagesProdTask(
|
||||
HASSIO_PAGE_ENTRIES,
|
||||
paths.hassio_dir,
|
||||
paths.hassio_output_root,
|
||||
paths.hassio_output_latest,
|
||||
paths.hassio_output_es5,
|
||||
"src"
|
||||
);
|
||||
|
||||
@@ -4,9 +4,9 @@ import { createOAuthDeviceAuth } from "@octokit/auth-oauth-device";
|
||||
import { retry } from "@octokit/plugin-retry";
|
||||
import { Octokit } from "@octokit/rest";
|
||||
import { deleteAsync } from "del";
|
||||
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
||||
import { series, task } from "gulp";
|
||||
import { series } from "gulp";
|
||||
import jszip from "jszip";
|
||||
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import process from "node:process";
|
||||
import { extract } from "tar";
|
||||
@@ -22,12 +22,13 @@ const TOKEN_FILE = path.posix.join(EXTRACT_DIR, "token.json");
|
||||
const ARTIFACT_FILE = path.posix.join(EXTRACT_DIR, "artifact.json");
|
||||
|
||||
let allowTokenSetup = false;
|
||||
task("allow-setup-fetch-nightly-translations", (done) => {
|
||||
|
||||
export const allowSetupFetchNightlyTranslations = (done) => {
|
||||
allowTokenSetup = true;
|
||||
done();
|
||||
});
|
||||
};
|
||||
|
||||
task("fetch-nightly-translations", async function () {
|
||||
export const fetchNightlyTranslations = async () => {
|
||||
// Skip all when environment flag is set (assumes translations are already in place)
|
||||
if (process.env?.SKIP_FETCH_NIGHTLY_TRANSLATIONS) {
|
||||
console.log("Skipping fetch due to environment signal");
|
||||
@@ -161,9 +162,9 @@ task("fetch-nightly-translations", async function () {
|
||||
await new Promise((resolve, reject) => {
|
||||
extractStream.on("close", resolve).on("error", reject);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
task(
|
||||
"setup-and-fetch-nightly-translations",
|
||||
series("allow-setup-fetch-nightly-translations", "fetch-nightly-translations")
|
||||
export const setupAndFetchNightlyTranslations = series(
|
||||
allowSetupFetchNightlyTranslations,
|
||||
fetchNightlyTranslations
|
||||
);
|
||||
|
||||
@@ -1,19 +1,23 @@
|
||||
import fs from "node:fs";
|
||||
import { glob } from "glob";
|
||||
import { parallel, series, task, watch } from "gulp";
|
||||
import { parallel, series, watch } from "gulp";
|
||||
import yaml from "js-yaml";
|
||||
import { marked } from "marked";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import paths from "../paths.ts";
|
||||
import "./clean.ts";
|
||||
import "./entry-html.ts";
|
||||
import "./gather-static.ts";
|
||||
import "./gen-icons-json.ts";
|
||||
import "./rspack.ts";
|
||||
import "./service-worker.ts";
|
||||
import "./translations.ts";
|
||||
import { cleanGallery } from "./clean.ts";
|
||||
import { genPagesGalleryDev, genPagesGalleryProd } from "./entry-html.ts";
|
||||
import { copyStaticGallery } from "./gather-static.ts";
|
||||
import { genIconsJson } from "./gen-icons-json.ts";
|
||||
import { buildLocaleData } from "./locale-data.ts";
|
||||
import { rspackDevServerGallery, rspackProdGallery } from "./rspack.ts";
|
||||
import {
|
||||
buildTranslations,
|
||||
translationsEnableMergeBackend,
|
||||
} from "./translations.ts";
|
||||
|
||||
task("gather-gallery-pages", async function gatherPages() {
|
||||
// gather-gallery-pages
|
||||
export const gatherGalleryPages = async function gatherPages() {
|
||||
const pageDir = path.resolve(paths.gallery_dir, "src/pages");
|
||||
const files = await glob(path.resolve(pageDir, "**/*"));
|
||||
|
||||
@@ -144,52 +148,48 @@ task("gather-gallery-pages", async function gatherPages() {
|
||||
content,
|
||||
"utf-8"
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
task(
|
||||
"develop-gallery",
|
||||
series(
|
||||
async function setEnv() {
|
||||
process.env.NODE_ENV = "development";
|
||||
},
|
||||
"clean-gallery",
|
||||
"translations-enable-merge-backend",
|
||||
parallel(
|
||||
"gen-icons-json",
|
||||
"build-translations",
|
||||
"build-locale-data",
|
||||
"gather-gallery-pages"
|
||||
),
|
||||
"copy-static-gallery",
|
||||
"gen-pages-gallery-dev",
|
||||
parallel("rspack-dev-server-gallery", async function watchMarkdownFiles() {
|
||||
watch(
|
||||
[
|
||||
path.resolve(paths.gallery_dir, "src/pages/**/*.markdown"),
|
||||
path.resolve(paths.gallery_dir, "sidebar.js"),
|
||||
],
|
||||
series("gather-gallery-pages")
|
||||
);
|
||||
})
|
||||
)
|
||||
// develop-gallery
|
||||
export const developGallery = series(
|
||||
async function setEnv() {
|
||||
process.env.NODE_ENV = "development";
|
||||
},
|
||||
cleanGallery,
|
||||
translationsEnableMergeBackend,
|
||||
parallel(
|
||||
genIconsJson,
|
||||
buildTranslations,
|
||||
buildLocaleData,
|
||||
gatherGalleryPages
|
||||
),
|
||||
copyStaticGallery,
|
||||
genPagesGalleryDev,
|
||||
parallel(rspackDevServerGallery, async function watchMarkdownFiles() {
|
||||
watch(
|
||||
[
|
||||
path.resolve(paths.gallery_dir, "src/pages/**/*.markdown"),
|
||||
path.resolve(paths.gallery_dir, "sidebar.js"),
|
||||
],
|
||||
series(gatherGalleryPages)
|
||||
);
|
||||
})
|
||||
);
|
||||
|
||||
task(
|
||||
"build-gallery",
|
||||
series(
|
||||
async function setEnv() {
|
||||
process.env.NODE_ENV = "production";
|
||||
},
|
||||
"clean-gallery",
|
||||
"translations-enable-merge-backend",
|
||||
parallel(
|
||||
"gen-icons-json",
|
||||
"build-translations",
|
||||
"build-locale-data",
|
||||
"gather-gallery-pages"
|
||||
),
|
||||
"copy-static-gallery",
|
||||
"rspack-prod-gallery",
|
||||
"gen-pages-gallery-prod"
|
||||
)
|
||||
// build-gallery
|
||||
export const buildGallery = series(
|
||||
async function setEnv() {
|
||||
process.env.NODE_ENV = "production";
|
||||
},
|
||||
cleanGallery,
|
||||
translationsEnableMergeBackend,
|
||||
parallel(
|
||||
genIconsJson,
|
||||
buildTranslations,
|
||||
buildLocaleData,
|
||||
gatherGalleryPages
|
||||
),
|
||||
copyStaticGallery,
|
||||
rspackProdGallery,
|
||||
genPagesGalleryProd
|
||||
);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// Gulp task to gather all static files.
|
||||
|
||||
import fs from "fs-extra";
|
||||
import { task } from "gulp";
|
||||
import path from "node:path";
|
||||
import paths from "../paths.ts";
|
||||
|
||||
@@ -17,7 +16,7 @@ const genStaticPath =
|
||||
(...parts) =>
|
||||
path.resolve(staticDir, ...parts);
|
||||
|
||||
function copyTranslations(staticDir) {
|
||||
const copyTranslations = (staticDir) => {
|
||||
const staticPath = genStaticPath(staticDir);
|
||||
|
||||
// Translation output
|
||||
@@ -25,23 +24,23 @@ function copyTranslations(staticDir) {
|
||||
polyPath("build/translations/output"),
|
||||
staticPath("translations")
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
function copyLocaleData(staticDir) {
|
||||
const copyLocaleData = (staticDir) => {
|
||||
const staticPath = genStaticPath(staticDir);
|
||||
|
||||
// Locale data output
|
||||
fs.copySync(polyPath("build/locale-data"), staticPath("locale-data"));
|
||||
}
|
||||
};
|
||||
|
||||
function copyMdiIcons(staticDir) {
|
||||
const copyMdiIcons = (staticDir) => {
|
||||
const staticPath = genStaticPath(staticDir);
|
||||
|
||||
// MDI icons output
|
||||
fs.copySync(polyPath("build/mdi"), staticPath("mdi"));
|
||||
}
|
||||
};
|
||||
|
||||
function copyPolyfills(staticDir) {
|
||||
const copyPolyfills = (staticDir) => {
|
||||
const staticPath = genStaticPath(staticDir);
|
||||
|
||||
// For custom panels using ES5 builds that don't use Babel 7+
|
||||
@@ -70,9 +69,9 @@ function copyPolyfills(staticDir) {
|
||||
npmPath("dialog-polyfill/dialog-polyfill.css"),
|
||||
staticPath("polyfills/")
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
function copyFonts(staticDir) {
|
||||
const copyFonts = (staticDir) => {
|
||||
const staticPath = genStaticPath(staticDir);
|
||||
// Local fonts
|
||||
fs.copySync(
|
||||
@@ -82,14 +81,14 @@ function copyFonts(staticDir) {
|
||||
filter: (src) => !src.includes(".") || src.endsWith(".woff2"),
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
function copyQrScannerWorker(staticDir) {
|
||||
const copyQrScannerWorker = (staticDir) => {
|
||||
const staticPath = genStaticPath(staticDir);
|
||||
copyFileDir(npmPath("qr-scanner/qr-scanner-worker.min.js"), staticPath("js"));
|
||||
}
|
||||
};
|
||||
|
||||
function copyMapPanel(staticDir) {
|
||||
const copyMapPanel = (staticDir) => {
|
||||
const staticPath = genStaticPath(staticDir);
|
||||
copyFileDir(
|
||||
npmPath("leaflet/dist/leaflet.css"),
|
||||
@@ -103,43 +102,38 @@ function copyMapPanel(staticDir) {
|
||||
npmPath("leaflet/dist/images"),
|
||||
staticPath("images/leaflet/images/")
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
function copyZXingWasm(staticDir) {
|
||||
const copyZXingWasm = (staticDir) => {
|
||||
const staticPath = genStaticPath(staticDir);
|
||||
copyFileDir(
|
||||
npmPath("zxing-wasm/dist/reader/zxing_reader.wasm"),
|
||||
staticPath("js")
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
task("copy-locale-data", async () => {
|
||||
const staticDir = paths.app_output_static;
|
||||
copyLocaleData(staticDir);
|
||||
});
|
||||
|
||||
task("copy-translations-app", async () => {
|
||||
export const copyTranslationsApp = async () => {
|
||||
const staticDir = paths.app_output_static;
|
||||
copyTranslations(staticDir);
|
||||
});
|
||||
};
|
||||
|
||||
task("copy-translations-supervisor", async () => {
|
||||
export const copyTranslationsSupervisor = async () => {
|
||||
const staticDir = paths.hassio_output_static;
|
||||
copyTranslations(staticDir);
|
||||
});
|
||||
};
|
||||
|
||||
task("copy-translations-landing-page", async () => {
|
||||
export const copyTranslationsLandingPage = async () => {
|
||||
const staticDir = paths.landingPage_output_static;
|
||||
copyTranslations(staticDir);
|
||||
});
|
||||
};
|
||||
|
||||
task("copy-static-supervisor", async () => {
|
||||
export const copyStaticSupervisor = async () => {
|
||||
const staticDir = paths.hassio_output_static;
|
||||
copyLocaleData(staticDir);
|
||||
copyFonts(staticDir);
|
||||
});
|
||||
};
|
||||
|
||||
task("copy-static-app", async () => {
|
||||
export const copyStaticApp = async () => {
|
||||
const staticDir = paths.app_output_static;
|
||||
// Basic static files
|
||||
fs.copySync(polyPath("public"), paths.app_output_root);
|
||||
@@ -155,9 +149,9 @@ task("copy-static-app", async () => {
|
||||
// Qr Scanner assets
|
||||
copyZXingWasm(staticDir);
|
||||
copyQrScannerWorker(staticDir);
|
||||
});
|
||||
};
|
||||
|
||||
task("copy-static-demo", async () => {
|
||||
export const copyStaticDemo = async () => {
|
||||
// Copy app static files
|
||||
fs.copySync(
|
||||
polyPath("public/static"),
|
||||
@@ -171,9 +165,9 @@ task("copy-static-demo", async () => {
|
||||
copyTranslations(paths.demo_output_static);
|
||||
copyLocaleData(paths.demo_output_static);
|
||||
copyMdiIcons(paths.demo_output_static);
|
||||
});
|
||||
};
|
||||
|
||||
task("copy-static-cast", async () => {
|
||||
export const copyStaticCast = async () => {
|
||||
// Copy app static files
|
||||
fs.copySync(polyPath("public/static"), paths.cast_output_static);
|
||||
// Copy cast static files
|
||||
@@ -184,9 +178,9 @@ task("copy-static-cast", async () => {
|
||||
copyTranslations(paths.cast_output_static);
|
||||
copyLocaleData(paths.cast_output_static);
|
||||
copyMdiIcons(paths.cast_output_static);
|
||||
});
|
||||
};
|
||||
|
||||
task("copy-static-gallery", async () => {
|
||||
export const copyStaticGallery = async () => {
|
||||
// Copy app static files
|
||||
fs.copySync(polyPath("public/static"), paths.gallery_output_static);
|
||||
// Copy gallery static files
|
||||
@@ -200,9 +194,9 @@ task("copy-static-gallery", async () => {
|
||||
copyTranslations(paths.gallery_output_static);
|
||||
copyLocaleData(paths.gallery_output_static);
|
||||
copyMdiIcons(paths.gallery_output_static);
|
||||
});
|
||||
};
|
||||
|
||||
task("copy-static-landing-page", async () => {
|
||||
export const copyStaticLandingPage = async () => {
|
||||
// Copy landing-page static files
|
||||
fs.copySync(
|
||||
path.resolve(paths.landingPage_dir, "public"),
|
||||
@@ -211,4 +205,4 @@ task("copy-static-landing-page", async () => {
|
||||
|
||||
copyFonts(paths.landingPage_output_static);
|
||||
copyTranslations(paths.landingPage_output_static);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import fs from "node:fs";
|
||||
import { task } from "gulp";
|
||||
import hash from "object-hash";
|
||||
import path from "node:path";
|
||||
import hash from "object-hash";
|
||||
import paths from "../paths.ts";
|
||||
|
||||
const ICON_PACKAGE_PATH = path.resolve("node_modules/@mdi/svg/");
|
||||
@@ -97,7 +96,7 @@ const findDifferentiator = (curString, prevString) => {
|
||||
throw new Error(`Cannot find differentiator; ${curString}; ${prevString}`);
|
||||
};
|
||||
|
||||
task("gen-icons-json", (done) => {
|
||||
export const genIconsJson = (done) => {
|
||||
const meta = getMeta();
|
||||
|
||||
const metaAndRemoved = addRemovedMeta(meta);
|
||||
@@ -153,13 +152,13 @@ task("gen-icons-json", (done) => {
|
||||
);
|
||||
|
||||
done();
|
||||
});
|
||||
};
|
||||
|
||||
task("gen-dummy-icons-json", (done) => {
|
||||
export const genDummyIconsJson = (done) => {
|
||||
if (!fs.existsSync(OUTPUT_DIR)) {
|
||||
fs.mkdirSync(OUTPUT_DIR, { recursive: true });
|
||||
}
|
||||
|
||||
fs.writeFileSync(path.resolve(OUTPUT_DIR, "iconList.json"), "[]");
|
||||
done();
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,45 +1,45 @@
|
||||
import { series, task } from "gulp";
|
||||
import { series } from "gulp";
|
||||
import { isTestBuild } from "../env.ts";
|
||||
import "./clean.ts";
|
||||
import "./compress.ts";
|
||||
import "./entry-html.ts";
|
||||
import "./gather-static.ts";
|
||||
import "./gen-icons-json.ts";
|
||||
import "./rspack.ts";
|
||||
import "./translations.ts";
|
||||
import { cleanHassio } from "./clean.ts";
|
||||
import { compressHassio } from "./compress.ts";
|
||||
import { genPagesHassioDev, genPagesHassioProd } from "./entry-html.ts";
|
||||
import {
|
||||
copyStaticSupervisor,
|
||||
copyTranslationsSupervisor,
|
||||
} from "./gather-static.ts";
|
||||
import { genDummyIconsJson } from "./gen-icons-json.ts";
|
||||
import { buildLocaleData } from "./locale-data.ts";
|
||||
import { rspackProdHassio, rspackWatchHassio } from "./rspack.ts";
|
||||
import { buildSupervisorTranslations } from "./translations.ts";
|
||||
|
||||
task(
|
||||
"develop-hassio",
|
||||
series(
|
||||
async function setEnv() {
|
||||
process.env.NODE_ENV = "development";
|
||||
},
|
||||
"clean-hassio",
|
||||
"gen-dummy-icons-json",
|
||||
"gen-pages-hassio-dev",
|
||||
"build-supervisor-translations",
|
||||
"copy-translations-supervisor",
|
||||
"build-locale-data",
|
||||
"copy-static-supervisor",
|
||||
"rspack-watch-hassio"
|
||||
)
|
||||
// develop-hassio
|
||||
export const developHassio = series(
|
||||
async function setEnv() {
|
||||
process.env.NODE_ENV = "development";
|
||||
},
|
||||
cleanHassio,
|
||||
genDummyIconsJson,
|
||||
genPagesHassioDev,
|
||||
buildSupervisorTranslations,
|
||||
copyTranslationsSupervisor,
|
||||
buildLocaleData,
|
||||
copyStaticSupervisor,
|
||||
rspackWatchHassio
|
||||
);
|
||||
|
||||
task(
|
||||
"build-hassio",
|
||||
series(
|
||||
async function setEnv() {
|
||||
process.env.NODE_ENV = "production";
|
||||
},
|
||||
"clean-hassio",
|
||||
"gen-dummy-icons-json",
|
||||
"build-supervisor-translations",
|
||||
"copy-translations-supervisor",
|
||||
"build-locale-data",
|
||||
"copy-static-supervisor",
|
||||
"rspack-prod-hassio",
|
||||
"gen-pages-hassio-prod",
|
||||
...// Don't compress running tests
|
||||
(isTestBuild() ? [] : ["compress-hassio"])
|
||||
)
|
||||
// build-hassio
|
||||
export const buildHassio = series(
|
||||
async function setEnv() {
|
||||
process.env.NODE_ENV = "production";
|
||||
},
|
||||
cleanHassio,
|
||||
genDummyIconsJson,
|
||||
buildSupervisorTranslations,
|
||||
copyTranslationsSupervisor,
|
||||
buildLocaleData,
|
||||
copyStaticSupervisor,
|
||||
rspackProdHassio,
|
||||
genPagesHassioProd,
|
||||
...// Don't compress running tests
|
||||
(isTestBuild() ? [] : [compressHassio])
|
||||
);
|
||||
|
||||
@@ -1,17 +1,42 @@
|
||||
import "./app.ts";
|
||||
import "./cast.ts";
|
||||
import "./clean.ts";
|
||||
import "./compress.ts";
|
||||
import "./demo.ts";
|
||||
import "./download-translations.ts";
|
||||
import "./entry-html.ts";
|
||||
import "./fetch-nightly-translations.ts";
|
||||
import "./gallery.ts";
|
||||
import "./gather-static.ts";
|
||||
import "./gen-icons-json.ts";
|
||||
import "./hassio.ts";
|
||||
import "./landing-page.ts";
|
||||
import "./locale-data.ts";
|
||||
import "./rspack.ts";
|
||||
import "./service-worker.ts";
|
||||
import "./translations.ts";
|
||||
import { analyzeApp, buildApp, developApp } from "./app";
|
||||
import { buildCast, developCast } from "./cast";
|
||||
import { analyzeDemo, buildDemo, developDemo } from "./demo";
|
||||
import { downloadTranslations } from "./download-translations";
|
||||
import { setupAndFetchNightlyTranslations } from "./fetch-nightly-translations";
|
||||
import { buildGallery, developGallery, gatherGalleryPages } from "./gallery";
|
||||
import { genIconsJson } from "./gen-icons-json";
|
||||
import { buildHassio, developHassio } from "./hassio";
|
||||
import { buildLandingPage, developLandingPage } from "./landing-page";
|
||||
import { buildLocaleData } from "./locale-data";
|
||||
import { buildTranslations } from "./translations";
|
||||
|
||||
export default {
|
||||
"develop-app": developApp,
|
||||
"build-app": buildApp,
|
||||
"analyze-app": analyzeApp,
|
||||
|
||||
"develop-cast": developCast,
|
||||
"build-cast": buildCast,
|
||||
|
||||
"develop-demo": developDemo,
|
||||
"build-demo": buildDemo,
|
||||
"analyze-demo": analyzeDemo,
|
||||
|
||||
"develop-gallery": developGallery,
|
||||
"build-gallery": buildGallery,
|
||||
"gather-gallery-pages": gatherGalleryPages,
|
||||
|
||||
"develop-hassio": developHassio,
|
||||
"build-hassio": buildHassio,
|
||||
|
||||
"develop-landing-page": developLandingPage,
|
||||
"build-landing-page": buildLandingPage,
|
||||
|
||||
"setup-and-fetch-nightly-translations": setupAndFetchNightlyTranslations,
|
||||
"download-translations": downloadTranslations,
|
||||
"build-translations": buildTranslations,
|
||||
|
||||
"gen-icons-json": genIconsJson,
|
||||
|
||||
"build-locale-data": buildLocaleData,
|
||||
};
|
||||
|
||||
@@ -1,41 +1,46 @@
|
||||
import { series, task } from "gulp";
|
||||
import "./clean.ts";
|
||||
import { series } from "gulp";
|
||||
import { cleanLandingPage } from "./clean.ts";
|
||||
import "./compress.ts";
|
||||
import "./entry-html.ts";
|
||||
import "./gather-static.ts";
|
||||
import "./gen-icons-json.ts";
|
||||
import "./rspack.ts";
|
||||
import "./translations.ts";
|
||||
import {
|
||||
genPagesLandingPageDev,
|
||||
genPagesLandingPageProd,
|
||||
} from "./entry-html.ts";
|
||||
import {
|
||||
copyStaticLandingPage,
|
||||
copyTranslationsLandingPage,
|
||||
} from "./gather-static.ts";
|
||||
import { buildLocaleData } from "./locale-data.ts";
|
||||
import { rspackProdLandingPage, rspackWatchLandingPage } from "./rspack.ts";
|
||||
import {
|
||||
buildLandingPageTranslations,
|
||||
translationsEnableMergeBackend,
|
||||
} from "./translations.ts";
|
||||
|
||||
task(
|
||||
"develop-landing-page",
|
||||
series(
|
||||
async function setEnv() {
|
||||
process.env.NODE_ENV = "development";
|
||||
},
|
||||
"clean-landing-page",
|
||||
"translations-enable-merge-backend",
|
||||
"build-landing-page-translations",
|
||||
"copy-translations-landing-page",
|
||||
"build-locale-data",
|
||||
"copy-static-landing-page",
|
||||
"gen-pages-landing-page-dev",
|
||||
"rspack-watch-landing-page"
|
||||
)
|
||||
// develop-landing-page
|
||||
export const developLandingPage = series(
|
||||
async function setEnv() {
|
||||
process.env.NODE_ENV = "development";
|
||||
},
|
||||
cleanLandingPage,
|
||||
translationsEnableMergeBackend,
|
||||
buildLandingPageTranslations,
|
||||
copyTranslationsLandingPage,
|
||||
buildLocaleData,
|
||||
copyStaticLandingPage,
|
||||
genPagesLandingPageDev,
|
||||
rspackWatchLandingPage
|
||||
);
|
||||
|
||||
task(
|
||||
"build-landing-page",
|
||||
series(
|
||||
async function setEnv() {
|
||||
process.env.NODE_ENV = "production";
|
||||
},
|
||||
"clean-landing-page",
|
||||
"build-landing-page-translations",
|
||||
"copy-translations-landing-page",
|
||||
"build-locale-data",
|
||||
"copy-static-landing-page",
|
||||
"rspack-prod-landing-page",
|
||||
"gen-pages-landing-page-prod"
|
||||
)
|
||||
// build-landing-page
|
||||
export const buildLandingPage = series(
|
||||
async function setEnv() {
|
||||
process.env.NODE_ENV = "production";
|
||||
},
|
||||
cleanLandingPage,
|
||||
buildLandingPageTranslations,
|
||||
copyTranslationsLandingPage,
|
||||
buildLocaleData,
|
||||
copyStaticLandingPage,
|
||||
rspackProdLandingPage,
|
||||
genPagesLandingPageProd
|
||||
);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { deleteSync } from "del";
|
||||
import { series } from "gulp";
|
||||
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
||||
import { series, task } from "gulp";
|
||||
import { join, resolve } from "node:path";
|
||||
import paths from "../paths.ts";
|
||||
|
||||
@@ -54,9 +54,9 @@ const convertToJSON = async (
|
||||
await writeFile(join(outDir, `${pkg}/${lang}.json`), localeData);
|
||||
};
|
||||
|
||||
task("clean-locale-data", async () => deleteSync([outDir]));
|
||||
const cleanLocaleData = async () => deleteSync([outDir]);
|
||||
|
||||
task("create-locale-data", async () => {
|
||||
const createLocaleData = async () => {
|
||||
const translationMeta = JSON.parse(
|
||||
await readFile(
|
||||
resolve(paths.translations_src, "translationMetadata.json"),
|
||||
@@ -81,6 +81,6 @@ task("create-locale-data", async () => {
|
||||
)
|
||||
);
|
||||
await Promise.all(conversions);
|
||||
});
|
||||
};
|
||||
|
||||
task("build-locale-data", series("clean-locale-data", "create-locale-data"));
|
||||
export const buildLocaleData = series(cleanLocaleData, createLocaleData);
|
||||
|
||||
@@ -3,9 +3,10 @@
|
||||
import rspack from "@rspack/core";
|
||||
import { RspackDevServer } from "@rspack/dev-server";
|
||||
import log from "fancy-log";
|
||||
import { series, watch } from "gulp";
|
||||
import fs from "node:fs";
|
||||
import { task, watch, series } from "gulp";
|
||||
import path from "node:path";
|
||||
import { isDevContainer, isStatsBuild, isTestBuild } from "../env.ts";
|
||||
import paths from "../paths.ts";
|
||||
import {
|
||||
createAppConfig,
|
||||
@@ -15,7 +16,16 @@ import {
|
||||
createHassioConfig,
|
||||
createLandingPageConfig,
|
||||
} from "../rspack.ts";
|
||||
import { isDevContainer, isStatsBuild, isTestBuild } from "../env.ts";
|
||||
import {
|
||||
copyTranslationsApp,
|
||||
copyTranslationsLandingPage,
|
||||
copyTranslationsSupervisor,
|
||||
} from "./gather-static.ts";
|
||||
import {
|
||||
buildLandingPageTranslations,
|
||||
buildSupervisorTranslations,
|
||||
buildTranslations,
|
||||
} from "./translations.ts";
|
||||
|
||||
const bothBuilds = (createConfigFunc, params) => [
|
||||
createConfigFunc({ ...params, latestBuild: true }),
|
||||
@@ -105,7 +115,7 @@ const prodBuild = (conf) =>
|
||||
);
|
||||
});
|
||||
|
||||
task("rspack-watch-app", () => {
|
||||
export const rspackWatchApp = () => {
|
||||
// This command will run forever because we don't close compiler
|
||||
rspack(
|
||||
process.env.ES5
|
||||
@@ -114,40 +124,37 @@ task("rspack-watch-app", () => {
|
||||
).watch({ poll: isWsl }, doneHandler());
|
||||
watch(
|
||||
path.join(paths.translations_src, "en.json"),
|
||||
series("build-translations", "copy-translations-app")
|
||||
series(buildTranslations, copyTranslationsApp)
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
task("rspack-prod-app", () =>
|
||||
export const rspackProdApp = () =>
|
||||
prodBuild(
|
||||
bothBuilds(createAppConfig, {
|
||||
isProdBuild: true,
|
||||
isStatsBuild: isStatsBuild(),
|
||||
isTestBuild: isTestBuild(),
|
||||
})
|
||||
)
|
||||
);
|
||||
);
|
||||
|
||||
task("rspack-dev-server-demo", () =>
|
||||
export const rspackDevServerDemo = () =>
|
||||
runDevServer({
|
||||
compiler: rspack(
|
||||
createDemoConfig({ isProdBuild: false, latestBuild: true })
|
||||
),
|
||||
contentBase: paths.demo_output_root,
|
||||
port: 8090,
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
task("rspack-prod-demo", () =>
|
||||
export const rspackProdDemo = () =>
|
||||
prodBuild(
|
||||
bothBuilds(createDemoConfig, {
|
||||
isProdBuild: true,
|
||||
isStatsBuild: isStatsBuild(),
|
||||
})
|
||||
)
|
||||
);
|
||||
);
|
||||
|
||||
task("rspack-dev-server-cast", () =>
|
||||
export const rspackDevServerCast = () =>
|
||||
runDevServer({
|
||||
compiler: rspack(
|
||||
createCastConfig({ isProdBuild: false, latestBuild: true })
|
||||
@@ -156,18 +163,16 @@ task("rspack-dev-server-cast", () =>
|
||||
port: 8080,
|
||||
// Accessible from the network, because that's how Cast hits it.
|
||||
listenHost: "0.0.0.0",
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
task("rspack-prod-cast", () =>
|
||||
export const rspackProdCast = () =>
|
||||
prodBuild(
|
||||
bothBuilds(createCastConfig, {
|
||||
isProdBuild: true,
|
||||
})
|
||||
)
|
||||
);
|
||||
);
|
||||
|
||||
task("rspack-watch-hassio", () => {
|
||||
export const rspackWatchHassio = () => {
|
||||
// This command will run forever because we don't close compiler
|
||||
rspack(
|
||||
createHassioConfig({
|
||||
@@ -178,21 +183,20 @@ task("rspack-watch-hassio", () => {
|
||||
|
||||
watch(
|
||||
path.join(paths.translations_src, "en.json"),
|
||||
series("build-supervisor-translations", "copy-translations-supervisor")
|
||||
series(buildSupervisorTranslations, copyTranslationsSupervisor)
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
task("rspack-prod-hassio", () =>
|
||||
export const rspackProdHassio = () =>
|
||||
prodBuild(
|
||||
bothBuilds(createHassioConfig, {
|
||||
isProdBuild: true,
|
||||
isStatsBuild: isStatsBuild(),
|
||||
isTestBuild: isTestBuild(),
|
||||
})
|
||||
)
|
||||
);
|
||||
);
|
||||
|
||||
task("rspack-dev-server-gallery", () =>
|
||||
export const rspackDevServerGallery = () =>
|
||||
runDevServer({
|
||||
compiler: rspack(
|
||||
createGalleryConfig({ isProdBuild: false, latestBuild: true })
|
||||
@@ -200,19 +204,17 @@ task("rspack-dev-server-gallery", () =>
|
||||
contentBase: paths.gallery_output_root,
|
||||
port: 8100,
|
||||
listenHost: "0.0.0.0",
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
task("rspack-prod-gallery", () =>
|
||||
export const rspackProdGallery = () =>
|
||||
prodBuild(
|
||||
createGalleryConfig({
|
||||
isProdBuild: true,
|
||||
latestBuild: true,
|
||||
})
|
||||
)
|
||||
);
|
||||
);
|
||||
|
||||
task("rspack-watch-landing-page", () => {
|
||||
export const rspackWatchLandingPage = () => {
|
||||
// This command will run forever because we don't close compiler
|
||||
rspack(
|
||||
process.env.ES5
|
||||
@@ -222,16 +224,15 @@ task("rspack-watch-landing-page", () => {
|
||||
|
||||
watch(
|
||||
path.join(paths.translations_src, "en.json"),
|
||||
series("build-landing-page-translations", "copy-translations-landing-page")
|
||||
series(buildLandingPageTranslations, copyTranslationsLandingPage)
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
task("rspack-prod-landing-page", () =>
|
||||
export const rspackProdLandingPage = () =>
|
||||
prodBuild(
|
||||
bothBuilds(createLandingPageConfig, {
|
||||
isProdBuild: true,
|
||||
isStatsBuild: isStatsBuild(),
|
||||
isTestBuild: isTestBuild(),
|
||||
})
|
||||
)
|
||||
);
|
||||
);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// Generate service workers
|
||||
|
||||
import { deleteAsync } from "del";
|
||||
import { task } from "gulp";
|
||||
import { mkdir, readFile, symlink, writeFile } from "node:fs/promises";
|
||||
import { basename, join, relative } from "node:path";
|
||||
import { injectManifest } from "workbox-build";
|
||||
@@ -23,7 +22,7 @@ self.addEventListener('install', (event) => {
|
||||
});
|
||||
`.trim() + "\n";
|
||||
|
||||
task("gen-service-worker-app-dev", async () => {
|
||||
export const genServiceWorkerAppDev = async () => {
|
||||
await mkdir(paths.app_output_root, { recursive: true });
|
||||
await Promise.all(
|
||||
Object.values(SW_MAP).map((build) =>
|
||||
@@ -32,9 +31,9 @@ task("gen-service-worker-app-dev", async () => {
|
||||
})
|
||||
)
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
task("gen-service-worker-app-prod", () =>
|
||||
export const genServiceWorkerAppProd = () =>
|
||||
Promise.all(
|
||||
Object.entries(SW_MAP).map(async ([outPath, build]) => {
|
||||
const manifest = JSON.parse(
|
||||
@@ -83,5 +82,4 @@ task("gen-service-worker-app-prod", () =>
|
||||
await symlink(basename(swDest), swOld);
|
||||
}
|
||||
})
|
||||
)
|
||||
);
|
||||
);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import { deleteAsync } from "del";
|
||||
import { glob } from "glob";
|
||||
import { src as glupSrc, dest as gulpDest, parallel, series, task } from "gulp";
|
||||
import { src as glupSrc, dest as gulpDest, parallel, series } from "gulp";
|
||||
import rename from "gulp-rename";
|
||||
import merge from "lodash.merge";
|
||||
import { createHash } from "node:crypto";
|
||||
@@ -12,7 +12,10 @@ import { PassThrough, Transform } from "node:stream";
|
||||
import { finished } from "node:stream/promises";
|
||||
import { isProdBuild } from "../env.ts";
|
||||
import paths from "../paths.ts";
|
||||
import "./fetch-nightly-translations.ts";
|
||||
import {
|
||||
allowSetupFetchNightlyTranslations,
|
||||
fetchNightlyTranslations,
|
||||
} from "./fetch-nightly-translations.ts";
|
||||
|
||||
const inFrontendDir = "translations/frontend";
|
||||
const inBackendDir = "translations/backend";
|
||||
@@ -23,12 +26,10 @@ const TEST_LOCALE = "en-x-test";
|
||||
|
||||
let mergeBackend = false;
|
||||
|
||||
task(
|
||||
"translations-enable-merge-backend",
|
||||
parallel(async () => {
|
||||
mergeBackend = true;
|
||||
}, "allow-setup-fetch-nightly-translations")
|
||||
);
|
||||
// translations-enable-merge-backend
|
||||
export const translationsEnableMergeBackend = parallel(async () => {
|
||||
mergeBackend = true;
|
||||
}, allowSetupFetchNightlyTranslations);
|
||||
|
||||
// Transform stream to apply a function on Vinyl JSON files (buffer mode only).
|
||||
// The provided function can either return a new object, or an array of
|
||||
@@ -145,7 +146,7 @@ const lokaliseTransform = (data, path, original = data) => {
|
||||
return output;
|
||||
};
|
||||
|
||||
task("clean-translations", () => deleteAsync([workDir]));
|
||||
export const cleanTranslations = () => deleteAsync([workDir]);
|
||||
|
||||
const makeWorkDir = () => mkdir(workDir, { recursive: true });
|
||||
|
||||
@@ -312,26 +313,20 @@ const writeTranslationMetaData = () =>
|
||||
)
|
||||
.pipe(gulpDest(workDir));
|
||||
|
||||
task(
|
||||
"build-translations",
|
||||
series(
|
||||
parallel(
|
||||
"fetch-nightly-translations",
|
||||
series("clean-translations", makeWorkDir)
|
||||
),
|
||||
createTestTranslation,
|
||||
createMasterTranslation,
|
||||
createTranslations,
|
||||
writeTranslationMetaData
|
||||
)
|
||||
export const buildTranslations = series(
|
||||
parallel(fetchNightlyTranslations, series(cleanTranslations, makeWorkDir)),
|
||||
createTestTranslation,
|
||||
createMasterTranslation,
|
||||
createTranslations,
|
||||
writeTranslationMetaData
|
||||
);
|
||||
|
||||
task(
|
||||
"build-supervisor-translations",
|
||||
series(setFragment("supervisor"), "build-translations")
|
||||
export const buildSupervisorTranslations = series(
|
||||
setFragment("supervisor"),
|
||||
buildTranslations
|
||||
);
|
||||
|
||||
task(
|
||||
"build-landing-page-translations",
|
||||
series(setFragment("landing-page"), "build-translations")
|
||||
export const buildLandingPageTranslations = series(
|
||||
setFragment("landing-page"),
|
||||
buildTranslations
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user