Skip to content

Commit

Permalink
Merge pull request #7812 from ever-co/stage
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
evereq authored May 18, 2024
2 parents 0adb46c + db61ae0 commit 8c79986
Show file tree
Hide file tree
Showing 911 changed files with 17,672 additions and 22,348 deletions.
4 changes: 4 additions & 0 deletions .deploy/api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ COPY --chown=node:node packages/plugins/knowledge-base/package.json ./packages/p
COPY --chown=node:node packages/plugins/changelog/package.json ./packages/plugins/changelog/
COPY --chown=node:node packages/plugins/job-search/package.json ./packages/plugins/job-search/
COPY --chown=node:node packages/plugins/job-proposal/package.json ./packages/plugins/job-proposal/
COPY --chown=node:node packages/plugins/job-search-ui/package.json ./packages/plugins/job-search-ui/
COPY --chown=node:node packages/ui-sdk/package.json ./packages/ui-sdk/

# We do not build here Wakatime plugin, because it used in Desktop Apps for now
# COPY --chown=node:node packages/plugins/integration-wakatime/package.json ./packages/plugins/integration-wakatime/
Expand Down Expand Up @@ -219,6 +221,8 @@ COPY --chown=node:node packages/plugins/knowledge-base/package.json ./packages/p
COPY --chown=node:node packages/plugins/changelog/package.json ./packages/plugins/changelog/
COPY --chown=node:node packages/plugins/job-search/package.json ./packages/plugins/job-search/
COPY --chown=node:node packages/plugins/job-proposal/package.json ./packages/plugins/job-proposal/
COPY --chown=node:node packages/plugins/job-search-ui/package.json ./packages/plugins/job-search-ui/
COPY --chown=node:node packages/ui-sdk/package.json ./packages/ui-sdk/

# We do not build here Wakatime plugin, because it used in Desktop Apps for now
# COPY --chown=node:node packages/plugins/integration-wakatime/package.json ./packages/plugins/integration-wakatime/
Expand Down
2 changes: 2 additions & 0 deletions .deploy/webapp/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ COPY --chown=node:node packages/plugins/product-reviews/package.json ./packages/
COPY --chown=node:node packages/plugins/knowledge-base/package.json ./packages/plugins/knowledge-base/
COPY --chown=node:node packages/plugins/changelog/package.json ./packages/plugins/changelog/
COPY --chown=node:node packages/plugins/job-proposal/package.json ./packages/plugins/job-proposal/
COPY --chown=node:node packages/plugins/job-search-ui/package.json ./packages/plugins/job-search-ui/
COPY --chown=node:node packages/ui-sdk/package.json ./packages/ui-sdk/

# We do not build here Wakatime plugin, because it used in Desktop Apps for now
# COPY --chown=node:node packages/plugins/integration-wakatime/package.json ./packages/plugins/integration-wakatime/
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,5 @@ apps/server/src/assets/icons/desktop_logo_512x512.png
apps/desktop-timer/src/assets/icons/menu
apps/desktop/src/assets/icons/menu
apps/server/src/assets/icons/menu

.angular
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
**/xplat/*/.xplatframework

/dist
/coverage
/coverage
.angular
94 changes: 65 additions & 29 deletions .scripts/translation/translation-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,62 +17,98 @@ export class TranslationUtil {
this.i18nUrl = env.I18N_FILES_URL;
}

private validateUrl() {
/**
* Validate the provided URL for translation files.
* @returns true if the URL is valid, false otherwise.
*/
private validateUrl(): boolean {
if (!this.i18nUrl) {
console.warn('WARNING: No translation files url provided');
console.warn('WARNING: No translation files URL provided');
return false;
}

try {
const url = new URL(this.i18nUrl);
return !!url;
} catch (error) {
console.error(`ERROR: Url '${this.i18nUrl}' provided is not valid: ` + error);
console.error(`ERROR: URL '${this.i18nUrl}' provided is not valid:`, error);
return false;
}
}

