Skip to content

Commit

Permalink
Merge pull request #5001 from LedgerHQ/support/add-relative-path
Browse files Browse the repository at this point in the history
[LLM] - [LIVE-9909] - Add support for relatives import in `tsconfig.json`
  • Loading branch information
sshmaxime authored Oct 24, 2023
2 parents 0c92f85 + a733486 commit 3b13388
Show file tree
Hide file tree
Showing 108 changed files with 270 additions and 130 deletions.
6 changes: 6 additions & 0 deletions .changeset/polite-ravens-grab.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"metro-extra-config": patch
"live-mobile": patch
---

Added Path Mappings to LLM
18 changes: 18 additions & 0 deletions apps/ledger-live-mobile/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,24 @@ Optional environment variables you can put in `.env`, `.env.production` or `.env
- `DISABLE_READ_ONLY=1` Disable readonly mode by default.
- `SKIP_ONBOARDING=1` Skips the onboarding flow.

## Path mappings

Add any desired path mapping in `tsconfig.json`: (for instance `"@utils/*": ["./src/utils/*"]`)
Then, import `@utils/constants` in your project files and it will automatically resolve to `./src/utils/constants.{js/jsx/ts/tsx}`.

Please respect the following structure: `"@{package}/*": ["{any/path}/*"]`

```
// tsconfig.json
{
{ ... }
"paths": {
"@utils/*": ["./src/utils/*"],
"@constants/*": ["./src/constants/*"],
}
}
```

## Maintenance

### Refresh the languages (when we add new languages)
Expand Down
2 changes: 1 addition & 1 deletion apps/ledger-live-mobile/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ module.exports = {
plugins: [
"@babel/plugin-transform-named-capturing-groups-regex",
"@babel/plugin-proposal-export-namespace-from",
"react-native-reanimated/plugin",
"react-native-reanimated/plugin", // react-native-reanimated/plugin has to be listed last.
],
};
1 change: 0 additions & 1 deletion apps/ledger-live-mobile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@
"@types/ws": "^8.5.3",
"allure-js-commons": "1.3.2",
"babel-jest": "^28.0.0",
"babel-plugin-module-resolver": "^4.1.0",
"detox": "^20.11.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-detox": "^1.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ import Animation from "../Animation";
import { TrackScreen } from "../../analytics";
import GenericErrorView from "../GenericErrorView";
import { GenericInformationBody } from "../GenericInformationBody";
import { urls } from "../../config/urls";
import ExternalLink from "../ExternalLink";
import UnlockDeviceDrawer from "../UnlockDeviceDrawer";
import { urls } from "@utils/urls";

export type BleDevicePairingProps = {
onPaired: (device: Device) => void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Animation from "../Animation";
import BleDeviceItem from "./BleDeviceItem";
import Link from "../../components/wrappedUi/Link";
import lottie from "./assets/bluetooth.json";
import { urls } from "../../config/urls";
import { urls } from "@utils/urls";
import { TrackScreen, track } from "../../analytics";
import { useResetOnNavigationFocusState } from "../../helpers/useResetOnNavigationFocusState";
import LocationPermissionDenied from "../RequiresLocation/LocationPermissionDenied";
Expand Down
2 changes: 1 addition & 1 deletion apps/ledger-live-mobile/src/components/BuyDeviceCTA.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Trans } from "react-i18next";
import { useFeature } from "@ledgerhq/live-common/featureFlags/index";
import { useNavigation } from "@react-navigation/native";

import { urls } from "../config/urls";
import { urls } from "@utils/urls";
import { NavigatorName, ScreenName } from "../const";

const BuyDeviceCTA: React.FC<Record<string, never>> = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ImageSourcePropType, Linking } from "react-native";
import { useTranslation } from "react-i18next";
import { Language } from "@ledgerhq/types-live";
import { DeviceModel, DeviceModelId } from "@ledgerhq/types-devices";
import { urls } from "../config/urls";
import { urls } from "@utils/urls";
import Illustration from "../images/illustration/Illustration";

type Props = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import { ParamListBase } from "@react-navigation/native";
import isFirmwareUpdateVersionSupported from "@ledgerhq/live-common/hw/isFirmwareUpdateVersionSupported";
import ProviderIcon from "../ProviderIcon";
import { lastSeenDeviceSelector } from "../../reducers/settings";
import { urls } from "../../config/urls";
import { urls } from "@utils/urls";
import Alert from "../Alert";
import { lighten, Theme } from "../../colors";
import Button from "../Button";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { Device } from "@ledgerhq/live-common/hw/actions/types";
import { Linking, ScrollView } from "react-native";
import { track } from "../../analytics";
import Track from "../../analytics/Track";
import { urls } from "../../config/urls";
import { urls } from "@utils/urls";
import SafeMarkdown from "../SafeMarkdown";

type Props = {
Expand Down
2 changes: 1 addition & 1 deletion apps/ledger-live-mobile/src/components/HelpLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Trans } from "react-i18next";
import { useTheme } from "@react-navigation/native";
import Touchable, { Props as TouchableProps } from "./Touchable";
import LText from "./LText";
import { urls } from "../config/urls";
import { urls } from "@utils/urls";
import Help from "../icons/Help";

type Props = {
Expand Down
2 changes: 1 addition & 1 deletion apps/ledger-live-mobile/src/components/NeedHelp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useTheme } from "@react-navigation/native";
import LText from "./LText";
import Touchable from "./Touchable";
import IconHelp from "../icons/Help";
import { urls } from "../config/urls";
import { urls } from "@utils/urls";

function NeedHelp() {
const { colors } = useTheme();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Button, Checkbox, Flex, IconsLegacy, Link, Text } from "@ledgerhq/nativ
import { Linking, View } from "react-native";
import styled from "styled-components/native";
import { Trans, useTranslation } from "react-i18next";
import { LEDGER_APPLE_WARNING_EXPLAINER_LINK } from "../../../constants";
import { LEDGER_APPLE_WARNING_EXPLAINER_LINK } from "@utils/constants";

const CheckboxContainer = styled(View)(
({ theme }) => `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
import { useMemo } from "react";
import { Linking } from "react-native";
import { track } from "../../../analytics";
import { urls } from "../../../config/urls";
import { urls } from "@utils/urls";

