@@ -116,8 +116,6 @@ export async function validateSiteNotOnboarded(baseURL, imsOrgId, dataFolder, co
116116 }
117117}
118118
119- /* c8 ignore start */
120-
121119/**
122120 * Publishes a file to admin.hlx.page.
123121 * @param {string } filename - The filename to publish
@@ -169,10 +167,10 @@ async function publishToAdminHlx(filename, outputLocation, log) {
169167 * Copies template files to SharePoint for a new LLMO onboarding.
170168 * @param {string } dataFolder - The data folder name
171169 * @param {object } context - The request context
172- * @param {object } slackContext - Slack context (optional, for Slack operations )
170+ * @param {Function } say - Optional function to send messages (e.g., Slack say function )
173171 * @returns {Promise<void> }
174172 */
175- export async function copyFilesToSharepoint ( dataFolder , context ) {
173+ export async function copyFilesToSharepoint ( dataFolder , context , say = ( ) => { } ) {
176174 const { log, env } = context ;
177175
178176 const sharepointClient = await createSharePointClient ( env ) ;
@@ -189,13 +187,15 @@ export async function copyFilesToSharepoint(dataFolder, context) {
189187 await folder . createFolder ( folderName , base ) ;
190188 } else {
191189 log . warn ( `Warning: Folder ${ dataFolder } already exists. Skipping creation.` ) ;
190+ await say ( `Folder ${ dataFolder } already exists. Skipping creation.` ) ;
192191 }
193192
194193 const queryIndexExists = await newQueryIndex . exists ( ) ;
195194 if ( ! queryIndexExists ) {
196195 await templateQueryIndex . copy ( `/${ dataFolder } /query-index.xlsx` ) ;
197196 } else {
198197 log . warn ( `Warning: Query index at ${ dataFolder } already exists. Skipping creation.` ) ;
198+ await say ( `Query index in ${ dataFolder } already exists. Skipping creation.` ) ;
199199 }
200200
201201 log . debug ( 'Publishing query-index to admin.hlx.page' ) ;
@@ -206,10 +206,10 @@ export async function copyFilesToSharepoint(dataFolder, context) {
206206 * Updates the helix-query.yaml configuration in GitHub.
207207 * @param {string } dataFolder - The data folder name
208208 * @param {object } context - The request context
209- * @param {object } slackContext - Slack context (optional, for Slack operations )
209+ * @param {Function } say - Optional function to send messages (e.g., Slack say function )
210210 * @returns {Promise<void> }
211211 */
212- export async function updateIndexConfig ( dataFolder , context ) {
212+ export async function updateIndexConfig ( dataFolder , context , say = ( ) => { } ) {
213213 const { log, env } = context ;
214214
215215 log . debug ( 'Starting Git modification of helix query config' ) ;
@@ -229,6 +229,7 @@ export async function updateIndexConfig(dataFolder, context) {
229229
230230 if ( content . includes ( dataFolder ) ) {
231231 log . warn ( `Helix query yaml already contains string ${ dataFolder } . Skipping update.` ) ;
232+ await say ( `Helix query yaml already contains string ${ dataFolder } . Skipping GitHub update.` ) ;
232233 return ;
233234 }
234235
@@ -259,10 +260,9 @@ export async function updateIndexConfig(dataFolder, context) {
259260 * @param {object } slackContext - Slack context (optional, for Slack operations)
260261 * @returns {Promise<object> } The organization object
261262 */
262- export async function createOrFindOrganization ( imsOrgId , context , slackContext = null ) {
263+ export async function createOrFindOrganization ( imsOrgId , context , say = ( ) => { } ) {
263264 const { dataAccess, log } = context ;
264265 const { Organization } = dataAccess ;
265- const { say } = slackContext || { say : ( ) => { } } ;
266266
267267 // Check if organization already exists
268268 let organization = await Organization . findByImsOrgId ( imsOrgId ) ;
@@ -317,9 +317,10 @@ export async function createOrFindSite(baseURL, organizationId, context) {
317317 * Creates entitlement and enrollment for LLMO.
318318 * @param {object } site - The site object
319319 * @param {object } context - The request context
320- * @returns {Promise<void> }
320+ * @param {Function } say - Optional function to send messages (e.g., Slack say function)
321+ * @returns {Promise<object> } The entitlement and enrollment objects
321322 */
322- export async function createEntitlementAndEnrollment ( site , context ) {
323+ export async function createEntitlementAndEnrollment ( site , context , say = ( ) => { } ) {
323324 const { log } = context ;
324325
325326 try {
@@ -333,10 +334,22 @@ export async function createEntitlementAndEnrollment(site, context) {
333334 } ;
334335 } catch ( error ) {
335336 log . info ( `Ensuring LLMO entitlement and enrollment failed: ${ error . message } ` ) ;
337+ await say ( '❌ Ensuring LLMO entitlement and enrollment failed' ) ;
336338 throw error ;
337339 }
338340}
339341
342+ export async function enableAudits ( site , context , audits = [ ] ) {
343+ const { dataAccess } = context ;
344+ const { Configuration } = dataAccess ;
345+
346+ const configuration = await Configuration . findLatest ( ) ;
347+ audits . forEach ( ( audit ) => {
348+ configuration . enableHandlerForSite ( audit , site ) ;
349+ } ) ;
350+ await configuration . save ( ) ;
351+ }
352+
340353/**
341354 * Complete LLMO onboarding process.
342355 * @param {object } params - Onboarding parameters
@@ -374,6 +387,12 @@ export async function performLlmoOnboarding(params, context) {
374387 // Update index config
375388 await updateIndexConfig ( dataFolder , context ) ;
376389
390+ // Enable audits
391+ await enableAudits ( site , context , [
392+ 'headings' ,
393+ 'llm-blocked' ,
394+ ] ) ;
395+
377396 // Get current site config
378397 const siteConfig = site . getConfig ( ) ;
379398
@@ -393,4 +412,3 @@ export async function performLlmoOnboarding(params, context) {
393412 message : 'LLMO onboarding completed successfully' ,
394413 } ;
395414}
396- /* c8 ignore end */
0 commit comments