@postxl/cli 1.0.8 → 1.0.10

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.
@@ -38,9 +38,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.register = register;
40
40
  const child_process_1 = require("child_process");
41
- const fs = __importStar(require("fs/promises"));
42
41
  const util_1 = require("util");
43
42
  const dotenv_1 = __importDefault(require("dotenv"));
43
+ const fs = __importStar(require("node:fs/promises"));
44
44
  const path = __importStar(require("node:path"));
45
45
  const zod_validation_error_1 = require("zod-validation-error");
46
46
  const generator_1 = require("@postxl/generator");
@@ -78,7 +78,7 @@ This reads the schema from ${(0, utils_1.yellow)('schema.json')} and runs the ge
78
78
  const envConfig = dotenv_1.default.config({ path: path.join(projectPath, '.env') });
79
79
  const localGenerators = await getLocalGenerators({ program, projectPath });
80
80
  const schema = await getSchema({ program, projectPath });
81
- targetPath = resolveTargetPath({
81
+ targetPath = await resolveTargetPath({
82
82
  projectPath,
83
83
  targetPath,
84
84
  envTargetPath: process.env.PXL_PROJECT_PATH ?? envConfig.parsed?.PXL_PROJECT_PATH,
@@ -238,15 +238,32 @@ async function getSchema(params) {
238
238
  }
239
239
  return schema.data;
240
240
  }
241
- function resolveTargetPath({ projectPath, targetPath, envTargetPath, schemaSlug, projectType, }) {
241
+ /**
242
+ * Checks if the current projectPath is within the PostXL monorepo workspace
243
+ * by verifying if '../../packages/cli' exists relative to the project path.
244
+ */
245
+ async function isInPostxlWorkspace(projectPath) {
246
+ const cliPath = path.resolve(projectPath, '..', '..', 'packages', 'cli');
247
+ try {
248
+ await fs.access(cliPath);
249
+ return true;
250
+ }
251
+ catch {
252
+ return false;
253
+ }
254
+ }
255
+ async function resolveTargetPath({ projectPath, targetPath, envTargetPath, schemaSlug, projectType, }) {
242
256
  let resolved = targetPath ?? envTargetPath;
243
257
  if (!resolved) {
244
258
  if (projectType.kind === 'workspace') {
245
259
  resolved = projectPath;
246
260
  }
247
- else {
261
+ else if (await isInPostxlWorkspace(projectPath)) {
248
262
  const repositoryRoot = path.join(projectPath, '..', '..');
249
- resolved = path.resolve(repositoryRoot, '..', schemaSlug);
263
+ resolved = path.resolve(repositoryRoot, 'projects', schemaSlug);
264
+ }
265
+ else {
266
+ resolved = projectPath;
250
267
  }
251
268
  }
252
269
  if (resolved.startsWith('.') || !path.isAbsolute(resolved)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@postxl/cli",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
4
4
  "description": "Command-line interface for PostXL code generation framework",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -44,9 +44,10 @@
44
44
  "commander": "12.1.0",
45
45
  "dotenv": "16.4.7",
46
46
  "zod-validation-error": "3.4.0",
47
- "@postxl/generator": "^1.0.3",
48
- "@postxl/generators": "^1.0.3",
49
- "@postxl/schema": "^1.0.0"
47
+ "@postxl/generator": "^1.0.5",
48
+ "@postxl/generators": "^1.0.7",
49
+ "@postxl/schema": "^1.0.1",
50
+ "@postxl/utils": "^1.0.0"
50
51
  },
51
52
  "devDependencies": {},
52
53
  "wallaby": {