Skip to content

Commit

Permalink
feat: remove path alias for @shared, for better translation support
Browse files Browse the repository at this point in the history
  • Loading branch information
Stuyk committed Apr 19, 2024
1 parent 31fd2f5 commit 9c72377
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 71 deletions.
4 changes: 2 additions & 2 deletions docs/plugins/create.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Ensure that you create an `index.ts` file as an entry point for your client code
// client/index.ts
import * as alt from 'alt-client';
import '../translate/index.js';
import { useTranslate } from '@Shared/translate.js';
import { useTranslate } from '../../../main/shared/translate.js';

const { t } = useTranslate('en');

Expand All @@ -36,7 +36,7 @@ Ensure that you create an `index.ts` file as an entry point for your server code
// server/index.ts
import * as alt from 'alt-server';
import '../translate/index.js';
import { useTranslate } from '@Shared/translate.js';
import { useTranslate } from '../../../main/shared/translate.js';

const { t } = useTranslate('en');

Expand Down
1 change: 0 additions & 1 deletion scripts/pathResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ function updatePaths(path: string) {
const relativePath = `../`.repeat(pathDepth);

let file = fs.readFileSync(path, 'utf-8');
file = file.replace(/\@Shared/gm, `${relativePath}main/shared`);
file = file.replace(/\@Server/gm, `${relativePath}main/server`);
file = file.replace(/\@Client/gm, `${relativePath}main/client`);
fs.writeFileSync(path, file);
Expand Down
4 changes: 2 additions & 2 deletions src/main/client/webview/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as alt from 'alt-client';
import { Events } from '@Shared/events/index.js';
import { PageNames, PageType } from '@Shared/webview/index.js';
import { Events } from '../../shared/events/index.js';
import { PageNames, PageType } from '../../shared/webview/index.js';

type AnyCallback = ((...args: any[]) => void) | ((...args: any[]) => Promise<void>) | Function;

Expand Down
2 changes: 1 addition & 1 deletion src/main/server/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as alt from 'alt-server';
import * as Utility from './utility/index.js';
import '../translate/index.js';
import { useTranslate } from '@Shared/translate.js';
import { useTranslate } from '../shared/translate.js';

const { t } = useTranslate();
const { reconnect } = Utility.useDevReconnect();
Expand Down
2 changes: 1 addition & 1 deletion src/main/server/webview/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Events } from '@Shared/events/index.js';
import { Events } from '../../shared/events/index.js';
import * as alt from 'alt-server';

export function useWebview() {
Expand Down
2 changes: 1 addition & 1 deletion src/main/translate/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useTranslate } from '@Shared/translate.js';
import { useTranslate } from '../shared/translate.js';

const { setBulk } = useTranslate();

Expand Down
12 changes: 6 additions & 6 deletions src/plugins/example/server/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as alt from "alt-server";
import * as alt from 'alt-server';

import "../translate/index.js";
import { useTranslate } from "@Shared/translate.js";
import '../translate/index.js';
import { useTranslate } from '../../../main/shared/translate.js';

const { t } = useTranslate("en");
const { t } = useTranslate('en');

alt.on("playerConnect", (player) => {
alt.log(`${player.name}, ${t("example.joined-server")}`);
alt.on('playerConnect', (player) => {
alt.log(`${player.name}, ${t('example.joined-server')}`);
});
8 changes: 4 additions & 4 deletions src/plugins/example/translate/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { useTranslate } from "@Shared/translate.js";
import { useTranslate } from '../../../main/shared/translate.js';

const { setBulk } = useTranslate();

setBulk({
en: {
"example.joined-server": "has joined the server successfully.",
},
en: {
'example.joined-server': 'has joined the server successfully.',
},
});
105 changes: 52 additions & 53 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,56 +1,55 @@
{
"compilerOptions": {
"baseUrl": "src",
"paths": {
"@Server/*": ["main/server/*"],
"@Client/*": ["main/client/*"],
"@Shared/*": ["main/shared/*"]
"compilerOptions": {
"baseUrl": "src",
"paths": {
"@Server/*": ["main/server/*"],
"@Client/*": ["main/client/*"]
},
"typeRoots": ["./node_modules/@types", "./node_modules/@altv"],
"removeComments": true,
"noUnusedLocals": false,
"noUnusedParameters": false,
"noImplicitReturns": true,
"allowJs": true,
"resolveJsonModule": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"moduleResolution": "NodeNext",
"allowSyntheticDefaultImports": true,
"composite": false,
"forceConsistentCasingInFileNames": true,
"strict": false,
"module": "NodeNext",
"target": "ES2022",
"outDir": "athena-cache",
"skipLibCheck": true,
"esModuleInterop": true,
"declaration": true,
"emitDeclarationOnly": false
},
"typeRoots": ["./node_modules/@types", "./node_modules/@altv"],
"removeComments": true,
"noUnusedLocals": false,
"noUnusedParameters": false,
"noImplicitReturns": true,
"allowJs": true,
"resolveJsonModule": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"moduleResolution": "NodeNext",
"allowSyntheticDefaultImports": true,
"composite": false,
"forceConsistentCasingInFileNames": true,
"strict": false,
"module": "NodeNext",
"target": "ES2022",
"outDir": "athena-cache",
"skipLibCheck": true,
"esModuleInterop": true,
"declaration": true,
"emitDeclarationOnly": false
},
"include": [
"src/**/*.ts",
"src-webviews/**/*.ts",
"src-webviews/**/*.d.ts",
"src/**/*.ts",
"src/**/*.d.ts",
"src/**/*.tsx",
"src/**/*.vue",
"src/main/plugins/**/webview/**.ts",
"src/main/plugins/**/webview/**.vue",
"src/main/plugins/**/components/**.vue"
],
"exclude": [
"resources",
"scripts",
"altv-athena-cache",
"athena-cache",
"node_modules",
"cache",
"crashdumps",
"data",
"doc",
"modules",
"screenshots"
]
"include": [
"src/**/*.ts",
"src-webviews/**/*.ts",
"src-webviews/**/*.d.ts",
"src/**/*.ts",
"src/**/*.d.ts",
"src/**/*.tsx",
"src/**/*.vue",
"src/main/plugins/**/webview/**.ts",
"src/main/plugins/**/webview/**.vue",
"src/main/plugins/**/components/**.vue"
],
"exclude": [
"resources",
"scripts",
"altv-athena-cache",
"athena-cache",
"node_modules",
"cache",
"crashdumps",
"data",
"doc",
"modules",
"screenshots"
]
}

0 comments on commit 9c72377

Please sign in to comment.