Skip to content

Commit

Permalink
Merge branch 'main' into jsr
Browse files Browse the repository at this point in the history
  • Loading branch information
Bas950 authored Feb 20, 2025
2 parents bb4d78a + 4a70201 commit 273c2ba
Show file tree
Hide file tree
Showing 369 changed files with 1,407 additions and 1,353 deletions.
4 changes: 2 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.MD
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
<!-- A clear and detailed description of the changes, referencing issues if applicable -->

## Acknowledgements
- [ ] I read the [Presence Guidelines](https://github.com/PreMiD/Presences/blob/main/.github/CONTRIBUTING.md)
- [ ] I read the [Activity Guidelines](https://github.com/PreMiD/Presences/blob/main/.github/CONTRIBUTING.md)
- [ ] I linted the code by running `yarn format`
- [ ] The PR title follows the repo's [commit conventions](https://github.com/PreMiD/Presences/blob/main/.github/COMMIT_CONVENTION.md)

## Screenshots
<details>
<summary> Proof showing the creation/modification is working as expected </summary>
<!--
Screenshots of the presence settings (if applicable) and at least TWO screenshots of the presence displaying correctly
Screenshots of the activity settings (if applicable) and at least TWO screenshots of the activity displaying correctly
Including these screenshots will assist the reviewing processes thus speeding up the process of the pull request being merged
-->

Expand Down
10 changes: 4 additions & 6 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"addLabels": ["dependencies"],
"automerge": false,
"semanticCommits": "enabled",
"configWarningReuseIssue": false,
"schedule": ["0 17 * * 5"],
"stabilityDays": 3
"extends": [
"github>Recodive/Recodive:renovate-config"
],
"automerge": false
}
2 changes: 1 addition & 1 deletion .github/workflows/assets-updater.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: pmd
name: Assets Updater

on:
push:
Expand Down
13 changes: 1 addition & 12 deletions .github/workflows/pmd.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
name: pmd
name: Validate

on:
push:
branches: [main]
pull_request:
branches: [main]
schedule:
- cron: '0 0 * * *'
workflow_dispatch:

jobs:
pmd:
Expand All @@ -30,19 +27,11 @@ jobs:
run: npm ci

- name: Validate metadata and build (changed files)
if: github.event_name == 'push' || github.event_name == 'pull_request'
run: npx pmd build --changed --no-kill --validate --sarif
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
continue-on-error: true

- name: Validate metadata and build (all files)
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
run: npx pmd build --all --no-kill --validate --sarif
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
continue-on-error: true

- name: Upload analysis results to GitHub
uses: github/codeql-action/upload-sarif@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: pmd
name: Release
on:
push:
branches:
Expand Down
4 changes: 2 additions & 2 deletions .resources/README.MD
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Resouces for Presences
# Resources for Activities

In this folder you can find resource images which you can use to display the status of what the user is doing.

Expand Down Expand Up @@ -44,4 +44,4 @@ enum Assets {
PremiereLive = "https://cdn.rcd.gg/PreMiD/resources/premiere-live.png",
Viewing = "https://cdn.rcd.gg/PreMiD/resources/viewing.png",
}
```
```
99 changes: 70 additions & 29 deletions cli/src/classes/ActivityCompiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import chalk from 'chalk'
import { watch } from 'chokidar'
import { build } from 'esbuild'
import ora from 'ora'
import { compare, inc } from 'semver'
import { inc } from 'semver'
import { getChangedActivities } from '../util/getActivities.js'
import { getJsonPosition } from '../util/getJsonPosition.js'
import { error, exit, prefix } from '../util/log.js'
import { sanitazeFolderName } from '../util/sanitazeFolderName.js'
Expand All @@ -25,6 +26,7 @@ export interface ActivityMetadata {
iframe?: boolean
iFrameRegExp?: string
description: Record<string, string>
tags: string[]
}

export class ActivityCompiler {
Expand Down Expand Up @@ -54,21 +56,26 @@ export class ActivityCompiler {
preCheck?: boolean
zip: boolean
}): Promise<boolean> {
let checksSucceeded = true
if (preCheck) {
await this.dependencies.installDependencies()
const success = await this.ts.typecheck(kill)
if (!success) {
return false
checksSucceeded = false
}
}

if (validate) {
const success = await this.validate({ kill })
if (!success) {
return false
checksSucceeded = false
}
}

if (!checksSucceeded) {
return false
}

const spinner = ora(prefix + chalk.greenBright(` Compiling ${this.activity.service}...`))
spinner.start()

Expand Down Expand Up @@ -186,12 +193,35 @@ export class ActivityCompiler {
valid = false
}

if (!libraryVersion) {
if (metadata.version === '1.0.0') {
return true
if (!libraryVersion && metadata.version !== '1.0.0') {
const message = `Expected initial version of activity ${metadata.service} to be 1.0.0`
if (kill) {
exit(message)
}
else {
const message = `Expected initial version of activity ${metadata.service} to be 1.0.0`

error(message)
addSarifLog({
path: resolve(this.cwd, 'metadata.json'),
message,
ruleId: SarifRuleId.bumpCheck,
position: await getJsonPosition(resolve(this.cwd, 'metadata.json'), 'version'),
})
valid = false
}

if (libraryVersion) {
const expectedVersions = [
inc(libraryVersion.version, 'patch'),
inc(libraryVersion.version, 'minor'),
inc(libraryVersion.version, 'major'),
]

const { changed } = await getChangedActivities()
if (
changed.some(activity => activity.folder === this.cwd)
&& !expectedVersions.includes(metadata.version)
) {
const message = `Expected version of activity ${metadata.service} to be bumped to one of the following: ${expectedVersions.join(', ')}`
if (kill) {
exit(message)
}
Expand All @@ -207,27 +237,6 @@ export class ActivityCompiler {
}
}

if (libraryVersion && compare(metadata.version, libraryVersion.version) === -1) {
const expectedVersions = [
inc(libraryVersion.version, 'patch'),
inc(libraryVersion.version, 'minor'),
inc(libraryVersion.version, 'major'),
]
const message = `Expected version of activity ${metadata.service} to be bumped to one of the following: ${expectedVersions.join(', ')}`
if (kill) {
exit(message)
}

error(message)
addSarifLog({
path: resolve(this.cwd, 'metadata.json'),
message,
ruleId: SarifRuleId.bumpCheck,
position: await getJsonPosition(resolve(this.cwd, 'metadata.json'), 'version'),
})
valid = false
}

if (metadata.iframe && !existsSync(resolve(this.cwd, 'iframe.ts'))) {
const message = `Expected iframe.ts to exist for activity ${metadata.service}, as metadata.iframe is true`
if (kill) {
Expand Down Expand Up @@ -302,6 +311,38 @@ export class ActivityCompiler {
}
}

if (new Set(metadata.tags).size !== metadata.tags.length) {
const message = `Tags must be unique`
if (kill) {
exit(message)
}

error(message)
addSarifLog({
path: resolve(this.cwd, 'metadata.json'),
message,
ruleId: SarifRuleId.tagsCheck,
position: await getJsonPosition(resolve(this.cwd, 'metadata.json'), 'tags'),
})
valid = false
}

if (metadata.tags.includes(metadata.service.toLowerCase().replace(/[A-Z\s!"#$%&'()*+,./:;<=>?@[\\\]^_`{|}~]/g, ''))) {
const message = `Tags must not contain the service name`
if (kill) {
exit(message)
}

error(message)
addSarifLog({
path: resolve(this.cwd, 'metadata.json'),
message,
ruleId: SarifRuleId.tagsServiceCheck,
position: await getJsonPosition(resolve(this.cwd, 'metadata.json'), 'tags'),
})
valid = false
}

return valid
}
}
Expand Down
4 changes: 2 additions & 2 deletions cli/src/classes/TypescriptCompiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ export class TypescriptCompiler {
message: ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n'),
ruleId: SarifRuleId.typeCheck,
position: {
line,
column: character,
line: line + 1,
column: character + 1,
},
})
}
Expand Down
14 changes: 12 additions & 2 deletions cli/src/util/getActivities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,19 @@ export async function getActivities(): Promise<ActivityMetadataAndFolder[]> {
})
}

let cache: {
changed: ActivityMetadataAndFolder[]
deleted: ActivityMetadataAndFolder[]
} | null = null

export async function getChangedActivities(): Promise<{
changed: ActivityMetadataAndFolder[]
deleted: ActivityMetadataAndFolder[]
}> {
if (cache) {
return cache
}

const changedFiles = (isCI ? await getChangedFilesCi() : await getChangedFilesLocal())
.map(file => ({
...file,
Expand Down Expand Up @@ -81,7 +90,7 @@ export async function getChangedActivities(): Promise<{
.filter(folder => !Array.from(activityPaths).some(activityPath => activityPath.startsWith(folder))),
)

return {
return cache = {
changed: (
await Promise.all(
Array.from(activityPaths)
Expand All @@ -105,10 +114,11 @@ export async function getChangedActivities(): Promise<{
logo: '',
thumbnail: '',
version: '1.0.0',
tags: [],
},
folder,
versionized,
}
} satisfies ActivityMetadataAndFolder
}),
}
}
Expand Down
24 changes: 20 additions & 4 deletions cli/src/util/sarif.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { writeFile } from 'node:fs/promises'
import { resolve } from 'node:path'
import process from 'node:process'
import { pathToFileURL } from 'node:url'
import { getCliPackageJson } from './getPackageJson.js'

export enum SarifRuleId {
Expand All @@ -13,6 +12,8 @@ export enum SarifRuleId {
serviceFolderCheck = 'service-folder-check',
imageSizeCheck = 'image-size-check',
imageMimeTypeCheck = 'image-mime-type-check',
tagsCheck = 'tags-check',
tagsServiceCheck = 'tags-service-check',
}

const sarifRules: Record<SarifRuleId, ReportingDescriptor> = {
Expand Down Expand Up @@ -72,6 +73,20 @@ const sarifRules: Record<SarifRuleId, ReportingDescriptor> = {
text: 'Makes sure all images (logo and URLs) have the correct MIME type',
},
},
[SarifRuleId.tagsCheck]: {
id: SarifRuleId.tagsCheck,
name: 'Tags Check',
shortDescription: {
text: 'Makes sure the `tags` metadata property is unique',
},
},
[SarifRuleId.tagsServiceCheck]: {
id: SarifRuleId.tagsServiceCheck,
name: 'Tags Service Check',
shortDescription: {
text: 'Makes sure the `tags` don\'t contain the service name',
},
},
}

const sarifLog: SARIF = {
Expand Down Expand Up @@ -107,15 +122,16 @@ export function addSarifLog(log: {
column: number
}
}) {
log.path = log.path.replace(process.cwd(), '')
// Remove the cwd from the path. And remove the leading slash.
log.path = encodeURI(log.path.replace(process.cwd(), '').slice(1))

if (typeof sarifArtifactIndices[log.path] === 'undefined') {
sarifArtifactIndices[log.path] = nextArtifactIndex++

// Create a new entry in the files dictionary.
sarifFiles[log.path] = {
location: {
uri: pathToFileURL(log.path).toString(),
uri: log.path,
},
}
}
Expand All @@ -133,7 +149,7 @@ export function addSarifLog(log: {
{
physicalLocation: {
artifactLocation: {
uri: pathToFileURL(log.path),
uri: log.path,
index: sarifArtifactIndices[log.path],
},
...(log.position && log.position.line > 0
Expand Down
3 changes: 1 addition & 2 deletions websites/#/대성마이맥/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@
"vi": "Digital Daesung là công ty giáo dục hàng đầu Hàn Quốc, cung cấp nội dung giáo dục chất lượng cao. Chúng tôi cung cấp dịch vụ giáo dục toàn vẹn cho bậc tiểu học, trung học, cao đẳng và đại học, từ học trực tuyến đến trực tiếp, luyện viết luận và tư vấn nộp hồ sơ đại học."
},
"url": "www.mimacstudy.com",
"version": "1.0.23",
"version": "1.0.24",
"logo": "https://cdn.rcd.gg/PreMiD/websites/%23/%EB%8C%80%EC%84%B1%EB%A7%88%EC%9D%B4%EB%A7%A5/assets/logo.png",
"thumbnail": "https://cdn.rcd.gg/PreMiD/websites/%23/%EB%8C%80%EC%84%B1%EB%A7%88%EC%9D%B4%EB%A7%A5/assets/thumbnail.png",
"color": "#2581c4",
"category": "videos",
"tags": [
"mimacstudy",
"대성마이맥",
"인강"
]
}
3 changes: 1 addition & 2 deletions websites/0-9/000webhost/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@
},
"url": "000webhost.com",
"regExp": "([a-z0-9-]+[.])*000webhost[.]com[\\/]",
"version": "1.3.6",
"version": "1.3.7",
"logo": "https://cdn.rcd.gg/PreMiD/websites/0-9/000webhost/assets/logo.png",
"thumbnail": "https://cdn.rcd.gg/PreMiD/websites/0-9/000webhost/assets/thumbnail.jpg",
"color": "#ff5c62",
"category": "other",
"tags": [
"000webhost",
"webhost",
"web",
"hosting",
Expand Down
Loading

0 comments on commit 273c2ba

Please sign in to comment.