campaign-cli 0.7.2

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 ADDED
@@ -0,0 +1,242 @@
1
+ # Campaign CLI
2
+
3
+ **A command-line interface for ACC (Campaign Classic) developers**
4
+
5
+ [![License: AGPL v3](https://img.shields.io/badge/License-AGPL_v3-blue.svg)](https://www.gnu.org/licenses/agpl-3.0)
6
+ [![Node.js](https://img.shields.io/badge/Node.js-22+-green.svg)](https://nodejs.org)
7
+ [![npm](https://img.shields.io/badge/npm-CLI-blue.svg)](https://www.npmjs.com/)
8
+
9
+ ## 🚀 Quick Start
10
+
11
+ ### Quick usage
12
+
13
+ ```bash
14
+ acc auth init --host https://instance.com --user username --password --alias staging
15
+
16
+ acc instance pull --alias staging
17
+ # Downloaded /Administration/Configuration/Form rendering
18
+ # Downloaded /Administration/Configuration/Dynamic Javascript pages
19
+ ```
20
+
21
+ ### Quick installation
22
+
23
+ ```bash
24
+ cd ~/Downloads
25
+ git clone https://github.com/myrosblog/campaign-cli.git
26
+ cd campaign-cli
27
+ npm install
28
+ npm link
29
+ acc # check installation
30
+ ```
31
+
32
+ ### Basic Usage
33
+
34
+ Folder structure recommendation, under a local folder, i.e. `Downloads`
35
+
36
+ ```bash
37
+ /Downloads/
38
+ ├── campaign-cli/ # Clone of this source code
39
+
40
+ ├── instance1-staging/ # Staging Instance 1
41
+ │ ├── config/ # Instance-specific config => automatically created with acc check
42
+ │ │ └── acc.config.json
43
+ │ └── Administration/Configuration/ # Downloaded schemas => automatically downloaded with acc pull
44
+ │ ├── schema1.xml
45
+ │ └── schema2.xml
46
+
47
+ └── instance1-production/ # Production Instance 2
48
+ ├── config/
49
+ │ └── acc.config.json
50
+ └── Administration/Configuration/
51
+ ├── schema1.xml
52
+ └── schema2.xml
53
+ ```
54
+
55
+ #### Step 1: Configure an ACC Instance
56
+
57
+ ```bash
58
+ acc auth init \
59
+ --host http://localhost:8080 \
60
+ --user admin \
61
+ --password admin \
62
+ --alias local
63
+ ```
64
+
65
+ This command:
66
+
67
+ - Saves credentials securely in your config store
68
+ - Tests the connection to your ACC instance
69
+ - Lists available schemas and record counts
70
+
71
+ #### Step 2: Pull Data from Your Instance with default configuration
72
+
73
+ ```bash
74
+ acc instance check --alias local
75
+ acc instance pull --alias local
76
+ ```
77
+
78
+ This command:
79
+
80
+ - Creates a local directory structure
81
+ - Downloads schema definitions as XML files
82
+ - Preserves original naming conventions
83
+ - Implements pagination for large datasets
84
+
85
+ #### Step 2-bis: Pull Data from Your Instance with custom configuration
86
+
87
+ Create
88
+
89
+ ```bash
90
+
91
+ ```
92
+
93
+ ## 📚 Features
94
+
95
+ ### Authentication Management
96
+
97
+ ```bash
98
+ # List all configured instances
99
+ acc auth list
100
+
101
+ # Troubleshoot IP via https://api.db-ip.com/v2/free/self @see https://opensource.adobe.com/acc-js-sdk/connecting.html
102
+ acc auth ip
103
+
104
+ # Login to an existing instance
105
+ acc auth login --alias prod
106
+
107
+ # Initialize a new instance
108
+ acc auth init --alias staging --host https://staging.example.com
109
+ ```
110
+
111
+ ### Data Operations
112
+
113
+ ```bash
114
+ # Check instance (count records without downloading)
115
+ acc instance check --alias prod
116
+
117
+ # Pull data with custom config
118
+ acc instance pull \
119
+ --alias prod \
120
+ --path ./my-project/data \
121
+ --config ./config/acc.config.json
122
+ ```
123
+
124
+ ### Configuration Management
125
+
126
+ Create a `acc.config.json` file to customize data pulling:
127
+
128
+ ```json
129
+ {
130
+ "nms:delivery": {
131
+ "filename": "Deliveries/{%name%}.xml",
132
+ "queryDef": {
133
+ "where": {
134
+ "condition": [{ "expr": "@builtIn = false AND @isModel = true" }]
135
+ }
136
+ }
137
+ }
138
+ }
139
+ ```
140
+
141
+ ## 🎯 Use Cases
142
+
143
+ ### For ACC Developers
144
+
145
+ ```bash
146
+ # Setup development environment
147
+ acc auth init --alias dev --host http://localhost:8080
148
+
149
+ # Pull specific schemas
150
+ acc instance pull --alias dev
151
+
152
+ # Regular data refresh
153
+ acc instance pull --alias prod --path ./backup/$(date +%Y-%m-%d)
154
+ ```
155
+
156
+ ### For DevOps Teams
157
+
158
+ ```bash
159
+ # CI/CD integration
160
+ acc auth init --alias ci --host $ACC_HOST --user $ACC_USER --password $ACC_PASSWORD
161
+ acc instance check --alias ci || exit 1
162
+
163
+ # Automated backups
164
+ acc instance pull --alias prod --path /backups/acc/$(date +%Y-%m-%d)
165
+ ```
166
+
167
+ ### For Data Analysts
168
+
169
+ ```bash
170
+ # Quick data extraction
171
+ acc instance pull --alias analytics --config ./config/analytics.config.json
172
+
173
+ # Schema documentation
174
+ acc instance check --alias prod > schema_report.txt
175
+ ```
176
+
177
+ ## 🔧 Advanced Configuration
178
+
179
+ ### Custom Paths and Configs
180
+
181
+ ```bash
182
+ acc instance pull \
183
+ --alias staging \
184
+ --path /projects/acc-migration/data \
185
+ --config ./config/migration.config.json
186
+ ```
187
+
188
+ ### Filename Patterns
189
+
190
+ Available variables for filename patterns:
191
+
192
+ - `%schema%` - Schema name (e.g., `nms_recipient`)
193
+ - `%namespace%` - Schema namespace
194
+ - `%name%` - Schema display name
195
+ - `%internalName%` - Internal schema name
196
+
197
+ ## 🤝 Contributing
198
+
199
+ Contributions are welcome! Please open a Pull Request!
200
+
201
+ ### Local development
202
+
203
+ ```bash
204
+ # Clone repository
205
+ git clone https://github.com/myrosblog/acc-cli.git
206
+ cd acc-cli
207
+ npm install
208
+ npm link
209
+ npm test
210
+ ```
211
+
212
+ ### Project Structure
213
+
214
+ ```
215
+ src/
216
+ ├── main.js # CLI entry point
217
+ ├── CampaignAuth.js # Authentication and instance management
218
+ ├── CampaignInstance.js # Data operations (check, pull, download)
219
+ └── CampaignError.js # Custom error handling
220
+
221
+ test/
222
+ ├── CampaignAuth.spec.js # Authentication tests
223
+ ├── CampaignInstance.spec.js # Data operation tests
224
+ └── CampaignError.spec.js # Error handling tests
225
+
226
+ bin/
227
+ └── acc # Executable wrapper
228
+
229
+ config/
230
+ └── acc.config.json # Default configuration template
231
+ ```
232
+
233
+ ## Roadmap
234
+
235
+ - Publish to npm
236
+
237
+ ## 🔒 Security
238
+
239
+ - Credentials are stored securely using `configstore`
240
+ - No credentials are logged or transmitted unnecessarily
241
+ - All network communications use the official ACC JS SDK
242
+ - Regular dependency updates for security patches
package/bin/acc ADDED
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env node
2
+ import { fileURLToPath } from "url";
3
+ import { dirname, join } from "path";
4
+ import { pathToFileURL } from "url";
5
+
6
+ // Récupère le chemin absolu du fichier courant
7
+ const __filename = fileURLToPath(import.meta.url);
8
+ const __dirname = dirname(__filename);
9
+
10
+ // Chemin vers le fichier main.mjs (compatible Windows/macOS/Linux)
11
+ const mainPath = join(__dirname, "..", "src", "main.js");
12
+ const mainUrl = pathToFileURL(mainPath).href; // Convertit en URL valide pour ESM
13
+
14
+ try {
15
+ await import(mainUrl);
16
+ } catch (error) {
17
+ console.error("Failed to load acc:", error.message);
18
+ process.exit(1);
19
+ }
@@ -0,0 +1,339 @@
1
+ {
2
+ "schemas": [
3
+ {
4
+ "schemaId": "nms:localOrgUnit",
5
+ "filename": "/Administration/Access Management/Organizational entities/{@name}.meta.xml",
6
+ "queryDef": {
7
+ "where": { "condition": [{ "expr": "@name NOT LIKE 'xtk%'" }] }
8
+ }
9
+ },
10
+ {
11
+ "schemaId": "nms:deliveryMapping",
12
+ "filename": "/Administration/Campaign Management/Target mappings/{@name}.meta.xml",
13
+ "queryDef": {
14
+ "where": { "condition": [{ "expr": "@builtIn = false" }] }
15
+ }
16
+ },
17
+ {
18
+ "schemaId": "nms:typology",
19
+ "filename": "/Administration/Campaign Management/Typology management/Typologies/{@name}.meta.xml",
20
+ "queryDef": {
21
+ "where": { "condition": [{ "expr": "@name NOT LIKE 'xtk%'" }] }
22
+ }
23
+ },
24
+ {
25
+ "schemaId": "nms:typologyRule",
26
+ "filename": "/Administration/Campaign Management/Typology management/Typology rules/{@name}.meta.xml",
27
+ "queryDef": {
28
+ "where": { "condition": [{ "expr": "@name NOT LIKE 'xtk%'" }] }
29
+ }
30
+ },
31
+ {
32
+ "schemaId": "xtk:srcSchema",
33
+ "filename": "/Administration/Configuration/Data schemas/{@namespace}/{@name}.xml",
34
+ "queryDef": {
35
+ "where": {
36
+ "condition": [
37
+ {
38
+ "expr": "@namespace NOT IN ('xtk', 'nl', 'ncm','nms', 'sfdc', 'crm', 'acx', 'adb')"
39
+ }
40
+ ]
41
+ },
42
+ "orderBy": { "node": [{ "expr": "@namespace" }, { "expr": "@name" }] }
43
+ }
44
+ },
45
+ {
46
+ "schemaId": "xtk:enum",
47
+ "filename": "/Administration/Platform/Enumerations/{@name}.xml",
48
+ "queryDef": {
49
+ "where": {
50
+ "condition": [
51
+ {
52
+ "expr": "@name NOT LIKE ''"
53
+ }
54
+ ]
55
+ }
56
+ }
57
+ },
58
+ {
59
+ "schemaId": "xtk:counter",
60
+ "filename": "/Administration/Platform/Counters/{@name}.xml",
61
+ "queryDef": {
62
+ "where": {
63
+ "condition": [
64
+ {
65
+ "expr": "@name NOT LIKE ''"
66
+ }
67
+ ]
68
+ }
69
+ }
70
+ },
71
+ {
72
+ "schemaId": "xtk:jssp",
73
+ "filename": "/Administration/Configuration/Dynamic JavaScript pages/{@namespace}/{@name}.meta.xml",
74
+ "decompose": {
75
+ "data": "/Administration/Configuration/Dynamic JavaScript pages/{@namespace}/{@name}.js"
76
+ },
77
+ "queryDef": {
78
+ "where": {
79
+ "condition": [
80
+ {
81
+ "expr": "@namespace NOT IN ('xtk', 'nl', 'ncm','nms', 'sfdc', 'crm', 'acx', 'adb')"
82
+ }
83
+ ]
84
+ }
85
+ }
86
+ },
87
+ {
88
+ "schemaId": "xtk:jst",
89
+ "filename": "/Administration/Configuration/JavaScript templates/{@namespace}/{@name}.meta.xml",
90
+ "decompose": {
91
+ "code": "/Administration/Configuration/JavaScript templates/{@namespace}/{@name}.js"
92
+ },
93
+ "queryDef": {
94
+ "where": {
95
+ "condition": [
96
+ {
97
+ "expr": "@namespace NOT IN ('xtk', 'nl', 'ncm','nms', 'sfdc', 'crm', 'acx', 'adb')"
98
+ }
99
+ ]
100
+ }
101
+ }
102
+ },
103
+ {
104
+ "schemaId": "xtk:formRendering",
105
+ "filename": "/Administration/Configuration/Form rendering/{@internalName}.meta.xml",
106
+ "decompose": {
107
+ "format/cssOverloading": "/Administration/Configuration/Form rendering/{@internalName}.css"
108
+ },
109
+ "queryDef": {
110
+ "where": {
111
+ "condition": [
112
+ {
113
+ "expr": "@internalName NOT LIKE 'xtk%' AND @internalName NOT LIKE 'nl%' AND @internalName NOT LIKE 'ncm%' AND @internalName NOT LIKE 'nms%'"
114
+ }
115
+ ]
116
+ }
117
+ }
118
+ },
119
+ {
120
+ "schemaId": "xtk:form",
121
+ "filename": "/Administration/Configuration/Input forms/{@namespace}/{@name}.xml",
122
+ "queryDef": {
123
+ "where": {
124
+ "condition": [
125
+ {
126
+ "expr": "@namespace NOT IN ('xtk', 'nl', 'ncm','nms', 'sfdc', 'crm', 'acx', 'adb')"
127
+ }
128
+ ]
129
+ }
130
+ }
131
+ },
132
+ {
133
+ "schemaId": "ncm:publishing",
134
+ "filename": "/Administration/Configuration/Publication Templates/{@namespace}/{@name}.meta.xml",
135
+ "queryDef": {
136
+ "where": {
137
+ "condition": [
138
+ {
139
+ "expr": "@namespace NOT IN ('xtk', 'nl', 'ncm','nms', 'sfdc', 'crm', 'acx', 'adb')"
140
+ }
141
+ ]
142
+ }
143
+ }
144
+ },
145
+ {
146
+ "schemaId": "xtk:javascript",
147
+ "filename": "/Administration/Configuration/JavaScript codes/{@namespace}/{@name}.meta.xml",
148
+ "decompose": {
149
+ "data": "/Administration/Configuration/JavaScript codes/{@namespace}/{@name}.js"
150
+ },
151
+ "queryDef": {
152
+ "where": {
153
+ "condition": [
154
+ {
155
+ "expr": "@namespace NOT IN ('xtk', 'nl', 'ncm','nms', 'sfdc', 'crm', 'acx', 'adb')"
156
+ }
157
+ ]
158
+ }
159
+ }
160
+ },
161
+ {
162
+ "schemaId": "xtk:navtree",
163
+ "filename": "/Administration/Configuration/Navigation hierarchies/{@namespace}/{@name}.xml",
164
+ "queryDef": {
165
+ "where": {
166
+ "condition": [
167
+ {
168
+ "expr": "@namespace NOT IN ('xtk', 'nl', 'ncm','nms', 'sfdc', 'crm', 'acx', 'adb')"
169
+ }
170
+ ]
171
+ }
172
+ }
173
+ },
174
+ {
175
+ "schemaId": "xtk:sql",
176
+ "filename": "/Administration/Configuration/SQL scripts/{@namespace}/{@name}.meta.xml",
177
+ "decompose": {
178
+ "data": "/Administration/Configuration/SQL scripts/{@namespace}/{@name}.sql"
179
+ },
180
+ "queryDef": {
181
+ "where": {
182
+ "condition": [
183
+ {
184
+ "expr": "@namespace NOT IN ('xtk', 'nl', 'ncm','nms', 'sfdc', 'crm', 'acx', 'adb')"
185
+ }
186
+ ]
187
+ }
188
+ }
189
+ },
190
+ {
191
+ "schemaId": "xtk:xslt",
192
+ "filename": "/Administration/Configuration/XSL style sheets/{@namespace}/{@name}.meta.xml",
193
+ "decompose": {
194
+ "data": "/Administration/Configuration/XSL style sheets/{@namespace}/{@name}.xsl"
195
+ },
196
+ "queryDef": {
197
+ "where": {
198
+ "condition": [
199
+ {
200
+ "expr": "@namespace NOT IN ('xtk', 'nl', 'ncm','nms', 'sfdc', 'crm', 'acx', 'adb')"
201
+ }
202
+ ]
203
+ }
204
+ }
205
+ },
206
+ {
207
+ "schemaId": "xtk:workflow",
208
+ "filename": "/Administration/Production/Objects created automatically/Campaign workflows/{@internalName}.meta.xml",
209
+ "queryDef": {
210
+ "where": {
211
+ "condition": [{ "expr": "@builtIn = true AND @isModel = false AND [@operation-id] != 0" }]
212
+ }
213
+ }
214
+ },
215
+ {
216
+ "schemaId": "xtk:workflow",
217
+ "filename": "/Administration/Production/Technical workflows/{@internalName}.meta.xml",
218
+ "queryDef": {
219
+ "where": {
220
+ "condition": [{ "expr": "@builtIn = true AND @isModel = false AND [@operation-id] = 0" }]
221
+ }
222
+ }
223
+ },
224
+ {
225
+ "schemaId": "xtk:workflow",
226
+ "filename": "/Resources/Templates/Workflow templates/{@internalName}.meta.xml",
227
+ "queryDef": {
228
+ "where": {
229
+ "condition": [{ "expr": "@builtIn = true AND @isModel = true" }]
230
+ }
231
+ }
232
+ },
233
+ {
234
+ "schemaId": "nms:operation",
235
+ "filename": "/Campaign Management/Campaigns/{@internalName}.meta.xml",
236
+ "queryDef": {
237
+ "where": {
238
+ "condition": [{ "expr": "@builtIn = false AND @isModel = true" }]
239
+ }
240
+ }
241
+ },
242
+ {
243
+ "schemaId": "nms:delivery",
244
+ "filename": "/Campaign Management/Deliveries/{@internalName}.meta.xml",
245
+ "decompose": {
246
+ "content/html/source": "/Campaign Management/Deliveries/{@internalName}.html",
247
+ "content/text/source": "/Campaign Management/Deliveries/{@internalName}.txt"
248
+ },
249
+ "excludeXPaths": ["@cryptedId"],
250
+ "queryDef": {
251
+ "where": {
252
+ "condition": [
253
+ { "expr": "@builtIn = true", "boolOperator": "AND" },
254
+ { "expr": "@isModel = false", "boolOperator": "AND" }
255
+ ]
256
+ }
257
+ }
258
+ },
259
+ {
260
+ "schemaId": "nms:delivery",
261
+ "filename": "/Resources/Templates/Delivery templates/{@internalName}.meta.xml",
262
+ "decompose": {
263
+ "content/html/source": "/Campaign Management/Deliveries/{@internalName}.html",
264
+ "content/text/source": "/Campaign Management/Deliveries/{@internalName}.txt"
265
+ },
266
+ "excludeXPaths": ["@cryptedId"],
267
+ "queryDef": {
268
+ "where": {
269
+ "condition": [
270
+ { "expr": "@builtIn = true", "boolOperator": "AND" },
271
+ { "expr": "@isModel = true", "boolOperator": "AND" }
272
+ ]
273
+ }
274
+ }
275
+ },
276
+ {
277
+ "schemaId": "nms:includeView",
278
+ "filename": "/Resources/Campaign Management/Personalization blocks/{@name}.meta.xml",
279
+ "decompose": {
280
+ "source/html": "/Resources/Campaign Management/Personalization blocks/{@name}.html",
281
+ "source/text": "/Resources/Campaign Management/Personalization blocks/{@name}.txt"
282
+ },
283
+ "queryDef": {
284
+ "where": {
285
+ "condition": [{ "expr": "@name NOT LIKE 'xtk%'" }]
286
+ }
287
+ }
288
+ },
289
+ {
290
+ "schemaId": "nms:deliveryCustomization",
291
+ "filename": "/Resources/Campaign Management/Personalization fields/{@name}.xml",
292
+ "queryDef": {
293
+ "where": { "condition": [{ "expr": "@isModel = true" }] }
294
+ }
295
+ },
296
+ {
297
+ "schemaId": "nms:webApp",
298
+ "filename": "/Resources/Online/Web applications/{@internalName}.xml",
299
+ "queryDef": {
300
+ "where": { "condition": [{ "expr": "@builtIn = false" }] }
301
+ }
302
+ },
303
+ {
304
+ "schemaId": "xtk:queryFilter",
305
+ "filename": "/Profiles and Targets/Predefined filters/{@name}.meta.xml",
306
+ "queryDef": {
307
+ "where": {
308
+ "condition": [{ "expr": "@name NOT LIKE ''" }]
309
+ }
310
+ }
311
+ },
312
+ {
313
+ "schemaId": "nms:group",
314
+ "filename": "/Profiles and Targets/Lists/{@name}.meta.xml",
315
+ "queryDef": {
316
+ "where": {
317
+ "condition": [
318
+ {
319
+ "expr": "@name NOT LIKE 'xtk%'"
320
+ }
321
+ ]
322
+ }
323
+ }
324
+ },
325
+ {
326
+ "schemaId": "xtk:folder",
327
+ "filename": "/Explorer/{@name}.meta.xml",
328
+ "queryDef": {
329
+ "where": {
330
+ "condition": [
331
+ {
332
+ "expr": "@builtIn = true"
333
+ }
334
+ ]
335
+ }
336
+ }
337
+ }
338
+ ]
339
+ }
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "campaign-cli",
3
+ "version": "0.7.2",
4
+ "description": "Save time, reduce risk and improve code health with acc CLI",
5
+ "keywords": [
6
+ "adobe",
7
+ "adobe campaign",
8
+ "adobe campaign classic",
9
+ "acc"
10
+ ],
11
+ "bin": {
12
+ "acc": "./bin/acc"
13
+ },
14
+ "preferGlobal": true,
15
+ "files": [
16
+ "bin/",
17
+ "src/",
18
+ "config/"
19
+ ],
20
+ "scripts": {
21
+ "init": "node src/main.js",
22
+ "test": "c8 mocha test/index.js"
23
+ },
24
+ "type": "module",
25
+ "dependencies": {
26
+ "@adobe/acc-js-sdk": "^1.1.61",
27
+ "chalk": "^5.6.2",
28
+ "commander": "^14.0.3",
29
+ "configstore": "^8.0.0",
30
+ "fs-extra": "^11.3.3"
31
+ },
32
+ "devDependencies": {
33
+ "c8": "^11.0.0",
34
+ "chai": "^6.2.2",
35
+ "mocha": "^11.3.0",
36
+ "sinon": "^21.0.1",
37
+ "sinon-chai": "^4.0.1"
38
+ },
39
+ "repository": {
40
+ "type": "git",
41
+ "url": "git+https://github.com/myrosblog/acc-cli.git"
42
+ },
43
+ "author": "Myros",
44
+ "license": "AGPL-3.0-only",
45
+ "bugs": {
46
+ "url": "https://github.com/myrosblog/acc-cli/issues"
47
+ },
48
+ "homepage": "https://myrosblog.com/adobe-campaign/acc-cli?utm_campaign=acc-cli"
49
+ }