From 43f369565cee32741e354470abb7487e1fb2cfc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Knuchel?= Date: Mon, 30 Sep 2024 08:37:18 +0200 Subject: [PATCH] publish cli --- cli/README.md | 5 +++ cli/html-report/package.json | 2 +- cli/package.json | 5 +-- cli/src/convert.ts | 8 ++-- cli/src/utils/file.ts | 8 ++-- cli/src/version.ts | 2 +- cli/tsconfig.json | 2 +- pnpm-lock.yaml | 82 +++++++++++++++++++++++------------- 8 files changed, 71 insertions(+), 43 deletions(-) diff --git a/cli/README.md b/cli/README.md index 7232161cf..137d96e41 100644 --- a/cli/README.md +++ b/cli/README.md @@ -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 diff --git a/cli/html-report/package.json b/cli/html-report/package.json index 63a66ce5b..f16e8f116 100644 --- a/cli/html-report/package.json +++ b/cli/html-report/package.json @@ -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", diff --git a/cli/package.json b/cli/package.json index 7fc6ae70e..0ea913385 100644 --- a/cli/package.json +++ b/cli/package.json @@ -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", @@ -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:^", @@ -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" } } diff --git a/cli/src/convert.ts b/cli/src/convert.ts index f0845d4b0..376b194db 100644 --- a/cli/src/convert.ts +++ b/cli/src/convert.ts @@ -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"; @@ -24,7 +24,7 @@ export async function convertFile(path: string, opts: Opts): Promise { 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 @@ -39,13 +39,13 @@ export async function convertFile(path: string, opts: Opts): Promise { } function parseDialect(dialect: string, content: string): ParserResult { - 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 { - 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`) } diff --git a/cli/src/utils/file.ts b/cli/src/utils/file.ts index 6c0fbee0b..132032f0a 100644 --- a/cli/src/utils/file.ts +++ b/cli/src/utils/file.ts @@ -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"; @@ -18,5 +18,5 @@ export const fileWrite = (path: string, content: string): Promise => 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); diff --git a/cli/src/version.ts b/cli/src/version.ts index c8c19954a..37747cb5b 100644 --- a/cli/src/version.ts +++ b/cli/src/version.ts @@ -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 :/ diff --git a/cli/tsconfig.json b/cli/tsconfig.json index 350fe43b8..74b50a6ae 100644 --- a/cli/tsconfig.json +++ b/cli/tsconfig.json @@ -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. */ diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0d9a15600..ad8fa3c41 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -35,9 +35,6 @@ importers: cli: dependencies: - '@azimutt/aml': - specifier: workspace:^ - version: link:../libs/aml '@azimutt/gateway': specifier: workspace:^ version: link:../gateway @@ -83,19 +80,19 @@ importers: version: 22.7.4 jest: specifier: ^29.7.0 - version: 29.7.0(@types/node@22.7.4)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@22.7.4)(typescript@5.6.2)) + version: 29.7.0(@types/node@22.7.4)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@22.7.4)(typescript@5.5.4)) nodemon: specifier: ^3.1.7 version: 3.1.7 ts-jest: specifier: ^29.2.5 - version: 29.2.5(@babel/core@7.25.2)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.25.2))(jest@29.7.0(@types/node@22.7.4)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@22.7.4)(typescript@5.6.2)))(typescript@5.6.2) + version: 29.2.5(@babel/core@7.25.2)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.25.2))(jest@29.7.0(@types/node@22.7.4)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@22.7.4)(typescript@5.5.4)))(typescript@5.5.4) ts-node: specifier: ^10.9.2 - version: 10.9.2(@swc/core@1.7.26)(@types/node@22.7.4)(typescript@5.6.2) + version: 10.9.2(@swc/core@1.7.26)(@types/node@22.7.4)(typescript@5.5.4) typescript: - specifier: ^5.6.2 - version: 5.6.2 + specifier: 5.5.4 + version: 5.5.4 cli/html-report: dependencies: @@ -179,8 +176,8 @@ importers: specifier: ^8.7.0 version: 8.7.0(eslint@8.57.1)(typescript@5.6.2) '@vitejs/plugin-react-swc': - specifier: ^3.7.0 - version: 3.7.0(vite@5.4.8(@types/node@22.7.4)(terser@5.34.1)) + specifier: ^3.7.1 + version: 3.7.1(vite@5.4.8(@types/node@22.7.4)(terser@5.34.1)) autoprefixer: specifier: ^10.4.20 version: 10.4.20(postcss@8.4.47) @@ -3655,8 +3652,8 @@ packages: '@vercel/webpack-asset-relocator-loader@1.7.4': resolution: {integrity: sha512-RFFite6v51Qhj/eERru3qwUNCLybnceSChI5yiu9bhLpTemWbKPORAOExOgpO2W7IE/0UEh3aX6wTSHgDE/fdQ==} - '@vitejs/plugin-react-swc@3.7.0': - resolution: {integrity: sha512-yrknSb3Dci6svCd/qhHqhFPDSw0QtjumcqdKMoNNzmOl5lMXTTiqzjWtG4Qask2HdvvzaNgSunbQGet8/GrKdA==} + '@vitejs/plugin-react-swc@3.7.1': + resolution: {integrity: sha512-vgWOY0i1EROUK0Ctg1hwhtC3SdcDjZcdit4Ups4aPkDcB1jYhmo+RMYWY87cmXMhvtD5uf8lV89j2w16vkdSVg==} peerDependencies: vite: ^4 || ^5 @@ -8844,6 +8841,11 @@ packages: typedarray-to-buffer@3.1.5: resolution: {integrity: sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==} + typescript@5.5.4: + resolution: {integrity: sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==} + engines: {node: '>=14.17'} + hasBin: true + typescript@5.6.2: resolution: {integrity: sha512-NW8ByodCSNCwZeghjN3o+JX5OFH0Ojg6sadjEKY4huZ52TqbJTJnDo5+Tw98lSy63NZvi4n+ez5m2u5d4PkZyw==} engines: {node: '>=14.17'} @@ -11125,7 +11127,7 @@ snapshots: jest-util: 29.7.0 slash: 3.0.0 - '@jest/core@29.7.0(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@22.7.4)(typescript@5.6.2))': + '@jest/core@29.7.0(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@22.7.4)(typescript@5.5.4))': dependencies: '@jest/console': 29.7.0 '@jest/reporters': 29.7.0 @@ -11139,7 +11141,7 @@ snapshots: exit: 0.1.2 graceful-fs: 4.2.11 jest-changed-files: 29.7.0 - jest-config: 29.7.0(@types/node@22.7.4)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@22.7.4)(typescript@5.6.2)) + jest-config: 29.7.0(@types/node@22.7.4)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@22.7.4)(typescript@5.5.4)) jest-haste-map: 29.7.0 jest-message-util: 29.7.0 jest-regex-util: 29.6.3 @@ -12975,7 +12977,7 @@ snapshots: dependencies: resolve: 1.22.8 - '@vitejs/plugin-react-swc@3.7.0(vite@5.4.8(@types/node@22.7.4)(terser@5.34.1))': + '@vitejs/plugin-react-swc@3.7.1(vite@5.4.8(@types/node@22.7.4)(terser@5.34.1))': dependencies: '@swc/core': 1.7.26 vite: 5.4.8(@types/node@22.7.4)(terser@5.34.1) @@ -13995,13 +13997,13 @@ snapshots: transitivePeerDependencies: - supports-color - create-jest@29.7.0(@types/node@22.7.4)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@22.7.4)(typescript@5.6.2)): + create-jest@29.7.0(@types/node@22.7.4)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@22.7.4)(typescript@5.5.4)): dependencies: '@jest/types': 29.6.3 chalk: 4.1.2 exit: 0.1.2 graceful-fs: 4.2.11 - jest-config: 29.7.0(@types/node@22.7.4)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@22.7.4)(typescript@5.6.2)) + jest-config: 29.7.0(@types/node@22.7.4)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@22.7.4)(typescript@5.5.4)) jest-util: 29.7.0 prompts: 2.4.2 transitivePeerDependencies: @@ -16333,16 +16335,16 @@ snapshots: - babel-plugin-macros - supports-color - jest-cli@29.7.0(@types/node@22.7.4)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@22.7.4)(typescript@5.6.2)): + jest-cli@29.7.0(@types/node@22.7.4)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@22.7.4)(typescript@5.5.4)): dependencies: - '@jest/core': 29.7.0(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@22.7.4)(typescript@5.6.2)) + '@jest/core': 29.7.0(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@22.7.4)(typescript@5.5.4)) '@jest/test-result': 29.7.0 '@jest/types': 29.6.3 chalk: 4.1.2 - create-jest: 29.7.0(@types/node@22.7.4)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@22.7.4)(typescript@5.6.2)) + create-jest: 29.7.0(@types/node@22.7.4)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@22.7.4)(typescript@5.5.4)) exit: 0.1.2 import-local: 3.2.0 - jest-config: 29.7.0(@types/node@22.7.4)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@22.7.4)(typescript@5.6.2)) + jest-config: 29.7.0(@types/node@22.7.4)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@22.7.4)(typescript@5.5.4)) jest-util: 29.7.0 jest-validate: 29.7.0 yargs: 17.7.2 @@ -16371,7 +16373,7 @@ snapshots: - supports-color - ts-node - jest-config@29.7.0(@types/node@22.7.4)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@22.7.4)(typescript@5.6.2)): + jest-config@29.7.0(@types/node@22.7.4)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@22.7.4)(typescript@5.5.4)): dependencies: '@babel/core': 7.25.2 '@jest/test-sequencer': 29.7.0 @@ -16397,7 +16399,7 @@ snapshots: strip-json-comments: 3.1.1 optionalDependencies: '@types/node': 22.7.4 - ts-node: 10.9.2(@swc/core@1.7.26)(@types/node@22.7.4)(typescript@5.6.2) + ts-node: 10.9.2(@swc/core@1.7.26)(@types/node@22.7.4)(typescript@5.5.4) transitivePeerDependencies: - babel-plugin-macros - supports-color @@ -16669,12 +16671,12 @@ snapshots: merge-stream: 2.0.0 supports-color: 8.1.1 - jest@29.7.0(@types/node@22.7.4)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@22.7.4)(typescript@5.6.2)): + jest@29.7.0(@types/node@22.7.4)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@22.7.4)(typescript@5.5.4)): dependencies: - '@jest/core': 29.7.0(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@22.7.4)(typescript@5.6.2)) + '@jest/core': 29.7.0(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@22.7.4)(typescript@5.5.4)) '@jest/types': 29.6.3 import-local: 3.2.0 - jest-cli: 29.7.0(@types/node@22.7.4)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@22.7.4)(typescript@5.6.2)) + jest-cli: 29.7.0(@types/node@22.7.4)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@22.7.4)(typescript@5.5.4)) transitivePeerDependencies: - '@types/node' - babel-plugin-macros @@ -19041,18 +19043,18 @@ snapshots: babel-jest: 29.7.0(@babel/core@7.25.2) esbuild: 0.23.1 - ts-jest@29.2.5(@babel/core@7.25.2)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.25.2))(jest@29.7.0(@types/node@22.7.4)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@22.7.4)(typescript@5.6.2)))(typescript@5.6.2): + ts-jest@29.2.5(@babel/core@7.25.2)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.25.2))(jest@29.7.0(@types/node@22.7.4)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@22.7.4)(typescript@5.5.4)))(typescript@5.5.4): dependencies: bs-logger: 0.2.6 ejs: 3.1.10 fast-json-stable-stringify: 2.1.0 - jest: 29.7.0(@types/node@22.7.4)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@22.7.4)(typescript@5.6.2)) + jest: 29.7.0(@types/node@22.7.4)(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@22.7.4)(typescript@5.5.4)) jest-util: 29.7.0 json5: 2.2.3 lodash.memoize: 4.1.2 make-error: 1.3.6 semver: 7.6.3 - typescript: 5.6.2 + typescript: 5.5.4 yargs-parser: 21.1.1 optionalDependencies: '@babel/core': 7.25.2 @@ -19089,6 +19091,26 @@ snapshots: typescript: 5.6.2 webpack: 5.95.0(@swc/core@1.7.26) + ts-node@10.9.2(@swc/core@1.7.26)(@types/node@22.7.4)(typescript@5.5.4): + dependencies: + '@cspotcode/source-map-support': 0.8.1 + '@tsconfig/node10': 1.0.11 + '@tsconfig/node12': 1.0.11 + '@tsconfig/node14': 1.0.3 + '@tsconfig/node16': 1.0.4 + '@types/node': 22.7.4 + acorn: 8.12.1 + acorn-walk: 8.3.4 + arg: 4.1.3 + create-require: 1.1.1 + diff: 4.0.2 + make-error: 1.3.6 + typescript: 5.5.4 + v8-compile-cache-lib: 3.0.1 + yn: 3.1.1 + optionalDependencies: + '@swc/core': 1.7.26 + ts-node@10.9.2(@swc/core@1.7.26)(@types/node@22.7.4)(typescript@5.6.2): dependencies: '@cspotcode/source-map-support': 0.8.1 @@ -19191,6 +19213,8 @@ snapshots: dependencies: is-typedarray: 1.0.0 + typescript@5.5.4: {} + typescript@5.6.2: {} unbox-primitive@1.0.2: