@common-stack/generate-plugin 6.0.8-alpha.5 → 6.0.8-alpha.51
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 +188 -4
- package/lib/common/package-releases/package.json +26 -0
- package/lib/common/package-releases/package.json.cjs +33 -0
- package/lib/common/package-releases/package.json.cjs.map +1 -0
- package/lib/common/package-releases/package.json.mjs +33 -0
- package/lib/common/package-releases/package.json.mjs.map +1 -0
- 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/src/context.tsx.template +8 -0
- package/lib/generators/add-frontend/frameworks/antui/{entry.client.tsx.template → src/entry.client.tsx.template} +12 -12
- package/{src/generators/add-frontend/frameworks/antui → lib/generators/add-frontend/frameworks/antui/src}/entry.server.tsx.template +61 -51
- package/{src/generators/add-frontend/frameworks/antui → lib/generators/add-frontend/frameworks/antui/src}/root.tsx.template +6 -15
- package/lib/generators/add-frontend/frameworks/chakraui/{context.tsx.template → src/context.tsx.template} +6 -0
- package/lib/generators/add-frontend/frameworks/chakraui/{entry.client.tsx.template → src/entry.client.tsx.template} +21 -18
- package/{src/generators/add-frontend/frameworks/chakraui → lib/generators/add-frontend/frameworks/chakraui/src}/entry.server.tsx.template +33 -30
- package/lib/generators/add-frontend/frameworks/chakraui/{root.tsx.template → src/root.tsx.template} +8 -4
- package/{src/generators/add-frontend/frameworks/tailwindui → lib/generators/add-frontend/frameworks/tailwindui/src}/entry.client.tsx.template +3 -10
- package/lib/generators/add-frontend/generator.cjs +83 -36
- package/lib/generators/add-frontend/generator.cjs.map +1 -1
- package/lib/generators/add-frontend/generator.mjs +83 -36
- package/lib/generators/add-frontend/generator.mjs.map +1 -1
- 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 +18 -1
- package/lib/generators/add-fullstack/files/Jenkinsfile +2 -2
- package/lib/generators/add-fullstack/files/cdecode-config.json +126 -0
- package/lib/generators/add-fullstack/files/package.json +31 -18
- 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-fullstack/generator.cjs +8 -4
- package/lib/generators/add-fullstack/generator.cjs.map +1 -1
- package/lib/generators/add-fullstack/generator.mjs +8 -4
- package/lib/generators/add-fullstack/generator.mjs.map +1 -1
- package/lib/generators/add-fullstack/schema.json +1 -1
- 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/rollup.config.mjs +3 -0
- package/src/common/package-releases/package.json +26 -0
- package/src/generators/add-frontend/__snapshots__/generator.test.ts.snap +33 -0
- package/src/generators/add-frontend/frameworks/antui/src/context.tsx.template +8 -0
- package/src/generators/add-frontend/frameworks/antui/{entry.client.tsx.template → src/entry.client.tsx.template} +12 -12
- package/{lib/generators/add-frontend/frameworks/antui → src/generators/add-frontend/frameworks/antui/src}/entry.server.tsx.template +61 -51
- package/{lib/generators/add-frontend/frameworks/antui → src/generators/add-frontend/frameworks/antui/src}/root.tsx.template +6 -15
- package/src/generators/add-frontend/frameworks/chakraui/{context.tsx.template → src/context.tsx.template} +6 -0
- package/src/generators/add-frontend/frameworks/chakraui/{entry.client.tsx.template → src/entry.client.tsx.template} +21 -18
- package/{lib/generators/add-frontend/frameworks/chakraui → src/generators/add-frontend/frameworks/chakraui/src}/entry.server.tsx.template +33 -30
- package/src/generators/add-frontend/frameworks/chakraui/{root.tsx.template → src/root.tsx.template} +8 -4
- package/src/generators/add-frontend/frameworks/tailwindui/postcss.config.js +6 -0
- package/{lib/generators/add-frontend/frameworks/tailwindui → src/generators/add-frontend/frameworks/tailwindui/src}/entry.client.tsx.template +3 -10
- package/src/generators/add-frontend/frameworks/tailwindui/tailwind.config.ts.template +12 -0
- package/src/generators/add-frontend/generator.test.ts +79 -0
- package/src/generators/add-frontend/generator.ts +109 -44
- package/src/generators/add-fullstack/files/Jenkinsfile +2 -2
- package/src/generators/add-fullstack/files/cdecode-config.json +126 -0
- package/src/generators/add-fullstack/files/package.json +31 -18
- 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-fullstack/generator.ts +8 -4
- package/src/generators/add-fullstack/schema.json +1 -1
- 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/tsconfig.spec.json +9 -0
- package/docker-releases/backend/package.json +0 -134
- package/docker-releases/frontend/antd/package.json +0 -121
- package/lib/generators/add-fullstack/files/codegen.yml +0 -47
- package/lib/generators/add-moleculer/files/src/modules/module.ts.template +0 -31
- package/src/generators/add-frontend/generator.spec.ts +0 -20
- package/src/generators/add-fullstack/files/codegen.yml +0 -47
- package/src/generators/add-moleculer/files/src/modules/module.ts.template +0 -31
- /package/lib/generators/add-frontend/{templates → frameworks/tailwindui}/postcss.config.js +0 -0
- /package/lib/generators/add-frontend/frameworks/tailwindui/{entry.server.tsx.template → src/entry.server.tsx.template} +0 -0
- /package/lib/generators/add-frontend/frameworks/tailwindui/{root.tsx.template → src/root.tsx.template} +0 -0
- /package/lib/generators/add-frontend/frameworks/tailwindui/{tailwind.css → src/tailwind.css} +0 -0
- /package/lib/generators/add-frontend/{templates → frameworks/tailwindui}/tailwind.config.ts.template +0 -0
- /package/lib/generators/add-frontend/{generator.spec.d.ts → generator.test.d.ts} +0 -0
- /package/src/generators/add-frontend/frameworks/tailwindui/{entry.server.tsx.template → src/entry.server.tsx.template} +0 -0
- /package/src/generators/add-frontend/frameworks/tailwindui/{root.tsx.template → src/root.tsx.template} +0 -0
- /package/src/generators/add-frontend/frameworks/tailwindui/{tailwind.css → src/tailwind.css} +0 -0
|
@@ -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';
|
|
@@ -13,17 +11,8 @@ import clientModules, { plugins } from '@app/frontend-stack-react/modules.js';
|
|
|
13
11
|
import { useChangeLanguage } from 'remix-i18next/react';
|
|
14
12
|
import { useTranslation } from 'react-i18next';
|
|
15
13
|
// @ts-ignore
|
|
16
|
-
import { i18nextInstance as i18next } from '@app/frontend-stack-react/i18n-localization/i18next.server.js';
|
|
17
|
-
// @ts-ignore
|
|
18
14
|
import { ErrorBoundary } from '@app/frontend-stack-react/entries/antui/components/ErrorBoundary';
|
|
19
|
-
|
|
20
|
-
export const loader = async ({ request }) => {
|
|
21
|
-
const locale = await i18next.getLocale(request);
|
|
22
|
-
return json({
|
|
23
|
-
__ENV__: publicEnv,
|
|
24
|
-
locale,
|
|
25
|
-
});
|
|
26
|
-
};
|
|
15
|
+
import { LocaleContext } from './context';
|
|
27
16
|
|
|
28
17
|
export const handle = {
|
|
29
18
|
i18n: 'common',
|
|
@@ -34,8 +23,8 @@ export function shouldRevalidate(params: any) {
|
|
|
34
23
|
}
|
|
35
24
|
|
|
36
25
|
export function Layout({ children }: { children: React.ReactNode }) {
|
|
37
|
-
const data = useRouteLoaderData<{ locale: any }>('root');
|
|
38
|
-
const locale =
|
|
26
|
+
// const data = useRouteLoaderData<{ locale: any }>('root');
|
|
27
|
+
const locale: any = React.useContext(LocaleContext);
|
|
39
28
|
|
|
40
29
|
const { i18n } = useTranslation();
|
|
41
30
|
|
|
@@ -49,9 +38,10 @@ export function Layout({ children }: { children: React.ReactNode }) {
|
|
|
49
38
|
if (typeof window === 'undefined') {
|
|
50
39
|
return (
|
|
51
40
|
<>
|
|
41
|
+
<script>window.__ENV__=[__ENV__]</script>
|
|
52
42
|
<script
|
|
53
43
|
dangerouslySetInnerHTML={{
|
|
54
|
-
__html: `window.
|
|
44
|
+
__html: `window.process = {} `,
|
|
55
45
|
}}
|
|
56
46
|
/>
|
|
57
47
|
<script
|
|
@@ -68,6 +58,7 @@ export function Layout({ children }: { children: React.ReactNode }) {
|
|
|
68
58
|
__html: `if (global === undefined) { var global = window; }`,
|
|
69
59
|
}}
|
|
70
60
|
/>
|
|
61
|
+
<script>window.__LOCALE__=[__LOCALE__]</script>
|
|
71
62
|
</>
|
|
72
63
|
);
|
|
73
64
|
}
|
|
@@ -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);
|
|
@@ -6,8 +6,6 @@ import { ApolloProvider } from '@apollo/client/index.js';
|
|
|
6
6
|
import { SlotFillProvider, removeUniversalPortals } from '@common-stack/components-pro';
|
|
7
7
|
import { InversifyProvider, PluginArea } from '@common-stack/client-react';
|
|
8
8
|
import { Provider as ReduxProvider } from 'react-redux';
|
|
9
|
-
import { PersistGate } from 'redux-persist/integration/react';
|
|
10
|
-
import { persistStore } from 'redux-persist';
|
|
11
9
|
import { CacheProvider } from '@emotion/react';
|
|
12
10
|
|
|
13
11
|
// @ts-ignore
|
|
@@ -27,12 +25,10 @@ import Backend from 'i18next-http-backend';
|
|
|
27
25
|
import { getInitialNamespaces } from 'remix-i18next/client';
|
|
28
26
|
import config from '@app/cde-webconfig.json';
|
|
29
27
|
// @ts-ignore
|
|
30
|
-
|
|
31
|
-
import { ClientStyleContext } from './context';
|
|
28
|
+
import { ClientStyleContext, LocaleContext } from './context';
|
|
32
29
|
|
|
33
30
|
const { apolloClient: client, container, serviceFunc } = createClientContainer();
|
|
34
31
|
const { store } = createReduxStore(client, serviceFunc(), container);
|
|
35
|
-
const persistor = persistStore(store);
|
|
36
32
|
|
|
37
33
|
(window as any).__remixStore = store;
|
|
38
34
|
removeUniversalPortals((window as any).__SLOT_FILLS__ || []);
|
|
@@ -60,6 +56,13 @@ function ClientCacheProvider({ children }: ClientCacheProviderProps) {
|
|
|
60
56
|
);
|
|
61
57
|
}
|
|
62
58
|
|
|
59
|
+
function LocaleProvider({ children }: ClientCacheProviderProps) {
|
|
60
|
+
const el = (document as any).querySelector('html');
|
|
61
|
+
const locale = el?.getAttribute('lng') || '';
|
|
62
|
+
|
|
63
|
+
return <LocaleContext.Provider value={locale}>{children}</LocaleContext.Provider>;
|
|
64
|
+
}
|
|
65
|
+
|
|
63
66
|
async function hydrate() {
|
|
64
67
|
if (!i18next.isInitialized && config.i18n.enabled) {
|
|
65
68
|
await i18next
|
|
@@ -83,19 +86,19 @@ async function hydrate() {
|
|
|
83
86
|
document.getElementById('root')!,
|
|
84
87
|
// <StrictMode>
|
|
85
88
|
<I18nextProvider i18n={i18next}>
|
|
86
|
-
<
|
|
87
|
-
<
|
|
88
|
-
<
|
|
89
|
-
<
|
|
90
|
-
<
|
|
91
|
-
<
|
|
92
|
-
|
|
93
|
-
</
|
|
94
|
-
</
|
|
95
|
-
</
|
|
96
|
-
</
|
|
97
|
-
</
|
|
98
|
-
</
|
|
89
|
+
<LocaleProvider>
|
|
90
|
+
<ClientCacheProvider>
|
|
91
|
+
<ApolloProvider client={client}>
|
|
92
|
+
<ReduxProvider store={store}>
|
|
93
|
+
<SlotFillProvider>
|
|
94
|
+
<InversifyProvider container={container} modules={clientModules}>
|
|
95
|
+
<RemixBrowser />
|
|
96
|
+
</InversifyProvider>
|
|
97
|
+
</SlotFillProvider>
|
|
98
|
+
</ReduxProvider>
|
|
99
|
+
</ApolloProvider>
|
|
100
|
+
</ClientCacheProvider>
|
|
101
|
+
</LocaleProvider>
|
|
99
102
|
</I18nextProvider>,
|
|
100
103
|
// </StrictMode>,
|
|
101
104
|
);
|
|
@@ -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
|
{
|
package/lib/generators/add-frontend/frameworks/chakraui/{root.tsx.template → src/root.tsx.template}
RENAMED
|
@@ -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
|
}, []);
|
|
@@ -12,8 +12,6 @@ import { ApolloProvider } from '@apollo/client/index.js';
|
|
|
12
12
|
import { SlotFillProvider, removeUniversalPortals } from '@common-stack/components-pro';
|
|
13
13
|
import { InversifyProvider } from '@common-stack/client-react';
|
|
14
14
|
import { Provider as ReduxProvider } from 'react-redux';
|
|
15
|
-
import { PersistGate } from 'redux-persist/integration/react';
|
|
16
|
-
import { persistStore } from 'redux-persist';
|
|
17
15
|
import i18next from 'i18next';
|
|
18
16
|
import { I18nextProvider, initReactI18next } from 'react-i18next';
|
|
19
17
|
import LanguageDetector from 'i18next-browser-languagedetector';
|
|
@@ -31,7 +29,6 @@ import config from '@app/cde-webconfig.json';
|
|
|
31
29
|
|
|
32
30
|
const { apolloClient: client, container, serviceFunc } = createClientContainer();
|
|
33
31
|
const { store } = createReduxStore(client, serviceFunc(), container);
|
|
34
|
-
const persistor = persistStore(store);
|
|
35
32
|
|
|
36
33
|
(window as any).__remixStore = store;
|
|
37
34
|
removeUniversalPortals((window as any).__SLOT_FILLS__ || []);
|
|
@@ -64,13 +61,9 @@ async function hydrate() {
|
|
|
64
61
|
<ReduxProvider store={store}>
|
|
65
62
|
<SlotFillProvider>
|
|
66
63
|
<InversifyProvider container={container} modules={clientModules}>
|
|
67
|
-
<
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
<RemixBrowser />
|
|
71
|
-
</ApolloProvider>
|
|
72
|
-
)}
|
|
73
|
-
</PersistGate>
|
|
64
|
+
<ApolloProvider client={client}>
|
|
65
|
+
<RemixBrowser />
|
|
66
|
+
</ApolloProvider>
|
|
74
67
|
</InversifyProvider>
|
|
75
68
|
</SlotFillProvider>
|
|
76
69
|
</ReduxProvider>
|
|
@@ -1,5 +1,61 @@
|
|
|
1
|
-
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var tslib=require('tslib'),devkit=require('@nx/devkit'),path=require('path'),setupConfig_cjs=require('@common-stack/rollup-vite-utils/lib/utils/setupConfig.cjs'),index=require('../../utils/index.cjs'),constants=require('../../common/constants.cjs');function _interopNamespaceDefault(e){var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var path__namespace=/*#__PURE__*/_interopNamespaceDefault(path);const DEFAULT_FRAMEWORK = constants.FRAMEWORK_ANTUI;
|
|
1
|
+
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var tslib=require('tslib'),devkit=require('@nx/devkit'),path=require('path'),setupConfig_cjs=require('@common-stack/rollup-vite-utils/lib/utils/setupConfig.cjs'),index=require('../../utils/index.cjs'),constants=require('../../common/constants.cjs'),_package=require('../../common/package-releases/package.json.cjs');function _interopNamespaceDefault(e){var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var path__namespace=/*#__PURE__*/_interopNamespaceDefault(path);const DEFAULT_FRAMEWORK = constants.FRAMEWORK_ANTUI;
|
|
2
2
|
const DEFAULT_SERVER_NAME = 'frontend-server';
|
|
3
|
+
/**
|
|
4
|
+
* Helper to retrieve a package version from pluginPkg.
|
|
5
|
+
* Throws an error if a version for packageName is not defined.
|
|
6
|
+
*/
|
|
7
|
+
function getPackageVersion(packageName) {
|
|
8
|
+
// Read the generator's package.json. This file is updated using ncu,
|
|
9
|
+
// so the generator always picks up the latest dependency versions.
|
|
10
|
+
// const pluginPkgPath = path.resolve(__dirname, '../../common/package-releases/package.json');
|
|
11
|
+
// const pluginPkg = JSON.parse(fs.readFileSync(pluginPkgPath, 'utf-8'));
|
|
12
|
+
const version = (_package.default.dependencies && _package.default.dependencies[packageName]) ||
|
|
13
|
+
(_package.default.devDependencies && _package.default.devDependencies[packageName]);
|
|
14
|
+
if (!version) {
|
|
15
|
+
throw new Error(`Version for package "${packageName}" not found in plugin package.json.`);
|
|
16
|
+
}
|
|
17
|
+
return version;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Helper to map an array of dependency names to an object where each key is a dependency
|
|
21
|
+
* and its value is obtained via getPackageVersion().
|
|
22
|
+
*/
|
|
23
|
+
function mapDependencies(depNames) {
|
|
24
|
+
return depNames.reduce((acc, name) => {
|
|
25
|
+
acc[name] = getPackageVersion(name);
|
|
26
|
+
return acc;
|
|
27
|
+
}, {});
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* A mapping of frameworks to dependency definitions.
|
|
31
|
+
* Each dependency's version is obtained dynamically from pluginPkg using a helper.
|
|
32
|
+
*/
|
|
33
|
+
const frameworkDependencyMap = {
|
|
34
|
+
[constants.FRAMEWORK_ANTUI]: {
|
|
35
|
+
dependencies: mapDependencies([
|
|
36
|
+
'@admin-layout/ant-design-pro',
|
|
37
|
+
'@ant-design/static-style-extract',
|
|
38
|
+
'@emotion/react',
|
|
39
|
+
'@emotion/server',
|
|
40
|
+
'@emotion/css',
|
|
41
|
+
'@emotion/styled',
|
|
42
|
+
'antd',
|
|
43
|
+
]),
|
|
44
|
+
},
|
|
45
|
+
[constants.FRAMEWORK_CHAKRAUI]: {
|
|
46
|
+
dependencies: mapDependencies([
|
|
47
|
+
'@chakra-ui/react',
|
|
48
|
+
'framer-motion',
|
|
49
|
+
'@emotion/react',
|
|
50
|
+
'@emotion/server',
|
|
51
|
+
'@emotion/css',
|
|
52
|
+
'@emotion/styled',
|
|
53
|
+
]),
|
|
54
|
+
},
|
|
55
|
+
[constants.FRAMEWORK_TAILWINDUI]: {
|
|
56
|
+
devDependencies: mapDependencies(['tailwindcss', 'postcss', 'autoprefixer']),
|
|
57
|
+
},
|
|
58
|
+
};
|
|
3
59
|
function addFrontendGenerator(tree, options) {
|
|
4
60
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
5
61
|
const projectName = index.isValid(options.name) ? `frontend-${index.getValid(options.name)}-server` : DEFAULT_SERVER_NAME;
|
|
@@ -12,55 +68,46 @@ const generateFrontend = (tree, options) => tslib.__awaiter(void 0, void 0, void
|
|
|
12
68
|
let projectName = (_a = index.getValid(options.name)) !== null && _a !== void 0 ? _a : DEFAULT_SERVER_NAME;
|
|
13
69
|
const projectRoot = index.isValid(options.directory) ? `${index.getValid(options.directory)}/${projectName}` : projectName;
|
|
14
70
|
projectName = index.isValid(options.ns) ? `${index.getValid(options.ns)}-${projectName}` : projectName;
|
|
15
|
-
const projectSrc = `${projectRoot}/src`;
|
|
16
71
|
const framework = (_b = index.getValid(options.framework)) !== null && _b !== void 0 ? _b : DEFAULT_FRAMEWORK;
|
|
17
72
|
console.log('UI framework specified: ', framework);
|
|
18
|
-
// resetProject(`${basePath}/${projectRoot}`);
|
|
19
|
-
// addProjectConfiguration(tree, framework, {
|
|
20
|
-
// root: projectRoot,
|
|
21
|
-
// projectType: 'library',
|
|
22
|
-
// sourceRoot: projectSrc,
|
|
23
|
-
// targets: {},
|
|
24
|
-
// });
|
|
25
73
|
devkit.generateFiles(tree, path__namespace.join(__dirname, 'templates'), projectRoot, {});
|
|
26
|
-
devkit.generateFiles(tree, path__namespace.join(__dirname, 'frameworks', framework),
|
|
74
|
+
devkit.generateFiles(tree, path__namespace.join(__dirname, 'frameworks', framework), projectRoot, options);
|
|
27
75
|
devkit.updateJson(tree, `${projectRoot}/package.json`, (packageJson) => {
|
|
28
|
-
packageJson
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
else if (framework === constants.FRAMEWORK_CHAKRAUI) {
|
|
39
|
-
packageJson['dependencies']["@chakra-ui/react"] = "^2.8.2";
|
|
40
|
-
packageJson['dependencies']["framer-motion"] = "^11.5.4";
|
|
41
|
-
packageJson['dependencies']["@emotion/react"] = "^11.10.0";
|
|
42
|
-
packageJson['dependencies']["@emotion/server"] = "^11.10.0";
|
|
43
|
-
packageJson['dependencies']["@emotion/css"] = "^11.10.0";
|
|
44
|
-
packageJson['dependencies']["@emotion/styled"] = "^11.10.4";
|
|
76
|
+
packageJson.name = projectName;
|
|
77
|
+
packageJson.dependencies = packageJson.dependencies || {};
|
|
78
|
+
packageJson.devDependencies = packageJson.devDependencies || {};
|
|
79
|
+
const dependencyOverrides = frameworkDependencyMap[framework] || {};
|
|
80
|
+
if (dependencyOverrides.dependencies) {
|
|
81
|
+
Object.entries(dependencyOverrides.dependencies).forEach(([pkg, version]) => {
|
|
82
|
+
if (!packageJson.dependencies[pkg]) {
|
|
83
|
+
packageJson.dependencies[pkg] = version;
|
|
84
|
+
}
|
|
85
|
+
});
|
|
45
86
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
87
|
+
if (dependencyOverrides.devDependencies) {
|
|
88
|
+
Object.entries(dependencyOverrides.devDependencies).forEach(([pkg, version]) => {
|
|
89
|
+
if (!packageJson.devDependencies[pkg]) {
|
|
90
|
+
packageJson.devDependencies[pkg] = version;
|
|
91
|
+
}
|
|
92
|
+
});
|
|
50
93
|
}
|
|
51
94
|
return packageJson;
|
|
52
95
|
});
|
|
53
96
|
devkit.updateJson(tree, `${projectRoot}/config.json`, (configJson) => {
|
|
54
|
-
configJson
|
|
97
|
+
configJson.uiFramework = framework;
|
|
55
98
|
if (framework === constants.FRAMEWORK_ANTUI) {
|
|
56
|
-
configJson
|
|
99
|
+
if (!configJson.modules.includes('@admin-layout/ant-design-pro')) {
|
|
100
|
+
configJson.modules.push('@admin-layout/ant-design-pro');
|
|
101
|
+
}
|
|
57
102
|
}
|
|
58
103
|
else if (framework === constants.FRAMEWORK_CHAKRAUI) {
|
|
59
|
-
configJson
|
|
104
|
+
if (!configJson.modules.includes('@admin-layout/chakra-design-pro')) {
|
|
105
|
+
configJson.modules.push('@admin-layout/chakra-design-pro');
|
|
106
|
+
}
|
|
60
107
|
}
|
|
61
108
|
if (options['config.json']) {
|
|
62
|
-
const
|
|
63
|
-
configJson = setupConfig_cjs.deepMerge(configJson,
|
|
109
|
+
const additionalConfigs = options['config.json'];
|
|
110
|
+
configJson = setupConfig_cjs.deepMerge(configJson, additionalConfigs);
|
|
64
111
|
}
|
|
65
112
|
return configJson;
|
|
66
113
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.cjs","sources":["../../../src/generators/add-frontend/generator.ts"],"sourcesContent":[null],"names":["FRAMEWORK_ANTUI","isValid","getValid","__awaiter","generateFiles","path","updateJson","
|
|
1
|
+
{"version":3,"file":"generator.cjs","sources":["../../../src/generators/add-frontend/generator.ts"],"sourcesContent":[null],"names":["FRAMEWORK_ANTUI","pluginPkg","FRAMEWORK_CHAKRAUI","FRAMEWORK_TAILWINDUI","isValid","getValid","__awaiter","generateFiles","path","updateJson","deepMerge","formatFiles"],"mappings":"guBAYA,MAAM,iBAAiB,GAAGA,yBAAe,CAAC;AAC1C,MAAM,mBAAmB,GAAG,iBAAiB,CAAC;AAE9C;;;AAGG;AACH,SAAS,iBAAiB,CAAC,WAAmB,EAAA;;;;;AAM1C,IAAA,MAAM,OAAO,GACT,CAACC,gBAAS,CAAC,YAAY,IAAIA,gBAAS,CAAC,YAAY,CAAC,WAAW,CAAC;SAC7DA,gBAAS,CAAC,eAAe,IAAIA,gBAAS,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC,CAAC;IAE1E,IAAI,CAAC,OAAO,EAAE;AACV,QAAA,MAAM,IAAI,KAAK,CAAC,wBAAwB,WAAW,CAAA,mCAAA,CAAqC,CAAC,CAAC;KAC7F;AACD,IAAA,OAAO,OAAO,CAAC;AACnB,CAAC;AAED;;;AAGG;AACH,SAAS,eAAe,CAAC,QAAkB,EAAA;IACvC,OAAO,QAAQ,CAAC,MAAM,CAClB,CAAC,GAAG,EAAE,IAAI,KAAI;QACV,GAAG,CAAC,IAAI,CAAC,GAAG,iBAAiB,CAAC,IA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AAE;AACxB,YAAA,MAAM,iBAAiB,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AACjD,YAAA,UAAU,GAAGQ,yBAAS,CAAC,UAAU,EAAE,iBAAiB,CAAC,CAAC;SACzD;AAED,QAAA,OAAO,UAAU,CAAC;AACtB,KAAC,CAAC,CAAC;AAEH,IAAA,MAAMC,kBAAW,CAAC,IAAI,CAAC,CAAC;AAC5B,CAAC"}
|
|
@@ -1,5 +1,61 @@
|
|
|
1
|
-
import {__awaiter}from'tslib';import {generateFiles,updateJson,formatFiles}from'@nx/devkit';import*as path from'path';import {deepMerge}from'@common-stack/rollup-vite-utils/lib/utils/setupConfig.cjs';import {isValid,getValid}from'../../utils/index.mjs';import {FRAMEWORK_ANTUI,FRAMEWORK_CHAKRAUI,FRAMEWORK_TAILWINDUI}from'../../common/constants.mjs';const DEFAULT_FRAMEWORK = FRAMEWORK_ANTUI;
|
|
1
|
+
import {__awaiter}from'tslib';import {generateFiles,updateJson,formatFiles}from'@nx/devkit';import*as path from'path';import {deepMerge}from'@common-stack/rollup-vite-utils/lib/utils/setupConfig.cjs';import {isValid,getValid}from'../../utils/index.mjs';import {FRAMEWORK_ANTUI,FRAMEWORK_CHAKRAUI,FRAMEWORK_TAILWINDUI}from'../../common/constants.mjs';import pluginPkg from'../../common/package-releases/package.json.mjs';const DEFAULT_FRAMEWORK = FRAMEWORK_ANTUI;
|
|
2
2
|
const DEFAULT_SERVER_NAME = 'frontend-server';
|
|
3
|
+
/**
|
|
4
|
+
* Helper to retrieve a package version from pluginPkg.
|
|
5
|
+
* Throws an error if a version for packageName is not defined.
|
|
6
|
+
*/
|
|
7
|
+
function getPackageVersion(packageName) {
|
|
8
|
+
// Read the generator's package.json. This file is updated using ncu,
|
|
9
|
+
// so the generator always picks up the latest dependency versions.
|
|
10
|
+
// const pluginPkgPath = path.resolve(__dirname, '../../common/package-releases/package.json');
|
|
11
|
+
// const pluginPkg = JSON.parse(fs.readFileSync(pluginPkgPath, 'utf-8'));
|
|
12
|
+
const version = (pluginPkg.dependencies && pluginPkg.dependencies[packageName]) ||
|
|
13
|
+
(pluginPkg.devDependencies && pluginPkg.devDependencies[packageName]);
|
|
14
|
+
if (!version) {
|
|
15
|
+
throw new Error(`Version for package "${packageName}" not found in plugin package.json.`);
|
|
16
|
+
}
|
|
17
|
+
return version;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Helper to map an array of dependency names to an object where each key is a dependency
|
|
21
|
+
* and its value is obtained via getPackageVersion().
|
|
22
|
+
*/
|
|
23
|
+
function mapDependencies(depNames) {
|
|
24
|
+
return depNames.reduce((acc, name) => {
|
|
25
|
+
acc[name] = getPackageVersion(name);
|
|
26
|
+
return acc;
|
|
27
|
+
}, {});
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* A mapping of frameworks to dependency definitions.
|
|
31
|
+
* Each dependency's version is obtained dynamically from pluginPkg using a helper.
|
|
32
|
+
*/
|
|
33
|
+
const frameworkDependencyMap = {
|
|
34
|
+
[FRAMEWORK_ANTUI]: {
|
|
35
|
+
dependencies: mapDependencies([
|
|
36
|
+
'@admin-layout/ant-design-pro',
|
|
37
|
+
'@ant-design/static-style-extract',
|
|
38
|
+
'@emotion/react',
|
|
39
|
+
'@emotion/server',
|
|
40
|
+
'@emotion/css',
|
|
41
|
+
'@emotion/styled',
|
|
42
|
+
'antd',
|
|
43
|
+
]),
|
|
44
|
+
},
|
|
45
|
+
[FRAMEWORK_CHAKRAUI]: {
|
|
46
|
+
dependencies: mapDependencies([
|
|
47
|
+
'@chakra-ui/react',
|
|
48
|
+
'framer-motion',
|
|
49
|
+
'@emotion/react',
|
|
50
|
+
'@emotion/server',
|
|
51
|
+
'@emotion/css',
|
|
52
|
+
'@emotion/styled',
|
|
53
|
+
]),
|
|
54
|
+
},
|
|
55
|
+
[FRAMEWORK_TAILWINDUI]: {
|
|
56
|
+
devDependencies: mapDependencies(['tailwindcss', 'postcss', 'autoprefixer']),
|
|
57
|
+
},
|
|
58
|
+
};
|
|
3
59
|
function addFrontendGenerator(tree, options) {
|
|
4
60
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5
61
|
const projectName = isValid(options.name) ? `frontend-${getValid(options.name)}-server` : DEFAULT_SERVER_NAME;
|
|
@@ -12,55 +68,46 @@ const generateFrontend = (tree, options) => __awaiter(void 0, void 0, void 0, fu
|
|
|
12
68
|
let projectName = (_a = getValid(options.name)) !== null && _a !== void 0 ? _a : DEFAULT_SERVER_NAME;
|
|
13
69
|
const projectRoot = isValid(options.directory) ? `${getValid(options.directory)}/${projectName}` : projectName;
|
|
14
70
|
projectName = isValid(options.ns) ? `${getValid(options.ns)}-${projectName}` : projectName;
|
|
15
|
-
const projectSrc = `${projectRoot}/src`;
|
|
16
71
|
const framework = (_b = getValid(options.framework)) !== null && _b !== void 0 ? _b : DEFAULT_FRAMEWORK;
|
|
17
72
|
console.log('UI framework specified: ', framework);
|
|
18
|
-
// resetProject(`${basePath}/${projectRoot}`);
|
|
19
|
-
// addProjectConfiguration(tree, framework, {
|
|
20
|
-
// root: projectRoot,
|
|
21
|
-
// projectType: 'library',
|
|
22
|
-
// sourceRoot: projectSrc,
|
|
23
|
-
// targets: {},
|
|
24
|
-
// });
|
|
25
73
|
generateFiles(tree, path.join(__dirname, 'templates'), projectRoot, {});
|
|
26
|
-
generateFiles(tree, path.join(__dirname, 'frameworks', framework),
|
|
74
|
+
generateFiles(tree, path.join(__dirname, 'frameworks', framework), projectRoot, options);
|
|
27
75
|
updateJson(tree, `${projectRoot}/package.json`, (packageJson) => {
|
|
28
|
-
packageJson
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
else if (framework === FRAMEWORK_CHAKRAUI) {
|
|
39
|
-
packageJson['dependencies']["@chakra-ui/react"] = "^2.8.2";
|
|
40
|
-
packageJson['dependencies']["framer-motion"] = "^11.5.4";
|
|
41
|
-
packageJson['dependencies']["@emotion/react"] = "^11.10.0";
|
|
42
|
-
packageJson['dependencies']["@emotion/server"] = "^11.10.0";
|
|
43
|
-
packageJson['dependencies']["@emotion/css"] = "^11.10.0";
|
|
44
|
-
packageJson['dependencies']["@emotion/styled"] = "^11.10.4";
|
|
76
|
+
packageJson.name = projectName;
|
|
77
|
+
packageJson.dependencies = packageJson.dependencies || {};
|
|
78
|
+
packageJson.devDependencies = packageJson.devDependencies || {};
|
|
79
|
+
const dependencyOverrides = frameworkDependencyMap[framework] || {};
|
|
80
|
+
if (dependencyOverrides.dependencies) {
|
|
81
|
+
Object.entries(dependencyOverrides.dependencies).forEach(([pkg, version]) => {
|
|
82
|
+
if (!packageJson.dependencies[pkg]) {
|
|
83
|
+
packageJson.dependencies[pkg] = version;
|
|
84
|
+
}
|
|
85
|
+
});
|
|
45
86
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
87
|
+
if (dependencyOverrides.devDependencies) {
|
|
88
|
+
Object.entries(dependencyOverrides.devDependencies).forEach(([pkg, version]) => {
|
|
89
|
+
if (!packageJson.devDependencies[pkg]) {
|
|
90
|
+
packageJson.devDependencies[pkg] = version;
|
|
91
|
+
}
|
|
92
|
+
});
|
|
50
93
|
}
|
|
51
94
|
return packageJson;
|
|
52
95
|
});
|
|
53
96
|
updateJson(tree, `${projectRoot}/config.json`, (configJson) => {
|
|
54
|
-
configJson
|
|
97
|
+
configJson.uiFramework = framework;
|
|
55
98
|
if (framework === FRAMEWORK_ANTUI) {
|
|
56
|
-
configJson
|
|
99
|
+
if (!configJson.modules.includes('@admin-layout/ant-design-pro')) {
|
|
100
|
+
configJson.modules.push('@admin-layout/ant-design-pro');
|
|
101
|
+
}
|
|
57
102
|
}
|
|
58
103
|
else if (framework === FRAMEWORK_CHAKRAUI) {
|
|
59
|
-
configJson
|
|
104
|
+
if (!configJson.modules.includes('@admin-layout/chakra-design-pro')) {
|
|
105
|
+
configJson.modules.push('@admin-layout/chakra-design-pro');
|
|
106
|
+
}
|
|
60
107
|
}
|
|
61
108
|
if (options['config.json']) {
|
|
62
|
-
const
|
|
63
|
-
configJson = deepMerge(configJson,
|
|
109
|
+
const additionalConfigs = options['config.json'];
|
|
110
|
+
configJson = deepMerge(configJson, additionalConfigs);
|
|
64
111
|
}
|
|
65
112
|
return configJson;
|
|
66
113
|
});
|