An experimental TypeSpec syntax for Lexicon

more descriptive

Changed files
+5 -5
packages
cli
example
typelex
+4 -4
packages/cli/src/utils/externals-generator.ts
··· 22 22 /** 23 23 * Generate TypeSpec external definitions from lexicon documents 24 24 */ 25 - function generateExternalsCode(lexicons: Map<string, LexiconDoc>): string { 25 + function generateExternalsCode(lexicons: Map<string, LexiconDoc>, outDir: string, excludedPrefix: string): string { 26 26 const lines: string[] = []; 27 27 28 28 lines.push('import "@typelex/emitter";'); 29 29 lines.push(""); 30 - lines.push("// Generated by typelex"); 30 + lines.push(`// Generated by typelex from ${outDir} (excluding ${excludedPrefix}.*)`); 31 31 lines.push("// This file is auto-generated. Do not edit manually."); 32 32 lines.push(""); 33 33 ··· 89 89 await mkdir(resolve(cwd, "typelex"), { recursive: true }); 90 90 await writeFile( 91 91 outputFile, 92 - 'import "@typelex/emitter";\n\n// Generated by typelex\n// No external lexicons found\n', 92 + `import "@typelex/emitter";\n\n// Generated by typelex from ${outDir} (excluding ${prefix}.*)\n// No external lexicons found\n`, 93 93 "utf-8" 94 94 ); 95 95 return; 96 96 } 97 97 98 - const code = generateExternalsCode(externals); 98 + const code = generateExternalsCode(externals, outDir, prefix); 99 99 await mkdir(resolve(cwd, "typelex"), { recursive: true }); 100 100 await writeFile(outputFile, code, "utf-8"); 101 101 } catch (error) {
+1 -1
packages/example/typelex/externals.tsp
··· 1 1 import "@typelex/emitter"; 2 2 3 - // Generated by typelex 3 + // Generated by typelex from ./lexicons (excluding xyz.statusphere.*) 4 4 // This file is auto-generated. Do not edit manually. 5 5 6 6 @external