Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

monorepo squashed commit #59

Draft
wants to merge 2 commits into
base: monorepo
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@jsr:registry=https://npm.jsr.io
11 changes: 7 additions & 4 deletions nr-app/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@
"backgroundColor": "#ffffff"
},
"ios": {
"supportsTablet": true
"supportsTablet": true,
"bundleIdentifier": "org.trustroots.nostroots"
},
"android": {
"adaptiveIcon": {
"foregroundImage": "./assets/images/adaptive-icon.png",
"backgroundColor": "#ffffff"
}
},
"package": "org.trustroots.nostroots"
},
"web": {
"bundler": "metro",
Expand All @@ -40,7 +42,7 @@
"origin": false
},
"eas": {
"projectId": "0147b304-d2cd-4e24-a237-da8bd5f3e4f3"
"projectId": "a6c7b2e0-f036-44a3-b57c-d05b9d383c30"
}
},
"runtimeVersion": {
Expand All @@ -49,6 +51,7 @@
"newArchEnabled": true,
"updates": {
"url": "https://u.expo.dev/0147b304-d2cd-4e24-a237-da8bd5f3e4f3"
}
},
"owner": "nostroots"
}
}
14 changes: 6 additions & 8 deletions nr-app/app/(tabs)/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,21 @@ import Toast from "react-native-root-toast";
const DevSwitch = () => {
const [devMode, setDevMode] = useState(true); // Local state for toggle

const toggleVisibility = (value: boolean | ((prevState: boolean) => boolean)) => {
const toggleVisibility = (
value: boolean | ((prevState: boolean) => boolean),
) => {
setDevMode(value); // Update visibility based on switch value
};

return (
<View>
<Switch
value={devMode}
onValueChange={toggleVisibility}
/>
<Text>dev mode</Text>
{devMode && <Text>DEV MODE ON</Text>}
<Switch value={devMode} onValueChange={toggleVisibility} />
<Text>dev mode</Text>
{devMode && <Text>DEV MODE ON</Text>}
</View>
);
};


export default function TabThreeScreen() {
const [nsec, setNsec] = useState("");
const [mnemonic, setMnemonic] = useState("");
Expand Down
19 changes: 3 additions & 16 deletions nr-app/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,10 @@ module.exports = function (api) {
presets: ["babel-preset-expo"],
plugins: [
[
"module-resolver",
"babel-plugin-root-import",
{
extensions: [
".ios.js",
".android.js",
".ios.jsx",
".android.jsx",
".js",
".jsx",
".json",
".ts",
".tsx",
],
root: ["."],
alias: {
"@common": "../nr-common",
},
rootPathPrefix: "@/",
rootPathSuffix: "src/",
},
],
],
Expand Down
11 changes: 5 additions & 6 deletions nr-app/eas_DISABLED.json → nr-app/eas.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
{
"cli": {
"version": ">= 11.0.3"
"version": ">= 14.2.0",
"appVersionSource": "remote"
},
"build": {
"development": {
"developmentClient": true,
"distribution": "internal",
"channel": "development"
"distribution": "internal"
},
"preview": {
"distribution": "internal",
"channel": "preview"
"distribution": "internal"
},
"production": {
"channel": "production"
"autoIncrement": true
}
},
"submit": {
Expand Down
21 changes: 13 additions & 8 deletions nr-app/metro.config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
// Learn more https://docs.expo.io/guides/customizing-metro
// Learn more https://docs.expo.dev/guides/monorepos
const { getDefaultConfig } = require("expo/metro-config");
const path = require("path");

/** @type {import('expo/metro-config').MetroConfig} */
const config = getDefaultConfig(__dirname);
const projectRoot = __dirname;
const workspaceRoot = path.resolve(projectRoot, "..");

const extraConfig = {
watchFolders: [path.resolve(`${__dirname}/../nr-common/`)],
};
const config = getDefaultConfig(projectRoot);

const mergedConfig = { ...config, ...extraConfig };
// Since we are using pnpm, we have to setup the monorepo manually for Metro
// #1 - Watch all files in the monorepo
config.watchFolders = [workspaceRoot];
// #2 - Try resolving with project modules first, then workspace modules
config.resolver.nodeModulesPaths = [
path.resolve(projectRoot, "node_modules"),
path.resolve(workspaceRoot, "node_modules"),
];

module.exports = mergedConfig;
module.exports = config;
32 changes: 21 additions & 11 deletions nr-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"scripts": {
"start": "expo start",
"reset-project": "node ./scripts/reset-project.js",
"android": "expo start --android",
"ios": "expo start --ios",
"android": "expo run:android",
"ios": "expo run:ios",
"web": "expo start --web",
"test": "jest --watchAll",
"lint": "expo lint",
Expand All @@ -23,9 +23,11 @@
"@mobily/ts-belt": "^3.13.1",
"@react-navigation/native": "^7.0.3",
"@reduxjs/toolkit": "^2.2.7",
"@trustroots/nr-common": "workspace:*",
"expo": "~52.0.8",
"expo-constants": "~17.0.3",
"expo-crypto": "~14.0.1",
"expo-dev-client": "~5.0.7",
"expo-font": "~13.0.1",
"expo-linking": "~7.0.3",
"expo-router": "~4.0.7",
Expand All @@ -42,21 +44,22 @@
"open-location-code-typescript": "^1.5.0",
"react": "18.3.1",
"react-dom": "18.3.1",
"react-native": "0.76.2",
"react-native": "0.76.5",
"react-native-gesture-handler": "~2.20.2",
"react-native-get-random-values": "^1.11.0",
"react-native-maps": "1.18.0",
"react-native-reanimated": "~3.16.1",
"react-native-root-toast": "^3.6.0",
"react-native-safe-area-context": "4.12.0",
"react-native-screens": "4.1.0",
"react-native-screens": "4.4.0",
"react-native-web": "~0.19.13",
"react-redux": "^9.1.2",
"reactotron-react-native": "^5.1.10",
"redux-devtools-expo-dev-plugin": "^1.0.0",
"redux-saga": "^1.3.0",
"redux-saga-promise-actions": "^1.3.5",
"url-join": "^5.0.0",
"utils": "link:@noble/hashes/utils",
"zod": "^3.23.8"
},
"devDependencies": {
Expand All @@ -67,6 +70,7 @@
"@types/react": "~18.3.12",
"@types/react-test-renderer": "^18.0.7",
"babel-plugin-module-resolver": "^5.0.2",
"babel-plugin-root-import": "^6.6.0",
"eslint": "^8.57.0",
"eslint-config-expo": "^8.0.1",
"eslint-config-prettier": "^9.1.0",
Expand All @@ -78,11 +82,17 @@
"react-test-renderer": "18.2.0",
"typescript": "~5.3.3"
},
"pnpm": {
"overrides": {
"redux": "^5.0.1"
}
},
"private": true,
"packageManager": "[email protected]+sha512.e5a7e52a4183a02d5931057f7a0dbff9d5e9ce3161e33fa68ae392125b79282a8a8a470a51dfc8a0ed86221442eb2fb57019b0990ed24fab519bf0e1bc5ccfc4"
}
"packageManager": "[email protected]+sha512.e5a7e52a4183a02d5931057f7a0dbff9d5e9ce3161e33fa68ae392125b79282a8a8a470a51dfc8a0ed86221442eb2fb57019b0990ed24fab519bf0e1bc5ccfc4",
"expo": {
"doctor": {
"reactNativeDirectoryCheck": {
"listUnknownPackages": false,
"exclude": [
"expo-split-pane",
"react-native-maps"
]
}
}
}
}
2 changes: 1 addition & 1 deletion nr-app/src/__tests__/nr-common-utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isPlusCode } from "@common/utils";
import { isPlusCode } from "@trustroots/nr-common";

const plusCodeTestData: [string, number, number, number, number, number][] = [
["7FG49Q00+", 6, 20.35, 2.75, 20.4, 2.8],
Expand Down
4 changes: 2 additions & 2 deletions nr-app/src/common/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Filter } from "nostr-tools";
import { MapLayer, NOSTROOTS_VALIDATION_PUBKEY } from "@common/constants";
import { isHexKey } from "@common/utils";
import { MapLayer, NOSTROOTS_VALIDATION_PUBKEY } from "@trustroots/nr-common";
import { isHexKey } from "@trustroots/nr-common";

// TODO - Move these into `nr-common` (they depend on nostr-tools)

Expand Down
2 changes: 1 addition & 1 deletion nr-app/src/components/Map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { publishNotePromiseAction } from "@/redux/actions/publish.actions";
import { useAppDispatch, useAppSelector } from "@/redux/hooks";
import { mapActions, mapSelectors } from "@/redux/slices/map.slice";
import { coordinatesToPlusCode } from "@/utils/map.utils";
import { MAP_LAYER_KEY, MAP_LAYERS, MapLayer } from "@common/constants";
import { MAP_LAYER_KEY, MAP_LAYERS, MapLayer } from "@trustroots/nr-common";
import React, { useMemo, useState } from "react";
import { Button, Modal, TextInput } from "react-native";
import Toast from "react-native-root-toast";
Expand Down
2 changes: 1 addition & 1 deletion nr-app/src/components/MapMarkers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from "@/redux/slices/events.slice";
import { mapActions, mapSelectors } from "@/redux/slices/map.slice";
import { allPlusCodesForRegion } from "@/utils/map.utils";
import { MAP_LAYER_KEY, MAP_LAYERS } from "@common/constants";
import { MAP_LAYER_KEY, MAP_LAYERS } from "@trustroots/nr-common";
import { createSelector } from "@reduxjs/toolkit";
import { matchFilter } from "nostr-tools";
import { Fragment, useMemo } from "react";
Expand Down
2 changes: 1 addition & 1 deletion nr-app/src/components/MapNoteMarker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
plusCodeToCoordinates,
plusCodeToRectangle,
} from "@/utils/map.utils";
import { getFirstLabelValueFromEvent } from "@common/utils";
import { getFirstLabelValueFromEvent } from "@trustroots/nr-common";
import React, { memo } from "react";
import { Linking, StyleSheet, Text, View } from "react-native";
import { Callout, Marker, Polygon } from "react-native-maps";
Expand Down
2 changes: 1 addition & 1 deletion nr-app/src/nostr/keystore.nostr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
SECURE_STORE_PRIVATE_KEY_HEX_KEY,
SECURE_STORE_PRIVATE_KEY_HEX_NMEONIC,
} from "@/constants";
import { isHexKey } from "@common/utils";
import { isHexKey } from "@trustroots/nr-common";
import { hexToBytes } from "@noble/hashes/utils";
import * as SecureStore from "expo-secure-store";
import { accountFromSeedWords } from "nip06";
Expand Down
2 changes: 1 addition & 1 deletion nr-app/src/redux/actions/publish.actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { SerializableError } from "@/utils/error.utils";
import {
getCurrentTimestamp,
getPlusCodeAndPlusCodePrefixTags,
} from "@common/utils";
} from "@trustroots/nr-common";
import { nanoid } from "@reduxjs/toolkit";
import { EventTemplate } from "nostr-tools";
import { createPromiseAction } from "redux-saga-promise-actions";
Expand Down
2 changes: 1 addition & 1 deletion nr-app/src/redux/sagas/map.saga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
filterForMapLayerConfig,
trustrootsMapFilterForPlusCodePrefixes,
} from "@/common/utils";
import { MAP_LAYER_KEY, MAP_LAYERS } from "@common/constants";
import { MAP_LAYER_KEY, MAP_LAYERS } from "@trustroots/nr-common";
import { createSelector } from "@reduxjs/toolkit";
import { Filter } from "nostr-tools";
import { AnyAction } from "redux-saga";
Expand Down
2 changes: 1 addition & 1 deletion nr-app/src/redux/sagas/subscriptions.saga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
getSubscription,
subscribeToFilter,
} from "@/nostr/subscriptions.nostr";
import { DEFAULT_RELAY_URL } from "@common/constants";
import { DEFAULT_RELAY_URL } from "@trustroots/nr-common";
import { Subscription } from "nostr-tools/lib/types/abstract-relay";
import {
all,
Expand Down
2 changes: 1 addition & 1 deletion nr-app/src/redux/slices/events.slice.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ID_SEPARATOR } from "@/constants";
import { Event, isValidEvent } from "@common/mod";
import { Event, isValidEvent } from "@trustroots/nr-common";
import {
createEntityAdapter,
createSlice,
Expand Down
2 changes: 1 addition & 1 deletion nr-app/src/redux/slices/map.slice.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MAP_LAYER_KEY } from "@common/constants";
import { MAP_LAYER_KEY } from "@trustroots/nr-common";
import { createSelector, createSlice, PayloadAction } from "@reduxjs/toolkit";
import { LatLng } from "react-native-maps";
import { setVisiblePlusCodes } from "../actions/map.actions";
Expand Down
2 changes: 1 addition & 1 deletion nr-app/src/redux/slices/relays.slice.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DEFAULT_RELAY_URL } from "@common/constants";
import { DEFAULT_RELAY_URL } from "@trustroots/nr-common";
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
import { Filter } from "nostr-tools";

