diff options
Diffstat (limited to 'packages/monorepo-scripts/src/utils')
-rw-r--r-- | packages/monorepo-scripts/src/utils/configs.ts | 8 | ||||
-rw-r--r-- | packages/monorepo-scripts/src/utils/npm_utils.ts | 6 |
2 files changed, 11 insertions, 3 deletions
diff --git a/packages/monorepo-scripts/src/utils/configs.ts b/packages/monorepo-scripts/src/utils/configs.ts new file mode 100644 index 000000000..e579bdb7c --- /dev/null +++ b/packages/monorepo-scripts/src/utils/configs.ts @@ -0,0 +1,8 @@ +const IS_LOCAL_PUBLISH = process.env.IS_LOCAL_PUBLISH === 'true'; +const LOCAL_NPM_REGISTRY_URL = 'http://localhost:4873'; +const REMOTE_NPM_REGISTRY_URL = 'https://registry.npmjs.org'; + +export const configs = { + IS_LOCAL_PUBLISH, + NPM_REGISTRY_URL: IS_LOCAL_PUBLISH ? LOCAL_NPM_REGISTRY_URL : REMOTE_NPM_REGISTRY_URL, +}; diff --git a/packages/monorepo-scripts/src/utils/npm_utils.ts b/packages/monorepo-scripts/src/utils/npm_utils.ts index 7c8310459..9c8e51508 100644 --- a/packages/monorepo-scripts/src/utils/npm_utils.ts +++ b/packages/monorepo-scripts/src/utils/npm_utils.ts @@ -4,14 +4,14 @@ import * as _ from 'lodash'; import { PackageRegistryJson } from '../types'; -const lernaJson = JSON.parse(fs.readFileSync('lerna.json').toString()); -const NPM_REGISTRY_BASE_URL = lernaJson.registry; +import { configs } from './configs'; + const SUCCESS_STATUS = 200; const NOT_FOUND_STATUS = 404; export const npmUtils = { async getPackageRegistryJsonIfExistsAsync(packageName: string): Promise<PackageRegistryJson | undefined> { - const url = `${NPM_REGISTRY_BASE_URL}/${packageName}`; + const url = `${configs.NPM_REGISTRY_URL}/${packageName}`; const response = await fetch(url); if (response.status === NOT_FOUND_STATUS) { |