sinto 1.8.0 → 1.8.1

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
@@ -55,11 +55,12 @@ This command is generate public directory from src directory.
55
55
  * sin init - Initilalize the project
56
56
  * sin serve - Start development server
57
57
  * sin build - Start public generation
58
+ * sin rmno - Delete node_modules directory
58
59
  * sin api - Generate fake REST API with hai-server
59
60
  * sin webpack - Generate Webpack project
60
61
  * sin pup - Generate Puppeteer test with Mocha
61
- * sin rmno - Delete node_modules directory
62
- * sin ts - Generate tsconfig.json and add dependencies
62
+ * sin addts - Generate tsconfig.json and add dependencies
63
+ * sin ts - Initialize TypeScript Node.js project
63
64
  * sin web - Generate HTML and empty CSS files
64
65
  * sin esbuild - Generate esbuild project
65
66
 
@@ -17,6 +17,8 @@ const packageTsContent =
17
17
  "gulp": "^5.0.0",
18
18
  "gulp-clean-css": "^4.3.0",
19
19
  "gulp-concat": "^2.6.1",
20
+ "gulp-image": "^6.3.1",
21
+ "gulp-minify": "^3.1.0",
20
22
  "gulp-uglify": "^3.0.2",
21
23
  "gulp-replace": "^1.1.4",
22
24
  "gulp-typescript": "6.0.0-alpha.1"
@@ -0,0 +1,13 @@
1
+
2
+ const tsBsconfigContent =
3
+ {
4
+ server: [
5
+ "app",
6
+ "node_modules/bootstrap/dist/css",
7
+ "node_modules/bootstrap/dist/js"
8
+ ],
9
+ port: 3000,
10
+ watch: true
11
+ };
12
+
13
+ module.exports = tsBsconfigContent;
@@ -1,18 +1,19 @@
1
1
 
2
2
  const tsGulfileContent = `
3
- import {src, dest, parallel} from 'gulp';
3
+ import {src, dest, series} from 'gulp';
4
4
  import cleanCss from 'gulp-clean-css';
5
5
  import replace from 'gulp-replace';
6
6
  import concat from 'gulp-concat'
7
7
  import ts from 'gulp-typescript';
8
8
  import uglify from 'gulp-uglify';
9
+ import minify from 'gulp-minify';
9
10
 
10
11
  import {create as bsCreate} from 'browser-sync';
11
12
  const browserSync = bsCreate();
12
13
 
13
14
  function genHTML(cb) {
14
- src('src/**/*.html')
15
- .pipe(dest('public'))
15
+ src('app/**/*.html')
16
+ .pipe(dest('dist'))
16
17
  cb();
17
18
  }
18
19
 
@@ -25,17 +26,36 @@ function streamTs(cb) {
25
26
  cb();
26
27
  }
27
28
 
29
+ function minifyJS(cb) {
30
+ src([
31
+ 'public/**/*.js',
32
+ 'node_modules/bootstrap/dist/js/bootstrap.js'
33
+ ])
34
+ .pipe(replace(/import .*/g, ''))
35
+ .pipe(replace(/export .*/g, ''))
36
+ .pipe(concat('app.js'))
37
+ .pipe(minify())
38
+ .pipe(dest('dist'));
39
+ cb();
40
+ }
41
+
28
42
  function minifyCSS(cb) {
29
43
  src([
30
- 'src/**/*.css',
44
+ 'app/**/*.css',
31
45
  'node_modules/bootstrap/dist/css/bootstrap.css'])
32
46
  .pipe(cleanCss())
33
- .pipe(dest('public'));
47
+ .pipe(dest('dist'));
48
+ cb();
49
+ }
50
+
51
+ function copyImages(cb) {
52
+ src('app/assets/**/*')
53
+ .pipe(dest('dist/assets'));
34
54
  cb();
35
55
  }
36
56
 
37
57
  function build(cb) {
38
- parallel(genHTML, streamTs, minifyCSS)(cb);
58
+ series(genHTML, streamTs, minifyJS, minifyCSS, copyImages)(cb);
39
59
  }
40
60
 
41
61
  export default build
@@ -0,0 +1,44 @@
1
+ const {debug} = require('../../config.json');
2
+ const fsExtra = require('fs-extra');
3
+
4
+ const defaultTsGulpfileContent = require('./genTsGulpfile');
5
+ const defaultHtmlContent = require('../../genweb/generators/genHtml');
6
+ const defaultTsBsconfigContent = require('./genTsBsconfig');
7
+ const defaultTsPackageContent = require('../contents/tsPackageContent');
8
+
9
+ const {
10
+ createDirectory,
11
+ createFile,
12
+ createGulpfileJsFile,
13
+ createBsconfigFile,
14
+ createIndexHtmlFile,
15
+ createPackageJsonFile
16
+ } = require('../../tools/tools');
17
+
18
+ const outputDir = 'app';
19
+
20
+ const createTsWeb = () => {
21
+ const dir = process.cwd();
22
+
23
+ createDirectory(`${dir}/src`);
24
+ createDirectory(`${dir}/${outputDir}`);
25
+ createDirectory(`${dir}/${outputDir}/assets`);
26
+
27
+ createFile(`${dir}/${outputDir}/style.css`, '');
28
+
29
+ createFile(`${dir}/src/app.ts`, '');
30
+
31
+ createFile(`${dir}/README.md`, '# Sinto Project');
32
+
33
+ createPackageJsonFile(dir, defaultTsPackageContent);
34
+ createIndexHtmlFile(dir, outputDir, defaultHtmlContent);
35
+ createGulpfileJsFile(dir, defaultTsGulpfileContent);
36
+ createBsconfigFile(dir, defaultTsBsconfigContent);
37
+
38
+
39
+ console.log('Base directories and files created.');
40
+ };
41
+
42
+
43
+
44
+ module.exports.createTsWeb = createTsWeb
package/gents/gents.js CHANGED
@@ -1,15 +1,14 @@
1
1
  const {debug} = require('../config.json');
2
- const tsconfigContent = require('./tsconfigContent.js');
2
+ const tsconfigContent = require('./contents/tsconfigContent.js');
3
3
  const { createFile } = require('../tools/tools.js');
4
4
  const jsonfile = require('jsonfile');
5
5
  const { addDevDep, addScript } = require('../tools/dep.js');
6
6
  const fs = require('fs');
7
- const { createWeb } = require('../genweb/genweb');
8
- const defaultTsPackageContent = require('./tsPackageContent.js');
7
+ const { createTsWeb } = require('./generators/genTsWeb.js');
8
+ const defaultTsPackageContent = require('./contents/tsPackageContent.js');
9
9
 
10
10
  const initTypescriptProject = async () => {
11
- createWeb('ts');
12
- createPackageJsonFile(process.cwd());
11
+ createTsWeb();
13
12
  writeConfigFile();
14
13
  showMsg();
15
14
  }
@@ -28,12 +27,4 @@ pnpm install
28
27
  `);
