From 58ef695de7ed1d1029d62da9f866afe8f0849664 Mon Sep 17 00:00:00 2001 From: Kevin Nennig Date: Tue, 26 Sep 2023 13:41:17 -0400 Subject: [PATCH 01/12] Delete example.config.yml --- example.config.yml | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 example.config.yml diff --git a/example.config.yml b/example.config.yml deleted file mode 100644 index f4fc388..0000000 --- a/example.config.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- -auth: - API_KEY: xxxxxxxxxxxxxxxxxxxxx - CLIENT_SECRET: xxxxxxxxxxxxxxxxxxxxx - ORG_ID: xxxxxxxxxxxxxxxxxxxxx@AdobeOrg - TECHNICAL_ACCOUNT_ID: xxxxxxxxxxxxxxxxxxxxx@techacct.adobe.com - PRIVATE_KEY: ./private.key ---- \ No newline at end of file From 9d3732230e000402e8af9a4b015ab2e6269d0f0f Mon Sep 17 00:00:00 2001 From: Kevin Nennig Date: Tue, 26 Sep 2023 13:41:46 -0400 Subject: [PATCH 02/12] oauth added --- example.oauth.json | 12 ++ index.js | 14 +- launch.js | 65 +++++++-- newman.js | 22 ++- ...obe IO Token OAuth.postman_collection.json | 129 ++++++++++++++++++ .../Adobe IO Token.postman_collection.json | 4 +- .../Delete Properties.postman_collection.json | 6 +- ...xport Tag Property.postman_collection.json | 10 +- ...mport Tag Property.postman_collection.json | 66 ++++----- postman/aep-tag-tool.postman_environment.json | 12 +- 10 files changed, 279 insertions(+), 61 deletions(-) create mode 100644 example.oauth.json create mode 100644 postman/Adobe IO Token OAuth.postman_collection.json diff --git a/example.oauth.json b/example.oauth.json new file mode 100644 index 0000000..fa8d4c7 --- /dev/null +++ b/example.oauth.json @@ -0,0 +1,12 @@ +{ + "ORG_ID": "xxxxxxxxxxxxxxxxxxxxx@AdobeOrg", + "CLIENT_SECRETS": [ "xxxxxxxxxxxxxxxxxxxxx" ], + "CLIENT_ID": "xxxxxxxxxxxxxxxxxxxxx", + "SCOPES": [ + "xxxxxxxxx", + "xxxxxxxxx", + "xxxxxxxxx" + ], + "TECHNICAL_ACCOUNT_ID": "xxxxxxxxxxxxxxxxxxxxx@techacct.adobe.com", + "TECHNICAL_ACCOUNT_EMAIL": "xxxxxxxxxxxxxxxxxxxxx@techacct.adobe.com" +} \ No newline at end of file diff --git a/index.js b/index.js index b4b286f..2495c47 100644 --- a/index.js +++ b/index.js @@ -20,12 +20,16 @@ const modes = { delete: "delete" }; -function init(envParam, modeParam, dataParam, pidParam, workingDirParam, searchStrParam){ +function init(envParam, modeParam, dataParam, pidParam, workingDirParam, searchStrParam, authMethod){ let mode = ""; - if(modeParam && modeParam.toLowerCase() == modes.export || args.export || args.e) mode = modes.export; - if(modeParam && modeParam.toLowerCase() == modes.import || args.import || args.i) mode = modes.import; - if(modeParam && modeParam.toLowerCase() == modes.delete || args.delete || args.d) mode = modes.delete; + if(modeParam?.toLowerCase() == modes.export || args.export || args.e) mode = modes.export; + if(modeParam?.toLowerCase() == modes.import || args.import || args.i) mode = modes.import; + if(modeParam?.toLowerCase() == modes.delete || args.delete || args.d) mode = modes.delete; let argsEnv = envParam || args.config || args.c; + let argsAuth = authMethod?.toLowerCase() || launch.auth.oauth; //default is oauth + if(args.jwt) argsAuth = launch.auth.jwt; + if(args.oauth) argsAuth = launch.auth.oauth; + const argsVersion = args.v || args.version; const argsHelp = args.h || args.help; @@ -65,7 +69,7 @@ function init(envParam, modeParam, dataParam, pidParam, workingDirParam, searchS // aep-tag-tool -c ./myCSV.csv --delete "2023" //create AuthObj from config.yml - let authObj = launch.createAuthObjSync(argsEnv); + let authObj = launch.createAuthObjSync(argsEnv, argsAuth); debugDryRun(JSON.stringify(authObj, null, 2)); if(!authObj) { console.log("Authentication not properly configured. Make sure your config file has the required Auth values."); diff --git a/launch.js b/launch.js index 139b275..cf6f0b1 100644 --- a/launch.js +++ b/launch.js @@ -9,10 +9,23 @@ exports.debugOptions = { "property": "messages related to the property file", "config": "Messages related to config file" }; +const auth = { + jwt: "jwt", + oauth: "oauth" +} const POSTMAN_ENV = require("./postman/aep-tag-tool.postman_environment.json"); -// Returns a Postman Environment json with the correct variables for authentication -function createAuthObjFromConfig(file){ +function createPostmanEnvObjFromConfig(file, authMethod){ + if(authMethod == auth.oauth){ + return createOAuthPostmanEnvObjFromConfig(file, auth.oauth) + } if(authMethod == auth.jwt) { + return createJWTPostmanEnvObjFromConfig(file, auth.jwt) + } + return ""; +} + +// Returns a Postman Environment json with the correct variables for OAuth +function createOAuthPostmanEnvObjFromConfig(file){ let fileContentsAndWorkingDir = createFileObj(file); let fileContentsJSON = getJSONSync(fileContentsAndWorkingDir.contents); if(!fileContentsJSON) return; @@ -22,11 +35,44 @@ function createAuthObjFromConfig(file){ console.log("Looking for auth values in config file..."); let foundValues = {}; - foundValues.API_KEY = findNestedObj(fileContentsJSON,"API_KEY") || findNestedObj(fileContentsJSON,"CLIENT_ID"); + foundValues.CLIENT_ID = findNestedObj(fileContentsJSON,"API_KEY") || findNestedObj(fileContentsJSON,"CLIENT_ID"); + foundValues.CLIENT_SECRETS = findNestedObj(fileContentsJSON,"CLIENT_SECRETS"); + foundValues.ORG_ID = findNestedObj(fileContentsJSON,"ORG_ID") || findNestedObj(fileContentsJSON,"IMS_ORG_ID"); + foundValues.SCOPES = findNestedObj(fileContentsJSON,"SCOPES") + foundValues.AUTH_METHOD = auth.oauth; + + for(let key in foundValues){ + if(foundValues[key]){ + let foundValue = foundValues[key]; + postmanObj = setPostmanEnvironmentValue(postmanObj, key, foundValue); + debugConfig(key + " set."); + authParamCount++; + } else console.error("Could not find " + key); + } + //Verify that all 5 foundValues above are set + if(authParamCount == 5){ + debugConfig(postmanObj); + return postmanObj; + } +} + +// Returns a Postman Environment json with the correct variables for JWT +function createJWTPostmanEnvObjFromConfig(file){ + let fileContentsAndWorkingDir = createFileObj(file); + let fileContentsJSON = getJSONSync(fileContentsAndWorkingDir.contents); + if(!fileContentsJSON) return; + + let postmanObj = POSTMAN_ENV; + let authParamCount = 0; // counter to make sure all auth params are set + + console.log("Looking for auth values in config file..."); + let foundValues = {}; + foundValues.CLIENT_ID = findNestedObj(fileContentsJSON,"API_KEY") || findNestedObj(fileContentsJSON,"CLIENT_ID"); foundValues.CLIENT_SECRET = findNestedObj(fileContentsJSON,"CLIENT_SECRET"); foundValues.ORG_ID = findNestedObj(fileContentsJSON,"ORG_ID") || findNestedObj(fileContentsJSON,"IMS_ORG_ID"); foundValues.TECHNICAL_ACCOUNT_ID = findNestedObj(fileContentsJSON,"TECHNICAL_ACCOUNT_ID") || findNestedObj(fileContentsJSON,"IMS_ORG_ID"); foundValues.PRIVATE_KEY = findNestedObj(fileContentsJSON,"PRIVATE_KEY"); + foundValues.AUTH_METHOD = auth.jwt; for(let key in foundValues){ if(foundValues[key]){ @@ -37,8 +83,8 @@ function createAuthObjFromConfig(file){ authParamCount++; } else console.error("Could not find " + key); } - //Verify that all 5 auth params have been found and set - if(authParamCount == 5){ + //Verify that all 6 foundValues above are set + if(authParamCount == 6){ debugConfig(postmanObj); return postmanObj; } @@ -133,7 +179,7 @@ function findNestedObj(entireObj, keyToFind) { return foundValue; } -//Helper method to either return the absPath or the contents of the file +//Helper method to either return the absPath or the contents of the config file function resolveFileWithContents(val, workingDir, extractContents) { if(typeof val == "string"){ let contents = path.resolve(workingDir,val); @@ -174,7 +220,7 @@ function setPostmanEnvironmentValue(envObj, key, value){ return null; } -//helper method to get the file contents and working directory of the file +//helper method to get the file contents and working directory of the config file // { // contents: // workingDir: @@ -199,7 +245,8 @@ function createFileObj(file){ return obj; } +exports.createAuthObjSync = createPostmanEnvObjFromConfig; exports.setEnvironmentValue = setPostmanEnvironmentValue; -exports.createAuthObjSync = createAuthObjFromConfig; exports.createLaunchObjSync = getWebPropertyFromFile; -exports.getPropertiesFromConfig = getWebPropertiesFromConfig; \ No newline at end of file +exports.getPropertiesFromConfig = getWebPropertiesFromConfig; +exports.auth = auth; \ No newline at end of file diff --git a/newman.js b/newman.js index 42e95fc..a0609e0 100644 --- a/newman.js +++ b/newman.js @@ -13,7 +13,8 @@ exports.debugOptions = { }; let REPORTERS = ["emojitrain", "junit", "html"]; -let IO_COLLECTION = require("./postman/Adobe IO Token.postman_collection.json"); +let IO_OAUTH_COLLECTION = require("./postman/Adobe IO Token OAuth.postman_collection.json"); +let IO_JWT_COLLECTION = require("./postman/Adobe IO Token.postman_collection.json"); let EXPORT_COLLECTION = require("./postman/Export Tag Property.postman_collection.json"); let IMPORT_COLLECTION = require("./postman/Import Tag Property.postman_collection.json"); let DELETE_PROPS = require("./postman/Delete Properties.postman_collection.json"); @@ -21,7 +22,8 @@ let DELETE_PROPS = require("./postman/Delete Properties.postman_collection.json" //Development commands if (debug.enabled("collections")) { debugCollections("Using Postman Collections"); - IO_COLLECTION = "https://www.getpostman.com/collections/6ad99074fc75d564ac8a"; + IO_OAUTH_COLLECTION = "" + IO_JWT_COLLECTION = "https://www.getpostman.com/collections/6ad99074fc75d564ac8a"; IMPORT_COLLECTION = "https://www.getpostman.com/collections/2f3dc4c81eb464c21693"; DELETE_PROPS = "https://www.getpostman.com/collections/357a7d9bea644bfc5b46"; EXPORT_COLLECTION = "https://www.getpostman.com/collections/55520565b0f9933b5cf8"; @@ -140,9 +142,23 @@ function deleteTags(env, searchStr, callback) { // Runs the Adobe IO Token collection function authenicateAIO(environment) { + let auth_method; + for(let i = 0; i < environment.values.length; i++){ + if(environment.values[i].key == "AUTH_METHOD"){ + auth_method = environment.values[i].value + i = environment.values.length; + } + } + + let auth_collection; + if(auth_method == launch.auth.oauth){ + auth_collection = IO_OAUTH_COLLECTION; + } else if(auth_method == launch.auth.jwt){ + auth_collection = IO_JWT_COLLECTION; + } return newmanRun("auth", environment, "", - IO_COLLECTION, "", + auth_collection, "", "", ""); } diff --git a/postman/Adobe IO Token OAuth.postman_collection.json b/postman/Adobe IO Token OAuth.postman_collection.json new file mode 100644 index 0000000..5e8952b --- /dev/null +++ b/postman/Adobe IO Token OAuth.postman_collection.json @@ -0,0 +1,129 @@ +{ + "info": { + "_postman_id": "a29e2e66-1d46-4f76-b9df-327be5c41d2f", + "name": "Adobe IO Token OAuth", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", + "_exporter_id": "17913394" + }, + "item": [ + { + "name": "IMS: OAuth", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "var data = JSON.parse(responseBody);", + "", + "access_token = data.access_token;", + "postman.setEnvironmentVariable(\"ACCESS_TOKEN\", access_token);", + "", + "// console.log(\"Access Token: \" + access_token);", + "", + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + " pm.expect(access_token).to.be.not.empty;", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "warning": "This is a duplicate header and will be overridden by the Content-Type header generated by Postman.", + "key": "Content-Type", + "value": "application/x-www-form-urlencoded", + "type": "text" + } + ], + "body": { + "mode": "formdata", + "formdata": [ + { + "key": "client_id", + "value": "{{CLIENT_ID}}", + "type": "text" + }, + { + "key": "client_secret", + "value": "{{CLIENT_SECRETS}}", + "type": "text" + }, + { + "key": "scope", + "value": "{{SCOPES}}", + "type": "text" + }, + { + "key": "grant_type", + "value": "client_credentials", + "type": "text" + } + ] + }, + "url": { + "raw": "{{IMS}}/ims/token/v3", + "host": [ + "{{IMS}}" + ], + "path": [ + "ims", + "token", + "v3" + ] + }, + "description": "Generate a JWT token using the Crypto RS256\nSend to IMS for access_token" + }, + "response": [] + }, + { + "name": "IMS: Get Profile", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer {{ACCESS_TOKEN}}" + } + ], + "url": { + "raw": "{{IMS}}/ims/profile/v1", + "host": [ + "{{IMS}}" + ], + "path": [ + "ims", + "profile", + "v1" + ] + } + }, + "response": [] + } + ] +} \ No newline at end of file diff --git a/postman/Adobe IO Token.postman_collection.json b/postman/Adobe IO Token.postman_collection.json index d1dac6c..a93edb6 100644 --- a/postman/Adobe IO Token.postman_collection.json +++ b/postman/Adobe IO Token.postman_collection.json @@ -90,7 +90,7 @@ "\t\"exp\": Math.round(87000 + Date.now()/1000),", "\t\"iss\": postman.getEnvironmentVariable(\"ORG_ID\"),", "\t\"sub\": postman.getEnvironmentVariable(\"TECHNICAL_ACCOUNT_ID\"),", - "\t\"aud\": postman.getEnvironmentVariable(\"IMS\")+\"/c/\"+postman.getEnvironmentVariable(\"API_KEY\")", + "\t\"aud\": postman.getEnvironmentVariable(\"IMS\")+\"/c/\"+postman.getEnvironmentVariable(\"CLIENT_ID\")", "};", "", "meta_scopes = postman.getEnvironmentVariable(\"META_SCOPE\")", @@ -128,7 +128,7 @@ "formdata": [ { "key": "client_id", - "value": "{{API_KEY}}", + "value": "{{CLIENT_ID}}", "type": "text" }, { diff --git a/postman/Delete Properties.postman_collection.json b/postman/Delete Properties.postman_collection.json index 88deb2e..25b73e3 100644 --- a/postman/Delete Properties.postman_collection.json +++ b/postman/Delete Properties.postman_collection.json @@ -44,7 +44,7 @@ }, { "key": "x-api-key", - "value": "{{API_KEY}}", + "value": "{{CLIENT_ID}}", "type": "text" }, { @@ -125,7 +125,7 @@ }, { "key": "x-api-key", - "value": "{{API_KEY}}", + "value": "{{CLIENT_ID}}", "type": "text" }, { @@ -217,7 +217,7 @@ }, { "key": "x-api-key", - "value": "{{API_KEY}}", + "value": "{{CLIENT_ID}}", "type": "text" }, { diff --git a/postman/Export Tag Property.postman_collection.json b/postman/Export Tag Property.postman_collection.json index d459ce3..6d484e4 100644 --- a/postman/Export Tag Property.postman_collection.json +++ b/postman/Export Tag Property.postman_collection.json @@ -37,7 +37,7 @@ }, { "key": "x-api-key", - "value": "{{API_KEY}}", + "value": "{{CLIENT_ID}}", "type": "text" }, { @@ -108,7 +108,7 @@ }, { "key": "x-api-key", - "value": "{{API_KEY}}", + "value": "{{CLIENT_ID}}", "type": "text" }, { @@ -180,7 +180,7 @@ }, { "key": "x-api-key", - "value": "{{API_KEY}}", + "value": "{{CLIENT_ID}}", "type": "text" }, { @@ -275,7 +275,7 @@ }, { "key": "x-api-key", - "value": "{{API_KEY}}", + "value": "{{CLIENT_ID}}", "type": "text" }, { @@ -375,7 +375,7 @@ }, { "key": "x-api-key", - "value": "{{API_KEY}}", + "value": "{{CLIENT_ID}}", "type": "text" }, { diff --git a/postman/Import Tag Property.postman_collection.json b/postman/Import Tag Property.postman_collection.json index d3a0177..e36775d 100644 --- a/postman/Import Tag Property.postman_collection.json +++ b/postman/Import Tag Property.postman_collection.json @@ -40,7 +40,7 @@ }, { "key": "x-api-key", - "value": "{{API_KEY}}", + "value": "{{CLIENT_ID}}", "type": "text" }, { @@ -117,7 +117,7 @@ }, { "key": "x-api-key", - "value": "{{API_KEY}}", + "value": "{{CLIENT_ID}}", "type": "text" }, { @@ -185,7 +185,7 @@ }, { "key": "x-api-key", - "value": "{{API_KEY}}", + "value": "{{CLIENT_ID}}", "type": "text" }, { @@ -251,7 +251,7 @@ }, { "key": "x-api-key", - "value": "{{API_KEY}}", + "value": "{{CLIENT_ID}}", "type": "text" }, { @@ -317,7 +317,7 @@ }, { "key": "x-api-key", - "value": "{{API_KEY}}", + "value": "{{CLIENT_ID}}", "type": "text" }, { @@ -383,7 +383,7 @@ }, { "key": "x-api-key", - "value": "{{API_KEY}}", + "value": "{{CLIENT_ID}}", "type": "text" }, { @@ -496,7 +496,7 @@ }, { "key": "x-api-key", - "value": "{{API_KEY}}", + "value": "{{CLIENT_ID}}", "type": "text" }, { @@ -610,7 +610,7 @@ }, { "key": "x-api-key", - "value": "{{API_KEY}}", + "value": "{{CLIENT_ID}}", "type": "text" }, { @@ -716,7 +716,7 @@ }, { "key": "x-api-key", - "value": "{{API_KEY}}", + "value": "{{CLIENT_ID}}", "type": "text" }, { @@ -811,7 +811,7 @@ }, { "key": "x-api-key", - "value": "{{API_KEY}}", + "value": "{{CLIENT_ID}}", "type": "text" }, { @@ -922,7 +922,7 @@ }, { "key": "x-api-key", - "value": "{{API_KEY}}", + "value": "{{CLIENT_ID}}", "type": "text" }, { @@ -994,7 +994,7 @@ }, { "key": "x-api-key", - "value": "{{API_KEY}}", + "value": "{{CLIENT_ID}}", "type": "text" }, { @@ -1078,7 +1078,7 @@ }, { "key": "x-api-key", - "value": "{{API_KEY}}", + "value": "{{CLIENT_ID}}", "type": "text" }, { @@ -1194,7 +1194,7 @@ }, { "key": "x-api-key", - "value": "{{API_KEY}}", + "value": "{{CLIENT_ID}}", "type": "text" }, { @@ -1268,7 +1268,7 @@ }, { "key": "x-api-key", - "value": "{{API_KEY}}", + "value": "{{CLIENT_ID}}", "type": "text" }, { @@ -1342,7 +1342,7 @@ }, { "key": "x-api-key", - "value": "{{API_KEY}}", + "value": "{{CLIENT_ID}}", "type": "text" }, { @@ -1407,7 +1407,7 @@ }, { "key": "x-api-key", - "value": "{{API_KEY}}", + "value": "{{CLIENT_ID}}", "type": "text" }, { @@ -1548,7 +1548,7 @@ }, { "key": "x-api-key", - "value": "{{API_KEY}}", + "value": "{{CLIENT_ID}}", "type": "text" }, { @@ -1634,7 +1634,7 @@ }, { "key": "x-api-key", - "value": "{{API_KEY}}", + "value": "{{CLIENT_ID}}", "type": "text" }, { @@ -1735,7 +1735,7 @@ }, { "key": "x-api-key", - "value": "{{API_KEY}}", + "value": "{{CLIENT_ID}}", "type": "text" }, { @@ -1807,7 +1807,7 @@ }, { "key": "x-api-key", - "value": "{{API_KEY}}", + "value": "{{CLIENT_ID}}", "type": "text" }, { @@ -1879,7 +1879,7 @@ }, { "key": "x-api-key", - "value": "{{API_KEY}}", + "value": "{{CLIENT_ID}}", "type": "text" }, { @@ -1960,7 +1960,7 @@ }, { "key": "x-api-key", - "value": "{{API_KEY}}", + "value": "{{CLIENT_ID}}", "type": "text" }, { @@ -2062,7 +2062,7 @@ }, { "key": "x-api-key", - "value": "{{API_KEY}}", + "value": "{{CLIENT_ID}}", "type": "text" }, { @@ -2136,7 +2136,7 @@ }, { "key": "x-api-key", - "value": "{{API_KEY}}", + "value": "{{CLIENT_ID}}", "type": "text" }, { @@ -2210,7 +2210,7 @@ }, { "key": "x-api-key", - "value": "{{API_KEY}}", + "value": "{{CLIENT_ID}}", "type": "text" }, { @@ -2275,7 +2275,7 @@ }, { "key": "x-api-key", - "value": "{{API_KEY}}", + "value": "{{CLIENT_ID}}", "type": "text" }, { @@ -2416,7 +2416,7 @@ }, { "key": "x-api-key", - "value": "{{API_KEY}}", + "value": "{{CLIENT_ID}}", "type": "text" }, { @@ -2494,7 +2494,7 @@ }, { "key": "x-api-key", - "value": "{{API_KEY}}", + "value": "{{CLIENT_ID}}", "type": "text" }, { @@ -2567,7 +2567,7 @@ }, { "key": "x-api-key", - "value": "{{API_KEY}}", + "value": "{{CLIENT_ID}}", "type": "text" }, { @@ -2639,7 +2639,7 @@ }, { "key": "x-api-key", - "value": "{{API_KEY}}", + "value": "{{CLIENT_ID}}", "type": "text" }, { @@ -2711,7 +2711,7 @@ }, { "key": "x-api-key", - "value": "{{API_KEY}}", + "value": "{{CLIENT_ID}}", "type": "text" }, { @@ -2792,7 +2792,7 @@ }, { "key": "x-api-key", - "value": "{{API_KEY}}", + "value": "{{CLIENT_ID}}", "type": "text" }, { diff --git a/postman/aep-tag-tool.postman_environment.json b/postman/aep-tag-tool.postman_environment.json index 922ee39..d40965d 100644 --- a/postman/aep-tag-tool.postman_environment.json +++ b/postman/aep-tag-tool.postman_environment.json @@ -2,6 +2,11 @@ "id": "e17a0553-73f4-42a7-b06c-c6701956bac3", "name": "aep-tag-tool", "values": [ + { + "key": "AUTH_METHOD", + "value": "", + "enabled": true + }, { "key": "IMS", "value": "https://ims-na1.adobelogin.com", @@ -13,7 +18,7 @@ "enabled": true }, { - "key": "API_KEY", + "key": "CLIENT_ID", "value": "", "enabled": true }, @@ -22,6 +27,11 @@ "value": "", "enabled": true }, + { + "key": "CLIENT_SECRETS", + "value": "", + "enabled": true + }, { "key": "ORG_ID", "value": "", From e1e56dc1086cf5c482c2428f08e35dd2bb1d56bb Mon Sep 17 00:00:00 2001 From: Kevin Nennig Date: Tue, 26 Sep 2023 13:41:52 -0400 Subject: [PATCH 03/12] Update package.json --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 11fdfa6..f212fbc 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,8 @@ "debug": "^4.3.4", "js-yaml": "^4.1.0", "minimist": "^1.2.7", - "newman": "^4.6.1" + "newman": "^4.6.1", + "newman-reporter-html": "latest" }, "devDependencies": { "depcheck": "^1.4.3", From a72e2b7a6e5c8c5f49a08e677a227a2d309a5a37 Mon Sep 17 00:00:00 2001 From: Kevin Nennig Date: Tue, 26 Sep 2023 14:49:13 -0400 Subject: [PATCH 04/12] Update launch.js --- launch.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/launch.js b/launch.js index cf6f0b1..55533c4 100644 --- a/launch.js +++ b/launch.js @@ -1,6 +1,9 @@ const fs = require("fs"); const path = require("path"); const yaml = require("js-yaml"); +//https://www.npmjs.com/package/debug +//Mac: DEBUG=* aep-tag-tool.... +//WIN: set DEBUG=* & aep-tag-tool.... const debugProperty = require("debug")("property"); const debugJSON = require("debug")("json"); const debugConfig = require("debug")("config"); From e8f097755c17fc85109c1dc554df2dd863b42b67 Mon Sep 17 00:00:00 2001 From: Kevin Nennig Date: Tue, 26 Sep 2023 14:49:37 -0400 Subject: [PATCH 05/12] added pid and title params to the propertyObj --- index.js | 49 +++++++++++++++++++++++++++---------------------- newman.js | 8 +++++--- 2 files changed, 32 insertions(+), 25 deletions(-) diff --git a/index.js b/index.js index 2495c47..bd1b8ee 100644 --- a/index.js +++ b/index.js @@ -4,6 +4,8 @@ const packageInfo = require("./package.json"); const minimist = require("minimist"); const args = minimist(process.argv.slice(2)); //https://www.npmjs.com/package/debug +//Mac: DEBUG=* aep-tag-tool.... +//WIN: set DEBUG=* & aep-tag-tool.... const debug = require("debug"); const debugDryRun = require("debug")("dryrun"); const debugArgs = require("debug")("args"); @@ -19,8 +21,8 @@ const modes = { import: "import", delete: "delete" }; - -function init(envParam, modeParam, dataParam, pidParam, workingDirParam, searchStrParam, authMethod){ +//TODO reimplement as a JSON input +function init(envParam, modeParam, dataParam, pidParam, workingDirParam, searchStrParam, titleParam, authMethod){ let mode = ""; if(modeParam?.toLowerCase() == modes.export || args.export || args.e) mode = modes.export; if(modeParam?.toLowerCase() == modes.import || args.import || args.i) mode = modes.import; @@ -30,7 +32,6 @@ function init(envParam, modeParam, dataParam, pidParam, workingDirParam, searchS if(args.jwt) argsAuth = launch.auth.jwt; if(args.oauth) argsAuth = launch.auth.oauth; - const argsVersion = args.v || args.version; const argsHelp = args.h || args.help; @@ -105,7 +106,8 @@ function init(envParam, modeParam, dataParam, pidParam, workingDirParam, searchS }); } } else if(mode == modes.import){ //IMPORT - const importPID = pidParam || args.pid || args.p || ""; + let importPID = pidParam || args.pid || args.p || ""; + let importTitle = titleParam || args.title || args.t || ""; //importFile. --file, -f first priority, --import, -i second priority let propertiesFile = dataParam || args.file || args.f || args.import || args.i; @@ -121,11 +123,16 @@ function init(envParam, modeParam, dataParam, pidParam, workingDirParam, searchS return; // } } else { - propsToImport[propertiesFile] = importPID; + //single property to import + let propertyObj = launch.createLaunchObjSync(propertiesFile); + propertyObj.propertyName = importTitle; + propertyObj.propID = importPID; + propsToImport[propertiesFile] = propertyObj; } - debugDryRun(JSON.stringify(propsToImport,null,2)); - recursiveImport(authObj, propsToImport); + debugDryRun(propsToImport); + + recursiveImport(authObj, propsToImport, importTitle); } else if(mode == modes.delete){ //DELETE //searchStr. --search, -s first priority, --delete, -d second priority @@ -155,37 +162,35 @@ function init(envParam, modeParam, dataParam, pidParam, workingDirParam, searchS } //TODO Recursively importing files results in messages being mixed. Need to review before enabling. -function recursiveImport(authObj, propertyFilesToImport){ +function recursiveImport(authObj, propertyObjsToImport){ //Grab the first file and remove it from propertyFilesToImport - let nextPropertyFile = Object.keys(propertyFilesToImport)[0]; - let nextPID = propertyFilesToImport[nextPropertyFile]; - delete propertyFilesToImport[nextPropertyFile]; + let propertyObj = Object.keys(propertyObjsToImport)[0]; + let propertyFile = Object.values(propertyObjsToImport)[0] + delete propertyObjsToImport[propertyFile]; - if(nextPropertyFile) { - console.log("Importing: " + nextPropertyFile); - - let propertyObj = launch.createLaunchObjSync(nextPropertyFile); + if(propertyObj) { + console.log("Importing: " + propertyObj); if(!propertyObj){ - console.log("Cannot parse or it DNE: " + nextPropertyFile); + console.log("Cannot parse or it DNE: " + propertyFile); console.log("Skipping..."); } else { let actions = newman.getImportActions(args.C, args.E, args.D, args.R, args.L, args.P); - if(!actions.includes("C") && !nextPID){ + if(!actions.includes("C")){ console.log("A PID (-p) is required when importing without creating a new property"); console.log("Skipping.."); } else { if(debug.enabled("dryrun")){ // var f2 = function (k, v) { return k && v && typeof v !== "number" ? "" + v : v; }; - debugDryRun("Importing: " + nextPropertyFile); + debugDryRun("Importing: " + propertyObj); // debugDryRun(JSON.stringify(propertyObj, f2, 2)); - debugDryRun("PID: " + nextPID); + debugDryRun("PID: " + propertyObj.propID); debugDryRun("Actions: " + actions); debugDryRun("Auth: " + authObj); - return recursiveImport(authObj, propertyFilesToImport); + return recursiveImport(authObj, propertyObjsToImport); } else { //TODO decide on global inclusion - return newman.importTag(authObj, propertyObj, actions, nextPID, "") - .then(() => recursiveImport(authObj, propertyFilesToImport)); + return newman.importTag(authObj, propertyObj, actions, "") + .then(() => recursiveImport(authObj, propertyObjsToImport)); } } } diff --git a/newman.js b/newman.js index a0609e0..154a701 100644 --- a/newman.js +++ b/newman.js @@ -2,6 +2,8 @@ const newman = require("newman"); const launch = require("./launch.js"); const fs = require("fs"); //https://www.npmjs.com/package/debug +//Mac: DEBUG=* aep-tag-tool.... +//WIN: set DEBUG=* & aep-tag-tool.... const debug = require("debug"); const debugCollections = require("debug")("collections"); const debugNewman = require("debug")("newman"); @@ -70,15 +72,15 @@ function exportTag(env, pid, exportDir, callback) { .catch(err => callback(err, null)); } -function importTag(env, importObj, actions, pid, globals) { +function importTag(env, importObj, actions, globals) { return new Promise(function(resolve, reject) { authenicateAIO(env) .then(function(resultEnv){ //Add propID if importing to an existing property return new Promise(function (resolve,reject){ if(!actions) actions = getImportActions(); //TODO verify it works if(actions[0] != "C"){ - if(pid){ - let env = launch.setEnvironmentValue(resultEnv, "propID", pid); + if(importObj.propID){ + let env = launch.setEnvironmentValue(resultEnv, "propID", importObj.propID); if(env) resolve(env); else reject(new Error("Cannot update environment")); } else { From 4be7cbdc22604f6714f159aad7f3ba64da996451 Mon Sep 17 00:00:00 2001 From: Kevin Nennig Date: Tue, 26 Sep 2023 14:49:54 -0400 Subject: [PATCH 06/12] docs updated --- message.js | 46 ++++++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/message.js b/message.js index ae850fb..c6c5c49 100644 --- a/message.js +++ b/message.js @@ -5,6 +5,7 @@ const launch = require("./launch.js"); const HELP_config = "-c, --config Specify a config file"; const HELP_F = "-f, --file [import] file containing import json"; +const HELP_T = "-t, --title [import] optional new title of tag property"; const HELP_P = "-p, --pid <pid> [export, import] property ID"; const HELP_S = "-s, --search <str> [delete] search string for properties deletion"; const HELP_O = "-o, --output <folder> [export] folder path to save export property. Default ./"; @@ -21,11 +22,13 @@ const HELP = ` + HELP_delete + ` ` + HELP_CEDRLP + ` ` + HELP_F + ` + ` + HELP_T + ` ` + HELP_P + ` ` + HELP_S + ` ` + HELP_O + ` -g <postman_globals.json> Not supported currently -v, --version Displays version of this package + --jwt Use if using JWT Auth. Deprecated by Adobe. Default is OAuth. -h, --help config export @@ -33,7 +36,19 @@ const HELP = delete debug`; const CONFIGFILE_EXAMPLE = - `Dowload the jwt.json from an Adobe IO Project and add PRIVATE_KEY: + `In your Adobe IO Project under Credentials click the "Download JSON" button + For OAuth credentials, make sure the JSON contains at least: + { + "ORG_ID": "xxxxxxxxxxxxxxxxxxxxx@AdobeOrg", + "CLIENT_SECRETS": [ "xxxxxxxxxxxxxxxxxxxxx" ], + "CLIENT_ID": "xxxxxxxxxxxxxxxxxxxxx", + "SCOPES": [ + "xxxxxxxxx", + "xxxxxxxxx", + "xxxxxxxxx" + ] +} + For JWT credentials, download the private key add PRIVATE_KEY: { "CLIENT_SECRET": "xxxxxxxxxxxxxxxxxxx", "ORG_ID": "xxxxxxxxxxxxxxxxxxx@AdobeOrg", @@ -50,35 +65,16 @@ Alternatively: Create a myconfig.yml and optionally add an import section to import all listed properties with import mode --- auth: - API_KEY: xxxxxxxxxxxxxxxxxxx + CLIENT_ID: xxxxxxxxxxxxxxxxxxx CLIENT_SECRET: xxxxxxxxxxxxxxxxxxx ORG_ID: xxxxxxxxxxxxxxxxxxx@AdobeOrg - TECHNICAL_ACCOUNT_ID: xxxxxxxxxxxxxxxxxxx@techacct.adobe.com - PRIVATE_KEY: location/of/private.key + SCOPES: [xxxxx, xxxxxx, xxxxx] import: ./propertyOne.json: ./propertyTwo.json: Pxxxxxxxxxxxxxxxxxxx ./propertyThree.json: --- `; -const CREATE_PROPERTYFILE = ` -Create myPropertyFile.json - - Option 1: Create the tag property file using the export command: - > `+ packageInfo.name.replace("@knennigtri/", "") + ` -c <configFile> --export <pid> - - Option 2: Manually create with Launch API responses: - { - "propName": "name of property", - "extensions": "./fileOfExtension.json", - "dataElements": "./fileOfDataElements.json", - "rules": { - "rule name one": "./fileOfRule1Components.json", - "rule name two": "./fileOfRule2Components.json", - "rule name three": "./fileOfRule3Compponents.json" - } - } - `; const HELP_EXPORT = `Mode: Export Requires: @@ -99,6 +95,7 @@ Requires: Optionally include the property file with a parameter ` + HELP_F + ` + ` + HELP_T + ` ` + HELP_P + ` Note: PID is ignored unless importing to an existing property (-C is omited) @@ -112,7 +109,9 @@ If -C is not used with the remaining parameters, a PID is required in parameters -R Imports rule components. propertyFile.rules.[rules] is required. -L Builds a library of all items the Dev environment -P Publishes the library into Prod - ` +CREATE_PROPERTYFILE; + +Create the tag property file using the export command: + > `+ packageInfo.name.replace("@knennigtri/", "") + ` -c <configFile> --export <pid>`; const HELP_DELETE = `Mode: Delete Requires: @@ -153,7 +152,6 @@ const HELP_DEBUG = exports.HELP = HELP; exports.CONFIGFILE_EXAMPLE = CONFIGFILE_EXAMPLE; -exports.CREATE_PROPERTYFILE = CREATE_PROPERTYFILE; exports.HELP_EXPORT = HELP_EXPORT; exports.HELP_IMPORT = HELP_IMPORT; exports.HELP_DELETE = HELP_DELETE; From fc4902da2221eea5856e0965969a64fbd1c3b83a Mon Sep 17 00:00:00 2001 From: Kevin Nennig <knennig213@gmail.com> Date: Tue, 26 Sep 2023 15:43:41 -0400 Subject: [PATCH 07/12] lint fix --- launch.js | 8 ++++---- message.js | 4 +++- newman.js | 4 ++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/launch.js b/launch.js index 55533c4..315ffe5 100644 --- a/launch.js +++ b/launch.js @@ -15,14 +15,14 @@ exports.debugOptions = { const auth = { jwt: "jwt", oauth: "oauth" -} +}; const POSTMAN_ENV = require("./postman/aep-tag-tool.postman_environment.json"); function createPostmanEnvObjFromConfig(file, authMethod){ if(authMethod == auth.oauth){ - return createOAuthPostmanEnvObjFromConfig(file, auth.oauth) + return createOAuthPostmanEnvObjFromConfig(file, auth.oauth); } if(authMethod == auth.jwt) { - return createJWTPostmanEnvObjFromConfig(file, auth.jwt) + return createJWTPostmanEnvObjFromConfig(file, auth.jwt); } return ""; } @@ -41,7 +41,7 @@ function createOAuthPostmanEnvObjFromConfig(file){ foundValues.CLIENT_ID = findNestedObj(fileContentsJSON,"API_KEY") || findNestedObj(fileContentsJSON,"CLIENT_ID"); foundValues.CLIENT_SECRETS = findNestedObj(fileContentsJSON,"CLIENT_SECRETS"); foundValues.ORG_ID = findNestedObj(fileContentsJSON,"ORG_ID") || findNestedObj(fileContentsJSON,"IMS_ORG_ID"); - foundValues.SCOPES = findNestedObj(fileContentsJSON,"SCOPES") + foundValues.SCOPES = findNestedObj(fileContentsJSON,"SCOPES"); foundValues.AUTH_METHOD = auth.oauth; for(let key in foundValues){ diff --git a/message.js b/message.js index c6c5c49..9534925 100644 --- a/message.js +++ b/message.js @@ -111,7 +111,9 @@ If -C is not used with the remaining parameters, a PID is required in parameters -P Publishes the library into Prod Create the tag property file using the export command: - > `+ packageInfo.name.replace("@knennigtri/", "") + ` -c <configFile> --export <pid>`; + > + ` + packageInfo.name.replace("@knennigtri/", "") + ` -c <configFile> --export <pid> + `; const HELP_DELETE = `Mode: Delete Requires: diff --git a/newman.js b/newman.js index 154a701..6e62fcd 100644 --- a/newman.js +++ b/newman.js @@ -24,7 +24,7 @@ let DELETE_PROPS = require("./postman/Delete Properties.postman_collection.json" //Development commands if (debug.enabled("collections")) { debugCollections("Using Postman Collections"); - IO_OAUTH_COLLECTION = "" + IO_OAUTH_COLLECTION = ""; IO_JWT_COLLECTION = "https://www.getpostman.com/collections/6ad99074fc75d564ac8a"; IMPORT_COLLECTION = "https://www.getpostman.com/collections/2f3dc4c81eb464c21693"; DELETE_PROPS = "https://www.getpostman.com/collections/357a7d9bea644bfc5b46"; @@ -147,7 +147,7 @@ function authenicateAIO(environment) { let auth_method; for(let i = 0; i < environment.values.length; i++){ if(environment.values[i].key == "AUTH_METHOD"){ - auth_method = environment.values[i].value + auth_method = environment.values[i].value; i = environment.values.length; } } From b0d8e06bc40c7266d3d7cdcf2bf6ca316f7d5e79 Mon Sep 17 00:00:00 2001 From: Kevin Nennig <knennig213@gmail.com> Date: Tue, 26 Sep 2023 15:43:50 -0400 Subject: [PATCH 08/12] recursion bug --- index.js | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/index.js b/index.js index bd1b8ee..7d5a3b2 100644 --- a/index.js +++ b/index.js @@ -132,7 +132,7 @@ function init(envParam, modeParam, dataParam, pidParam, workingDirParam, searchS debugDryRun(propsToImport); - recursiveImport(authObj, propsToImport, importTitle); + recursiveImport(authObj, propsToImport); } else if(mode == modes.delete){ //DELETE //searchStr. --search, -s first priority, --delete, -d second priority @@ -164,13 +164,13 @@ function init(envParam, modeParam, dataParam, pidParam, workingDirParam, searchS //TODO Recursively importing files results in messages being mixed. Need to review before enabling. function recursiveImport(authObj, propertyObjsToImport){ //Grab the first file and remove it from propertyFilesToImport - let propertyObj = Object.keys(propertyObjsToImport)[0]; - let propertyFile = Object.values(propertyObjsToImport)[0] + let propertyFile = Object.keys(propertyObjsToImport)[0]; + let propertyObj = Object.values(propertyObjsToImport)[0]; delete propertyObjsToImport[propertyFile]; - - if(propertyObj) { - console.log("Importing: " + propertyObj); - if(!propertyObj){ + + if(propertyFile) { + console.log("Importing: " + propertyFile); + if(!propertyFile){ console.log("Cannot parse or it DNE: " + propertyFile); console.log("Skipping..."); } else { @@ -180,12 +180,10 @@ function recursiveImport(authObj, propertyObjsToImport){ console.log("Skipping.."); } else { if(debug.enabled("dryrun")){ - // var f2 = function (k, v) { return k && v && typeof v !== "number" ? "" + v : v; }; - debugDryRun("Importing: " + propertyObj); - // debugDryRun(JSON.stringify(propertyObj, f2, 2)); - debugDryRun("PID: " + propertyObj.propID); - debugDryRun("Actions: " + actions); - debugDryRun("Auth: " + authObj); + debugDryRun("Importing: " + propertyFile + "\n" + + "PID: " + propertyObj.propID + "\n" + + "Actions: " + actions + "\n" + + "Auth: " + authObj); return recursiveImport(authObj, propertyObjsToImport); } else { //TODO decide on global inclusion From 146cffe81fe7cb7b664675e1d41981374cf543b6 Mon Sep 17 00:00:00 2001 From: Kevin Nennig <knennig213@gmail.com> Date: Tue, 26 Sep 2023 15:43:53 -0400 Subject: [PATCH 09/12] Update README.md --- README.md | 86 ++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 54 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 5b03d7b..00d8d96 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ This is a project to automates postman collections using the [Reactor API](https - [Export a Tag](#export-a-tag) - [Import a Tag](#import-a-tag) - [CEDRLP params](#cedrlp-params) - - [Import into other Organizations](#import-into-other-organizations) + - [Import into other Adobe Organizations](#import-into-other-adobe-organizations) - [Delete tag properties that contain a specific string](#delete-tag-properties-that-contain-a-specific-string) - [Using this tool without NPM](#using-this-tool-without-npm) - [Postman files](#postman-files) @@ -38,52 +38,68 @@ npm install -g @knennigtri/aep-tag-tool Export a tag property: ```bash - aep-tag-tool -c myconfig.yml --export PR12345678901234567890 + aep-tag-tool -c auth-config.json --export PR12345678901234567890 ``` Import a tag property: ```bash - aep-tag-tool -c myconfig.yml --import myImportData.json + aep-tag-tool -c auth-config.json --import tagPropertyData.json ``` Delete a tag properties that contain 2022 in the title ```bash - aep-tag-tool -c myconfig.yml --delete "2022" + aep-tag-tool -c auth-config.json --delete "2023" ``` ## Create config file for Authentication 1. Create and [Adobe IO project](https://developer.adobe.com/dep/guides/dev-console/create-project/) 1. Add the Experiance Platform Launch API 1. Generate a public/private key pair - 2. Download the public/private key - 2. Go to Service Account (JWT) - 1. In the top right click **Download JSON** - 2. Update downloaded file to `config.json` - 3. Update `config.json` to include the path to the private.key you downloaded earlier. - ```JSON - { - "CLIENT_SECRET": "xxxxxxxxxxxxxxxxxxxxx", - "ORG_ID": "xxxxxxxxxxxxxxxxxxxxx@AdobeOrg", - "API_KEY": "xxxxxxxxxxxxxxxxxxxxx", - "TECHNICAL_ACCOUNT_ID": "xxxxxxxxxxxxxxxxxxxxx@techacct.adobe.com", - "TECHNICAL_ACCOUNT_EMAIL": "xxxxxxxxxxxxxxxxxxxxx@techacct.adobe.com", - "PUBLIC_KEYS_WITH_EXPIRY": {}, - "PRIVATE_Key": "path/to/private.key" - } - ``` + 2. (JWT only) Download the public/private key + 2. Go to the Credentials screen and download the JSON. Adobe has deprecated JWT and OAuth is preferred. + +For OAuth credentials, make sure the JSON contains at least: + +```json +{ + "ORG_ID": "xxxxxxxxxxxxxxxxxxxxx@AdobeOrg", + "CLIENT_SECRETS": [ "xxxxxxxxxxxxxxxxxxxxx" ], + "CLIENT_ID": "xxxxxxxxxxxxxxxxxxxxx", + "SCOPES": [ + "xxxxxxxxx", + "xxxxxxxxx", + "xxxxxxxxx" + ] +} +``` + +For JWT credentials, download the private key add PRIVATE_KEY: + +```json +{ + "CLIENT_SECRET": "xxxxxxxxxxxxxxxxxxxxx", + "ORG_ID": "xxxxxxxxxxxxxxxxxxxxx@AdobeOrg", + "API_KEY": "xxxxxxxxxxxxxxxxxxxxx", + "TECHNICAL_ACCOUNT_ID": "xxxxxxxxxxxxxxxxxxxxx@techacct.adobe.com", + "TECHNICAL_ACCOUNT_EMAIL": "xxxxxxxxxxxxxxxxxxxxx@techacct.adobe.com", + "PUBLIC_KEYS_WITH_EXPIRY": {}, + "PRIVATE_Key": "path/to/private.key" +} +``` Alternatively, you can use yaml as well: + ```yaml --- -API_KEY: xxxxxxxxxxxxxxxxxxx +CLIENT_ID: xxxxxxxxxxxxxxxxxxx CLIENT_SECRET: xxxxxxxxxxxxxxxxxxx ORG_ID: xxxxxxxxxxxxxxxxxxx@AdobeOrg -TECHNICAL_ACCOUNT_ID: xxxxxxxxxxxxxxxxxxx@techacct.adobe.com -PRIVATE_KEY: ./private.key +SCOPES: [xxxxx, xxxxxx, xxxxx] --- ``` ## Usage + ```bash aep-tag-tool -h Usage: aep-tag-tool [ARGS] @@ -94,11 +110,13 @@ Usage: aep-tag-tool [ARGS] -d, --delete <searchStr> Mode to delete properties containing a specific string -C,-E,-D,-R,-L,-P [import] Options to partially import. See -h import -f, --file <file> [import] file containing import json + -t, --title <title> [import] optional new title of tag property; -p, --pid <pid> [export, import] property ID -s, --search <str> [delete] search string for properties deletion -o, --output <folder> [export] folder path to save export property. Default ./ -g <postman_globals.json> Not supported currently -v, --version Displays version of this package + --jwt Use if using JWT Auth. Deprecated by Adobe. Default is OAuth. -h, --help config export @@ -153,6 +171,7 @@ Requires: Optionally include the property file with a parameter ``` -f, --file <file> [import] file containing import json + -t, --title <title> [import] optional new title of tag property; -p, --pid <pid> [export, import] property ID ``` Note: PID is ignored unless importing to an existing property (-C is omited) @@ -180,15 +199,17 @@ If `-C` is not used with the remaining parameters, a PID is required in paramete `-P` Publishes the library into Prod -### Import into other Organizations -1. Create a new [AEP Tag property](https://experienceleague.adobe.com/docs/experience-manager-learn/sites/integrations/experience-platform-launch/create-launch-property.html?lang=en). - 1. Take note of the PID from the URL: Pxxxxxxxxxxxxxxxxxxxxxxx - 2. Manually adding extensions automatically put default values related to your organization. Look at the propertyFile.json you'd like to import and manually install those extension in you new property - 3. The command below will only import Data Elements (-D) and Rules (-R) from the propertyFile.json + +### Import into other Adobe Organizations +1. Export the desired property as specified above +2. In the new Organization, create an Adobe IO project with the Launch API + 1. download the OAuth JSON +3. The command below will only import Extensions (-E), Data Elements (-D) and Rules (-R) from the origPropertyExport.json ``` - aep-tag-tool -c config.json --import propertyFile.json -p <yourPID> -DR + aep-tag-tool -c newOrg-oauth-config.json --import origPropertyExport.json -EDR ``` - 4. Verify the import and build and deploy a new Library +4. Manually update any values unique to the Adobe org. Typically in the Extension values. +5. Verify the import and build and deploy a new Library ## Delete tag properties that contain a specific string Quickly delete web properties that might have been created with this tool. Delete mode allows you to search for web properties in an Adobe organization based on a search string. If any web properties contain the search string, they are deleted. This is particularly useful if you are developing your own property to import/export since all properties end with a timestamp. Searching (-s) for `2022-10-25` would delete `MyProperty 2022-10-25T20:57:42.049Z`, `MyProperty 2022-10-25T21:57:42.049Z`, and `MyProperty 2022-10-25T20:58:42.049Z`. @@ -208,9 +229,10 @@ Optionally include the search string with a parameter The Postman collections apart of this tool can also be used with [Postman](https://www.postman.com/) or [npm newman](https://www.npmjs.com/package/newman). See the [extra docs](docs/README.md) to learn more. ### Postman files -* Download the [Authentication Collection](postman/Adobe%20IO%20Token.postman_collection.json) +* Download the [OAuth Authentication Collection](postman/Adobe%20IO%20Token%20OAuth.postman_collection.json) * Download the [Import Collection](postman/Import%20Tag%20Property.postman_collection.json) * Download the [Export Collection](postman/Export%20Tag%20Property.postman_collection.json) * Download the [Delete Collection](postman/Export%20Tag%20Property.postman_collection.json) * Download a sample [Environment file](postman/aep-tag-tool.postman_environment.json) - * See configuration instructions: [docs/environment.md](docs/environment.md) \ No newline at end of file + * See configuration instructions: [docs/environment.md](docs/environment.md) +* Download the [JWT Authentication Collection](postman/Adobe%20IO%20Token.postman_collection.json) \ No newline at end of file From 1411303a1f167b47252daea63ff8c2a7c5153669 Mon Sep 17 00:00:00 2001 From: Kevin Nennig <knennig213@gmail.com> Date: Tue, 26 Sep 2023 15:57:51 -0400 Subject: [PATCH 10/12] Update README.md --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 00d8d96..2a32a3b 100644 --- a/README.md +++ b/README.md @@ -195,7 +195,7 @@ If `-C` is not used with the remaining parameters, a PID is required in paramete `-R` Imports rule components. `propertyFile.rules.[rules]` is required. - `-L` Builds a library of all items the Dev environment + `-L` Builds a library of all items into the Dev environment `-P` Publishes the library into Prod @@ -204,12 +204,12 @@ If `-C` is not used with the remaining parameters, a PID is required in paramete 1. Export the desired property as specified above 2. In the new Organization, create an Adobe IO project with the Launch API 1. download the OAuth JSON -3. The command below will only import Extensions (-E), Data Elements (-D) and Rules (-R) from the origPropertyExport.json +3. The command below will only import (E)xtensions, (D)ata Elements and (R)ules from the origPropertyExport.json and build a (L)ibrary into the Dev Environment: ``` - aep-tag-tool -c newOrg-oauth-config.json --import origPropertyExport.json -EDR + aep-tag-tool -c newOrg-oauth-config.json --import origPropertyExport.json -EDRL ``` -4. Manually update any values unique to the Adobe org. Typically in the Extension values. -5. Verify the import and build and deploy a new Library +1. Manually update any values unique to the Adobe org. Typically in the Extension values. +2. Verify the import and build and deploy a new Library ## Delete tag properties that contain a specific string Quickly delete web properties that might have been created with this tool. Delete mode allows you to search for web properties in an Adobe organization based on a search string. If any web properties contain the search string, they are deleted. This is particularly useful if you are developing your own property to import/export since all properties end with a timestamp. Searching (-s) for `2022-10-25` would delete `MyProperty 2022-10-25T20:57:42.049Z`, `MyProperty 2022-10-25T21:57:42.049Z`, and `MyProperty 2022-10-25T20:58:42.049Z`. From d02e47a2903f4a58b3f609c9ae02585d5228296b Mon Sep 17 00:00:00 2001 From: Kevin Nennig <knennig213@gmail.com> Date: Tue, 26 Sep 2023 16:32:08 -0400 Subject: [PATCH 11/12] removed dependency requirement --- newman.js | 4 ++-- package.json | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/newman.js b/newman.js index 6e62fcd..4343820 100644 --- a/newman.js +++ b/newman.js @@ -14,7 +14,7 @@ exports.debugOptions = { "newman:cli": "Newman cli output for verbose messaging of collections" }; -let REPORTERS = ["emojitrain", "junit", "html"]; +let REPORTERS = ["emojitrain", "junit"]; let IO_OAUTH_COLLECTION = require("./postman/Adobe IO Token OAuth.postman_collection.json"); let IO_JWT_COLLECTION = require("./postman/Adobe IO Token.postman_collection.json"); let EXPORT_COLLECTION = require("./postman/Export Tag Property.postman_collection.json"); @@ -34,7 +34,7 @@ if (debug.enabled("collections")) { //Mac: DEBUG=newman:cli aep-tag-tool.... //WIN: set DEBUG=newman:cli & aep-tag-tool.... if (debug.enabled("newman:cli")) { - REPORTERS = ["cli", "junit", "html"]; + REPORTERS = ["cli", "junit"]; } let TIMESTAMP = formatDateTime(); diff --git a/package.json b/package.json index f212fbc..11fdfa6 100644 --- a/package.json +++ b/package.json @@ -59,8 +59,7 @@ "debug": "^4.3.4", "js-yaml": "^4.1.0", "minimist": "^1.2.7", - "newman": "^4.6.1", - "newman-reporter-html": "latest" + "newman": "^4.6.1" }, "devDependencies": { "depcheck": "^1.4.3", From 664143da4130472b70725ef1b9e123e773f8ea2e Mon Sep 17 00:00:00 2001 From: Kevin Nennig <knennig213@gmail.com> Date: Tue, 26 Sep 2023 16:32:25 -0400 Subject: [PATCH 12/12] Added OAuth as default --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index b4afd36..5424553 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@knennigtri/aep-tag-tool", - "version": "1.0.0", + "version": "1.1.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@knennigtri/aep-tag-tool", - "version": "1.0.0", + "version": "1.1.0", "license": "ISC", "dependencies": { "debug": "^4.3.4", diff --git a/package.json b/package.json index 11fdfa6..5e99dff 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@knennigtri/aep-tag-tool", - "version": "1.0.0", + "version": "1.1.0", "description": "Export and Import Adobe Experience Platform Tags (previously Launch) with optional variable updates based on Organzations", "repository": { "type": "git",