Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

generator-langium

Package Overview
Dependencies
Maintainers
3
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

generator-langium - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

5

app/index.d.ts

@@ -6,2 +6,3 @@ /******************************************************************************

******************************************************************************/
/// <reference types="node" />
import Generator from 'yeoman-generator';

@@ -14,4 +15,8 @@ declare class LangiumGenerator extends Generator {

install(): void;
end(): Promise<void>;
_extensionPath(...path: string[]): string;
_replaceTemplateWords(fileExtensionGlob: string, languageName: string, languageId: string, content: Buffer): string;
_replaceTemplateNames(languageId: string, path: string): string;
}
export = LangiumGenerator;
//# sourceMappingURL=index.d.ts.map

81

app/index.js

@@ -14,12 +14,12 @@ "use strict";

const path_1 = __importDefault(require("path"));
const which_1 = __importDefault(require("which"));
const TEMPLATE_DIR = '../langium-template';
const USER_DIR = '.';
const OPEN = '<%= ';
const CLOSE = ' %>';
const EXTENSION_NAME = 'extension-name';
const RAW_LANGUAGE_NAME = 'RawLanguageName';
const FILE_EXTENSION = 'file-extension';
const FILE_EXTENSION_GLOB = 'file-glob-extension';
const LANGUAGE_NAME = 'LanguageName';
const LANGUAGE_ID = 'language-id';
const EXTENSION_NAME = /<%= extension-name %>/g;
const RAW_LANGUAGE_NAME = /<%= RawLanguageName %>/g;
const FILE_EXTENSION = /<%= file-extension %>/g;
const FILE_EXTENSION_GLOB = /<%= file-glob-extension %>/g;
const LANGUAGE_NAME = /<%= LanguageName %>/g;
const LANGUAGE_ID = /<%= language-id %>/g;
const LANGUAGE_PATH_ID = /language-id/g;
function printLogo(log) {

@@ -73,5 +73,5 @@ log('\u001b[36m┌─────┐ ─┐');

writing() {
const fileExtensions = [...new Set(this.answers.fileExtensions.split(',').map(ext => {
return ext.trim().replace('.', '');
}))];
const fileExtensions = Array.from(new Set(this.answers.fileExtensions
.split(',')
.map(ext => ext.replace(/\./g, '').trim())));
this.answers.fileExtensions = `[${fileExtensions.map(ext => `".${ext}"`).join(', ')}]`;

@@ -83,20 +83,11 @@ const fileExtensionGlob = fileExtensions.length > 1 ? `{${fileExtensions.join(',')}}` : fileExtensions[0];

this.sourceRoot(path_1.default.join(__dirname, TEMPLATE_DIR));
['.', '.vscode', '.eslintrc.json', '.vscodeignore'].forEach((path) => {
const replaceTemplateWords = (answers, content) => [
[EXTENSION_NAME, this.answers.extensionName],
[RAW_LANGUAGE_NAME, this.answers.rawLanguageName],
[FILE_EXTENSION, this.answers.fileExtensions],
[FILE_EXTENSION_GLOB, fileExtensionGlob],
[LANGUAGE_NAME, languageName],
[LANGUAGE_ID, languageId],
].reduce((acc, [templateWord, userAnswer]) => acc.replace(new RegExp(`${OPEN}${templateWord}${CLOSE}`, 'g'), userAnswer), content.toString());
const replaceTemplateNames = (answers, path) => path.replace(new RegExp(LANGUAGE_ID, 'g'), languageId);
this.fs.copy(this.templatePath(path), this.destinationPath(USER_DIR, this.answers.extensionName, path), {
process: (content) => replaceTemplateWords(this.answers, content),
processDestinationPath: (path) => replaceTemplateNames(this.answers, path),
for (const path of ['.', '.vscode', '.eslintrc.json', '.vscodeignore']) {
this.fs.copy(this.templatePath(path), this._extensionPath(path), {
process: content => this._replaceTemplateWords(fileExtensionGlob, languageName, languageId, content),
processDestinationPath: path => this._replaceTemplateNames(languageId, path),
});
});
}
}
install() {
const extensionPath = this.destinationPath(USER_DIR, this.answers.extensionName);
const extensionPath = this._extensionPath();
const opts = { cwd: extensionPath };

@@ -107,4 +98,42 @@ this.spawnCommandSync('npm', ['install'], opts);

}
async end() {
const code = await (0, which_1.default)('code').catch(() => undefined);
if (code) {
const answer = await this.prompt({
type: 'list',
name: 'openWith',
message: 'Do you want to open the new folder with Visual Studio Code?',
choices: [
{
name: 'Open with `code`',
value: code
},
{
name: 'Skip',
value: false
}
]
});
if (answer === null || answer === void 0 ? void 0 : answer.openWith) {
this.spawnCommand(answer.openWith, [this._extensionPath()]);
}
}
}
_extensionPath(...path) {
return this.destinationPath(USER_DIR, this.answers.extensionName, ...path);
}
_replaceTemplateWords(fileExtensionGlob, languageName, languageId, content) {
return content.toString()
.replace(EXTENSION_NAME, this.answers.extensionName)
.replace(RAW_LANGUAGE_NAME, this.answers.rawLanguageName)
.replace(FILE_EXTENSION, this.answers.fileExtensions)
.replace(FILE_EXTENSION_GLOB, fileExtensionGlob)
.replace(LANGUAGE_NAME, languageName)
.replace(LANGUAGE_ID, languageId);
}
_replaceTemplateNames(languageId, path) {
return path.replace(LANGUAGE_PATH_ID, languageId);
}
}
module.exports = LangiumGenerator;
//# sourceMappingURL=index.js.map

@@ -0,0 +0,0 @@ // A launch configuration that launches the extension inside a new window

@@ -0,0 +0,0 @@ # Welcome to your Langium VS Code Extension

@@ -7,3 +7,3 @@ {

"engines": {
"vscode": "^1.56.0"
"vscode": "^1.67.0"
},

@@ -47,19 +47,19 @@ "categories": [

"dependencies": {
"chevrotain": "^10.4.1",
"chalk": "^4.1.2",
"commander": "^8.0.0",
"langium": "~1.0.0",
"vscode-languageclient": "^8.0.2",
"vscode-languageserver": "^8.0.2",
"vscode-uri": "^3.0.2"
"chevrotain": "~10.4.2",
"chalk": "~4.1.2",
"commander": "~10.0.0",
"langium": "~1.1.0",
"vscode-languageclient": "~8.0.2",
"vscode-languageserver": "~8.0.2",
"vscode-uri": "~3.0.7"
},
"devDependencies": {
"@types/node": "^14.17.3",
"@types/vscode": "^1.56.0",
"@typescript-eslint/eslint-plugin": "^5.28.0",
"@typescript-eslint/parser": "^5.28.0",
"eslint": "^8.17.0",
"langium-cli": "~1.0.0",
"typescript": "^4.9.4"
"@types/node": "~16.18.11",
"@types/vscode": "~1.67.0",
"@typescript-eslint/eslint-plugin": "~5.51.0",
"@typescript-eslint/parser": "~5.51.0",
"eslint": "~8.33.0",
"langium-cli": "~1.1.0",
"typescript": "~4.9.5"
}
}

@@ -0,0 +0,0 @@ import chalk from 'chalk';

@@ -0,0 +0,0 @@ import fs from 'fs';

@@ -0,0 +0,0 @@ import chalk from 'chalk';

@@ -0,0 +0,0 @@ import * as vscode from 'vscode';

@@ -0,0 +0,0 @@ import { ValidationAcceptor, ValidationChecks } from 'langium';

@@ -0,0 +0,0 @@ import { startLanguageServer } from 'langium';

{
"name": "generator-langium",
"version": "1.0.0",
"version": "1.1.0",
"description": "Yeoman generator for Langium - the language engineering tool",
"homepage": "https://langium.org",
"engines": {
"node": ">=12.10.0"
"node": ">=14.0.0"
},

@@ -28,4 +28,5 @@ "keywords": [

"watch": "tsc --watch",
"lint": "eslint src --ext .ts",
"lint": "eslint src test --ext .ts",
"run": "yo langium",
"test": "vitest run",
"debug": "npx --node-arg=--inspect yo langium",

@@ -36,10 +37,18 @@ "publish:next": "npm --no-git-tag-version version \"$(semver $npm_package_version -i minor)-next.$(git rev-parse --short HEAD)\" && npm publish --tag next",

"dependencies": {
"chalk": "^4.1.2",
"lodash": "^4.17.21",
"yeoman-generator": "^5.5.2"
"chalk": "~4.1.2",
"lodash": "~4.17.21",
"which": "~2.0.2",
"yeoman-generator": "~5.7.0"
},
"devDependencies": {
"@types/lodash": "^4.14.170",
"@types/yeoman-generator": "^5.0.0"
"@types/lodash": "~4.14.191",
"@types/which": "~2.0.1",
"@types/yeoman-generator": "~5.2.11",
"@types/yeoman-test": "~4.0.3",
"yeoman-test": "~7.3.0"
},
"volta": {
"node": "16.19.0",
"npm": "8.19.3"
},
"repository": {

@@ -46,0 +55,0 @@ "type": "git",

@@ -0,0 +0,0 @@ # Langium Package Generator

@@ -11,2 +11,3 @@ /******************************************************************************

import path from 'path';
import which from 'which';

@@ -16,13 +17,11 @@ const TEMPLATE_DIR = '../langium-template';

const OPEN = '<%= ';
const CLOSE = ' %>';
const EXTENSION_NAME = /<%= extension-name %>/g;
const RAW_LANGUAGE_NAME = /<%= RawLanguageName %>/g;
const FILE_EXTENSION = /<%= file-extension %>/g;
const FILE_EXTENSION_GLOB = /<%= file-glob-extension %>/g;
const EXTENSION_NAME = 'extension-name';
const RAW_LANGUAGE_NAME = 'RawLanguageName';
const FILE_EXTENSION = 'file-extension';
const FILE_EXTENSION_GLOB = 'file-glob-extension';
const LANGUAGE_NAME = /<%= LanguageName %>/g;
const LANGUAGE_ID = /<%= language-id %>/g;
const LANGUAGE_PATH_ID = /language-id/g;
const LANGUAGE_NAME = 'LanguageName';
const LANGUAGE_ID = 'language-id';
interface Answers {

@@ -101,5 +100,9 @@ extensionName: string;

writing(): void {
const fileExtensions = [...new Set(this.answers.fileExtensions.split(',').map(ext => {
return ext.trim().replace('.', '');
}))];
const fileExtensions = Array.from(
new Set(
this.answers.fileExtensions
.split(',')
.map(ext => ext.replace(/\./g, '').trim())
)
);
this.answers.fileExtensions = `[${fileExtensions.map(ext => `".${ext}"`).join(', ')}]`;

@@ -119,56 +122,19 @@

this.sourceRoot(path.join(__dirname, TEMPLATE_DIR));
['.', '.vscode', '.eslintrc.json', '.vscodeignore'].forEach(
(path: string) => {
const replaceTemplateWords = (
answers: Answers,
content: Buffer
): string =>
[
[EXTENSION_NAME, this.answers.extensionName],
[RAW_LANGUAGE_NAME, this.answers.rawLanguageName],
[FILE_EXTENSION, this.answers.fileExtensions],
[FILE_EXTENSION_GLOB, fileExtensionGlob],
[LANGUAGE_NAME, languageName],
[LANGUAGE_ID, languageId],
].reduce(
(acc: string, [templateWord, userAnswer]) =>
acc.replace(
new RegExp(
`${OPEN}${templateWord}${CLOSE}`,
'g'
),
userAnswer
),
content.toString()
);
const replaceTemplateNames = (
answers: Answers,
path: string
): string =>
path.replace(new RegExp(LANGUAGE_ID, 'g'), languageId);
this.fs.copy(
this.templatePath(path),
this.destinationPath(
USER_DIR,
this.answers.extensionName,
path
),
{
process: (content: Buffer) =>
replaceTemplateWords(this.answers, content),
processDestinationPath: (path: string) =>
replaceTemplateNames(this.answers, path),
}
);
}
);
for (const path of ['.', '.vscode', '.eslintrc.json', '.vscodeignore']) {
this.fs.copy(
this.templatePath(path),
this._extensionPath(path),
{
process: content =>
this._replaceTemplateWords(fileExtensionGlob, languageName, languageId, content),
processDestinationPath: path =>
this._replaceTemplateNames(languageId, path),
}
);
}
}
install(): void {
const extensionPath = this.destinationPath(
USER_DIR,
this.answers.extensionName
);
const extensionPath = this._extensionPath();

@@ -180,4 +146,47 @@ const opts = { cwd: extensionPath };

}
async end(): Promise<void> {
const code = await which('code').catch(() => undefined);
if (code) {
const answer = await this.prompt({
type: 'list',
name: 'openWith',
message: 'Do you want to open the new folder with Visual Studio Code?',
choices: [
{
name: 'Open with `code`',
value: code
},
{
name: 'Skip',
value: false
}
]
});
if (answer?.openWith) {
this.spawnCommand(answer.openWith, [this._extensionPath()]);
}
}
}
_extensionPath(...path: string[]): string {
return this.destinationPath(USER_DIR, this.answers.extensionName, ...path);
}
_replaceTemplateWords(fileExtensionGlob: string, languageName: string, languageId: string, content: Buffer): string {
return content.toString()
.replace(EXTENSION_NAME, this.answers.extensionName)
.replace(RAW_LANGUAGE_NAME, this.answers.rawLanguageName)
.replace(FILE_EXTENSION, this.answers.fileExtensions)
.replace(FILE_EXTENSION_GLOB, fileExtensionGlob)
.replace(LANGUAGE_NAME, languageName)
.replace(LANGUAGE_ID, languageId);
}
_replaceTemplateNames(languageId: string, path: string): string {
return path.replace(LANGUAGE_PATH_ID, languageId);
}
}
export = LangiumGenerator;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc