Skip to content

Commit

Permalink
Constants change
Browse files Browse the repository at this point in the history
  • Loading branch information
pylixonly committed Feb 9, 2024
1 parent d543317 commit 8d2e17d
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 25 deletions.
54 changes: 35 additions & 19 deletions build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ const isRelease = isFlag("r", "release");
const shouldServe = isFlag("s", "serve");
const shouldWatch = isFlag("w", "watch");

// TODO: This does not change unless you re-execute the script
const timeHash = Number(new Date).toString(36);
const commitHash = execSync("git rev-parse --short HEAD").toString().trim();

try {
Expand All @@ -32,27 +30,55 @@ try {
},
outfile: "dist/bunny.js",
keepNames: true,
define: {
__vendettaIsDev: `${!isRelease}`,
__vendettaVersion: `"${isRelease ? commitHash : timeHash}"`,
},
footer: {
js: "//# sourceURL=bunny"
},
loader: { ".png": "dataurl" },
legalComments: "none",
alias: {
alias: {
"@*": "src*",
"@types": "src/def.d.ts"
},
plugins: [
{
name: "buildLog",
setup: async build => {
build.onStart(() => {
console.clear();
console.log(`Building with commit hash "${commitHash}", isRelease="${isRelease}"`)
});

build.onEnd(result => {
const { outfile } = build.initialOptions;
copyFileSync(outfile, path.resolve(outfile, "..", "pyondetta.js"))
console.log(`Built with ${result.errors?.length} errors!`);
});
}
},
{
name: "swc",
setup(build) {
let timeString = Number(new Date).toString(36);

build.onStart(() => {
timeString = Number(new Date).toString(36);
console.log(`swc plugin: time-string="${timeString}"`);
})

build.onLoad({ filter: /\.[jt]sx?/ }, async args => {
const result = await swc.transformFile(args.path, {
jsc: {
externalHelpers: true,
transform: {
optimizer: {
globals: {
vars: {
__vendettaIsDev: `${!isRelease}`,
__vendettaVersion: `"${isRelease ? commitHash : timeString}"`,
}
}
}
},
},
env: {
targets: "defaults",
Expand All @@ -67,19 +93,9 @@ try {
return { contents: result.code };
});
}
},
{
name: "buildLog",
setup: async build => {
build.onStart(() => console.log(`Building with commit hash "${commitHash}", isRelease="${isRelease}", timeHash="${timeHash}"`));
build.onEnd(result => {
const { outfile } = build.initialOptions;
copyFileSync(outfile, path.resolve(outfile, "..", "pyondetta.js"))
console.log(`Built with ${result.errors?.length} errors!`);
});
}
}
]
],
external: ["commit-hash"]
});

if (shouldWatch) {
Expand Down
14 changes: 8 additions & 6 deletions src/lib/constants.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
export const DISCORD_SERVER = "https://discord.gg/n9QQ4XhhJP";
export const DISCORD_SERVER_ID = "1015931589865246730";
export const PLUGINS_CHANNEL_ID = "1091880384561684561";
export const THEMES_CHANNEL_ID = "1091880434939482202";
export const GITHUB = "https://github.com/vendetta-mod";
export const DISCORD_SERVER = "https://discord.gg/XjYgWXHb9Q";
export const GITHUB = "https://github.com/pyoncord";
export const PROXY_PREFIX = "https://vd-plugins.github.io/proxy";
export const HTTP_REGEX = /^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/;
export const HTTP_REGEX_MULTI = /https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&//=]*)/g;
export const HTTP_REGEX_MULTI = /https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&//=]*)/g;

// These are still Vendetta's
export const DISCORD_SERVER_ID = "1015931589865246730";
export const PLUGINS_CHANNEL_ID = "1091880384561684561";
export const THEMES_CHANNEL_ID = "1091880434939482202";

0 comments on commit 8d2e17d

Please sign in to comment.