Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Cynosphere committed Feb 11, 2024
1 parent e1ef75d commit 008da38
Show file tree
Hide file tree
Showing 13 changed files with 656 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Deploy to GitHub Pages

on:
push:
branches:
- main

permissions:
contents: read
pages: write
id-token: write

jobs:
deploy:
name: Deploy to GitHub Pages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: pnpm/action-setup@v2
with:
version: 8
run_install: false
- uses: actions/setup-node@v3
with:
node-version: 18
cache: pnpm

- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build extensions
env:
NODE_ENV: production
run: pnpm run build
- name: Pack extensions
env:
REPO_URL: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}
run: pnpm run repo

- name: Setup GitHub Pages
uses: actions/configure-pages@v3

- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
path: ./repo

- name: Deploy to GitHub Pages
uses: actions/deploy-pages@v2
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/dist
/repo
/node_modules
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "moonlight"]
path = moonlight
url = https://github.com/moonlight-mod/moonlight.git
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"printWidth": 80,
"trailingComma": "none",
"tabWidth": 2,
"singleQuote": false
}
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# goonlight

> when is goonlight releasing
>
> need to make cumcord plugin for moonlight called goonlight
>
> ~ [Nat Sepruko](https://github.com/sepruko), 2024
103 changes: 103 additions & 0 deletions build.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
import * as esbuild from "esbuild";
import copyStaticFiles from "esbuild-copy-static-files";
import fs from "fs";

const prod = process.env.NODE_ENV === "production";
const watch = process.argv.includes("--watch");

function makeConfig(ext, name) {
const entryPoints = [];
const fileExts = ["js", "jsx", "ts", "tsx"];
for (const fileExt of fileExts) {
const path = `./src/${name}.${fileExt}`;
if (fs.existsSync(path)) entryPoints.push(path);
}

const wpModulesDir = `./src/webpackModules`;
if (fs.existsSync(wpModulesDir) && name === "index") {
const wpModules = fs.readdirSync(wpModulesDir);
for (const wpModule of wpModules) {
entryPoints.push(`./src/webpackModules/${wpModule}`);
}
}

if (entryPoints.length === 0) return null;

const wpImportPlugin = {
name: "webpackImports",
setup(build) {
build.onResolve({ filter: /^@moonlight-mod\/wp\// }, (args) => {
const wpModule = args.path.replace(/^@moonlight-mod\/wp\//, "");
return {
path: wpModule,
external: true
};
});
}
};

const timeFormatter = new Intl.DateTimeFormat(undefined, {
hour: "numeric",
minute: "numeric",
second: "numeric",
hour12: false
});
const buildLogPlugin = {
name: "buildLog",
setup(build) {
build.onEnd(() => {
console.log(
`[${timeFormatter.format(
new Date()
)}] [${ext}/${name}] build finished`
);
});
}
};

return {
entryPoints,
outdir: `./dist/${ext}`,

format: "cjs",
platform: "node",

treeShaking: true,
bundle: true,
minify: prod,
sourcemap: "inline",

external: ["electron", "fs", "path", "module", "events", "original-fs"],

plugins: [
copyStaticFiles({
src: `./src/manifest.json`,
dest: `./dist/${ext}/manifest.json`
}),
wpImportPlugin,
buildLogPlugin
]
};
}

const EXT_NAME = "goonlight";
const config = [
makeConfig(EXT_NAME, "index"),
makeConfig(EXT_NAME, "node"),
makeConfig(EXT_NAME, "host")
]
.flat()
.filter((c) => c !== null);

if (watch) {
await Promise.all(
config.map(async (c) => {
const ctx = await esbuild.context(c);
await ctx.watch();
})
);
} else {
for (const c of config) {
await esbuild.build(c);
}
}
1 change: 1 addition & 0 deletions env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="@moonlight-mod/types" />
18 changes: 18 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "@cynosphere/moonlight-extensions",
"version": "1.0.0",
"main": "dist/index.js",
"scripts": {
"build": "node build.mjs",
"dev": "node build.mjs --watch",
"repo": "node repo.mjs"
},
"devDependencies": {
"@electron/asar": "^3.2.8",
"esbuild": "^0.19.3",
"esbuild-copy-static-files": "^0.1.0"
},
"dependencies": {
"@moonlight-mod/types": "^1.0.0"
}
}
Loading

0 comments on commit 008da38

Please sign in to comment.