Browse Source

- generate a jsconfig.json file for JavaScript projects
- Make sure the TypeScript build task doesn’t get generated for JavaScript projects

Shaddock Heath 8 years ago
parent
commit
11b9ac1f26

+ 57 - 40
Script/AtomicEditor/hostExtensions/languageExtensions/TypescriptLanguageExtension.ts

@@ -397,6 +397,19 @@ export default class TypescriptLanguageExtension extends Atomic.ScriptObject imp
 
 
             tsconfigFile.writeString(JSON.stringify(tsconfig, null, 4));
             tsconfigFile.writeString(JSON.stringify(tsconfig, null, 4));
             tsconfigFile.close();
             tsconfigFile.close();
+        } else {
+            const jsconfigFile = new Atomic.File(projectDir + "jsconfig.json", Atomic.FileMode.FILE_WRITE);
+            let jsconfig = {
+                "compilerOptions": {
+                    "target": "es5"
+                }
+            };
+
+            // Don't use fully qualified path in the persistent jsconfig file, just use a relative path from the jsconfig
+            jsconfig.compilerOptions["baseUrl"] = "./Resources";
+
+            jsconfigFile.writeString(JSON.stringify(jsconfig, null, 4));
+            jsconfigFile.close();
         }
         }
 
 
         this.generateVsCodeFiles();
         this.generateVsCodeFiles();
@@ -411,47 +424,51 @@ export default class TypescriptLanguageExtension extends Atomic.ScriptObject imp
         Atomic.fileSystem.createDir(vscodeDir);
         Atomic.fileSystem.createDir(vscodeDir);
 
 
         // Build out the vscode tasks.json
         // Build out the vscode tasks.json
-        const tasks = {
+        const taskFile = {
             "version": "0.1.0",
             "version": "0.1.0",
-            "tasks": [
-                {
-                    "taskName": "Build",
-                    "command": "tsc",
-                    "isShellCommand": true,
-                    "args": [
-                        "-p",
-                        "."
-                    ],
-                    "showOutput": "always",
-                    "problemMatcher": "$tsc",
-                    "isBuildCommand": true
-                },
-                {
-                    "taskName": "Debug Atomic Player",
-                    "command": `${ToolCore.toolEnvironment.editorBinary}`,
-                    "args": [
-                        "--player",
-                        "--debug",
-                        "--project",
-                        "${workspaceRoot}"
-                    ],
-                    "isBackground": true
-                },
-                {
-                    "taskName": "Launch Atomic Player",
-                    "command": `${ToolCore.toolEnvironment.editorBinary}`,
-                    "args": [
-                        "--player",
-                        "--project",
-                        "${workspaceRoot}"
-                    ],
-                    "isBackground": true
-                }
-            ]
+            "tasks": []
         };
         };
 
 
+        if (this.isTypescriptProject) {
+            taskFile.tasks.push({
+                "taskName": "Build",
+                "command": "tsc",
+                "isShellCommand": true,
+                "args": [
+                    "-p",
+                    "."
+                ],
+                "showOutput": "always",
+                "problemMatcher": "$tsc",
+                "isBuildCommand": true
+            });
+        };
+
+        taskFile.tasks.push({
+            "taskName": "Debug Atomic Player",
+            "command": `${ToolCore.toolEnvironment.editorBinary}`,
+            "args": [
+                "--player",
+                "--debug",
+                "--project",
+                "${workspaceRoot}"
+            ],
+            "isBackground": true
+        });
+
+        taskFile.tasks.push({
+            "taskName": "Launch Atomic Player",
+            "command": `${ToolCore.toolEnvironment.editorBinary}`,
+            "args": [
+                "--player",
+                "--project",
+                "${workspaceRoot}"
+            ],
+            "isBackground": true
+        });
+
         const tasksFile = new Atomic.File(vscodeDir + "tasks.json", Atomic.FileMode.FILE_WRITE);
         const tasksFile = new Atomic.File(vscodeDir + "tasks.json", Atomic.FileMode.FILE_WRITE);
-        tasksFile.writeString(JSON.stringify(tasks, null, 4));
+        tasksFile.writeString(JSON.stringify(taskFile, null, 4));
         tasksFile.close();
         tasksFile.close();
 
 
         // Build vscode launch.json
         // Build vscode launch.json
@@ -503,10 +520,10 @@ export default class TypescriptLanguageExtension extends Atomic.ScriptObject imp
             const webClient = new WebView.WebClient();
             const webClient = new WebView.WebClient();
             this.webClient = webClient;
             this.webClient = webClient;
             //this.webClient.loadURL(url);
             //this.webClient.loadURL(url);
-
+ 
             const webTexture = new WebView.WebTexture2D();
             const webTexture = new WebView.WebTexture2D();
             webClient.webRenderHandler = webTexture;
             webClient.webRenderHandler = webTexture;
-
+ 
             // doesn't work because atomicquery doesn't seem to be exposed to WebView.WebClient instances
             // doesn't work because atomicquery doesn't seem to be exposed to WebView.WebClient instances
             webClient.subscribeToEvent(EditorEvents.WebMessage, (data) => {
             webClient.subscribeToEvent(EditorEvents.WebMessage, (data) => {
                 switch (data.message) {
                 switch (data.message) {
@@ -516,7 +533,7 @@ export default class TypescriptLanguageExtension extends Atomic.ScriptObject imp
                         break;
                         break;
                 }
                 }
             });
             });
-
+ 
             webClient.createBrowser(url, 1, 1);
             webClient.createBrowser(url, 1, 1);
         */
         */
     }
     }