Skip to content

Commit

Permalink
publish cli
Browse files Browse the repository at this point in the history
  • Loading branch information
loicknuchel committed Sep 30, 2024
1 parent 8a21b17 commit 43f3695
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 43 deletions.
5 changes: 5 additions & 0 deletions cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ Start with `pnpm install` to install dependencies and set up the CLI, then you h
- `pnpm run start` to launch it with live reload (same, use `-- args` to pass arguments to the CLI)
- `pnpm run test` to launch tests

Issues:

- upgrading to typescript 5.6.2 cause the error: `TypeError: Cannot read properties of undefined (reading 'sourceFile')` when running tests :/
- importing @azimutt/aml fails as it's commonjs, not es module :/

## Publish

- update `package.json` and `src/version.ts` version
Expand Down
2 changes: 1 addition & 1 deletion cli/html-report/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"@types/react-dom": "^18.3.0",
"@typescript-eslint/eslint-plugin": "^8.7.0",
"@typescript-eslint/parser": "^8.7.0",
"@vitejs/plugin-react-swc": "^3.7.0",
"@vitejs/plugin-react-swc": "^3.7.1",
"autoprefixer": "^10.4.20",
"eslint": "^8.57.1",
"eslint-plugin-react-hooks": "^4.6.2",
Expand Down
5 changes: 2 additions & 3 deletions cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "azimutt",
"version": "0.1.25",
"version": "0.1.29",
"description": "Export database schema from relational or document databases. Import it to https://azimutt.app",
"keywords": [
"database",
Expand Down Expand Up @@ -41,7 +41,6 @@
"dry-publish": "pnpm run build && pnpm test && pnpm pack"
},
"dependencies": {
"@azimutt/aml": "workspace:^",
"@azimutt/gateway": "workspace:^",
"@azimutt/models": "workspace:^",
"@azimutt/utils": "workspace:^",
Expand All @@ -62,6 +61,6 @@
"nodemon": "^3.1.7",
"ts-jest": "^29.2.5",
"ts-node": "^10.9.2",
"typescript": "^5.6.2"
"typescript": "5.5.4"
}
}
8 changes: 4 additions & 4 deletions cli/src/convert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
ParserResult,
TokenEditor
} from "@azimutt/models";
import {generateAml, parseAml} from "@azimutt/aml";
// import {generateAml, parseAml} from "@azimutt/aml";
import {fileRead, fileWrite} from "./utils/file.js";
import {logger} from "./utils/logger.js";

Expand All @@ -24,7 +24,7 @@ export async function convertFile(path: string, opts: Opts): Promise<void> {
const content = await fileRead(path)
logger.log(`Parsing ${opts.from} content...`)
const parsed = parseDialect(opts.from, content)
parsed.errors?.forEach(err => logger.error(`Parsing ${err.kind}: ${err.message}${showPosition(err.position)}`))
parsed.errors?.forEach(err => logger.error(`Parsing ${err.level}: ${err.message} (${err.kind})${showPosition(err.position)}`))
if (!parsed.result) {
logger.error(`Unable to parse ${path} content as ${opts.from}`)
return
Expand All @@ -39,13 +39,13 @@ export async function convertFile(path: string, opts: Opts): Promise<void> {
}

function parseDialect(dialect: string, content: string): ParserResult<Database> {
if (dialect === 'aml') return parseAml(content)
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)
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.success(generateAml(db))
if (dialect === 'aml') return Result.failure('AML generator not available') // Result.success(generateAml(db))
if (dialect === 'json') return Result.success(generateJsonDatabase(db))
return Result.failure(`Can't generate ${dialect} dialect`)
}
Expand Down
8 changes: 4 additions & 4 deletions cli/src/utils/file.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as fs from "node:fs";
// import {dirname} from "node:path";
// import {fileURLToPath} from "node:url";
import {dirname} from "node:path";
import {fileURLToPath} from "node:url";
import os from "os";
import {pathParent} from "@azimutt/utils";

Expand All @@ -18,5 +18,5 @@ export const fileWrite = (path: string, content: string): Promise<void> => fs.pr
export const userHome = (): string => os.homedir()
export const pathResolve = (path: string): string => path.startsWith('~/') ? path.replace(/^~/, userHome()) : path

// export const __filename = fileURLToPath(import.meta.url);
// export const __dirname = dirname(__filename);
export const __filename = fileURLToPath(import.meta.url);
export const __dirname = dirname(__filename);
2 changes: 1 addition & 1 deletion cli/src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const version = '0.1.25' // FIXME: `process.env.npm_package_version` is not available :/
export const version = '0.1.29' // FIXME: `process.env.npm_package_version` is not available :/
2 changes: 1 addition & 1 deletion cli/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */

/* Modules */
"module": "commonjs", /* Specify what module code is generated. */
"module": "ESNext", /* Specify what module code is generated. */
"rootDir": "./src", /* Specify the root folder within your source files. */
"moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
Expand Down
82 changes: 53 additions & 29 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 43f3695

Please sign in to comment.