Create build dir to reduce mess

This commit is contained in:
ViViDboarder 2017-07-15 14:24:10 -07:00
parent 0be33639b0
commit 7aae9915f0
7 changed files with 75 additions and 39 deletions

1
.gitignore vendored
View File

@ -13,3 +13,4 @@ syntax-highlighter.min.css
*.tgz
# External Go dependencies
vendor/
build/

View File

@ -19,36 +19,38 @@ run-combined: clean-index
package-apex: run-apex
$(eval name = Apex)
$(eval package = Salesforce $(name).docset)
$(eval version = $(shell cat SFDashC/apexcode-version.txt))
$(eval version = $(shell cat ./build/apexcode-version.txt))
cat ./SFDashC/docset-apexcode.json | sed s/VERSION/$(version)/ > ./build/docset-apexcode.json
mkdir -p "$(package)/Contents/Resources/Documents"
cp -r SFDashC/atlas.en-us.apexcode.meta "$(package)/Contents/Resources/Documents/"
cp SFDashC/*.html "$(package)/Contents/Resources/Documents/"
cp SFDashC/*.css "$(package)/Contents/Resources/Documents/"
cp SFDashC/Info-$(name).plist "$(package)/Contents/Info.plist"
cp SFDashC/docSet.dsidx "$(package)/Contents/Resources/"
cp -r ./build/atlas.en-us.apexcode.meta "$(package)/Contents/Resources/Documents/"
cp ./build/*.html "$(package)/Contents/Resources/Documents/"
cp ./build/*.css "$(package)/Contents/Resources/Documents/"
cp ./SFDashC/Info-$(name).plist "$(package)/Contents/Info.plist"
cp ./build/docSet.dsidx "$(package)/Contents/Resources/"
@echo "Docset generated!"
package-vf: run-vf
$(eval name = Pages)
$(eval package = Salesforce $(name).docset)
$(eval version = $(shell cat SFDashC/pages-version.txt))
$(eval version = $(shell cat ./build/pages-version.txt))
cat ./SFDashC/docset-pages.json | sed s/VERSION/$(version)/ > ./build/docset-pages.json
mkdir -p "$(package)/Contents/Resources/Documents"
cp -r SFDashC/atlas.en-us.pages.meta "$(package)/Contents/Resources/Documents/"
cp SFDashC/*.html "$(package)/Contents/Resources/Documents/"
cp SFDashC/*.css "$(package)/Contents/Resources/Documents/"
cp SFDashC/Info-$(name).plist "$(package)/Contents/Info.plist"
cp SFDashC/docSet.dsidx "$(package)/Contents/Resources/"
cp -r ./build/atlas.en-us.pages.meta "$(package)/Contents/Resources/Documents/"
cp ./build/*.html "$(package)/Contents/Resources/Documents/"
cp ./build/*.css "$(package)/Contents/Resources/Documents/"
cp ./SFDashC/Info-$(name).plist "$(package)/Contents/Info.plist"
cp ./build/docSet.dsidx "$(package)/Contents/Resources/"
@echo "Docset generated!"
package-combined: run-combined
$(eval name = Combined)
$(eval package = Salesforce $(name).docset)
mkdir -p "$(package)/Contents/Resources/Documents"
cp -r SFDashC/*.meta "$(package)/Contents/Resources/Documents/"
cp SFDashC/*.html "$(package)/Contents/Resources/Documents/"
cp SFDashC/*.css "$(package)/Contents/Resources/Documents/"
cp SFDashC/Info-$(name).plist "$(package)/Contents/Info.plist"
cp SFDashC/docSet.dsidx "$(package)/Contents/Resources/"
cp -r ./build/*.meta "$(package)/Contents/Resources/Documents/"
cp ./build/*.html "$(package)/Contents/Resources/Documents/"
cp ./build/*.css "$(package)/Contents/Resources/Documents/"
cp ./SFDashC/Info-$(name).plist "$(package)/Contents/Info.plist"
cp ./build/docSet.dsidx "$(package)/Contents/Resources/"
@echo "Docset generated!"
archive:
@ -56,10 +58,9 @@ archive:
@echo "Archives created!"
clean-index:
rm -f SFDashC/docSet.dsidx
rm -f ./build/docSet.dsidx
clean: clean-index
rm -fr SFDashC/*.meta
rm -fr ./build
rm -fr *.docset
rm -f SFDashC/*.css
rm -f *.tgz

View File

@ -4,12 +4,19 @@ import (
"database/sql"
"github.com/coopernurse/gorp"
_ "github.com/mattn/go-sqlite3"
"os"
"path/filepath"
)
var dbmap *gorp.DbMap
var dbName = "docSet.dsidx"
func InitDb() *gorp.DbMap {
db, err := sql.Open("sqlite3", "docSet.dsidx")
func InitDb(buildDir string) *gorp.DbMap {
dbPath := filepath.Join(buildDir, dbName)
err := os.MkdirAll(filepath.Dir(dbPath), 0755)
ExitIfError(err)
db, err := sql.Open("sqlite3", dbPath)
ExitIfError(err)
dbmap := &gorp.DbMap{Db: db, Dialect: gorp.SqliteDialect{}}

View File

@ -0,0 +1,15 @@
{
"name": "Salesforce Apex",
"version": "VERSION",
"archive": "Salesforce_Apex.tgz",
"author": {
"name": "ViViDboarder",
"link": "https://github.com/ViViDboarder"
},
"aliases": [
"apex",
"salesforce",
"sfdc"
],
"specific_versions": []
}

15
SFDashC/docset-pages.json Normal file
View File

@ -0,0 +1,15 @@
{
"name": "Salesforce Visualforce",
"version": "VERSION",
"archive": "Salesforce_Pages.tgz",
"author": {
"name": "ViViDboarder",
"link": "https://github.com/ViViDboarder"
},
"aliases": [
"visualforce",
"salesforce",
"sfdc"
],
"specific_versions": []
}

View File

@ -1,5 +0,0 @@
<html>
<body>
This is a joint docset
</body>
</html>

View File

@ -13,8 +13,9 @@ import (
)
// CSS Paths
var cssBasePath = "https://developer.salesforce.com/resource/stylesheets"
var cssBaseURL = "https://developer.salesforce.com/resource/stylesheets"
var cssFiles = []string{"holygrail.min.css", "docs.min.css", "syntax-highlighter.min.css"}
var buildDir = "build"
var wg sync.WaitGroup
var throttle = make(chan int, maxConcurrency)
@ -70,6 +71,8 @@ func printSuccess(toc *AtlasTOC) {
func saveMainContent(toc *AtlasTOC) {
filePath := fmt.Sprintf("%s.html", toc.Deliverable)
// Prepend build dir
filePath = filepath.Join(buildDir, filePath)
// Make sure file doesn't exist first
if _, err := os.Stat(filePath); os.IsNotExist(err) {
content := toc.Content
@ -93,6 +96,8 @@ func saveMainContent(toc *AtlasTOC) {
func saveContentVersion(toc *AtlasTOC) {
filePath := fmt.Sprintf("%s-version.txt", toc.Deliverable)
// Prepend build dir
filePath = filepath.Join(buildDir, filePath)
err := os.MkdirAll(filepath.Dir(filePath), 0755)
ExitIfError(err)
@ -118,7 +123,7 @@ func main() {
}
// Init the Sqlite db
dbmap = InitDb()
dbmap = InitDb(buildDir)
err := dbmap.TruncateTables()
ExitIfError(err)
@ -132,12 +137,6 @@ func main() {
saveContentVersion(toc)
// Download each entry
/*
* topLevelEntryIDs := map[string]bool{
* "apex_dev_guide": true,
* "pages_compref": true,
* }
*/
for _, entry := range toc.TOCEntries {
processChildReferences(entry, nil, toc)
}
@ -203,6 +202,8 @@ func downloadContent(entry TOCEntry, toc *AtlasTOC, wg *sync.WaitGroup) {
defer wg.Done()
filePath := entry.GetContentFilepath(toc, true)
// Prepend build dir
filePath = filepath.Join(buildDir, filePath)
// Make sure file doesn't exist first
if _, err := os.Stat(filePath); os.IsNotExist(err) {
content, err := entry.GetContent(toc)
@ -235,15 +236,16 @@ func downloadContent(entry TOCEntry, toc *AtlasTOC, wg *sync.WaitGroup) {
func downloadCSS(fileName string, wg *sync.WaitGroup) {
defer wg.Done()
if _, err := os.Stat(fileName); os.IsNotExist(err) {
err = os.MkdirAll(filepath.Dir(fileName), 0755)
filePath := filepath.Join(buildDir, fileName)
if _, err := os.Stat(filePath); os.IsNotExist(err) {
err = os.MkdirAll(filepath.Dir(filePath), 0755)
ExitIfError(err)
ofile, err := os.Create(fileName)
ofile, err := os.Create(filePath)
ExitIfError(err)
defer ofile.Close()
cssURL := cssBasePath + "/" + fileName
cssURL := cssBaseURL + "/" + fileName
response, err := http.Get(cssURL)
ExitIfError(err)
defer response.Body.Close()