@lagless/codegen 0.0.38 → 0.0.40
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/LICENSE +26 -0
- package/dist/cli.js +3 -2
- package/dist/cli.js.map +1 -1
- package/package.json +4 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
Creative Commons Attribution-NonCommercial 4.0 International
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Lagless
|
|
4
|
+
|
|
5
|
+
This work is licensed under the Creative Commons
|
|
6
|
+
Attribution-NonCommercial 4.0 International License.
|
|
7
|
+
|
|
8
|
+
You are free to:
|
|
9
|
+
|
|
10
|
+
Share — copy and redistribute the material in any medium or format
|
|
11
|
+
Adapt — remix, transform, and build upon the material
|
|
12
|
+
|
|
13
|
+
Under the following terms:
|
|
14
|
+
|
|
15
|
+
Attribution — You must give appropriate credit, provide a link to
|
|
16
|
+
the license, and indicate if changes were made. You may do so in
|
|
17
|
+
any reasonable manner, but not in any way that suggests the licensor
|
|
18
|
+
endorses you or your use.
|
|
19
|
+
|
|
20
|
+
NonCommercial — You may not use the material for commercial purposes.
|
|
21
|
+
|
|
22
|
+
No additional restrictions — You may not apply legal terms or
|
|
23
|
+
technological measures that legally restrict others from doing
|
|
24
|
+
anything the license permits.
|
|
25
|
+
|
|
26
|
+
Full license text: https://creativecommons.org/licenses/by-nc/4.0/legalcode
|
package/dist/cli.js
CHANGED
|
@@ -24,7 +24,7 @@ async function generateFromConfig(options) {
|
|
|
24
24
|
if (!configContent.trim()) {
|
|
25
25
|
throw new Error(`Config file is empty: ${configPath}`);
|
|
26
26
|
}
|
|
27
|
-
const { schema, projectName } = parseYamlConfig(configContent, configPath);
|
|
27
|
+
const { schema, projectName, simulationType } = parseYamlConfig(configContent, configPath);
|
|
28
28
|
// Determine output directory
|
|
29
29
|
const outputDir = outputPath || path.join(path.dirname(configPath), 'code-gen');
|
|
30
30
|
// Determine templates directory
|
|
@@ -75,7 +75,8 @@ async function generateFromConfig(options) {
|
|
|
75
75
|
projectName,
|
|
76
76
|
outputDir,
|
|
77
77
|
templateDir,
|
|
78
|
-
fileOperations
|
|
78
|
+
fileOperations,
|
|
79
|
+
simulationType
|
|
79
80
|
});
|
|
80
81
|
console.log('ECS code generation complete!');
|
|
81
82
|
console.log(`Generated ${schema.components.length} components and ${schema.singletons.length} singletons.`);
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { program } from 'commander';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { parseYamlConfig } from './parser.js';\nimport { generateCode } from './generator.js';\nimport { FileOperations } from './template-engine.js';\nimport { DIRNAME } from './dirname.js';\n\ninterface CliOptions {\n config: string;\n output?: string;\n templates?: string;\n}\n\nprogram\n .name('lagless-codegen')\n .description('Generate ECS code from YAML configuration')\n .version('1.0.0')\n .requiredOption('-c, --config <path>', 'Path to YAML configuration file')\n .option('-o, --output <path>', 'Output directory (default: config_dir/../code-gen)')\n .option('-t, --templates <path>', 'Templates directory')\n .action(async (options: CliOptions) => {\n try {\n await generateFromConfig(options);\n } catch (error) {\n console.error('Error:', error instanceof Error ? error.message : error);\n process.exit(1);\n }\n });\n\nasync function generateFromConfig(options: CliOptions): Promise<void> {\n const { config: configPath, output: outputPath, templates: templatesPath } = options;\n\n // Validate config file exists\n if (!fs.existsSync(configPath)) {\n throw new Error(`Config file not found: ${configPath}`);\n }\n\n // Read and parse config\n const configContent = fs.readFileSync(configPath, 'utf-8');\n if (!configContent.trim()) {\n throw new Error(`Config file is empty: ${configPath}`);\n }\n\n const { schema, projectName } = parseYamlConfig(configContent, configPath);\n\n // Determine output directory\n const outputDir = outputPath || path.join(path.dirname(configPath), 'code-gen');\n\n // Determine templates directory\n const templateDir = templatesPath || path.join(DIRNAME, '..', 'files');\n\n console.log(`Generating ECS code...`);\n console.log(`Config: ${configPath}`);\n console.log(`Output: ${outputDir}`);\n console.log(`Templates: ${templateDir}`);\n console.log(`Project: ${projectName}`);\n\n // Create file operations for Node.js filesystem\n const fileOperations: FileOperations = {\n readFile: (filePath: string) => {\n try {\n return fs.readFileSync(filePath, 'utf-8');\n } catch {\n return '';\n }\n },\n writeFile: (filePath: string, content: string) => {\n const dir = path.dirname(filePath);\n if (!fs.existsSync(dir)) {\n fs.mkdirSync(dir, { recursive: true });\n }\n fs.writeFileSync(filePath, content, 'utf-8');\n },\n joinPath: (...segments: string[]) => path.join(...segments),\n exists: (filePath: string) => fs.existsSync(filePath),\n readDir: (dirPath: string) => {\n try {\n return fs.readdirSync(dirPath);\n } catch {\n return [];\n }\n },\n isDirectory: (filePath: string) => {\n try {\n return fs.statSync(filePath).isDirectory();\n } catch {\n return false;\n }\n },\n };\n\n // Generate code\n await generateCode({\n schema,\n projectName,\n outputDir,\n templateDir,\n fileOperations,\n });\n\n console.log('ECS code generation complete!');\n console.log(`Generated ${schema.components.length} components and ${schema.singletons.length} singletons.`);\n console.log(`Project name: ${projectName}`);\n console.log(`Output written to: ${outputDir}`);\n}\n\n// Handle unhandled promise rejections\nprocess.on('unhandledRejection', (reason, promise) => {\n console.error('Unhandled Rejection at:', promise, 'reason:', reason);\n process.exit(1);\n});\n\nprogram.parse();\n"],"names":["program","fs","path","parseYamlConfig","generateCode","DIRNAME","name","description","version","requiredOption","option","action","options","generateFromConfig","error","console","Error","message","process","exit","config","configPath","output","outputPath","templates","templatesPath","existsSync","configContent","readFileSync","trim","schema","projectName","outputDir","join","dirname","templateDir","log","fileOperations","readFile","filePath","writeFile","content","dir","mkdirSync","recursive","writeFileSync","joinPath","segments","exists","readDir","dirPath","readdirSync","isDirectory","statSync","components","length","singletons","on","reason","promise","parse"],"rangeMappings":"
|
|
1
|
+
{"version":3,"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { program } from 'commander';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { parseYamlConfig } from './parser.js';\nimport { generateCode } from './generator.js';\nimport { FileOperations } from './template-engine.js';\nimport { DIRNAME } from './dirname.js';\n\ninterface CliOptions {\n config: string;\n output?: string;\n templates?: string;\n}\n\nprogram\n .name('lagless-codegen')\n .description('Generate ECS code from YAML configuration')\n .version('1.0.0')\n .requiredOption('-c, --config <path>', 'Path to YAML configuration file')\n .option('-o, --output <path>', 'Output directory (default: config_dir/../code-gen)')\n .option('-t, --templates <path>', 'Templates directory')\n .action(async (options: CliOptions) => {\n try {\n await generateFromConfig(options);\n } catch (error) {\n console.error('Error:', error instanceof Error ? error.message : error);\n process.exit(1);\n }\n });\n\nasync function generateFromConfig(options: CliOptions): Promise<void> {\n const { config: configPath, output: outputPath, templates: templatesPath } = options;\n\n // Validate config file exists\n if (!fs.existsSync(configPath)) {\n throw new Error(`Config file not found: ${configPath}`);\n }\n\n // Read and parse config\n const configContent = fs.readFileSync(configPath, 'utf-8');\n if (!configContent.trim()) {\n throw new Error(`Config file is empty: ${configPath}`);\n }\n\n const { schema, projectName, simulationType } = parseYamlConfig(configContent, configPath);\n\n // Determine output directory\n const outputDir = outputPath || path.join(path.dirname(configPath), 'code-gen');\n\n // Determine templates directory\n const templateDir = templatesPath || path.join(DIRNAME, '..', 'files');\n\n console.log(`Generating ECS code...`);\n console.log(`Config: ${configPath}`);\n console.log(`Output: ${outputDir}`);\n console.log(`Templates: ${templateDir}`);\n console.log(`Project: ${projectName}`);\n\n // Create file operations for Node.js filesystem\n const fileOperations: FileOperations = {\n readFile: (filePath: string) => {\n try {\n return fs.readFileSync(filePath, 'utf-8');\n } catch {\n return '';\n }\n },\n writeFile: (filePath: string, content: string) => {\n const dir = path.dirname(filePath);\n if (!fs.existsSync(dir)) {\n fs.mkdirSync(dir, { recursive: true });\n }\n fs.writeFileSync(filePath, content, 'utf-8');\n },\n joinPath: (...segments: string[]) => path.join(...segments),\n exists: (filePath: string) => fs.existsSync(filePath),\n readDir: (dirPath: string) => {\n try {\n return fs.readdirSync(dirPath);\n } catch {\n return [];\n }\n },\n isDirectory: (filePath: string) => {\n try {\n return fs.statSync(filePath).isDirectory();\n } catch {\n return false;\n }\n },\n };\n\n // Generate code\n await generateCode({\n schema,\n projectName,\n outputDir,\n templateDir,\n fileOperations,\n simulationType,\n });\n\n console.log('ECS code generation complete!');\n console.log(`Generated ${schema.components.length} components and ${schema.singletons.length} singletons.`);\n console.log(`Project name: ${projectName}`);\n console.log(`Output written to: ${outputDir}`);\n}\n\n// Handle unhandled promise rejections\nprocess.on('unhandledRejection', (reason, promise) => {\n console.error('Unhandled Rejection at:', promise, 'reason:', reason);\n process.exit(1);\n});\n\nprogram.parse();\n"],"names":["program","fs","path","parseYamlConfig","generateCode","DIRNAME","name","description","version","requiredOption","option","action","options","generateFromConfig","error","console","Error","message","process","exit","config","configPath","output","outputPath","templates","templatesPath","existsSync","configContent","readFileSync","trim","schema","projectName","simulationType","outputDir","join","dirname","templateDir","log","fileOperations","readFile","filePath","writeFile","content","dir","mkdirSync","recursive","writeFileSync","joinPath","segments","exists","readDir","dirPath","readdirSync","isDirectory","statSync","components","length","singletons","on","reason","promise","parse"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";AACA,SAASA,OAAO,QAAQ,YAAY;AACpC,YAAYC,QAAQ,KAAK;AACzB,YAAYC,UAAU,OAAO;AAC7B,SAASC,eAAe,QAAQ,cAAc;AAC9C,SAASC,YAAY,QAAQ,iBAAiB;AAE9C,SAASC,OAAO,QAAQ,eAAe;AAQvCL,QACGM,IAAI,CAAC,mBACLC,WAAW,CAAC,6CACZC,OAAO,CAAC,SACRC,cAAc,CAAC,uBAAuB,mCACtCC,MAAM,CAAC,uBAAuB,sDAC9BA,MAAM,CAAC,0BAA0B,uBACjCC,MAAM,CAAC,OAAOC;IACb,IAAI;QACF,MAAMC,mBAAmBD;IAC3B,EAAE,OAA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
4
|
-
"license": "
|
|
3
|
+
"version": "0.0.40",
|
|
4
|
+
"license": "CC-BY-NC-4.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/GbGr/lagless",
|
|
@@ -54,8 +54,8 @@
|
|
|
54
54
|
"yaml": "^2.8.1",
|
|
55
55
|
"ejs": "^3.1.10",
|
|
56
56
|
"@swc/helpers": "~0.5.11",
|
|
57
|
-
"@lagless/binary": "0.0.
|
|
58
|
-
"@lagless/core": "0.0.
|
|
57
|
+
"@lagless/binary": "0.0.40",
|
|
58
|
+
"@lagless/core": "0.0.40"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@types/ejs": "^3.1.5"
|