sinto 1.8.1 → 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
 
@@ -63,12 +60,13 @@ This command is generate public directory from src directory.
63
60
  * sin ts - Initialize TypeScript Node.js project
64
61
  * sin web - Generate HTML and empty CSS files
65
62
  * sin esbuild - Generate esbuild project
63
+ * sin javafx - Generate JavaFX project
66
64
 
67
- 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.
68
66
 
69
67
  ## Fake REST API server
70
68
 
71
- The sin api command generate fake REST API project directory.
69
+ The sin api command generate fake REST API project directory with hai-server.
72
70
 
73
71
  Using:
74
72
 
@@ -244,3 +242,22 @@ pnpm build
244
242
  ```
245
243
 
246
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.
@@ -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.1",
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.1');
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();