microsoft / vscode-generator-code

Visual Studio Code extension generator
Other
1.29k stars 222 forks source link

`yo code` Fails when attempting to create a new language support extention #58

Closed Lindenk closed 7 years ago

Lindenk commented 7 years ago

I've created a dummy test.tmLanguage file to initialize myself a new language using yo code. After filling in all the prompts, yo code crashes.

Here's the related error and entries, and the .tmLanguage file used:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>name</key>
    <string>Test</string>
    <key>scope</key>
    <string>test.test</string>
    <key>settings</key>
    <dict>
    </dict>
    <key>uuid</key>
    <string>A67A8BD9-A951-406F-9175-018DD4B52FD1</string>
</dict>
</plist>
> yo code             

     _-----_     ╭──────────────────────────╮
    |       |    │   Welcome to the Visual  │
    |--(o)--|    │   Studio Code Extension  │
   `---------´   │        generator!        │
    ( _´U`_ )    ╰──────────────────────────╯
    /___A___\   /
     |  ~  |     
   __'.___.'__   
 ´   `  |° ´ Y ` 

? What type of extension do you want to create? New Language Support
URL (http, https) or file name of the tmLanguage file, e.g., http://raw.githubusercontent.com/textmate/ant.tmbundle/master/Syntaxes/Ant.tmLanguage.
? URL or file: test.tmLanguage
? What's the name of your extension? Test
? What's the identifier of your extension? test
? What's the description of your extension? A test language
? What's your publisher name? testman
Verify the id of the language. The id is an identifier and is single, lower-case name such as 'php', 'javascript'
? Detected languageId: test
Verify the name of the language. The name will be shown in the VS code editor mode selector.
? Detected name: Test
Verify the file extensions of the language. Use commas to separate multiple entries (e.g. .ruby, .rb)
? Detected file extensions: .test
events.js:160
      throw er; // Unhandled 'error' event
      ^

ReferenceError: /usr/lib/node_modules/generator-code/generators/app/templates/ext-language/package.json:22
    20|         "grammars": [{
    21|             "language": <%- JSON.stringify(languageId) %>,
 >> 22|             "scopeName": <%- JSON.stringify(languageScopeName) %>,
    23|             "path": <%- JSON.stringify("./syntaxes/" + languageId + ".tmLanguage") %>
    24|         }]
    25|     }

languageScopeName is not defined
    at eval (eval at compile (/usr/lib/node_modules/generator-code/node_modules/ejs/lib/ejs.js:498:12), <anonymous>:40:31)
    at returnedFn (/usr/lib/node_modules/generator-code/node_modules/ejs/lib/ejs.js:529:17)
    at Object.exports.render (/usr/lib/node_modules/generator-code/node_modules/ejs/lib/ejs.js:339:37)
    at process (/usr/lib/node_modules/generator-code/node_modules/mem-fs-editor/lib/actions/copy-tpl.js:12:18)
    at applyProcessingFunc (/usr/lib/node_modules/generator-code/node_modules/mem-fs-editor/lib/actions/copy.js:13:16)
    at EditionInterface.exports._copySingle (/usr/lib/node_modules/generator-code/node_modules/mem-fs-editor/lib/actions/copy.js:51:16)
    at EditionInterface.exports.copy (/usr/lib/node_modules/generator-code/node_modules/mem-fs-editor/lib/actions/copy.js:23:17)
    at EditionInterface.module.exports [as copyTpl] (/usr/lib/node_modules/generator-code/node_modules/mem-fs-editor/lib/actions/copy-tpl.js:10:8)
    at constructor.template (/usr/lib/node_modules/generator-code/node_modules/yeoman-generator/lib/actions/actions.js:134:11)
    at constructor._writingLanguage (/usr/lib/node_modules/generator-code/generators/app/index.js:563:14

I'm running:

OS:                     Arch Linux x64
Nodejs version:         v7.2.0

(installed fresh from npm)
yo version:             1.8.5
generator-code version: 1.1.4

Of course, the real issue here is #55. It's possible there might be something wrong with this dummy test.tmLanguage file, however there is no documentation anywhere I can find on how to create a new language definition. Either way, I would expect a crash during prompts would be a bug in any context.

aeschli commented 7 years ago

Fixed in generator-code@1.1.5