From aa2e71a04ff36d1540203cfd580739f94d0107c4 Mon Sep 17 00:00:00 2001 From: Jordan Daniels Date: Sat, 22 Jan 2022 02:07:06 -0800 Subject: [PATCH] v2.0.0 ready for publish --- .gitignore | 2 ++ example/src/Home/AlarmList.js | 1 - index.js | 3 --- package.json | 6 +++++- Types.ts => src/Types.ts | 0 src/helpers/Alarm.ts | 2 +- src/helpers/cancelAlarm.ts | 2 +- src/helpers/createAlarm.ts | 2 +- src/helpers/deleteAlarm.ts | 2 +- src/helpers/editAlarm.ts | 2 +- src/helpers/getAlarms.ts | 4 ++-- .../libraryOnlyHelpers/activateAlarmWithoutEdit.ts | 2 +- .../editAlarmWithoutActivateAlarm.ts | 2 +- src/helpers/uuid.ts | 2 +- src/index.js | 3 +++ tsconfig.json | 12 ++++++++++++ 16 files changed, 32 insertions(+), 15 deletions(-) delete mode 100644 index.js rename Types.ts => src/Types.ts (100%) create mode 100644 src/index.js create mode 100644 tsconfig.json diff --git a/.gitignore b/.gitignore index c5464d9..0b76e55 100644 --- a/.gitignore +++ b/.gitignore @@ -40,3 +40,5 @@ local.properties buck-out/ \.buckd/ *.keystore + +dist \ No newline at end of file diff --git a/example/src/Home/AlarmList.js b/example/src/Home/AlarmList.js index 79ddb87..e49c710 100644 --- a/example/src/Home/AlarmList.js +++ b/example/src/Home/AlarmList.js @@ -32,7 +32,6 @@ class AlarmList extends Component { async componentDidMount() { const alarms = await getAlarms(); - console.log('alarms', alarms); // eslint-disable-next-line react/no-did-mount-set-state this.setState({ alarms, diff --git a/index.js b/index.js deleted file mode 100644 index 005673b..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -import * as SimpleAlarm from "./src/helpers"; -export * from "./src/helpers"; -export default { ...SimpleAlarm }; diff --git a/package.json b/package.json index aa3953d..c89073e 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,11 @@ "title": "React Native Simple Alarm", "version": "2.0.0", "description": "Alarm clock functionality for react native ios and android using react-native-push-notification and react-native-community/async-storage", - "main": "index.js", + "main": "./dist/index.js", + "types": "./dist/index.d.ts", + "files": [ + "dist/**" + ], "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, diff --git a/Types.ts b/src/Types.ts similarity index 100% rename from Types.ts rename to src/Types.ts diff --git a/src/helpers/Alarm.ts b/src/helpers/Alarm.ts index ef72d35..e2e443b 100644 --- a/src/helpers/Alarm.ts +++ b/src/helpers/Alarm.ts @@ -11,7 +11,7 @@ // libs import { Platform } from "react-native"; -import { Alarm as AlarmType } from "../../Types"; +import { Alarm as AlarmType } from "../Types"; const emptyProperty = Platform.select({ ios: "", android: null }); diff --git a/src/helpers/cancelAlarm.ts b/src/helpers/cancelAlarm.ts index 7e0e578..2b8ec58 100644 --- a/src/helpers/cancelAlarm.ts +++ b/src/helpers/cancelAlarm.ts @@ -12,7 +12,7 @@ import PushNotificationIOS from "@react-native-community/push-notification-ios"; // local import { getAlarmById } from "./getAlarms"; import { editAlarm } from "./editAlarm"; -import { Alarm as AlarmType } from "../../Types"; +import { Alarm as AlarmType } from "../Types"; export const cancelAlarm = (alarm: AlarmType): void => { if (!alarm) { diff --git a/src/helpers/createAlarm.ts b/src/helpers/createAlarm.ts index c084ad7..41b4c58 100644 --- a/src/helpers/createAlarm.ts +++ b/src/helpers/createAlarm.ts @@ -6,7 +6,7 @@ import Alarm from "./Alarm"; import uuid from "./uuid"; import { activateAlarmWithoutEdit } from "./libraryOnlyHelpers/activateAlarmWithoutEdit"; import { alarmStorage } from "./constants"; -import { Alarm as AlarmType } from "../../Types"; +import { Alarm as AlarmType } from "../Types"; export const createAlarm = async ({ active = false, diff --git a/src/helpers/deleteAlarm.ts b/src/helpers/deleteAlarm.ts index 8071cb4..a03591d 100644 --- a/src/helpers/deleteAlarm.ts +++ b/src/helpers/deleteAlarm.ts @@ -4,7 +4,7 @@ import AsyncStorage from "@react-native-community/async-storage"; // local import { alarmStorage } from "./constants"; import { cancelAlarmWithoutEdit } from "./libraryOnlyHelpers/cancelAlarmWithoutEdit"; -import { Alarm as AlarmType } from "../../Types"; +import { Alarm as AlarmType } from "../Types"; export const deleteAlarm = async (alarm: AlarmType): Promise => { if (!alarm) { diff --git a/src/helpers/editAlarm.ts b/src/helpers/editAlarm.ts index 5fdce98..ae9533a 100644 --- a/src/helpers/editAlarm.ts +++ b/src/helpers/editAlarm.ts @@ -10,7 +10,7 @@ import { alarmStorage } from "./constants"; import { getAlarmById } from "./getAlarms"; import { activateAlarmWithoutEdit } from "./libraryOnlyHelpers/activateAlarmWithoutEdit"; import { cancelAlarmWithoutEdit } from "./libraryOnlyHelpers/cancelAlarmWithoutEdit"; -import { Alarm as AlarmType } from "../../Types"; +import { Alarm as AlarmType } from "../Types"; export const editAlarm = async (alarm: AlarmType): Promise => { if (!alarm) { diff --git a/src/helpers/getAlarms.ts b/src/helpers/getAlarms.ts index c96fbb1..23c00ad 100644 --- a/src/helpers/getAlarms.ts +++ b/src/helpers/getAlarms.ts @@ -3,7 +3,7 @@ import AsyncStorage from "@react-native-community/async-storage"; // local import { alarmStorage } from "./constants"; -import { Alarm as AlarmType } from "../../Types"; +import { Alarm as AlarmType } from "../Types"; export const getAlarms = async (): Promise => { const storage = await AsyncStorage.getItem(alarmStorage); @@ -15,7 +15,7 @@ export const getAlarms = async (): Promise => { } }; -export const getAlarmById = async (id: string | number): Promise | null=> { +export const getAlarmById = async (id: string | number)=> { if (!id) { throw new Error("Please enter an id"); } diff --git a/src/helpers/libraryOnlyHelpers/activateAlarmWithoutEdit.ts b/src/helpers/libraryOnlyHelpers/activateAlarmWithoutEdit.ts index 68ce6f4..0932ed1 100644 --- a/src/helpers/libraryOnlyHelpers/activateAlarmWithoutEdit.ts +++ b/src/helpers/libraryOnlyHelpers/activateAlarmWithoutEdit.ts @@ -17,7 +17,7 @@ import moment from "moment"; // local import { getAlarmById } from "../getAlarms"; import { editAlarmWithoutActivateAlarm } from "./editAlarmWithoutActivateAlarm"; -import { Alarm as AlarmType } from "../../../Types"; +import { Alarm as AlarmType } from "../../Types"; // doesn't call edit alarm again // should only be used within the library diff --git a/src/helpers/libraryOnlyHelpers/editAlarmWithoutActivateAlarm.ts b/src/helpers/libraryOnlyHelpers/editAlarmWithoutActivateAlarm.ts index e92812d..88715b8 100644 --- a/src/helpers/libraryOnlyHelpers/editAlarmWithoutActivateAlarm.ts +++ b/src/helpers/libraryOnlyHelpers/editAlarmWithoutActivateAlarm.ts @@ -8,7 +8,7 @@ import AsyncStorage from "@react-native-community/async-storage"; // local import { alarmStorage } from "../constants"; import { getAlarmById } from "../getAlarms"; -import { Alarm as AlarmType } from "../../../Types"; +import { Alarm as AlarmType } from "../../Types"; // doesn't call activateAlarm again export const editAlarmWithoutActivateAlarm = async (alarm: AlarmType): Promise => { diff --git a/src/helpers/uuid.ts b/src/helpers/uuid.ts index f20eda2..427bcc1 100644 --- a/src/helpers/uuid.ts +++ b/src/helpers/uuid.ts @@ -3,7 +3,7 @@ import { Platform } from "react-native"; export const uuid = () => { if (Platform.OS === "ios") { - function s4() { + const s4 = () => { return Math.floor((1 + Math.random()) * 0x10000) .toString(16) .substring(1); diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000..0a1e9ba --- /dev/null +++ b/src/index.js @@ -0,0 +1,3 @@ +import * as SimpleAlarm from "./helpers"; +export * from "./helpers"; +export default SimpleAlarm; diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..0fbc5cd --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "target": "es5", + "module": "commonjs", + "lib": ["es2017", "es7", "es6", "dom"], + "outDir": "./dist", + "rootDir": "./src", + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true , + "declaration": true + } +} \ No newline at end of file