create-sitecore-jss 22.5.0-canary.7 → 22.5.0-canary.9
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/dist/templates/angular-xmcloud/.env +0 -3
- package/dist/templates/angular-xmcloud/README.md +0 -1
- package/dist/templates/angular-xmcloud/scripts/config/plugins/xmcloud.ts +0 -2
- package/dist/templates/angular-xmcloud/src/app/lib/config.ts +0 -1
- package/dist/templates/angular-xmcloud/src/app/lib/graphql-client-factory/config.ts +1 -5
- package/dist/templates/node-xmcloud-proxy/README.md +60 -51
- package/package.json +2 -2
|
@@ -7,9 +7,6 @@ SITECORE_EDGE_CONTEXT_ID=
|
|
|
7
7
|
|
|
8
8
|
# ========== XM Cloud Proxy ===========
|
|
9
9
|
|
|
10
|
-
# Your XM Cloud Proxy hostname is needed to build the app and execute the client-side requests against the proxy server.
|
|
11
|
-
PROXY_HOST=http://localhost:3000
|
|
12
|
-
|
|
13
10
|
# Your XM Cloud Proxy server path is needed to build the app. The build output will be copied to the proxy server path.
|
|
14
11
|
# Use a relative unix style path to ensure compatibility when deployment runs on Windows or Unix based systems.
|
|
15
12
|
PROXY_BUILD_PATH=<%- locals.relativeProxyAppDestination.replace(/\\/g, '\/') %>dist
|
|
@@ -77,7 +77,6 @@ The following environment variables can be used to configure the angular app. Yo
|
|
|
77
77
|
|
|
78
78
|
| Parameter | Description |
|
|
79
79
|
| -------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
80
|
-
| `PROXY_HOST` | Your XM Cloud Proxy hostname is needed to build the app and execute the client-side requests against the proxy server. Default value `http://localhost:3000` |
|
|
81
80
|
| `PROXY_BUILD_PATH` | Your XM Cloud Proxy server path is needed to build the app. The build output will be copied to the XM Cloud Proxy application path. Default value `<xmcloud_proxy_path>\dist`.
|
|
82
81
|
| `SITECORE_EDGE_CONTEXT_ID` | The Context ID, which covers many system configurations, is required for connecting to the XM Cloud back end. This is an XM Cloud system environment variable. When the application runs on the XM Cloud editing host, this value is always set to the preview Context ID. |
|
|
83
82
|
| `SITECORE_API_KEY` | The API key for GRAPH_QL_ENDPOINT authentication. It should be used in combination with SITECORE_API_HOST for local development when connecting to a local XM Cloud instance
|
|
@@ -12,7 +12,6 @@ class XMCloudPlugin implements ConfigPlugin {
|
|
|
12
12
|
|
|
13
13
|
async exec(config: JssConfig) {
|
|
14
14
|
const proxyBuildPath = process.env[`${constantCase('proxyBuildPath')}`]?.replace(/\/$/, '');
|
|
15
|
-
const proxyHost = process.env[`${constantCase('proxyHost')}`];
|
|
16
15
|
|
|
17
16
|
const sitecoreEdgeUrl =
|
|
18
17
|
process.env[`${constantCase('sitecoreEdgeUrl')}`]?.replace(/\/$/, '') ||
|
|
@@ -30,7 +29,6 @@ class XMCloudPlugin implements ConfigPlugin {
|
|
|
30
29
|
|
|
31
30
|
return Object.assign({}, config, {
|
|
32
31
|
proxyBuildPath,
|
|
33
|
-
proxyHost,
|
|
34
32
|
sitecoreEdgeUrl,
|
|
35
33
|
sitecoreEdgeContextId,
|
|
36
34
|
personalizeScope,
|
|
@@ -11,7 +11,6 @@ export interface JssConfig extends Record<string, string | boolean | undefined>
|
|
|
11
11
|
graphQLEndpointPath?: string;
|
|
12
12
|
defaultServerRoute?: string;
|
|
13
13
|
proxyBuildPath?: string;
|
|
14
|
-
proxyHost?: string;
|
|
15
14
|
sitecoreEdgeUrl?: string;
|
|
16
15
|
sitecoreEdgeContextId?: string;
|
|
17
16
|
}
|
|
@@ -17,15 +17,11 @@ export const getGraphQLClientFactoryConfig = () => {
|
|
|
17
17
|
const isProduction = env.production === 'true';
|
|
18
18
|
|
|
19
19
|
if (isProduction) {
|
|
20
|
-
if (!env.proxyHost) {
|
|
21
|
-
throw new Error('Please configure your proxyHost.');
|
|
22
|
-
}
|
|
23
|
-
|
|
24
20
|
if (env.sitecoreEdgeContextId) {
|
|
25
21
|
clientConfig = {
|
|
26
22
|
endpoint: isServer
|
|
27
23
|
? getEdgeProxyContentUrl(env.sitecoreEdgeContextId, env.sitecoreEdgeUrl)
|
|
28
|
-
: getEdgeProxyContentUrl(env.sitecoreEdgeContextId,
|
|
24
|
+
: getEdgeProxyContentUrl(env.sitecoreEdgeContextId, ''),
|
|
29
25
|
};
|
|
30
26
|
} else if (env.graphQLEndpoint && env.sitecoreApiKey) {
|
|
31
27
|
// we ignore ssr-proxy and query CM directly in case apiKey is used (i.e. in dev docker deployments)
|
|
@@ -91,64 +91,73 @@ If the operation is successful, you’ll see the following message:
|
|
|
91
91
|
|
|
92
92
|
Follow these steps to deploy your application to Netlify. The deployed site can be used as an editing host in XM Cloud.
|
|
93
93
|
|
|
94
|
-
1. Run `npm init` in the root directory (which contains SPA and Node XM Cloud Proxy app
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
2. Ensure that `<your-proxy-app-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
94
|
+
1. Run `npm init` in the root directory (which contains SPA and Node XM Cloud Proxy app folders) and add the following scripts to package.json:
|
|
95
|
+
```
|
|
96
|
+
"build": "cd ./<your-proxy-app-folder> && npm run build-all && cd ..",
|
|
97
|
+
"install": "cd ./<your-proxy-app-folder> && npm install && npm run install-all && cd .."
|
|
98
|
+
```
|
|
99
|
+
2. Ensure that `<your-proxy-app-folder>/package.json` includes the following commands to handle the build and install steps properly:
|
|
100
|
+
```
|
|
101
|
+
"build-all": "cd ../angular && npm run build && cd ../<your-proxy-app-folder> && tsc",
|
|
102
|
+
"install-all": "cd ../angular && npm i && cd ../<your-proxy-app-folder> && npm i"
|
|
103
|
+
```
|
|
104
104
|
3. Configure `serverless-http`:
|
|
105
|
-
- Install the
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
105
|
+
- Install the serverless-http package :
|
|
106
|
+
- If you're deploying a standalone Angular app with the Node proxy, run the following command inside your proxy app folder:
|
|
107
|
+
```
|
|
108
|
+
npm i serverless-http
|
|
109
|
+
```
|
|
110
|
+
- If you're working within the pnpm setup context of the [xmcloud-foundation-head](https://github.com/sitecorelabs/xmcloud-foundation-head), run the following command inside your proxy app folder:
|
|
111
|
+
```
|
|
112
|
+
pnpm add serverless-http
|
|
113
|
+
```
|
|
114
|
+
- Import serverless-http in `<your-proxy-app-folder>/src/index.ts` file and export the serverless handler:
|
|
110
115
|
```
|
|
111
|
-
|
|
116
|
+
import serverless from 'serverless-http';
|
|
117
|
+
...
|
|
118
|
+
export const handler = serverless(server);
|
|
112
119
|
```
|
|
113
120
|
4. Create a `netlify.toml` file and ensure that the following Netlify configuration is added there:
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
- Add the following build command:
|
|
137
|
-
```
|
|
138
|
-
[build]
|
|
139
|
-
command = "npm run build"
|
|
140
|
-
publish = "<your-proxy-app-name>/dist"
|
|
141
|
-
```
|
|
121
|
+
```
|
|
122
|
+
[functions]
|
|
123
|
+
directory = "<your-proxy-app-folder>/src"
|
|
124
|
+
node_bundler = "esbuild"
|
|
125
|
+
included_files = ["<your-proxy-app-folder>/dist/**"]
|
|
126
|
+
[[redirects]]
|
|
127
|
+
from = "/dist/browser/*"
|
|
128
|
+
status = 200
|
|
129
|
+
to = "/browser/:splat"
|
|
130
|
+
[[redirects]]
|
|
131
|
+
from = "/*"
|
|
132
|
+
status = 200
|
|
133
|
+
to = "/.netlify/functions/index/:splat"
|
|
134
|
+
force = true
|
|
135
|
+
[build]
|
|
136
|
+
command = "npm run build"
|
|
137
|
+
publish = "<your-proxy-app-folder>/dist"
|
|
138
|
+
```
|
|
139
|
+
- The `[functions]` section allows the proxy app to be treated as Netlify functions. [Functions Overview](https://docs.netlify.com/functions/overview/)
|
|
140
|
+
- The first `[[redirects]]` section ensures that static assets are accessed properly.
|
|
141
|
+
- The second `[[redirects]]` section means that, by default, redirects aren't applied if a file exists at the same path as the one defined in the `from` property. Setting `force` to `true` ensures the redirect rule takes precedence over existing files, preventing files in the deploy folder from being publicly accessible.
|
|
142
|
+
|
|
142
143
|
5. Create your [Netlify deployment](https://www.netlify.com/blog/2016/09/29/a-step-by-step-guide-deploying-on-netlify/):
|
|
143
144
|
- Set up all your necessary environment variables like `SITECORE_EDGE_CONTEXT_ID`, `SITECORE_SITE_NAME` etc.
|
|
145
|
+
- Configure Netlify to use the latest LTS version of Node.js.
|
|
144
146
|
- Configure your build settings in the Build and Deploy tab under Site configuration.
|
|
145
|
-
- sample configuration:
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
147
|
+
- sample configuration for standalone Angular + proxy deployment:
|
|
148
|
+
```
|
|
149
|
+
Base directory: /
|
|
150
|
+
Build command: npm run build
|
|
151
|
+
Publish directory: /proxy/dist
|
|
152
|
+
Functions directory: /proxy/src
|
|
153
|
+
```
|
|
154
|
+
- Sample configuration for use within the context of [xmcloud-foundation-head](https://github.com/sitecorelabs/xmcloud-foundation-head):
|
|
155
|
+
```
|
|
156
|
+
Base directory: /headapps/spa-starters/
|
|
157
|
+
Build command: npm run build
|
|
158
|
+
Publish directory: /headapps/spa-starters/proxy/dist
|
|
159
|
+
Functions directory: /headapps/spa-starters/proxy/src
|
|
160
|
+
```
|
|
152
161
|
NOTE: If `proxy/dist` folder is not picked up properly by Netlify make sure that the `PROXY_BUILD_PATH` env variable is unix style path e.g. `../proxy/dist`
|
|
153
162
|
|
|
154
163
|
### Deploy to Vercel
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-sitecore-jss",
|
|
3
|
-
"version": "22.5.0-canary.
|
|
3
|
+
"version": "22.5.0-canary.9",
|
|
4
4
|
"description": "Sitecore JSS initializer",
|
|
5
5
|
"bin": "./dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"ts-node": "^10.9.1",
|
|
66
66
|
"typescript": "~5.6.3"
|
|
67
67
|
},
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "22f5a2afa0a8d3d48a634fc1314fc960f898bc1d"
|
|
69
69
|
}
|