Let’s test the script formatting here.
Script Debugger 6 exposes several of the manifest values as properties, allowing you to roll your own manifest report. Here’s an example script to produce a manifest of a document in XML:
use framework "Foundation"
use scripting additions
-- classes, constants, and enums used
property NSXMLDocumentXMLKind : a reference to 0
property NSXMLNodePrettyPrint : a reference to 131072
property NSXMLElement : a reference to current application's NSXMLElement
property NSXMLDocument : a reference to current application's NSXMLDocument
-- get info from SD
tell application id "com.latenightsw.ScriptDebugger6" -- Script Debugger.app
if not (exists document 1) then
beep
display dialog "No document open" buttons {"OK"} default button 1
error number -128
end if
set theResult to compile document 1
if not theResult then
beep
activate
error number -128
end if
set appName to name
set appVersion to version
tell document 1
set docName to name
set docFile to file spec
set appNames to used applications
set additionNames to used scripting additions
set additionFiles to used scripting addition files
set libNames to used script libraries
set libFiles to used script library files
set frameworkNames to used frameworks
set frameworkFiles to used framework files
set embeddedLibs to embedded script libraries
end tell
-- get destination
set theDest to choose file name with prompt "Save Manifest XML report" default name (docName & " manifest.xml")
end tell
-- make root element
set attribs to {creator:appName, |version|:appVersion, |name|:docName}
if docFile is not missing value then set attribs to attribs & {|path|:(POSIX path of docFile)}
set rootElement to NSXMLElement's elementWithName:"manifest"
rootElement's setAttributesWithDictionary:attribs
-- make XML document
set theXMLDocument to NSXMLDocument's alloc()'s initWithRootElement:rootElement
theXMLDocument's setDocumentContentKind:NSXMLDocumentXMLKind
theXMLDocument's setStandalone:true
theXMLDocument's setCharacterEncoding:"UTF-8"
-- build XML
if (count of appNames) > 0 then
set newElement to NSXMLElement's elementWithName:"applications"
rootElement's addChild:newElement
repeat with aName in appNames
set childElement to (NSXMLElement's elementWithName:"application" stringValue:aName)
(newElement's addChild:childElement)
end repeat
end if
if (count of additionNames) > 0 then
set newElement to NSXMLElement's elementWithName:"scripting_additions"
rootElement's addChild:newElement
repeat with i from 1 to count of additionNames
set childElement to (NSXMLElement's elementWithName:"addition" stringValue:(item i of additionNames))
set theFile to item i of additionFiles
if theFile is not missing value then (childElement's setAttributesWithDictionary:{|path|:(POSIX path of theFile)})
(newElement's addChild:childElement)
end repeat
end if
if (count of libNames) > 0 then
set newElement to NSXMLElement's elementWithName:"used_script_libraries"
rootElement's addChild:newElement
repeat with i from 1 to count of libNames
set childElement to (NSXMLElement's elementWithName:"library" stringValue:(item i of libNames))
set theFile to item i of libFiles
if theFile is not missing value then (childElement's setAttributesWithDictionary:{|path|:(POSIX path of theFile)})
(newElement's addChild:childElement)
end repeat
end if
if (embeddedLibs is not missing value and (count of embeddedLibs) > 0) then
set newElement to NSXMLElement's elementWithName:"embedded_script_libraries"
rootElement's addChild:newElement
repeat with aName in embeddedLibs
set childElement to (NSXMLElement's elementWithName:"library" stringValue:aName)
(newElement's addChild:childElement)
end repeat
end if
if (count of frameworkFiles) > 0 then
set newElement to NSXMLElement's elementWithName:"frameworks"
rootElement's addChild:newElement
repeat with i from 1 to count of frameworkNames
set childElement to (NSXMLElement's elementWithName:"framework" stringValue:(item i of frameworkNames))
set theFile to item i of frameworkFiles
if theFile is not missing value then (childElement's setAttributesWithDictionary:{|path|:(POSIX path of theFile)})
(newElement's addChild:childElement)
end repeat
end if
set theNSData to theXMLDocument's XMLDataWithOptions:NSXMLNodePrettyPrint
-- write data to file atomically
set theResult to theNSData's writeToFile:(POSIX path of theDest) atomically:true
beep