2
0

first commit

This commit is contained in:
2024-08-09 00:39:27 +02:00
commit 79688abe2e
5698 changed files with 497838 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
import { readFileSync, readdirSync, writeFileSync } from "fs";
import { join } from "path";
const TEMPLATE_LANGUAGE = "en";
const SPECIFIC_LOCALES = process.argv.slice(2) || [];
const LOCALES_PATH = join(__dirname, "../public/static/locales");
const ALL_LOCALES = readdirSync(LOCALES_PATH);
const templateJsonPath = join(LOCALES_PATH, `${TEMPLATE_LANGUAGE}/common.json`);
const templateJson: { [key: string]: string } = JSON.parse(readFileSync(templateJsonPath, "utf-8"));
const missingTranslationLocales: string[] = [];
// If locales are not specified, then check all folders under `public/static/locales`
(SPECIFIC_LOCALES.length ? SPECIFIC_LOCALES : ALL_LOCALES).forEach((locale: string) => {
if (locale === TEMPLATE_LANGUAGE) return;
if (!ALL_LOCALES.includes(locale)) {
missingTranslationLocales.push(locale);
console.log(`
${locale} is not found in ${LOCALES_PATH}!
If you want to create a new locale, Please create common.json under ${join(LOCALES_PATH, locale)}.
`);
return;
}
const localeJsonPath = join(LOCALES_PATH, `${locale}/common.json`);
const localeJson: { [key: string]: string } = JSON.parse(readFileSync(localeJsonPath, "utf8"));
if (Object.keys(templateJson).length === Object.keys(localeJson).length) return;
const missingTranslations: { [key: string]: string } = {};
missingTranslationLocales.push(locale);
Object.entries(templateJson).forEach(([key, value]: [string, string]) => {
if (key in localeJson) return;
missingTranslations[key] = value;
});
const newLocaleJson = {
...missingTranslations,
...localeJson,
};
writeFileSync(localeJsonPath, JSON.stringify(newLocaleJson, null, 2));
});
if (missingTranslationLocales.length) {
console.log("🌍 The following locales need to be translated: ");
console.log(` ${missingTranslationLocales.join(", ")}`);
} else {
console.log("💯 All the locales are completely translated!");
}

View File

@@ -0,0 +1,40 @@
import { execSync } from "child_process";
type Err = {
stdout: string;
};
const diff = execSync(`git diff --name-only origin/main HEAD`).toString();
const files = diff
.trim()
.split("\n")
.map((file) => file.trim())
.filter(Boolean)
.filter((file) => file.endsWith(".ts") || file.endsWith(".tsx"));
console.log(" Changed files:");
console.log(files.map((str) => ` - ${str}`).join("\n"));
try {
console.log("⏳ Checking type errors..");
execSync("yarn tsc --noEmit", {});
console.log("😻 No errors!");
} catch (_err) {
const err = _err as Err;
const output = err.stdout.toString() as string;
const filesWithTypeErrors = files.filter((file) => output.includes(file));
if (!filesWithTypeErrors.length) {
console.log(`🎉 You haven't introduced any new type errors!`);
process.exit(0);
}
console.log("❌ ❌ ❌ You seem to have touched files that have type errors ❌ ❌ ❌");
console.log("🙏 Please inspect the following files:");
console.log(filesWithTypeErrors.map((str) => ` - ${str}`).join("\n"));
process.exit(1);
}

View File

@@ -0,0 +1,46 @@
#!/bin/bash
# Only deploy to production
if [ "$VERCEL_ENV" != "production" ]; then exit 0; fi
checkRoute () {
if [ "$1" != '1' ]; then rm -rf $2; fi
}
# These conditionals are used to remove directories from the build that are not needed in production
# This is to reduce the size of the build and prevent OOM errors
checkRoute "$APP_ROUTER_EVENT_TYPES_ENABLED" app/future/event-types
checkRoute "$APP_ROUTER_SETTINGS_ADMIN_ENABLED" app/future/settings/admin
checkRoute "$APP_ROUTER_APPS_INSTALLED_CATEGORY_ENABLED" app/future/apps/installed
checkRoute "$APP_ROUTER_APPS_SLUG_ENABLED" app/future/apps/\[slug\]
checkRoute "$APP_ROUTER_APPS_SLUG_SETUP_ENABLED" app/future/apps/\[slug\]/setup
checkRoute "$APP_ROUTER_APPS_CATEGORIES_ENABLED" app/future/apps/categories
checkRoute "$APP_ROUTER_APPS_CATEGORIES_CATEGORY_ENABLED" app/future/apps/categories/\[category\]
checkRoute "$APP_ROUTER_WORKFLOWS_ENABLED" app/future/workflows
checkRoute "$APP_ROUTER_SETTINGS_TEAMS_ENABLED" app/future/settings/teams
checkRoute "$APP_ROUTER_GETTING_STARTED_STEP_ENABLED" app/future/getting-started
checkRoute "$APP_ROUTER_APPS_ENABLED" app/future/apps
checkRoute "$APP_ROUTER_BOOKINGS_STATUS_ENABLED" app/future/bookings
checkRoute "$APP_ROUTER_VIDEO_ENABLED" app/future/video
checkRoute "$APP_ROUTER_TEAMS_ENABLED" app/future/teams
# These are routes that don't have and environment variable to enable or disable them
# Will stop removing gradually as we test and confirm that they are working
rm -rf \
app/future/[user]\
app/future/auth\
app/future/booking\
app/future/connect-and-join\
app/future/d\
app/future/enterprise\
app/future/insights\
app/future/maintenance\
app/future/more\
app/future/org\
app/future/payment\
app/future/reschedule\
app/future/routing-forms\
app/future/signup\
app/future/team
exit 1

View File

@@ -0,0 +1,11 @@
#!/bin/bash
if [ "$SKIP_APP_DIR" == "1" ]; then
echo "Skipping app directory build"
rm -rf \
app/\
components/PageWrapperAppDir.tsx\
lib/app-providers-app-dir.tsx\
.next/types/app/
fi
if [ "$VERCEL_ENV" == "preview" ]; then exit 1; else exit 0; fi