Skip to content

Commit

Permalink
SITES-28254: Polling tooling enhancements (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
BaDos authored Feb 6, 2025
1 parent 6669d9b commit a494237
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 9 deletions.
8 changes: 6 additions & 2 deletions app.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,14 @@ application:
authToken: ${AEM_ADMIN_API_AUTH_TOKEN}
annotations:
final: true
# parameters:
# COMMERCE_STORE_CODE: "<your_store_code>"
# COMMERCE_STORE_URL: "<your_store_url>"
# COMMERCE_CONFIG_NAME: "<your_config_name>"
# triggers:
# everyMinTrigger:
# feed: /whisk.system/alarms/interval
# inputs:
# inputs:
# minutes: 1
# rules:
# everyMinRule:
Expand All @@ -53,4 +57,4 @@ application:
# # The above means that the actual logic is not
# # necessarily executed every minute.
# trigger: everyMinTrigger
# action: check-product-changes
# action: check-product-changes
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"cheerio": "^1.0.0",
"commander": "^13.1.0",
"handlebars": "^4.7.8",
"js-yaml": "^4.1.0",
"node-fetch": "^2.6.0",
"striptags": "^3.2.0",
"vega": "^5.30.0",
Expand Down
30 changes: 23 additions & 7 deletions tools/check-products-count.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,33 @@ governing permissions and limitations under the License.

require('dotenv').config();

const fs = require('fs');
const yaml = require('js-yaml');
const path = require('path');
const { requestSaaS, requestSpreadsheet } = require('../actions/utils');
const { GetAllSkusPaginatedQuery } = require('../actions/queries');
const filePath = path.resolve(__dirname, '..', 'app.config.yaml');

async function main() {
// TODO: fetch from app.config.yaml (incl. mapped env vars)?
// https://jira.corp.adobe.com/browse/SITES-28254
let storeCodeYaml, storeUrlYaml, configNameYaml;
try {
const fileContents = fs.readFileSync(filePath, 'utf8');
const data = yaml.load(fileContents, 'utf8');
const parameters = data?.application?.runtimeManifest?.packages['aem-commerce-ssg']?.parameters || {};
({
COMMERCE_STORE_CODE: storeCodeYaml,
COMMERCE_STORE_URL: storeUrlYaml,
COMMERCE_CONFIG_NAME: configNameYaml
} = parameters);
} catch (e) {
console.error('Error getting configuration from app.config.yaml file:', e);
}

const {
COMMERCE_STORE_CODE: storeCode,
COMMERCE_STORE_URL: storeUrl,
COMMERCE_CONFIG_NAME: configName,
// eslint-disable-next-line no-undef
COMMERCE_STORE_CODE: storeCode = storeCodeYaml,
COMMERCE_STORE_URL: storeUrl = storeUrlYaml,
COMMERCE_CONFIG_NAME: configName = configNameYaml,
// eslint-disable-next-line no-undef
} = process.env;

const context = { storeCode, storeUrl, configName };
Expand All @@ -40,4 +56,4 @@ async function main() {
}
}

main().catch(console.error);
main().catch(console.error);

0 comments on commit a494237

Please sign in to comment.