hoosat-create 1.2.0 → 1.3.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/README.md +3 -1
- package/index.js +45 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
# Hoosat Create
|
|
2
2
|
|
|
3
|
-
Hoosat create is a `npx` script that creates React + Express project for you, where you can use Typescript to build web applications.
|
|
3
|
+
Hoosat create is a `npx` script that creates React + Express project for you, where you can use Typescript to build web applications.
|
|
4
4
|
|
|
5
5
|
Give it a test:
|
|
6
6
|
```
|
|
7
7
|
npx hoosat-create
|
|
8
8
|
```
|
|
9
9
|
|
|
10
|
+
It uses @Hoosat-Oy/hoosat-template to build React + Express project with SSR and Typescript.
|
|
11
|
+
|
|
10
12
|
|
package/index.js
CHANGED
|
@@ -24,11 +24,16 @@ async function run() {
|
|
|
24
24
|
try {
|
|
25
25
|
await promisifiedDownload(repository, destination);
|
|
26
26
|
console.log('Project downloaded successfully');
|
|
27
|
+
|
|
28
|
+
// Change directory to the project directory
|
|
29
|
+
process.chdir(destination);
|
|
30
|
+
|
|
27
31
|
console.log('Running npm install...');
|
|
28
|
-
const install = spawn('npm', ['install'], {
|
|
32
|
+
const install = spawn('npm', ['install'], { stdio: 'inherit' });
|
|
29
33
|
await new Promise(resolve => install.on('close', resolve));
|
|
30
34
|
console.log('npm install completed');
|
|
31
|
-
|
|
35
|
+
|
|
36
|
+
const packageJsonPath = path.join(process.cwd(), 'package.json');
|
|
32
37
|
const packageJson = require(packageJsonPath);
|
|
33
38
|
packageJson.name = destination;
|
|
34
39
|
packageJson.description = description;
|
|
@@ -36,11 +41,32 @@ async function run() {
|
|
|
36
41
|
packageJson.license = license;
|
|
37
42
|
packageJson.keywords = keywordList;
|
|
38
43
|
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
39
|
-
console.log(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
+
console.log('Project package.json has been modified.');
|
|
45
|
+
|
|
46
|
+
// Initialize git repository
|
|
47
|
+
const gitInit = spawn('git', ['init']);
|
|
48
|
+
await new Promise(resolve => gitInit.on('close', resolve));
|
|
49
|
+
console.log('Git repository initialized.');
|
|
50
|
+
|
|
51
|
+
const installHoosatUI = await askYesNoQuestion('Do you want to install HoosatUI? [Y/n] ');
|
|
52
|
+
if (installHoosatUI) {
|
|
53
|
+
// Change directory to the client directory
|
|
54
|
+
process.chdir('src/client');
|
|
55
|
+
|
|
56
|
+
// Install HoosatUI as a git submodule
|
|
57
|
+
const gitSubmodule = spawn('git', ['submodule', 'add', 'https://github.com/hoosat-oy/HoosatUI']);
|
|
58
|
+
await new Promise(resolve => gitSubmodule.on('close', resolve));
|
|
59
|
+
console.log('HoosatUI installed successfully.');
|
|
60
|
+
|
|
61
|
+
// Install necessary dependencies
|
|
62
|
+
const installDeps = spawn('npm', ['install', '--save-dev', '@testing-library/jest-dom', '@testing-library/react']);
|
|
63
|
+
await new Promise(resolve => installDeps.on('close', resolve));
|
|
64
|
+
console.log('npm HoosatUI devDependencies installed successfully.');
|
|
65
|
+
|
|
66
|
+
const installMarkdownDeps = spawn('npm', ['install', 'react-markdown', 'rehype-highlight', 'remark-gfm']);
|
|
67
|
+
await new Promise(resolve => installMarkdownDeps.on('close', resolve));
|
|
68
|
+
console.log('npm HoosatUI dependencies installed successfully.');
|
|
69
|
+
}
|
|
44
70
|
} catch (err) {
|
|
45
71
|
console.error(`Failed to download project: ${err}`);
|
|
46
72
|
} finally {
|
|
@@ -54,4 +80,16 @@ function askQuestion(question) {
|
|
|
54
80
|
});
|
|
55
81
|
}
|
|
56
82
|
|
|
83
|
+
function askYesNoQuestion(question) {
|
|
84
|
+
return new Promise(resolve => {
|
|
85
|
+
rl.question(question, answer => {
|
|
86
|
+
const normalizedAnswer = answer.trim().toLowerCase();
|
|
87
|
+
resolve(normalizedAnswer === '' || normalizedAnswer === 'y' || normalizedAnswer === 'yes');
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
57
92
|
run();
|
|
93
|
+
|
|
94
|
+
// Export the askQuestion function for testing purposes
|
|
95
|
+
module.exports = { askQuestion };
|