-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use specific fns instead of massive paths obj (#1005)
* use specific fns instead of massive paths obj * lint
- Loading branch information
Showing
4 changed files
with
145 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,108 +1,140 @@ | ||
import fs from 'fs' | ||
|
||
export const getContractNames = () => { | ||
return ['captcha', 'common', 'proxy'] | ||
} | ||
|
||
export type Paths = { | ||
root: string | ||
dev: string | ||
demos: string | ||
contract: string | ||
protocol: string | ||
packages: string | ||
config: string | ||
scripts: string | ||
protocolCli: string | ||
protocolDist: string | ||
clientExample: string | ||
clientExampleServer: string | ||
clientBundleExample: string | ||
dappExample: string | ||
common: string | ||
api: string | ||
cli: string | ||
util: string | ||
database: string | ||
datasets: string | ||
datasetsFs: string | ||
env: string | ||
fileServer: string | ||
procaptcha: string | ||
procaptchaReact: string | ||
procaptchaBundle: string | ||
provider: string | ||
server: string | ||
typesDatabase: string | ||
typesEnv: string | ||
types: string | ||
contractPackagesDir: string | ||
} | ||
|
||
export const getPaths = (): Paths => { | ||
const root = new URL('../../..', import.meta.url).pathname.slice(0, -1) | ||
const dev = `${root}/dev` | ||
const packages = `${root}/packages` | ||
const protocol = `${root}/protocol` | ||
const demos = `${root}/demos` | ||
const contract = `${packages}/contract` | ||
const types = `${packages}/types` | ||
const config = `${dev}/config` | ||
const scripts = `${dev}/scripts` | ||
const protocolCli = `${protocol}/dist/cli` | ||
const protocolDist = `${protocol}/target/ink` | ||
const clientExample = `${demos}/client-example` | ||
const clientExampleServer = `${demos}/client-example-server` | ||
const clientBundleExample = `${demos}/client-bundle-example` | ||
const dappExample = `${demos}/dapp-example` | ||
const common = `${packages}/common` | ||
const api = `${packages}/api` | ||
const cli = `${packages}/cli` | ||
const util = `${packages}/util` | ||
const database = `${packages}/database` | ||
const datasets = `${packages}/datasets` | ||
const datasetsFs = `${packages}/datasets-fs` | ||
const env = `${packages}/env` | ||
const fileServer = `${packages}/file-server` | ||
const procaptcha = `${packages}/procaptcha` | ||
const procaptchaReact = `${packages}/procaptcha-react` | ||
const procaptchaBundle = `${packages}/procaptcha-bundle` | ||
const provider = `${packages}/provider` | ||
const server = `${packages}/server` | ||
const typesDatabase = `${packages}/types-database` | ||
const typesEnv = `${packages}/types-env` | ||
const contractPackagesDir = `${root}/contracts` | ||
|
||
return { | ||
contractPackagesDir, | ||
root, | ||
dev, | ||
demos, | ||
contract, | ||
protocol, | ||
packages, | ||
config, | ||
scripts, | ||
protocolCli, | ||
protocolDist, | ||
clientExample, | ||
clientExampleServer, | ||
clientBundleExample, | ||
dappExample, | ||
common, | ||
api, | ||
cli, | ||
util, | ||
database, | ||
datasets, | ||
datasetsFs, | ||
env, | ||
fileServer, | ||
procaptcha, | ||
procaptchaReact, | ||
procaptchaBundle, | ||
provider, | ||
server, | ||
typesDatabase, | ||
typesEnv, | ||
types, | ||
} | ||
return fs.readdirSync(getProtocolContractsDir()).filter((name) => { | ||
// test is dir | ||
return fs.statSync(`${getProtocolContractsDir()}/${name}`).isDirectory() | ||
}) | ||
} | ||
|
||
export const getRootDir = () => { | ||
return new URL('../../..', import.meta.url).pathname.slice(0, -1) | ||
} | ||
|
||
export const getDevDir = () => { | ||
return `${getRootDir()}/dev` | ||
} | ||
|
||
export const getDemosDir = () => { | ||
return `${getRootDir()}/demos` | ||
} | ||
|
||
export const getContractDir = () => { | ||
return `${getRootDir()}/packages/contract` | ||
} | ||
|
||
export const getProtocolDir = () => { | ||
return `${getRootDir()}/protocol` | ||
} | ||
|
||
export const getPackagesDir = () => { | ||
return `${getRootDir()}/packages` | ||
} | ||
|
||
export const getConfigPkgDir = () => { | ||
return `${getDevDir()}/config` | ||
} | ||
|
||
export const getScriptsPkgDir = () => { | ||
return `${getDevDir()}/scripts` | ||
} | ||
|
||
export const getProtocolCliDir = () => { | ||
return `${getProtocolDir()}/dist/cli` | ||
} | ||
|
||
export const getProtocolDistDir = () => { | ||
return `${getProtocolDir()}/target/ink` | ||
} | ||
|
||
export const getClientExampleDir = () => { | ||
return `${getDemosDir()}/client-example` | ||
} | ||
|
||
export const getClientExampleServerDir = () => { | ||
return `${getDemosDir()}/client-example-server` | ||
} | ||
|
||
export const getClientBundleExampleDir = () => { | ||
return `${getDemosDir()}/client-bundle-example` | ||
} | ||
|
||
export const getDappExampleDir = () => { | ||
return `${getDemosDir()}/dapp-example` | ||
} | ||
|
||
export const getCommonPkgDir = () => { | ||
return `${getPackagesDir()}/common` | ||
} | ||
|
||
export const getApiPkgDir = () => { | ||
return `${getPackagesDir()}/api` | ||
} | ||
|
||
export const getCliPkgDir = () => { | ||
return `${getPackagesDir()}/cli` | ||
} | ||
|
||
export const getUtilPkgDir = () => { | ||
return `${getPackagesDir()}/util` | ||
} | ||
|
||
export const getDatabasePkgDir = () => { | ||
return `${getPackagesDir()}/database` | ||
} | ||
|
||
export const getDatasetsPkgDir = () => { | ||
return `${getPackagesDir()}/datasets` | ||
} | ||
|
||
export const getDatasetsFsPkgDir = () => { | ||
return `${getPackagesDir()}/datasets-fs` | ||
} | ||
|
||
export const getEnvPkgDir = () => { | ||
return `${getPackagesDir()}/env` | ||
} | ||
|
||
export const getFileServerPkgDir = () => { | ||
return `${getPackagesDir()}/file-server` | ||
} | ||
|
||
export const getProcaptchaPkgDir = () => { | ||
return `${getPackagesDir()}/procaptcha` | ||
} | ||
|
||
export const getProcaptchaReactPkgDir = () => { | ||
return `${getPackagesDir()}/procaptcha-react` | ||
} | ||
|
||
export const getProcaptchaBundlePkgDir = () => { | ||
return `${getPackagesDir()}/procaptcha-bundle` | ||
} | ||
|
||
export const getProviderPkgDir = () => { | ||
return `${getPackagesDir()}/provider` | ||
} | ||
|
||
export const getServerPkgDir = () => { | ||
return `${getPackagesDir()}/server` | ||
} | ||
|
||
export const getTypesDatabasePkgDir = () => { | ||
return `${getPackagesDir()}/types-database` | ||
} | ||
|
||
export const getTypesEnvPkgDir = () => { | ||
return `${getPackagesDir()}/types-env` | ||
} | ||
|
||
export const getTypesPkgDir = () => { | ||
return `${getPackagesDir()}/types` | ||
} | ||
|
||
export const getContractsDir = () => { | ||
return `${getRootDir()}/contracts` | ||
} | ||
|
||
export const getProtocolContractsDir = () => { | ||
return `${getProtocolDir()}/contracts` | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters