🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@chargebee/chargebee-apps-shared

Package Overview
Dependencies
Maintainers
4
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@chargebee/chargebee-apps-shared - npm Package Compare versions

Comparing version
0.0.3
to
0.0.4
+7
-72
dist/config/path-resolver.d.ts
import { IEnvironmentConfig } from './environment';
/**
* Path type enum for different package paths
* Path type enum for shared workspace paths
*/
export declare enum PathType {
/** Root directory of the CLI workspace */
CLI_ROOT = "CLI_ROOT",
/** Private application distribution directory */
PRIVATE_APP_DIST = "PRIVATE_APP_DIST",
/** Private application root directory */
PRIVATE_APP_ROOT = "PRIVATE_APP_ROOT",
/** Public libs templates directory */
PUBLIC_LIBS_TEMPLATES = "PUBLIC_LIBS_TEMPLATES",
/** Public libs UI web directory */
PUBLIC_LIBS_UI_WEB = "PUBLIC_LIBS_UI_WEB"
CLI_ROOT = "CLI_ROOT"
}
/**
* Path resolver interface
* Base path resolver interface for workspace root resolution
*/

@@ -32,45 +24,9 @@ export interface IPathResolver {

getCliRoot(): string;
/**
* Gets the private application distribution directory path
* @returns {string} Path to private application dist directory
*/
getPrivateAppDistDir(): string;
/**
* Gets the private application root directory path
* @returns {string} Path to private application root directory
*/
getPrivateAppRootDir(): string;
/**
* Gets the public libs templates directory path
* @returns {string} Path to public libs templates directory
*/
getPublicLibsTemplatesDir(): string;
/**
* Gets the public libs UI web directory path
* @returns {string} Path to public libs UI web directory
*/
getPublicLibsUiWebDir(): string;
}
/**
* Path resolver class for resolving paths based on environment
* @class PathResolver
* @implements {IPathResolver}
*
* @description
* This class provides centralized path resolution for all packages in the CLI.
* It detects the environment (development vs production) and resolves paths accordingly:
* - In development: Uses workspace-relative paths
* - In production: Uses require.resolve to find installed packages
*
* This eliminates the need for try-catch error handling scattered across the codebase.
*
* @example
* ```typescript
* const pathResolver = new PathResolver();
* const templatesDir = pathResolver.getPublicLibsTemplatesDir();
* console.log(`Templates directory: ${templatesDir}`);
* ```
* Base path resolver for workspace root resolution.
* Package-specific paths are resolved by extending this class in public-cli or private-cli.
*/
export declare class PathResolver implements IPathResolver {
private envConfig;
protected envConfig: IEnvironmentConfig;
private cliRoot;

@@ -91,22 +47,2 @@ constructor(envConfig?: IEnvironmentConfig);

/**
* Gets the private application distribution directory path
* @returns {string} Path to private application dist directory
*/
getPrivateAppDistDir(): string;
/**
* Gets the private application root directory path
* @returns {string} Path to private application root directory
*/
getPrivateAppRootDir(): string;
/**
* Gets the public libs templates directory path
* @returns {string} Path to public libs templates directory
*/
getPublicLibsTemplatesDir(): string;
/**
* Gets the public libs UI web directory path
* @returns {string} Path to public libs UI web directory
*/
getPublicLibsUiWebDir(): string;
/**
* Finds the project root by looking for package.json with workspaces

@@ -116,5 +52,4 @@ * @param {string} startDir - Directory to start searching from

* @throws {Error} If project root cannot be found
* @private
*/
private findProjectRootWithWorkspaces;
protected findProjectRootWithWorkspaces(startDir: string): string;
}
+1
-1

@@ -1,1 +0,1 @@

