Skip to content

Commit

Permalink
Merge branch 'main' into ci-deploy-roid
Browse files Browse the repository at this point in the history
  • Loading branch information
NigelBreslaw committed Jan 5, 2024
2 parents d371977 + b33aaa8 commit 03522da
Show file tree
Hide file tree
Showing 38 changed files with 542 additions and 233 deletions.
9 changes: 9 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ updates:
directory: "/gg-mono" # Location of package manifests
schedule:
interval: "daily"
time: "07:00"
groups:
production-dependencies:
dependency-type: "production"
Expand All @@ -21,6 +22,7 @@ updates:
directory: "/native_gg" # Location react native package.json
schedule:
interval: "daily"
time: "07:00"
groups:
production-dependencies:
dependency-type: "production"
Expand All @@ -31,3 +33,10 @@ updates:
- "vitest*"
- "@react-native*"
- "@babel*"
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
# Workflow files stored in the default location of `.github/workflows`. (You don't need to specify `/.github/workflows` for `directory`. You can use `directory: "/"`.)
directory: "/"
schedule:
interval: "daily"
time: "07:00"
29 changes: 18 additions & 11 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,34 @@ on:
branches: [ main ]

jobs:

build:
name: build
runs-on: ubuntu-latest
defaults:
run:
working-directory: gg-mono
# defaults:
# run:
# working-directory: gg-mono
timeout-minutes: 1
steps:
- uses: actions/[email protected]
- uses: pnpm/[email protected]
with:
version: 8.12.1
- name: install dependencies
run: pnpm install --frozen-lockfile
run: cd gg-mono && pnpm install --frozen-lockfile
- name: lint
run: pnpm lint
run: cd gg-mono && pnpm lint
- name: format
run: pnpm format:check
run: cd gg-mono && pnpm format:check
- name: build
run: pnpm build

run: cd gg-mono && pnpm build
- name: install dependencies
run: cd native_gg && pnpm install --frozen-lockfile
- name: lint
run: cd native_gg && pnpm lint
- name: format
run: cd native_gg && pnpm format:check


