Skip to content

Commit 9d864e9

Browse files
authored
Merge pull request #637 from dzcode-io/fix/cloudflare-workers-build-is-broken
fix: broken cloudflare worker builds
2 parents c0ed3d3 + 37dad7d commit 9d864e9

File tree

6 files changed

+17
-9
lines changed

6 files changed

+17
-9
lines changed

.github/workflows/ci.reusable.misc.yml

+1
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ jobs:
2727
- run: npx lerna run bundle:alone --scope "@dzcode.io/web"
2828
- run: npx lerna run generate:sitemap --scope "@dzcode.io/web"
2929
- run: npx lerna run generate:htmls --scope "@dzcode.io/web"
30+
- run: npm run --prefix web/cloudflare ts:check

web/cloudflare/functions/w/contributions-sitemap.xml.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { Env } from "handler/contribution";
22
import { environments } from "@dzcode.io/utils/dist/config/environment";
3-
import { Language, Languages } from "@dzcode.io/models/dist/language";
3+
import { LANGUAGES } from "@dzcode.io/models/dist/language";
44
import { getContributionURL } from "@dzcode.io/web/dist/utils/contribution";
55
import { fsConfig } from "@dzcode.io/utils/dist/config";
66
import { fetchV2Factory } from "@dzcode.io/utils/dist/fetch/factory";
77
import { Endpoints } from "@dzcode.io/api/dist/app/endpoints";
8+
import { LanguageCode } from "@dzcode.io/utils/dist/language";
89

910
function xmlEscape(s: string) {
1011
return s.replace(
@@ -20,9 +21,9 @@ export const onRequest: PagesFunction<Env> = async (context) => {
2021
stage = "development";
2122
}
2223
const fullstackConfig = fsConfig(stage);
23-
const links: Array<{ url: string; lang: Language["code"] }> = [];
24+
const links: Array<{ url: string; lang: LanguageCode }> = [];
2425

25-
for (const lang of Languages) {
26+
for (const lang of LANGUAGES) {
2627
const fetchV2 = fetchV2Factory<Endpoints>(fullstackConfig, lang.code);
2728
const { contributions } = await fetchV2("api:contributions/for-sitemap", {});
2829

web/cloudflare/functions/w/contributors-sitemap.xml.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { Env } from "handler/contributor";
22
import { environments } from "@dzcode.io/utils/dist/config/environment";
3-
import { Language, Languages } from "@dzcode.io/models/dist/language";
3+
import { LANGUAGES } from "@dzcode.io/models/dist/language";
44
import { getContributorURL } from "@dzcode.io/web/dist/utils/contributor";
55
import { fsConfig } from "@dzcode.io/utils/dist/config";
66
import { fetchV2Factory } from "@dzcode.io/utils/dist/fetch/factory";
77
import { Endpoints } from "@dzcode.io/api/dist/app/endpoints";
8+
import { LanguageCode } from "@dzcode.io/utils/dist/language";
89

910
export const onRequest: PagesFunction<Env> = async (context) => {
1011
let stage = context.env.STAGE;
@@ -13,8 +14,8 @@ export const onRequest: PagesFunction<Env> = async (context) => {
1314
stage = "development";
1415
}
1516
const fullstackConfig = fsConfig(stage);
16-
const links: Array<{ url: string; lang: Language["code"] }> = [];
17-
for (const lang of Languages) {
17+
const links: Array<{ url: string; lang: LanguageCode }> = [];
18+
for (const lang of LANGUAGES) {
1819
const fetchV2 = fetchV2Factory<Endpoints>(fullstackConfig, lang.code);
1920
const { contributors } = await fetchV2("api:contributors/for-sitemap", {});
2021
for (const contributor of contributors) {

web/cloudflare/functions/w/projects-sitemap.xml.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { Env } from "handler/project";
22
import { environments } from "@dzcode.io/utils/dist/config/environment";
3-
import { Language, Languages } from "@dzcode.io/models/dist/language";
43
import { getProjectURL } from "@dzcode.io/web/dist/utils/project";
54
import { fsConfig } from "@dzcode.io/utils/dist/config";
65
import { fetchV2Factory } from "@dzcode.io/utils/dist/fetch/factory";
76
import { Endpoints } from "@dzcode.io/api/dist/app/endpoints";
7+
import { LANGUAGES } from "@dzcode.io/models/dist/language";
8+
import { LanguageCode } from "@dzcode.io/utils/dist/language";
89

910
export const onRequest: PagesFunction<Env> = async (context) => {
1011
let stage = context.env.STAGE;
@@ -13,8 +14,8 @@ export const onRequest: PagesFunction<Env> = async (context) => {
1314
stage = "development";
1415
}
1516
const fullstackConfig = fsConfig(stage);
16-
const links: Array<{ url: string; lang: Language["code"] }> = [];
17-
for (const lang of Languages) {
17+
const links: Array<{ url: string; lang: LanguageCode }> = [];
18+
for (const lang of LANGUAGES) {
1819
const fetchV2 = fetchV2Factory<Endpoints>(fullstackConfig, lang.code);
1920
const { projects } = await fetchV2("api:projects/for-sitemap", {});
2021
for (const project of projects) {

web/cloudflare/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
},
1515
"private": true,
1616
"scripts": {
17+
"ts:check": "tsc --noEmit",
1718
"build": "lerna run build:alone [email protected]/web --include-dependencies --stream",
1819
"deploy:prd": "npm run generate:config -- production && wrangler pages deploy --branch main",
1920
"deploy:stg": "npm run generate:config -- staging && wrangler pages deploy --branch main",

web/cloudflare/scripts/generate-config.ts

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
2+
// @ts-nocheck
3+
14
import { writeFileSync } from "fs";
25

36
// Get the environment passed as argument

0 commit comments

Comments
 (0)