diff --git a/babel.config.js b/babel.config.js index 234e2764..529a4577 100644 --- a/babel.config.js +++ b/babel.config.js @@ -22,8 +22,8 @@ module.exports = function (api) { root: ['./'], alias: { - '@': './', - '@lib': './lib', + '@': './src', + '@lib': './src/lib', 'tailwind.config': './tailwind.config.js', }, }, diff --git a/index.tsx b/index.tsx index eddf67d4..412e9448 100644 --- a/index.tsx +++ b/index.tsx @@ -1,7 +1,7 @@ // Entry point for React Native import 'react-native-devsettings'; import './global.css'; -import './lib/env'; +import './src/lib/env'; import React from 'react'; import { AppRegistry, Text } from 'react-native'; @@ -14,18 +14,18 @@ enableScreens(); import { TouchableOpacity, BackHandler } from 'react-native'; import { Ionicons } from '@expo/vector-icons'; import { PowerSyncContext } from '@powersync/react'; -import { db as psDb } from './lib/powersync'; -import { setupPowerSyncLogCapture } from './lib/powersync/Connector'; -import { SettingsProvider } from './lib/hooks/SettingsContext'; -import { SyncDebugProvider } from './lib/hooks/SyncDebugContext'; -import { ThemeProvider, useTheme } from './lib/theme/ThemeContext'; -import { GluestackUIProvider } from './components/ui/gluestack-ui-provider'; +import { db as psDb } from './src/lib/powersync'; +import { setupPowerSyncLogCapture } from './src/lib/powersync/Connector'; +import { SettingsProvider } from './src/lib/hooks/SettingsContext'; +import { SyncDebugProvider } from './src/lib/hooks/SyncDebugContext'; +import { ThemeProvider, useTheme } from './src/lib/theme/ThemeContext'; +import { GluestackUIProvider } from './src/components/ui/gluestack-ui-provider'; import Logger from 'js-logger'; // Screens -import HomeScreen from './app/index'; -import SettingsScreen from './app/settings'; -import SyncDebugScreen from './app/sync-debug'; +import HomeScreen from './src/screens/index'; +import SettingsScreen from './src/screens/settings'; +import SyncDebugScreen from './src/screens/sync-debug'; // Initialize logger Logger.useDefaults(); diff --git a/jest.config.js b/jest.config.js index 3b94a625..22e714e7 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,15 +1,15 @@ module.exports = { preset: 'ts-jest', testEnvironment: 'jsdom', - roots: ['/lib', '/scripts'], + roots: ['/src/lib', '/scripts'], testMatch: ['**/*.test.ts', '**/*.test.tsx', '**/*.ui.test.tsx'], moduleNameMapper: { - '^@lib/(.*)$': '/lib/$1', - '^@/components/ui$': '/lib/features/__tests__/__mocks__/gluestackUI.tsx', - '^@/(.*)$': '/$1', + '^@lib/(.*)$': '/src/lib/$1', + '^@/components/ui$': '/src/lib/features/__tests__/__mocks__/gluestackUI.tsx', + '^@/(.*)$': '/src/$1', '^react-native$': 'react-native-web', - '^@expo/vector-icons$': '/lib/features/__tests__/__mocks__/vectorIcons.ts', - '^@env$': '/lib/features/__tests__/__mocks__/env.ts', + '^@expo/vector-icons$': '/src/lib/features/__tests__/__mocks__/vectorIcons.ts', + '^@env$': '/src/lib/features/__tests__/__mocks__/env.ts', }, transform: { '^.+\\.tsx?$': ['ts-jest', { @@ -23,18 +23,18 @@ module.exports = { }], }, setupFilesAfterEnv: [ - '/lib/powersync/testSetup.ts', - '/lib/features/__tests__/setupComponentTests.ts', + '/src/lib/powersync/testSetup.ts', + '/src/lib/features/__tests__/setupComponentTests.ts', ], moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], clearMocks: true, collectCoverageFrom: [ - 'lib/**/*.{ts,tsx}', - '!lib/**/*.test.{ts,tsx}', - '!lib/**/*.ui.test.{ts,tsx}', - '!lib/**/testSetup.ts', - '!lib/**/setupComponentTests.ts', - '!lib/**/__tests__/**', + 'src/lib/**/*.{ts,tsx}', + '!src/lib/**/*.test.{ts,tsx}', + '!src/lib/**/*.ui.test.{ts,tsx}', + '!src/lib/**/testSetup.ts', + '!src/lib/**/setupComponentTests.ts', + '!src/lib/**/__tests__/**', ], coverageDirectory: 'coverage', coverageReporters: ['text', 'text-summary', 'lcov', 'html'], diff --git a/components/ui/alert/index.tsx b/src/components/ui/alert/index.tsx similarity index 100% rename from components/ui/alert/index.tsx rename to src/components/ui/alert/index.tsx diff --git a/components/ui/box/index.tsx b/src/components/ui/box/index.tsx similarity index 100% rename from components/ui/box/index.tsx rename to src/components/ui/box/index.tsx diff --git a/components/ui/box/index.web.tsx b/src/components/ui/box/index.web.tsx similarity index 100% rename from components/ui/box/index.web.tsx rename to src/components/ui/box/index.web.tsx diff --git a/components/ui/box/styles.tsx b/src/components/ui/box/styles.tsx similarity index 100% rename from components/ui/box/styles.tsx rename to src/components/ui/box/styles.tsx diff --git a/components/ui/button/index.tsx b/src/components/ui/button/index.tsx similarity index 100% rename from components/ui/button/index.tsx rename to src/components/ui/button/index.tsx diff --git a/components/ui/card/index.tsx b/src/components/ui/card/index.tsx similarity index 100% rename from components/ui/card/index.tsx rename to src/components/ui/card/index.tsx diff --git a/components/ui/card/index.web.tsx b/src/components/ui/card/index.web.tsx similarity index 100% rename from components/ui/card/index.web.tsx rename to src/components/ui/card/index.web.tsx diff --git a/components/ui/card/styles.tsx b/src/components/ui/card/styles.tsx similarity index 100% rename from components/ui/card/styles.tsx rename to src/components/ui/card/styles.tsx diff --git a/components/ui/divider/index.tsx b/src/components/ui/divider/index.tsx similarity index 100% rename from components/ui/divider/index.tsx rename to src/components/ui/divider/index.tsx diff --git a/components/ui/gluestack-ui-provider/config.ts b/src/components/ui/gluestack-ui-provider/config.ts similarity index 100% rename from components/ui/gluestack-ui-provider/config.ts rename to src/components/ui/gluestack-ui-provider/config.ts diff --git a/components/ui/gluestack-ui-provider/index.tsx b/src/components/ui/gluestack-ui-provider/index.tsx similarity index 100% rename from components/ui/gluestack-ui-provider/index.tsx rename to src/components/ui/gluestack-ui-provider/index.tsx diff --git a/components/ui/hstack/index.tsx b/src/components/ui/hstack/index.tsx similarity index 100% rename from components/ui/hstack/index.tsx rename to src/components/ui/hstack/index.tsx diff --git a/components/ui/hstack/index.web.tsx b/src/components/ui/hstack/index.web.tsx similarity index 100% rename from components/ui/hstack/index.web.tsx rename to src/components/ui/hstack/index.web.tsx diff --git a/components/ui/hstack/styles.tsx b/src/components/ui/hstack/styles.tsx similarity index 100% rename from components/ui/hstack/styles.tsx rename to src/components/ui/hstack/styles.tsx diff --git a/components/ui/index.ts b/src/components/ui/index.ts similarity index 100% rename from components/ui/index.ts rename to src/components/ui/index.ts diff --git a/components/ui/input/index.tsx b/src/components/ui/input/index.tsx similarity index 100% rename from components/ui/input/index.tsx rename to src/components/ui/input/index.tsx diff --git a/components/ui/link/index.tsx b/src/components/ui/link/index.tsx similarity index 100% rename from components/ui/link/index.tsx rename to src/components/ui/link/index.tsx diff --git a/components/ui/switch/index.tsx b/src/components/ui/switch/index.tsx similarity index 100% rename from components/ui/switch/index.tsx rename to src/components/ui/switch/index.tsx diff --git a/components/ui/text/index.tsx b/src/components/ui/text/index.tsx similarity index 100% rename from components/ui/text/index.tsx rename to src/components/ui/text/index.tsx diff --git a/components/ui/text/index.web.tsx b/src/components/ui/text/index.web.tsx similarity index 100% rename from components/ui/text/index.web.tsx rename to src/components/ui/text/index.web.tsx diff --git a/components/ui/text/styles.tsx b/src/components/ui/text/styles.tsx similarity index 100% rename from components/ui/text/styles.tsx rename to src/components/ui/text/styles.tsx diff --git a/components/ui/vstack/index.tsx b/src/components/ui/vstack/index.tsx similarity index 100% rename from components/ui/vstack/index.tsx rename to src/components/ui/vstack/index.tsx diff --git a/components/ui/vstack/index.web.tsx b/src/components/ui/vstack/index.web.tsx similarity index 100% rename from components/ui/vstack/index.web.tsx rename to src/components/ui/vstack/index.web.tsx diff --git a/components/ui/vstack/styles.tsx b/src/components/ui/vstack/styles.tsx similarity index 100% rename from components/ui/vstack/styles.tsx rename to src/components/ui/vstack/styles.tsx diff --git a/lib/components/ui/ActionButton.tsx b/src/lib/components/ui/ActionButton.tsx similarity index 100% rename from lib/components/ui/ActionButton.tsx rename to src/lib/components/ui/ActionButton.tsx diff --git a/lib/components/ui/Section.tsx b/src/lib/components/ui/Section.tsx similarity index 100% rename from lib/components/ui/Section.tsx rename to src/lib/components/ui/Section.tsx diff --git a/lib/components/ui/SecureInput.tsx b/src/lib/components/ui/SecureInput.tsx similarity index 100% rename from lib/components/ui/SecureInput.tsx rename to src/lib/components/ui/SecureInput.tsx diff --git a/lib/components/ui/WarningBanner.tsx b/src/lib/components/ui/WarningBanner.tsx similarity index 100% rename from lib/components/ui/WarningBanner.tsx rename to src/lib/components/ui/WarningBanner.tsx diff --git a/lib/components/ui/__tests__/ActionButton.test.ts b/src/lib/components/ui/__tests__/ActionButton.test.ts similarity index 100% rename from lib/components/ui/__tests__/ActionButton.test.ts rename to src/lib/components/ui/__tests__/ActionButton.test.ts diff --git a/lib/components/ui/__tests__/SecureInput.test.ts b/src/lib/components/ui/__tests__/SecureInput.test.ts similarity index 100% rename from lib/components/ui/__tests__/SecureInput.test.ts rename to src/lib/components/ui/__tests__/SecureInput.test.ts diff --git a/lib/components/ui/__tests__/WarningBanner.test.ts b/src/lib/components/ui/__tests__/WarningBanner.test.ts similarity index 100% rename from lib/components/ui/__tests__/WarningBanner.test.ts rename to src/lib/components/ui/__tests__/WarningBanner.test.ts diff --git a/lib/components/ui/hooks.ts b/src/lib/components/ui/hooks.ts similarity index 100% rename from lib/components/ui/hooks.ts rename to src/lib/components/ui/hooks.ts diff --git a/lib/components/ui/index.ts b/src/lib/components/ui/index.ts similarity index 100% rename from lib/components/ui/index.ts rename to src/lib/components/ui/index.ts diff --git a/lib/components/ui/variants.ts b/src/lib/components/ui/variants.ts similarity index 100% rename from lib/components/ui/variants.ts rename to src/lib/components/ui/variants.ts diff --git a/lib/config.ts b/src/lib/config.ts similarity index 100% rename from lib/config.ts rename to src/lib/config.ts diff --git a/lib/constants.ts b/src/lib/constants.ts similarity index 100% rename from lib/constants.ts rename to src/lib/constants.ts diff --git a/lib/cr-sqlite/install.ts b/src/lib/cr-sqlite/install.ts similarity index 100% rename from lib/cr-sqlite/install.ts rename to src/lib/cr-sqlite/install.ts diff --git a/lib/env.ts b/src/lib/env.ts similarity index 100% rename from lib/env.ts rename to src/lib/env.ts diff --git a/lib/features/SetupSync.tsx b/src/lib/features/SetupSync.tsx similarity index 98% rename from lib/features/SetupSync.tsx rename to src/lib/features/SetupSync.tsx index 079763bd..a268cc48 100644 --- a/lib/features/SetupSync.tsx +++ b/src/lib/features/SetupSync.tsx @@ -1,6 +1,6 @@ import React, { useContext, useEffect, useState, memo } from 'react'; import { Linking, ScrollView } from 'react-native'; -import { hello, sendRescheduleConfirmations, addChangeListener } from '../../modules/my-module'; +import { hello, sendRescheduleConfirmations, addChangeListener } from '../../../modules/my-module'; import { open } from '@op-engineering/op-sqlite'; import { useQuery } from '@powersync/react'; import { PowerSyncContext } from "@powersync/react"; @@ -15,7 +15,7 @@ import { ActionButton, WarningBanner, AlertText } from '@lib/components/ui'; import { emitSyncLog } from '@lib/logging/syncLog'; import { VStack, Card, Text, Link, LinkText, Button, ButtonText } from '@/components/ui'; -import type { RawRescheduleConfirmation } from '../../modules/my-module'; +import type { RawRescheduleConfirmation } from '../../../modules/my-module'; import type { Settings } from '@lib/hooks/SettingsContext'; /** Isolated component for polling timestamp - re-renders every second without affecting parent */ diff --git a/lib/features/__tests__/SetupSync.test.ts b/src/lib/features/__tests__/SetupSync.test.ts similarity index 100% rename from lib/features/__tests__/SetupSync.test.ts rename to src/lib/features/__tests__/SetupSync.test.ts diff --git a/lib/features/__tests__/SetupSync.ui.test.tsx b/src/lib/features/__tests__/SetupSync.ui.test.tsx similarity index 100% rename from lib/features/__tests__/SetupSync.ui.test.tsx rename to src/lib/features/__tests__/SetupSync.ui.test.tsx diff --git a/lib/features/__tests__/__mocks__/env.ts b/src/lib/features/__tests__/__mocks__/env.ts similarity index 100% rename from lib/features/__tests__/__mocks__/env.ts rename to src/lib/features/__tests__/__mocks__/env.ts diff --git a/lib/features/__tests__/__mocks__/gluestackUI.tsx b/src/lib/features/__tests__/__mocks__/gluestackUI.tsx similarity index 100% rename from lib/features/__tests__/__mocks__/gluestackUI.tsx rename to src/lib/features/__tests__/__mocks__/gluestackUI.tsx diff --git a/lib/features/__tests__/__mocks__/vectorIcons.ts b/src/lib/features/__tests__/__mocks__/vectorIcons.ts similarity index 100% rename from lib/features/__tests__/__mocks__/vectorIcons.ts rename to src/lib/features/__tests__/__mocks__/vectorIcons.ts diff --git a/lib/features/__tests__/setupComponentTests.ts b/src/lib/features/__tests__/setupComponentTests.ts similarity index 98% rename from lib/features/__tests__/setupComponentTests.ts rename to src/lib/features/__tests__/setupComponentTests.ts index d4469a20..8e32ffa6 100644 --- a/lib/features/__tests__/setupComponentTests.ts +++ b/src/lib/features/__tests__/setupComponentTests.ts @@ -25,7 +25,7 @@ jest.mock('@react-navigation/native', () => ({ })); // Mock the native module -jest.mock('../../../modules/my-module', () => ({ +jest.mock('../../../../modules/my-module', () => ({ hello: jest.fn(() => 'mocked'), sendRescheduleConfirmations: jest.fn(), addChangeListener: jest.fn(), diff --git a/lib/hooks/SettingsContext.tsx b/src/lib/hooks/SettingsContext.tsx similarity index 100% rename from lib/hooks/SettingsContext.tsx rename to src/lib/hooks/SettingsContext.tsx diff --git a/lib/hooks/SyncDebugContext.tsx b/src/lib/hooks/SyncDebugContext.tsx similarity index 100% rename from lib/hooks/SyncDebugContext.tsx rename to src/lib/hooks/SyncDebugContext.tsx diff --git a/lib/logging/__tests__/syncLog.test.ts b/src/lib/logging/__tests__/syncLog.test.ts similarity index 100% rename from lib/logging/__tests__/syncLog.test.ts rename to src/lib/logging/__tests__/syncLog.test.ts diff --git a/lib/logging/errors.ts b/src/lib/logging/errors.ts similarity index 100% rename from lib/logging/errors.ts rename to src/lib/logging/errors.ts diff --git a/lib/logging/syncLog.ts b/src/lib/logging/syncLog.ts similarity index 100% rename from lib/logging/syncLog.ts rename to src/lib/logging/syncLog.ts diff --git a/lib/navigation/types.ts b/src/lib/navigation/types.ts similarity index 100% rename from lib/navigation/types.ts rename to src/lib/navigation/types.ts diff --git a/lib/orm/index.ts b/src/lib/orm/index.ts similarity index 100% rename from lib/orm/index.ts rename to src/lib/orm/index.ts diff --git a/lib/powersync/Connector.test.ts b/src/lib/powersync/Connector.test.ts similarity index 100% rename from lib/powersync/Connector.test.ts rename to src/lib/powersync/Connector.test.ts diff --git a/lib/powersync/Connector.ts b/src/lib/powersync/Connector.ts similarity index 100% rename from lib/powersync/Connector.ts rename to src/lib/powersync/Connector.ts diff --git a/lib/powersync/Schema.tsx b/src/lib/powersync/Schema.tsx similarity index 100% rename from lib/powersync/Schema.tsx rename to src/lib/powersync/Schema.tsx diff --git a/lib/powersync/index.tsx b/src/lib/powersync/index.tsx similarity index 100% rename from lib/powersync/index.tsx rename to src/lib/powersync/index.tsx diff --git a/lib/powersync/testSetup.ts b/src/lib/powersync/testSetup.ts similarity index 100% rename from lib/powersync/testSetup.ts rename to src/lib/powersync/testSetup.ts diff --git a/lib/theme/ThemeContext.tsx b/src/lib/theme/ThemeContext.tsx similarity index 100% rename from lib/theme/ThemeContext.tsx rename to src/lib/theme/ThemeContext.tsx diff --git a/lib/theme/__tests__/colors.test.ts b/src/lib/theme/__tests__/colors.test.ts similarity index 100% rename from lib/theme/__tests__/colors.test.ts rename to src/lib/theme/__tests__/colors.test.ts diff --git a/lib/theme/colors.ts b/src/lib/theme/colors.ts similarity index 100% rename from lib/theme/colors.ts rename to src/lib/theme/colors.ts diff --git a/app/index.tsx b/src/screens/index.tsx similarity index 100% rename from app/index.tsx rename to src/screens/index.tsx diff --git a/app/settings.tsx b/src/screens/settings.tsx similarity index 100% rename from app/settings.tsx rename to src/screens/settings.tsx diff --git a/app/sync-debug.tsx b/src/screens/sync-debug.tsx similarity index 100% rename from app/sync-debug.tsx rename to src/screens/sync-debug.tsx diff --git a/tailwind.config.js b/tailwind.config.js index a003762a..cc9a07d2 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -2,12 +2,8 @@ module.exports = { darkMode: process.env.DARK_MODE ? process.env.DARK_MODE : 'class', content: [ - './app/**/*.{html,js,jsx,ts,tsx,mdx}', - './components/**/*.{html,js,jsx,ts,tsx,mdx}', - './lib/**/*.{html,js,jsx,ts,tsx,mdx}', - './utils/**/*.{html,js,jsx,ts,tsx,mdx}', - './*.{html,js,jsx,ts,tsx,mdx}', './src/**/*.{html,js,jsx,ts,tsx,mdx}', + './*.{html,js,jsx,ts,tsx,mdx}', ], presets: [require('nativewind/preset')], important: 'html', diff --git a/tsconfig.json b/tsconfig.json index 0549f740..68e37701 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -14,10 +14,10 @@ "baseUrl": ".", "paths": { "@lib/*": [ - "lib/*" + "src/lib/*" ], "@/*": [ - "./*" + "src/*" ], "tailwind.config": [ "./tailwind.config.js" @@ -29,8 +29,6 @@ "src/**/*", "test/**/*", "index.tsx", - "app/**/*", - "lib/**/*", "scripts/**/*.ts", "nativewind-env.d.ts" ],