@needle-tools/needle-component-compiler 1.9.2-exp → 1.9.3

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/COMPILE.bat ADDED
@@ -0,0 +1 @@
1
+ npm run tsc src/component-compiler
package/Changelog.md CHANGED
@@ -4,8 +4,12 @@ All notable changes to this package will be documented in this file.
4
4
  The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5
5
  and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6
6
 
7
- ## [1.9.2-exp] - 2022-11-12
8
- - Add first version of blender scheme compiler
7
+ ## [1.9.3] - 2022-12-30
8
+ - Add debug logs for when no file or target directory was passed in. Also wrapping core with try catch
9
+
10
+ ## [1.9.2] - 2022-11-29
11
+ - Fix codegen deleting code added manually outside of codegen sections
12
+ - Fix codegen creating output directory if it does not exist yet
9
13
 
10
14
  ## [1.9.1] - 2022-11-05
11
15
  - Fix ``new Vector2(1, .5)`` generating invalid C# where number arguments were emitted as double instead of float
package/DEV.bat ADDED
@@ -0,0 +1 @@
1
+ npm install && npm run dev
package/INSTALL.bat ADDED
@@ -0,0 +1 @@
1
+ npm install && timeout 10
package/PUBLISH.bat ADDED
@@ -0,0 +1,8 @@
1
+ @echo off
2
+ echo Press a key to publish! (close the window if you changed your mind)
3
+ pause
4
+ echo Publishing in 2 sec
5
+ timeout 2
6
+ npm run compile & npm set registry https://registry.npmjs.org && npm publish & pause
7
+ echo Finished...
8
+ timeout 10
@@ -0,0 +1 @@
1
+ npm run tsc src/component-compiler && node src/component-compiler.js dist src/test.ts
package/RUN_TESTS.bat ADDED
@@ -0,0 +1 @@
1
+ npm run test & pause
package/package.json CHANGED
@@ -1,16 +1,15 @@
1
1
  {
2
2
  "name": "@needle-tools/needle-component-compiler",
3
- "version": "1.9.2-exp",
3
+ "version": "1.9.3",
4
4
  "description": "Compile mock unity components from typescript",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
7
  "tsc": "tsc",
8
- "dev": "npm-watch compile || exit 1",
9
- "compile": "tsc",
8
+ "dev": "npm-watch compile",
9
+ "compile" : "tsc",
10
10
  "test": "mocha -r ts-node/register test/**.test.ts"
11
11
  },
12
12
  "dependencies": {
13
- "chokidar": "^3.5.3",
14
13
  "typescript": "^4.5.5"
15
14
  },
16
15
  "devDependencies": {
@@ -19,21 +18,17 @@
19
18
  "@types/node": "^18.7.18",
20
19
  "chai": "^4.3.6",
21
20
  "mocha": "^10.0.0",
22
- "npm-watch": "^0.11.0",
23
- "ts-node": "^10.9.1"
21
+ "ts-node": "^10.9.1",
22
+ "npm-watch": "^0.11.0"
24
23
  },
25
24
  "watch": {
26
- "compile": {
27
- "patterns": [
28
- "src/base-compiler.ts",
29
- "src/blender-compiler.ts",
30
- "src/component-compiler.ts",
31
- "src/watcher.ts"
32
- ],
33
- "ignore": "src/test.ts",
34
- "extensions": "ts",
35
- "quiet": false
36
- }
25
+ "compile": {
26
+ "patterns": [
27
+ "src/component-compiler.ts"
28
+ ],
29
+ "extensions": "ts",
30
+ "quiet": false
31
+ }
37
32
  },
38
33
  "author": {
39
34
  "name": "Needle",
@@ -90,18 +90,24 @@ var ExportContext = /** @class */ (function () {
90
90
  this.append(text + "\n");
91
91
  };
92
92
  ExportContext.prototype.flush = function () {
93
- if (this.textBuffer.length <= 0)
93
+ if (this.textBuffer.length <= 0) {
94
94
  return;
95
+ }
95
96
  this.textBuffer = CODEGEN_MARKER_START + "\n" + this.textBuffer + "\n" + CODEGEN_MARKER_END;
96
97
  var code = this.textBuffer;
97
98
  if (this.outputDir !== null) {
99
+ if (!fs.existsSync(this.outputDir))
100
+ fs.mkdirSync(this.outputDir);
98
101
  var dir = this.outputDir + "/";
99
102
  var path_1 = dir + this.fileName;
100
- this.replaceGeneratedCodeSection(path_1);
103
+ code = this.replaceGeneratedCodeSection(path_1, code);
101
104
  if (allowDebugLogs)
102
105
  console.log("Write to " + path_1);
103
106
  fs.writeFileSync(path_1, code);
104
107
  }
108
+ else {
109
+ console.log("No output dir specified");
110
+ }
105
111
  this.reset();
106
112
  return code;
107
113
  };
@@ -109,7 +115,7 @@ var ExportContext = /** @class */ (function () {
109
115
  this.textBuffer = "";
110
116
  this.classEnd = -1;
111
117
  };
112
- ExportContext.prototype.replaceGeneratedCodeSection = function (path) {
118
+ ExportContext.prototype.replaceGeneratedCodeSection = function (path, code) {
113
119
  if (fs.existsSync(path)) {
114
120
  var existing = fs.readFileSync(path, "utf8");
115
121
  var regex = new RegExp("(?<before>.*?)\/\/ ?NEEDLE_CODEGEN_START.+\/\/ ?NEEDLE_CODEGEN_END(?<after>.*)", "s");
@@ -119,9 +125,10 @@ var ExportContext = /** @class */ (function () {
119
125
  console.log("Found codegen sections");
120
126
  var before_1 = matches.groups.before;
121
127
  var after_1 = matches.groups.after;
122
- this.textBuffer = before_1 + this.textBuffer + after_1;
128
+ return before_1 + code + after_1;
123
129
  }
124
130
  }
131
+ return code;
125
132
  };
126
133
  return ExportContext;
127
134
  }());
@@ -688,11 +695,17 @@ if (process) {
688
695
  var outputDir_1 = process.argv[2];
689
696
  var fileNames = process.argv.slice(3);
690
697
  fileNames.forEach(function (fileName) {
691
- if (!fs.existsSync(fileName)) {
698
+ try {
699
+ if (!fs.existsSync(fileName)) {
700
+ console.error("File not found: " + fileName);
701
+ }
702
+ else {
703
+ var code = (0, fs_1.readFileSync)(fileName).toString();
704
+ compile(code, fileName, outputDir_1);
705
+ }
692
706
  }
693
- else {
694
- var code = (0, fs_1.readFileSync)(fileName).toString();
695
- compile(code, fileName, outputDir_1);
707
+ catch (e) {
708
+ console.error(e);
696
709
  }
697
710
  });
698
711
  }