lincd-cli 0.2.41 → 0.2.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4 @@
1
+ #!/bin/zsh
2
+ . "$(dirname "$0")/_/husky.sh"
3
+
4
+ yarn
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env sh
2
+ . "$(dirname -- "$0")/_/husky.sh"
3
+
4
+ npx lint-staged
@@ -0,0 +1,4 @@
1
+ node_modules
2
+ *.scss.json
3
+ defaults
4
+ package.json
@@ -0,0 +1,24 @@
1
+ {
2
+ "printWidth": 80,
3
+ "tabWidth": 2,
4
+ "bracketSpacing": false,
5
+ "useTabs": false,
6
+ "semi": true,
7
+ "singleQuote": true,
8
+ "trailingComma": "all",
9
+ "endOfLine": "auto",
10
+ "overrides": [
11
+ {
12
+ "files": "*.json",
13
+ "options": {
14
+ "printWidth": 200
15
+ }
16
+ },
17
+ {
18
+ "files": "*.jsonld",
19
+ "options": {
20
+ "parser": "json"
21
+ }
22
+ }
23
+ ]
24
+ }
@@ -3,9 +3,9 @@ import { CapacitorConfig } from '@capacitor/cli';
3
3
  const config: CapacitorConfig = {
4
4
  appId: 'com.mydomain.FILL_IN_YOUR_OWN',
5
5
  appName: 'FILL_IN_YOUR_OWN',
6
- webDir: 'frontend/web',
6
+ webDir: 'web',
7
7
  server: {
8
- allowNavigation: ['DOMAIN', 'APP_DOMAIN'],
8
+ allowNavigation: ['yourdomain.com', 'sub.yourdomain.com'],
9
9
  },
10
10
  bundledWebRuntime: false,
11
11
  //Add or remove plugins that you need. Here is a starter list
@@ -13,85 +13,35 @@ const config: CapacitorConfig = {
13
13
  CapacitorHttp: {
14
14
  enabled: true,
15
15
  },
16
- FirebaseMessaging: {
17
- presentationOptions: ['badge', 'sound', 'alert'],
18
- },
19
- GoogleAuth: {
20
- scopes: ['profile', 'email'],
21
- //self created production web client
22
- clientId: '734627482469-37q563qta2jt6bmhksemmvco8si0pmai.apps.googleusercontent.com',
23
- //For these lines use the auto generated web client "Web client (auto created by Google Service)"
24
- serverClientId: '580968717451-68kpj51ulab8q7drbd3sr7imodai81lp.apps.googleusercontent.com',
25
- androidClientId: '580968717451-68kpj51ulab8q7drbd3sr7imodai81lp.apps.googleusercontent.com',
26
- iosClientId: '580968717451-aoj80o3e8qfjlmbrgabf916mfk4t3ntr.apps.googleusercontent.com',
27
- forceCodeForRefreshToken: true,
28
- },
29
- SplashScreen: {
30
- launchShowDuration: 400,
31
- launchAutoHide: true,
32
- // launchFadeOutDuration: 500,
33
- backgroundColor: '#F7E5FF',
34
- androidSplashResourceName: 'splash',
35
- // androidScaleType: 'CENTER',
36
- showSpinner: false,
37
- // androidSpinnerStyle: 'large',
38
- // iosSpinnerStyle: 'small',
39
- // spinnerColor: '#999999',
40
- splashFullScreen: true,
41
- splashImmersive: true,
42
- // layoutName: 'launch_screen',
43
- // useDialog: true,
44
- },
45
- },
46
- };
47
-
48
- export default config;
49
-
50
- import {CapacitorConfig} from '@capacitor/cli';
51
-
52
- const config: CapacitorConfig = {
53
- appId: 'com.spiritualplaymates.app',
54
- appName: 'Spiritual Playmates',
55
- webDir: 'frontend/web',
56
- server: {
57
- allowNavigation: ['spiritualplaymates.com', 'app.spiritualplaymates.com', 'http://reborn-pro.local:4000'],
58
- },
59
- cordova: {},
60
- plugins: {
61
- FirebaseMessaging: {
62
- presentationOptions: ['badge', 'sound', 'alert'],
63
- },
64
- GoogleAuth: {
65
- scopes: ['profile', 'email'],
66
- //self created production web client
67
- clientId: '734627482469-37q563qta2jt6bmhksemmvco8si0pmai.apps.googleusercontent.com',
68
- serverClientId: '580968717451-68kpj51ulab8q7drbd3sr7imodai81lp.apps.googleusercontent.com',
69
- //auto generated web client
70
- //clientId: '580968717451-68kpj51ulab8q7drbd3sr7imodai81lp.apps.googleusercontent.com ',
71
- androidClientId: '580968717451-68kpj51ulab8q7drbd3sr7imodai81lp.apps.googleusercontent.com',
72
-
73
- iosClientId: '580968717451-aoj80o3e8qfjlmbrgabf916mfk4t3ntr.apps.googleusercontent.com',
74
- forceCodeForRefreshToken: true,
75
- },
76
- CapacitorHttp: {
77
- enabled: true,
78
- },
79
- SplashScreen: {
80
- launchShowDuration: 400,
81
- launchAutoHide: true,
82
- // launchFadeOutDuration: 500,
83
- backgroundColor: '#F7E5FF',
84
- androidSplashResourceName: 'splash',
85
- // androidScaleType: 'CENTER',
86
- showSpinner: false,
87
- // androidSpinnerStyle: 'large',
88
- // iosSpinnerStyle: 'small',
89
- // spinnerColor: '#999999',
90
- splashFullScreen: true,
91
- splashImmersive: true,
92
- // layoutName: 'launch_screen',
93
- // useDialog: true,
94
- },
16
+ // FirebaseMessaging: {
17
+ // presentationOptions: ['badge', 'sound', 'alert'],
18
+ // },
19
+ // GoogleAuth: {
20
+ // scopes: ['profile', 'email'],
21
+ // //self created production web client
22
+ // clientId: '...',
23
+ // //For these lines use the auto generated web client "Web client (auto created by Google Service)"
24
+ // serverClientId: '....',
25
+ // androidClientId: '...',
26
+ // iosClientId: '...',
27
+ // forceCodeForRefreshToken: true,
28
+ // },
29
+ // SplashScreen: {
30
+ // launchShowDuration: 400,
31
+ // launchAutoHide: true,
32
+ // backgroundColor: '#F7E5FF',
33
+ // androidSplashResourceName: 'splash',
34
+ // showSpinner: false,
35
+ // splashFullScreen: true,
36
+ // splashImmersive: true,
37
+ // // launchFadeOutDuration: 500,
38
+ // // androidScaleType: 'CENTER',
39
+ // // androidSpinnerStyle: 'large',
40
+ // // iosSpinnerStyle: 'small',
41
+ // // spinnerColor: '#999999',
42
+ // // layoutName: 'launch_screen',
43
+ // // useDialog: true,
44
+ // },
95
45
  },
96
46
  };
97
47
 
@@ -0,0 +1,28 @@
1
+ import React from 'react';
2
+ import ReactDOM from 'react-dom/client';
3
+ import {BrowserRouter} from 'react-router-dom';
4
+ import App from './App';
5
+ import {BackendAPIStore} from 'lincd-server/lib/shapes/BackendAPIStore';
6
+ import {Storage} from 'lincd/lib/utils/Storage';
7
+ import {AppContextProvider} from 'lincd-server-utils/lib/components/AppContext';
8
+
9
+ const root = ReactDOM.createRoot(
10
+ // document
11
+ // document.body
12
+ document.getElementById('root') as HTMLElement
13
+ );
14
+ //store all quads in a file on the backend named 'main'
15
+ // export const store = new BackendFileStore('main');
16
+ export const store = new BackendAPIStore();
17
+ Storage.setDefaultStore(store);
18
+
19
+
20
+ root.render(
21
+ <React.StrictMode>
22
+ <BrowserRouter>
23
+ <AppContextProvider isNativeApp={true}>
24
+ <App />
25
+ </AppContextProvider>
26
+ </BrowserRouter>
27
+ </React.StrictMode>
28
+ );
@@ -0,0 +1,12 @@
1
+ <component name="ProjectRunConfigurationManager">
2
+ <configuration default="false" name="start" type="js.build_tools.npm" nameIsGenerated="true">
3
+ <package-json value="$PROJECT_DIR$/package.json" />
4
+ <command value="run" />
5
+ <scripts>
6
+ <script value="start" />
7
+ </scripts>
8
+ <node-interpreter value="project" />
9
+ <envs />
10
+ <method v="2" />
11
+ </configuration>
12
+ </component>
@@ -59,6 +59,7 @@
59
59
  "@babel/register": "^7.22.5",
