@aex.is/zero 0.1.13 → 0.1.15

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.
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -1,5 +1,5 @@
1
1
  import path from 'path';
2
- import { promises as fs } from 'fs';
2
+ import { constants as fsConstants, promises as fs } from 'fs';
3
3
  import { execa } from 'execa';
4
4
  import { getFrameworkDefinition } from '../config/frameworks.js';
5
5
  import { getBaseEnvHelp } from '../config/base-env.js';
@@ -65,6 +65,7 @@ async function ensureEmptyTargetDir(targetDir) {
65
65
  if (!stat.isDirectory()) {
66
66
  throw new Error('Target path exists and is not a directory.');
67
67
  }
68
+ await assertWritable(targetDir);
68
69
  const entries = await fs.readdir(targetDir);
69
70
  const allowed = new Set(['.git', '.gitignore', '.gitkeep']);
70
71
  const remaining = entries.filter((entry) => !allowed.has(entry));
@@ -74,11 +75,32 @@ async function ensureEmptyTargetDir(targetDir) {
74
75
  }
75
76
  catch (error) {
76
77
  if (isErrnoException(error) && error.code === 'ENOENT') {
77
- return;
78
+ try {
79
+ await fs.mkdir(targetDir, { recursive: true });
80
+ await assertWritable(targetDir);
81
+ return;
82
+ }
83
+ catch (createError) {
84
+ if (isErrnoException(createError) && (createError.code === 'EACCES' || createError.code === 'EPERM')) {
85
+ throw new Error('Cannot create target directory. Check your permissions and try again.');
86
+ }
87
+ throw createError;
88
+ }
89
+ }
90
+ if (isErrnoException(error) && (error.code === 'EACCES' || error.code === 'EPERM')) {
91
+ throw new Error('Target directory is not writable. Check your permissions and try again.');
78
92
  }
79
93
  throw error;
80
94
  }
81
95
  }
96
+ async function assertWritable(targetDir) {
97
+ try {
98
+ await fs.access(targetDir, fsConstants.W_OK);
99
+ }
100
+ catch {
101
+ throw new Error('Target directory is not writable. Check your permissions and try again.');
102
+ }
103
+ }
82
104
  async function runScaffoldCommand(runner, packageName, directoryInput, argSets) {
83
105
  const errors = [];
84
106
  const targetArg = directoryInput === '.' ? '.' : directoryInput;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aex.is/zero",
3
- "version": "0.1.13",
3
+ "version": "0.1.15",
4
4
  "description": "Aexis Zero scaffolding CLI",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",