@common-stack/generate-plugin 6.0.2-alpha.7 → 6.0.2-alpha.8
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.
- package/CHANGELOG.md +4 -0
- package/lib/generators/add-frontend/frameworks/chakraui/entry.client.tsx.template +30 -24
- package/lib/generators/add-frontend/frameworks/chakraui/entry.server.tsx.template +5 -8
- package/lib/generators/add-frontend/frameworks/chakraui/root.tsx.template +3 -3
- package/lib/generators/add-fullstack/files/package.json +1 -1
- package/package.json +2 -2
- package/src/generators/add-frontend/frameworks/chakraui/entry.client.tsx.template +30 -24
- package/src/generators/add-frontend/frameworks/chakraui/entry.server.tsx.template +5 -8
- package/src/generators/add-frontend/frameworks/chakraui/root.tsx.template +3 -3
- package/src/generators/add-fullstack/files/package.json +1 -1
- package/lib/generators/add-fullstack/files/jest.config copy.js +0 -27
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [6.0.2-alpha.8](https://github.com/cdmbase/common-stack/compare/v6.0.2-alpha.7...v6.0.2-alpha.8) (2024-08-23)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @common-stack/generate-plugin
|
|
9
|
+
|
|
6
10
|
## [6.0.2-alpha.7](https://github.com/cdmbase/common-stack/compare/v6.0.2-alpha.6...v6.0.2-alpha.7) (2024-08-23)
|
|
7
11
|
|
|
8
12
|
**Note:** Version bump only for package @common-stack/generate-plugin
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState, startTransition, StrictMode } from 'react';
|
|
1
|
+
import React, { useState, startTransition, StrictMode, useMemo, createContext, useContext } from 'react';
|
|
2
2
|
import 'reflect-metadata';
|
|
3
3
|
import { RemixBrowser } from '@remix-run/react';
|
|
4
4
|
import { hydrateRoot } from 'react-dom/client';
|
|
@@ -27,7 +27,8 @@ import Backend from 'i18next-http-backend';
|
|
|
27
27
|
import { getInitialNamespaces } from 'remix-i18next/client';
|
|
28
28
|
import config from '@app/cde-webconfig.json';
|
|
29
29
|
// @ts-ignore
|
|
30
|
-
import { ClientStyleContext } from '@app/frontend-stack-react/entries/chakraui/context.js';
|
|
30
|
+
// import { ClientStyleContext } from '@app/frontend-stack-react/entries/chakraui/context.js';
|
|
31
|
+
import { ClientStyleContext } from './context';
|
|
31
32
|
|
|
32
33
|
const { apolloClient: client, container, serviceFunc } = createClientContainer();
|
|
33
34
|
const { store } = createReduxStore(client, serviceFunc(), container);
|
|
@@ -40,16 +41,21 @@ interface ClientCacheProviderProps {
|
|
|
40
41
|
children: React.ReactNode;
|
|
41
42
|
}
|
|
42
43
|
|
|
44
|
+
export function useClientStyleContext() {
|
|
45
|
+
return useContext(ClientStyleContext);
|
|
46
|
+
}
|
|
47
|
+
|
|
43
48
|
function ClientCacheProvider({ children }: ClientCacheProviderProps) {
|
|
44
|
-
const [
|
|
49
|
+
const [count, setCount] = useState(0);
|
|
50
|
+
const defaultCache = useMemo(() => createEmotionCache(), [count]);
|
|
45
51
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
52
|
+
const reset = () => {
|
|
53
|
+
setCount((prev) => prev + 1);
|
|
54
|
+
};
|
|
49
55
|
|
|
50
56
|
return (
|
|
51
57
|
<ClientStyleContext.Provider value={{ reset }}>
|
|
52
|
-
<CacheProvider value={
|
|
58
|
+
<CacheProvider value={defaultCache}>{children}</CacheProvider>
|
|
53
59
|
</ClientStyleContext.Provider>
|
|
54
60
|
);
|
|
55
61
|
}
|
|
@@ -75,23 +81,23 @@ async function hydrate() {
|
|
|
75
81
|
}
|
|
76
82
|
hydrateRoot(
|
|
77
83
|
document.getElementById('root')!,
|
|
78
|
-
<StrictMode>
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
</StrictMode>,
|
|
84
|
+
// <StrictMode>
|
|
85
|
+
<I18nextProvider i18n={i18next}>
|
|
86
|
+
<ClientCacheProvider>
|
|
87
|
+
<ApolloProvider client={client}>
|
|
88
|
+
<ReduxProvider store={store}>
|
|
89
|
+
<SlotFillProvider>
|
|
90
|
+
<InversifyProvider container={container} modules={clientModules}>
|
|
91
|
+
<PersistGate loading={null} persistor={persistor}>
|
|
92
|
+
{() => <RemixBrowser />}
|
|
93
|
+
</PersistGate>
|
|
94
|
+
</InversifyProvider>
|
|
95
|
+
</SlotFillProvider>
|
|
96
|
+
</ReduxProvider>
|
|
97
|
+
</ApolloProvider>
|
|
98
|
+
</ClientCacheProvider>
|
|
99
|
+
</I18nextProvider>,
|
|
100
|
+
// </StrictMode>,
|
|
95
101
|
);
|
|
96
102
|
// });
|
|
97
103
|
}
|
|
@@ -36,8 +36,10 @@ import config from '@app/cde-webconfig.json';
|
|
|
36
36
|
|
|
37
37
|
import { Head } from './root';
|
|
38
38
|
import type { IAppLoadContext } from '@common-stack/client-core';
|
|
39
|
-
import { ServerStyleContext } from '@app/frontend-stack-react/entries/chakraui/context.js';
|
|
39
|
+
// import { ServerStyleContext } from '@app/frontend-stack-react/entries/chakraui/context.js';
|
|
40
|
+
import { ServerStyleContext } from './context';
|
|
40
41
|
import { i18nextInstance as i18next } from '@app/frontend-stack-react/i18n-localization/i18next.server.js';
|
|
42
|
+
|
|
41
43
|
const { extractCriticalToChunks } = createEmotionServer(defaultCache);
|
|
42
44
|
|
|
43
45
|
const ABORT_DELAY = 5000;
|
|
@@ -124,12 +126,7 @@ async function handleBrowserRequest(
|
|
|
124
126
|
// And here we detect what namespaces the routes about to render want to use
|
|
125
127
|
const ns = i18next.getRouteNamespaces(remixContext);
|
|
126
128
|
const slotFillContext = { fills: {} };
|
|
127
|
-
const {
|
|
128
|
-
modules: clientModules,
|
|
129
|
-
container,
|
|
130
|
-
apolloClient: client,
|
|
131
|
-
store,
|
|
132
|
-
}: IAppLoadContext = loadContext;
|
|
129
|
+
const { modules: clientModules, container, apolloClient: client, store }: IAppLoadContext = loadContext;
|
|
133
130
|
|
|
134
131
|
// First, we create a new instance of i18next so every request will have a
|
|
135
132
|
// completely unique instance and not share any state.
|
|
@@ -145,7 +142,7 @@ async function handleBrowserRequest(
|
|
|
145
142
|
lng, // The locale we detected above
|
|
146
143
|
ns, // The namespaces the routes about to render want to use
|
|
147
144
|
backend: {
|
|
148
|
-
loadPath:
|
|
145
|
+
loadPath: config.i18n.backend.loadServerPath,
|
|
149
146
|
},
|
|
150
147
|
});
|
|
151
148
|
}
|
|
@@ -79,8 +79,8 @@ export function shouldRevalidate(params: any) {
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
export default function App() {
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
// const { locale } = useLoaderData();
|
|
83
|
+
const locale = 'en';
|
|
84
84
|
useChangeLanguage(locale);
|
|
85
85
|
|
|
86
86
|
React.useEffect(() => {
|
|
@@ -94,4 +94,4 @@ export default function App() {
|
|
|
94
94
|
);
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
export { ErrorBoundary };
|
|
97
|
+
export { ErrorBoundary };
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"publish:forceManual": "yarn lernapublish --force-publish=*",
|
|
77
77
|
"publish:push": "yarn prelernapublish && git push origin publish && yarn postlernapublish",
|
|
78
78
|
"setBranchEnv": "cross-env REPOSITORY_BRANCH=${1:-$REPOSITORY_BRANCH} PUBLISH_BRANCH=${2:-$PUBLISH_BRANCH}",
|
|
79
|
-
"sort-packages": "node tools/sortPackageJson.mjs",
|
|
79
|
+
"sort-packages": "node tools/sortPackageJson.mjs && prettier --write package.json **/**/*/package.json **/*/package.json",
|
|
80
80
|
"start": "cross-env NODE_ENV=development ENV_FILE=../../config/development/dev.env yarn startWeb",
|
|
81
81
|
"start:SSR": "concurrently --names \"BACKEND,FRONTEND\" -c \"bgBlue.bold,bgMagenta.bold\" \"lerna run --scope='*backend-server' start\" \"lerna run --scope='*frontend-server' start:SSR\"",
|
|
82
82
|
"start:devSSR": "concurrently --names \"BACKEND,FRONTEND\" -c \"bgBlue.bold,bgMagenta.bold\" \"lerna run --scope='*backend-server' watch\" \"lerna run --scope='*frontend-server' start:devSSR\"",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@common-stack/generate-plugin",
|
|
3
|
-
"version": "6.0.2-alpha.
|
|
3
|
+
"version": "6.0.2-alpha.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./lib/index.mjs",
|
|
6
6
|
"typings": "./lib/index.d.ts",
|
|
@@ -26,5 +26,5 @@
|
|
|
26
26
|
},
|
|
27
27
|
"executors": "./executors.json",
|
|
28
28
|
"generators": "./generators.json",
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "697635195ad5a0965b394c5a509cdc4e9020558e"
|
|
30
30
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState, startTransition, StrictMode } from 'react';
|
|
1
|
+
import React, { useState, startTransition, StrictMode, useMemo, createContext, useContext } from 'react';
|
|
2
2
|
import 'reflect-metadata';
|
|
3
3
|
import { RemixBrowser } from '@remix-run/react';
|
|
4
4
|
import { hydrateRoot } from 'react-dom/client';
|
|
@@ -27,7 +27,8 @@ import Backend from 'i18next-http-backend';
|
|
|
27
27
|
import { getInitialNamespaces } from 'remix-i18next/client';
|
|
28
28
|
import config from '@app/cde-webconfig.json';
|
|
29
29
|
// @ts-ignore
|
|
30
|
-
import { ClientStyleContext } from '@app/frontend-stack-react/entries/chakraui/context.js';
|
|
30
|
+
// import { ClientStyleContext } from '@app/frontend-stack-react/entries/chakraui/context.js';
|
|
31
|
+
import { ClientStyleContext } from './context';
|
|
31
32
|
|
|
32
33
|
const { apolloClient: client, container, serviceFunc } = createClientContainer();
|
|
33
34
|
const { store } = createReduxStore(client, serviceFunc(), container);
|
|
@@ -40,16 +41,21 @@ interface ClientCacheProviderProps {
|
|
|
40
41
|
children: React.ReactNode;
|
|
41
42
|
}
|
|
42
43
|
|
|
44
|
+
export function useClientStyleContext() {
|
|
45
|
+
return useContext(ClientStyleContext);
|
|
46
|
+
}
|
|
47
|
+
|
|
43
48
|
function ClientCacheProvider({ children }: ClientCacheProviderProps) {
|
|
44
|
-
const [
|
|
49
|
+
const [count, setCount] = useState(0);
|
|
50
|
+
const defaultCache = useMemo(() => createEmotionCache(), [count]);
|
|
45
51
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
52
|
+
const reset = () => {
|
|
53
|
+
setCount((prev) => prev + 1);
|
|
54
|
+
};
|
|
49
55
|
|
|
50
56
|
return (
|
|
51
57
|
<ClientStyleContext.Provider value={{ reset }}>
|
|
52
|
-
<CacheProvider value={
|
|
58
|
+
<CacheProvider value={defaultCache}>{children}</CacheProvider>
|
|
53
59
|
</ClientStyleContext.Provider>
|
|
54
60
|
);
|
|
55
61
|
}
|
|
@@ -75,23 +81,23 @@ async function hydrate() {
|
|
|
75
81
|
}
|
|
76
82
|
hydrateRoot(
|
|
77
83
|
document.getElementById('root')!,
|
|
78
|
-
<StrictMode>
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
</StrictMode>,
|
|
84
|
+
// <StrictMode>
|
|
85
|
+
<I18nextProvider i18n={i18next}>
|
|
86
|
+
<ClientCacheProvider>
|
|
87
|
+
<ApolloProvider client={client}>
|
|
88
|
+
<ReduxProvider store={store}>
|
|
89
|
+
<SlotFillProvider>
|
|
90
|
+
<InversifyProvider container={container} modules={clientModules}>
|
|
91
|
+
<PersistGate loading={null} persistor={persistor}>
|
|
92
|
+
{() => <RemixBrowser />}
|
|
93
|
+
</PersistGate>
|
|
94
|
+
</InversifyProvider>
|
|
95
|
+
</SlotFillProvider>
|
|
96
|
+
</ReduxProvider>
|
|
97
|
+
</ApolloProvider>
|
|
98
|
+
</ClientCacheProvider>
|
|
99
|
+
</I18nextProvider>,
|
|
100
|
+
// </StrictMode>,
|
|
95
101
|
);
|
|
96
102
|
// });
|
|
97
103
|
}
|
|
@@ -36,8 +36,10 @@ import config from '@app/cde-webconfig.json';
|
|
|
36
36
|
|
|
37
37
|
import { Head } from './root';
|
|
38
38
|
import type { IAppLoadContext } from '@common-stack/client-core';
|
|
39
|
-
import { ServerStyleContext } from '@app/frontend-stack-react/entries/chakraui/context.js';
|
|
39
|
+
// import { ServerStyleContext } from '@app/frontend-stack-react/entries/chakraui/context.js';
|
|
40
|
+
import { ServerStyleContext } from './context';
|
|
40
41
|
import { i18nextInstance as i18next } from '@app/frontend-stack-react/i18n-localization/i18next.server.js';
|
|
42
|
+
|
|
41
43
|
const { extractCriticalToChunks } = createEmotionServer(defaultCache);
|
|
42
44
|
|
|
43
45
|
const ABORT_DELAY = 5000;
|
|
@@ -124,12 +126,7 @@ async function handleBrowserRequest(
|
|
|
124
126
|
// And here we detect what namespaces the routes about to render want to use
|
|
125
127
|
const ns = i18next.getRouteNamespaces(remixContext);
|
|
126
128
|
const slotFillContext = { fills: {} };
|
|
127
|
-
const {
|
|
128
|
-
modules: clientModules,
|
|
129
|
-
container,
|
|
130
|
-
apolloClient: client,
|
|
131
|
-
store,
|
|
132
|
-
}: IAppLoadContext = loadContext;
|
|
129
|
+
const { modules: clientModules, container, apolloClient: client, store }: IAppLoadContext = loadContext;
|
|
133
130
|
|
|
134
131
|
// First, we create a new instance of i18next so every request will have a
|
|
135
132
|
// completely unique instance and not share any state.
|
|
@@ -145,7 +142,7 @@ async function handleBrowserRequest(
|
|
|
145
142
|
lng, // The locale we detected above
|
|
146
143
|
ns, // The namespaces the routes about to render want to use
|
|
147
144
|
backend: {
|
|
148
|
-
loadPath:
|
|
145
|
+
loadPath: config.i18n.backend.loadServerPath,
|
|
149
146
|
},
|
|
150
147
|
});
|
|
151
148
|
}
|
|
@@ -79,8 +79,8 @@ export function shouldRevalidate(params: any) {
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
export default function App() {
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
// const { locale } = useLoaderData();
|
|
83
|
+
const locale = 'en';
|
|
84
84
|
useChangeLanguage(locale);
|
|
85
85
|
|
|
86
86
|
React.useEffect(() => {
|
|
@@ -94,4 +94,4 @@ export default function App() {
|
|
|
94
94
|
);
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
export { ErrorBoundary };
|
|
97
|
+
export { ErrorBoundary };
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"publish:forceManual": "yarn lernapublish --force-publish=*",
|
|
77
77
|
"publish:push": "yarn prelernapublish && git push origin publish && yarn postlernapublish",
|
|
78
78
|
"setBranchEnv": "cross-env REPOSITORY_BRANCH=${1:-$REPOSITORY_BRANCH} PUBLISH_BRANCH=${2:-$PUBLISH_BRANCH}",
|
|
79
|
-
"sort-packages": "node tools/sortPackageJson.mjs",
|
|
79
|
+
"sort-packages": "node tools/sortPackageJson.mjs && prettier --write package.json **/**/*/package.json **/*/package.json",
|
|
80
80
|
"start": "cross-env NODE_ENV=development ENV_FILE=../../config/development/dev.env yarn startWeb",
|
|
81
81
|
"start:SSR": "concurrently --names \"BACKEND,FRONTEND\" -c \"bgBlue.bold,bgMagenta.bold\" \"lerna run --scope='*backend-server' start\" \"lerna run --scope='*frontend-server' start:SSR\"",
|
|
82
82
|
"start:devSSR": "concurrently --names \"BACKEND,FRONTEND\" -c \"bgBlue.bold,bgMagenta.bold\" \"lerna run --scope='*backend-server' watch\" \"lerna run --scope='*frontend-server' start:devSSR\"",
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
const merge = require('merge')
|
|
2
|
-
const baseConfig = require('./jest.config.base');
|
|
3
|
-
const mongodbConfig = require('./jest.config.mongodb')
|
|
4
|
-
module.exports = merge.recursive(
|
|
5
|
-
baseConfig,
|
|
6
|
-
mongodbConfig,
|
|
7
|
-
{
|
|
8
|
-
globals: {
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
}, {
|
|
12
|
-
moduleDirectories: [
|
|
13
|
-
"node_modules",
|
|
14
|
-
"packages/adminide-core",
|
|
15
|
-
],
|
|
16
|
-
}
|
|
17
|
-
// https://baltuta.eu/posts/typescript-lerna-monorepo-more-tools
|
|
18
|
-
// {
|
|
19
|
-
// roots: ['<rootDir>'],
|
|
20
|
-
// projects: [
|
|
21
|
-
// '<rootDir>/packages/ui',
|
|
22
|
-
// '<rootDir>/packages/api',
|
|
23
|
-
// '<rootDir>/packages/diceroll'
|
|
24
|
-
// ],
|
|
25
|
-
// }
|
|
26
|
-
|
|
27
|
-
);
|