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 #58

Closed
wants to merge 9 commits into from
Closed
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"
}
}
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
Binary file added nr-app/build-1736258045007.aab
Binary file not shown.
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;
31 changes: 20 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 @@ -26,6 +26,7 @@
"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 @@ -39,17 +40,18 @@
"fast-text-encoding": "^1.0.6",
"nip06": "^1.2.0",
"nostr-tools": "2.10.3",
"@trustroots/nr-common": "workspace:*",
"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",
Expand All @@ -67,6 +69,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 +81,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
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/
4 changes: 1 addition & 3 deletions nr-common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@

This is code shared between the other parts of the repo.

To initialise it, or after updates, ensure you have deno installed and then run:

deno task cache
To propagate changes to `nr-app`, you need to run `deno task build` in this directory and `pnpm i` in the `nr-app/` directory.
4 changes: 4 additions & 0 deletions nr-common/build/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/src/
/test_runner.js
yarn.lock
pnpm-lock.yaml
7 changes: 7 additions & 0 deletions nr-common/build/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Common

This is code shared between the other parts of the repo.

To initialise it, or after updates, ensure you have deno installed and then run:

deno task cache
28 changes: 28 additions & 0 deletions nr-common/build/esm/constants.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
export declare const DERIVED_EVENT_PLUS_CODE_PREFIX_MINIMUM_LENGTH: 2;
export declare const MAP_NOTE_KIND: 30397;
export declare const MAP_NOTE_REPOST_KIND: 30398;
export declare const OPEN_LOCATION_CODE_TAG_NAME: "open-location-code";
export declare const OPEN_LOCATION_CODE_PREFIX_TAG_NAME: "open-location-code-prefix";
export declare const DEFAULT_RELAY_URL = "wss://relay.trustroots.org";
export declare const DEV_PUBKEY: "80789235a71a388074abfa5c482e270456d2357425266270f82071cf2b1de74a";
export declare const NOSTROOTS_VALIDATION_PUBKEY: "f5bc71692fc08ea52c0d1c8bcfb87579584106b5feb4ea542b1b8a95612f257b";
export declare const HITCHMAPS_AUTHOR_PUBLIC_KEY: "53055ee011e96a00a705b38253b9cbc6614ccbd37df4dad42ec69bbe608c4209";
export declare const HITCHWIKI_AUTHOR_PUBLIC_KEY: "16db5234c1dd8082897bd2d21bbec4b8051d2cd03e24b819aa5232077d443da9";
export declare const TIMESAFARI_AUTHOR_PUBLIC_KEY: "76e88d2e653fc3655f8e0b97f6bc85f5468eaffc5d64522b584ce13eedbd8af7";
export type MapLayer = {
title: string;
rootUrl: string;
kind: 30399 | 30398 | 30397;
pubkey: string;
markerColor: string;
rectangleColor: string;
};
export declare const MAP_LAYERS: {
readonly hitchmap: MapLayer;
readonly hitchwiki: MapLayer;
readonly timesafari: MapLayer;
readonly triphopping: MapLayer;
readonly unverified: MapLayer;
};
export type MAP_LAYER_KEY = keyof typeof MAP_LAYERS;
//# sourceMappingURL=constants.d.ts.map
1 change: 1 addition & 0 deletions nr-common/build/esm/constants.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading