refactord paths.ts
This commit is contained in:
51
src/paths.ts
51
src/paths.ts
@@ -1,23 +1,42 @@
|
||||
export const BaseUrl = `https://git.zomo.dev/zomo/browser-scripts`
|
||||
export const RemoteBranch = 'main'
|
||||
export const ScriptBase = 'scripts'
|
||||
export const DistBase = 'dist'
|
||||
|
||||
export const SupportUrl = `${BaseUrl}/issues`
|
||||
export const FileUrl = (name: string) =>
|
||||
`${BaseUrl}/raw/branch/${RemoteBranch}/${DistBase}/${name}.user.js`
|
||||
|
||||
export interface ScriptPathT {
|
||||
dir: `${string}/${string}`
|
||||
main: `${string}/${string}/main.ts`
|
||||
meta: `${string}/${string}/meta.json`
|
||||
error: `${string}/${string}/error.log`
|
||||
dist: `${string}/${string}.user.js`
|
||||
url: `${string}/raw/branch/${string}/${string}/${string}.user.js`
|
||||
}
|
||||
export const ScriptPath = (name: string): ScriptPathT => ({
|
||||
dir: `${ScriptBase}/${name}`,
|
||||
main: `${ScriptBase}/${name}/main.ts`,
|
||||
meta: `${ScriptBase}/${name}/meta.json`,
|
||||
error: `${ScriptBase}/${name}/error.log`,
|
||||
})
|
||||
|
||||
export const DistPath = (name: string) => `${DistBase}/${name}.user.js`
|
||||
export interface getAllPathsOps {
|
||||
baseURL: string
|
||||
remoteBranch: string
|
||||
scriptBase: string
|
||||
distBase: string
|
||||
}
|
||||
|
||||
export default function getAllPaths({
|
||||
baseURL,
|
||||
remoteBranch,
|
||||
scriptBase,
|
||||
distBase,
|
||||
}: getAllPathsOps) {
|
||||
return {
|
||||
base: {
|
||||
branch: remoteBranch,
|
||||
script: scriptBase,
|
||||
dist: distBase,
|
||||
},
|
||||
url: {
|
||||
base: baseURL,
|
||||
support: `${baseURL}/issues`,
|
||||
},
|
||||
script: (name: string): ScriptPathT => ({
|
||||
dir: `${scriptBase}/${name}`,
|
||||
main: `${scriptBase}/${name}/main.ts`,
|
||||
meta: `${scriptBase}/${name}/meta.json`,
|
||||
error: `${scriptBase}/${name}/error.log`,
|
||||
dist: `${distBase}/${name}.user.js`,
|
||||
url: `${baseURL}/raw/branch/${remoteBranch}/${distBase}/${name}.user.js`,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user