@@ -4,9 +4,10 @@ const cheerio = require('cheerio')
44const LDP = require ( '../../lib/ldp' )
55const { URL } = require ( 'url' )
66const debug = require ( '../../lib/debug' )
7+ const { readFile } = require ( '../../lib/common/fs-utils' )
78
89const { compileTemplate, writeTemplate } = require ( '../../lib/common/template-utils' )
9- const { getAccountManager , loadConfig, loadUsernames } = require ( './cli-utils' )
10+ const { loadConfig, loadAccounts } = require ( './cli-utils' )
1011const { getName, getWebId } = require ( '../../lib/common/user-utils' )
1112const { initConfigDir, initTemplateDirs } = require ( '../../lib/server-config' )
1213
@@ -21,21 +22,20 @@ module.exports = function (program) {
2122 const indexTemplatePath = path . join ( templates . account , 'index.html' )
2223 const indexTemplate = await compileTemplate ( indexTemplatePath )
2324 const ldp = new LDP ( config )
24- const accountManager = getAccountManager ( config , { ldp } )
25- const usernames = loadUsernames ( config )
26- const usersProcessed = usernames . map ( async username => {
27- const accountDirectory = accountManager . accountDirFor ( username )
28- const indexFilePath = path . join ( accountDirectory , 'index.html' )
25+ const accounts = loadAccounts ( config )
26+ const usersProcessed = accounts . map ( async account => {
27+ const accountDirectory = path . join ( config . root , account )
28+ const indexFilePath = path . join ( accountDirectory , '/index.html' )
2929 if ( ! isUpdateAllowed ( indexFilePath ) ) {
3030 return
3131 }
32- const accountUrl = getAccountUrl ( username , config )
32+ const accountUrl = getAccountUrl ( account , config )
3333 try {
34- const webId = await getWebId ( accountDirectory , accountUrl , { ldp } )
35- const name = await getName ( webId , { ldp } )
34+ const webId = await getWebId ( accountDirectory , accountUrl , ldp . suffixMeta , ( filePath ) => readFile ( filePath ) )
35+ const name = await getName ( webId , ldp . fetchGraph )
3636 writeTemplate ( indexFilePath , indexTemplate , { name, webId } )
3737 } catch ( err ) {
38- debug . errors ( `Failed to create new index for ${ username } : ${ JSON . stringify ( err , null , 2 ) } ` )
38+ debug . errors ( `Failed to create new index for ${ account } : ${ JSON . stringify ( err , null , 2 ) } ` )
3939 }
4040 } )
4141 await Promise . all ( usersProcessed )
0 commit comments