@common-stack/generate-plugin 6.0.8-alpha.4 → 6.0.8-alpha.41
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 +152 -4
- package/docker-releases/backend/package.json +6 -7
- package/docker-releases/frontend/antd/package.json +7 -7
- package/lib/generators/add-backend/files/Dockerfile +2 -0
- package/lib/generators/add-backend/files/package.json +4 -2
- package/lib/generators/add-backend/files/webpack.config.js +3 -1
- package/lib/generators/add-frontend/frameworks/antui/context.tsx.template +8 -0
- package/lib/generators/add-frontend/frameworks/antui/entry.client.tsx.template +9 -2
- package/lib/generators/add-frontend/frameworks/antui/entry.server.tsx.template +60 -51
- package/lib/generators/add-frontend/frameworks/antui/root.tsx.template +7 -11
- package/lib/generators/add-frontend/frameworks/chakraui/context.tsx.template +6 -0
- package/lib/generators/add-frontend/frameworks/chakraui/entry.client.tsx.template +23 -15
- package/lib/generators/add-frontend/frameworks/chakraui/entry.server.tsx.template +33 -30
- package/lib/generators/add-frontend/frameworks/chakraui/root.tsx.template +8 -4
- package/lib/generators/add-frontend/templates/Dockerfile +4 -0
- package/lib/generators/add-frontend/templates/package.json +7 -3
- package/lib/generators/add-frontend/templates/vite.config.ts.template +3 -0
- package/lib/generators/add-fullstack/files/Jenkinsfile +1 -1
- package/lib/generators/add-fullstack/files/cdecode-config.json +109 -0
- package/lib/generators/add-fullstack/files/package.json +17 -7
- package/lib/generators/add-fullstack/files/rollup.config.base.mjs +17 -95
- package/lib/generators/add-fullstack/files/tools/codegenGenerator.mjs +36 -0
- package/lib/generators/add-moleculer/files/Dockerfile +2 -0
- package/lib/generators/add-moleculer/files/config.json +5 -0
- package/lib/generators/add-moleculer/files/package.json +10 -6
- package/lib/generators/add-moleculer/files/rollup.config.mjs +14 -1
- package/package.json +3 -3
- package/src/generators/add-frontend/frameworks/antui/context.tsx.template +8 -0
- package/src/generators/add-frontend/frameworks/antui/entry.client.tsx.template +9 -2
- package/src/generators/add-frontend/frameworks/antui/entry.server.tsx.template +60 -51
- package/src/generators/add-frontend/frameworks/antui/root.tsx.template +7 -11
- package/src/generators/add-frontend/frameworks/chakraui/context.tsx.template +6 -0
- package/src/generators/add-frontend/frameworks/chakraui/entry.client.tsx.template +23 -15
- package/src/generators/add-frontend/frameworks/chakraui/entry.server.tsx.template +33 -30
- package/src/generators/add-frontend/frameworks/chakraui/root.tsx.template +8 -4
- package/src/generators/add-fullstack/files/Jenkinsfile +1 -1
- package/src/generators/add-fullstack/files/cdecode-config.json +109 -0
- package/src/generators/add-fullstack/files/package.json +17 -7
- package/src/generators/add-fullstack/files/rollup.config.base.mjs +17 -95
- package/src/generators/add-fullstack/files/tools/codegenGenerator.mjs +36 -0
- package/src/generators/add-moleculer/files/.dockerignore +2 -1
- package/src/generators/add-moleculer/files/Dockerfile +2 -0
- package/src/generators/add-moleculer/files/config.json +5 -0
- package/src/generators/add-moleculer/files/package.json +10 -6
- package/src/generators/add-moleculer/files/rollup.config.mjs +14 -1
- package/lib/generators/add-moleculer/files/src/modules/module.ts.template +0 -31
- package/src/generators/add-moleculer/files/src/modules/module.ts.template +0 -31
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@common-stack/generate-plugin",
|
|
3
|
-
"version": "6.0.8-alpha.
|
|
3
|
+
"version": "6.0.8-alpha.41",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./lib/index.mjs",
|
|
6
6
|
"typings": "./lib/index.d.ts",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"watch": "yarn build:lib:watch"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@common-stack/rollup-vite-utils": "6.0.8-alpha.
|
|
20
|
+
"@common-stack/rollup-vite-utils": "6.0.8-alpha.40",
|
|
21
21
|
"tslib": "^2.3.0"
|
|
22
22
|
},
|
|
23
23
|
"publishConfig": {
|
|
@@ -25,5 +25,5 @@
|
|
|
25
25
|
},
|
|
26
26
|
"executors": "./executors.json",
|
|
27
27
|
"generators": "./generators.json",
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "8260bd00873550a81dd90950aed9de021b0a1c6f"
|
|
29
29
|
}
|
|
@@ -32,6 +32,7 @@ import clientModules from '@app/frontend-stack-react/modules.js';
|
|
|
32
32
|
import createEmotionCache from '@app/frontend-stack-react/entries/common/createEmotionCache.js';
|
|
33
33
|
// @ts-ignore
|
|
34
34
|
import config from '@app/cde-webconfig.json';
|
|
35
|
+
import { LocaleContext } from './context';
|
|
35
36
|
|
|
36
37
|
const { apolloClient: client, container, serviceFunc } = createClientContainer();
|
|
37
38
|
const { store } = createReduxStore(client, serviceFunc(), container);
|
|
@@ -42,6 +43,12 @@ const cache = createEmotionCache();
|
|
|
42
43
|
(window as any).__remixStore = store;
|
|
43
44
|
removeUniversalPortals((window as any).__SLOT_FILLS__ || []);
|
|
44
45
|
|
|
46
|
+
function LocaleProvider({ children }: any) {
|
|
47
|
+
const locale = (window as any).__LOCALE__ || '';
|
|
48
|
+
|
|
49
|
+
return <LocaleContext.Provider value={locale}>{children}</LocaleContext.Provider>;
|
|
50
|
+
}
|
|
51
|
+
|
|
45
52
|
async function hydrate() {
|
|
46
53
|
if (!i18next.isInitialized && config.i18n.enabled) {
|
|
47
54
|
await i18next
|
|
@@ -66,7 +73,7 @@ async function hydrate() {
|
|
|
66
73
|
document,
|
|
67
74
|
(
|
|
68
75
|
<I18nextProvider i18n={i18next}>
|
|
69
|
-
<
|
|
76
|
+
<LocaleProvider>
|
|
70
77
|
<CacheProvider value={cache}>
|
|
71
78
|
<StyleProvider cache={antCache}>
|
|
72
79
|
<ReduxProvider store={store}>
|
|
@@ -84,7 +91,7 @@ async function hydrate() {
|
|
|
84
91
|
</ReduxProvider>
|
|
85
92
|
</StyleProvider>
|
|
86
93
|
</CacheProvider>
|
|
87
|
-
</
|
|
94
|
+
</LocaleProvider>
|
|
88
95
|
</I18nextProvider>
|
|
89
96
|
) as any,
|
|
90
97
|
);
|
|
@@ -31,6 +31,9 @@ import config from '@app/cde-webconfig.json';
|
|
|
31
31
|
// @ts-ignore
|
|
32
32
|
import createEmotionCache from '@app/frontend-stack-react/entries/common/createEmotionCache';
|
|
33
33
|
import type { IAppLoadContext } from '@common-stack/client-core';
|
|
34
|
+
// @ts-ignore
|
|
35
|
+
import publicEnv from '@src/config/public-config';
|
|
36
|
+
import { LocaleContext } from './context';
|
|
34
37
|
|
|
35
38
|
const ABORT_DELAY = 5_000;
|
|
36
39
|
const antdCache = createAntdCache();
|
|
@@ -41,18 +44,23 @@ class ConstantsTransform extends Transform {
|
|
|
41
44
|
_apolloState: any;
|
|
42
45
|
_reduxState: any;
|
|
43
46
|
_styleSheet: string;
|
|
47
|
+
_lng: string;
|
|
44
48
|
|
|
45
|
-
constructor(fills: string[], apolloState: any, reduxState: any, styleSheet: any) {
|
|
49
|
+
constructor(fills: string[], apolloState: any, reduxState: any, styleSheet: any, lng: string) {
|
|
46
50
|
super();
|
|
47
51
|
this._fills = fills;
|
|
48
52
|
this._apolloState = apolloState;
|
|
49
53
|
this._reduxState = reduxState;
|
|
50
54
|
this._styleSheet = styleSheet;
|
|
55
|
+
this._lng = lng;
|
|
51
56
|
}
|
|
52
57
|
|
|
53
58
|
_transform(chunk, encoding, callback) {
|
|
54
59
|
let transformedChunk = chunk.toString();
|
|
55
60
|
|
|
61
|
+
if (transformedChunk.includes('[__ENV__]')) {
|
|
62
|
+
transformedChunk = transformedChunk.replace('[__ENV__]', JSON.stringify(publicEnv));
|
|
63
|
+
}
|
|
56
64
|
if (transformedChunk.includes('[__APOLLO_STATE__]')) {
|
|
57
65
|
transformedChunk = transformedChunk.replace(
|
|
58
66
|
'[__APOLLO_STATE__]',
|
|
@@ -71,6 +79,9 @@ class ConstantsTransform extends Transform {
|
|
|
71
79
|
if (transformedChunk.includes('[__STYLESHEET__]')) {
|
|
72
80
|
transformedChunk = transformedChunk.replace('[__STYLESHEET__]', this._styleSheet);
|
|
73
81
|
}
|
|
82
|
+
if (transformedChunk.includes('[__LOCALE__]')) {
|
|
83
|
+
transformedChunk = transformedChunk.replace('[__LOCALE__]', `"${this._lng}"`);
|
|
84
|
+
}
|
|
74
85
|
|
|
75
86
|
callback(null, transformedChunk);
|
|
76
87
|
}
|
|
@@ -86,32 +97,9 @@ export default async function handleRequest(
|
|
|
86
97
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
87
98
|
loadContext: IAppLoadContext,
|
|
88
99
|
) {
|
|
89
|
-
const instance = createInstance();
|
|
90
|
-
const lng = await i18next.getLocale(request);
|
|
91
|
-
const ns = i18next.getRouteNamespaces(remixContext);
|
|
92
|
-
|
|
93
|
-
// First, we create a new instance of i18next so every request will have a
|
|
94
|
-
// completely unique instance and not share any state.
|
|
95
|
-
if (config.i18n.enabled) {
|
|
96
|
-
await instance
|
|
97
|
-
.use(initReactI18next) // Tell our instance to use react-i18next
|
|
98
|
-
.use(Backend) // Setup our backend.init({
|
|
99
|
-
.init({
|
|
100
|
-
fallbackLng: config.i18n.fallbackLng,
|
|
101
|
-
defaultNS: config.i18n.defaultNS,
|
|
102
|
-
react: config.i18n.react,
|
|
103
|
-
supportedLngs: config.i18n.supportedLngs,
|
|
104
|
-
lng, // The locale we detected above
|
|
105
|
-
ns, // The namespaces the routes about to render want to use
|
|
106
|
-
backend: {
|
|
107
|
-
loadPath: resolve(config.i18n.backend.loadServerPath),
|
|
108
|
-
},
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
|
|
112
100
|
return isbot(request.headers.get('user-agent') || '')
|
|
113
|
-
? handleBotRequest(request, responseStatusCode, responseHeaders, remixContext, loadContext
|
|
114
|
-
: handleBrowserRequest(request, responseStatusCode, responseHeaders, remixContext, loadContext
|
|
101
|
+
? handleBotRequest(request, responseStatusCode, responseHeaders, remixContext, loadContext)
|
|
102
|
+
: handleBrowserRequest(request, responseStatusCode, responseHeaders, remixContext, loadContext);
|
|
115
103
|
}
|
|
116
104
|
|
|
117
105
|
function handleBotRequest(
|
|
@@ -120,14 +108,11 @@ function handleBotRequest(
|
|
|
120
108
|
responseHeaders: Headers,
|
|
121
109
|
remixContext: EntryContext,
|
|
122
110
|
loadContext: IAppLoadContext,
|
|
123
|
-
i18nInstance: i18next,
|
|
124
111
|
) {
|
|
125
112
|
return new Promise((resolve, reject) => {
|
|
126
113
|
let shellRendered = false;
|
|
127
114
|
const { pipe, abort } = renderToPipeableStream(
|
|
128
|
-
<
|
|
129
|
-
<RemixServer context={remixContext} url={request.url} abortDelay={ABORT_DELAY} />
|
|
130
|
-
</I18nextProvider>,
|
|
115
|
+
<RemixServer context={remixContext} url={request.url} abortDelay={ABORT_DELAY} />,
|
|
131
116
|
{
|
|
132
117
|
onAllReady() {
|
|
133
118
|
shellRendered = true;
|
|
@@ -164,14 +149,36 @@ function handleBotRequest(
|
|
|
164
149
|
});
|
|
165
150
|
}
|
|
166
151
|
|
|
167
|
-
function handleBrowserRequest(
|
|
152
|
+
async function handleBrowserRequest(
|
|
168
153
|
request: Request,
|
|
169
154
|
responseStatusCode: number,
|
|
170
155
|
responseHeaders: Headers,
|
|
171
156
|
remixContext: EntryContext,
|
|
172
157
|
loadContext: IAppLoadContext,
|
|
173
|
-
i18nInstance: i18next,
|
|
174
158
|
) {
|
|
159
|
+
const instance = createInstance();
|
|
160
|
+
const lng = await i18next.getLocale(request);
|
|
161
|
+
const ns = i18next.getRouteNamespaces(remixContext);
|
|
162
|
+
|
|
163
|
+
// First, we create a new instance of i18next so every request will have a
|
|
164
|
+
// completely unique instance and not share any state.
|
|
165
|
+
if (config.i18n.enabled) {
|
|
166
|
+
await instance
|
|
167
|
+
.use(initReactI18next) // Tell our instance to use react-i18next
|
|
168
|
+
.use(Backend) // Setup our backend.init({
|
|
169
|
+
.init({
|
|
170
|
+
fallbackLng: config.i18n.fallbackLng,
|
|
171
|
+
defaultNS: config.i18n.defaultNS,
|
|
172
|
+
react: config.i18n.react,
|
|
173
|
+
supportedLngs: config.i18n.supportedLngs,
|
|
174
|
+
lng, // The locale we detected above
|
|
175
|
+
ns, // The namespaces the routes about to render want to use
|
|
176
|
+
backend: {
|
|
177
|
+
loadPath: resolve(config.i18n.backend.loadServerPath),
|
|
178
|
+
},
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
|
|
175
182
|
return new Promise((resolve, reject) => {
|
|
176
183
|
let shellRendered = false;
|
|
177
184
|
const slotFillContext = { fills: {} };
|
|
@@ -190,24 +197,26 @@ function handleBrowserRequest(
|
|
|
190
197
|
|
|
191
198
|
const { pipe, abort } = renderToPipeableStream(
|
|
192
199
|
(
|
|
193
|
-
<I18nextProvider i18n={
|
|
194
|
-
<
|
|
195
|
-
<
|
|
196
|
-
<
|
|
197
|
-
<
|
|
198
|
-
<
|
|
199
|
-
<
|
|
200
|
-
<
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
200
|
+
<I18nextProvider i18n={instance}>
|
|
201
|
+
<LocaleContext.Provider value={lng}>
|
|
202
|
+
<CacheProvider value={cache}>
|
|
203
|
+
<StyleProvider cache={antdCache}>
|
|
204
|
+
<ReduxProvider store={store}>
|
|
205
|
+
<SlotFillProvider context={slotFillContext}>
|
|
206
|
+
<InversifyProvider container={container} modules={clientModules as any}>
|
|
207
|
+
<ApolloProvider client={client}>
|
|
208
|
+
<RemixServer
|
|
209
|
+
context={remixContext}
|
|
210
|
+
url={request.url}
|
|
211
|
+
abortDelay={ABORT_DELAY}
|
|
212
|
+
/>
|
|
213
|
+
</ApolloProvider>
|
|
214
|
+
</InversifyProvider>
|
|
215
|
+
</SlotFillProvider>
|
|
216
|
+
</ReduxProvider>
|
|
217
|
+
</StyleProvider>
|
|
218
|
+
</CacheProvider>
|
|
219
|
+
</LocaleContext.Provider>
|
|
211
220
|
</I18nextProvider>
|
|
212
221
|
) as any,
|
|
213
222
|
{
|
|
@@ -220,7 +229,7 @@ function handleBrowserRequest(
|
|
|
220
229
|
const fills = Object.keys(slotFillContext.fills);
|
|
221
230
|
const styleSheet = extractStyle(antdCache);
|
|
222
231
|
|
|
223
|
-
const transform = new ConstantsTransform(fills, apolloState, reduxState, styleSheet);
|
|
232
|
+
const transform = new ConstantsTransform(fills, apolloState, reduxState, styleSheet, lng);
|
|
224
233
|
|
|
225
234
|
responseHeaders.set('Content-Type', 'text/html');
|
|
226
235
|
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { Links, Meta, Outlet, Scripts, ScrollRestoration, useRouteLoaderData, useRouteError, json } from '@remix-run/react';
|
|
4
|
-
// @ts-ignore
|
|
5
|
-
import publicEnv from '@src/config/public-config';
|
|
6
4
|
import { PluginArea } from '@common-stack/client-react';
|
|
7
5
|
import { subscribeReduxRouter } from '@common-stack/remix-router-redux';
|
|
8
6
|
import { ApplicationErrorHandler } from '@admin-layout/ant-ui';
|
|
@@ -16,7 +14,8 @@ import { useTranslation } from 'react-i18next';
|
|
|
16
14
|
import { i18nextInstance as i18next } from '@app/frontend-stack-react/i18n-localization/i18next.server.js';
|
|
17
15
|
// @ts-ignore
|
|
18
16
|
import { ErrorBoundary } from '@app/frontend-stack-react/entries/antui/components/ErrorBoundary';
|
|
19
|
-
|
|
17
|
+
import { LocaleContext } from './context';
|
|
18
|
+
/*
|
|
20
19
|
export const loader = async ({ request }) => {
|
|
21
20
|
const locale = await i18next.getLocale(request);
|
|
22
21
|
return json({
|
|
@@ -24,7 +23,7 @@ export const loader = async ({ request }) => {
|
|
|
24
23
|
locale,
|
|
25
24
|
});
|
|
26
25
|
};
|
|
27
|
-
|
|
26
|
+
*/
|
|
28
27
|
export const handle = {
|
|
29
28
|
i18n: 'common',
|
|
30
29
|
};
|
|
@@ -34,8 +33,8 @@ export function shouldRevalidate(params: any) {
|
|
|
34
33
|
}
|
|
35
34
|
|
|
36
35
|
export function Layout({ children }: { children: React.ReactNode }) {
|
|
37
|
-
const data = useRouteLoaderData<{ locale: any }>('root');
|
|
38
|
-
const locale =
|
|
36
|
+
// const data = useRouteLoaderData<{ locale: any }>('root');
|
|
37
|
+
const locale: any = React.useContext(LocaleContext);
|
|
39
38
|
|
|
40
39
|
const { i18n } = useTranslation();
|
|
41
40
|
|
|
@@ -49,11 +48,7 @@ export function Layout({ children }: { children: React.ReactNode }) {
|
|
|
49
48
|
if (typeof window === 'undefined') {
|
|
50
49
|
return (
|
|
51
50
|
<>
|
|
52
|
-
<script
|
|
53
|
-
dangerouslySetInnerHTML={{
|
|
54
|
-
__html: `window.__ENV__ = ${JSON.stringify((data as any)?.__ENV__)}`,
|
|
55
|
-
}}
|
|
56
|
-
/>
|
|
51
|
+
<script>window.__ENV__=[__ENV__]</script>
|
|
57
52
|
<script
|
|
58
53
|
src="https://cdnjs.cloudflare.com/ajax/libs/reflect-metadata/0.1.13/Reflect.min.js"
|
|
59
54
|
integrity="sha512-jvbPH2TH5BSZumEfOJZn9IV+5bSwwN+qG4dvthYe3KCGC3/9HmxZ4phADbt9Pfcp+XSyyfc2vGZ/RMsSUZ9tbQ=="
|
|
@@ -68,6 +63,7 @@ export function Layout({ children }: { children: React.ReactNode }) {
|
|
|
68
63
|
__html: `if (global === undefined) { var global = window; }`,
|
|
69
64
|
}}
|
|
70
65
|
/>
|
|
66
|
+
<script>window.__LOCALE__=[__LOCALE__]</script>
|
|
71
67
|
</>
|
|
72
68
|
);
|
|
73
69
|
}
|
|
@@ -18,3 +18,9 @@ export interface ClientStyleContextData {
|
|
|
18
18
|
export const ClientStyleContext = createContext<ClientStyleContextData | null>(
|
|
19
19
|
null,
|
|
20
20
|
);
|
|
21
|
+
|
|
22
|
+
export interface LocaleContextData {
|
|
23
|
+
locale: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const LocaleContext = createContext<LocaleContextData | null>(null);
|
|
@@ -27,8 +27,7 @@ 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
|
-
|
|
31
|
-
import { ClientStyleContext } from './context';
|
|
30
|
+
import { ClientStyleContext, LocaleContext } from './context';
|
|
32
31
|
|
|
33
32
|
const { apolloClient: client, container, serviceFunc } = createClientContainer();
|
|
34
33
|
const { store } = createReduxStore(client, serviceFunc(), container);
|
|
@@ -60,6 +59,13 @@ function ClientCacheProvider({ children }: ClientCacheProviderProps) {
|
|
|
60
59
|
);
|
|
61
60
|
}
|
|
62
61
|
|
|
62
|
+
function LocaleProvider({ children }: ClientCacheProviderProps) {
|
|
63
|
+
const el = (document as any).querySelector('html');
|
|
64
|
+
const locale = el?.getAttribute('lng') || '';
|
|
65
|
+
|
|
66
|
+
return <LocaleContext.Provider value={locale}>{children}</LocaleContext.Provider>;
|
|
67
|
+
}
|
|
68
|
+
|
|
63
69
|
async function hydrate() {
|
|
64
70
|
if (!i18next.isInitialized && config.i18n.enabled) {
|
|
65
71
|
await i18next
|
|
@@ -83,19 +89,21 @@ async function hydrate() {
|
|
|
83
89
|
document.getElementById('root')!,
|
|
84
90
|
// <StrictMode>
|
|
85
91
|
<I18nextProvider i18n={i18next}>
|
|
86
|
-
<
|
|
87
|
-
<
|
|
88
|
-
<
|
|
89
|
-
<
|
|
90
|
-
<
|
|
91
|
-
<
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
92
|
+
<LocaleProvider>
|
|
93
|
+
<ClientCacheProvider>
|
|
94
|
+
<ApolloProvider client={client}>
|
|
95
|
+
<ReduxProvider store={store}>
|
|
96
|
+
<SlotFillProvider>
|
|
97
|
+
<InversifyProvider container={container} modules={clientModules}>
|
|
98
|
+
<PersistGate loading={null} persistor={persistor}>
|
|
99
|
+
{() => <RemixBrowser />}
|
|
100
|
+
</PersistGate>
|
|
101
|
+
</InversifyProvider>
|
|
102
|
+
</SlotFillProvider>
|
|
103
|
+
</ReduxProvider>
|
|
104
|
+
</ApolloProvider>
|
|
105
|
+
</ClientCacheProvider>
|
|
106
|
+
</LocaleProvider>
|
|
99
107
|
</I18nextProvider>,
|
|
100
108
|
// </StrictMode>,
|
|
101
109
|
);
|
|
@@ -36,8 +36,7 @@ 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
|
-
|
|
40
|
-
import { ServerStyleContext } from './context';
|
|
39
|
+
import { ServerStyleContext, LocaleContext } from './context';
|
|
41
40
|
import { i18nextInstance as i18next } from '@app/frontend-stack-react/i18n-localization/i18next.server.js';
|
|
42
41
|
|
|
43
42
|
const { extractCriticalToChunks } = createEmotionServer(defaultCache);
|
|
@@ -149,17 +148,19 @@ async function handleBrowserRequest(
|
|
|
149
148
|
|
|
150
149
|
const html = renderToString(
|
|
151
150
|
<I18nextProvider i18n={instance}>
|
|
152
|
-
<
|
|
153
|
-
<
|
|
154
|
-
<
|
|
155
|
-
<
|
|
156
|
-
<
|
|
157
|
-
<
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
151
|
+
<LocaleContext.Provider value={lng}>
|
|
152
|
+
<CacheProvider value={defaultCache}>
|
|
153
|
+
<ApolloProvider client={client}>
|
|
154
|
+
<ReduxProvider store={store}>
|
|
155
|
+
<SlotFillProvider context={slotFillContext}>
|
|
156
|
+
<InversifyProvider container={container} modules={clientModules}>
|
|
157
|
+
<RemixServer context={remixContext} url={request.url} />
|
|
158
|
+
</InversifyProvider>
|
|
159
|
+
</SlotFillProvider>
|
|
160
|
+
</ReduxProvider>
|
|
161
|
+
</ApolloProvider>
|
|
162
|
+
</CacheProvider>
|
|
163
|
+
</LocaleContext.Provider>
|
|
163
164
|
</I18nextProvider>,
|
|
164
165
|
);
|
|
165
166
|
|
|
@@ -177,23 +178,25 @@ async function handleBrowserRequest(
|
|
|
177
178
|
const { pipe, abort } = renderToPipeableStream(
|
|
178
179
|
(
|
|
179
180
|
<I18nextProvider i18n={instance}>
|
|
180
|
-
<
|
|
181
|
-
<
|
|
182
|
-
<
|
|
183
|
-
<
|
|
184
|
-
<
|
|
185
|
-
<
|
|
186
|
-
<
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
181
|
+
<LocaleContext.Provider value={lng}>
|
|
182
|
+
<ServerStyleContext.Provider value={chunks.styles}>
|
|
183
|
+
<CacheProvider value={defaultCache}>
|
|
184
|
+
<ApolloProvider client={client}>
|
|
185
|
+
<ReduxProvider store={store}>
|
|
186
|
+
<SlotFillProvider context={slotFillContext}>
|
|
187
|
+
<InversifyProvider container={container} modules={clientModules}>
|
|
188
|
+
<RemixServer
|
|
189
|
+
context={remixContext}
|
|
190
|
+
url={request.url}
|
|
191
|
+
abortDelay={ABORT_DELAY}
|
|
192
|
+
/>
|
|
193
|
+
</InversifyProvider>
|
|
194
|
+
</SlotFillProvider>
|
|
195
|
+
</ReduxProvider>
|
|
196
|
+
</ApolloProvider>
|
|
197
|
+
</CacheProvider>
|
|
198
|
+
</ServerStyleContext.Provider>
|
|
199
|
+
</LocaleContext.Provider>
|
|
197
200
|
</I18nextProvider>
|
|
198
201
|
) as any,
|
|
199
202
|
{
|
|
@@ -11,7 +11,7 @@ import { ApplicationErrorHandler } from '@admin-layout/chakra-ui';
|
|
|
11
11
|
import clientModules, { plugins } from '@app/frontend-stack-react/modules.js';
|
|
12
12
|
import { createHead } from 'remix-island';
|
|
13
13
|
import { useContext } from 'react';
|
|
14
|
-
import { ServerStyleContext, ClientStyleContext } from './context';
|
|
14
|
+
import { ServerStyleContext, ClientStyleContext, LocaleContext } from './context';
|
|
15
15
|
import { withEmotionCache } from '@emotion/react';
|
|
16
16
|
import { useChangeLanguage } from 'remix-i18next/react';
|
|
17
17
|
import { i18nextInstance as i18next } from '@app/frontend-stack-react/i18n-localization/i18next.server.js';
|
|
@@ -31,6 +31,9 @@ export const Head = createHead(() => (
|
|
|
31
31
|
export const Document = withEmotionCache(({ children }: DocumentProps, emotionCache) => {
|
|
32
32
|
const serverStyleData = useContext(ServerStyleContext);
|
|
33
33
|
const clientStyleData = useContext(ClientStyleContext);
|
|
34
|
+
const locale = useContext(LocaleContext);
|
|
35
|
+
|
|
36
|
+
useChangeLanguage(locale);
|
|
34
37
|
|
|
35
38
|
React.useEffect(() => {
|
|
36
39
|
// re-link sheet container
|
|
@@ -64,12 +67,12 @@ export const Document = withEmotionCache(({ children }: DocumentProps, emotionCa
|
|
|
64
67
|
</>
|
|
65
68
|
);
|
|
66
69
|
});
|
|
67
|
-
|
|
70
|
+
/*
|
|
68
71
|
export let loader = async ({ request }) => {
|
|
69
72
|
let locale = await i18next.getLocale(request);
|
|
70
73
|
return json({ locale });
|
|
71
74
|
};
|
|
72
|
-
|
|
75
|
+
*/
|
|
73
76
|
export let handle = {
|
|
74
77
|
i18n: 'common',
|
|
75
78
|
};
|
|
@@ -79,11 +82,12 @@ export function shouldRevalidate(params: any) {
|
|
|
79
82
|
}
|
|
80
83
|
|
|
81
84
|
export default function App() {
|
|
85
|
+
/*
|
|
82
86
|
const data = useRouteLoaderData<{ locale: any }>('root');
|
|
83
87
|
const locale = data?.locale;
|
|
84
88
|
|
|
85
89
|
useChangeLanguage(locale);
|
|
86
|
-
|
|
90
|
+
*/
|
|
87
91
|
React.useEffect(() => {
|
|
88
92
|
subscribeReduxRouter({ store: window.__remixStore, router: window.__remixRouter } as any);
|
|
89
93
|
}, []);
|
|
@@ -646,7 +646,7 @@ def buildAndPushDockerImage(server, name, version) {
|
|
|
646
646
|
} else {
|
|
647
647
|
sh """
|
|
648
648
|
npx lerna exec --scope=*${server} ${params.BUILD_STRATEGY} run ${env.BUILD_COMMAND};
|
|
649
|
-
|
|
649
|
+
npx lerna exec --scope=*${server} ${params.BUILD_STRATEGY} copycommon
|
|
650
650
|
docker buildx create --name ${server} --driver docker-container --use
|
|
651
651
|
docker buildx inspect ${server} --bootstrap
|
|
652
652
|
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
{
|
|
2
|
+
"servers": ["servers/frontend-server/config.json", "servers/backend-server/config.json"],
|
|
3
|
+
"codegen": {
|
|
4
|
+
"outputFile": "codegen.ts",
|
|
5
|
+
"rootSchema": "servers/backend-server/src/api/root-schema.graphqls",
|
|
6
|
+
"fullConfig": {
|
|
7
|
+
"overwrite": true,
|
|
8
|
+
"schema": ["$PRIMARY_SCHEMA_PLACEHOLDER$"],
|
|
9
|
+
"generates": {
|
|
10
|
+
"packages/common/src/generated/generated-models.ts": {
|
|
11
|
+
"schema": "%discoveredSchemas%",
|
|
12
|
+
"documents": "%discoveredDocuments%",
|
|
13
|
+
"config": {
|
|
14
|
+
"scalars": {
|
|
15
|
+
"URI": "URI",
|
|
16
|
+
"URIInput": "URI | UriComponents"
|
|
17
|
+
},
|
|
18
|
+
"enumValues": {
|
|
19
|
+
"ConfigurationScope": "@workbench-stack/core/lib/interfaces/configuration/configuration.js#ConfigurationScope",
|
|
20
|
+
"ConfigurationTarget": "../configuration#ConfigurationTarget"
|
|
21
|
+
},
|
|
22
|
+
"constEnums": false,
|
|
23
|
+
"contextType": "../apollo-context#MyContext",
|
|
24
|
+
"withHooks": true,
|
|
25
|
+
"typesPrefix": "I",
|
|
26
|
+
"noNamespaces": true,
|
|
27
|
+
"noGraphQLTag": true
|
|
28
|
+
},
|
|
29
|
+
"plugins": [
|
|
30
|
+
{
|
|
31
|
+
"add": {
|
|
32
|
+
"content": [
|
|
33
|
+
"import { URI, UriComponents } from '@vscode-alt/monaco-editor/esm/vs/base/common/uri.js';"
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"typescript",
|
|
38
|
+
"typescript-operations",
|
|
39
|
+
"typescript-resolvers"
|
|
40
|
+
]
|
|
41
|
+
},
|
|
42
|
+
"packages/common/src/generated/generated.tsx": {
|
|
43
|
+
"schema": "%discoveredSchemas%",
|
|
44
|
+
"documents": "%discoveredDocuments%",
|
|
45
|
+
"config": {
|
|
46
|
+
"scalars": {
|
|
47
|
+
"URI": "URI",
|
|
48
|
+
"URIInput": "URI | UriComponents"
|
|
49
|
+
},
|
|
50
|
+
"withHooks": true,
|
|
51
|
+
"typesPrefix": "I",
|
|
52
|
+
"noNamespaces": true,
|
|
53
|
+
"noGraphQLTag": true
|
|
54
|
+
},
|
|
55
|
+
"preset": "import-types-preset",
|
|
56
|
+
"presetConfig": {
|
|
57
|
+
"typesPath": "./generated-models",
|
|
58
|
+
"importTypesNamespace": "SchemaTypes"
|
|
59
|
+
},
|
|
60
|
+
"plugins": [
|
|
61
|
+
{
|
|
62
|
+
"add": {
|
|
63
|
+
"content": [
|
|
64
|
+
"import { URI, UriComponents } from '@vscode-alt/monaco-editor/esm/vs/base/common/uri.js';"
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
"typescript-react-apollo"
|
|
69
|
+
]
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
"updateDependencies": {
|
|
75
|
+
"packagesToCheck": [
|
|
76
|
+
"@common-stack/server-stack",
|
|
77
|
+
"@common-stack/frontend-stack-react",
|
|
78
|
+
"@common-stack/mobile-stack-react"
|
|
79
|
+
],
|
|
80
|
+
"packagePaths": {
|
|
81
|
+
"backend": ["servers/backend-server/package.json"],
|
|
82
|
+
"frontend": ["servers/frontend-server/package.json"],
|
|
83
|
+
"mobile": ["portable-devices/mobile/package.json"]
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
"updateDependencyVersion": {
|
|
87
|
+
"roots": ["servers", "portable-devices", "packages", "packages-modules"],
|
|
88
|
+
"ignorePattern": "**/node_modules/**",
|
|
89
|
+
"jsonSpacing": 4,
|
|
90
|
+
"addEndNewLine": true,
|
|
91
|
+
"commitMessage": "Updated packages to use correct versions"
|
|
92
|
+
},
|
|
93
|
+
"sortPackageJson": {
|
|
94
|
+
"directories": [".", "packages", "packages-modules", "servers", "portable-devices"],
|
|
95
|
+
"skipNodeModules": true
|
|
96
|
+
},
|
|
97
|
+
"deployVersionUpdate": {
|
|
98
|
+
"lernaJsonPath": "lerna.json",
|
|
99
|
+
"jenkinsfilePath": "Jenkinsfile",
|
|
100
|
+
"valuesDevYamlPath": "values-dev.yaml",
|
|
101
|
+
"valuesProdYamlPath": "values-prod.yaml"
|
|
102
|
+
},
|
|
103
|
+
"projectPaths": {
|
|
104
|
+
"packages": "packages",
|
|
105
|
+
"packagesModules": "packages-modules",
|
|
106
|
+
"servers": "servers",
|
|
107
|
+
"portableDevices": "portable-devices"
|
|
108
|
+
}
|
|
109
|
+
}
|