"use strict";var __createBinding=this&&this.__createBinding||(Object.create?(function(r,e,t,i){i===void 0&&(i=t);var a=Object.getOwnPropertyDescriptor(e,t);(!a||("get"in a?!e.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(r,i,a)}):(function(r,e,t,i){i===void 0&&(i=t),r[i]=e[t]})),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?(function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}):function(r,e){r.default=e}),__importStar=this&&this.__importStar||(function(){var r=function(e){return r=Object.getOwnPropertyNames||function(t){var i=[];for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(i[i.length]=a);return i},r(e)};return function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var i=r(e),a=0;a<i.length;a++)i[a]!=="default"&&__createBinding(t,e,i[a]);return __setModuleDefault(t,e),t}})(),__importDefault=this&&this.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.PathResolver=exports.PathType=void 0;const path_1=__importDefault(require("path")),fs=__importStar(require("fs")),environment_1=require("./environment");var PathType;(function(r){r.CLI_ROOT="CLI_ROOT",r.PRIVATE_APP_DIST="PRIVATE_APP_DIST",r.PRIVATE_APP_ROOT="PRIVATE_APP_ROOT",r.PUBLIC_LIBS_TEMPLATES="PUBLIC_LIBS_TEMPLATES",r.PUBLIC_LIBS_UI_WEB="PUBLIC_LIBS_UI_WEB"})(PathType||(exports.PathType=PathType={}));class PathResolver{constructor(e){this.cliRoot=null,this.envConfig=e||new environment_1.EnvironmentConfig}resolvePath(e){switch(e){case PathType.CLI_ROOT:return this.getCliRoot();case PathType.PRIVATE_APP_DIST:return this.getPrivateAppDistDir();case PathType.PRIVATE_APP_ROOT:return this.getPrivateAppRootDir();case PathType.PUBLIC_LIBS_TEMPLATES:return this.getPublicLibsTemplatesDir();case PathType.PUBLIC_LIBS_UI_WEB:return this.getPublicLibsUiWebDir();default:throw new Error(`Unknown path type: ${e}`)}}getCliRoot(){return this.cliRoot?this.cliRoot:(this.envConfig.isDevelopment()?this.cliRoot=this.findProjectRootWithWorkspaces(__dirname):this.cliRoot=path_1.default.resolve(__dirname,"../.."),this.cliRoot)}getPrivateAppDistDir(){if(this.envConfig.isDevelopment()){const e=this.getCliRoot();return path_1.default.join(e,"packages","private-application","dist")}else try{const e=require.resolve("@chargebee-private/chargebee-apps-private-application");return path_1.default.dirname(e)}catch{throw new Error("Failed to resolve private-application path. Ensure @chargebee-private/chargebee-apps-private-application is installed.")}}getPrivateAppRootDir(){if(this.envConfig.isDevelopment()){const e=this.getCliRoot();return path_1.default.join(e,"packages","private-application")}else try{const e=require.resolve("@chargebee-private/chargebee-apps-private-application/package.json");return path_1.default.dirname(e)}catch{throw new Error("Failed to resolve private-application root path. Ensure @chargebee-private/chargebee-apps-private-application is installed.")}}getPublicLibsTemplatesDir(){if(this.envConfig.isDevelopment()){const e=this.getCliRoot();return path_1.default.join(e,"packages","public-libs","templates")}else try{const e=require.resolve("@chargebee/chargebee-apps-libs"),t=path_1.default.dirname(path_1.default.dirname(e));return path_1.default.join(t,"templates")}catch{throw new Error("Failed to resolve public-libs templates path. Ensure @chargebee/chargebee-apps-libs is installed.")}}getPublicLibsUiWebDir(){if(this.envConfig.isDevelopment()){const e=this.getCliRoot();return path_1.default.join(e,"packages","public-libs","ui","web")}else try{const e=require.resolve("@chargebee/chargebee-apps-libs"),t=path_1.default.dirname(path_1.default.dirname(e));return path_1.default.join(t,"ui","web")}catch{throw new Error("Failed to resolve public-libs UI web path. Ensure @chargebee/chargebee-apps-libs is installed.")}}findProjectRootWithWorkspaces(e){let t=e;const i=path_1.default.parse(t).root;for(;t!==i;){const a=path_1.default.join(t,"package.json");if(fs.existsSync(a))try{if(JSON.parse(fs.readFileSync(a,"utf8")).workspaces)return t}catch{}const o=path_1.default.dirname(t);if(o===t)break;t=o}throw new Error("Could not find project root with workspaces")}}exports.PathResolver=PathResolver;
"use strict";var __createBinding=this&&this.__createBinding||(Object.create?(function(r,e,t,n){n===void 0&&(n=t);var o=Object.getOwnPropertyDescriptor(e,t);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(r,n,o)}):(function(r,e,t,n){n===void 0&&(n=t),r[n]=e[t]})),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?(function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}):function(r,e){r.default=e}),__importStar=this&&this.__importStar||(function(){var r=function(e){return r=Object.getOwnPropertyNames||function(t){var n=[];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(n[n.length]=o);return n},r(e)};return function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n=r(e),o=0;o<n.length;o++)n[o]!=="default"&&__createBinding(t,e,n[o]);return __setModuleDefault(t,e),t}})(),__importDefault=this&&this.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.PathResolver=exports.PathType=void 0;const path_1=__importDefault(require("path")),fs=__importStar(require("fs")),environment_1=require("./environment");var PathType;(function(r){r.CLI_ROOT="CLI_ROOT"})(PathType||(exports.PathType=PathType={}));class PathResolver{constructor(e){this.cliRoot=null,this.envConfig=e||new environment_1.EnvironmentConfig}resolvePath(e){if(e===PathType.CLI_ROOT)return this.getCliRoot();throw new Error(`Unknown path type: ${e}`)}getCliRoot(){return this.cliRoot?this.cliRoot:(this.envConfig.isDevelopment()?this.cliRoot=this.findProjectRootWithWorkspaces(__dirname):this.cliRoot=path_1.default.resolve(__dirname,"../.."),this.cliRoot)}findProjectRootWithWorkspaces(e){let t=e;const n=path_1.default.parse(t).root;for(;t!==n;){const o=path_1.default.join(t,"package.json");if(fs.existsSync(o))try{if(JSON.parse(fs.readFileSync(o,"utf8")).workspaces)return t}catch{}const i=path_1.default.dirname(t);if(i===t)break;t=i}throw new Error("Could not find project root with workspaces")}}exports.PathResolver=PathResolver;

@@ -35,2 +35,5 @@ /**

export interface Manifest {
name?: string;
description?: string;
github_url?: string;
events: Record<string, {

@@ -37,0 +40,0 @@ handler: string;

{
"name": "@chargebee/chargebee-apps-shared",
"version": "0.0.3",
"version": "0.0.4",
"description": "Shared interfaces and utilities for Chargebee Apps CLI",

@@ -5,0 +5,0 @@ "main": "dist/index.js",