@salesforce/storefront-next-dev 0.1.1 → 0.2.0-alpha.1
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/README.md +45 -36
- package/bin/run.js +12 -0
- package/dist/bundle.js +83 -0
- package/dist/cartridge-services/index.d.ts +2 -26
- package/dist/cartridge-services/index.d.ts.map +1 -1
- package/dist/cartridge-services/index.js +3 -336
- package/dist/cartridge-services/index.js.map +1 -1
- package/dist/commands/create-bundle.js +107 -0
- package/dist/commands/create-instructions.js +174 -0
- package/dist/commands/create-storefront.js +210 -0
- package/dist/commands/deploy-cartridge.js +52 -0
- package/dist/commands/dev.js +122 -0
- package/dist/commands/extensions/create.js +38 -0
- package/dist/commands/extensions/install.js +44 -0
- package/dist/commands/extensions/list.js +21 -0
- package/dist/commands/extensions/remove.js +38 -0
- package/dist/commands/generate-cartridge.js +35 -0
- package/dist/commands/prepare-local.js +30 -0
- package/dist/commands/preview.js +101 -0
- package/dist/commands/push.js +139 -0
- package/dist/config.js +87 -0
- package/dist/configs/react-router.config.js +3 -1
- package/dist/configs/react-router.config.js.map +1 -1
- package/dist/dependency-utils.js +314 -0
- package/dist/entry/client.d.ts +1 -0
- package/dist/entry/client.js +28 -0
- package/dist/entry/client.js.map +1 -0
- package/dist/entry/server.d.ts +15 -0
- package/dist/entry/server.d.ts.map +1 -0
- package/dist/entry/server.js +35 -0
- package/dist/entry/server.js.map +1 -0
- package/dist/flags.js +11 -0
- package/dist/generate-cartridge.js +620 -0
- package/dist/hooks/init.js +47 -0
- package/dist/index.d.ts +9 -29
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +413 -621
- package/dist/index.js.map +1 -1
- package/dist/local-dev-setup.js +176 -0
- package/dist/logger.js +105 -0
- package/dist/manage-extensions.js +329 -0
- package/dist/mrt/ssr.mjs +21 -21
- package/dist/mrt/ssr.mjs.map +1 -1
- package/dist/mrt/streamingHandler.mjs +28 -28
- package/dist/mrt/streamingHandler.mjs.map +1 -1
- package/dist/server.js +425 -0
- package/dist/utils.js +126 -0
- package/package.json +44 -9
- package/dist/cli.js +0 -3393
- /package/{LICENSE.txt → LICENSE} +0 -0
package/README.md
CHANGED
|
@@ -71,6 +71,7 @@ export default {
|
|
|
71
71
|
### CLI Commands
|
|
72
72
|
|
|
73
73
|
#### Create storefront
|
|
74
|
+
|
|
74
75
|
```bash
|
|
75
76
|
# Create storefront
|
|
76
77
|
pnpm dlx @salesforce/storefront-next-dev create-storefront
|
|
@@ -80,19 +81,19 @@ pnpm dlx @salesforce/storefront-next-dev create-storefront
|
|
|
80
81
|
|
|
81
82
|
```bash
|
|
82
83
|
# Push bundle
|
|
83
|
-
pnpm sfnext push --project-directory /path/to/your/project --project
|
|
84
|
+
pnpm sfnext push --project-directory /path/to/your/project --project mrt-project-id --environment mrt-target-environment
|
|
84
85
|
|
|
85
86
|
# Push bundle and wait for deployment
|
|
86
|
-
pnpm sfnext push --project-directory /path/to/your/project --project
|
|
87
|
+
pnpm sfnext push --project-directory /path/to/your/project --project mrt-project-id --environment mrt-target-environment --wait
|
|
87
88
|
|
|
88
89
|
# Push with custom message
|
|
89
|
-
pnpm sfnext push --project-directory /path/to/your/project --project
|
|
90
|
+
pnpm sfnext push --project-directory /path/to/your/project --project mrt-project-id --environment mrt-target-environment --message "Release v1.2.3"
|
|
90
91
|
|
|
91
92
|
# Push without deployment (upload only)
|
|
92
|
-
pnpm sfnext push --project-directory /path/to/your/project --project
|
|
93
|
+
pnpm sfnext push --project-directory /path/to/your/project --project mrt-project-id
|
|
93
94
|
|
|
94
95
|
# With custom build directory
|
|
95
|
-
pnpm sfnext push --project-directory /path/to/your/project --build-directory /custom/build/path --project
|
|
96
|
+
pnpm sfnext push --project-directory /path/to/your/project --build-directory /custom/build/path --project mrt-project-id --environment mrt-target-environment
|
|
96
97
|
```
|
|
97
98
|
|
|
98
99
|
#### Generate extension instructions
|
|
@@ -104,21 +105,16 @@ pnpm sfnext create-instructions --project-directory /path/to/your/project --exte
|
|
|
104
105
|
|
|
105
106
|
#### Cartridge generation and deployment instructions
|
|
106
107
|
|
|
108
|
+
Run these commands from your project directory (e.g., `template-retail-rsc-app`):
|
|
109
|
+
|
|
107
110
|
```bash
|
|
108
111
|
# Generate cartridge metadata for your site
|
|
109
|
-
pnpm sfnext generate-cartridge
|
|
112
|
+
pnpm sfnext generate-cartridge
|
|
110
113
|
|
|
111
114
|
# Deploy generated metadata to Commerce Cloud (uses dw.json for all settings)
|
|
112
|
-
pnpm sfnext deploy-cartridge
|
|
113
|
-
|
|
114
|
-
# Deploy cartridge to Commerce Cloud (uses dw.json for all settings)
|
|
115
|
-
pnpm sfnext deploy-cartridge my-cartridge.zip
|
|
116
|
-
|
|
117
|
-
# Deploy with both custom instance and version
|
|
118
|
-
pnpm sfnext deploy-cartridge my-cartridge.zip -i yourCommerceInstance -v custom-version
|
|
115
|
+
pnpm sfnext deploy-cartridge
|
|
119
116
|
```
|
|
120
117
|
|
|
121
|
-
|
|
122
118
|
## CLI Options
|
|
123
119
|
|
|
124
120
|
#### Push bundle
|
|
@@ -127,31 +123,40 @@ Run `pnpm sfnext push --help` to see all available options:
|
|
|
127
123
|
|
|
128
124
|
- `-b, --build-directory <dir>`: Build directory to push (default: auto-detected)
|
|
129
125
|
- `-m, --message <message>`: Bundle message (default: git branch:commit)
|
|
130
|
-
- `-
|
|
131
|
-
- `-
|
|
126
|
+
- `-p, --project <slug>`: Project slug - the unique identifier for your project on Managed Runtime
|
|
127
|
+
- `-e, --environment <target>`: Deploy target environment on Managed Runtime
|
|
132
128
|
- `-w, --wait`: Wait for deployment to complete
|
|
133
129
|
- `--cloud-origin <origin>`: API origin (default: https://cloud.mobify.com)
|
|
134
|
-
-
|
|
135
|
-
-
|
|
136
|
-
|
|
130
|
+
- `--credentials-file <file>`: Credentials file location
|
|
131
|
+
- `--api-key <api-key>`: MRT API key
|
|
132
|
+
|
|
133
|
+
Backward compatibility:
|
|
134
|
+
|
|
135
|
+
- `--project-slug` is supported as a deprecated alias for `--project`
|
|
136
|
+
- `--target` is supported as a deprecated alias for `--environment`
|
|
137
|
+
- `MRT_PROJECT` and `MRT_TARGET` are supported as fallback env vars for `project` and `environment`
|
|
137
138
|
|
|
138
139
|
#### Manage extensions
|
|
139
140
|
|
|
140
141
|
Run `pnpm sfnext extensions list` to view the list of installed extensions
|
|
142
|
+
|
|
141
143
|
- `-d, --project-directory`: Target project directory (default: current directory)
|
|
142
144
|
|
|
143
145
|
Run `pnpm sfnext extensions install` to install a new extension
|
|
146
|
+
|
|
144
147
|
- `-d, --project-directory`: Target project directory (default: current directory)
|
|
145
148
|
- `-e, --extension`: Extension marker value (e.g. SFDC_EXT_STORE_LOCATOR)
|
|
146
149
|
- `-s, --source-git-url`: Git URL of the source template project (default: "https://github.com/SalesforceCommerceCloud/storefront-next-template.git")
|
|
147
150
|
- `-v, --verbose`: Verbose mode
|
|
148
151
|
|
|
149
152
|
Run `pnpm sfnext extensions remove` to remove existing extensions
|
|
153
|
+
|
|
150
154
|
- `-d, --project-directory`: Target project directory (default: current directory)
|
|
151
155
|
- `-e, --extensions`: Comma-separated list of extension marker values (e.g. SFDC_EXT_STORE_LOCATOR,SFDC_EXT_INTERNAL_THEME_SWITCHER)
|
|
152
156
|
- `-v, --verbose`: Verbose mode
|
|
153
157
|
|
|
154
158
|
Run `pnpm sfnext extensions create` to create a new extension scaffolding
|
|
159
|
+
|
|
155
160
|
- `-p, --project-directory`: Target project directory (default: current directory)
|
|
156
161
|
- `-n, --name`: New extension name (e.g., Store Locator)
|
|
157
162
|
- `-d, --description`: Description for the extension
|
|
@@ -205,34 +210,35 @@ Response streaming is enabled by default for bundles pushed to MRT. To change th
|
|
|
205
210
|
|
|
206
211
|
### Deploy Cartridge Command Authentication
|
|
207
212
|
|
|
208
|
-
For cartridge deployment to Commerce Cloud,
|
|
213
|
+
For cartridge deployment to Commerce Cloud, configure B2C settings in `dw.json` (or pass flags directly):
|
|
209
214
|
|
|
210
|
-
1. **dw.json file** (
|
|
211
|
-
```json
|
|
212
|
-
{
|
|
213
|
-
"username": "your-username@salesforce.com",
|
|
214
|
-
"password": "your-web-access-key",
|
|
215
|
-
"hostname": "your-instance.dx.commercecloud.salesforce.com",
|
|
216
|
-
"code-version": "code-version-from-instance-BM"
|
|
217
|
-
}
|
|
218
|
-
```
|
|
215
|
+
1. **dw.json file** (recommended):
|
|
219
216
|
|
|
220
|
-
|
|
217
|
+
```json
|
|
218
|
+
{
|
|
219
|
+
"username": "your-username@salesforce.com",
|
|
220
|
+
"password": "your-web-access-key",
|
|
221
|
+
"hostname": "your-instance.dx.commercecloud.salesforce.com",
|
|
222
|
+
"code-version": "code-version-from-instance-BM"
|
|
223
|
+
}
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
2. **Authentication**: `sfnext deploy-cartridge` resolves instance settings from SDK config sources (`dw.json`, env vars, flags, instance selection) and supports WebDAV basic auth or OAuth credentials.
|
|
221
227
|
|
|
222
228
|
### Cartridge Commands
|
|
223
229
|
|
|
224
230
|
The cartridge commands are independent tools for working with Commerce Cloud metadata:
|
|
225
231
|
|
|
226
232
|
**Generate Cartridge**: `generate-cartridge` scans your project for decorated components and creates metadata files
|
|
233
|
+
|
|
227
234
|
- Scans `src/` directory for `@Component`, `@PageType`, and `@Aspect` decorators
|
|
228
235
|
- Generates JSON metadata files in `cartridge/cartridge/experience/` directory
|
|
229
236
|
- Creates separate files for components, page types, and aspects
|
|
230
237
|
|
|
231
238
|
**Deploy Metadata**: `deploy-cartridge` uploads metadata directories to Commerce Cloud
|
|
232
|
-
|
|
233
|
-
-
|
|
234
|
-
-
|
|
235
|
-
- Cleanup: Deletes the temporary ZIP file from the server using WebDAV DELETE
|
|
239
|
+
|
|
240
|
+
- Uploads mapped cartridges through `@salesforce/b2c-tooling-sdk`
|
|
241
|
+
- Uses the configured code version and credentials from resolved SDK config
|
|
236
242
|
|
|
237
243
|
**Automatic Cartridge Generation and Deployment on Push**
|
|
238
244
|
|
|
@@ -251,14 +257,17 @@ export const GENERATE_AND_DEPLOY_CARTRIDGE_ON_MRT_PUSH = true; // Set to true to
|
|
|
251
257
|
**Default:** `false` (manual cartridge generation/deployment via `sfnext generate-cartridge` and `sfnext deploy-cartridge`)
|
|
252
258
|
|
|
253
259
|
**Prerequisites:**
|
|
254
|
-
|
|
260
|
+
|
|
261
|
+
- A valid B2C configuration must be available via SDK config resolution (for example `dw.json`, env vars, or CLI flags)
|
|
255
262
|
|
|
256
263
|
When enabled, before each `pnpm sfnext push` command:
|
|
264
|
+
|
|
257
265
|
1. Cartridge metadata will be automatically generated from decorated components
|
|
258
266
|
2. The cartridge will be automatically deployed to Commerce Cloud
|
|
259
267
|
3. The MRT push will proceed as normal
|
|
260
268
|
|
|
261
269
|
If generation or deployment fails:
|
|
270
|
+
|
|
262
271
|
- A warning is displayed with manual command suggestions
|
|
263
272
|
- The MRT push still succeeds (cartridge errors don't block deployments)
|
|
264
273
|
|
|
@@ -279,7 +288,7 @@ Set up credentials in one of these ways:
|
|
|
279
288
|
}
|
|
280
289
|
```
|
|
281
290
|
|
|
282
|
-
2. **Command line flags**: Use `--
|
|
291
|
+
2. **Command line flags**: Use `--api-key` and optionally `--credentials-file` (see CLI Options section)
|
|
283
292
|
|
|
284
293
|
Get your credentials at: https://runtime.commercecloud.com/account/settings
|
|
285
294
|
|
package/bin/run.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import {execute} from '@oclif/core';
|
|
4
|
+
|
|
5
|
+
// Load .env file if present (Node.js native support)
|
|
6
|
+
try {
|
|
7
|
+
process.loadEnvFile();
|
|
8
|
+
} catch {
|
|
9
|
+
// .env file not found or not readable, continue without it
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
await execute({dir: import.meta.url});
|
package/dist/bundle.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { a as getProjectDependencyTree, o as getProjectPkg, s as getPwaKitDependencies } from "./utils.js";
|
|
2
|
+
import os from "os";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import fs from "fs-extra";
|
|
5
|
+
import { Minimatch } from "minimatch";
|
|
6
|
+
import archiver from "archiver";
|
|
7
|
+
|
|
8
|
+
//#region src/bundle.ts
|
|
9
|
+
/**
|
|
10
|
+
* Create a bundle from the build directory
|
|
11
|
+
*/
|
|
12
|
+
const createBundle = async (options) => {
|
|
13
|
+
const { message, ssr_parameters, ssr_only, ssr_shared, buildDirectory, projectDirectory, projectSlug } = options;
|
|
14
|
+
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "storefront-next-dev-push-"));
|
|
15
|
+
const destination = path.join(tmpDir, "build.tar");
|
|
16
|
+
const filesInArchive = [];
|
|
17
|
+
if (!ssr_only || ssr_only.length === 0 || !ssr_shared || ssr_shared.length === 0) throw new Error("no ssrOnly or ssrShared files are defined");
|
|
18
|
+
return new Promise((resolve, reject) => {
|
|
19
|
+
const output = fs.createWriteStream(destination);
|
|
20
|
+
const archive = archiver("tar");
|
|
21
|
+
archive.pipe(output);
|
|
22
|
+
const newRoot = path.join(projectSlug, "bld", "");
|
|
23
|
+
const storybookExclusionMatchers = [
|
|
24
|
+
"**/*.stories.tsx",
|
|
25
|
+
"**/*.stories.ts",
|
|
26
|
+
"**/*-snapshot.tsx",
|
|
27
|
+
".storybook/**/*",
|
|
28
|
+
"storybook-static/**/*",
|
|
29
|
+
"**/__mocks__/**/*",
|
|
30
|
+
"**/__snapshots__/**/*"
|
|
31
|
+
].map((pattern) => new Minimatch(pattern, { nocomment: true }));
|
|
32
|
+
archive.directory(buildDirectory, "", (entry) => {
|
|
33
|
+
if (entry.name && storybookExclusionMatchers.some((matcher) => matcher.match(entry.name))) return false;
|
|
34
|
+
if (entry.stats?.isFile() && entry.name) filesInArchive.push(entry.name);
|
|
35
|
+
entry.prefix = newRoot;
|
|
36
|
+
return entry;
|
|
37
|
+
});
|
|
38
|
+
archive.on("error", reject);
|
|
39
|
+
output.on("finish", () => {
|
|
40
|
+
try {
|
|
41
|
+
const { dependencies = {}, devDependencies = {} } = getProjectPkg(projectDirectory);
|
|
42
|
+
const dependencyTree = getProjectDependencyTree(projectDirectory);
|
|
43
|
+
const pwaKitDeps = dependencyTree ? getPwaKitDependencies(dependencyTree) : {};
|
|
44
|
+
const bundle_metadata = { dependencies: {
|
|
45
|
+
...dependencies,
|
|
46
|
+
...devDependencies,
|
|
47
|
+
...pwaKitDeps
|
|
48
|
+
} };
|
|
49
|
+
const data = fs.readFileSync(destination);
|
|
50
|
+
const encoding = "base64";
|
|
51
|
+
fs.rmSync(tmpDir, { recursive: true });
|
|
52
|
+
const createGlobMatcher = (patterns) => {
|
|
53
|
+
const allPatterns = patterns.map((pattern) => new Minimatch(pattern, { nocomment: true })).filter((pattern) => !pattern.empty);
|
|
54
|
+
const positivePatterns = allPatterns.filter((pattern) => !pattern.negate);
|
|
55
|
+
const negativePatterns = allPatterns.filter((pattern) => pattern.negate);
|
|
56
|
+
return (filePath) => {
|
|
57
|
+
if (filePath) {
|
|
58
|
+
const positive = positivePatterns.some((pattern) => pattern.match(filePath));
|
|
59
|
+
const negative = negativePatterns.some((pattern) => !pattern.match(filePath));
|
|
60
|
+
return positive && !negative;
|
|
61
|
+
}
|
|
62
|
+
return false;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
resolve({
|
|
66
|
+
message,
|
|
67
|
+
encoding,
|
|
68
|
+
data: data.toString(encoding),
|
|
69
|
+
ssr_parameters,
|
|
70
|
+
ssr_only: filesInArchive.filter(createGlobMatcher(ssr_only)),
|
|
71
|
+
ssr_shared: filesInArchive.filter(createGlobMatcher(ssr_shared)),
|
|
72
|
+
bundle_metadata
|
|
73
|
+
});
|
|
74
|
+
} catch (err) {
|
|
75
|
+
reject(err);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
archive.finalize().catch(reject);
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
//#endregion
|
|
83
|
+
export { createBundle as t };
|
|
@@ -1,29 +1,5 @@
|
|
|
1
|
-
//#region src/cartridge-services/types.d.ts
|
|
2
|
-
|
|
3
|
-
interface DeployResult {
|
|
4
|
-
version: string;
|
|
5
|
-
}
|
|
6
|
-
//#endregion
|
|
7
|
-
//#region src/cartridge-services/deploy-cartridge.d.ts
|
|
8
|
-
/**
|
|
9
|
-
* Deploy code to Commerce Cloud by uploading, unzipping, and cleaning up
|
|
10
|
-
*
|
|
11
|
-
* This function performs a complete code deployment workflow:
|
|
12
|
-
* 1. Uploads the archive file via WebDAV to the specified cartridge version
|
|
13
|
-
* 2. Unzips the archive on the server
|
|
14
|
-
* 3. Deletes the uploaded archive file
|
|
15
|
-
* 4. Returns the deployed version name
|
|
16
|
-
*
|
|
17
|
-
* @param instance - The Commerce Cloud instance hostname
|
|
18
|
-
* @param codeVersionName - The target code version name
|
|
19
|
-
* @param sourceDir - The local directory containing the source files to deploy
|
|
20
|
-
* @param basicAuth - Base64 encoded basic authentication credentials
|
|
21
|
-
* @returns Promise resolving to deployment result with the version name
|
|
22
|
-
* @throws Error if any step of the deployment process fails
|
|
23
|
-
*/
|
|
24
|
-
declare function deployCode(instance: string, codeVersionName: string, sourceDir: string, basicAuth: string): Promise<DeployResult>;
|
|
25
|
-
//#endregion
|
|
26
1
|
//#region src/cartridge-services/generate-cartridge.d.ts
|
|
2
|
+
|
|
27
3
|
/**
|
|
28
4
|
* Options for generateMetadata function
|
|
29
5
|
*/
|
|
@@ -56,5 +32,5 @@ interface GenerateMetadataResult {
|
|
|
56
32
|
}
|
|
57
33
|
declare function generateMetadata(projectDirectory: string, metadataDirectory: string, options?: GenerateMetadataOptions): Promise<GenerateMetadataResult>;
|
|
58
34
|
//#endregion
|
|
59
|
-
export { type
|
|
35
|
+
export { type GenerateMetadataOptions, type GenerateMetadataResult, generateMetadata };
|
|
60
36
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/cartridge-services/
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/cartridge-services/generate-cartridge.ts"],"sourcesContent":[],"mappings":";;AA8vBA;;;AAIG,UA1Ec,uBAAA,CA0Ed;EAAO;;;;;;;;;;;;;;;;;;;;UAlDO,sBAAA;;;;;;iBA8CK,gBAAA,gEAGR,0BACX,QAAQ"}
|