changes:
runs-on: ubuntu-latest
outputs:
Expand All @@ -34,8 +41,8 @@ jobs:
docs: ${{ steps.changes.outputs.docs }}
react-native: ${{ steps.changes.outputs.react-native }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v2
- uses: actions/checkout@v4.1.1
- uses: dorny/paths-filter@v2.11.1
id: changes
with:
filters: |
Expand Down
5 changes: 3 additions & 2 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
"enabled": true
},
"formatter": {
"indentWidth": 4,
"indentWidth": 2,
"indentStyle": "space",
"lineWidth": 120
"lineWidth": 120,
"ignore": ["ios/**"]
},
"linter": {
"enabled": true,
Expand Down
2 changes: 2 additions & 0 deletions gg-mono/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# New dependencies should be an exact version
save-prefix=""
2 changes: 1 addition & 1 deletion gg-mono/apps/dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@gg-monorepo/dashboard",
"version": "0.0.1",
"dependencies": {
"solid-js": "1.8.7"
"solid-js": "1.8.8"
},
"devDependencies": {
"@vitest/coverage-v8": "1.1.1",
Expand Down
40 changes: 20 additions & 20 deletions gg-mono/apps/dashboard/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@ import "./App.css";
import solidLogo from "./assets/solid.svg";

function App() {
const [count, setCount] = createSignal(0);
const [count, setCount] = createSignal(0);

return (
<>
<div>
<a href="https://vitejs.dev" target="_blank" rel="noreferrer">
<img src={viteLogo} class="logo" alt="Vite logo" />
</a>
<a href="https://solidjs.com" target="_blank" rel="noreferrer">
<img src={solidLogo} class="logo solid" alt="Solid logo" />
</a>
</div>
<h1>Placeholder for dashboard!</h1>
<div class="card">
<button type="button" onClick={() => setCount((count) => count + 1)}>
count is {count()}
</button>
<p>Developer stats coming soon.</p>
</div>
</>
);
return (
<>
<div>
<a href="https://vitejs.dev" target="_blank" rel="noreferrer">
<img src={viteLogo} class="logo" alt="Vite logo" />
</a>
<a href="https://solidjs.com" target="_blank" rel="noreferrer">
<img src={solidLogo} class="logo solid" alt="Solid logo" />
</a>
</div>
<h1>Placeholder for dashboard!</h1>
<div class="card">
<button type="button" onClick={() => setCount((count) => count + 1)}>
count is {count()}
</button>
<p>Developer stats coming soon.</p>
</div>
</>
);
}

export default App;
7 changes: 7 additions & 0 deletions gg-mono/apps/dashboard/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,11 @@ import solid from 'vite-plugin-solid'

export default defineConfig({
plugins: [solid()],
server: {
open: true,
host: '127.0.0.1'
},
build: {
sourcemap: true,
}
})
196 changes: 98 additions & 98 deletions gg-mono/apps/react-frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,105 +4,105 @@ import { deleteCookie, getCookie, setCookie } from "./Utilities";
type AuthState = "pre-auth" | "waiting-for-auth" | "waiting-for-token" | "authorized";

const App: React.FC = () => {
const [authState, setAuthState] = useState<AuthState>("pre-auth");

const cookieName = "auth-state";

const startAuth = () => {
const stateID = crypto.randomUUID();
const [authState, setAuthState] = useState<AuthState>("pre-auth");

const cookieName = "auth-state";

const startAuth = () => {
const stateID = crypto.randomUUID();
deleteCookie(cookieName);
setCookie(cookieName, stateID, { sameSite: "strict", maxAge: 20 });

const bungieURL = `https://www.bungie.net/en/oauth/authorize?client_id=45432&response_type=code&state=${stateID}`;
window.location.href = bungieURL;
};

const determineState = () => {
const cookie = getCookie(cookieName);

if (cookie) {
setAuthState("waiting-for-auth");
}
console.log("cookie", cookie);
};

// biome-ignore lint/correctness/useExhaustiveDependencies: Should run once on mount
useEffect(() => {
determineState();
}, []);

useEffect(() => {
if (authState === "waiting-for-auth") {
const currentUrl = new URL(window.location.href);
const code = currentUrl.searchParams.get("code");
const state = currentUrl.searchParams.get("state");

if (code && state) {
console.log("Authorization successful!");
console.log("Code:", code);
console.log("State:", state);
setAuthState("waiting-for-token");
// Stop showing the returned token in the url
// window.location.href = currentUrl.origin
} else {
deleteCookie(cookieName);
setCookie(cookieName, stateID, { sameSite: "strict", maxAge: 20 });

const bungieURL = `https://www.bungie.net/en/oauth/authorize?client_id=45432&response_type=code&state=${stateID}`;
window.location.href = bungieURL;
};

const determineState = () => {
const cookie = getCookie(cookieName);

if (cookie) {
setAuthState("waiting-for-auth");
}
console.log("cookie", cookie);
};

// biome-ignore lint/correctness/useExhaustiveDependencies: Should run once on mount
useEffect(() => {
determineState();
}, []);

useEffect(() => {
if (authState === "waiting-for-auth") {
const currentUrl = new URL(window.location.href);
const code = currentUrl.searchParams.get("code");
const state = currentUrl.searchParams.get("state");

if (code && state) {
console.log("Authorization successful!");
console.log("Code:", code);
console.log("State:", state);
setAuthState("waiting-for-token");
// Stop showing the returned token in the url
// window.location.href = currentUrl.origin
} else {
deleteCookie(cookieName);
console.error("Authorization failed. State mismatch.");
}
}

if (authState === "waiting-for-token") {
const currentUrl = new URL(window.location.href);
window.location.href = currentUrl.origin;
console.log("waiting for token");
}
}, [authState]);
// useEffect(() => {
// // Function to parse URL parameters
// const getCodeFromUrl = (url: URL): string | null => {
// const state = url.searchParams.get("state")

// if (originalState.current === state) {
// const code = url.searchParams.get("code")
// if (code) {
// return code
// } else {
// throw new Error("No code in URL")
// }
// } else {
// throw new Error("State mismatch")
// }
// }

// const currentUrl = new URL(window.location.href);
// const urlParams = getCodeFromUrl(currentUrl);

// // Check if 'state' matches the original state
// if (urlParams) {
// // Perform actions with 'code' and 'state'
// console.log("Authorization successful!")
// console.log("Code:", urlParams)
// // console.log('State:', state);
// // Clear the state cookie once used
// deleteCookie(cookieName)
// } else {
// console.error("Authorization failed. State mismatch.")
// }
// }, [])

return (
<>
<h1>Ishtar For Web</h1>
<h2>Auth State: {authState}</h2>

<div>
{authState === "pre-auth" && (
<button type="button" onClick={startAuth}>
Auth
</button>
)}
</div>
</>
);
console.error("Authorization failed. State mismatch.");
}
}

if (authState === "waiting-for-token") {
const currentUrl = new URL(window.location.href);
window.location.href = currentUrl.origin;
console.log("waiting for token");
}
}, [authState]);
// useEffect(() => {
// // Function to parse URL parameters
// const getCodeFromUrl = (url: URL): string | null => {
// const state = url.searchParams.get("state")

// if (originalState.current === state) {
// const code = url.searchParams.get("code")
// if (code) {
// return code
// } else {
// throw new Error("No code in URL")
// }
// } else {
// throw new Error("State mismatch")
// }
// }

// const currentUrl = new URL(window.location.href);
// const urlParams = getCodeFromUrl(currentUrl);

// // Check if 'state' matches the original state
// if (urlParams) {
// // Perform actions with 'code' and 'state'
// console.log("Authorization successful!")
// console.log("Code:", urlParams)
// // console.log('State:', state);
// // Clear the state cookie once used
// deleteCookie(cookieName)
// } else {
// console.error("Authorization failed. State mismatch.")
// }
// }, [])

return (
<>
<h1>Ishtar For Web</h1>
<h2>Auth State: {authState}</h2>

<div>
{authState === "pre-auth" && (
<button type="button" onClick={startAuth}>
Auth
</button>
)}
</div>
</>
);
};

export default App;
Loading

0 comments on commit 03522da

Please sign in to comment.