Skip to content

Commit 3511460

Browse files
builder and sidecar updates (#88)
Co-authored-by: feederbox826 <[email protected]> Co-authored-by: DogmaDragon <[email protected]>
1 parent aa39a08 commit 3511460

29 files changed

+254
-610
lines changed

builder/LICENSE

Lines changed: 0 additions & 21 deletions
This file was deleted.

builder/build.ts

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import axios from 'axios'
22
import YAML from 'yaml'
3-
import fs from 'fs'
4-
import path from 'path'
3+
import * as fs from 'fs';
4+
import * as path from 'path';
55

6-
import { LocalCollection, LocalRepository, LocalSidecar, RemoteIndex } from './types'
6+
import { LocalCollection, LocalRepository, LocalSidecar, RemoteIndex, RemotePlugin } from './types'
77
import { Plugin } from './plugin'
88
import { infoLog, warnLog } from './utils'
9+
import { debuglog } from 'util';
910

1011
// iterate over folder
1112
async function searchRepository(pathName: string = "plugins"): Promise<Plugin[]> {
@@ -18,6 +19,8 @@ async function searchRepository(pathName: string = "plugins"): Promise<Plugin[]>
1819
if (file.endsWith(".yml")) {
1920
const fileData = fs.readFileSync(`${repoPath}/${file}`, 'utf8')
2021
const localRepo: LocalRepository = YAML.parse(fileData)
22+
// set name to filename if not defined
23+
if (!localRepo.name) localRepo.name = file.replace(".yml", "")
2124
repositories.push(localRepo)
2225
}
2326
})
@@ -27,13 +30,19 @@ async function searchRepository(pathName: string = "plugins"): Promise<Plugin[]>
2730
const plugin = await parseRepository(repo)
2831
plugins.push(...plugin)
2932
}
33+
// fetch all readmes of plugins
34+
const readmePromises = plugins.map(plugin => plugin.checkReadme())
35+
await Promise.all(readmePromises)
3036
// sort plugins and print to md
3137
const sortedPlugins = plugins
3238
.sort((a, b) => a.name.toLowerCase().localeCompare(b.name.toLowerCase()))
3339
return sortedPlugins
3440
}
3541