Expand Down
26 changes: 26 additions & 0 deletions nr-app/src/redux/slices/settings.slice.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { createSlice, PayloadAction } from "@reduxjs/toolkit";

type SettingsState = {
areTestFeaturesEnabled: boolean;
};

const initialState: SettingsState = {
areTestFeaturesEnabled: false,
};

export const settingsSlice = createSlice({
name: "settings",
initialState,
reducers: {
toggleTestFeatures: (state, action: PayloadAction) => {
state.areTestFeaturesEnabled = !state.areTestFeaturesEnabled;
},
},
selectors: {
selectAreTestFeaturesEnabled: (state) => state.areTestFeaturesEnabled,
},
});

export const settingsActions = settingsSlice.actions;

export const settingsSelectors = settingsSlice.selectors;
2 changes: 2 additions & 0 deletions nr-app/src/redux/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { eventsSlice } from "./slices/events.slice";
import { mapSlice } from "./slices/map.slice";
import { relaysSlice } from "./slices/relays.slice";
import { keystoreSlice } from "./slices/keystore.slice";
import { settingsSlice } from "./slices/settings.slice";

const isOnDevice = Platform.OS !== "web";

Expand All @@ -21,6 +22,7 @@ const reducer = combineSlices(
keystoreSlice,
mapSlice,
relaysSlice,
settingsSlice,
);

export const store = configureStore({
Expand Down
4 changes: 2 additions & 2 deletions nr-app/src/utils/map.utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { NOSTR_EVENT_INDEX_MAXIMUM_PLUS_CODE_LENGTH } from "@/constants";
import { MAP_LAYER_KEY, MAP_LAYERS, MapLayer } from "@common/constants";
import { getFirstTagValueFromEvent } from "@common/utils";
import { MAP_LAYER_KEY, MAP_LAYERS, MapLayer } from "@trustroots/nr-common";
import { getFirstTagValueFromEvent } from "@trustroots/nr-common";
import { NostrEvent } from "nostr-tools";
import OpenLocationCode from "open-location-code-typescript";
import urlJoin from "url-join";
Expand Down
3 changes: 1 addition & 2 deletions nr-app/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
"compilerOptions": {
"strict": true,
"paths": {
"@/*": ["./src/*"],
"@common/*": ["../nr-common/*"]
"@/*": ["./src/*"]
},
"allowImportingTsExtensions": true
},
Expand Down
2 changes: 1 addition & 1 deletion nr-common/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
node_modules/
node_modules/
Loading