@common-stack/generate-plugin 6.0.2-alpha.6 → 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 CHANGED
@@ -3,6 +3,14 @@
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
+
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)
11
+
12
+ **Note:** Version bump only for package @common-stack/generate-plugin
13
+
6
14
  ## [6.0.2-alpha.6](https://github.com/cdmbase/common-stack/compare/v6.0.2-alpha.5...v6.0.2-alpha.6) (2024-08-23)
7
15
 
8
16
  **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 [cache, setCache] = useState(defaultCache);
49
+ const [count, setCount] = useState(0);
50
+ const defaultCache = useMemo(() => createEmotionCache(), [count]);
45
51
 
46
- function reset() {
47
- setCache(createEmotionCache());
48
- }
52
+ const reset = () => {
53
+ setCount((prev) => prev + 1);
54
+ };
49
55
 
50
56
  return (
51
57
  <ClientStyleContext.Provider value={{ reset }}>
52
- <CacheProvider value={cache}>{children}</CacheProvider>
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
- <I18nextProvider i18n={i18next}>
80
- <ClientCacheProvider>
81
- <ApolloProvider client={client}>
82
- <ReduxProvider store={store}>
83
- <SlotFillProvider>
84
- <InversifyProvider container={container} modules={clientModules}>
85
- <PersistGate loading={null} persistor={persistor}>
86
- {() => <RemixBrowser />}
87
- </PersistGate>
88
- </InversifyProvider>
89
- </SlotFillProvider>
90
- </ReduxProvider>
91
- </ApolloProvider>
92
- </ClientCacheProvider>
93
- </I18nextProvider>
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: resolve(config.i18n.backend.loadServerPath),
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
- let { locale } = useLoaderData();
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\"",
@@ -3,6 +3,9 @@ const fs = require('fs');
3
3
 
4
4
  // Function to update the configuration file
5
5
  function updateConfiguration(filePath, newVersion) {
6
+ // Convert the version from vMajor.Minor to vMajor-Minor for URL
7
+ const versionForUrl = newVersion.replace('.', '-');
8
+
6
9
  // Read the configuration file
7
10
  fs.readFile(filePath, 'utf8', (err, data) => {
8
11
  if (err) {
@@ -10,24 +13,20 @@ function updateConfiguration(filePath, newVersion) {
10
13
  return;
11
14
  }
12
15
 
13
- // Replace VERSION and CONNECTION_ID with newVersion
16
+ // Replace only the specific VERSION and CONNECTION_ID fields, preserving leading whitespace
14
17
  let updatedData = data
15
- .replace(/VERSION: v\d+(\.\d+)?/g, `VERSION: ${newVersion}`)
16
- .replace(/CONNECTION_ID: v\d+(\.\d+)?/g, `CONNECTION_ID: ${newVersion}`);
18
+ .replace(/^(\s*)VERSION:\s*v\d+(\.\d+)?/gm, `$1VERSION: ${newVersion}`)
19
+ .replace(/^(\s*)CONNECTION_ID:\s*v\d+(\.\d+)?/gm, `$1CONNECTION_ID: ${newVersion}`);
17
20
 
18
- // Update CLIENT_URL
21
+ // Update CLIENT_URL, preserving leading whitespace, and replacing the version with the hyphenated version
19
22
  updatedData = updatedData.replace(
20
- /CLIENT_URL: "https:\/\/[\w-]+-v\d+(\.\d+)?\.[\w-]+(\.\w+)?\/?"/g,
21
- (match) => {
22
- const domainParts = match.match(/https:\/\/[\w-]+-v\d+(\.\d+)?(\.[\w-]+)+/g);
23
- if (domainParts && domainParts.length > 0) {
24
- const domain = domainParts[0];
25
- const newDomain = domain.replace(/-v\d+(\.\d+)?/, `-${newVersion}`);
26
- return match.replace(domain, newDomain);
27
- }
28
- return match;
23
+ /^(\s*)CLIENT_URL:\s*"https:\/\/([\w-]+)-v\d+(-\d+)?(\.[\w-]+(\.\w+)?)\/?"/gm,
24
+ (match, p1, p2, p3, p4) => {
25
+ const newDomain = `${p2}-${versionForUrl}${p4}`;
26
+ return `${p1}CLIENT_URL: "https://${newDomain}"`;
29
27
  },
30
28
  );
29
+
31
30
  // Write the updated configuration back to the file
32
31
  fs.writeFile(filePath, updatedData, 'utf8', (err) => {
33
32
  if (err) {
@@ -35,7 +34,7 @@ function updateConfiguration(filePath, newVersion) {
35
34
  return;
36
35
  }
37
36
  console.log(`Configuration file updated successfully.`);
38
- console.log(`Manually update CLIENT_URL in values-dev.yaml and values-prod.yaml`)
37
+ console.log(`Manually update CLIENT_URL in values-dev.yaml and values-prod.yaml`);
39
38
  });
40
39
  });
41
40
  }
@@ -45,7 +44,7 @@ const filePath = process.argv[2];
45
44
  const versionArg = process.argv[3];
46
45
 
47
46
  if (!filePath || !versionArg || !versionArg.match(/^v\d+(\.\d+)?$/)) {
48
- console.error('Usage: node updateConfiguration.js v[Major].[Minor]');
47
+ console.error('Usage: node updateConfiguration.js <path-to-config> v[Major].[Minor]');
49
48
  process.exit(1);
50
49
  }
51
50
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@common-stack/generate-plugin",
3
- "version": "6.0.2-alpha.6",
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": "835ce01a9673173684b1e890c4256c1118054433"
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 [cache, setCache] = useState(defaultCache);
49
+ const [count, setCount] = useState(0);
50
+ const defaultCache = useMemo(() => createEmotionCache(), [count]);
45
51
 
46
- function reset() {
47
- setCache(createEmotionCache());
48
- }
52
+ const reset = () => {
53
+ setCount((prev) => prev + 1);
54
+ };
49
55
 
50
56
  return (
51
57
  <ClientStyleContext.Provider value={{ reset }}>
52
- <CacheProvider value={cache}>{children}</CacheProvider>
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
- <I18nextProvider i18n={i18next}>
80
- <ClientCacheProvider>
81
- <ApolloProvider client={client}>
82
- <ReduxProvider store={store}>
83
- <SlotFillProvider>
84
- <InversifyProvider container={container} modules={clientModules}>
85
- <PersistGate loading={null} persistor={persistor}>
86
- {() => <RemixBrowser />}
87
- </PersistGate>
88
- </InversifyProvider>
89
- </SlotFillProvider>
90
- </ReduxProvider>
91
- </ApolloProvider>
92
- </ClientCacheProvider>
93
- </I18nextProvider>
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: resolve(config.i18n.backend.loadServerPath),
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
- let { locale } = useLoaderData();
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\"",
@@ -3,6 +3,9 @@ const fs = require('fs');
3
3
 
4
4
  // Function to update the configuration file
5
5
  function updateConfiguration(filePath, newVersion) {
6
+ // Convert the version from vMajor.Minor to vMajor-Minor for URL
7
+ const versionForUrl = newVersion.replace('.', '-');
8
+
6
9
  // Read the configuration file
7
10
  fs.readFile(filePath, 'utf8', (err, data) => {
8
11
  if (err) {
@@ -10,24 +13,20 @@ function updateConfiguration(filePath, newVersion) {
10
13
  return;
11
14
  }
12
15
 
13
- // Replace VERSION and CONNECTION_ID with newVersion
16
+ // Replace only the specific VERSION and CONNECTION_ID fields, preserving leading whitespace
14
17
  let updatedData = data
15
- .replace(/VERSION: v\d+(\.\d+)?/g, `VERSION: ${newVersion}`)
16
- .replace(/CONNECTION_ID: v\d+(\.\d+)?/g, `CONNECTION_ID: ${newVersion}`);
18
+ .replace(/^(\s*)VERSION:\s*v\d+(\.\d+)?/gm, `$1VERSION: ${newVersion}`)
19
+ .replace(/^(\s*)CONNECTION_ID:\s*v\d+(\.\d+)?/gm, `$1CONNECTION_ID: ${newVersion}`);
17
20
 
18
- // Update CLIENT_URL
21
+ // Update CLIENT_URL, preserving leading whitespace, and replacing the version with the hyphenated version
19
22
  updatedData = updatedData.replace(
20
- /CLIENT_URL: "https:\/\/[\w-]+-v\d+(\.\d+)?\.[\w-]+(\.\w+)?\/?"/g,
21
- (match) => {
22
- const domainParts = match.match(/https:\/\/[\w-]+-v\d+(\.\d+)?(\.[\w-]+)+/g);
23
- if (domainParts && domainParts.length > 0) {
24
- const domain = domainParts[0];
25
- const newDomain = domain.replace(/-v\d+(\.\d+)?/, `-${newVersion}`);
26
- return match.replace(domain, newDomain);
27
- }
28
- return match;
23
+ /^(\s*)CLIENT_URL:\s*"https:\/\/([\w-]+)-v\d+(-\d+)?(\.[\w-]+(\.\w+)?)\/?"/gm,
24
+ (match, p1, p2, p3, p4) => {
25
+ const newDomain = `${p2}-${versionForUrl}${p4}`;
26
+ return `${p1}CLIENT_URL: "https://${newDomain}"`;
29
27
  },
30
28
  );
29
+
31
30
  // Write the updated configuration back to the file
32
31
  fs.writeFile(filePath, updatedData, 'utf8', (err) => {
33
32
  if (err) {
@@ -35,7 +34,7 @@ function updateConfiguration(filePath, newVersion) {
35
34
  return;
36
35
  }
37
36
  console.log(`Configuration file updated successfully.`);
38
- console.log(`Manually update CLIENT_URL in values-dev.yaml and values-prod.yaml`)
37
+ console.log(`Manually update CLIENT_URL in values-dev.yaml and values-prod.yaml`);
39
38
  });
40
39
  });
41
40
  }
@@ -45,7 +44,7 @@ const filePath = process.argv[2];
45
44
  const versionArg = process.argv[3];
46
45
 
47
46
  if (!filePath || !versionArg || !versionArg.match(/^v\d+(\.\d+)?$/)) {
48
- console.error('Usage: node updateConfiguration.js v[Major].[Minor]');
47
+ console.error('Usage: node updateConfiguration.js <path-to-config> v[Major].[Minor]');
49
48
  process.exit(1);
50
49
  }
51
50