export function useProtect() {
const servicesConfig = useFeature("protectServicesMobile");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useCallback } from "react";
import { Linking } from "react-native";
import { Trans } from "react-i18next";
import { urls } from "../config/urls";
import { urls } from "@utils/urls";
import ExternalLink from "./ExternalLink";
import { LearnMoreLink } from "./Alert";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import SetupDeviceBanner from "../SetupDeviceBanner";
import { track, useAnalytics } from "../../analytics";
import { useToasts } from "@ledgerhq/live-common/notifications/ToastProvider/index";
import useQuickActions from "../../hooks/useQuickActions";
import { PTX_SERVICES_TOAST_ID } from "../../constants";
import { PTX_SERVICES_TOAST_ID } from "@utils/constants";

import { useQuickAccessURI } from "@ledgerhq/live-common/hooks/recoverFeatureFlag";

Expand Down
2 changes: 1 addition & 1 deletion apps/ledger-live-mobile/src/components/TermsFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React, { useCallback } from "react";
import { Trans } from "react-i18next";
import { Linking } from "react-native";
import styled from "styled-components/native";
import { urls } from "../config/urls";
import { urls } from "@utils/urls";

const CenteredText = styled(Text).attrs({
fontWeight: "medium",
Expand Down
2 changes: 1 addition & 1 deletion apps/ledger-live-mobile/src/components/WarningBanner.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import { StyleSheet, View } from "react-native";
import { urls } from "../config/urls";
import { urls } from "@utils/urls";
import TranslatedError from "./TranslatedError";
import Alert from "./Alert";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import GenericErrorView from "../GenericErrorView";
import Button from "../Button";
import ExternalLink from "../ExternalLink";
import { useLocale } from "../../context/Locale";
import { urls } from "../../config/urls";
import { urls } from "@utils/urls";

const WebPTXPlayerNetworkFail = createCustomErrorClass("WebPTXPlayerNetworkFail");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { RefreshControl } from "react-native";
import { useTheme } from "@react-navigation/native";
import { useBridgeSync, useAccountSyncState } from "@ledgerhq/live-common/bridge/react/index";
import { useCountervaluesPolling } from "@ledgerhq/live-common/countervalues/react";
import { SYNC_DELAY } from "../constants";
import { SYNC_DELAY } from "@utils/constants";

export interface Props {
accountId?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { RefreshControl, RefreshControlProps } from "react-native";
import { useBridgeSync } from "@ledgerhq/live-common/bridge/react/index";
import { useCountervaluesPolling } from "@ledgerhq/live-common/countervalues/react";
import { useIsFocused, useTheme } from "@react-navigation/native";
import { SYNC_DELAY } from "../constants";
import { SYNC_DELAY } from "@utils/constants";

type Props = {
error?: Error;
Expand Down
17 changes: 0 additions & 17 deletions apps/ledger-live-mobile/src/constants.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import PasswordInput from "../../components/PasswordInput";
import KeyboardView from "../../components/KeyboardView";
import FailBiometrics from "./FailBiometrics";
import KeyboardBackgroundDismiss from "../../components/KeyboardBackgroundDismiss";
import { VIBRATION_PATTERN_ERROR } from "../../constants";
import { VIBRATION_PATTERN_ERROR } from "@utils/constants";
import { withTheme } from "../../colors";
import type { Theme } from "../../colors";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import LText from "../../../../components/LText";
import ExternalLink from "../../../../components/ExternalLink";
import BulletList, { BulletGreenCheck } from "../../../../components/BulletList";
import NavigationScrollView from "../../../../components/NavigationScrollView";
import { urls } from "../../../../config/urls";
import { urls } from "@utils/urls";
import { TrackScreen } from "../../../../analytics";
import Illustration from "../../../../images/illustration/Illustration";
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import LText from "../../components/LText";
import CurrencyUnitValue from "../../components/CurrencyUnitValue";
import CounterValue from "../../components/CounterValue";
import ExternalLink from "../../icons/ExternalLink";
import { urls } from "../../config/urls";
import { urls } from "@utils/urls";
import type { StackNavigatorProps } from "../../components/RootNavigator/types/helpers";
import type { SendFundsNavigatorStackParamList } from "../../components/RootNavigator/types/SendFundsNavigator";
import type { BaseNavigatorStackParamList } from "../../components/RootNavigator/types/BaseNavigator";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import IconPlus from "../../icons/Plus";
import Button from "../../components/Button";
import { NavigatorName, ScreenName } from "../../const";
import LText from "../../components/LText";
import { urls } from "../../config/urls";
import { urls } from "@utils/urls";
import ExternalLink from "../../components/ExternalLink";
import { accountScreenSelector } from "../../reducers/accounts";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import NavigationScrollView from "../../../components/NavigationScrollView";
import Illustration from "../../../images/illustration/Illustration";
import EarnLight from "../../../images/illustration/Light/_003.png";
import EarnDark from "../../../images/illustration/Dark/_003.png";
import { urls } from "../../../config/urls";
import { urls } from "@utils/urls";
import { ScreenName } from "../../../const";
import { TrackScreen } from "../../../analytics";
import { StackNavigatorProps } from "../../../components/RootNavigator/types/helpers";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import LText from "../../../components/LText";
import Touchable from "../../../components/Touchable";
import { rgba } from "../../../colors";
import IlluRewards from "../../../icons/images/Rewards";
import { urls } from "../../../config/urls";
import { urls } from "@utils/urls";
import { ScreenName, NavigatorName } from "../../../const";
import RedelegateIcon from "../../../icons/Redelegate";
import UndelegateIcon from "../../../icons/Undelegate";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { StackNavigationProp } from "@react-navigation/stack";
import Alert from "../../../components/Alert";
import AccountDelegationInfo from "../../../components/AccountDelegationInfo";
import IlluRewards from "../../../icons/images/Rewards";
import { urls } from "../../../config/urls";
import { urls } from "@utils/urls";
import AccountSectionLabel from "../../../components/AccountSectionLabel";
import DelegationDrawer from "../../../components/DelegationDrawer";
import type { IconProps } from "../../../components/DelegationDrawer";
Expand Down
2 changes: 1 addition & 1 deletion apps/ledger-live-mobile/src/families/celo/SendRowsFee.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import LText from "../../components/LText";
import CurrencyUnitValue from "../../components/CurrencyUnitValue";
import CounterValue from "../../components/CounterValue";
import ExternalLink from "../../icons/ExternalLink";
import { urls } from "../../config/urls";
import { urls } from "@utils/urls";
import type { BaseNavigatorStackParamList } from "../../components/RootNavigator/types/BaseNavigator";
import type { StackNavigatorProps } from "../../components/RootNavigator/types/helpers";
import type { SendFundsNavigatorStackParamList } from "../../components/RootNavigator/types/SendFundsNavigator";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import LText from "../../../components/LText";
import ExternalLink from "../../../components/ExternalLink";
import BulletList, { BulletGreenCheck } from "../../../components/BulletList";
import NavigationScrollView from "../../../components/NavigationScrollView";
import { urls } from "../../../config/urls";
import { urls } from "@utils/urls";
import { TrackScreen } from "../../../analytics";
import Illustration from "../../../images/illustration/Illustration";
import EarnLight from "../../../images/illustration/Light/_003.png";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import { AccountLike } from "@ledgerhq/types-live";
import { StackNavigationProp } from "@react-navigation/stack";
import AccountDelegationInfo from "../../../components/AccountDelegationInfo";
import IlluRewards from "../../../icons/images/Rewards";
import { urls } from "../../../config/urls";
import { urls } from "@utils/urls";
import AccountSectionLabel from "../../../components/AccountSectionLabel";
import DelegationDrawer from "../../../components/DelegationDrawer";
import type { IconProps } from "../../../components/DelegationDrawer";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import LText from "../../components/LText";
import CurrencyUnitValue from "../../components/CurrencyUnitValue";
import CounterValue from "../../components/CounterValue";
import ExternalLink from "../../icons/ExternalLink";
import { urls } from "../../config/urls";
import { urls } from "@utils/urls";
import type { BaseNavigatorStackParamList } from "../../components/RootNavigator/types/BaseNavigator";
import type { StackNavigatorProps } from "../../components/RootNavigator/types/helpers";
import type { SendFundsNavigatorStackParamList } from "../../components/RootNavigator/types/SendFundsNavigator";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import AccountSectionLabel from "../../../../../../components/AccountSectionLabe
import IlluRewards from "../../../../../../icons/images/Rewards";
import { ScreenName, NavigatorName } from "../../../../../../const";

import { urls } from "../../../../../../config/urls";
import { urls } from "@utils/urls";

import Delegation from "./components/Delegation";
import Right from "./components/Right";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Operation } from "@ledgerhq/types-live";
import type { getURLFeesInfoReturnType } from "./types";

import { urls } from "../../../../../config/urls";
import { urls } from "@utils/urls";

/*
* Handle the helper declaration.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Operation } from "@ledgerhq/types-live";
import type { getURLWhatIsThisReturnType } from "./types";

import { urls } from "../../../../../config/urls";
import { urls } from "@utils/urls";

/*
* Handle the helper declaration.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import IlluRewards from "../../../../../../../icons/images/Rewards";
import Alert from "../../../../../../../components/Alert";
import BulletList, { BulletGreenCheck } from "../../../../../../../components/BulletList";

import { urls } from "../../../../../../../config/urls";
import { urls } from "@utils/urls";
import { TrackScreen } from "../../../../../../../analytics";

import type { EarnRewardsPropsType } from "./types";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useCallback } from "react";
import i18next from "i18next";
import { useTheme } from "@react-navigation/native";
import { StyleSheet, Linking, Text } from "react-native";
import { urls } from "../../config/urls";
import { urls } from "@utils/urls";
import Touchable, { Props as TouchableProps } from "../../components/Touchable";
import LText from "../../components/LText";
import ExternalLink from "../../icons/ExternalLink";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { canStake, canUnstake, canWithdraw } from "@ledgerhq/live-common/familie
import { Account } from "@ledgerhq/types-live";
import AccountDelegationInfo from "../../../components/AccountDelegationInfo";
import IlluRewards from "../../../icons/images/Rewards";
import { urls } from "../../../config/urls";
import { urls } from "@utils/urls";
import AccountSectionLabel from "../../../components/AccountSectionLabel";
import DelegationDrawer from "../../../components/DelegationDrawer";
import type { IconProps } from "../../../components/DelegationDrawer";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import LText from "../../../components/LText";
import ExternalLink from "../../../components/ExternalLink";
import BulletList, { BulletGreenCheck } from "../../../components/BulletList";
import NavigationScrollView from "../../../components/NavigationScrollView";
import { urls } from "../../../config/urls";
import { urls } from "@utils/urls";
import { TrackScreen } from "../../../analytics";
import Illustration from "../../../images/illustration/Illustration";
import EarnLight from "../../../images/illustration/Light/_003.png";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import LText from "../../../components/LText";
import ExternalLink from "../../../components/ExternalLink";
import BulletList, { BulletGreenCheck } from "../../../components/BulletList";
import Alert from "../../../components/Alert";
import { urls } from "../../../config/urls";
import { urls } from "@utils/urls";
import Illustration from "../../../images/illustration/Illustration";
import EarnLight from "../../../images/illustration/Light/_003.png";
import EarnDark from "../../../images/illustration/Dark/_003.png";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { getAccountUnit, getMainAccount } from "@ledgerhq/live-common/account/in
import { getAccountBridge } from "@ledgerhq/live-common/bridge/index";
import { isFirstBond } from "@ledgerhq/live-common/families/polkadot/logic";
import { PolkadotAccount } from "@ledgerhq/live-common/families/polkadot/types";
import { urls } from "../../../config/urls";
import { urls } from "@utils/urls";
import { accountScreenSelector } from "../../../reducers/accounts";
import { ScreenName } from "../../../const";
import { TrackScreen } from "../../../analytics";
Expand Down
Loading

0 comments on commit 3b13388

Please sign in to comment.