pika-ux 1.0.0-beta.5 → 1.0.0-beta.7
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/dist/cli/index.js +37 -9
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -67,8 +67,10 @@ async function validatePnpm() {
|
|
|
67
67
|
logger.error("pnpm is not installed.");
|
|
68
68
|
logger.info("Please install pnpm:");
|
|
69
69
|
console.log(" npm install -g pnpm");
|
|
70
|
-
console.log(" # or");
|
|
70
|
+
console.log(" # or (Unix/Mac):");
|
|
71
71
|
console.log(" curl -fsSL https://get.pnpm.io/install.sh | sh -");
|
|
72
|
+
console.log(" # or (Windows):");
|
|
73
|
+
console.log(" iwr https://get.pnpm.io/install.ps1 -useb | iex");
|
|
72
74
|
process.exit(1);
|
|
73
75
|
}
|
|
74
76
|
}
|
|
@@ -101,15 +103,34 @@ function toHumanReadable(projectName) {
|
|
|
101
103
|
return parts.map((part) => part.charAt(0).toUpperCase() + part.slice(1).toLowerCase()).join(" ");
|
|
102
104
|
}
|
|
103
105
|
async function processTemplateFiles(sourceDir, targetDir, variables) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
106
|
+
logger.debug(`Processing template files from: ${sourceDir}`);
|
|
107
|
+
logger.debug(`Target directory: ${targetDir}`);
|
|
108
|
+
let files;
|
|
109
|
+
try {
|
|
110
|
+
files = await glob("**/*", {
|
|
111
|
+
cwd: sourceDir,
|
|
112
|
+
dot: true,
|
|
113
|
+
nodir: true,
|
|
114
|
+
absolute: false
|
|
115
|
+
});
|
|
116
|
+
logger.debug(`Glob found ${files.length} files`);
|
|
117
|
+
} catch (error) {
|
|
118
|
+
logger.debug(`Glob error: ${error}`);
|
|
119
|
+
throw new Error(`Failed to read template directory: ${error}`);
|
|
120
|
+
}
|
|
121
|
+
if (files.length === 0) {
|
|
122
|
+
logger.warn(`No files found in template directory: ${sourceDir}`);
|
|
123
|
+
try {
|
|
124
|
+
const dirContents = await fs.readdir(sourceDir);
|
|
125
|
+
logger.debug(`Directory contents: ${dirContents.join(", ")}`);
|
|
126
|
+
} catch (e) {
|
|
127
|
+
logger.debug(`Could not read directory: ${e}`);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
110
130
|
for (const file of files) {
|
|
111
131
|
const sourcePath = path2.join(sourceDir, file);
|
|
112
132
|
const targetPath = path2.join(targetDir, file);
|
|
133
|
+
logger.debug(`Copying: ${file}`);
|
|
113
134
|
await fs.ensureDir(path2.dirname(targetPath));
|
|
114
135
|
let content = await fs.readFile(sourcePath, "utf8");
|
|
115
136
|
content = content.replace(/\{projectName\}/g, variables.projectName).replace(/\{humanReadableProjectName\}/g, variables.humanReadableProjectName).replace(/\{pikaUxVersion\}/g, variables.pikaUxVersion);
|
|
@@ -192,8 +213,13 @@ async function createCommand(options = {}) {
|
|
|
192
213
|
try {
|
|
193
214
|
const pikaUxRoot = path2.dirname(require2.resolve("pika-ux/package.json"));
|
|
194
215
|
templateDir = path2.join(pikaUxRoot, "dist/cli/template-files");
|
|
216
|
+
logger.debug(`Template directory resolved to: ${templateDir}`);
|
|
195
217
|
} catch (error) {
|
|
196
|
-
templateDir = path2.join(__dirname, "
|
|
218
|
+
templateDir = path2.join(__dirname, "template-files");
|
|
219
|
+
logger.debug(`Using fallback template directory: ${templateDir}`);
|
|
220
|
+
}
|
|
221
|
+
if (!await fs.pathExists(templateDir)) {
|
|
222
|
+
throw new Error(`Template directory not found: ${templateDir}`);
|
|
197
223
|
}
|
|
198
224
|
logger.updateSpinner("Processing template files...");
|
|
199
225
|
await copyAndProcessTemplate(templateDir, targetPath, {
|
|
@@ -201,6 +227,7 @@ async function createCommand(options = {}) {
|
|
|
201
227
|
humanReadableProjectName: humanReadableName,
|
|
202
228
|
pikaUxVersion
|
|
203
229
|
});
|
|
230
|
+
logger.debug(`Files copied to: ${targetPath}`);
|
|
204
231
|
logger.stopSpinner(true, "Template files processed");
|
|
205
232
|
const installSpinner = logger.startSpinner("Installing dependencies with pnpm...");
|
|
206
233
|
try {
|
|
@@ -227,7 +254,8 @@ function showCompletionMessage(projectName, projectPath) {
|
|
|
227
254
|
console.log(chalk2.green.bold(`\u2713 Successfully created ${projectName}!`));
|
|
228
255
|
logger.newLine();
|
|
229
256
|
console.log(chalk2.bold("Next steps:"));
|
|
230
|
-
|
|
257
|
+
const relativePath = path2.relative(process.cwd(), projectPath).split(path2.sep).join("/");
|
|
258
|
+
console.log(chalk2.gray(` cd ${relativePath}`));
|
|
231
259
|
console.log(chalk2.gray(" pnpm dev # Start development server"));
|
|
232
260
|
console.log(chalk2.gray(" pnpm build # Build for production"));
|
|
233
261
|
logger.newLine();
|