sinto 1.6.1 → 1.8.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 CHANGED
@@ -61,6 +61,7 @@ This command is generate public directory from src directory.
61
61
  * sin rmno - Delete node_modules directory
62
62
  * sin ts - Generate tsconfig.json and add dependencies
63
63
  * sin web - Generate HTML and empty CSS files
64
+ * sin esbuild - Generate esbuild project
64
65
 
65
66
  The Default task manager is gulp. Development serve is browser-sync.
66
67
 
@@ -156,16 +157,89 @@ Write the tests in test directory and run the tests:
156
157
  npm test
157
158
  ```
158
159
 
159
- ## TypeScript config and dependencies
160
+ ## TypeScript
160
161
 
161
- The **sin ts** command generate a tsconfig.json and add dependencies to package.json.
162
+ ### TypeScript config and dependencies
162
163
 
163
- The **sin ts** command does not install the dependencies, it just writes them into the package.json file. Install the dependencies with the **npm i** or **pnpm i** command.
164
+ The **sin addts** command generate a tsconfig.json and add dependencies to package.json.
165
+
166
+ The **sin addts** command does not install the dependencies, it just writes them into the package.json file. Install the dependencies with the **npm i** or **pnpm i** command.
164
167
 
165
168
  Using:
166
169
 
167
170
  ```cmd
168
171
  sin init
172
+ sin addts
173
+ npm i
174
+ ```
175
+
176
+ ### TypeScript Node.js project
177
+
178
+ The **sin ts** command generate a TypeScript Node.js project.
179
+
180
+ Using:
181
+
182
+ ```cmd
169
183
  sin ts
170
184
  npm i
