create-sip 0.0.15 → 0.10.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.
Files changed (47) hide show
  1. package/README.md +12 -1
  2. package/create-sip.js +83 -10
  3. package/expressapi/README.md +65 -0
  4. package/expressapi/app/controllers/authcontroller.js +103 -0
  5. package/expressapi/app/controllers/usercontroller.js +27 -0
  6. package/expressapi/app/database/database.js +22 -0
  7. package/expressapi/app/index.js +19 -0
  8. package/expressapi/app/middleware/authjwt.js +22 -0
  9. package/expressapi/app/models/user.js +19 -0
  10. package/expressapi/app/routes/api.js +12 -0
  11. package/expressapi/config/default.json.example +15 -0
  12. package/expressapi/docs/dev_doc.md +15 -0
  13. package/expressapi/docs/user_doc.md +53 -0
  14. package/expressapi/nodemon.json +4 -0
  15. package/expressapi/package.json +32 -0
  16. package/expressapi/test/test.js +43 -0
  17. package/expressapi/tools/genkey.js +19 -0
  18. package/javascript/app.js +0 -0
  19. package/javascript/index.html +20 -0
  20. package/javascript/style.css +10 -0
  21. package/manager.js +85 -5
  22. package/mockapi/README.md +1 -0
  23. package/mockapi/database.json +26 -0
  24. package/mockapi/hai-server.json +4 -0
  25. package/mockapi/package.json +15 -0
  26. package/package.json +1 -1
  27. package/webbootstrap/index.html +22 -0
  28. package/webbootstrap/style.css +0 -0
  29. package/webesbuildjs/README.md +1 -0
  30. package/webesbuildjs/bs-config.json +9 -0
  31. package/webesbuildjs/package.json +24 -0
  32. package/webesbuildjs/public/index.html +29 -0
  33. package/webesbuildjs/public/style.css +0 -0
  34. package/webesbuildjs/src/app.js +0 -0
  35. package/webesbuildts/README.md +1 -0
  36. package/webesbuildts/bs-config.json +9 -0
  37. package/webesbuildts/package.json +25 -0
  38. package/webesbuildts/public/index.html +29 -0
  39. package/webesbuildts/public/style.css +0 -0
  40. package/webesbuildts/src/app.ts +0 -0
  41. package/webnodejs/bs-config.json +9 -0
  42. package/webnodejs/package.json +17 -0
  43. package/webnodejs/src/app.js +0 -0
  44. package/webnodejs/src/index.html +18 -0
  45. package/webnodejs/src/style.css +0 -0
  46. package/webpage/index.html +9 -3
  47. package/webpage/style.css +10 -0
package/README.md CHANGED
@@ -2,8 +2,19 @@
2
2
 
3
3
  Simple projekct generator.
4
4
 
5
- ## Használat
5
+ * Simple webpage. index.html and style.css
6
+ * Webpage with Bootstrap with CDN.
7
+ * Webpage with CSS and JS file.
8
+ * Node.js project for webpage.
9
+ * ESBuild and Javascript project for webpage.
10
+ * ESBuild and Typescript project for webpage.
11
+ * Mock REST API server.
12
+
13
+ ## Using
6
14
 
7
15
  ```bash
8
16
  npm create sip@latest
9
17
  ```
18
+
19
+ * Write project name.
20
+ * Select project type.
package/create-sip.js CHANGED
@@ -1,6 +1,15 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- const { genWebpage } = require('./manager');
3
+ const {
4
+ genWebpage,
5
+ genBootstrap,
6
+ genJavascript,
7
+ genNodejs,
8
+ genWebEsbuildJs,
9
+ genWebEsbuildTs,
10
+ genMockApi,
11
+ genExpressApi
12
+ } = require('./manager');
4
13
  const prompts = require('prompts');
5
14
 