/**
* Download a JSON file for the specified language from the provided URL and save it to the destination directory.
* @param language The language code (e.g., 'en', 'fr').
*/
private async download(language: string): Promise<void> {
const url = `${this.i18nUrl}/${language}.json`;
const response = await fetch(url);
const data = await response.json();
const fileName = path.basename(url);
fs.writeFileSync(path.join(this.destination, fileName), JSON.stringify(data, null, 4));
console.log(`✔ File ${fileName} downloaded.`);
try {
const url = `${this.i18nUrl}/${language}.json`;
const response = await fetch(url);

if (!response.ok) {
throw new Error(`Failed to download ${url}: ${response.statusText}`);
}

const data = await response.json();
const fileName = path.basename(url);
const filePath = path.join(this.destination, fileName);

fs.writeFileSync(filePath, JSON.stringify(data, null, 4));
console.log(`✔ File ${fileName} downloaded and saved to ${filePath}.`);
} catch (error) {
console.error(`❌ Error downloading language ${language}:`, error);
}
}

/**
* Copy all files from the source directory to the destination directory.
*/
private copyAll(): void {
const source = path.join('apps', 'gauzy', 'src', 'assets', 'i18n');
const source = path.join('packages', 'ui-sdk', 'src', 'lib', 'i18n', 'assets', 'i18n');
fs.cpSync(source, this.destination, { recursive: true });
console.log(`✔ All translations copied from ${source}.`);
}

/**
* Copy the JSON file for the specified language from the source directory to the destination directory.
* @param language The language code (e.g., 'en', 'fr').
*/
private copyOne(language: string): void {
try {
const file = `${language}.json`;
const source = path.join('apps', 'gauzy', 'src', 'assets', 'i18n', file);
fs.copyFileSync(source, path.join(this.destination, file));
console.log(`✔ Default translation ${language}.json copied from ${source}`);
const fileName = `${language}.json`;
const sourceFilePath = path.join('packages', 'ui-sdk', 'src', 'lib', 'i18n', 'assets', 'i18n');
const destinationFilePath = path.join(this.destination, fileName);

fs.copyFileSync(sourceFilePath, destinationFilePath);

console.log(`✔ Default translation ${fileName} copied from ${sourceFilePath} to ${destinationFilePath}`);
} catch (error) {
console.log(`ERROR: Language '${language}' not copied:` + error);
console.error(`❌ Error copying language '${language}':`, error);
}
}

