campaign-cli 0.7.6 → 0.7.8
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 +12 -32
- package/package.json +1 -1
- package/src/CampaignAuth.js +11 -10
- package/src/CampaignInstance.js +10 -1
- package/src/main.js +11 -8
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Save time, reduce risk, and improve code health with `acc`! This CLI tool helps you build on Adobe Campaign Classic platform. It quickly downloads Adobe Campaign **configuration, campaigns and online resources**. You can also use it to automate many common development tasks.
|
|
4
4
|
|
|
5
|
-
Full
|
|
5
|
+
Full documentation available on [Getting started with acc](https://myrosblog.com/adobe-campaign/acc-cli?utm_campaign=readme)
|
|
6
6
|
|
|
7
7
|
## Features
|
|
8
8
|
|
|
@@ -15,21 +15,25 @@ Full article in the blog post [Getting started with acc](https://myrosblog.com/a
|
|
|
15
15
|
|
|
16
16
|
## 🚀 Quick Start
|
|
17
17
|
|
|
18
|
-
###
|
|
18
|
+
### Installation
|
|
19
19
|
|
|
20
20
|
```bash
|
|
21
|
-
|
|
21
|
+
npm install -g campaign-cli
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Usage
|
|
22
25
|
|
|
23
|
-
|
|
26
|
+
```bash
|
|
27
|
+
acc auth init --host https://instance.com --user username --pass --alias staging
|
|
24
28
|
|
|
25
|
-
|
|
29
|
+
acc instance pull --alias staging
|
|
26
30
|
# Downloaded /Administration/Configuration/Form rendering
|
|
27
31
|
# Doanloaded /Administration/Configuration/Dynamic Javascript pages
|
|
28
32
|
```
|
|
29
33
|
|
|
30
34
|
### 🔧 Advanced Configuration
|
|
31
35
|
|
|
32
|
-
[Advanced
|
|
36
|
+
Read the [Advanced Use Cases documentation](https://myrosblog.com/adobe-campaign/acc-cli-use-cases?utm_campaign=readme)
|
|
33
37
|
|
|
34
38
|
## 🤝 Contributing
|
|
35
39
|
|
|
@@ -43,34 +47,10 @@ git clone https://github.com/myrosblog/acc-cli.git && cd acc-cli
|
|
|
43
47
|
npm install && npm test
|
|
44
48
|
```
|
|
45
49
|
|
|
46
|
-
### Project Structure
|
|
47
|
-
|
|
48
|
-
```
|
|
49
|
-
src/
|
|
50
|
-
├── main.js # CLI entry point
|
|
51
|
-
├── CampaignAuth.js # Authentication and instance management
|
|
52
|
-
├── CampaignInstance.js # Data operations (check, pull, download)
|
|
53
|
-
└── CampaignError.js # Custom error handling
|
|
54
|
-
|
|
55
|
-
test/
|
|
56
|
-
├── CampaignAuth.spec.js # Authentication tests
|
|
57
|
-
├── CampaignInstance.spec.js # Data operation tests
|
|
58
|
-
└── CampaignError.spec.js # Error handling tests
|
|
59
|
-
|
|
60
|
-
bin/
|
|
61
|
-
└── acc # Executable wrapper
|
|
62
|
-
|
|
63
|
-
config/
|
|
64
|
-
└── acc.config.json # Default configuration template
|
|
65
|
-
```
|
|
66
|
-
|
|
67
50
|
## Roadmap
|
|
68
51
|
|
|
69
52
|
- `acc instance push`
|
|
70
53
|
|
|
71
|
-
## 🔒 Security
|
|
54
|
+
## 🔒 Architecture & Security
|
|
72
55
|
|
|
73
|
-
|
|
74
|
-
- No credentials are logged or transmitted unnecessarily
|
|
75
|
-
- All network communications use the official ACC JS SDK
|
|
76
|
-
- All sensitive information are trimmed by the official ACC JS SDK (headers `x-security-token` and `x-session-token`, session tokens) via `_removeBetween`
|
|
56
|
+
Read the [Architecture & Security documentation](https://myrosblog.com/adobe-campaign/acc-cli-architecture?utm_campaign=readme).
|
package/package.json
CHANGED
package/src/CampaignAuth.js
CHANGED
|
@@ -19,21 +19,21 @@ class CampaignAuth {
|
|
|
19
19
|
* Creates a new CampaignAuth instance.
|
|
20
20
|
*
|
|
21
21
|
* @param {Object} sdk - ACC JS SDK instance
|
|
22
|
-
* @param {Object}
|
|
23
|
-
* @throws {CampaignError} Throws if SDK or
|
|
22
|
+
* @param {Object} auth - Configstore instance for persistent storage
|
|
23
|
+
* @throws {CampaignError} Throws if SDK or auth parameters are missing
|
|
24
24
|
*
|
|
25
25
|
* @example
|
|
26
|
-
* const auth = new CampaignAuth(sdk,
|
|
26
|
+
* const auth = new CampaignAuth(sdk, auth);
|
|
27
27
|
*/
|
|
28
|
-
constructor(sdk,
|
|
29
|
-
if (!sdk || !
|
|
28
|
+
constructor(sdk, auth) {
|
|
29
|
+
if (!sdk || !auth) {
|
|
30
30
|
throw new CampaignError(
|
|
31
31
|
"SDK and Configstore instances are required to initialize CampaignAuth.",
|
|
32
32
|
);
|
|
33
33
|
}
|
|
34
34
|
this.sdk = sdk;
|
|
35
|
-
this.
|
|
36
|
-
this.instances =
|
|
35
|
+
this.auth = auth;
|
|
36
|
+
this.instances = auth.get(this.INSTANCES_KEY) || {};
|
|
37
37
|
this.instanceIds = Object.keys(this.instances);
|
|
38
38
|
}
|
|
39
39
|
|
|
@@ -69,7 +69,7 @@ class CampaignAuth {
|
|
|
69
69
|
);
|
|
70
70
|
}
|
|
71
71
|
const { alias, host, user, password } = options;
|
|
72
|
-
this.
|
|
72
|
+
this.auth.set(`${this.INSTANCES_KEY}.${alias}`, { host, user, password });
|
|
73
73
|
console.log(`✅ Instance ${alias} added successfully.`);
|
|
74
74
|
return this.login(options);
|
|
75
75
|
}
|
|
@@ -87,7 +87,7 @@ class CampaignAuth {
|
|
|
87
87
|
*/
|
|
88
88
|
async login(options) {
|
|
89
89
|
const { host, user, password } =
|
|
90
|
-
this.
|
|
90
|
+
this.auth.get(`instances.${options.alias}`) || {};
|
|
91
91
|
if (!host || !user || !password) {
|
|
92
92
|
throw new CampaignError(
|
|
93
93
|
`Authentication with alias "${options.alias}" doesn't exist. Use "acc auth list" to see all configured instances.`,
|
|
@@ -117,7 +117,8 @@ class CampaignAuth {
|
|
|
117
117
|
* auth.list(); // Lists all configured instances
|
|
118
118
|
*/
|
|
119
119
|
list() {
|
|
120
|
-
console.log(`📚 Reading ${this.
|
|
120
|
+
console.log(`📚 Reading from authentication file ${this.auth.path} `);
|
|
121
|
+
console.log(`📚 Listing ${this.instanceIds.length} instance(s)`);
|
|
121
122
|
if(this.instanceIds.length === 0) {
|
|
122
123
|
console.log(` No instances configured yet. Use "campaign auth init" to add an instance.`);
|
|
123
124
|
return;
|
package/src/CampaignInstance.js
CHANGED
|
@@ -38,11 +38,12 @@ class CampaignInstance {
|
|
|
38
38
|
* { schemaId: "nms:recipient", filename: "recipient_%name%.xml" }
|
|
39
39
|
* ]});
|
|
40
40
|
*/
|
|
41
|
-
constructor(client, accConfig, options
|
|
41
|
+
constructor(client, accConfig, options) {
|
|
42
42
|
this.client = client;
|
|
43
43
|
this.accConfig = accConfig;
|
|
44
44
|
this.verbose = options.verbose;
|
|
45
45
|
this.downloadPath = options.path;
|
|
46
|
+
this.metadata = options.metadata;
|
|
46
47
|
/**
|
|
47
48
|
* Array of schema names to process (excluding default config)
|
|
48
49
|
* @type {string[]}
|
|
@@ -99,6 +100,14 @@ class CampaignInstance {
|
|
|
99
100
|
);
|
|
100
101
|
|
|
101
102
|
for (const schemaConfig of this.accConfig.schemas) {
|
|
103
|
+
// skip if metadata option was included and not matching
|
|
104
|
+
if (this.metadata && !this.metadata.includes(schemaConfig.schemaId)) {
|
|
105
|
+
if (this.verbose) {
|
|
106
|
+
this.log(`Skipping ${schemaConfig.schemaId}`);
|
|
107
|
+
}
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
// downalod and parse
|
|
102
111
|
const lineCount = schemaConfig.queryDef?.lineCount || 10;
|
|
103
112
|
let startLine = 1;
|
|
104
113
|
let recordsLengthTotal = 0;
|
package/src/main.js
CHANGED
|
@@ -22,17 +22,16 @@ const defaultConfigPath = path.join(process.cwd(), "acc.config.json"); // defaul
|
|
|
22
22
|
|
|
23
23
|
const vAcc = packageJson.version;
|
|
24
24
|
const vSdk = sdk.getSDKVersion().version;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
console.log(`🏠 acc ${vAcc} initialized with @adobe/acc-js-sdk ${vSdk}`);
|
|
26
|
+
// blog post tracking
|
|
27
|
+
const homepage = packageJson.homepage.replace(
|
|
28
|
+
"utm_campaign=package-json",
|
|
29
|
+
"utm_campaign=acc-cli",
|
|
28
30
|
);
|
|
29
|
-
const homepage = packageJson.homepage.replace('utm_campaign=package-json', 'utm_campaign=acc-cli')
|
|
30
31
|
|
|
31
32
|
program
|
|
32
33
|
.name("acc")
|
|
33
|
-
.description(
|
|
34
|
-
`${packageJson.description}. Documentation on ${homepage}`,
|
|
35
|
-
)
|
|
34
|
+
.description(`${packageJson.description}. Documentation on ${homepage}`)
|
|
36
35
|
.version(vAcc);
|
|
37
36
|
|
|
38
37
|
// AUTH
|
|
@@ -51,7 +50,7 @@ program
|
|
|
51
50
|
"URL of Adobe Campaign root, e.g. http://localhost:8080",
|
|
52
51
|
)
|
|
53
52
|
.requiredOption("--user <user>", "Operator username")
|
|
54
|
-
.requiredOption("--
|
|
53
|
+
.requiredOption("--pass <pwd>", "Operator password")
|
|
55
54
|
.action(async (options) => {
|
|
56
55
|
try {
|
|
57
56
|
await auth.init(options);
|
|
@@ -118,6 +117,10 @@ program
|
|
|
118
117
|
"Path to the configuration file. Defaults ./config/acc.config.json.",
|
|
119
118
|
defaultConfigPath,
|
|
120
119
|
)
|
|
120
|
+
.option(
|
|
121
|
+
"--metadata <schemasIds>",
|
|
122
|
+
"Comma-separated list of schema ids to retrieve, e.g. nms:delivery,nms:operation",
|
|
123
|
+
)
|
|
121
124
|
.option(
|
|
122
125
|
"--verbose",
|
|
123
126
|
"Verbose output with details on each configuration item. Defaults to false.",
|