-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
273eeb9
commit 0c95e78
Showing
5 changed files
with
38 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ import { | |
ParserResult, | ||
TokenEditor | ||
} from "@azimutt/models"; | ||
// import {generateAml, parseAml} from "@azimutt/aml"; | ||
import {generateAml, parseAml} from "@azimutt/aml"; | ||
import {track} from "@azimutt/gateway"; | ||
import {fileRead, fileWrite} from "./utils/file.js"; | ||
import {logger} from "./utils/logger.js"; | ||
|
@@ -41,14 +41,33 @@ export async function convertFile(path: string, opts: Opts): Promise<void> { | |
logger.log(`Done 👍️\n`) | ||
} | ||
|
||
// try it with: `npm run exec -- convert test.aml --from aml --to json --out test.aml.json` | ||
function parseDialect(dialect: string, content: string): ParserResult<Database> { | ||
if (dialect === 'aml') return ParserResult.failure([{message: 'AML parser not available', kind: 'NotImplemented', level: 'error', offset: {start: 0, end: 0}, position: {start: {line: 0, column: 0}, end: {line: 0, column: 0}}}]) // parseAml(content) | ||
/* FIXME: @azimutt/aml is using ESM to be bundled with Rollup, but this produce and error here: | ||
node:internal/modules/esm/resolve:257 | ||
throw new ERR_MODULE_NOT_FOUND( | ||
^ | ||
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/node_modules/.pnpm/@[email protected]/node_modules/@azimutt/aml/out/amlAst' imported from /node_modules/.pnpm/@[email protected]/node_modules/@azimutt/aml/out/index.js | ||
at finalizeResolution (node:internal/modules/esm/resolve:257:11) | ||
at moduleResolve (node:internal/modules/esm/resolve:913:10) | ||
at defaultResolve (node:internal/modules/esm/resolve:1037:11) | ||
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:650:12) | ||
at #cachedDefaultResolve (node:internal/modules/esm/loader:599:25) | ||
at ModuleLoader.resolve (node:internal/modules/esm/loader:582:38) | ||
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:241:38) | ||
at ModuleJob._link (node:internal/modules/esm/module_job:132:49) { | ||
code: 'ERR_MODULE_NOT_FOUND', | ||
url: 'file:///node_modules/.pnpm/@azimutt[email protected]/node_modules/@azimutt/aml/out/amlAst' | ||
} | ||
*/ | ||
if (dialect === 'aml') return ParserResult.failure([{message: 'AML parser not available', kind: 'NotImplemented', level: 'error', offset: {start: 0, end: 0}, position: {start: {line: 0, column: 0}, end: {line: 0, column: 0}}}]) // FIXME: return parseAml(content) | ||
if (dialect === 'json') return parseJsonDatabase(content) | ||
return ParserResult.failure([parserError(`Can't parse ${dialect} dialect`, 'BadArgument')]) | ||
} | ||
|
||
function generateDialect(dialect: string, db: Database): Result<string, string> { | ||
if (dialect === 'aml') return Result.failure('AML generator not available') // Result.success(generateAml(db)) | ||
if (dialect === 'aml') return Result.failure('AML generator not available') // FIXME: return Result.success(generateAml(db)) | ||
if (dialect === 'json') return Result.success(generateJsonDatabase(db)) | ||
return Result.failure(`Can't generate ${dialect} dialect`) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.