29
28
  }
30
29
 
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
- }
37
- }
38
-
39
30
  module.exports.initTypescriptProject = initTypescriptProject;
package/genweb/genweb.js CHANGED
@@ -1,79 +1,47 @@
1
1
  const {debug} = require('../config.json');
2
- const jsonfile = require('jsonfile');
3
2
  const fsExtra = require('fs-extra');
4
3
 
5
4
  const defaultPackageContent = require('../genweb/generators/genPackage');
6
5
  const defaultHtmlContent = require('../genweb/generators/genHtml');
7
6
  const defaultGulpfileContent = require('../genweb/generators/genGulpfile');
8
- const defaultTsGulpfileContent = require('../gents/generators/genTsGulpfile');
9
7
  const defaultBsconfigContent = require('../genweb/generators/genBsconfig');
10
8
 
11
-
12
9
  const {
13
10
  createDirectory,
14
- createFile
11
+ createFile,
12
+ createGulpfileJsFile,
13
+ createBsconfigFile,
14
+ createIndexHtmlFile,
15
+ createPackageJsonFile
15
16
  } = require('../tools/tools');
16
17
 
17
- const createWeb = (type) => {
18
- const currentDirectory = process.cwd();
18
+ const createWeb = () => {
19
+ const dir = process.cwd();
19
20
 
20
- createDirectory(`${currentDirectory}/src`);
21
- createDirectory(`${currentDirectory}/src/assets`);
21
+ createDirectory(`${dir}/src`);
22
+ createDirectory(`${dir}/src/assets`);
22
23
 
23
- createFile(`${currentDirectory}/src/style.css`, '');
24
+ createFile(`${dir}/src/style.css`, '');
25
+
24
26
 
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
- }
27
+ createFile(`${dir}/src/app.js`, '');
33
28
 
34
- createFile(`${currentDirectory}/README.md`, '# Sinto Project');
29
+ createFile(`${dir}/README.md`, '# Sinto Project');
35
30
 
36
- createPackageJsonFile(currentDirectory);
37
- createIndexHtmlFile(currentDirectory);
38
- createGulpfileJsFile(currentDirectory, content);
39
- createBsconfigFile(currentDirectory);
31
+ createPackageJsonFile(dir, defaultPackageContent);
32
+ createIndexHtmlFile(dir, 'src', defaultHtmlContent);
33
+ createGulpfileJsFile(dir, defaultGulpfileContent);
34
+ createBsconfigFile(dir, defaultBsconfigContent);
40
35
 
41
36
  console.log('Base directories and files created.');
42
37
  };
