@chargebee/chargebee-apps-shared 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +24 -0
- package/README.md +73 -0
- package/SECURITY.md +8 -0
- package/dist/config/environment.d.ts +78 -0
- package/dist/config/environment.js +150 -0
- package/dist/config/path-resolver.d.ts +117 -0
- package/dist/config/path-resolver.js +247 -0
- package/dist/dependency/dependency-manager.d.ts +66 -0
- package/dist/dependency/dependency-manager.js +257 -0
- package/dist/errors.d.ts +8 -0
- package/dist/errors.js +17 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +36 -0
- package/dist/libs/archive-service.d.ts +21 -0
- package/dist/libs/archive-service.js +145 -0
- package/dist/libs/file-management-service.d.ts +59 -0
- package/dist/libs/file-management-service.js +189 -0
- package/dist/libs/iparams-service.d.ts +69 -0
- package/dist/libs/iparams-service.js +136 -0
- package/dist/libs/template-service.d.ts +57 -0
- package/dist/libs/template-service.js +152 -0
- package/dist/logger/cb-logger.d.ts +56 -0
- package/dist/logger/cb-logger.js +13 -0
- package/dist/logger/internal-logger.d.ts +81 -0
- package/dist/logger/internal-logger.js +146 -0
- package/dist/node/file-system.d.ts +66 -0
- package/dist/node/file-system.js +76 -0
- package/dist/node/process.d.ts +30 -0
- package/dist/node/process.js +25 -0
- package/dist/sandbox/sandbox-context.d.ts +37 -0
- package/dist/sandbox/sandbox-context.js +48 -0
- package/dist/sandbox/sandbox-wrapper.d.ts +75 -0
- package/dist/sandbox/sandbox-wrapper.js +2 -0
- package/dist/types/common.d.ts +135 -0
- package/dist/types/common.js +20 -0
- package/dist/validator/iparam-constants.d.ts +49 -0
- package/dist/validator/iparam-constants.js +52 -0
- package/dist/validator/iparam-defns-validator.d.ts +46 -0
- package/dist/validator/iparam-defns-validator.js +291 -0
- package/dist/validator/iparams-inputs-validator.d.ts +62 -0
- package/dist/validator/iparams-inputs-validator.js +289 -0
- package/dist/validator/manifest-validator.d.ts +48 -0
- package/dist/validator/manifest-validator.js +138 -0
- package/dist/validator/package-validator.d.ts +27 -0
- package/dist/validator/package-validator.js +43 -0
- package/dist/validator/validator-utils.d.ts +13 -0
- package/dist/validator/validator-utils.js +26 -0
- package/package.json +45 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
The MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2011-2024 Chargebee, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person
|
|
6
|
+
obtaining a copy of this software and associated documentation
|
|
7
|
+
files (the "Software"), to deal in the Software without
|
|
8
|
+
restriction, including without limitation the rights to use,
|
|
9
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the
|
|
11
|
+
Software is furnished to do so, subject to the following
|
|
12
|
+
conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be
|
|
15
|
+
included in all copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
18
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
19
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
20
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
21
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
22
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
23
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
24
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# @chargebee/chargebee-apps-shared
|
|
2
|
+
|
|
3
|
+
Shared interfaces, types, and utilities for the Chargebee Apps CLI ecosystem.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @chargebee/chargebee-apps-shared
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
This package is typically installed as a dependency of [`@chargebee/chargebee-apps`](https://www.npmjs.com/package/@chargebee/chargebee-apps) or [`@chargebee/chargebee-apps-libs`](https://www.npmjs.com/package/@chargebee/chargebee-apps-libs).
|
|
12
|
+
|
|
13
|
+
## Overview
|
|
14
|
+
|
|
15
|
+
Provides the common building blocks used across Chargebee Apps packages:
|
|
16
|
+
|
|
17
|
+
- **Configuration** — environment detection and path resolution
|
|
18
|
+
- **Dependency management** — isolated npm installs and secure module loading
|
|
19
|
+
- **Validation** — manifest, package, and iparams validation
|
|
20
|
+
- **File and archive services** — packaging and file operations
|
|
21
|
+
- **Logging** — standardized logging interfaces
|
|
22
|
+
- **Sandbox** — secure code execution contracts
|
|
23
|
+
- **Types** — shared event, manifest, and handler types
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import {
|
|
29
|
+
DependencyManager,
|
|
30
|
+
ManifestValidator,
|
|
31
|
+
PathResolver,
|
|
32
|
+
EnvironmentConfig,
|
|
33
|
+
CBFileSystem,
|
|
34
|
+
CBProcess,
|
|
35
|
+
} from '@chargebee/chargebee-apps-shared';
|
|
36
|
+
|
|
37
|
+
const envConfig = new EnvironmentConfig();
|
|
38
|
+
const pathResolver = new PathResolver();
|
|
39
|
+
|
|
40
|
+
const fileSystem = new CBFileSystem();
|
|
41
|
+
const dependencyManager = new DependencyManager(fileSystem);
|
|
42
|
+
|
|
43
|
+
const allowedModules = [{ name: 'lodash', version: '^4.17.21' }];
|
|
44
|
+
const validator = new ManifestValidator(allowedModules);
|
|
45
|
+
const manifest = validator.validateFile('./my-app/manifest.json');
|
|
46
|
+
|
|
47
|
+
await dependencyManager.ensureDependencies('./my-app', manifest);
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Main exports
|
|
51
|
+
|
|
52
|
+
| Export | Purpose |
|
|
53
|
+
|--------|---------|
|
|
54
|
+
| `EnvironmentConfig` | Detect development vs production runtime |
|
|
55
|
+
| `PathResolver` | Resolve CLI and package paths |
|
|
56
|
+
| `DependencyManager` | Install and load app dependencies safely |
|
|
57
|
+
| `ManifestValidator` | Validate `manifest.json` |
|
|
58
|
+
| `PackageValidator` | Validate app package structure |
|
|
59
|
+
| `ArchiveService` | Create and extract zip packages |
|
|
60
|
+
| `TemplateService` | Copy app templates |
|
|
61
|
+
| `FileManagementService` | Collect files for packaging |
|
|
62
|
+
| `IparamsService` | Load and validate iparams |
|
|
63
|
+
| `CBFileSystem` / `CBProcess` | File and process abstractions |
|
|
64
|
+
| `sandboxContext` | Correlate sandbox execution context |
|
|
65
|
+
|
|
66
|
+
## Related packages
|
|
67
|
+
|
|
68
|
+
- [`@chargebee/chargebee-apps`](https://www.npmjs.com/package/@chargebee/chargebee-apps) — CLI for creating, running, and packaging apps
|
|
69
|
+
- [`@chargebee/chargebee-apps-libs`](https://www.npmjs.com/package/@chargebee/chargebee-apps-libs) — library implementations and templates
|
|
70
|
+
|
|
71
|
+
## License
|
|
72
|
+
|
|
73
|
+
MIT
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
At Chargebee, we take data integrity and security very seriously. Due to the nature of the product and service we provide, we are committed to working with individuals to stay updated on the latest security techniques and fix any security weakness in our application or infrastructure reported to us responsibly by external parties.
|
|
4
|
+
|
|
5
|
+
https://www.chargebee.com/security/responsible-disclosure-policy/
|
|
6
|
+
|
|
7
|
+
## Reporting a vulnerability
|
|
8
|
+
Reach out to us at security@chargebee.com. Please do not open GitHub issues or pull requests as this makes the problem immediately visible to everyone, including malicious actors. Chargebee's security team will triage your report and respond according to its impact.
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Environment type enum
|
|
3
|
+
*/
|
|
4
|
+
export declare enum EnvironmentType {
|
|
5
|
+
DEVELOPMENT = "development",
|
|
6
|
+
PRODUCTION = "production"
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Environment configuration interface
|
|
10
|
+
*/
|
|
11
|
+
export interface IEnvironmentConfig {
|
|
12
|
+
/**
|
|
13
|
+
* Get the current environment type
|
|
14
|
+
* @returns {EnvironmentType} The current environment
|
|
15
|
+
*/
|
|
16
|
+
getEnvironment(): EnvironmentType;
|
|
17
|
+
/**
|
|
18
|
+
* Check if running in development mode
|
|
19
|
+
* @returns {boolean} True if in development mode
|
|
20
|
+
*/
|
|
21
|
+
isDevelopment(): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Check if running in production mode
|
|
24
|
+
* @returns {boolean} True if in production mode
|
|
25
|
+
*/
|
|
26
|
+
isProduction(): boolean;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Environment configuration class that detects the current environment
|
|
30
|
+
* @class EnvironmentConfig
|
|
31
|
+
* @implements {IEnvironmentConfig}
|
|
32
|
+
*
|
|
33
|
+
* @description
|
|
34
|
+
* This class provides environment detection based on multiple indicators:
|
|
35
|
+
* 1. NODE_ENV environment variable
|
|
36
|
+
* 2. Presence of workspace structure (workspaces field in package.json)
|
|
37
|
+
* 3. Module resolution capability (can resolve published packages)
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* const envConfig = new EnvironmentConfig();
|
|
42
|
+
* if (envConfig.isDevelopment()) {
|
|
43
|
+
* console.log('Running in development mode');
|
|
44
|
+
* }
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare class EnvironmentConfig implements IEnvironmentConfig {
|
|
48
|
+
private environment;
|
|
49
|
+
constructor();
|
|
50
|
+
/**
|
|
51
|
+
* Detects the current environment based on various indicators
|
|
52
|
+
* @returns {EnvironmentType} The detected environment type
|
|
53
|
+
* @private
|
|
54
|
+
*/
|
|
55
|
+
private detectEnvironment;
|
|
56
|
+
/**
|
|
57
|
+
* Finds the project root by traversing up the directory tree
|
|
58
|
+
* @param {string} startDir - Directory to start searching from
|
|
59
|
+
* @returns {string | null} Path to project root or null if not found
|
|
60
|
+
* @private
|
|
61
|
+
*/
|
|
62
|
+
private findProjectRoot;
|
|
63
|
+
/**
|
|
64
|
+
* Gets the current environment type
|
|
65
|
+
* @returns {EnvironmentType} The current environment
|
|
66
|
+
*/
|
|
67
|
+
getEnvironment(): EnvironmentType;
|
|
68
|
+
/**
|
|
69
|
+
* Checks if running in development mode
|
|
70
|
+
* @returns {boolean} True if in development mode
|
|
71
|
+
*/
|
|
72
|
+
isDevelopment(): boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Checks if running in production mode
|
|
75
|
+
* @returns {boolean} True if in production mode
|
|
76
|
+
*/
|
|
77
|
+
isProduction(): boolean;
|
|
78
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.EnvironmentConfig = exports.EnvironmentType = void 0;
|
|
40
|
+
const path_1 = __importDefault(require("path"));
|
|
41
|
+
const fs = __importStar(require("fs"));
|
|
42
|
+
/**
|
|
43
|
+
* Environment type enum
|
|
44
|
+
*/
|
|
45
|
+
var EnvironmentType;
|
|
46
|
+
(function (EnvironmentType) {
|
|
47
|
+
EnvironmentType["DEVELOPMENT"] = "development";
|
|
48
|
+
EnvironmentType["PRODUCTION"] = "production";
|
|
49
|
+
})(EnvironmentType || (exports.EnvironmentType = EnvironmentType = {}));
|
|
50
|
+
/**
|
|
51
|
+
* Environment configuration class that detects the current environment
|
|
52
|
+
* @class EnvironmentConfig
|
|
53
|
+
* @implements {IEnvironmentConfig}
|
|
54
|
+
*
|
|
55
|
+
* @description
|
|
56
|
+
* This class provides environment detection based on multiple indicators:
|
|
57
|
+
* 1. NODE_ENV environment variable
|
|
58
|
+
* 2. Presence of workspace structure (workspaces field in package.json)
|
|
59
|
+
* 3. Module resolution capability (can resolve published packages)
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```typescript
|
|
63
|
+
* const envConfig = new EnvironmentConfig();
|
|
64
|
+
* if (envConfig.isDevelopment()) {
|
|
65
|
+
* console.log('Running in development mode');
|
|
66
|
+
* }
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
class EnvironmentConfig {
|
|
70
|
+
constructor() {
|
|
71
|
+
this.environment = this.detectEnvironment();
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Detects the current environment based on various indicators
|
|
75
|
+
* @returns {EnvironmentType} The detected environment type
|
|
76
|
+
* @private
|
|
77
|
+
*/
|
|
78
|
+
detectEnvironment() {
|
|
79
|
+
// Check NODE_ENV first
|
|
80
|
+
const nodeEnv = process.env['NODE_ENV']?.toLowerCase();
|
|
81
|
+
if (nodeEnv === 'production') {
|
|
82
|
+
return EnvironmentType.PRODUCTION;
|
|
83
|
+
}
|
|
84
|
+
if (nodeEnv === 'development') {
|
|
85
|
+
return EnvironmentType.DEVELOPMENT;
|
|
86
|
+
}
|
|
87
|
+
// If NODE_ENV is not set, detect based on workspace structure
|
|
88
|
+
// In development, we should be in a monorepo with workspaces
|
|
89
|
+
// In production, packages are published and installed independently
|
|
90
|
+
try {
|
|
91
|
+
const currentDir = __dirname;
|
|
92
|
+
const projectRoot = this.findProjectRoot(currentDir);
|
|
93
|
+
if (projectRoot) {
|
|
94
|
+
const packageJsonPath = path_1.default.join(projectRoot, 'package.json');
|
|
95
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
96
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
97
|
+
// If workspaces field exists, we're in development
|
|
98
|
+
if (packageJson.workspaces) {
|
|
99
|
+
return EnvironmentType.DEVELOPMENT;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
// If we can't find workspace structure, assume production
|
|
106
|
+
}
|
|
107
|
+
// Default to production if we can't determine
|
|
108
|
+
return EnvironmentType.PRODUCTION;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Finds the project root by traversing up the directory tree
|
|
112
|
+
* @param {string} startDir - Directory to start searching from
|
|
113
|
+
* @returns {string | null} Path to project root or null if not found
|
|
114
|
+
* @private
|
|
115
|
+
*/
|
|
116
|
+
findProjectRoot(startDir) {
|
|
117
|
+
let currentDir = startDir;
|
|
118
|
+
const root = path_1.default.parse(currentDir).root;
|
|
119
|
+
while (currentDir !== root) {
|
|
120
|
+
const packageJsonPath = path_1.default.join(currentDir, 'package.json');
|
|
121
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
122
|
+
return currentDir;
|
|
123
|
+
}
|
|
124
|
+
currentDir = path_1.default.dirname(currentDir);
|
|
125
|
+
}
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Gets the current environment type
|
|
130
|
+
* @returns {EnvironmentType} The current environment
|
|
131
|
+
*/
|
|
132
|
+
getEnvironment() {
|
|
133
|
+
return this.environment;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Checks if running in development mode
|
|
137
|
+
* @returns {boolean} True if in development mode
|
|
138
|
+
*/
|
|
139
|
+
isDevelopment() {
|
|
140
|
+
return this.environment === EnvironmentType.DEVELOPMENT;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Checks if running in production mode
|
|
144
|
+
* @returns {boolean} True if in production mode
|
|
145
|
+
*/
|
|
146
|
+
isProduction() {
|
|
147
|
+
return this.environment === EnvironmentType.PRODUCTION;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
exports.EnvironmentConfig = EnvironmentConfig;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { IEnvironmentConfig } from './environment';
|
|
2
|
+
/**
|
|
3
|
+
* Path type enum for different package paths
|
|
4
|
+
*/
|
|
5
|
+
export declare enum PathType {
|
|
6
|
+
/** Root directory of the CLI workspace */
|
|
7
|
+
CLI_ROOT = "CLI_ROOT",
|
|
8
|
+
/** Private application distribution directory */
|
|
9
|
+
PRIVATE_APP_DIST = "PRIVATE_APP_DIST",
|
|
10
|
+
/** Private application root directory */
|
|
11
|
+
PRIVATE_APP_ROOT = "PRIVATE_APP_ROOT",
|
|
12
|
+
/** Public libs templates directory */
|
|
13
|
+
PUBLIC_LIBS_TEMPLATES = "PUBLIC_LIBS_TEMPLATES",
|
|
14
|
+
/** Public libs UI web directory */
|
|
15
|
+
PUBLIC_LIBS_UI_WEB = "PUBLIC_LIBS_UI_WEB"
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Path resolver interface
|
|
19
|
+
*/
|
|
20
|
+
export interface IPathResolver {
|
|
21
|
+
/**
|
|
22
|
+
* Resolves a path based on the current environment
|
|
23
|
+
* @param {PathType} pathType - Type of path to resolve
|
|
24
|
+
* @returns {string} Resolved path
|
|
25
|
+
*/
|
|
26
|
+
resolvePath(pathType: PathType): string;
|
|
27
|
+
/**
|
|
28
|
+
* Gets the CLI workspace root path
|
|
29
|
+
* @returns {string} Path to CLI workspace root
|
|
30
|
+
*/
|
|
31
|
+
getCliRoot(): string;
|
|
32
|
+
/**
|
|
33
|
+
* Gets the private application distribution directory path
|
|
34
|
+
* @returns {string} Path to private application dist directory
|
|
35
|
+
*/
|
|
36
|
+
getPrivateAppDistDir(): string;
|
|
37
|
+
/**
|
|
38
|
+
* Gets the private application root directory path
|
|
39
|
+
* @returns {string} Path to private application root directory
|
|
40
|
+
*/
|
|
41
|
+
getPrivateAppRootDir(): string;
|
|
42
|
+
/**
|
|
43
|
+
* Gets the public libs templates directory path
|
|
44
|
+
* @returns {string} Path to public libs templates directory
|
|
45
|
+
*/
|
|
46
|
+
getPublicLibsTemplatesDir(): string;
|
|
47
|
+
/**
|
|
48
|
+
* Gets the public libs UI web directory path
|
|
49
|
+
* @returns {string} Path to public libs UI web directory
|
|
50
|
+
*/
|
|
51
|
+
getPublicLibsUiWebDir(): string;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Path resolver class for resolving paths based on environment
|
|
55
|
+
* @class PathResolver
|
|
56
|
+
* @implements {IPathResolver}
|
|
57
|
+
*
|
|
58
|
+
* @description
|
|
59
|
+
* This class provides centralized path resolution for all packages in the CLI.
|
|
60
|
+
* It detects the environment (development vs production) and resolves paths accordingly:
|
|
61
|
+
* - In development: Uses workspace-relative paths
|
|
62
|
+
* - In production: Uses require.resolve to find installed packages
|
|
63
|
+
*
|
|
64
|
+
* This eliminates the need for try-catch error handling scattered across the codebase.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```typescript
|
|
68
|
+
* const pathResolver = new PathResolver();
|
|
69
|
+
* const templatesDir = pathResolver.getPublicLibsTemplatesDir();
|
|
70
|
+
* console.log(`Templates directory: ${templatesDir}`);
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export declare class PathResolver implements IPathResolver {
|
|
74
|
+
private envConfig;
|
|
75
|
+
private cliRoot;
|
|
76
|
+
constructor(envConfig?: IEnvironmentConfig);
|
|
77
|
+
/**
|
|
78
|
+
* Resolves a path based on the path type and environment
|
|
79
|
+
* @param {PathType} pathType - Type of path to resolve
|
|
80
|
+
* @returns {string} Resolved path
|
|
81
|
+
* @throws {Error} If path cannot be resolved
|
|
82
|
+
*/
|
|
83
|
+
resolvePath(pathType: PathType): string;
|
|
84
|
+
/**
|
|
85
|
+
* Gets the CLI workspace root path
|
|
86
|
+
* @returns {string} Path to CLI workspace root
|
|
87
|
+
*/
|
|
88
|
+
getCliRoot(): string;
|
|
89
|
+
/**
|
|
90
|
+
* Gets the private application distribution directory path
|
|
91
|
+
* @returns {string} Path to private application dist directory
|
|
92
|
+
*/
|
|
93
|
+
getPrivateAppDistDir(): string;
|
|
94
|
+
/**
|
|
95
|
+
* Gets the private application root directory path
|
|
96
|
+
* @returns {string} Path to private application root directory
|
|
97
|
+
*/
|
|
98
|
+
getPrivateAppRootDir(): string;
|
|
99
|
+
/**
|
|
100
|
+
* Gets the public libs templates directory path
|
|
101
|
+
* @returns {string} Path to public libs templates directory
|
|
102
|
+
*/
|
|
103
|
+
getPublicLibsTemplatesDir(): string;
|
|
104
|
+
/**
|
|
105
|
+
* Gets the public libs UI web directory path
|
|
106
|
+
* @returns {string} Path to public libs UI web directory
|
|
107
|
+
*/
|
|
108
|
+
getPublicLibsUiWebDir(): string;
|
|
109
|
+
/**
|
|
110
|
+
* Finds the project root by looking for package.json with workspaces
|
|
111
|
+
* @param {string} startDir - Directory to start searching from
|
|
112
|
+
* @returns {string} Path to project root
|
|
113
|
+
* @throws {Error} If project root cannot be found
|
|
114
|
+
* @private
|
|
115
|
+
*/
|
|
116
|
+
private findProjectRootWithWorkspaces;
|
|
117
|
+
}
|