sinto 1.7.0 → 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 +32 -3
- package/addts/addts.js +43 -0
- package/addts/tsconfigContent.js +13 -0
- package/gents/generators/genTsGulpfile.js +45 -0
- package/gents/gents.js +20 -17
- package/gents/tsPackageContent.js +27 -0
- package/gents/tsconfigContent.js +2 -2
- package/genweb/genweb.js +19 -6
- package/package.json +1 -1
- package/sin.js +13 -4
- package/tools/dep.js +3 -1
package/README.md
CHANGED
|
@@ -157,20 +157,49 @@ Write the tests in test directory and run the tests:
|
|
|
157
157
|
npm test
|
|
158
158
|
```
|
|
159
159
|
|
|
160
|
-
## TypeScript
|
|
160
|
+
## TypeScript
|
|
161
161
|
|
|
162
|
-
|
|
162
|
+
### TypeScript config and dependencies
|
|
163
163
|
|
|
164
|
-
The **sin
|
|
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.
|
|
165
167
|
|
|
166
168
|
Using:
|
|
167
169
|
|
|
168
170
|
```cmd
|
|
169
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
|
|
170
183
|
sin ts
|
|
171
184
|
npm i
|
|
172
185
|
```
|
|
173
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
|
+
|
|
174
203
|
## ESBuild project generator
|
|
175
204
|
|
|
176
205
|
The sin esbuild command generate a esbuild project.
|
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,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
|
|
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
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
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
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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.
|
|
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;
|
package/gents/tsconfigContent.js
CHANGED
|
@@ -3,7 +3,7 @@ const tsconfigContent =
|
|
|
3
3
|
{
|
|
4
4
|
"compilerOptions": {
|
|
5
5
|
"target": "ES6",
|
|
6
|
-
"module": "
|
|
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
|
-
|
|
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,
|
|
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
package/sin.js
CHANGED
|
@@ -9,7 +9,8 @@ const { createApi } = require('./haiserver/apigen');
|
|
|
9
9
|
const { createWebpack } = require('./webpack/generate');
|
|
10
10
|
const { createEsbuildProject } = require('./esbuild/generate');
|
|
11
11
|
const { createPuppeteerTest } = require('./gentest/generate');
|
|
12
|
-
const { supplementTypescript } = require('./
|
|
12
|
+
const { supplementTypescript } = require('./addts/addts');
|
|
13
|
+
const { initTypescriptProject } = require('./gents/gents');
|
|
13
14
|
const { createIndexHtmlCssFile } = require('./htmlcss/htmlcss');
|
|
14
15
|
|
|
15
16
|
const program = new Command();
|
|
@@ -17,11 +18,11 @@ const program = new Command();
|
|
|
17
18
|
program
|
|
18
19
|
.name('sin')
|
|
19
20
|
.description('Project handler')
|
|
20
|
-
.version('1.
|
|
21
|
+
.version('1.8.0');
|
|
21
22
|
|
|
22
23
|
program
|
|
23
24
|
.command('init')
|
|
24
|
-
.description('Initialize the web project')
|
|
25
|
+
.description('Initialize the Node.js web project')
|
|
25
26
|
.action(() => {
|
|
26
27
|
createWeb();
|
|
27
28
|
});
|
|
@@ -70,12 +71,20 @@ program
|
|
|
70
71
|
})
|
|
71
72
|
|
|
72
73
|
program
|
|
73
|
-
.command('
|
|
74
|
+
.command('addts')
|
|
74
75
|
.description('Supplement with TypeScript')
|
|
75
76
|
.action(() => {
|
|
76
77
|
supplementTypescript();
|
|
77
78
|
})
|
|
78
79
|
|
|
80
|
+
program
|
|
81
|
+
.command('ts')
|
|
82
|
+
.description('Initialize TypeScript Node.js project')
|
|
83
|
+
.action(() => {
|
|
84
|
+
initTypescriptProject();
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
|
|
79
88
|
program
|
|
80
89
|
.command('web')
|
|
81
90
|
.description('HTML és üres CSS fájl')
|
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(`
|
|
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:');
|