171
185
  ```
186
+
187
+ Generated directories and files:
188
+
189
+ ```txt
190
+ app01/
191
+ |-src/
192
+ | |-assets/
193
+ | |-app.ts
194
+ | |-index.html
195
+ | `-style.css
196
+ |-bs-config.json
197
+ |-gulpfile.js
198
+ |-package.json
199
+ |-README.md
200
+ `-tsconfig.json
201
+ ```
202
+
203
+ ## ESBuild project generator
204
+
205
+ The sin esbuild command generate a esbuild project.
206
+
207
+ Using:
208
+
209
+ ```cmd
210
+ sin esbuild
211
+ pnpm i
212
+ pnpm dev
213
+ pnpm start
214
+ ```
215
+
216
+ Generated directories and files:
217
+
218
+ ```txt
219
+ app01/
220
+ |-public/
221
+ | |-index.html
222
+ | `-style.css
223
+ |-src/
224
+ | `-index.js
225
+ |-package.json
226
+ `-README.md
227
+ ```
228
+
229
+ Update the src/app.ts your index file.
230
+
231
+ Example:
232
+
233
+ * src/app.ts
234
+ * src/index.ts
235
+ * src/app.js
236
+ * src/index.js
237
+ * src/script.js
238
+
239
+ To build production run next command:
240
+
241
+ ```cmd
242
+ pnpm build
243
+ ```
244
+
245
+ This command is generate dist directory from src directory. The build command not copy the public directory.
package/addts/addts.js ADDED
@@ -0,0 +1,43 @@
1
+ const tsconfigContent = require('./tsconfigContent.js');
2
+ const { createFile } = require('../tools/tools.js');
3
+ const jsonfile = require('jsonfile');
4
+ const { addDevDep } = require('../tools/dep.js');
5
+
6
+ const fs = require('fs');
7
+
8
+ const supplementTypescript = () => {
9
+ writeConfigFile();
10
+ showMsg();
11
+ addDependencies();
12
+ }
13
+
14
+ const writeConfigFile = () => {
15
+ const dir = process.cwd();
16
+ const path = `${dir}/tsconfig.json`;
17
+ jsonfile.writeFileSync(path, tsconfigContent, { spaces: 2 });
18
+ }
19
+
20
+ const showMsg = () => {
21
+ console.log(`
22
+ Install dependencies with npm or pnpm command:
23
+
24
+ pnpm install
25
+ `);
26
+ }
27
+
28
+ const addDependencies = () => {
29
+
30
+ const dir = process.cwd();
31
+ const path = `${dir}/package.json`;
32
+
33
+ if (!fs.existsSync(path)) {
34
+ console.log('package.json file does not exist.');
35
+ return;
36
+ }
37
+
38
+
39
+
40
+ addDevDep(path, ['typescript']);
41
+ }
42
+
43
+ module.exports.supplementTypescript = supplementTypescript;
@@ -0,0 +1,13 @@
1
+
2
+ const tsconfigContent =
3
+ {
4
+ "compilerOptions": {
5
+ "target": "ES6",
6
+ "module": "ES6",
7
+ "outDir": "./app",
8
+ "strict": true,
9
+ "esModuleInterop": true
10
+ }
11
+ }
12
+
13
+ module.exports = tsconfigContent;
@@ -0,0 +1,19 @@
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.ts --outdir=public --bundle --watch",
9
+ "build": "npx esbuild src/app.ts --outdir=dist --bundle --minify"
10
+ },
11
+ "dependencies": {
12
+ "bootstrap": "^5.3.3"
13
+ },
14
+ "devDependencies": {
15
+ "esbuild": "^0.23.1",
16
+ "browser-sync": "^3.0.2"
17
+ }
18
+ }
19
+
@@ -0,0 +1,18 @@
1
+
2
+ module.exports = `
3
+ <!DOCTYPE html>
4
+ <html lang="hu">
5
+ <head>
6
+ <meta charset="UTF-8">
7
+ <title>Sinto esbuild</title>
8
+ </head>
9
+ <body>
10
+ <div class="container">
11
+ <h1>Sinto</h1>
12
+ <p>The website generated by Sinto.</p>
13
+
14
+ </div>
15
+ <script src="app.js"></script>
16
+ </body>
17
+ </html>
18
+ `
@@ -0,0 +1,47 @@
1
+ const { debug } = require('../config.json')
2
+ const { createFile, createDirectory } = require('../tools/tools.js');
3
+ const jsonfile = require('jsonfile');
4
+
5
+ const swcPackageContent = require('./contents/esbuildPackage.json');
6
+ const indexHtmlContent = require('./contents/indexHtml.js');
7
+ const defaultBsconfigContent = require('./generators/genBsconfig.js');
8
+
9
+ const createEsbuildProject = () => {
10
+ const dir = process.cwd();
11
+
12
+ createDirectory(`${dir}/src`);
13
+ createDirectory(`${dir}/public`);
14
+ createDirectory(`${dir}/public/assets`);
15
+
16
+ createFile(`${dir}/public/index.html`, indexHtmlContent);
17
+ createFile(`${dir}/public/style.css`, '');
18
+ createFile(`${dir}/src/app.ts`, '');
19
+
20
+ createFile(`${dir}/README.md`, '# Sinto ESBuild client\n');
21
+
22
+ createPackageJsonFile(dir);
23
+ createBsconfigFile(dir);
24
+
25
+ console.log('ESBuild client created.');
26
+ console.log('Run next commands:');
27
+ console.log(' pnpm i');
28
+ console.log(' pnpm dev');
29
+ console.log(' pnpm start');
30
+ }
31
+
32
+ const createPackageJsonFile = (directory) => {
33
+ const packageJsonPath = `${directory}/package.json`;
34
+ jsonfile.writeFileSync(packageJsonPath, swcPackageContent, { spaces: 2 });
35
+ if(debug) {
36
+ console.log('package.json file created.');
37
+ }
38
+ }
39
+
40
+ const createBsconfigFile = (dir) => {
41
+ const bsconfigPath = `${dir}/bs-config.json`;
42
+ jsonfile.writeFileSync(bsconfigPath, defaultBsconfigContent, { spaces: 2 });
43
+ if(debug)
44
+ console.log('bs-config.json file created.');
45
+ }
46
+
47
+ module.exports.createEsbuildProject = createEsbuildProject;
@@ -0,0 +1,13 @@
1
+
2
+ const bsconfigContent =
3
+ {
4
+ server: [
5
+ "public",
6
+ "node_modules/bootstrap/dist/css",
7
+ "node_modules/bootstrap/dist/js"
8
+ ],
9
+ port: 3000,
10
+ watch: true
11
+ };
12
+
13
+ module.exports = bsconfigContent;
@@ -0,0 +1,45 @@
1
+
2
+ const tsGulfileContent = `
3
+ import {src, dest, parallel} from 'gulp';
4
+ import cleanCss from 'gulp-clean-css';
5
+ import replace from 'gulp-replace';
6
+ import concat from 'gulp-concat'
7
+ import ts from 'gulp-typescript';
8
+ import uglify from 'gulp-uglify';
9
+
10
+ import {create as bsCreate} from 'browser-sync';
11
+ const browserSync = bsCreate();
12
+
13
+ function genHTML(cb) {
14
+ src('src/**/*.html')
15
+ .pipe(dest('public'))
16
+ cb();
17
+ }
18
+
19
+
20
+ function streamTs(cb) {
21
+ src('src/**/*.ts')
22
+ .pipe(ts())
23
+ .pipe(uglify())
24
+ .pipe(dest('public'));
25
+ cb();
26
+ }
27
+
28
+ function minifyCSS(cb) {
29
+ src([
30
+ 'src/**/*.css',
31
+ 'node_modules/bootstrap/dist/css/bootstrap.css'])
32
+ .pipe(cleanCss())
33
+ .pipe(dest('public'));
34
+ cb();
35
+ }
36
+
37
+ function build(cb) {
38
+ parallel(genHTML, streamTs, minifyCSS)(cb);
39
+ }
40
+
41
+ export default build
42
+
43
+ `;
44
+
45
+ module.exports = tsGulfileContent;
package/gents/gents.js CHANGED
@@ -1,12 +1,17 @@
1
- const tsconfigContent = require('./tsconfigContent');
1
+ const {debug} = require('../config.json');
2
+ const tsconfigContent = require('./tsconfigContent.js');
2
3
  const { createFile } = require('../tools/tools.js');
