@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
|
@@ -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
|
}, []);
|
|
@@ -5,6 +5,9 @@ ENV PYTHON=/usr/bin/python
|
|
|
5
5
|
|
|
6
6
|
COPY .npmrc package.json /tmp/
|
|
7
7
|
|
|
8
|
+
# Copy the common package to the temporary directory
|
|
9
|
+
COPY common /tmp/common
|
|
10
|
+
|
|
8
11
|
RUN set -ex \
|
|
9
12
|
&& cd /tmp \
|
|
10
13
|
&& npm install -g node-gyp \
|
|
@@ -13,6 +16,7 @@ RUN set -ex \
|
|
|
13
16
|
&& rm -f /tmp/.npmrc \
|
|
14
17
|
&& mkdir -p /home/app \
|
|
15
18
|
&& cp -a /tmp/node_modules /home/app/ \
|
|
19
|
+
&& cp -a /tmp/common /home/app/common \
|
|
16
20
|
&& rm -Rf /tmp/*
|
|
17
21
|
|
|
18
22
|
|
|
@@ -25,8 +25,9 @@
|
|
|
25
25
|
"build:dev": "cross-env ENV_FILE=../../config/development/dev.env yarn build",
|
|
26
26
|
"build:devSSR": "cross-env SSR=true NODE_ENV=development ENV_FILE=../../config/development/dev.env yarn build",
|
|
27
27
|
"build:stats": "cross-env BUNDLE_STATS=true yarn build:debug",
|
|
28
|
+
"copycommon": "cp -r ../../packages/common .",
|
|
28
29
|
"dev:vite:ssr": "cross-env SSR=true NODE_ENV=development ENV_FILE=../../config/development/dev.env node ./server.js",
|
|
29
|
-
"docker:build": "
|
|
30
|
+
"docker:build": "yarn copycommon && yarn build && docker build . -t $npm_package_name:$npm_package_version",
|
|
30
31
|
"docker:build:debug": "yarn build:debug && docker build . -t $npm_package_name:$npm_package_version",
|
|
31
32
|
"docker:run": "docker run --env-file ../../config/staging/docker-staging.env -p 3000:3000 -it $npm_package_name:$npm_package_version",
|
|
32
33
|
"genconfig": "node ./tools/mergeConfig.js",
|
|
@@ -51,8 +52,11 @@
|
|
|
51
52
|
"watch:staging": "cross-env ENV_FILE=../../config/staging/staging.env node ./server.js",
|
|
52
53
|
"watch:test": "cross-env ENV_FILE=../../config/test/test.env node ./server.js"
|
|
53
54
|
},
|
|
55
|
+
"resolutions": {
|
|
56
|
+
"common": "link:./common"
|
|
57
|
+
},
|
|
54
58
|
"dependencies": {
|
|
55
|
-
"@common-stack/frontend-stack-react": "6.0.8-alpha.
|
|
59
|
+
"@common-stack/frontend-stack-react": "6.0.8-alpha.31",
|
|
56
60
|
"@react-icons/all-files": "^4.1.0",
|
|
57
61
|
"classnames": "^2.2.6",
|
|
58
62
|
"compression": "^1.7.4",
|
|
@@ -77,7 +81,7 @@
|
|
|
77
81
|
},
|
|
78
82
|
"devDependencies": {
|
|
79
83
|
"@cdmbase/vite-plugin-i18next-loader": "^2.0.12",
|
|
80
|
-
"@common-stack/rollup-vite-utils": "6.0.8-alpha.
|
|
84
|
+
"@common-stack/rollup-vite-utils": "6.0.8-alpha.40",
|
|
81
85
|
"@remix-run/dev": "~2.10.1",
|
|
82
86
|
"@remix-run/serve": "~2.10.1",
|
|
83
87
|
"cross-env": "^7.0.3",
|
|
@@ -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
|
+
}
|
|
@@ -52,7 +52,9 @@
|
|
|
52
52
|
"devpublish:push": "yarn predevpublish && git push origin $PUBLISH_BRANCH && yarn postdevpublish",
|
|
53
53
|
"format": "yarn lint --fix",
|
|
54
54
|
"format:md": "yarn lint:md --fix",
|
|
55
|
-
"
|
|
55
|
+
"pregenerateGraphql": " node --experimental-modules tools/codegenGenerator.mjs",
|
|
56
|
+
"generateGraphql": "graphql-codegen-esm",
|
|
57
|
+
"postgenerateGraphql": "lerna run watch --scope=common",
|
|
56
58
|
"generateGraphql:watch": "yarn generateGraphql -- --watch",
|
|
57
59
|
"git:pull": "git pull origin $(git rev-parse --abbrev-ref HEAD)",
|
|
58
60
|
"git:push": "git push origin $(git rev-parse --abbrev-ref HEAD)",
|
|
@@ -105,9 +107,11 @@
|
|
|
105
107
|
},
|
|
106
108
|
"resolutions": {
|
|
107
109
|
"@apollo/client": "^3.9.0",
|
|
108
|
-
"@types/react": "^18.
|
|
109
|
-
"@types/react-dom": "^18.
|
|
110
|
+
"@types/react": "^18.2.25",
|
|
111
|
+
"@types/react-dom": "^18.2.7",
|
|
112
|
+
"common": "link:packages/common",
|
|
110
113
|
"html-to-text": "^8.0.0",
|
|
114
|
+
"lerna": "8.1.8",
|
|
111
115
|
"react": "18.3.0-canary-c3048aab4-20240326",
|
|
112
116
|
"react-dom": "18.3.0-canary-c3048aab4-20240326",
|
|
113
117
|
"react-native": "0.72.10",
|
|
@@ -146,9 +150,9 @@
|
|
|
146
150
|
"@babel/preset-typescript": "^7.18.6",
|
|
147
151
|
"@babel/register": "^7.18.9",
|
|
148
152
|
"@babel/runtime": "^7.20.1",
|
|
149
|
-
"@common-stack/env-list-loader": "6.0.8-alpha.
|
|
150
|
-
"@common-stack/generate-plugin": "6.0.8-alpha.
|
|
151
|
-
"@common-stack/rollup-vite-utils": "6.0.8-alpha.
|
|
153
|
+
"@common-stack/env-list-loader": "6.0.8-alpha.31",
|
|
154
|
+
"@common-stack/generate-plugin": "6.0.8-alpha.40",
|
|
155
|
+
"@common-stack/rollup-vite-utils": "6.0.8-alpha.40",
|
|
152
156
|
"@emotion/babel-plugin": "^11.11.0",
|
|
153
157
|
"@graphql-codegen/add": "^5.0.2",
|
|
154
158
|
"@graphql-codegen/cli": "^5.0.2",
|
|
@@ -272,7 +276,7 @@
|
|
|
272
276
|
"jest-raw-loader": "^1.0.1",
|
|
273
277
|
"jest-transform-graphql": "^2.1.0",
|
|
274
278
|
"jsdom": "^20.0.2",
|
|
275
|
-
"lerna": "8",
|
|
279
|
+
"lerna": "8.1.8",
|
|
276
280
|
"less": "^4.1.3",
|
|
277
281
|
"less-loader": "^11.0.0",
|
|
278
282
|
"lint-staged": "^15.2.7",
|
|
@@ -311,7 +315,9 @@
|
|
|
311
315
|
"rimraf": "^3.0.2",
|
|
312
316
|
"rollup": "^4.13.0",
|
|
313
317
|
"rollup-plugin-esbuild": "^6.1.1",
|
|
318
|
+
"rollup-plugin-multi-input": "^1.5.0",
|
|
314
319
|
"rollup-plugin-string": "^3.0.0",
|
|
320
|
+
"rollup-plugin-svg": "^2.0.0",
|
|
315
321
|
"sass-loader": "^13.1.0",
|
|
316
322
|
"shelljs": "^0.8.5",
|
|
317
323
|
"simple-git": "^3.14.1",
|
|
@@ -332,6 +338,10 @@
|
|
|
332
338
|
"typedoc": "^0.23.20",
|
|
333
339
|
"typescript": "^5.5.4",
|
|
334
340
|
"url-loader": "^4.1.1",
|
|
341
|
+
"vite": "^5.1.1",
|
|
342
|
+
"vite-plugin-babel-macros": "^1.0.6",
|
|
343
|
+
"vite-plugin-cjs-interop": "^2.0.6",
|
|
344
|
+
"vite-plugin-compression": "^0.5.1",
|
|
335
345
|
"wait-on": "^6.0.1",
|
|
336
346
|
"webpack": "^5.74.0",
|
|
337
347
|
"webpack-bundle-analyzer": "^4.7.0",
|
|
@@ -3,15 +3,15 @@ import graphql from '@rollup/plugin-graphql';
|
|
|
3
3
|
import image from '@rollup/plugin-image';
|
|
4
4
|
import typescript from '@rollup/plugin-typescript';
|
|
5
5
|
import { string } from 'rollup-plugin-string';
|
|
6
|
+
import svg from 'rollup-plugin-svg';
|
|
6
7
|
import { copy } from '@web/rollup-plugin-copy';
|
|
7
8
|
import modifyLibFilesPlugin from '@common-stack/rollup-vite-utils/lib/rollup/rollupPluginModifyLibFiles.js';
|
|
8
9
|
import generateJsonFromObject from '@common-stack/rollup-vite-utils/lib/rollup/rollupPluginGenerateJson.js';
|
|
9
10
|
import addJsExtensionToImportsPlugin from '@common-stack/rollup-vite-utils/lib/rollup/rollupPluginAddJsExtension.js';
|
|
10
11
|
import { ignoreCssUrlPlugin } from '@common-stack/rollup-vite-utils/lib/rollup/pluginIgnore.js';
|
|
11
|
-
|
|
12
|
-
// Define any additional plugins specific to this bundle
|
|
12
|
+
// Define any additional plugins specific to this bundle
|
|
13
13
|
const additionalPlugins = [
|
|
14
|
-
copy({ patterns: ['**/cdm-locales/**/*', '**/styles/**/*'], rootDir: './src' }),
|
|
14
|
+
copy({ patterns: ['**/cdm-locales/**/*', '**/*.gql', '**/**/*.graphql', '**/styles/**/*', '**/css/**/*'], rootDir: './src' }),
|
|
15
15
|
];
|
|
16
16
|
|
|
17
17
|
function deepMergeConfigs(baseConfig, specificConfig) {
|
|
@@ -28,7 +28,8 @@ function deepMergeConfigs(baseConfig, specificConfig) {
|
|
|
28
28
|
// Base configuration
|
|
29
29
|
const baseConfig = {
|
|
30
30
|
plugins: [
|
|
31
|
-
image(),
|
|
31
|
+
image({ exclude: '**/*.svg' }),
|
|
32
|
+
svg({ include: '**/*.svg' }),
|
|
32
33
|
graphql({ include: '**/*.gql' }),
|
|
33
34
|
string({
|
|
34
35
|
include: ['**/*.ejs', '**/*.graphql'],
|
|
@@ -45,6 +46,7 @@ const baseConfig = {
|
|
|
45
46
|
outputDir: 'lib', // Ensure this matches your actual output directory
|
|
46
47
|
}),
|
|
47
48
|
generateJsonFromObject({}),
|
|
49
|
+
|
|
48
50
|
...additionalPlugins,
|
|
49
51
|
],
|
|
50
52
|
external: (id) => !/^[./]/.test(id),
|
|
@@ -52,101 +54,21 @@ const baseConfig = {
|
|
|
52
54
|
};
|
|
53
55
|
|
|
54
56
|
// Function to create a configuration by extending the base
|
|
55
|
-
function createRollupConfig(overrides) {
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
function watch(watchOptions, buildMode = '') {
|
|
59
|
-
const filename = path.basename(watchOptions.input);
|
|
60
|
-
message(
|
|
61
|
-
'note',
|
|
62
|
-
`${dt()} Rollup: Watcher Starting - watching for changes starting with: "${filename}" buildMode="${buildMode}"...`,
|
|
63
|
-
'WATCH ',
|
|
64
|
-
true,
|
|
65
|
-
);
|
|
66
|
-
const watcher = rollup.watch(watchOptions);
|
|
67
|
-
|
|
68
|
-
watcher.on('event', (event) => {
|
|
69
|
-
// event.code can be one of:
|
|
70
|
-
// START — the watcher is (re)starting
|
|
71
|
-
// BUNDLE_START — building an individual bundle
|
|
72
|
-
// * event.input will be the input options object if present
|
|
73
|
-
// * event.output contains an array of the "file" or
|
|
74
|
-
// "dir" option values of the generated outputs
|
|
75
|
-
// BUNDLE_END — finished building a bundle
|
|
76
|
-
// * event.input will be the input options object if present
|
|
77
|
-
// * event.output contains an array of the "file" or
|
|
78
|
-
// "dir" option values of the generated outputs
|
|
79
|
-
// * event.duration is the build duration in milliseconds
|
|
80
|
-
// * event.result contains the bundle object that can be
|
|
81
|
-
// used to generate additional outputs by calling
|
|
82
|
-
// bundle.generate or bundle.write. This is especially
|
|
83
|
-
// important when the watch.skipWrite option is used.
|
|
84
|
-
// You should call "event.result.close()" once you are done
|
|
85
|
-
// generating outputs, or if you do not generate outputs.
|
|
86
|
-
// This will allow plugins to clean up resources via the
|
|
87
|
-
// "closeBundle" hook.
|
|
88
|
-
// END — finished building all bundles
|
|
89
|
-
// ERROR — encountered an error while bundling
|
|
90
|
-
// * event.error contains the error that was thrown
|
|
91
|
-
// * event.result is null for build errors and contains the
|
|
92
|
-
// bundle object for output generation errors. As with
|
|
93
|
-
// "BUNDLE_END", you should call "event.result.close()" if
|
|
94
|
-
// present once you are done.
|
|
95
|
-
// If you return a Promise from your event handler, Rollup will wait until the
|
|
96
|
-
// Promise is resolved before continuing.
|
|
97
|
-
// console.log(`rollup: ${event.code}`)
|
|
98
|
-
if (event.code === 'BUNDLE_END') {
|
|
99
|
-
const outputFiles = event.output.map((o) => path.basename(o)).join(', .../');
|
|
100
|
-
const msg = `${dt()} Rollup: wrote bundle${event.output.length > 1 ? 's' : ''}: ".../${outputFiles}"`;
|
|
101
|
-
if (NOTIFY) {
|
|
102
|
-
notifier.notify({
|
|
103
|
-
title: 'React Component Build',
|
|
104
|
-
message: msg,
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
// messenger: success, warn, critical, note, log
|
|
108
|
-
message('success', msg, 'SUCCESS', true);
|
|
109
|
-
} else if (event.code === 'ERROR') {
|
|
110
|
-
message('critical', `!!!!!!!!!!!!!!!\nRollup ${event.error}\n!!!!!!!!!!!!!!!\n`, 'ERROR', true);
|
|
111
|
-
if (NOTIFY) {
|
|
112
|
-
notifier.notify({
|
|
113
|
-
title: 'NotePlan Plugins Build',
|
|
114
|
-
message: `An error occurred during build process.\nSee console for more information`,
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
});
|
|
57
|
+
function createRollupConfig(overrides, isWatchMode = false) {
|
|
58
|
+
const config = deepMergeConfigs(baseConfig, overrides);
|
|
119
59
|
|
|
120
|
-
//
|
|
121
|
-
|
|
122
|
-
if (
|
|
123
|
-
|
|
60
|
+
// Adjust TypeScript plugin based on watch mode
|
|
61
|
+
config.plugins = config.plugins.map((plugin) => {
|
|
62
|
+
if (plugin.name === 'typescript') {
|
|
63
|
+
return typescript({
|
|
64
|
+
...plugin.options,
|
|
65
|
+
noEmitOnError: !isWatchMode, // Set to false only in watch mode
|
|
66
|
+
});
|
|
124
67
|
}
|
|
68
|
+
return plugin;
|
|
125
69
|
});
|
|
126
70
|
|
|
127
|
-
|
|
128
|
-
// make Rollup wait at that stage:
|
|
129
|
-
watcher.on('change', (id /* , { event } */) => {
|
|
130
|
-
const filename = path.basename(id);
|
|
131
|
-
message('info', `${dt()} Rollup: file: "${filename}" changed`, 'CHANGE', true);
|
|
132
|
-
/* a file was modified */
|
|
133
|
-
});
|
|
134
|
-
watcher.on('restart', () => {
|
|
135
|
-
// console.log(`rollup: restarting`)
|
|
136
|
-
/* a new run was triggered (usually a watched file change) */
|
|
137
|
-
});
|
|
138
|
-
watcher.on('close', () => {
|
|
139
|
-
console.log(`rollup: closing`);
|
|
140
|
-
/* the watcher was closed, see below */
|
|
141
|
-
});
|
|
142
|
-
process.on('SIGINT', async function () {
|
|
143
|
-
console.log('\n\n');
|
|
144
|
-
console.log(colors.yellow('Quitting...\n'));
|
|
145
|
-
if (watcher) {
|
|
146
|
-
await watcher.close();
|
|
147
|
-
}
|
|
148
|
-
process.exit();
|
|
149
|
-
});
|
|
71
|
+
return config;
|
|
150
72
|
}
|
|
151
73
|
|
|
152
74
|
export { createRollupConfig, baseConfig };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
|
|
5
|
+
import { runCodegenTasks } from '@common-stack/rollup-vite-utils/lib/tools/codegen/index.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* This main script orchestrates your codegen steps, using cdecode-config.json.
|
|
9
|
+
* Usage:
|
|
10
|
+
* node tools/mainScript.mjs
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
// ESM housekeeping
|
|
14
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
15
|
+
const __dirname = path.dirname(__filename);
|
|
16
|
+
|
|
17
|
+
(async function main() {
|
|
18
|
+
try {
|
|
19
|
+
// 1) Locate and parse cdecode-config.json
|
|
20
|
+
const configPath = path.join(__dirname, '../cdecode-config.json');
|
|
21
|
+
if (!fs.existsSync(configPath)) {
|
|
22
|
+
console.error(`cdecode-config.json not found at: ${configPath}`);
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
const rawConfig = fs.readFileSync(configPath, 'utf-8');
|
|
26
|
+
const cdecodeConfig = JSON.parse(rawConfig);
|
|
27
|
+
|
|
28
|
+
// 2) Run the orchestrated tasks
|
|
29
|
+
await runCodegenTasks(cdecodeConfig);
|
|
30
|
+
|
|
31
|
+
console.log('mainScript completed successfully!');
|
|
32
|
+
} catch (err) {
|
|
33
|
+
console.error('Error running mainScript:', err);
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
36
|
+
})();
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
FROM node:20.16-alpine
|
|
2
2
|
|
|
3
3
|
COPY .npmrc package.json /tmp/
|
|
4
|
+
COPY common /tmp/common
|
|
4
5
|
|
|
5
6
|
RUN set -ex \
|
|
6
7
|
&& apk add --no-cache \
|
|
@@ -13,6 +14,7 @@ RUN set -ex \
|
|
|
13
14
|
&& rm -f /tmp/.npmrc \
|
|
14
15
|
&& mkdir -p /home/app \
|
|
15
16
|
&& cp -a /tmp/node_modules /home/app/ \
|
|
17
|
+
&& cp -a /tmp/common /home/app/common \
|
|
16
18
|
&& rm -Rf /tmp/*
|
|
17
19
|
|
|
18
20
|
WORKDIR /home/app
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
"build:clean": "rimraf dist",
|
|
13
13
|
"build:dist": "rollup -c rollup.config.mjs",
|
|
14
14
|
"build:watch": "npm run build:dist -- --watch",
|
|
15
|
-
"
|
|
15
|
+
"copycommon": "cp -r ../../packages/common .",
|
|
16
|
+
"docker:build": "yarn copycommon && npm run build && docker build . -t $npm_package_name:$npm_package_version",
|
|
16
17
|
"docker:run": "docker run -it --env-file ../../config/staging/docker-staging.env $npm_package_name:$npm_package_version",
|
|
17
18
|
"jest": "./node_modules/.bin/jest",
|
|
18
19
|
"start": "cross-env NODE_ENV=production tsx dist/index.js",
|
|
@@ -24,12 +25,15 @@
|
|
|
24
25
|
"test:watch": "npm test -- --watch",
|
|
25
26
|
"watch": "npm run start:dev"
|
|
26
27
|
},
|
|
28
|
+
"resolutions": {
|
|
29
|
+
"common": "link:./common"
|
|
30
|
+
},
|
|
27
31
|
"dependencies": {
|
|
28
|
-
"@common-stack/client-core": "6.0.8-alpha.
|
|
29
|
-
"@common-stack/core": "6.0.8-alpha.
|
|
30
|
-
"@common-stack/server-core": "6.0.8-alpha.
|
|
31
|
-
"@common-stack/server-stack": "6.0.8-alpha.
|
|
32
|
-
"@common-stack/store-mongo": "6.0.8-alpha.
|
|
32
|
+
"@common-stack/client-core": "6.0.8-alpha.31",
|
|
33
|
+
"@common-stack/core": "6.0.8-alpha.31",
|
|
34
|
+
"@common-stack/server-core": "6.0.8-alpha.31",
|
|
35
|
+
"@common-stack/server-stack": "6.0.8-alpha.32",
|
|
36
|
+
"@common-stack/store-mongo": "6.0.8-alpha.31",
|
|
33
37
|
"@container-stack/mailing-api": "5.2.1-alpha.1",
|
|
34
38
|
"helmet": "^3.21.2",
|
|
35
39
|
"react": "18.2.0",
|
|
@@ -1,11 +1,24 @@
|
|
|
1
1
|
import graphql from '@rollup/plugin-graphql';
|
|
2
2
|
import typescript from '@rollup/plugin-typescript';
|
|
3
3
|
import { string } from 'rollup-plugin-string';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import { fileURLToPath } from 'url';
|
|
6
|
+
import { writeBackendModuleFile } from '@common-stack/rollup-vite-utils';
|
|
7
|
+
|
|
8
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
+
const __dirname = path.dirname(__filename);
|
|
10
|
+
|
|
11
|
+
// Write backend module file before bundling
|
|
12
|
+
try {
|
|
13
|
+
const packageConfig = await import('./config.json', { assert: { type: 'json' } });
|
|
14
|
+
await writeBackendModuleFile(path.join(__dirname, 'src/modules'), packageConfig.default);
|
|
15
|
+
} catch (e) {
|
|
16
|
+
console.error('Error writing backend module file:', e);
|
|
17
|
+
}
|
|
4
18
|
|
|
5
19
|
const bundle = (config) => ({
|
|
6
20
|
...config,
|
|
7
21
|
input: 'src/index.ts',
|
|
8
|
-
// marking all node modules as external
|
|
9
22
|
external: (id) => !/^[./]/.test(id),
|
|
10
23
|
});
|
|
11
24
|
|