@postxl/cli 1.4.2 → 1.4.4

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.
@@ -160,14 +160,34 @@ async function resolveProjectPath({ slug, projectPath, }) {
160
160
  return projectGenerationPath;
161
161
  }
162
162
  async function createFolderOrThrow(targetPath) {
163
+ let stat;
163
164
  try {
164
- await fs.access(targetPath);
165
- console.error(`Target path "${targetPath}" already exists! Please choose a different path.`);
165
+ stat = await fs.stat(targetPath);
166
+ }
167
+ catch (error) {
168
+ if (error instanceof Error && 'code' in error && error.code === 'ENOENT') {
169
+ await fs.mkdir(targetPath, { recursive: true });
170
+ return;
171
+ }
172
+ console.error(`Cannot access target path "${targetPath}": ${error instanceof Error ? error.message : error}`);
173
+ process.exit(1);
174
+ }
175
+ if (!stat.isDirectory()) {
176
+ console.error(`Target path "${targetPath}" already exists and is not a directory! Please choose a different path.`);
166
177
  process.exit(1);
167
178
  }
168
- catch {
169
- // Path does not exist, create it
170
- await fs.mkdir(targetPath, { recursive: true });
179
+ try {
180
+ const entries = await fs.readdir(targetPath);
181
+ if (entries.length > 0) {
182
+ const hasOnlyHidden = entries.every((entry) => entry.startsWith('.'));
183
+ const hint = hasOnlyHidden ? ' (it contains hidden files/folders)' : '';
184
+ console.error(`Target path "${targetPath}" already exists and is not empty${hint}! Please choose a different path.`);
185
+ process.exit(1);
186
+ }
187
+ }
188
+ catch (error) {
189
+ console.error(`Cannot read target path "${targetPath}": ${error instanceof Error ? error.message : error}`);
190
+ process.exit(1);
171
191
  }
172
192
  }
173
193
  async function createProjectStructure({ name, slug, schema, projectPath, }) {
package/dist/index.js CHANGED
@@ -10,7 +10,7 @@ program
10
10
  //
11
11
  .name('pxl')
12
12
  .description('CLI for PostXL')
13
- .version('0.1.0');
13
+ .version('1.4.4');
14
14
  // Adding all the commands
15
15
  (0, generate_command_1.register)(program);
16
16
  (0, create_project_command_1.register)(program);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@postxl/cli",
3
- "version": "1.4.2",
3
+ "version": "1.4.4",
4
4
  "description": "Command-line interface for PostXL code generation framework",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -44,10 +44,10 @@
44
44
  "commander": "14.0.3",
45
45
  "dotenv": "17.3.1",
46
46
  "zod-validation-error": "5.0.0",
47
- "@postxl/generator": "^1.3.6",
48
- "@postxl/generators": "^1.19.0",
49
- "@postxl/schema": "^1.7.0",
50
- "@postxl/utils": "^1.3.4"
47
+ "@postxl/generator": "^1.3.7",
48
+ "@postxl/generators": "^1.21.0",
49
+ "@postxl/schema": "^1.8.0",
50
+ "@postxl/utils": "^1.4.0"
51
51
  },
52
52
  "devDependencies": {},
53
53
  "wallaby": {