60
60
  "chalk": "4.1.2",
61
61
  "lincd": "^0.5.22",
62
+ "lincd-auth": "^0.1.19",
62
63
  "lincd-jsonld": "^0.1.21",
63
64
  "lincd-server": "^0.1.39",
64
65
  "lincd-server-utils": "^0.1.7",
@@ -9,8 +9,13 @@ export function Header() {
9
9
  <header className={style.header}>
10
10
  <h1>${name}</h1>
11
11
  <nav className={style.menu}>
12
- {Object.keys(ROUTES).map(key => {
13
- return <Link key={key} to={ROUTES[key].path}>{ROUTES[key].label || key}</Link>
12
+ {Object.keys(ROUTES).map((key) => {
13
+ if (ROUTES[key].excludeFromMenu) return null;
14
+ return (
15
+ <Link key={key} to={ROUTES[key].path}>
16
+ {ROUTES[key].label || key}
17
+ </Link>
18
+ );
14
19
  })}
15
20
  </nav>
16
21
  </header>
@@ -0,0 +1,11 @@
1
+ import {DefaultLayout} from '../layout/DefaultLayout';
2
+
3
+ export default function PageNotFound() {
4
+ return (
5
+ <DefaultLayout>
6
+ <div>
7
+ <h2>Page not found</h2>
8
+ </div>
9
+ </DefaultLayout>
10
+ );
11
+ }
@@ -0,0 +1,12 @@
1
+ import {DefaultLayout} from '../layout/DefaultLayout';
2
+
3
+ export default function Signin() {
4
+ return (
5
+ <DefaultLayout>
6
+ <div>
7
+ <h2>Sign In</h2>
8
+ See lincd.org for different ways to sign in.
9
+ </div>
10
+ </DefaultLayout>
11
+ );
12
+ }
@@ -1,21 +1,36 @@
1
1
  import React, {lazy, Suspense} from 'react';
2
2
  import {Route, Routes} from 'react-router-dom';
3
3
  import {Spinner} from './components/Spinner';
4
+ import {RequireAuth} from 'lincd-auth/lib/components/RequireAuth';
5
+ import PageNotFound from './pages/PageNotFound';
4
6
 
5
7
  //In React 18 you can use 'lazy' to import pages only when you need them.
6
8
  //This will cause webpack to create multiple bundles, and the right bundles are automatically loaded
7
-
8
- export const ROUTES = {
9
+ interface RouteObj {
10
+ path: string;
11
+ component?: React.LazyExoticComponent<() => JSX.Element>;
12
+ render?: () => JSX.Element;
13
+ requireAuth?: boolean;
14
+ excludeFromMenu?: boolean;
15
+ label?: string;
16
+ }
17
+ export const ROUTES: {[key: string]: RouteObj} = {
9
18
  index: {
10
19
  path: '/',
11
20
  component: lazy(() => import('./pages/Home' /* webpackPrefetch: true */)),
12
- requireAuth: true,
13
- label:"Home",
21
+ label: 'Home',
14
22
  },
15
23
  page1: {
16
24
  path: '/page1',
17
25
  component: lazy(() => import('./pages/Page1' /* webpackPrefetch: true */)),
18
- label:"Page 1",
26
+ label: 'Protected page',
27
+ requireAuth: true,
28
+ },
29
+ signin: {
30
+ path: '/signin',
31
+ component: lazy(() => import('./pages/Signin' /* webpackPrefetch: true */)),
32
+ label: 'Sign In',
33
+ excludeFromMenu: true,
19
34
  },
20
35
  };
21
36
 
@@ -25,18 +40,33 @@ export default function AppRoutes() {
25
40
  {Object.keys(ROUTES).map((routeName) => {
26
41
  const route = ROUTES[routeName];
27
42
  const Component = route.component;
43
+
44
+ //if a route is marked as requireAuth, wrap it in the RequireAuth component and pass the signinRoute
45
+ const AuthGuard = route.requireAuth ? RequireAuth : React.Fragment;
46
+ const authProps = route.requireAuth
47
+ ? {signinRoute: ROUTES.signin.path}
48
+ : {};
49
+
50
+ // define a render function that determines what to render based on the component and route.render
51
+ const renderRoute = () =>
52
+ // if a Component is defined, render it using JSX syntax (<Component />)
53
+ // if not, check if a route.render function is defined and call that render function if available.
54
+ // if neither Component nor route.render is defined, return null
55
+ Component ? <Component /> : route.render ? route.render() : null;
56
+
28
57
  return (
29
58
  <Route
30
59
  key={route.path}
31
60
  path={route.path}
32
61
  element={
33
- <Suspense fallback={<Spinner />}>
34
- <Component />
35
- </Suspense>
62
+ <AuthGuard {...authProps}>
63
+ <Suspense fallback={<Spinner />}>{renderRoute()}</Suspense>
64
+ </AuthGuard>
36
65
  }
37
66
  />
38
67
  );
39
68
  })}
69
+ <Route path="*" element={<PageNotFound />} />
40
70
  </Routes>
41
71
  );
42
72
  }
@@ -0,0 +1,41 @@
1
+ fs = require('fs');
2
+
3
+ let file = 'android/capacitor-cordova-android-plugins/build.gradle';
4
+
5
+ //check if file exists
6
+ if (!fs.existsSync(file)) {
7
+ console.log('File does not exist.', file);
8
+ } else {
9
+ //read contents of "android/capacitor-cordova-android-plugins/build.gradle"
10
+ let contents = fs.readFileSync(file, 'utf8');
11
+
12
+ if (!contents.includes('namespace')) {
13
+ //insert text on line 19
14
+ contents = contents.replace(
15
+ /android \{/,
16
+ `android {
17
+ namespace 'capacitor.android.plugins'`,
18
+ );
19
+
20
+ //write back to file
21
+ fs.writeFileSync(file, contents, 'utf8');
22
+
23
+ console.log('Added namespace to ' + file);
24
+ } else {
25
+ console.log('Namespace already present in ' + file);
26
+ }
27
+ }
28
+
29
+ let file2 = 'ios/App/Pods/Pods.xcodeproj/project.pbxproj';
30
+ if (!fs.existsSync(file2)) {
31
+ console.log('File does not exist.', file2);
32
+ } else {
33
+ let contents2 = fs.readFileSync(file2, 'utf8');
34
+ if (contents2.includes('IPHONEOS_DEPLOYMENT_TARGET = 12.0')) {
35
+ contents2 = contents2.replace(/IPHONEOS_DEPLOYMENT_TARGET \= 12\.0/g, `IPHONEOS_DEPLOYMENT_TARGET = 13.0`);
36
+ fs.writeFileSync(file2, contents2, 'utf8');
37
+ console.log('Fixed IOS target version for codetrix google oauth plugin');
38
+ } else {
39
+ console.log("Didn't need to fix IOS target version");
40
+ }
41
+ }