Skip to content

Commit

Permalink
Update manifester + packager
Browse files Browse the repository at this point in the history
To use the new format where the version number is appended to the file's basename instead of being a folder.
  • Loading branch information
greystate committed Jun 1, 2021
1 parent c0c7067 commit 01fa3eb
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 9 deletions.
21 changes: 20 additions & 1 deletion lib/manifester.xslt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:str="http://exslt.org/strings"
exclude-result-prefixes="str"
>
<xsl:output method="text"
indent="yes"
Expand Down Expand Up @@ -89,6 +91,13 @@
<xsl:if test="not(position() = last())">, </xsl:if>
</xsl:template>

<xsl:template match="*[. = 'true'] | *[. = 'false']" mode="json">
<xsl:value-of select="name()" />
<xsl:text>: </xsl:text>
<xsl:value-of select="." />
<xsl:if test="not(position() = last())">, </xsl:if>
</xsl:template>

<xsl:template match="*[not(text()) and not(*)]" mode="json">
<xsl:value-of select="name()" />
<xsl:text>: ""</xsl:text>
Expand Down Expand Up @@ -128,7 +137,17 @@

<xsl:template match="*" mode="versioned">
<xsl:variable name="pluginpath" select="concat('~/App_Plugins/', $packageAlias, '/')" />
<xsl:value-of select="concat($pluginpath, $version, '/', .)" />
<xsl:variable name="parts" select="str:split(., '.')" />
<xsl:value-of select="$pluginpath" />
<xsl:for-each select="$parts">
<xsl:if test="not(position() = 1) and not(position() = last())">.</xsl:if>
<xsl:if test="not(position() = last())">
<xsl:value-of select="." />
</xsl:if>
<xsl:if test="position() = last()">
<xsl:value-of select="concat('-', $version, '.', .)" />
</xsl:if>
</xsl:for-each>
</xsl:template>

</xsl:stylesheet>
37 changes: 29 additions & 8 deletions lib/packager.xslt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:str="http://exslt.org/strings"
exclude-result-prefixes="str"
>

<xsl:output method="xml"
Expand All @@ -36,9 +38,8 @@
</xsl:copy>
</xsl:template>

<xsl:template match="comment() | processing-instruction()">
<xsl:copy-of select="." />
</xsl:template>
<!-- No output for these -->
<xsl:template match="comment() | processing-instruction()" />

<!-- The `<files>` element has a `@folderPrefix` attribute we don't want to copy -->
<xsl:template match="files">
Expand All @@ -47,13 +48,25 @@
</files>
</xsl:template>

<xsl:template match="file[@path]">
<file>
<guid><xsl:value-of select="@name" /></guid>
<orgPath><xsl:value-of select="@path" /></orgPath>
<orgName><xsl:value-of select="@name" /></orgName>
</file>
</xsl:template>

<xsl:template match="file[@ref]">
<file>
<guid><xsl:value-of select="@ref" /></guid>
<orgPath>
<xsl:apply-templates select="@ref" mode="versioned" />
<xsl:value-of select="concat('/App_Plugins/', $packageAlias)" />
</orgPath>
<orgName><xsl:value-of select="@ref" /></orgName>
<orgName>
<!-- These are mutually exclusive: -->
<xsl:apply-templates select="@ref[../@versioned = 'no']" />
<xsl:apply-templates select="@ref[not(../@versioned = 'no')]" mode="versioned" />
</orgName>
</file>
</xsl:template>

Expand All @@ -67,9 +80,17 @@
</file>
</xsl:template>

<xsl:template match="@*" mode="versioned">
<xsl:value-of select="concat('/App_Plugins/', $packageAlias, '/')" />
<xsl:if test="not(../@versioned = 'no')"><xsl:value-of select="$version" /></xsl:if>
<xsl:template match="@ref" mode="versioned">
<xsl:variable name="parts" select="str:split(., '.')" />
<xsl:for-each select="$parts">
<xsl:if test="not(position() = 1) and not(position() = last())">.</xsl:if>
<xsl:if test="not(position() = last())">
<xsl:value-of select="." />
</xsl:if>
<xsl:if test="position() = last()">
<xsl:value-of select="concat('-', $version, '.', .)" />
</xsl:if>
</xsl:for-each>
</xsl:template>

</xsl:stylesheet>

0 comments on commit 01fa3eb

Please sign in to comment.