3
4
  const jsonfile = require('jsonfile');
4
- const { addDevDep } = require('../tools/dep.js');
5
+ const { addDevDep, addScript } = require('../tools/dep.js');
6
+ const fs = require('fs');
7
+ const { createWeb } = require('../genweb/genweb');
8
+ const defaultTsPackageContent = require('./tsPackageContent.js');
5
9
 
6
- const supplementTypescript = () => {
7
- writeConfigFile();
8
- showMsg();
9
- addDependencies();
10
+ const initTypescriptProject = async () => {
11
+ createWeb('ts');
12
+ createPackageJsonFile(process.cwd());
13
+ writeConfigFile();
14
+ showMsg();
10
15
  }
11
16
 
12
17
  const writeConfigFile = () => {
@@ -16,21 +21,19 @@ const writeConfigFile = () => {
16
21
  }
17
22
 
18
23
  const showMsg = () => {
19
- console.log(`
20
- Proposal:
21
- In the tsconfig.json file, leave the module value
22
- at commonjs for a NodeJS project. In the case of
23
- an ES project, rewrite it to, for example, ES6.
24
+ console.log(`TypeScript project initialized.
25
+ Install dependencies with npm or pnpm command:
24
26
 
25
- Install dependencies:
26
27
  pnpm install
27
28
  `);
28
29
  }
29
30
 
30
- const addDependencies = () => {
31
- const dir = process.cwd();
32
- const path = `${dir}/package.json`;
33
- addDevDep(path, ['typescript']);
31
+ const createPackageJsonFile = (dir) => {
32
+ const packageJsonPath = `${dir}/package.json`;
33
+ jsonfile.writeFileSync(packageJsonPath, defaultTsPackageContent, { spaces: 2 });
34
+ if(debug) {
35
+ console.log('package.json file created.');
36
+ }
34
37
  }
35
38
 
36
- module.exports.supplementTypescript = supplementTypescript;
39
+ module.exports.initTypescriptProject = initTypescriptProject;
@@ -0,0 +1,27 @@
1
+
2
+ const packageTsContent =
3
+ {
4
+ name: 'sinto-project',
5
+ version: '0.0.1',
6
+ description: 'A project created by the Sinto command',
7
+ scripts: {
8
+ 'start': 'browser-sync start --config bs-config.json',
9
+ 'build': 'gulp',
10
+ 'ts': 'tsc'
11
+ },
12
+ "dependencies": {
13
+ "bootstrap": "^5.3.3"
14
+ },
15
+ "devDependencies": {
16
+ "browser-sync": "^3.0.2",
17
+ "gulp": "^5.0.0",
18
+ "gulp-clean-css": "^4.3.0",
19
+ "gulp-concat": "^2.6.1",
20
+ "gulp-uglify": "^3.0.2",
21
+ "gulp-replace": "^1.1.4",
22
+ "gulp-typescript": "6.0.0-alpha.1"
23
+ },
24
+ "type": "module"
25
+ }
26
+
27
+ module.exports = packageTsContent;
@@ -3,7 +3,7 @@ const tsconfigContent =
3
3
  {
4
4
  "compilerOptions": {
5
5
  "target": "ES6",
6
- "module": "commonjs",
6
+ "module": "ES6",
7
7
  "outDir": "./app",
8
8
  "strict": true,
9
9
  "esModuleInterop": true
@@ -11,4 +11,4 @@ const tsconfigContent =
11
11
  }
12
12
 
13
13
 
14
- module.exports = tsconfigContent;
14
+ module.exports = tsconfigContent;
package/genweb/genweb.js CHANGED
@@ -5,26 +5,37 @@ const fsExtra = require('fs-extra');
5
5
  const defaultPackageContent = require('../genweb/generators/genPackage');
6
6
  const defaultHtmlContent = require('../genweb/generators/genHtml');
7
7
  const defaultGulpfileContent = require('../genweb/generators/genGulpfile');
8
+ const defaultTsGulpfileContent = require('../gents/generators/genTsGulpfile');
8
9
  const defaultBsconfigContent = require('../genweb/generators/genBsconfig');
9
10
 
11
+
10
12
  const {
11
13
  createDirectory,
12
14
  createFile
13
15
  } = require('../tools/tools');
14
16
 
15
- const createWeb = () => {
17
+ const createWeb = (type) => {
16
18
  const currentDirectory = process.cwd();
17
19
 
18
20
  createDirectory(`${currentDirectory}/src`);
19
21
  createDirectory(`${currentDirectory}/src/assets`);
20
22
 
21
- createFile(`${currentDirectory}/src/style.css`, '');
22
- createFile(`${currentDirectory}/src/app.js`, '');
23
+ createFile(`${currentDirectory}/src/style.css`, '');
24
+
25
+ let content = '';
26
+ if(type === 'ts') {
27
+ createFile(`${currentDirectory}/src/app.ts`, '');
28
+ content = defaultTsGulpfileContent;
29
+ }else {
30
+ createFile(`${currentDirectory}/src/app.js`, '');
31
+ content = defaultGulpfileContent;
32
+ }
33
+
23
34
  createFile(`${currentDirectory}/README.md`, '# Sinto Project');
24
35
 
25
36
  createPackageJsonFile(currentDirectory);
26
37
  createIndexHtmlFile(currentDirectory);
27
- createGulpfileJsFile(currentDirectory);
38
+ createGulpfileJsFile(currentDirectory, content);
28
39
  createBsconfigFile(currentDirectory);
29
40
 
30
41
  console.log('Base directories and files created.');
@@ -45,13 +56,15 @@ const createIndexHtmlFile = (directory) => {
45
56
  console.log('index.html file created');
46
57
  }
47
58
 
48
- const createGulpfileJsFile = (directory) => {
59
+ const createGulpfileJsFile = (directory, content) => {
49
60
  const gulpfileJsPath = `${directory}/gulpfile.js`;
50
- fsExtra.writeFileSync(gulpfileJsPath, defaultGulpfileContent);
61
+ fsExtra.writeFileSync(gulpfileJsPath, content);
51
62
  if(debug)
52
63
  console.log('gulpfile.js file created.');
53
64
  }
54
65
 
66
+
67
+
55
68
  const createBsconfigFile = (directory) => {
56
69
  const bsconfigPath = `${directory}/bs-config.json`;
57
70
  jsonfile.writeFileSync(bsconfigPath, defaultBsconfigContent, { spaces: 2 });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sinto",
3
- "version": "1.6.1",
3
+ "version": "1.8.0",
4
4
  "description": "Website project development manager",
5
5
  "bin": {
6
6
  "sin": "sin.js"
package/sin.js CHANGED
@@ -7,8 +7,10 @@ const { build } = require('./build/build');
7
7
  const { rmno } = require('./rmno/rmno');
8
8
  const { createApi } = require('./haiserver/apigen');
9
9
  const { createWebpack } = require('./webpack/generate');
10
+ const { createEsbuildProject } = require('./esbuild/generate');
10
11
  const { createPuppeteerTest } = require('./gentest/generate');
11
- const { supplementTypescript } = require('./gents/gents');
12
+ const { supplementTypescript } = require('./addts/addts');
13
+ const { initTypescriptProject } = require('./gents/gents');
12
14
  const { createIndexHtmlCssFile } = require('./htmlcss/htmlcss');
13
15
 
14
16
  const program = new Command();
@@ -16,11 +18,11 @@ const program = new Command();
16
18
  program
17
19
  .name('sin')
18
20
  .description('Project handler')
19
- .version('1.6.1');
21
+ .version('1.8.0');
20
22
 
21
23
  program
22
24
  .command('init')
23
- .description('Initialize the web project')
25
+ .description('Initialize the Node.js web project')
24
26
  .action(() => {
25
27
  createWeb();
26
28
  });
@@ -69,12 +71,20 @@ program
69
71
  })
70
72
 
71
73
  program
72
- .command('ts')
74
+ .command('addts')
73
75
  .description('Supplement with TypeScript')
74
76
  .action(() => {
75
77
  supplementTypescript();
76
78
  })
77
79
 
80
+ program
81
+ .command('ts')
82
+ .description('Initialize TypeScript Node.js project')
83
+ .action(() => {
84
+ initTypescriptProject();
85
+ })
86
+
87
+
78
88
  program
79
89
  .command('web')
80
90
  .description('HTML és üres CSS fájl')
@@ -82,4 +92,11 @@ program
82
92
  createIndexHtmlCssFile();
83
93
  })
84
94
 
95
+ program
96
+ .command('esbuild')
97
+ .description('ESBuild client')
98
+ .action(() => {
99
+ createEsbuildProject();
100
+ });
101
+
85
102
  program.parse();
package/tools/dep.js CHANGED
@@ -31,6 +31,7 @@ async function readJsonFile(filePath) {
31
31
  }
32
32
 
33
33
  async function addDependencies(obj, packageNames, devDep) {
34
+ console.log(`Adding dependencies...`);
34
35
  for(const packageName of packageNames) {
35
36
  try {
36
37
  const newDependency = await getPackageInfo(packageName);
@@ -65,7 +66,8 @@ async function writeJsonFile(path, obj) {
65
66
  try {
66
67
  await jsonfile.writeFile(path, obj, { spaces: 2});
67
68
  if(debug) {
68
- console.log(`Added new depencies`);
69
+ console.log(`Written new JSON file: ${path}`);
70
+ console.log(obj);
69
71
  }
70
72
  } catch (err) {
71
73
  console.error('Error! Failed to write package.json:');