From 4ec9d1e432a3ca28504671faa0d02b52671d0fb2 Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Fri, 20 Dec 2019 15:56:59 +0100 Subject: [PATCH] Also generate README default values --- README.md | 4 ++-- scripts/import-editor.js | 28 +++++++++++++++++++++++----- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 956ec7d6..3c37ec7b 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ Options can be passed in to `MonacoWebpackPlugin`. They can be used to generate * `publicPath` (`string`) - custom public path for worker scripts, overrides the public path from which files generated by this plugin will be served. This wins out over Webpack's dynamic runtime path and can be useful to avoid attempting to load workers cross-origin when using a CDN for other static resources. Use e.g. '/' if you want to load your resources from the current origin.. * default value: `''`. * `languages` (`string[]`) - include only a subset of the languages supported. - * default value: `['apex', 'azcli', 'bat', 'clojure', 'coffee', 'cpp', 'csharp', 'csp', 'css', 'dockerfile', 'fsharp', 'go', 'handlebars', 'html', 'ini', 'java', 'javascript', 'json', 'less', 'lua', 'markdown', 'msdax', 'mysql', 'objective', 'perl', 'pgsql', 'php', 'postiats', 'powerquery', 'powershell', 'pug', 'python', 'r', 'razor', 'redis', 'redshift', 'ruby', 'rust', 'sb', 'scheme', 'scss', 'shell', 'solidity', 'sql', 'st', 'swift', 'typescript', 'vb', 'xml', 'yaml']`. + * default value: `['abap', 'apex', 'azcli', 'bat', 'clojure', 'coffee', 'cpp', 'csharp', 'csp', 'css', 'dockerfile', 'fsharp', 'go', 'graphql', 'handlebars', 'html', 'ini', 'java', 'javascript', 'json', 'kotlin', 'less', 'lua', 'markdown', 'mips', 'msdax', 'mysql', 'objective-c', 'pascal', 'pascaligo', 'perl', 'pgsql', 'php', 'postiats', 'powerquery', 'powershell', 'pug', 'python', 'r', 'razor', 'redis', 'redshift', 'ruby', 'rust', 'sb', 'scheme', 'scss', 'shell', 'solidity', 'sophia', 'sql', 'st', 'swift', 'tcl', 'twig', 'typescript', 'vb', 'xml', 'yaml']`. Some languages share the same web worker. If one of the following languages is included, you must also include the language responsible for instantiating their shared worker: @@ -64,7 +64,7 @@ Options can be passed in to `MonacoWebpackPlugin`. They can be used to generate * `features` (`string[]`) - include only a subset of the editor features. - * default value: `['accessibilityHelp', 'bracketMatching', 'caretOperations', 'clipboard', 'codeAction', 'codelens', 'colorDetector', 'comment', 'contextmenu', 'coreCommands', 'cursorUndo', 'dnd', 'find', 'folding', 'fontZoom', 'format', 'goToDefinitionCommands', 'goToDefinitionMouse', 'gotoError', 'gotoLine', 'hover', 'inPlaceReplace', 'inspectTokens', 'iPadShowKeyboard', 'linesOperations', 'links', 'multicursor', 'parameterHints', 'quickCommand', 'quickOutline', 'referenceSearch', 'rename', 'smartSelect', 'snippets', 'suggest', 'toggleHighContrast', 'toggleTabFocusMode', 'transpose', 'wordHighlighter', 'wordOperations', 'wordPartOperations']`. + * default value: `['accessibilityHelp', 'bracketMatching', 'caretOperations', 'clipboard', 'codeAction', 'codelens', 'colorDetector', 'comment', 'contextmenu', 'coreCommands', 'cursorUndo', 'dnd', 'find', 'folding', 'fontZoom', 'format', 'goToDefinitionCommands', 'goToDefinitionMouse', 'gotoError', 'gotoLine', 'hover', 'iPadShowKeyboard', 'inPlaceReplace', 'inspectTokens', 'linesOperations', 'links', 'multicursor', 'parameterHints', 'quickCommand', 'quickOutline', 'referenceSearch', 'rename', 'smartSelect', 'snippets', 'suggest', 'toggleHighContrast', 'toggleTabFocusMode', 'transpose', 'wordHighlighter', 'wordOperations', 'wordPartOperations']`. * excluded features: It is also possible to exclude certain default features prefixing them with an exclamation mark '!'. ## Contributing diff --git a/scripts/import-editor.js b/scripts/import-editor.js index 1468b0e5..6c9c9e32 100644 --- a/scripts/import-editor.js +++ b/scripts/import-editor.js @@ -155,10 +155,19 @@ export const languagesArr: IFeatureDefinition[] = ${ export type EditorLanguage = ${ result.map(el => `'${el.label}'`).join(' | ') -}; + }; ` fs.writeFileSync(path.join(__dirname, '../src/languages.ts'), code.replace(/\r\n/g, '\n')); + + const readmeLanguages = ( + JSON.stringify(result.map(r => r.label)) + .replace(/"/g, '\'') + .replace(/','/g, '\', \'') + ); + let readme = fs.readFileSync(path.join(__dirname, '../README.md')).toString(); + readme = readme.replace(/([^<]+)/, `\`${readmeLanguages}\``); + fs.writeFileSync(path.join(__dirname, '../README.md'), readme); }); } @@ -239,12 +248,21 @@ export const featuresArr: IFeatureDefinition[] = ${ }; export type EditorFeature = ${ - result.map(el => `'${el.label}'`).join(' | ') -}; + result.map(el => `'${el.label}'`).join(' | ') + }; export type NegatedEditorFeature = ${ - result.map(el => `'!${el.label}'`).join(' | ') -}; + result.map(el => `'!${el.label}'`).join(' | ') + }; ` fs.writeFileSync(path.join(__dirname, '../src/features.ts'), code.replace(/\r\n/g, '\n')); + + const readmeFeatures = ( + JSON.stringify(result.map(r => r.label)) + .replace(/"/g, '\'') + .replace(/','/g, '\', \'') + ); + let readme = fs.readFileSync(path.join(__dirname, '../README.md')).toString(); + readme = readme.replace(/([^<]+)/, `\`${readmeFeatures}\``); + fs.writeFileSync(path.join(__dirname, '../README.md'), readme); }