devfast 1.0.0 ā 1.1.0
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/src/api.js +3 -2
- package/dist/src/commands/create.js +12 -9
- package/package.json +2 -2
package/dist/src/api.js
CHANGED
|
@@ -11,8 +11,9 @@ export async function fetchTemplate(id) {
|
|
|
11
11
|
}
|
|
12
12
|
catch (err) {
|
|
13
13
|
return {
|
|
14
|
-
|
|
15
|
-
error: err.response?.data?.
|
|
14
|
+
repository: null,
|
|
15
|
+
error: err.response?.data?.error || 'Server unreachable',
|
|
16
|
+
message: err.response?.data?.message || 'An error occurred while fetching the template.'
|
|
16
17
|
};
|
|
17
18
|
}
|
|
18
19
|
}
|
|
@@ -7,8 +7,12 @@ import { fetchTemplate } from '../api.js';
|
|
|
7
7
|
import { isValidProjectPath, isValidFolderName, isDirEmpty, formatMessage } from '../utils.js';
|
|
8
8
|
export async function createAction(templateId) {
|
|
9
9
|
const template = await fetchTemplate(templateId);
|
|
10
|
-
if (template.
|
|
11
|
-
console.error(chalk.red(
|
|
10
|
+
if (template.error) {
|
|
11
|
+
console.error(chalk.red(template.message || template.error));
|
|
12
|
+
process.exit(1);
|
|
13
|
+
}
|
|
14
|
+
if (!template.repository) {
|
|
15
|
+
console.error(chalk.red('Template repository not found.'));
|
|
12
16
|
process.exit(1);
|
|
13
17
|
}
|
|
14
18
|
const response = await prompts({
|
|
@@ -36,20 +40,19 @@ export async function createAction(templateId) {
|
|
|
36
40
|
process.exit(1);
|
|
37
41
|
}
|
|
38
42
|
const templateData = { APP_NAME: appName, RELATIVE_PATH: relativePath };
|
|
39
|
-
|
|
40
|
-
console.log(`\n${formatMessage(template.data.welcomeMessage, templateData)}`);
|
|
43
|
+
console.log(chalk.green(`\nš Setting up ${appName} with devfast...`));
|
|
41
44
|
const spinner = ora('Setting up project...').start();
|
|
42
45
|
try {
|
|
43
|
-
const emitter = degit(template.
|
|
46
|
+
const emitter = degit(template.repository, { force: true });
|
|
44
47
|
await emitter.clone(targetDir);
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
console.log(formatMessage(template.data.nextSteps, templateData));
|
|
48
|
+
if (template.nextSteps) {
|
|
49
|
+
console.log(formatMessage(template.nextSteps, templateData));
|
|
50
|
+
}
|
|
49
51
|
process.exit(0);
|
|
50
52
|
}
|
|
51
53
|
catch (err) {
|
|
52
54
|
spinner.fail(chalk.red('Setup failed.'));
|
|
55
|
+
console.error(chalk.red(err instanceof Error ? err.message : 'An unexpected error has occurred.'));
|
|
53
56
|
process.exit(1);
|
|
54
57
|
}
|
|
55
58
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "devfast",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Devfast template setup library",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/src/api.js",
|
|
@@ -32,4 +32,4 @@
|
|
|
32
32
|
"@types/prompts": "^2.4.9",
|
|
33
33
|
"typescript": "^5.9.3"
|
|
34
34
|
}
|
|
35
|
-
}
|
|
35
|
+
}
|