6
15
  const questions = [
@@ -13,33 +22,97 @@ const questions = [
13
22
  {
14
23
  type: 'select',
15
24
  name: 'type',
16
- message: 'Project type (webpage): ',
25
+ message: 'Project type: ',
17
26
  choices: [
18
27
  {
19
- title: 'webpage',
20
- description: 'simple webpage: index.html, style.css',
28
+ title: 'Webpage',
29
+ description: 'Simple webpage: index.html, style.css',
21
30
  value: 'webpage'
22
31
  },
23
32
  {
24
- title: 'javascript',
25
- description: 'simple javascript: index.html, style.css,app.js',
33
+ title: 'Web Bootstrap',
34
+ description: 'Simple webpage with Bootstrap',
35
+ value: 'webbootstrap'
36
+ },
37
+ {
38
+ title: 'JavaScript',
39
+ description: 'Only index.html, style.css, app.js',
26
40
  value: 'javascript'
41
+ },
42
+ {
43
+ title: 'Web Node.js',
44
+ description: 'Node.js project for webpage',
45
+ value: 'webnodejs'
46
+ },
47
+ {
48
+ title: 'ESBuild JavaScript',
49
+ description: 'Esbuild JavaScript webpage',
50
+ value: 'webesbuildjs'
51
+ },
52
+ {
53
+ title: 'ESBuild TypeScript',
54
+ description: 'Esbuild TypeScript webpage',
55
+ value: 'webesbuildts'
56
+ },
57
+ {
58
+ title: 'MockAPI',
59
+ description: 'API server with hai-server 0.0.4',
60
+ value: 'mockapi'
61
+ },
62
+ {
63
+ title: 'Express API',
64
+ description: 'Express API with simple Sequelize',
65
+ value: 'expressapi'
66
+ },
67
+ {
68
+ title: 'Cancel',
69
+ value: 'cancel'
27
70
  }
28
71
  ],
29
72
  initial: 0
30
73
  }
31
74
  ];
32
75
 
33
- (async () => {
76
+ (async () => {
34
77
  const res = await prompts(questions);
35
78
  if(res.type === 'webpage') {
36
- console.log('create a new webpage...');
79
+ console.log('Create a new webpage...');
37
80
  genWebpage(res.name);
38
81
  return;
39
82
  }
83
+ if(res.type === 'webbootstrap') {
84
+ console.log('Create a new webpage with Bootstrap...');
85
+ genBootstrap(res.name);
86
+ return;
87
+ }
40
88
  if(res.type === 'javascript') {
41
- console.log('create a new javascript...');
42
- console.log('Nincs implementálva.')
89
+ console.log('Create a new javascript...');
90
+ genJavascript(res.name);
91
+ return;
92
+ }
93
+ if(res.type === 'webnodejs') {
94
+ console.log('Create a new webpage with Node.js...');
95
+ genNodejs(res.name);
96
+ return;
97
+ }
98
+ if(res.type === 'webesbuildjs') {
99
+ console.log('Create a new webpage with ESBuild and Javascript...');
100
+ genWebEsbuildJs(res.name);
101
+ return;
102
+ }
103
+ if(res.type === 'webesbuildts') {
104
+ console.log('Create a new webpage with ESBuild and Typescript...');
105
+ genWebEsbuildTs(res.name);
106
+ return;
107
+ }
108
+ if(res.type === 'mockapi') {
109
+ console.log('Create a new MockAPI server...');
110
+ genMockApi(res.name);
111
+ return;
112
+ }
113
+ if(res.type === 'expressapi') {
114
+ console.log('Create a new Express API...');
115
+ genExpressApi(res.name);
43
116
  return;
44
117
  }
45
118
 
@@ -0,0 +1,65 @@
1
+ # exapi
2
+
3
+ Exapi framework
4
+
5
+ Express based REST API sablon
6
+
7
+ ## Install
8
+
9
+ ```cmd
10
+ npm install
11
+ ```
12
+
13
+ ## APP KEY generation
14
+
15
+ Run the genkey tools:
16
+
17
+ ```cmd
18
+ node tools/genkey.js
19
+ ```
20
+
21
+ ## Database settings
22
+
23
+ The database settings can be found at the following location:
24
+
25
+ * config/default.json
26
+
27
+ ### Database dialect
28
+
29
+ The default database is an in-memory database. Its contents are cleared after the server is restarted.
30
+
31
+ One of:
32
+
33
+ * sqlite
34
+ * mariadb
35
+
36
+ After installing the appropriate dependencies, it can be used:
37
+
38
+ * mysql
39
+ * postgres
40
+ * mssql
41
+ * db2
42
+ * snowflake
43
+ * oracle
44
+
45
+ With the `sqlite` option, the database is stored in the `database.sqlite` file, or you can add :memory:, then the database is stored in memory.
46
+
47
+ ## Starting
48
+
49
+ For development:
50
+
51
+ ```cmd
52
+ npm run dev
53
+ ```
54
+
55
+ Run productum:
56
+
57
+ ```cmd
58
+ npm start
59
+ ```
60
+
61
+ ## Licence
62
+
63
+ May be freely distributed under the MIT license.
64
+
65
+ Copyright (c) 2023 Sallai András
@@ -0,0 +1,103 @@
1
+ const bcrypt = require('bcryptjs')
2
+ const jwt = require('jsonwebtoken')
3
+ const User = require('../models/user')
4
+ const config = require('../../config/default.json')
5
+
6
+ const AuthController = {
7
+ async register(req, res) {
8
+ var clientError = false;
9
+ try {
10
+ if(!req.body.name ||
11
+ !req.body.email ||
12
+ !req.body.password ||
13
+ !req.body.password_confirmation) {
14
+ clientError = true
15
+ throw new Error('Error! Bad request data!')
16
+ }
17
+ if(req.body.password != req.body.password_confirmation) {
18
+ clientError = true
19
+ throw new Error('Error! The two password is not same!')
20
+ }
21
+ const user = await User.findOne({
22
+ where: { name: req.body.name }
23
+ })
24
+ if(user) {
25
+ clientError = true
26
+ throw new Error('Error! User already exists: ' + user.name)
27
+ }
28
+ AuthController.tryRegister(req, res)
29
+ } catch (error) {
30
+ if (clientError) {
31
+ res.status(400)
32
+ }else {
33
+ res.status(500)
34
+ }
35
+ await res.json({
36
+ success: false,
37
+ message: 'Error! User creation failed!',
38
+ error: error.message
39
+ })
40
+ }
41
+ },
42
+ async tryRegister(req, res) {
43
+ const user = {
44
+ name: req.body.name,
45
+ email: req.body.email,
46
+ password: bcrypt.hashSync(req.body.password)
47
+ }
48
+ await User.create(user)
49
+ .then( result => {
50
+ res.status(201)
51
+ res.json({
52
+ succes: true,
53
+ data: result
54
+ })
55
+ })
56
+ },
57
+ async login(req, res) {
58
+
59
+ try {
60
+ if(!req.body.name || !req.body.password) {
61
+ res.status(400)
62
+ throw new Error('Error! Bad name or password!')
63
+ }
64
+ const user = await User.findOne({
65
+ where: { name: req.body.name }
66
+ })
67
+
68
+ if(!user) {
69
+ res.status(404)
70
+ throw new Error('Error! User not found!')
71
+ }
72
+ var passwordIsValid = await bcrypt.compare(
73
+ req.body.password,
74
+ user.dataValues.password
75
+ );
76
+ if(!passwordIsValid) {
77
+ res.status(401)
78
+ throw new Error('Error! Password is not valid!')
79
+ }
80
+ AuthController.tryLogin(req, res, user)
81
+
82
+ } catch (error) {
83
+ res.json({
84
+ success: false,
85
+ message: 'Error! The login is failed!',
86
+ error: error.message
87
+ })
88
+ }
89
+ },
90
+ async tryLogin(req, res, user) {
91
+ var token = jwt.sign({ id: user.id }, config.app.key, {
92
+ expiresIn: 86400 //24 óra
93
+ })
94
+ res.status(200).json({
95
+ id: user.id,
96
+ name: user.name,
97
+ email: user.email,
98
+ accessToken: token
99
+ })
100
+ }
101
+ }
102
+
103
+ module.exports = AuthController
@@ -0,0 +1,27 @@
1
+ const User = require('../models/user')
2
+
3
+
4
+
5
+ const UserController = {
6
+ async index(req, res) {
7
+ try {
8
+ UserController.tryIndex(req, res)
9
+ }catch(error) {
10
+ res.status(500)
11
+ res.json({
12
+ success: false,
13
+ message: 'Error! The query is failed!'
14
+ })
15
+ }
16
+ },
17
+ async tryIndex(req, res) {
18
+ const users = await User.findAll()
19
+ res.status(200)
20
+ res.json({
21
+ success: true,
22
+ data: users
23
+ })
24
+ }
25
+ }
26
+
27
+ module.exports = UserController
@@ -0,0 +1,22 @@
1
+ const Sequelize = require('sequelize')
2
+ const config = require('../../config/default.json')
3
+
4
+ if(config.app.log != false) {
5
+ var log = console.log
6
+ }
7
+
8
+ console.log(typeof console.log)
9
+ const sequelize = new Sequelize(
10
+ config.db.name,
11
+ config.db.user,
12
+ config.db.pass,
13
+ {
14
+ logging: log,
15
+ dialect: config.db.dialect,
16
+ storage: config.db.path,
17
+ host: config.db.host,
18
+ dialectOptions: {}
19
+ }
20
+ )
21
+
22
+ module.exports = sequelize
@@ -0,0 +1,19 @@
1
+ const express = require('express')
2
+ const morgan = require('morgan')
3
+ const app = express()
4
+ const fs = require('fs')
5
+ const router = require('./routes/api')
6
+ const config = require('../config/default.json')
7
+
8
+ const PORT = config.app.port || 8000
9
+
10
+ const logfile = 'access.log'
11
+ var accessLogStream = fs.createWriteStream(logfile, { flags: 'a' })
12
+ app.use(morgan('dev', { stream: accessLogStream }))
13
+
14
+ app.use(express.json())
15
+ app.use('/api', router);
16
+
17
+ app.listen(PORT, () => {
18
+ console.log(`Listening on port: ${PORT}`)
19
+ })
@@ -0,0 +1,22 @@
1
+ const jwt = require("jsonwebtoken");
2
+ const config = require('../../config/default.json')
3
+
4
+ exports.verifyToken = (req, res, next) => {
5
+ let authData = req.headers.authorization;
6
+ if(!authData) {
7
+ return res.status(403).send({
8
+ message: 'No token provided!'
9
+ })
10
+ }
11
+ let token = authData.split(' ')[1];
12
+
13
+ jwt.verify(token, config.app.key, (err, decoded) => {
14
+ if(err) {
15
+ return res.status(401).send({
16
+ message: "Unauthorized!"
17
+ })
18
+ }
19
+ req.userId = decoded.id;
20
+ next()
21
+ })
22
+ };
@@ -0,0 +1,19 @@
1
+ const { DataTypes } = require('sequelize')
2
+ const sequelize = require('../database/database')
3
+
4
+ const User = sequelize.define('User', {
5
+ id: {
6
+ type: DataTypes.INTEGER,
7
+ autoIncrement: true,
8
+ primaryKey: true
9
+ },
10
+ name: { type: DataTypes.STRING, allowNull: false },
11
+ email: { type: DataTypes.STRING, allowNull: true },
12
+ password: { type: DataTypes.STRING , allowNull: false }
13
+ })
14
+
15
+
16
+ sequelize.sync({
17
+ force: false
18
+ })
19
+ module.exports = User
@@ -0,0 +1,12 @@
1
+ const Router = require('express')
2
+ const router = Router()
3
+
4
+ const AuthController = require('../controllers/authcontroller')
5
+ const UserController = require('../controllers/usercontroller')
6
+ const { verifyToken } = require('../middleware/authjwt')
7
+
8
+ router.post('/register', AuthController.register)
9
+ router.post('/login', AuthController.login)
10
+ router.get('/users', [verifyToken], UserController.index)
11
+
12
+ module.exports = router
@@ -0,0 +1,15 @@
1
+ {
2
+ "app": {
3
+ "port": 8000,
4
+ "key": "",
5
+ "log": "console.log"
6
+ },
7
+ "db": {
8
+ "dialect": "sqlite",
9
+ "host": "127.0.0.1",
10
+ "name": "",
11
+ "user": "",
12
+ "pass": "",
13
+ "path": ":memory:"
14
+ }
15
+ }
@@ -0,0 +1,15 @@
1
+ # expressapi
2
+
3
+ ## API KEY
4
+
5
+ The app key generated with generate-api-key package.
6
+
7
+ ## Testing
8
+
9
+ Set in config/default.json file, the db.dialect to sqlite. Set db.path to :memory:
10
+
11
+ Start the application:
12
+
13
+ ```cmd
14
+ npm run dev
15
+ ```
@@ -0,0 +1,53 @@
1
+ # User documentation
2
+
3
+ ## Install dependencies
4
+
5
+ ```cmd
6
+ pnpm install
7
+ ```
8
+
9
+ ## App key generation
10
+
11
+ ```cmd
12
+ node tools/genkey.js
13
+ ```
14
+
15
+ ## Database setup
16
+
17
+ Edit the config/default.json file.
18
+
19
+ ## Endpoints
20
+
21
+ All endpoint have a /api prefix.
22
+
23
+ | Endpoint | Method | Auth | Description |
24
+ |-|-|-|-|
25
+ | /register | POST | no | create user |
26
+ | /login | POST | no | login |
27
+ | /users | GET | yes | read users |
28
+
29
+ ## The register endpoint
30
+
31
+ ```json
32
+ {
33
+ "name": "joe",
34
+ "email": "joe@green.lan",
35
+ "password": "secret",
36
+ "password_confirmation": "secret"
37
+ }
38
+ ```
39
+
40
+ ## The login endpoint
41
+
42
+ ```json
43
+ {
44
+ "name": "joe",
45
+ "password": "secret"
46
+ }
47
+ ```
48
+
49
+ You receive the bearear token with accessToken key.
50
+
51
+ ## The users endpoint
52
+
53
+ Send the bearer token.
@@ -0,0 +1,4 @@
1
+ {
2
+ "watch": ["app/index.js", "app"],
3
+ "ext": "js"
4
+ }
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "expressapi",
3
+ "version": "1.0.1",
4
+ "description": "Express API with simple Sequelize",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "mocha",
8
+ "dev": "nodemon app",
9
+ "start": "node app"
10
+ },
11
+ "keywords": [
12
+ "express",
13
+ "api"
14
+ ],
15
+ "author": "Sallai András",
16
+ "license": "ISC",
17
+ "dependencies": {
18
+ "bcryptjs": "^2.4.3",
19
+ "express": "^4.18.2",
20
+ "generate-api-key": "^1.0.2",
21
+ "jsonwebtoken": "^9.0.0",
22
+ "mariadb": "^3.1.2",
23
+ "morgan": "^1.10.0",
24
+ "replace": "^1.2.2",
25
+ "sequelize": "^6.32.0",
26
+ "sqlite3": "^5.1.6"
27
+ },
28
+ "devDependencies": {
29
+ "nodemon": "^2.0.22",
30
+ "supertest": "^6.3.3"
31
+ }
32
+ }
@@ -0,0 +1,43 @@
1
+ const supertest = require('supertest')
2
+
3
+ describe('GET /api/users', () => {
4
+
5
+ const host = 'http://localhost:8000/api'
6
+ const restype= 'application/json; charset=utf-8'
7
+ var token = null
8
+
9
+ it('post /register ', function(done) {
10
+ supertest(host)
11
+ .post('/register')
12
+ .set('Accept', 'application/json')
13
+ .send({
14
+ name: 'mari',
15
+ email: 'mari@zold.lan',
16
+ password: 'titok',
17
+ password_confirmation: 'titok'
18
+ })
19
+ .expect('Content-Type', restype)
20
+ .expect(201, done)
21
+ })
22
+ it('post /login ', (done) => {
23
+ supertest(host)
24
+ .post('/login')
25
+ .set('Accept', 'application/json')
26
+ .send({
27
+ name: 'mari',
28
+ password: 'titok'
29
+ })
30
+ .expect('Content-Type', restype)
31
+ .expect(200, done)
32
+ .expect(res => {
33
+ token = res.body.accessToken
34
+ })
35
+ })
36
+ it('get /users ', function(done) {
37
+ supertest(host)
38
+ .get('/users')
39
+ .set('Accept', 'application/json')
40
+ .set('Authorization', 'Bearer ' + token)
41
+ .expect(200, done)
42
+ })
43
+ })
@@ -0,0 +1,19 @@
1
+ const fs = require('fs').promises
2
+ const path = require('path')
3
+ const fileName = '../config/default.json'
4
+ const { generateApiKey } = require('generate-api-key')
5
+
6
+ function generateKey(size = 32, format = 'base64') {
7
+ const buffer = crypto.randomBytes(size);
8
+ return buffer.toString(format);
9
+ }
10
+
11
+ fs.readFile(path.join(__dirname, fileName))
12
+ .then(body => JSON.parse(body))
13
+ .then(json => {
14
+ json.app.key = generateApiKey({method: 'bytes', length: 32})
15
+ return json
16
+ })
17
+ .then(json => JSON.stringify(json, null, 4))
18
+ .then(body => fs.writeFile(path.join(__dirname, fileName), body, 'utf8'))
19
+ .catch(error => console.log(error))
File without changes
@@ -0,0 +1,20 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Sip</title>
7
+ <link rel="stylesheet" href="style.css">
8
+ </head>
9
+ <body>
10
+ <div class="container">
11
+ <h1>Sip projekt</h1>
12
+ <p>
13
+ This project generated sip generator.
14
+ </p>
15
+ </div>
16
+
17
+ <script src="app.js"></script>
18
+
19
+ </body>
20
+ </html>
@@ -0,0 +1,10 @@
1
+ * {
2
+ margin: 0;
3
+ padding: 0;
4
+ }
5
+ .container {
6
+ color: #333;
7
+ background-color: aqua;
8
+ padding: 10px;
9
+ font-family:Arial, Helvetica, sans-serif
10
+ }
package/manager.js CHANGED
@@ -4,16 +4,96 @@ const dir = path.join(__dirname);
4
4
 
5
5
 
6
6
  const genWebpage = (target) => {
7
- copyDir('webpage', target);
7
+ copyDir(`${dir}/webpage`, target);
8
8
  }
9
9
 
10
+ const genBootstrap = (target) => {
11
+ copyDir(`${dir}/webbootstrap`, target);
12
+ }
13
+
14
+ const genJavascript = (target) => {
15
+ copyDir(`${dir}/javascript`, target);
16
+ }
17
+
18
+ const genNodejs = (target) => {
19
+ copyDir(`${dir}/webnodejs`, target);
20
+ updatePackageName(`${target}/package.json`, target);
21
+ console.log('Web client created');
22
+ console.log('Run next commands:');
23
+ console.log('npm install');
24
+ console.log('npm start');
25
+ }
26
+
27
+ const genWebEsbuildJs = (target) => {
28
+ copyDir(`${dir}/webesbuildjs`, target);
29
+ updatePackageName(`${target}/package.json`, target);
30
+ console.log('ESBuild client created with Javascript');
31
+ console.log('Run next commands:');
32
+ console.log('npm install');
33
+ console.log('npm run dev');
34
+ console.log('npm start');
35
+ console.log('If you want to build, run:');
36
+ console.log('npm run build');
37
+ }
38
+
39
+ const genWebEsbuildTs = (target) => {
40
+ copyDir(`${dir}/webesbuildts`, target);
41
+ updatePackageName(`${target}/package.json`, target);
42
+ console.log('ESBuild client created with Typescript');
43
+ console.log('Run next commands:');
44
+ console.log('npm install');
45
+ console.log('npm run dev');
46
+ console.log('npm start');
47
+ console.log('If you want to build, run:');
48
+ console.log('npm run build');
49
+ }
50
+
51
+ const genMockApi = (target) => {
52
+ copyDir(`${dir}/mockapi`, target);
53
+ updatePackageName(`${target}/package.json`, target);
54
+ console.log('MockAPI with hai-server 0.0.4');
55
+ console.log('Run next commands:');
56
+ console.log('npm install');
57
+ console.log('npm start');
58
+ }
59
+
60
+ const genExpressApi = (target) => {
61
+ copyDir(`${dir}/expressapi`, target);
62
+ updatePackageName(`${target}/package.json`, target);
63
+ console.log('ExpressJS REST API sablon created');
64
+ console.log('Read docs/user_doc.md');
65
+ }
66
+
67
+ const updatePackageName = (filePath, newName) => {
68
+ const content = JSON.parse(fs.readFileSync(filePath, 'utf-8'));
69
+ if (content.name) {
70
+ content.name = newName;
71
+ fs.writeFileSync(filePath, JSON.stringify(content, null, 2));
72
+ }
73
+ };
74
+
10
75
  const copyDir = (srcDir, destDir) => {
11
76
  fs.mkdirSync(destDir, { recursive: true });
12
- for (const file of fs.readdirSync(`${dir}/${srcDir}`)) {
13
- fs.copyFileSync(`${dir}/${srcDir}/${file}`, `${destDir}/${file}`);
77
+
78
+ for (const item of fs.readdirSync(srcDir)) {
79
+ const srcPath = path.join(srcDir, item);
80
+ const destPath = path.join(destDir, item);
81
+
82
+ if (fs.statSync(srcPath).isDirectory()) {
83
+ copyDir(srcPath, destPath);
84
+ } else {
85
+ fs.copyFileSync(srcPath, destPath);
86
+ }
14
87
  }
15
- }
88
+ };
16
89
 
17
90
  module.exports = {
18
- genWebpage
91
+ genWebpage,
92
+ genBootstrap,
93
+ genJavascript,
94
+ genNodejs,
95
+ genWebEsbuildJs,
96
+ genWebEsbuildTs,
97
+ genMockApi,
98
+ genExpressApi
19
99
  }
@@ -0,0 +1 @@
1
+ # Sinto Fake REST API
@@ -0,0 +1,26 @@
1
+ {
2
+ "employees": [
3
+ {
4
+ "id": 1,
5
+ "name": "Strong Steven",
6
+ "city": "Szeged",
7
+ "salary": 395
8
+ },
9
+ {
10
+ "id": 2,
11
+ "name": "John Doe",
12
+ "city": "New York",
13
+ "salary": 392
14
+ }
15
+ ],
16
+ "positions": [
17
+ {
18
+ "id": 1,
19
+ "name": "Manager"
20
+ },
21
+ {
22
+ "id": 2,
23
+ "name": "Developer"
24
+ }
25
+ ]
26
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "port": 8000,
3
+ "watch": true
4
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "mockapi",
3
+ "version": "1.0.0",
4
+ "description": "Mock REST API server",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "start": "hai-server database.json"
8
+ },
9
+ "keywords": [],
10
+ "author": "",
11
+ "license": "ISC",
12
+ "dependencies": {
13
+ "hai-server": "^0.0.4"
14
+ }
15
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-sip",
3
- "version": "0.0.15",
3
+ "version": "0.10.0",
4
4
  "main": "index.js",
5
5
  "bin": {
6
6
  "create-sip": "create-sip.js"
@@ -0,0 +1,22 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Sip</title>
7
+ <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
8
+ <link rel="stylesheet" href="style.css">
9
+
10
+ <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
11
+ </head>
12
+ <body>
13
+
14
+ <div class="container">
15
+ <h1>Sip projekt</h1>
16
+ <p>
17
+ This project with Bootstrap. Generated by sip.
18
+ </p>
19
+ </div>
20
+
21
+ </body>
22
+ </html>
File without changes
@@ -0,0 +1 @@
1
+ # Sinto ESBuild client
@@ -0,0 +1,9 @@
1
+ {
2
+ "server": [
3
+ "public",
4
+ "node_modules/bootstrap/dist/css",
5
+ "node_modules/bootstrap/dist/js"
6
+ ],
7
+ "port": 3000,
8
+ "watch": true
9
+ }
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "sinto-project",
3
+ "version": "0.0.1",
4
+ "description": "A project created by the Sinto command",
5
+ "scripts": {
6
+ "test": "echo \"Error: no test specified\" && exit 1",
7
+ "start": "browser-sync start --config bs-config.json",
8
+ "dev": "npx esbuild src/app.js --outdir=public --bundle --watch",
9
+ "build:src": "npx esbuild src/app.js --outdir=dist --bundle --minify",
10
+ "build:htmlcss": "cpx public/**/*.{html,css,png} dist",
11
+ "build:bscss": "cpx node_modules/bootstrap/dist/css/bootstrap.css dist",
12
+ "build:bsjs": "cpx node_modules/bootstrap/dist/js/bootstrap.js dist",
13
+ "build": "npm-run-all build:*"
14
+ },
15
+ "dependencies": {
16
+ "bootstrap": "^5.3.3"
17
+ },
18
+ "devDependencies": {
19
+ "esbuild": "^0.23.1",
20
+ "browser-sync": "^3.0.2",
21
+ "cpx": "^1.5.0",
22
+ "npm-run-all": "^4.1.5"
23
+ }
24
+ }
@@ -0,0 +1,29 @@
1
+
2
+ <!--
3
+ File: index.html
4
+ Author: Vezetéknév Keresztnév
5
+ Copyright: 2024, Vezetéknév Keresztnév
6
+ Group: Csoportnév
7
+ Date: 2024-12-02
8
+ Github: https://github.com/valami12345/
9
+ Licenc: MIT
10
+ -->
11
+
12
+ <!DOCTYPE html>
13
+ <html lang="hu">
14
+ <head>
15
+ <meta charset="UTF-8">
16
+ <title>Sinto esbuild</title>
17
+ <link rel="stylesheet" href="bootstrap.css">
18
+ <link rel="stylesheet" href="style.css">
19
+ </head>
20
+ <body>
21
+ <div class="container">
22
+ <h1>Sinto</h1>
23
+ <p>The website generated by Sinto.</p>
24
+
25
+ </div>
26
+ <script src="bootstrap.js"></script>
27
+ <script src="app.js"></script>
28
+ </body>
29
+ </html>
File without changes
File without changes
@@ -0,0 +1 @@
1
+ # Sinto ESBuild client
@@ -0,0 +1,9 @@
1
+ {
2
+ "server": [
3
+ "public",
4
+ "node_modules/bootstrap/dist/css",
5
+ "node_modules/bootstrap/dist/js"
6
+ ],
7
+ "port": 3000,
8
+ "watch": true
9
+ }
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "sinto-project",
3
+ "version": "0.0.1",
4
+ "description": "A project created by the Sinto command",
5
+ "scripts": {
6
+ "test": "echo \"Error: no test specified\" && exit 1",
7
+ "start": "browser-sync start --config bs-config.json",
8
+ "preview": "browser-sync start --server dist",
9
+ "dev": "npx esbuild src/**/*.ts --outdir=public --bundle --watch",
10
+ "build:src": "npx esbuild src/app.ts --outdir=dist --bundle --minify",
11
+ "build:htmlcss": "cpx public/**/*.{html,css,png} dist",
12
+ "build:bscss": "cpx node_modules/bootstrap/dist/css/bootstrap.css dist",
13
+ "build:bsjs": "cpx node_modules/bootstrap/dist/js/bootstrap.js dist",
14
+ "build": "npm-run-all build:*"
15
+ },
16
+ "dependencies": {
17
+ "bootstrap": "^5.3.3"
18
+ },
19
+ "devDependencies": {
20
+ "esbuild": "^0.23.1",
21
+ "browser-sync": "^3.0.2",
22
+ "cpx": "^1.5.0",
23
+ "npm-run-all": "^4.1.5"
24
+ }
25
+ }
@@ -0,0 +1,29 @@
1
+
2
+ <!--
3
+ File: index.html
4
+ Author: Vezetéknév Keresztnév
5
+ Copyright: 2024, Vezetéknév Keresztnév
6
+ Group: Csoportnév
7
+ Date: 2024-12-02
8
+ Github: https://github.com/valami12345/
9
+ Licenc: MIT
10
+ -->
11
+
12
+ <!DOCTYPE html>
13
+ <html lang="hu">
14
+ <head>
15
+ <meta charset="UTF-8">
16
+ <title>Sinto esbuild</title>
17
+ <link rel="stylesheet" href="bootstrap.css">
18
+ <link rel="stylesheet" href="style.css">
19
+ </head>
20
+ <body>
21
+ <div class="container">
22
+ <h1>Sinto</h1>
23
+ <p>The website generated by Sinto.</p>
24
+
25
+ </div>
26
+ <script src="bootstrap.js"></script>
27
+ <script src="app.js"></script>
28
+ </body>
29
+ </html>
File without changes
File without changes
@@ -0,0 +1,9 @@
1
+ {
2
+ "server": [
3
+ "src",
4
+ "node_modules/bootstrap/dist/css",
5
+ "node_modules/bootstrap/dist/js"
6
+ ],
7
+ "port": 3000,
8
+ "watch": ["src"]
9
+ }
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "webnodejs",
3
+ "version": "0.0.0",
4
+ "scripts": {
5
+ "start": "browser-sync start --config bs-config.json"
6
+ },
7
+ "keywords": [],
8
+ "author": "",
9
+ "license": "ISC",
10
+ "description": "",
11
+ "devDependencies": {
12
+ "browser-sync": "^3.0.3"
13
+ },
14
+ "dependencies": {
15
+ "bootstrap": "^5.3.3"
16
+ }
17
+ }
File without changes
@@ -0,0 +1,18 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Sip</title>
7
+ <link rel="stylesheet" href="bootstrap.css">
8
+ <link rel="stylesheet" href="style.css">
9
+ </head>
10
+ <body>
11
+ <div class="container">
12
+ <h1>Sip projekt</h1>
13
+ <p>
14
+ This is a Node.js project for webpage. Generated by sip.
15
+ </p>
16
+ </div>
17
+ </body>
18
+ </html>
File without changes
@@ -1,13 +1,19 @@
1
1
  <!DOCTYPE html>
2
- <html lang="hu">
2
+ <html lang="en">
3
3
  <head>
4
4
  <meta charset="UTF-8">
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>Sinto</title>
6
+ <title>Sip</title>
7
+ <link rel="stylesheet" href="style.css">
7
8
  </head>
8
9
  <body>
9
10
 
10
- <h1>Sinto</h1>
11
+ <div class="container">
12
+ <h1>Sip projekt</h1>
13
+ <p>
14
+ This project generated sip generator.
15
+ </p>
16
+ </div>
11
17
 
12
18
  </body>
13
19
  </html>
package/webpage/style.css CHANGED
@@ -0,0 +1,10 @@
1
+ * {
2
+ margin: 0;
3
+ padding: 0;
4
+ }
5
+ .container {
6
+ color: #333;
7
+ background-color: aqua;
8
+ padding: 10px;
9
+ font-family:Arial, Helvetica, sans-serif
10
+ }