sinto 1.8.0 → 1.9.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
@@ -1,9 +1,6 @@
1
- # Sinto web project management
1
+ # Sinto project management
2
2
 
3
- Simple project management, with the Browser-sync and gulp packages in the background.
4
-
5
- * Development in the src directory.
6
- * Publishing from the public directory.
3
+ A generateable web application using JavaScirpt and TypeScript, and a JavaFX form application for VSCode.
7
4
 
8
5
  GitHub:
9
6
 
@@ -55,19 +52,21 @@ This command is generate public directory from src directory.
55
52
  * sin init - Initilalize the project
56
53
  * sin serve - Start development server
57
54
  * sin build - Start public generation
55
+ * sin rmno - Delete node_modules directory
58
56
  * sin api - Generate fake REST API with hai-server
59
57
  * sin webpack - Generate Webpack project
60
58
  * sin pup - Generate Puppeteer test with Mocha
61
- * sin rmno - Delete node_modules directory
62
- * sin ts - Generate tsconfig.json and add dependencies
59
+ * sin addts - Generate tsconfig.json and add dependencies
60
+ * sin ts - Initialize TypeScript Node.js project
63
61
  * sin web - Generate HTML and empty CSS files
64
62
  * sin esbuild - Generate esbuild project
63
+ * sin javafx - Generate JavaFX project
65
64
 
66
- The Default task manager is gulp. Development serve is browser-sync.
65
+ For web application, the default task manager is gulp. Development serve is browser-sync.
67
66
 
68
67
  ## Fake REST API server
69
68
 
70
- The sin api command generate fake REST API project directory.
69
+ The sin api command generate fake REST API project directory with hai-server.
71
70
 
72
71
  Using:
73
72
 
@@ -243,3 +242,22 @@ pnpm build
243
242
  ```
244
243
 
245
244
  This command is generate dist directory from src directory. The build command not copy the public directory.
245
+
246
+ ## JavaFX project generator
247
+
248
+ The **sin javafx** command generate a JavaFX project. The generated project willl be a package generated with **No build tools** for VSCode.
249
+
250
+ Steps to use:
251
+
252
+ * Create project directory. For example: **mkdir app01**
253
+ * Change directory to project directory. For example: **cd app01**
254
+ * Create a JavaFX project with the **sin javafx** command.
255
+ * Copy to lib dirctory JavaFX libraries.
256
+ * Open project directory with VSCode: code .
257
+ * Add Configuration with VSCode: **Run** > **Add Configuration..**
258
+ * Save the .vscode/launch.json file.
259
+ * Run project with VSCode: **Run** > **Run** This will fail.
260
+ * Set the JavaFX path. For example: **sin javafx -p lib/javafx**
261
+ * Open the mainScedne.fmxl file, and add components, and save.
262
+
263
+ Change the path to your JavaFX path.
@@ -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;
@@ -0,0 +1,46 @@
1
+ const appContent = `
2
+ import javafx.application.Application;
3
+ import javafx.fxml.FXMLLoader;
4
+ import javafx.scene.Parent;
5
+ import javafx.scene.Scene;
6
+ import javafx.stage.Stage;
7
+
8
+ import java.io.IOException;
9
+
10
+ public class App extends Application {
11
+
12
+ private static Scene scene;
13
+
14
+ @Override
15
+ public void start(Stage stage) throws IOException {
16
+ scene = new Scene(loadFxml("mainScene"), 640, 480);
17
+ stage.setScene(scene);
18
+ stage.show();
19
+ }
20
+
21
+ static void setRoot(String fileName) throws IOException {
22
+ scene.setRoot(loadFxml(fileName));
23
+ }
24
+
25
+ private static Parent loadFxml(String fileName) {
26
+ try {
27
+ return tryLoadFxml(fileName);
28
+ } catch (IOException e) {
29
+ System.err.println("Unable to load FXML file: " + fileName);
30
+ System.err.println(e.getMessage());
31
+ return null;
32
+ }
33
+ }
34
+
35
+ private static Parent tryLoadFxml(String fileName) throws IOException {
36
+ FXMLLoader loader = new FXMLLoader(App.class.getResource(fileName + ".fxml"));
37
+ return loader.load();
38
+ }
39
+
40
+ public static void main(String[] args) {
41
+ launch();
42
+ }
43
+
44
+ }
45
+ `
46
+ module.exports = appContent
@@ -0,0 +1,33 @@
1
+ const { createFile, createDirectory } = require('../tools/tools.js');
2
+ const appContent = require('./appContent');
3
+ const settingsContent = require('./settingsContent');
4
+ const launchContent = require('./launchContent');
5
+ const gitignoreContent = require('./gitignoreContent');
6
+ const { exit } = require('browser-sync');
7
+ const { setJavafxPath } = require('./setJavafxPath');
8
+
9
+ const createJavafxProject = (argv) => {
10
+
11
+ if (argv.path != undefined) {
12
+ setJavafxPath(argv.path);
13
+ exit(0);
14
+ }
15
+
16
+ const dir = process.cwd();
17
+ createDirectory(`${dir}/.vscode`);
18
+ createDirectory(`${dir}/lib`);
19
+ createDirectory(`${dir}/src`);
20
+ createFile(`${dir}/src/App.java`, appContent);
21
+ createFile(`${dir}/.vscode/settings.json`, settingsContent);
22
+
23
+ createFile(`${dir}/src/mainScene.fxml`, '');
24
+
25
+ createFile(`${dir}/README.md`, '# Sinto JavaFX project\n');
26
+ createFile(`${dir}/.vscode/launch.json`, launchContent);
27
+
28
+ createFile(`${dir}/.gitignore`, gitignoreContent);
29
+ createFile(`${dir}/lib/.gitkeep`, '');
30
+
31
+ }
32
+
33
+ module.exports.createJavafxProject = createJavafxProject;
@@ -0,0 +1,8 @@
1
+ const gitignoreContent = `
2
+ bin/
3
+ *.jar
4
+ *.class
5
+ *.properties
6
+ *.so
7
+ `
8
+ module.exports = gitignoreContent
@@ -0,0 +1,17 @@
1
+ const launchContent = `
2
+ {
3
+ // Use IntelliSense to learn about possible attributes.
4
+ // Hover to view descriptions of existing attributes.
5
+ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
6
+ "version": "0.2.0",
7
+ "configurations": [
8
+ {
9
+ "type": "java",
10
+ "name": "Current File",
11
+ "request": "launch",
12
+ "mainClass": "\${file}"
13
+ }
14
+ ]
15
+ }
16
+ `
17
+ module.exports = launchContent
@@ -0,0 +1,51 @@
1
+ const {debug} = require('../config.json');
2
+ const { read } = require("fs-extra");
3
+ const jsonfile = require('jsonfile');
4
+ const hjson = require('hjson');
5
+ const fs = require('fs');
6
+
7
+ const setJavafxPath = (path) => {
8
+ const dir = process.cwd();
9
+
10
+ readJsonFile(`${dir}/.vscode/launch.json`).then((data) => {
11
+ var obj = hjson.parse(data);
12
+ obj.configurations.forEach( conf => {
13
+ conf.vmArgs = `--module-path ${path} --add-modules javafx.controls,javafx.fxml`;
14
+ })
15
+
16
+
17
+ var newData = hjson.stringify(obj, {space: 2, quotes: 'all', separator: true});
18
+ console.log('newData: ', newData);
19
+ writeJsonFile(`${dir}/.vscode/launch.json`, newData);
20
+ console.log('launch.json updated.');
21
+ });
22
+ }
23
+
24
+ async function readJsonFile(filePath) {
25
+ try {
26
+
27
+ const data = await fs.promises.readFile(filePath, 'utf8');
28
+ if(debug) {
29
+ console.log(`Readed JSON file`);
30
+ }
31
+ return data;
32
+ } catch (err) {
33
+ console.error(`Error! Failed to read ${filePath}`);
34
+ console.error(err);
35
+ }
36
+ }
37
+
38
+ async function writeJsonFile(path, data) {
39
+ try {
40
+ await fs.promises.writeFile(path, data);
41
+ if(debug) {
42
+ console.log(`Written new JSON file: ${path}`);
43
+ console.log(obj);
44
+ }
45
+ } catch (err) {
46
+ console.error('Error! Failed to write package.json:');
47
+ console.error(err);
48
+ }
49
+ }
50
+
51
+ module.exports.setJavafxPath = setJavafxPath
@@ -0,0 +1,10 @@
1
+ const settingsContent = `
2
+ {
3
+ "java.project.sourcePaths": ["src"],
4
+ "java.project.outputPath": "bin",
5
+ "java.project.referencedLibraries": [
6
+ "lib/**/*.jar"
7
+ ]
8
+ }
9
+ `
10
+ module.exports = settingsContent
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "sinto",
3
- "version": "1.8.0",
4
- "description": "Website project development manager",
3
+ "version": "1.9.0",
4
+ "description": "Project development manager for web and JavaFX",
5
5
  "bin": {
6
6
  "sin": "sin.js"
7
7
  },
@@ -15,6 +15,7 @@
15
15
  "commander": "^12.1.0",
16
16
  "fs-extra": "^11.2.0",
17
17
  "gulp": "^5.0.0",
18
+ "hjson": "^3.2.2",
18
19
  "jsonfile": "^6.1.0",
19
20
  "yargs": "^17.7.2"
20
21
  },
package/sin.js CHANGED
@@ -12,13 +12,14 @@ const { createPuppeteerTest } = require('./gentest/generate');
12
12
  const { supplementTypescript } = require('./addts/addts');
13
13
  const { initTypescriptProject } = require('./gents/gents');
14
14
  const { createIndexHtmlCssFile } = require('./htmlcss/htmlcss');
15
+ const { createJavafxProject } = require('./javafx/generate');
15
16
 
16
17
  const program = new Command();
17
18
 
18
19
  program
19
20
  .name('sin')
20
21
  .description('Project handler')
21
- .version('1.8.0');
22
+ .version('1.9.0');
22
23
 
23
24
  program
24
25
  .command('init')
@@ -84,7 +85,6 @@ program
84
85
  initTypescriptProject();
85
86
  })
86
87
 
87
-
88
88
  program
89
89
  .command('web')
90
90
  .description('HTML és üres CSS fájl')
@@ -99,4 +99,12 @@ program
99
99
  createEsbuildProject();
100
100
  });
101
101
 
102
+ program
103
+ .command('javafx')
104
+ .description('JavaFX project No build tools')
105
+ .option('-p, --path [path]', 'Path to javafx')
106
+ .action(( options ) => {
107
+ createJavafxProject(options);
108
+ })
109
+
102
110
  program.parse();
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;