43
38
 
44
- const createPackageJsonFile = (directory) => {
45
- const packageJsonPath = `${directory}/package.json`;
46
- jsonfile.writeFileSync(packageJsonPath, defaultPackageContent, { spaces: 2 });
47
- if(debug) {
48
- console.log('package.json file created.');
49
- }
50
- }
51
-
52
- const createIndexHtmlFile = (directory) => {
53
- const indexHtmlPath = `${directory}/src/index.html`;
54
- fsExtra.writeFileSync(indexHtmlPath, defaultHtmlContent);
55
- if(debug)
56
- console.log('index.html file created');
57
- }
58
39
 
59
- const createGulpfileJsFile = (directory, content) => {
60
- const gulpfileJsPath = `${directory}/gulpfile.js`;
61
- fsExtra.writeFileSync(gulpfileJsPath, content);
62
- if(debug)
63
- console.log('gulpfile.js file created.');
64
- }
65
40
 
66
41
 
67
42
 
68
- const createBsconfigFile = (directory) => {
69
- const bsconfigPath = `${directory}/bs-config.json`;
70
- jsonfile.writeFileSync(bsconfigPath, defaultBsconfigContent, { spaces: 2 });
71
- if(debug)
72
- console.log('bs-config.json file created.');
73
- }
74
43
 
75
44
  module.exports.createWeb = createWeb;
76
- module.exports.createPackageJsonFile = createPackageJsonFile;
77
- module.exports.createIndexHtmlFile = createIndexHtmlFile;
78
- module.exports.createGulpfileJsFile = createGulpfileJsFile;
79
- module.exports.createBsconfigFile = createBsconfigFile;
45
+ // module.exports.createPackageJsonFile = createPackageJsonFile;
46
+ // module.exports.createGulpfileJsFile = createGulpfileJsFile;
47
+ // module.exports.createBsconfigFile = createBsconfigFile;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sinto",
3
- "version": "1.8.0",
3
+ "version": "1.8.1",
4
4
  "description": "Website project development manager",
5
5
  "bin": {
6
6
  "sin": "sin.js"
package/sin.js CHANGED
@@ -18,7 +18,7 @@ const program = new Command();
18
18
  program
19
19
  .name('sin')
20
20
  .description('Project handler')
21
- .version('1.8.0');
21
+ .version('1.8.1');
22
22
 
23
23
  program
24
24
  .command('init')
package/tools/tools.js CHANGED
@@ -1,5 +1,6 @@
1
1
  const {debug} = require('../config.json');
2
2
  const fsExtra = require('fs-extra');
3
+ const jsonfile = require('jsonfile');
3
4
 
4
5
  const createDirectory = (path) => {
5
6
  if (!fsExtra.existsSync(path)) {
@@ -13,5 +14,38 @@ const createFile = (path, content) => {
13
14
  }
14
15
  }
15
16
 
17
+ const createGulpfileJsFile = (dir, content) => {
18
+ const gulpfileJsPath = `${dir}/gulpfile.js`;
19
+ fsExtra.writeFileSync(gulpfileJsPath, content);
20
+ if(debug)
21
+ console.log('gulpfile.js file created.');
22
+ }
23
+
24
+ const createBsconfigFile = (directory, content) => {
25
+ const bsconfigPath = `${directory}/bs-config.json`;
26
+ jsonfile.writeFileSync(bsconfigPath, content, { spaces: 2 });
27
+ if(debug)
28
+ console.log('bs-config.json file created.');
29
+ }
30
+
31
+ const createIndexHtmlFile = (dir, outputDir, content) => {
32
+ const indexHtmlPath = `${dir}/${outputDir}/index.html`;
33
+ fsExtra.writeFileSync(indexHtmlPath, content);
34
+ if(debug)
35
+ console.log('index.html file created');
36
+ }
37
+
38
+ const createPackageJsonFile = (directory, content) => {
39
+ const packageJsonPath = `${directory}/package.json`;
40
+ jsonfile.writeFileSync(packageJsonPath, content, { spaces: 2 });
41
+ if(debug) {
42
+ console.log('package.json file created.');
43
+ }
44
+ }
45
+
16
46
  module.exports.createDirectory = createDirectory;
17
47
  module.exports.createFile = createFile;
48
+ module.exports.createGulpfileJsFile = createGulpfileJsFile;
49
+ module.exports.createBsconfigFile = createBsconfigFile;
50
+ module.exports.createIndexHtmlFile = createIndexHtmlFile;
51
+ module.exports.createPackageJsonFile = createPackageJsonFile;