3642
function printPlugins(outputName: string, sortedPlugins: Plugin[]) {
43+
// create folder if not exists
44+
if (!fs.existsSync(`./dist`)) fs.mkdirSync(`./dist`)
45+
if (!fs.existsSync(`./dist/${outputName}`)) fs.mkdirSync(`./dist/${outputName}`)
3746
// print to file
3847
const outputPath = `./dist/${outputName}/list.md`
3948
const stream = fs.createWriteStream(outputPath)
@@ -55,23 +64,37 @@ async function parseRepository(localRepository: LocalRepository): Promise<Plugin
5564
.then(res => YAML.parse(res.data))
5665
// iterate over remote index and match with sidecars
5766
const indexPlugins: Plugin[] = []
67+
const idxMissingScar: Set<RemotePlugin> = new Set()
68+
const allIdx: Set<RemotePlugin> = new Set()
5869
for (const index of indexData) {
5970
const sidecarMatch = repoSidecars.find(sidecar => sidecar.id == index.id)
60-
if (sidecarMatch?.hide) {
61-
// skip if hidden, but warn
62-
infoLog(`Skipping hidden plugin: ${index.name}`)
63-
continue
71+
if (sidecarMatch) {
72+
if (sidecarMatch.id == "example") continue // if example, skip
73+
else if (sidecarMatch.hide) { // skip but warn if hidden
74+
debuglog(`Skipping hidden plugin: ${index.name}`)
75+
continue
76+
} else allIdx.add(index) // add to sidecars
77+
} else { // sidecar not found
78+
if (repoDefaults.exclusive) continue // if exclusive, skip
79+
idxMissingScar.add(index) // add to missing
6480
}
65-
if (repoDefaults.exclusive && !sidecarMatch) continue // if exclusive, skip if no sidecar
6681
const plugin = new Plugin(repoDefaults, sidecarMatch, index)
6782
indexPlugins.push(plugin)
6883
}
6984
// check if there are leftover sidecars
70-
const extraSidecars = repoSidecars.filter(sidecar => !indexPlugins.find(plugin => plugin.id == sidecar.id && !sidecar.hide))
85+
// not named example
86+
// not in indexPlugins and not hidden
87+
const extraSidecars = repoSidecars.filter(sidecar => sidecar.id != "example" && !sidecar.hide && !indexPlugins.find(plugin => plugin.id == sidecar.id))
7188
if (extraSidecars.length > 0) {
7289
warnLog(`Found ${extraSidecars.length} extra sidecars in ${localRepository.name}`)
7390
extraSidecars.forEach(sidecar => warnLog(` ${sidecar.id}`))
7491
}
92+
// check for plugins without sidecars
93+
const missingSCars = Array.from(idxMissingScar).filter(plugin => allIdx.has(plugin))
94+
if (missingSCars.length > 0) {
95+
infoLog(`Found ${missingSCars.length} missing sidecars in ${localRepository.name}`)
96+
missingSCars.forEach(sidecar => infoLog(` ${sidecar.name}`))
97+
}
7598
return indexPlugins
7699
}
77100

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

89113
run()

builder/plugin.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as utils from './utils'
22
import { LocalCollection, LocalSidecar, RemotePlugin } from './types'
3+
import axios from 'axios'
34

45
export class Plugin {
56
id: string // internal id of plugin
@@ -28,11 +29,21 @@ export class Plugin {
2829
this.path = sidecar?.path
2930
?? index.id // default to ID
3031
this.screenshots = sidecar?.screenshots ?? []
31-
this.readme = sidecar?.readme ?? true // readme file
32+
this.readme = defaults?.global_readme ?? sidecar?.readme // readme file
3233
this.base_path = defaults.base_path ?? "main/plugins"
3334
this.repo_path = `${this.base_path}/${this.path}`
3435
}
3536

37+
async checkReadme(): Promise<void> {
38+
// test readme if undefined
39+
if (this.readme === undefined) {
40+
this.readme = await axios.head(`https://github.com/${this.repo}/blob/${this.repo_path}/README.md`, {
41+
validateStatus: status => status == 200 || status == 404
42+
})
43+
.then(res => res.status == 200)
44+
}
45+
}
46+
3647
printMD() {
3748
// pre prepared values
3849
const folderPath = `https://github.com/${this.repo}/tree/${this.repo_path}`

builder/repositories/example.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Repository name
2+
collection:
3+
# index url for your repo
4+
index: https://ghost.github.io/stash-plugins/main/index.yml
5+
# github url of the repo - github.com/username/repo-name
6+
global_repo: ghost/stash-plugins
7+
# author of all plugins in the repo (OPTIONAL)
8+
global_author: "[ghost](https://github.com/ghost)"
9+
# link to readme if it applies to all scripts within the collection
10+
global_readme: "https://example.com/stash-plugins/README.md"
11+
# branch/path within the folder structure
12+
base_path: main/plugins
13+
# entries not in the sidecar are excluded
14+
exclusive: true
15+
16+
scripts:
17+
# internal id of the plugin
18+
id: my-first-stash-plugin
19+
# path if it is not at base_path/id
20+
path: CoolPlugin
21+
# description (OPTIONAL)
22+
description: My first plugin
23+
# readme, if not at base_path/id/README.md
24+
# if left empty, will try to search at the location
25+
readme: "https://example.com/stash-plugins/README.md"
26+
# override author from global_author
27+
author: "Ghost, Casper"
28+
# list of links to images of screenshots
29+
screenshots:
30+
- https://example.com/stash-plugins/CoolPlugin/demo.png
31+
- https://example.com/stash-plugins/CoolPlugin/usage.png
32+
- https://example.com/stash-plugins/CoolPlugin/settings.png
33+
# if plugin should be hidden from generate index
34+
# this should only be set if the plugin is a backend dependency
35+
# is in a completely broken state and wholly incompatible
36+
# or has been deprecated and should not be used
37+
hide: true

builder/repositories/plugins/7djx1qp-stash-plugins.yml

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,134 +13,115 @@ scripts:
1313
screenshots:
1414
- https://avatars.githubusercontent.com/u/10137
1515

16+
# id only
17+
- id: stashOpenMediaPlayer
18+
19+
# dependencies
20+
- id: stashUserscriptLibrary7dJx1qP
21+
hide: true
22+
23+
# screenshots
1624
- id: stashBatchQueryEdit
17-
readme: false
1825
screenshots:
1926
- https://raw.githubusercontent.com/7dJx1qP/stash-plugins/main/images/Stash%20Batch%20Query%20Edit/config.png
2027
- https://raw.githubusercontent.com/7dJx1qP/stash-plugins/main/images/Stash%20Batch%20Query%20Edit/scenes-tagger.png
2128

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

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

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

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

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

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

53-
- id: stashOpenMediaPlayer
54-
readme: false
5554

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

140-
- id: stashUserscriptLibrary7dJx1qP
141-
readme: false
142124

143125
- id: stashVideoPlayerABLoopTimeInput
144-
readme: false
145126
screenshots:
146127
- https://raw.githubusercontent.com/7dJx1qP/stash-plugins/main/images/Stash%20Video%20Player%20AB%20Loop%20Time%20Input/ab-loop-time-input.png

builder/repositories/plugins/MinasukiHikimuna-MidnightRider-Stash.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ scripts:
1414
screenshots:
1515
- https://avatars.githubusercontent.com/u/10137
1616

17+
# id only
1718
- id: CompleteTheStash
18-
readme: https://github.com/MinasukiHikimuna/MidnightRider-Stash/blob/main/plugins/CompleteTheStash/README.md
19-
2019
- id: HashTheStash
21-
readme: false

builder/repositories/plugins/S3L3CT3DLoves-stashPlugins.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,12 @@ scripts:
1313
screenshots:
1414
- https://avatars.githubusercontent.com/u/10137
1515

16+
# path override
1617
- id: cleanupUI
17-
readme: https://github.com/S3L3CT3DLoves/stashPlugins/blob/main/plugins/CleanupUI/README.md
18-
18+
path: CleanupUI
1919
- id: easytag
20-
readme: https://github.com/S3L3CT3DLoves/stashPlugins/blob/main/plugins/QuickEdit/README.md
21-
22-
- id: folderSort
23-
readme: https://github.com/S3L3CT3DLoves/stashPlugins/blob/main/plugins/folderSort/README.md
20+
path: QuickEdit
2421

22+
# id only
2523
- id: myIp
26-
readme: false
24+
- id: folderSort

builder/repositories/plugins/Valkyr-JS-stash-plugins.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@ scripts:
1313
screenshots:
1414
- https://avatars.githubusercontent.com/u/10137
1515

16-
- id: PerformerDetailsExtended
17-
readme: https://github.com/Valkyr-JS/PerformerDetailsExtended/blob/main/README.md
18-
16+
# id only
1917
- id: StashReels
2018
readme: https://github.com/Valkyr-JS/StashReels/blob/main/README.md
2119

20+
- id: PerformerDetailsExtended
21+
readme: https://github.com/Valkyr-JS/PerformerDetailsExtended/blob/main/README.md
22+
2223
- id: ValkyrSceneCards
2324
readme: https://github.com/Valkyr-JS/ValkyrSceneCards/blob/main/README.md
2425
screenshots:
2526
- /assets/plugins/ValkyrSceneCards/1.png
26-
- /assets/plugins/ValkyrSceneCards/2.png
27+
- /assets/plugins/ValkyrSceneCards/2.png

builder/repositories/plugins/carrotwaxr-stash-plugins.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,4 @@ scripts:
1313
screenshots:
1414
- https://avatars.githubusercontent.com/u/10137
1515

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

0 commit comments

Comments
 (0)