mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-16 16:30:15 +01:00
🪟 fix: Windows Build (npm) (#3889)
* chore: package-lock.json * chore: remove shadcn files (temp) * refactor: language comparisons script * fix: resolve package-lock file for windows compatibility * chore: Enable Windows unit tests for frontend * refactor: move shadcn components to data-provider
This commit is contained in:
parent
136599081c
commit
9ec665dd2c
7 changed files with 15089 additions and 15207 deletions
37
.github/workflows/frontend-review.yml
vendored
37
.github/workflows/frontend-review.yml
vendored
|
|
@ -33,25 +33,24 @@ jobs:
|
||||||
run: npm run test:ci --verbose
|
run: npm run test:ci --verbose
|
||||||
working-directory: client
|
working-directory: client
|
||||||
|
|
||||||
# Windows job is commented out
|
tests_frontend_windows:
|
||||||
# tests_frontend_windows:
|
name: Run frontend unit tests on Windows
|
||||||
# name: Run frontend unit tests on Windows
|
timeout-minutes: 60
|
||||||
# timeout-minutes: 60
|
runs-on: windows-latest
|
||||||
# runs-on: windows-latest
|
steps:
|
||||||
# steps:
|
- uses: actions/checkout@v4
|
||||||
# - uses: actions/checkout@v4
|
- name: Use Node.js 20.x
|
||||||
# - name: Use Node.js 20.x
|
uses: actions/setup-node@v4
|
||||||
# uses: actions/setup-node@v4
|
with:
|
||||||
# with:
|
node-version: 20
|
||||||
# node-version: 20
|
cache: 'npm'
|
||||||
# cache: 'npm'
|
|
||||||
|
|
||||||
# - name: Install dependencies
|
- name: Install dependencies
|
||||||
# run: npm ci
|
run: npm ci
|
||||||
|
|
||||||
# - name: Build Client
|
- name: Build Client
|
||||||
# run: npm run frontend:ci
|
run: npm run frontend:ci
|
||||||
|
|
||||||
# - name: Run unit tests
|
- name: Run unit tests
|
||||||
# run: npm run test:ci --verbose
|
run: npm run test:ci --verbose
|
||||||
# working-directory: client
|
working-directory: client
|
||||||
|
|
@ -1,10 +1,9 @@
|
||||||
import dedent from 'dedent';
|
import dedent from 'dedent';
|
||||||
import { ArtifactModes } from 'librechat-data-provider';
|
import { ArtifactModes, shadcnComponents } from 'librechat-data-provider';
|
||||||
import type {
|
import type {
|
||||||
SandpackProviderProps,
|
SandpackProviderProps,
|
||||||
SandpackPredefinedTemplate,
|
SandpackPredefinedTemplate,
|
||||||
} from '@codesandbox/sandpack-react';
|
} from '@codesandbox/sandpack-react';
|
||||||
import * as shadcnComponents from '~/utils/shadcn';
|
|
||||||
|
|
||||||
export const getArtifactsMode = ({
|
export const getArtifactsMode = ({
|
||||||
codeArtifacts,
|
codeArtifacts,
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -2,8 +2,7 @@ import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { exec } from 'child_process';
|
import { exec } from 'child_process';
|
||||||
|
|
||||||
async function main(baseFilePath: string, languagesDir: string) {
|
async function main(languagesDir: string) {
|
||||||
const { default: baseLanguage } = await import(path.resolve(baseFilePath));
|
|
||||||
const files = fs.readdirSync(languagesDir);
|
const files = fs.readdirSync(languagesDir);
|
||||||
|
|
||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
|
|
@ -13,41 +12,22 @@ async function main(baseFilePath: string, languagesDir: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const filePath = path.resolve(languagesDir, file);
|
const filePath = path.resolve(languagesDir, file);
|
||||||
if (filePath === baseFilePath) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const { default: otherLanguage } = await import(filePath);
|
|
||||||
const comparisons = {};
|
|
||||||
|
|
||||||
for (const key in otherLanguage) {
|
|
||||||
if (
|
|
||||||
Object.prototype.hasOwnProperty.call(otherLanguage, key) &&
|
|
||||||
Object.prototype.hasOwnProperty.call(baseLanguage, key)
|
|
||||||
) {
|
|
||||||
comparisons[key] = {
|
|
||||||
english: baseLanguage[key],
|
|
||||||
translated: otherLanguage[key],
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let fileContent = fs.readFileSync(filePath, 'utf8');
|
let fileContent = fs.readFileSync(filePath, 'utf8');
|
||||||
const comparisonsObjRegex = /export const comparisons = {[\s\S]*?};/gm;
|
const comparisonsObjRegex = /export const comparisons = {[\s\S]*?};/gm;
|
||||||
const hasComparisons = comparisonsObjRegex.test(fileContent);
|
|
||||||
const comparisonsExport = `\nexport const comparisons = ${JSON.stringify(
|
|
||||||
comparisons,
|
|
||||||
null,
|
|
||||||
2,
|
|
||||||
)};\n`;
|
|
||||||
|
|
||||||
if (hasComparisons) {
|
if (comparisonsObjRegex.test(fileContent)) {
|
||||||
fileContent = fileContent.replace(comparisonsObjRegex, comparisonsExport);
|
// Remove the comparisons object
|
||||||
|
fileContent = fileContent.replace(comparisonsObjRegex, '');
|
||||||
|
|
||||||
|
// Remove any empty lines at the end of the file
|
||||||
|
fileContent = fileContent.trim() + '\n';
|
||||||
|
|
||||||
|
fs.writeFileSync(filePath, fileContent);
|
||||||
|
console.log(`Removed comparisons from ${file}`);
|
||||||
} else {
|
} else {
|
||||||
fileContent = fileContent.trim() + comparisonsExport;
|
console.log(`No comparisons found in ${file}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
fs.writeFileSync(filePath, fileContent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute ESLint with the --fix option on the entire directory
|
// Execute ESLint with the --fix option on the entire directory
|
||||||
|
|
@ -65,17 +45,5 @@ async function main(baseFilePath: string, languagesDir: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const languagesDir = './client/src/localization/languages';
|
const languagesDir = './client/src/localization/languages';
|
||||||
const baseFilePath = path.resolve(languagesDir, 'Eng.ts');
|
|
||||||
|
|
||||||
main(baseFilePath, languagesDir).catch(console.error);
|
main(languagesDir).catch(console.error);
|
||||||
|
|
||||||
// const prompt = `
|
|
||||||
|
|
||||||
// Write a prompt that is mindful of the nuances in the language with respect to its English counterpart, which serves as the baseline for translations. Here are the comparisons between the language translations and their English counterparts:
|
|
||||||
|
|
||||||
// ${comparisons}
|
|
||||||
|
|
||||||
// Please consider the above comparisons to enhance understanding and guide improvements in translations. Provide insights or suggestions that could help refine the translation process, focusing on cultural and contextual relevance.
|
|
||||||
|
|
||||||
// Please craft a prompt that can be used to better inform future translations to this language. Write this prompt in the translated language, with all its nuances detected, not in the English.
|
|
||||||
// `;
|
|
||||||
|
|
|
||||||
24001
package-lock.json
generated
24001
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "librechat-data-provider",
|
"name": "librechat-data-provider",
|
||||||
"version": "0.7.419",
|
"version": "0.7.420",
|
||||||
"description": "data services for librechat apps",
|
"description": "data services for librechat apps",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"module": "dist/index.es.js",
|
"module": "dist/index.es.js",
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue