Skip to content

Commit

Permalink
builder and sidecar updates (#88)
Browse files Browse the repository at this point in the history
Co-authored-by: feederbox826 <[email protected]>
Co-authored-by: DogmaDragon <[email protected]>
  • Loading branch information
3 people authored Nov 27, 2024
1 parent aa39a08 commit 3511460
Show file tree
Hide file tree
Showing 29 changed files with 254 additions and 610 deletions.
21 changes: 0 additions & 21 deletions builder/LICENSE

This file was deleted.

42 changes: 33 additions & 9 deletions builder/build.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import axios from 'axios'
import YAML from 'yaml'
import fs from 'fs'
import path from 'path'
import * as fs from 'fs';
import * as path from 'path';

import { LocalCollection, LocalRepository, LocalSidecar, RemoteIndex } from './types'
import { LocalCollection, LocalRepository, LocalSidecar, RemoteIndex, RemotePlugin } from './types'
import { Plugin } from './plugin'
import { infoLog, warnLog } from './utils'
import { debuglog } from 'util';

// iterate over folder
async function searchRepository(pathName: string = "plugins"): Promise<Plugin[]> {
Expand All @@ -18,6 +19,8 @@ async function searchRepository(pathName: string = "plugins"): Promise<Plugin[]>
if (file.endsWith(".yml")) {
const fileData = fs.readFileSync(`${repoPath}/${file}`, 'utf8')
const localRepo: LocalRepository = YAML.parse(fileData)
// set name to filename if not defined
if (!localRepo.name) localRepo.name = file.replace(".yml", "")
repositories.push(localRepo)
}
})
Expand All @@ -27,13 +30,19 @@ async function searchRepository(pathName: string = "plugins"): Promise<Plugin[]>
const plugin = await parseRepository(repo)
plugins.push(...plugin)
}
// fetch all readmes of plugins
const readmePromises = plugins.map(plugin => plugin.checkReadme())
await Promise.all(readmePromises)
// sort plugins and print to md
const sortedPlugins = plugins
.sort((a, b) => a.name.toLowerCase().localeCompare(b.name.toLowerCase()))
return sortedPlugins
}

function printPlugins(outputName: string, sortedPlugins: Plugin[]) {
// create folder if not exists
if (!fs.existsSync(`./dist`)) fs.mkdirSync(`./dist`)
if (!fs.existsSync(`./dist/${outputName}`)) fs.mkdirSync(`./dist/${outputName}`)
// print to file
const outputPath = `./dist/${outputName}/list.md`
const stream = fs.createWriteStream(outputPath)
Expand All @@ -55,23 +64,37 @@ async function parseRepository(localRepository: LocalRepository): Promise<Plugin
.then(res => YAML.parse(res.data))
// iterate over remote index and match with sidecars
const indexPlugins: Plugin[] = []
const idxMissingScar: Set<RemotePlugin> = new Set()
const allIdx: Set<RemotePlugin> = new Set()
for (const index of indexData) {
const sidecarMatch = repoSidecars.find(sidecar => sidecar.id == index.id)
if (sidecarMatch?.hide) {
// skip if hidden, but warn
infoLog(`Skipping hidden plugin: ${index.name}`)
continue
if (sidecarMatch) {
if (sidecarMatch.id == "example") continue // if example, skip
else if (sidecarMatch.hide) { // skip but warn if hidden
debuglog(`Skipping hidden plugin: ${index.name}`)
continue
} else allIdx.add(index) // add to sidecars
} else { // sidecar not found
if (repoDefaults.exclusive) continue // if exclusive, skip
idxMissingScar.add(index) // add to missing
}
if (repoDefaults.exclusive && !sidecarMatch) continue // if exclusive, skip if no sidecar
const plugin = new Plugin(repoDefaults, sidecarMatch, index)
indexPlugins.push(plugin)
}
// check if there are leftover sidecars
const extraSidecars = repoSidecars.filter(sidecar => !indexPlugins.find(plugin => plugin.id == sidecar.id && !sidecar.hide))
// not named example
// not in indexPlugins and not hidden
const extraSidecars = repoSidecars.filter(sidecar => sidecar.id != "example" && !sidecar.hide && !indexPlugins.find(plugin => plugin.id == sidecar.id))
if (extraSidecars.length > 0) {
warnLog(`Found ${extraSidecars.length} extra sidecars in ${localRepository.name}`)
extraSidecars.forEach(sidecar => warnLog(` ${sidecar.id}`))
}
// check for plugins without sidecars
const missingSCars = Array.from(idxMissingScar).filter(plugin => allIdx.has(plugin))
if (missingSCars.length > 0) {
infoLog(`Found ${missingSCars.length} missing sidecars in ${localRepository.name}`)
missingSCars.forEach(sidecar => infoLog(` ${sidecar.name}`))
}
return indexPlugins
}

Expand All @@ -84,6 +107,7 @@ async function run() {
// remove themes from plugins
const filteredPlugins = plugins.filter(plugin => !themes.some(theme => theme.id == plugin.id))
printPlugins("plugins", filteredPlugins)
console.log("finished building plugin index")
}

run()
13 changes: 12 additions & 1 deletion builder/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as utils from './utils'
import { LocalCollection, LocalSidecar, RemotePlugin } from './types'
import axios from 'axios'

export class Plugin {
id: string // internal id of plugin
Expand Down Expand Up @@ -28,11 +29,21 @@ export class Plugin {
this.path = sidecar?.path
?? index.id // default to ID
this.screenshots = sidecar?.screenshots ?? []
this.readme = sidecar?.readme ?? true // readme file
this.readme = defaults?.global_readme ?? sidecar?.readme // readme file
this.base_path = defaults.base_path ?? "main/plugins"
this.repo_path = `${this.base_path}/${this.path}`
}

async checkReadme(): Promise<void> {
// test readme if undefined
if (this.readme === undefined) {
this.readme = await axios.head(`https://github.com/${this.repo}/blob/${this.repo_path}/README.md`, {
validateStatus: status => status == 200 || status == 404
})
.then(res => res.status == 200)
}
}

printMD() {
// pre prepared values
const folderPath = `https://github.com/${this.repo}/tree/${this.repo_path}`
Expand Down
37 changes: 37 additions & 0 deletions builder/repositories/example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Repository name
collection:
# index url for your repo
index: https://ghost.github.io/stash-plugins/main/index.yml
# github url of the repo - github.com/username/repo-name
global_repo: ghost/stash-plugins
# author of all plugins in the repo (OPTIONAL)
global_author: "[ghost](https://github.com/ghost)"
# link to readme if it applies to all scripts within the collection
global_readme: "https://example.com/stash-plugins/README.md"
# branch/path within the folder structure
base_path: main/plugins
# entries not in the sidecar are excluded
exclusive: true

scripts:
# internal id of the plugin
id: my-first-stash-plugin
# path if it is not at base_path/id
path: CoolPlugin
# description (OPTIONAL)
description: My first plugin
# readme, if not at base_path/id/README.md
# if left empty, will try to search at the location
readme: "https://example.com/stash-plugins/README.md"
# override author from global_author
author: "Ghost, Casper"
# list of links to images of screenshots
screenshots:
- https://example.com/stash-plugins/CoolPlugin/demo.png
- https://example.com/stash-plugins/CoolPlugin/usage.png
- https://example.com/stash-plugins/CoolPlugin/settings.png
# if plugin should be hidden from generate index
# this should only be set if the plugin is a backend dependency
# is in a completely broken state and wholly incompatible
# or has been deprecated and should not be used
hide: true
35 changes: 8 additions & 27 deletions builder/repositories/plugins/7djx1qp-stash-plugins.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,134 +13,115 @@ scripts:
screenshots:
- https://avatars.githubusercontent.com/u/10137

# id only
- id: stashOpenMediaPlayer

# dependencies
- id: stashUserscriptLibrary7dJx1qP
hide: true

# screenshots
- id: stashBatchQueryEdit
readme: false
screenshots:
- https://raw.githubusercontent.com/7dJx1qP/stash-plugins/main/images/Stash%20Batch%20Query%20Edit/config.png
- https://raw.githubusercontent.com/7dJx1qP/stash-plugins/main/images/Stash%20Batch%20Query%20Edit/scenes-tagger.png

- id: stashBatchResultToggle
readme: false
screenshots:
- https://raw.githubusercontent.com/7dJx1qP/stash-plugins/main/images/Stash%20Batch%20Result%20Toggle/config.png
- https://raw.githubusercontent.com/7dJx1qP/stash-plugins/main/images/Stash%20Batch%20Result%20Toggle/scenes-tagger.png

- id: stashBatchSave
readme: false
screenshots:
- https://raw.githubusercontent.com/7dJx1qP/stash-plugins/main/images/Stash%20Batch%20Save/scenes-tagger.png

- id: stashBatchSearch
readme: false
screenshots:
- https://raw.githubusercontent.com/7dJx1qP/stash-plugins/main/images/Stash%20Batch%20Search/scenes-tagger.png

- id: stashMarkdown
readme: false
screenshots:
- https://raw.githubusercontent.com/7dJx1qP/stash-plugins/main/images/Stash%20Markdown/tag-description.png

- id: stashMarkersAutoscroll
readme: false
screenshots:
- https://raw.githubusercontent.com/7dJx1qP/stash-plugins/main/images/Stash%20Markers%20Autoscroll/scroll-settings.png

- id: stashNewPerformerFilterButton
readme: false
screenshots:
- https://raw.githubusercontent.com/7dJx1qP/stash-plugins/main/images/Stash%20New%20Performer%20Filter%20Button/performers-page.png

- id: stashOpenMediaPlayer
readme: false

- id: stashPerformerAuditTaskButton
readme: false
screenshots:
- https://raw.githubusercontent.com/7dJx1qP/stash-plugins/main/images/Stash%20Performer%20Audit%20Task%20Button/performers-page.png

- id: stashPerformerCustomFields
readme: https://github.com/7dJx1qP/stash-plugins/blob/main/plugins/stashPerformerCustomFields/README.md
screenshots:
- https://raw.githubusercontent.com/7dJx1qP/stash-plugins/main/images/Stash%20Performer%20Custom%20Fields/custom-fields-view.png
- https://raw.githubusercontent.com/7dJx1qP/stash-plugins/main/images/Stash%20Performer%20Custom%20Fields/custom-fields-view-compact.png
- https://raw.githubusercontent.com/7dJx1qP/stash-plugins/main/images/Stash%20Performer%20Custom%20Fields/custom-fields-edit.png
- https://raw.githubusercontent.com/7dJx1qP/stash-plugins/main/images/Stash%20Performer%20Custom%20Fields/performer-details-edit.png

- id: stashPerformerImageCropper
readme: false
screenshots:
- https://raw.githubusercontent.com/7dJx1qP/stash-plugins/main/images/Stash%20Performer%20Image%20Cropper/performer-image-cropper.png

- id: stashPerformerMarkersTab
readme: false
screenshots:
- https://raw.githubusercontent.com/7dJx1qP/stash-plugins/main/images/Stash%20Performer%20Markers%20Tab/performer-page.png

- id: stashPerformerTaggerAdditions
readme: false
screenshots:
- https://raw.githubusercontent.com/7dJx1qP/stash-plugins/main/images/Stash%20Performer%20Tagger%20Additions/performer-tagger.png

- id: stashPerformerURLSearchbox
readme: false
screenshots:
- https://raw.githubusercontent.com/7dJx1qP/stash-plugins/main/images/Stash%20Performer%20URL%20Searchbox/performers-page.png

- id: stashSceneTaggerAdditions
readme: false
screenshots:
- https://raw.githubusercontent.com/7dJx1qP/stash-plugins/main/images/Stash%20Scene%20Tagger%20Additions/config.png
- https://raw.githubusercontent.com/7dJx1qP/stash-plugins/main/images/Stash%20Scene%20Tagger%20Additions/scenes-tagger.png

- id: stashSceneTaggerColorizer
readme: false
screenshots:
- https://raw.githubusercontent.com/7dJx1qP/stash-plugins/main/images/Stash%20Scene%20Tagger%20Colorizer/config.png
- https://raw.githubusercontent.com/7dJx1qP/stash-plugins/main/images/Stash%20Scene%20Tagger%20Colorizer/scenes-tagger.png
- https://raw.githubusercontent.com/7dJx1qP/stash-plugins/main/images/Stash%20Scene%20Tagger%20Colorizer/tag-colors.png

- id: stashSceneTaggerDraftSubmit
readme: false
screenshots:
- https://raw.githubusercontent.com/7dJx1qP/stash-plugins/main/images/Stash%20Scene%20Tagger%20Draft%20Submit/scenes-tagger.png

- id: stashSetStashboxFavoritePerformers
readme: false
screenshots:
- https://raw.githubusercontent.com/7dJx1qP/stash-plugins/main/images/Stash%20Set%20Stashbox%20Favorite%20Performers/performers-page.png

- id: stashStashIDIcon
readme: false
screenshots:
- https://raw.githubusercontent.com/7dJx1qP/stash-plugins/main/images/Stash%20StashID%20Icon/performer-page.png
- https://raw.githubusercontent.com/7dJx1qP/stash-plugins/main/images/Stash%20StashID%20Icon/studio-page.png
- https://raw.githubusercontent.com/7dJx1qP/stash-plugins/main/images/Stash%20StashID%20Icon/scene-page.png

- id: stashStashIDInput
readme: false
screenshots:
- https://raw.githubusercontent.com/7dJx1qP/stash-plugins/main/images/Stash%20StashID%20Input/performer-page.png
- https://raw.githubusercontent.com/7dJx1qP/stash-plugins/main/images/Stash%20StashID%20Input/studio-page.png

- id: stashStashboxSceneCount
readme: false
screenshots:
- https://raw.githubusercontent.com/7dJx1qP/stash-plugins/main/images/Stash%20Stashbox%20Scene%20Count/performer.png

- id: stashStats
readme: https://github.com/7dJx1qP/stash-plugins/blob/main/plugins/stashStats/README.md
screenshots:
- https://raw.githubusercontent.com/7dJx1qP/stash-plugins/main/images/Stash%20Stats/stats-page.png

- id: stashTagImageCropper
readme: false
screenshots:
- https://raw.githubusercontent.com/7dJx1qP/stash-plugins/main/images/Stash%20Tag%20Image%20Cropper/tag-image-cropper.png

- id: stashUserscriptLibrary7dJx1qP
readme: false

- id: stashVideoPlayerABLoopTimeInput
readme: false
screenshots:
- https://raw.githubusercontent.com/7dJx1qP/stash-plugins/main/images/Stash%20Video%20Player%20AB%20Loop%20Time%20Input/ab-loop-time-input.png
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ scripts:
screenshots:
- https://avatars.githubusercontent.com/u/10137

# id only
- id: CompleteTheStash
readme: https://github.com/MinasukiHikimuna/MidnightRider-Stash/blob/main/plugins/CompleteTheStash/README.md

- id: HashTheStash
readme: false
12 changes: 5 additions & 7 deletions builder/repositories/plugins/S3L3CT3DLoves-stashPlugins.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@ scripts:
screenshots:
- https://avatars.githubusercontent.com/u/10137

# path override
- id: cleanupUI
readme: https://github.com/S3L3CT3DLoves/stashPlugins/blob/main/plugins/CleanupUI/README.md

path: CleanupUI
- id: easytag
readme: https://github.com/S3L3CT3DLoves/stashPlugins/blob/main/plugins/QuickEdit/README.md

- id: folderSort
readme: https://github.com/S3L3CT3DLoves/stashPlugins/blob/main/plugins/folderSort/README.md
path: QuickEdit

# id only
- id: myIp
readme: false
- id: folderSort
9 changes: 5 additions & 4 deletions builder/repositories/plugins/Valkyr-JS-stash-plugins.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ scripts:
screenshots:
- https://avatars.githubusercontent.com/u/10137

- id: PerformerDetailsExtended
readme: https://github.com/Valkyr-JS/PerformerDetailsExtended/blob/main/README.md

# id only
- id: StashReels
readme: https://github.com/Valkyr-JS/StashReels/blob/main/README.md

- id: PerformerDetailsExtended
readme: https://github.com/Valkyr-JS/PerformerDetailsExtended/blob/main/README.md

- id: ValkyrSceneCards
readme: https://github.com/Valkyr-JS/ValkyrSceneCards/blob/main/README.md
screenshots:
- /assets/plugins/ValkyrSceneCards/1.png
- /assets/plugins/ValkyrSceneCards/2.png
- /assets/plugins/ValkyrSceneCards/2.png
3 changes: 1 addition & 2 deletions builder/repositories/plugins/carrotwaxr-stash-plugins.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ scripts:
screenshots:
- https://avatars.githubusercontent.com/u/10137

- id: mcMetadata
readme: https://github.com/carrotwaxr/stash-plugins/blob/main/plugins/mcMetadata/README.md
- id: mcMetadata
Loading

0 comments on commit 3511460

Please sign in to comment.