@postxl/cli 1.0.9 → 1.0.11
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.
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import { ProjectSchemaName, ProjectSlug } from '@postxl/schema';
|
|
1
|
+
import { ProjectSchemaName, ProjectSlug, ProjectType } from '@postxl/schema';
|
|
2
2
|
import { ProjectPath } from '../create-project.command';
|
|
3
3
|
export type CreateProjectOptions = {
|
|
4
4
|
name: ProjectSchemaName;
|
|
5
5
|
slug: ProjectSlug;
|
|
6
6
|
schema: object & {
|
|
7
|
-
projectType?:
|
|
8
|
-
kind: string;
|
|
9
|
-
};
|
|
7
|
+
projectType?: ProjectType;
|
|
10
8
|
};
|
|
11
9
|
projectPath: ProjectPath;
|
|
12
10
|
};
|
|
@@ -136,10 +136,7 @@ async function createProject(options) {
|
|
|
136
136
|
...schema,
|
|
137
137
|
name,
|
|
138
138
|
slug,
|
|
139
|
-
projectType:
|
|
140
|
-
kind: projectPath.kind,
|
|
141
|
-
projectDirectory: projectPath.projectGenerationPath,
|
|
142
|
-
},
|
|
139
|
+
projectType: projectPath.kind,
|
|
143
140
|
};
|
|
144
141
|
// Write source files directly to disk (not tracked as generated files)
|
|
145
142
|
// These are the files that define the project, not generated output
|
package/dist/generate.command.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
if (projectType
|
|
258
|
+
if (projectType === '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, '
|
|
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.
|
|
3
|
+
"version": "1.0.11",
|
|
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,9 @@
|
|
|
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.
|
|
48
|
-
"@postxl/generators": "^1.0.
|
|
49
|
-
"@postxl/schema": "^1.0.
|
|
47
|
+
"@postxl/generator": "^1.0.6",
|
|
48
|
+
"@postxl/generators": "^1.0.8",
|
|
49
|
+
"@postxl/schema": "^1.0.2",
|
|
50
50
|
"@postxl/utils": "^1.0.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {},
|