Skip to content

Commit

Permalink
fix: enable imports for sites (#807)
Browse files Browse the repository at this point in the history
Co-authored-by: Giorgia Fiscaletti <[email protected]>
  • Loading branch information
dzehnder and fiscafusca authored Mar 5, 2025
1 parent e0e3d1e commit 8992728
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/support/slack/commands/onboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// todo: prototype - untested
/* c8 ignore start */
import { Site as SiteModel, Organization as OrganizationModel } from '@adobe/spacecat-shared-data-access';
import { Config } from '@adobe/spacecat-shared-data-access/src/models/site/config.js';
import { isValidUrl, isObject, isNonEmptyArray } from '@adobe/spacecat-shared-utils';
import os from 'os';
import path from 'path';
Expand Down Expand Up @@ -178,6 +179,13 @@ function OnboardCommand(context) {
const configuration = await Configuration.findLatest();

const importTypes = Object.keys(profile.imports);
const siteConfig = site.getConfig();
for (const importType of importTypes) {
siteConfig.enableImport(importType);
}

site.setConfig(Config.toDynamoItem(siteConfig));
await site.save();

for (const importType of importTypes) {
/* eslint-disable no-await-in-loop */
Expand All @@ -194,6 +202,8 @@ function OnboardCommand(context) {

reportLine.imports = importTypes.join(',');

log.info(`Enabled the following imports for site ${site.getId()}: ${reportLine.imports}`);

const auditTypes = Object.keys(profile.audits);

auditTypes.forEach((auditType) => {
Expand All @@ -203,6 +213,7 @@ function OnboardCommand(context) {
await configuration.save();

reportLine.audits = auditTypes.join(',');
log.info(`Enabled the following audits for site ${site.getId()}: ${reportLine.audits}`);
} catch (error) {
log.error(error);
reportLine.errors = error.message;
Expand Down Expand Up @@ -271,6 +282,8 @@ function OnboardCommand(context) {
fileStream.write(csvStringifier.stringifyRecords([reportLine]));
}

log.info('All sites were processed and onboarded.');

fileStream.end();

fileStream.on('finish', async () => {
Expand Down

0 comments on commit 8992728

Please sign in to comment.