/**
* Download JSON files for all supported languages and save them to the destination directory.
* @returns A Promise that resolves when all files have been downloaded and saved.
*/
public async downloadAll(): Promise<void> {
if (!fs.existsSync(this.destination)) {
console.log(`✔ I18n directory created.`);
fs.mkdirSync(this.destination);
}
if (!this.validateUrl()) {
this.copyAll();
return;
}
for (const language of SupportedLanguage.list) {
try {
await this.download(language);
} catch (error) {
console.error(`ERROR: Language '${language}' not available: ` + error);
this.copyOne(language);
try {
if (!fs.existsSync(this.destination)) {
console.log(`✔ I18n directory created.`);
fs.mkdirSync(this.destination);
}

if (!this.validateUrl()) {
this.copyAll();
return;
}

const downloadPromises = SupportedLanguage.list.map((language) => this.download(language));
await Promise.all(downloadPromises);

console.log(`✔ All translations downloaded successfully.`);
} catch (error) {
console.error(`❌ Error downloading translations:`, error);
}
}
}
Expand Down
96 changes: 92 additions & 4 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"build": {
"builder": "./apps/gauzy/node_modules/@angular-builders/custom-webpack:browser",
"options": {
"preserveSymlinks": true,
"verbose": true,
"aot": true,
"customWebpackConfig": {
Expand All @@ -43,7 +44,12 @@
"apps/gauzy/src/favicon.ico",
"apps/gauzy/src/assets",
"apps/gauzy/src/manifest.json",
"apps/gauzy/src/silent-refresh.html"
"apps/gauzy/src/silent-refresh.html",
{
"glob": "**/*",
"input": "packages/ui-sdk/src/lib/i18n/assets/i18n",
"output": "assets/i18n/"
}
],
"styles": [
"node_modules/@nebular/theme/styles/prebuilt/default.css",
Expand All @@ -65,7 +71,6 @@
"node_modules/chart.js/dist/chart.js"
],
"allowedCommonJsDependencies": [
"@gauzy/common-angular",
"@gauzy/contracts",
"@gauzy/integration-hubstaff",
"brace",
Expand All @@ -77,7 +82,8 @@
"moment-timezone",
"moment",
"randomcolor",
"underscore.string"
"underscore.string",
"slugify"
]
},
"configurations": {
Expand Down Expand Up @@ -171,6 +177,78 @@
}
}
},
"@gauzy/ui-sdk": {
"projectType": "library",
"root": "packages/ui-sdk",
"sourceRoot": "packages/ui-sdk",
"prefix": "lib",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:ng-packagr",
"options": {
"project": "packages/ui-sdk/src/lib/ng-package.json"
},
"configurations": {
"production": {
"tsConfig": "packages/ui-sdk/tsconfig.lib.prod.json"
},
"development": {
"tsConfig": "packages/ui-sdk/tsconfig.lib.json"
}
},
"defaultConfiguration": "production"
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"tsConfig": "packages/ui-sdk/tsconfig.spec.json",
"polyfills": ["zone.js", "zone.js/testing"]
}
}
},
"schematics": {
"@nrwl/angular:component": {
"prefix": "ngx",
"style": "scss"
}
}
},
"@gauzy/job-search-ui-plugin": {
"projectType": "library",
"root": "packages/plugins/job-search-ui",
"sourceRoot": "packages/plugins/job-search-ui",
"prefix": "lib",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:ng-packagr",
"options": {
"project": "packages/plugins/job-search-ui/src/lib/ng-package.json"
},
"configurations": {
"production": {
"tsConfig": "packages/plugins/job-search-ui/tsconfig.lib.prod.json"
},
"development": {
"tsConfig": "packages/plugins/job-search-ui/tsconfig.lib.json"
}
},
"defaultConfiguration": "production"
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"tsConfig": "packages/plugins/job-search-ui/tsconfig.spec.json",
"polyfills": ["zone.js", "zone.js/testing"]
}
}
},
"schematics": {
"@nrwl/angular:component": {
"prefix": "ngx",
"style": "scss"
}
}
},
"gauzy-e2e": {
"root": "apps/gauzy-e2e",
"sourceRoot": "apps/gauzy-e2e/src",
Expand Down Expand Up @@ -365,6 +443,11 @@
"input": "apps/desktop/src/",
"ignore": ["**/*.ts"],
"output": ""
},
{
"glob": "**/*",
"input": "packages/ui-sdk/src/lib/i18n/assets/i18n",
"output": "assets/i18n/"
}
],
"styles": [
Expand Down Expand Up @@ -925,7 +1008,12 @@
"apps/gauzy/src/favicon.ico",
"apps/gauzy/src/assets",
"apps/gauzy/src/manifest.json",
"apps/gauzy/src/silent-refresh.html"
"apps/gauzy/src/silent-refresh.html",
{
"glob": "**/*",
"input": "packages/ui-sdk/src/lib/i18n/assets/i18n",
"output": "assets/i18n/"
}
],
"styles": [
"node_modules/bootstrap/dist/css/bootstrap.css",
Expand Down
2 changes: 1 addition & 1 deletion apps/gauzy-e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"cypress-file-upload": "^5.0.8",
"jasmine-core": "^3.6.0",
"jasmine-spec-reporter": "^6.0.0",
"jest": "29.4.3",
"jest": "^29.7.0",
"jest-preset-angular": "^13.1.4",
"karma": "^5.2.3",
"karma-chrome-launcher": "^3.1.0",
Expand Down
5 changes: 2 additions & 3 deletions apps/gauzy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
"@fullcalendar/interaction": "~6.1.10",
"@fullcalendar/moment-timezone": "~6.1.10",
"@fullcalendar/timegrid": "~6.1.10",
"@gauzy/common-angular": "^0.1.0",
"@gauzy/contracts": "^0.1.0",
"@jitsu/js": "^1.8.2",
"@kurkle/color": "^0.2.0",
Expand Down Expand Up @@ -90,7 +89,7 @@
"chart.js": "^4.4.1",
"chart.piecelabel.js": "^0.15.0",
"ckeditor4": "^4.23.0",
"ckeditor4-angular": "^5.0.0",
"ckeditor4-angular": "^5.1.0",
"core-js": "^3.8.3",
"d3": "^7.4.4",
"d3-selection-multi": "^1.0.1",
Expand Down Expand Up @@ -198,7 +197,7 @@
"copy-webpack-plugin": "^9.0.1",
"jasmine-core": "^3.6.0",
"jasmine-spec-reporter": "^6.0.0",
"jest": "29.4.3",
"jest": "^29.7.0",
"jest-preset-angular": "^13.1.4",
"karma": "^5.2.3",
"karma-chrome-launcher": "^3.1.0",
Expand Down
Loading

0 comments on commit 8c79986

Please sign in to comment.