sfcc-metadata-cli 0.0.1 → 1.0.0
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/.github/workflows/check.yml +80 -0
- package/AGENTS.md +82 -0
- package/LICENSE +661 -0
- package/README.md +249 -0
- package/biome.json +32 -0
- package/commands/create-migration.js +157 -0
- package/commands/custom-object.js +426 -0
- package/commands/site-preference.js +503 -0
- package/commands/system-object.js +572 -0
- package/index.js +34 -0
- package/lib/merge.js +271 -0
- package/lib/templates.js +315 -0
- package/lib/utils.js +188 -0
- package/package.json +24 -15
- package/test/merge.test.js +84 -0
- package/test/templates.test.js +133 -0
- package/test/utils.test.js +79 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
name: Check
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
pull_request:
|
|
6
|
+
release:
|
|
7
|
+
types: [published]
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
id-token: write
|
|
11
|
+
contents: read
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
check:
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
container: node:24-slim
|
|
17
|
+
|
|
18
|
+
steps:
|
|
19
|
+
- name: Checkout code
|
|
20
|
+
uses: actions/checkout@v4
|
|
21
|
+
|
|
22
|
+
- name: Install dependencies
|
|
23
|
+
run: npm ci
|
|
24
|
+
|
|
25
|
+
- name: Run Biome check
|
|
26
|
+
run: npm run check
|
|
27
|
+
|
|
28
|
+
test:
|
|
29
|
+
runs-on: ubuntu-latest
|
|
30
|
+
container: node:${{ matrix.node-version }}-slim
|
|
31
|
+
|
|
32
|
+
strategy:
|
|
33
|
+
matrix:
|
|
34
|
+
node-version: [18, 20, 22, 24]
|
|
35
|
+
|
|
36
|
+
steps:
|
|
37
|
+
- name: Checkout code
|
|
38
|
+
uses: actions/checkout@v4
|
|
39
|
+
|
|
40
|
+
- name: Install dependencies
|
|
41
|
+
run: npm ci
|
|
42
|
+
|
|
43
|
+
- name: Run tests
|
|
44
|
+
run: npm test
|
|
45
|
+
|
|
46
|
+
audit:
|
|
47
|
+
runs-on: ubuntu-latest
|
|
48
|
+
container: node:24-slim
|
|
49
|
+
|
|
50
|
+
steps:
|
|
51
|
+
- name: Checkout code
|
|
52
|
+
uses: actions/checkout@v4
|
|
53
|
+
|
|
54
|
+
- name: Install dependencies
|
|
55
|
+
run: npm ci
|
|
56
|
+
|
|
57
|
+
- name: Run npm audit
|
|
58
|
+
run: npm audit --audit-level=high
|
|
59
|
+
|
|
60
|
+
publish:
|
|
61
|
+
runs-on: ubuntu-latest
|
|
62
|
+
container: node:24-slim
|
|
63
|
+
needs: [check, test, audit]
|
|
64
|
+
if: github.event_name == 'release'
|
|
65
|
+
|
|
66
|
+
steps:
|
|
67
|
+
- name: Checkout code
|
|
68
|
+
uses: actions/checkout@v4
|
|
69
|
+
|
|
70
|
+
- name: Checkout code
|
|
71
|
+
uses: actions/setup-node@v4
|
|
72
|
+
with:
|
|
73
|
+
node-version: 24
|
|
74
|
+
registry-url: https://registry.npmjs.org/
|
|
75
|
+
|
|
76
|
+
- name: Install dependencies
|
|
77
|
+
run: npm ci
|
|
78
|
+
|
|
79
|
+
- name: Publish to npm
|
|
80
|
+
run: npm publish
|
package/AGENTS.md
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# Agent Instructions
|
|
2
|
+
|
|
3
|
+
## Project Overview
|
|
4
|
+
|
|
5
|
+
This is a CLI tool for creating SFCC (Salesforce Commerce Cloud) B2C migrations. It generates XML metadata files for custom objects, site preferences, and system object extensions.
|
|
6
|
+
|
|
7
|
+
## Code Principles
|
|
8
|
+
|
|
9
|
+
### DRY (Don't Repeat Yourself)
|
|
10
|
+
|
|
11
|
+
- Extract shared logic into `lib/` utilities
|
|
12
|
+
- Reuse XML generation functions from `lib/templates.js`
|
|
13
|
+
- Shared constants (attribute types, system objects) should be defined once
|
|
14
|
+
|
|
15
|
+
### KISS (Keep It Simple, Stupid)
|
|
16
|
+
|
|
17
|
+
- Prefer simple, readable code over clever solutions
|
|
18
|
+
- Each function should do one thing well
|
|
19
|
+
- Avoid unnecessary abstractions
|
|
20
|
+
- Use clear, descriptive variable and function names
|
|
21
|
+
|
|
22
|
+
### YAGNI (You Aren't Gonna Need It)
|
|
23
|
+
|
|
24
|
+
- Don't add features "just in case"
|
|
25
|
+
- Implement only what's needed for the current requirement
|
|
26
|
+
- Remove unused code rather than commenting it out
|
|
27
|
+
|
|
28
|
+
### LoB (Locality of Behavior)
|
|
29
|
+
|
|
30
|
+
- Keep related code close together
|
|
31
|
+
- Command-specific logic stays in its command file
|
|
32
|
+
- Avoid spreading a single behavior across multiple files
|
|
33
|
+
- Prefer inline handlers over distant callbacks when reasonable
|
|
34
|
+
|
|
35
|
+
### Functional Style
|
|
36
|
+
|
|
37
|
+
- Prefer pure functions without side effects
|
|
38
|
+
- Use `map`, `filter`, `reduce` over imperative loops
|
|
39
|
+
- Avoid mutating function arguments
|
|
40
|
+
- Return new objects/arrays instead of modifying existing ones
|
|
41
|
+
- Keep I/O (file operations, console output) at the edges
|
|
42
|
+
|
|
43
|
+
## Project Structure
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
├── index.js # CLI entry point
|
|
47
|
+
├── commands/ # Command handlers (one file per command)
|
|
48
|
+
│ ├── create-migration.js
|
|
49
|
+
│ ├── custom-object.js
|
|
50
|
+
│ ├── site-preference.js
|
|
51
|
+
│ └── system-object.js
|
|
52
|
+
└── lib/ # Shared utilities
|
|
53
|
+
├── merge.js # XML merging logic
|
|
54
|
+
├── templates.js # XML generation templates
|
|
55
|
+
└── utils.js # File system and naming utilities
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Coding Guidelines
|
|
59
|
+
|
|
60
|
+
- Use `const` by default, `let` only when reassignment is needed
|
|
61
|
+
- Use template literals for XML generation
|
|
62
|
+
- Handle errors with try/catch and provide helpful messages
|
|
63
|
+
- Use `chalk` for colored console output
|
|
64
|
+
- Use `inquirer` for interactive prompts
|
|
65
|
+
- Use `yargs` for CLI argument parsing
|
|
66
|
+
|
|
67
|
+
## XML Generation
|
|
68
|
+
|
|
69
|
+
- Always use the `METADATA_NAMESPACE` constant
|
|
70
|
+
- Escape XML special characters with `escapeXml()`
|
|
71
|
+
- Generate well-formatted, indented XML
|
|
72
|
+
- Keep XML templates readable with multi-line template literals
|
|
73
|
+
|
|
74
|
+
## Before Finishing
|
|
75
|
+
|
|
76
|
+
Always run the linter before committing or finishing work:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
npm run check
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Ensure there are no errors. Use `npm run check:write` to auto-fix issues when possible.
|