hoosat-create 1.2.1 → 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 -8
- package/package.json +1 -1
- package/Testi/README.md +0 -0
- package/Testi/babel.config.js +0 -7
- package/Testi/jest.config.js +0 -7
- package/Testi/package.json +0 -38
- package/Testi/src/__tests__/example.test.ts +0 -5
- package/Testi/src/client/App.tsx +0 -17
- package/Testi/src/client/index.tsx +0 -5
- package/Testi/src/server/index.ts +0 -34
- package/Testi/tsconfig.json +0 -18
- package/Testi/webpack.config.js +0 -55
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,12 +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
|
-
|
|
32
|
-
const packageJsonPath = path.join(
|
|
35
|
+
|
|
36
|
+
const packageJsonPath = path.join(process.cwd(), 'package.json');
|
|
33
37
|
const packageJson = require(packageJsonPath);
|
|
34
38
|
packageJson.name = destination;
|
|
35
39
|
packageJson.description = description;
|
|
@@ -37,11 +41,32 @@ async function run() {
|
|
|
37
41
|
packageJson.license = license;
|
|
38
42
|
packageJson.keywords = keywordList;
|
|
39
43
|
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
40
|
-
console.log(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
+
}
|
|
45
70
|
} catch (err) {
|
|
46
71
|
console.error(`Failed to download project: ${err}`);
|
|
47
72
|
} finally {
|
|
@@ -55,4 +80,16 @@ function askQuestion(question) {
|
|
|
55
80
|
});
|
|
56
81
|
}
|
|
57
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
|
+
|
|
58
92
|
run();
|
|
93
|
+
|
|
94
|
+
// Export the askQuestion function for testing purposes
|
|
95
|
+
module.exports = { askQuestion };
|
package/package.json
CHANGED
package/Testi/README.md
DELETED
|
File without changes
|
package/Testi/babel.config.js
DELETED
package/Testi/jest.config.js
DELETED
package/Testi/package.json
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "Testi",
|
|
3
|
-
"version": "1.0.0",
|
|
4
|
-
"description": "Tonton proggis",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "jest",
|
|
8
|
-
"start": "nodemon --watch 'src/**/*.ts*' --exec 'ts-node' src/server/index.ts",
|
|
9
|
-
"build": "webpack --config webpack.config.js",
|
|
10
|
-
"dev": "npm run build && NODE_ENV=development nodemon --watch 'dist/client.js' --exec 'node dist/server.js'"
|
|
11
|
-
},
|
|
12
|
-
"keywords": [],
|
|
13
|
-
"author": "Toni Lukkaroinen",
|
|
14
|
-
"license": "MIT",
|
|
15
|
-
"devDependencies": {
|
|
16
|
-
"@babel/core": "^7.21.8",
|
|
17
|
-
"@babel/preset-env": "^7.21.5",
|
|
18
|
-
"@babel/preset-react": "^7.18.6",
|
|
19
|
-
"@babel/preset-typescript": "^7.21.5",
|
|
20
|
-
"@types/jest": "^29.5.1",
|
|
21
|
-
"@types/react": "^18.2.6",
|
|
22
|
-
"@types/react-dom": "^18.2.4",
|
|
23
|
-
"@types/react-helmet": "^6.1.6",
|
|
24
|
-
"babel-loader": "^9.1.2",
|
|
25
|
-
"express": "^4.18.2",
|
|
26
|
-
"jest": "^29.5.0",
|
|
27
|
-
"nodemon": "^2.0.22",
|
|
28
|
-
"react": "^18.2.0",
|
|
29
|
-
"react-dom": "^18.2.0",
|
|
30
|
-
"react-helmet": "^6.1.0",
|
|
31
|
-
"ts-jest": "^29.1.0",
|
|
32
|
-
"ts-node": "^10.9.1",
|
|
33
|
-
"typescript": "^5.0.4",
|
|
34
|
-
"webpack": "^5.82.1",
|
|
35
|
-
"webpack-cli": "^5.1.1",
|
|
36
|
-
"webpack-node-externals": "^3.0.0"
|
|
37
|
-
}
|
|
38
|
-
}
|
package/Testi/src/client/App.tsx
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Helmet } from 'react-helmet';
|
|
3
|
-
|
|
4
|
-
const App = () => {
|
|
5
|
-
|
|
6
|
-
return (
|
|
7
|
-
<div>
|
|
8
|
-
<Helmet>
|
|
9
|
-
<title>Changes?</title>
|
|
10
|
-
<meta name="description" content="My page description" />
|
|
11
|
-
</Helmet>
|
|
12
|
-
Hoosat React + Express Typescript SSR!
|
|
13
|
-
</div>
|
|
14
|
-
);
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export default App;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import express from 'express';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import React from 'react';
|
|
4
|
-
import { renderToString } from 'react-dom/server';
|
|
5
|
-
import { Helmet } from 'react-helmet';
|
|
6
|
-
import App from '../client/App';
|
|
7
|
-
|
|
8
|
-
const app = express();
|
|
9
|
-
|
|
10
|
-
app.use(express.static(path.join(__dirname, '../../dist')));
|
|
11
|
-
|
|
12
|
-
app.get('/', (req, res) => {
|
|
13
|
-
const message = 'Hello from server!';
|
|
14
|
-
const html = renderToString(React.createElement(App));
|
|
15
|
-
const helmet = Helmet.renderStatic();
|
|
16
|
-
|
|
17
|
-
res.send(`
|
|
18
|
-
<!DOCTYPE html>
|
|
19
|
-
<html>
|
|
20
|
-
<head>
|
|
21
|
-
${helmet.title.toString()}
|
|
22
|
-
${helmet.meta.toString()}
|
|
23
|
-
</head>
|
|
24
|
-
<body>
|
|
25
|
-
<div id="root">${html}</div>
|
|
26
|
-
<script src="/server.js"></script>
|
|
27
|
-
</body>
|
|
28
|
-
</html>
|
|
29
|
-
`);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
app.listen(3000, () => {
|
|
33
|
-
console.log('Server started on http://localhost:3000');
|
|
34
|
-
});
|
package/Testi/tsconfig.json
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"module": "commonjs",
|
|
4
|
-
"esModuleInterop": true,
|
|
5
|
-
"target": "es6",
|
|
6
|
-
"outDir": "./dist",
|
|
7
|
-
"jsx": "react",
|
|
8
|
-
"moduleResolution": "node",
|
|
9
|
-
"noImplicitAny": false,
|
|
10
|
-
"sourceMap": true,
|
|
11
|
-
"baseUrl": "./src",
|
|
12
|
-
"paths": {
|
|
13
|
-
"*": ["node_modules/*", "src/types/*"]
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
"include": ["src/**/*"],
|
|
17
|
-
"exclude": ["node_modules"]
|
|
18
|
-
}
|
package/Testi/webpack.config.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
const path = require('path');
|
|
2
|
-
const webpack = require('webpack');
|
|
3
|
-
const nodeExternals = require('webpack-node-externals');
|
|
4
|
-
|
|
5
|
-
module.exports = [
|
|
6
|
-
{
|
|
7
|
-
name: 'client',
|
|
8
|
-
entry: './src/client/index.tsx',
|
|
9
|
-
mode: 'development',
|
|
10
|
-
output: {
|
|
11
|
-
path: path.resolve(__dirname, 'dist'),
|
|
12
|
-
filename: 'client.js',
|
|
13
|
-
},
|
|
14
|
-
resolve: {
|
|
15
|
-
extensions: ['.js', '.jsx', '.ts', '.tsx'],
|
|
16
|
-
},
|
|
17
|
-
module: {
|
|
18
|
-
rules: [
|
|
19
|
-
{
|
|
20
|
-
test: /\.tsx?$/,
|
|
21
|
-
use: 'ts-loader',
|
|
22
|
-
exclude: /node_modules/,
|
|
23
|
-
},
|
|
24
|
-
],
|
|
25
|
-
},
|
|
26
|
-
plugins: [
|
|
27
|
-
new webpack.DefinePlugin({
|
|
28
|
-
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development')
|
|
29
|
-
})
|
|
30
|
-
]
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
name: 'server',
|
|
34
|
-
entry: './src/server/index.ts',
|
|
35
|
-
mode: 'development',
|
|
36
|
-
target: 'node',
|
|
37
|
-
externals: [nodeExternals()],
|
|
38
|
-
output: {
|
|
39
|
-
path: path.resolve(__dirname, 'dist'),
|
|
40
|
-
filename: 'server.js',
|
|
41
|
-
},
|
|
42
|
-
resolve: {
|
|
43
|
-
extensions: ['.js', '.jsx', '.ts', '.tsx'],
|
|
44
|
-
},
|
|
45
|
-
module: {
|
|
46
|
-
rules: [
|
|
47
|
-
{
|
|
48
|
-
test: /\.tsx?$/,
|
|
49
|
-
use: 'ts-loader',
|
|
50
|
-
exclude: /node_modules/,
|
|
51
|
-
},
|
|
52
|
-
],
|
|
53
|
-
},
|
|
54
|
-
}
|
|
55
|
-
];
|