New Archival targets to make it easier to deploy

This commit is contained in:
ViViDboarder 2018-01-06 09:04:44 -08:00
parent 70ac28bb2f
commit 99e8034f02
19 changed files with 155 additions and 55 deletions

1
.gitignore vendored
View File

@ -14,5 +14,6 @@ syntax-highlighter.min.css
# External Go dependencies # External Go dependencies
vendor/ vendor/
build/ build/
archive/
.DS_Store .DS_Store
docset-gen docset-gen

View File

@ -7,36 +7,44 @@ all: package-apex package-vf package-lightning
vendor: vendor:
dep ensure dep ensure
docset-gen: vendor
go build -i -x -o docset-gen ./SFDashC/
.PHONY: run-apex .PHONY: run-apex
run-apex: clean-index docset-gen run-apex: clean-index vendor
./docset-gen apexcode go run ./SFDashC/*.go apexcode
.PHONY: run-vf .PHONY: run-vf
run-vf: clean-index docset-gen run-vf: clean-index vendor
./docset-gen pages go run ./SFDashC/*.go pages
.PHONY: run-lightning .PHONY: run-lightning
run-lightning: clean-index docset-gen run-lightning: clean-index vendor
./docset-gen lightning go run ./SFDashC/*.go lightning
.PHONY: package-apex
package-apex: run-apex package-apex: run-apex
./package-docset.sh Apex ./package-docset.sh apexcode
.PHONY: package-vf .PHONY: package-vf
package-vf: run-vf package-vf: run-vf
./package-docset.sh Pages ./package-docset.sh pages
.PHONY: package-lightning .PHONY: package-lightning
package-lightning: run-lightning package-lightning: run-lightning
./package-docset.sh Lightning ./package-docset.sh lightning
.PHONY: archive .PHONY: archive-apex
archive: archive-apex: package-apex
find *.docset -depth 0 | xargs -I '{}' sh -c 'tar --exclude=".DS_Store" -czf "$$(echo {} | sed -e "s/\.[^.]*$$//" -e "s/ /_/").tgz" "{}"' ./archive-docset.sh apexcode
@echo "Archives created!"
.PHONY: archive-vf
archive-vf: package-vf
./archive-docset.sh pages
.PHONY: archive-lightning
archive-lightning: package-lightning
./archive-docset.sh lightning
.PHONY: archive-all
archive-all: archive-apex archive-vf archive-lightning
.PHONY: clean-index .PHONY: clean-index
clean-index: clean-index:
@ -49,10 +57,10 @@ clean-package:
.PHONY: clean-archive .PHONY: clean-archive
clean-archive: clean-archive:
rm -f *.tgz rm -f *.tgz
rm -fr ./archive
.PHONY: clean .PHONY: clean
clean: clean-index clean-package clean-archive clean: clean-index clean-package clean-archive
rm -f docset-gen
.PHONY: clean-build .PHONY: clean-build
clean-build: clean-build:

View File

@ -20,3 +20,4 @@ To Do
----- -----
- [ ] Now that new `ForceCascadeType` is available, some of the entries in `./SFDashC/supportedtypes.go` can be simplified - [ ] Now that new `ForceCascadeType` is available, some of the entries in `./SFDashC/supportedtypes.go` can be simplified
- [ ] Allow archiving of multiple versions and fetching pre-releases

View File

@ -1,19 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleIdentifier</key>
<string>Salesforce</string>
<!-- Displayed in list view -->
<key>CFBundleName</key>
<string>Salesforce</string>
<key>DocSetPlatformFamily</key>
<string>sfdc</string>
<key>isDashDocset</key>
<true/>
<key>dashIndexFilePath</key>
<string>index.htm</string>
<key>DashDocSetFallbackURL</key>
<string>https://developer.salesforce.com/docs/</string>
</dict>
</plist>

View File

@ -167,7 +167,7 @@ func getEntryType(entry TOCEntry, parentType SupportedType) (SupportedType, erro
} }
childType, err := lookupEntryType(entry) childType, err := lookupEntryType(entry)
if err != nil && parentType.CascadeType { if err != nil && parentType.ShouldCascade() {
childType = parentType.CreateChildType() childType = parentType.CreateChildType()
err = nil err = nil
} }

View File

@ -87,7 +87,7 @@ type SupportedType struct {
// Should a namspace be prefixed to the database entry // Should a namspace be prefixed to the database entry
ShowNamespace bool ShowNamespace bool
// Indicates that this just contains other nodes and we don't want to index this node // Indicates that this just contains other nodes and we don't want to index this node
// This is not hereditary // This type will cascade down one level, but IsContainer itself is not hereditary
IsContainer bool IsContainer bool
// Indicates that this and all nodes underneith should be hidden // Indicates that this and all nodes underneith should be hidden
IsHidden bool IsHidden bool
@ -127,6 +127,11 @@ func (suppType SupportedType) matchesID(id string) bool {
return false return false
} }
// ShouldCascade returns if this type should be cascaded down to the child
func (suppType SupportedType) ShouldCascade() bool {
return suppType.ForceCascadeType || suppType.CascadeType || suppType.IsContainer
}
// CreateChildType returns a child type inheriting the current type // CreateChildType returns a child type inheriting the current type
func (suppType SupportedType) CreateChildType() SupportedType { func (suppType SupportedType) CreateChildType() SupportedType {
// Reset values that do not cascade // Reset values that do not cascade

58
archive-docset.sh Executable file
View File

@ -0,0 +1,58 @@
#! /bin/bash
set -e
files_dir=./resources
build_dir=./build
out_dir=.
archive_dir=./archive
deliverable=$1
function get_friendly_name {
local deliverable=$1
local name="$(tr '[:lower:]' '[:upper:]' <<< ${deliverable:0:1})${deliverable:1}"
case "$deliverable" in
"apexcode")
name="Apex"
;;
"pages")
name="Visualforce"
;;
esac
echo $name
}
function get_icon_name {
local icon="cloud-icon"
case "$1" in
"lightning")
icon="bolt-icon"
;;
esac
echo $icon
}
function main {
local name=$(get_friendly_name $deliverable)
local package="$out_dir/Salesforce $name.docset"
local archive_dir="$archive_dir/Salesforce_$name"
local archive="$archive_dir/Salesforce_$name.tgz"
local icon=$(get_icon_name $deliverable)
mkdir -p $archive_dir
# Generate docset.json
version=$(cat $build_dir/$deliverable-version.txt)
cat $files_dir/docset-$deliverable.json | sed s/VERSION/$version/ > $archive_dir/docset.json
# Generated tgz archive
tar --exclude=".DS_Store" -czf "$archive" "$package"
# Copy icons
cp "$files_dir/$icon.png" "$archive_dir/icon.png"
cp "$files_dir/$icon@2x.png" "$archive_dir/icon@2x.png"
# Copy readme
cp "$files_dir/Archive_Readme.md" "$archive_dir/README.md"
echo "Finished archive $archive"
}
main

View File

@ -1,24 +1,57 @@
#! /bin/bash #! /bin/bash
set -e set -e
files_dir=./SFDashC files_dir=./resources
build_dir=./build build_dir=./build
out_dir=.
name=$1 deliverable=$1
deliverable=$(echo $name | tr '[:upper:]' '[:lower:]')
if [ "$deliverable" == "apex" ]; then
deliverable="apexcode"
fi
package="Salesforce $name.docset" function get-friendly-name {
version=$(cat $build_dir/$deliverable-version.txt) local deliverable=$1
local name="$(tr '[:lower:]' '[:upper:]' <<< ${deliverable:0:1})${deliverable:1}"
case "$deliverable" in
"apexcode")
name="Apex"
;;
"pages")
name="Visualforce"
;;
esac
cat $files_dir/docset-$deliverable.json | sed s/VERSION/$version/ > $build_dir/docset-$deliverable.json echo $name
}
function get_icon_name {
local icon="cloud-icon"
case "$1" in
"lightning")
icon="bolt-icon"
;;
esac
echo $icon
}
function main {
local name=$(get-friendly-name $deliverable)
local package="$out_dir/Salesforce $name.docset"
local icon=$(get_icon_name $deliverable)
mkdir -p "$package/Contents/Resources/Documents" mkdir -p "$package/Contents/Resources/Documents"
# Copy all meta HTML
cp -r $build_dir/atlas.en-us.$deliverable.meta "$package/Contents/Resources/Documents/" cp -r $build_dir/atlas.en-us.$deliverable.meta "$package/Contents/Resources/Documents/"
cp $build_dir/*.html "$package/Contents/Resources/Documents/" # Copy HTML and CSS
cp $build_dir/$deliverable.html "$package/Contents/Resources/Documents/"
cp $build_dir/*.css "$package/Contents/Resources/Documents/" cp $build_dir/*.css "$package/Contents/Resources/Documents/"
# Copy plsit
cp $files_dir/Info-$name.plist "$package/Contents/Info.plist" cp $files_dir/Info-$name.plist "$package/Contents/Info.plist"
# Copy index
cp $build_dir/docSet.dsidx "$package/Contents/Resources/" cp $build_dir/docSet.dsidx "$package/Contents/Resources/"
# Copy icons
cp "$files_dir/$icon.png" "$package/icon.png"
cp "$files_dir/$icon@2x.png" "$package/icon@2x.png"
echo "Finished building $package" echo "Finished building $package"
}
main

View File

@ -0,0 +1,13 @@
Salesforce Apex
===============
Created by [ViViDboarder](https://github.com/ViViDboarder)
## Generation
* Clone the repo for [docset-sfdc](https://github.com/ViViDboarder/docset-sfdc)
* Run `make` as described in the readme
## Dependencies
To avoid redundancy, those are listed on the readme for the other repo

BIN
resources/bolt-icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
resources/bolt-icon@2x.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

BIN
resources/cloud-icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

BIN
resources/cloud-icon@2x.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

@ -1,7 +1,7 @@
{ {
"name": "Salesforce Visualforce", "name": "Salesforce Visualforce",
"version": "VERSION", "version": "VERSION",
"archive": "Salesforce_Pages.tgz", "archive": "Salesforce_Visualforce.tgz",
"author": { "author": {
"name": "ViViDboarder", "name": "ViViDboarder",
"link": "https://github.com/ViViDboarder" "link": "https://github.com/ViViDboarder"