Source: site.view [edit]
Function name: createDeploymentConfig
Arguments: fname
Description: Starts from a command and determines all dependent flies.
Page type: webl
Render function:  
Module: siteutil

Page source:

var versions = [. .];
var errs = [ ];

var search = fun(code, bef, aft)
   var res = {};
   var i = 0;
   var c = code;
   while i != -1 do
      i = Str_IndexOf(bef, c);
      if i != -1 then
         c = Select(c, i+Size(bef), Size(c));
         var j = Str_IndexOf(aft,c);
         if j != -1 then
            res = res + {Select(c, 0, j)};
            c = Select(c, j, Size(c))
         end
      end
   end;
   res
end;

  var findAllCodeReferences = fun(code, siteName)

   var res = {};

   res = res + search(code, `WubCall("`, `"`);  

   res = res + search(code, `name="cmdline" value="`, `(`); 
                         
                       
   var fs = search(code, `/site/`, `"`) ? [];  
   every f in fs do
      var i = Str_IndexOf("(", f);
      if i != -1 then
         f = Select(f, 0, i)
      end;
      if (siteName != nil) then
         f = siteName + "." + f
      end;
      res = res + {f}
   end;    
   res
end;
  
  
var findAllDependentVersions = fun(fname, siteName)

   var fi = Wub_GetFunctionInfo(fname) ? nil;
   if fi == nil then
      errs = errs + [fname]
   else
     var fullname = fi.module + "." + fi.name;
  
     if !(fullname member ToList(versions)) then
        versions[fullname] := fi.version;
        if fi.render != "" then
           findAllDependentVersions(fi.render, siteName)
        end;
        every f in ToList(findAllCodeReferences(fi.exec ? "", siteName)) do
           findAllDependentVersions(f, siteName)
        end
     end  
   end
end;
  

var fi = Wub_ParseFunctionIdentifier(fname);
findAllDependentVersions(fname, fi.module);

[. versions=versions, errors=errs .];