Skip to content

Commit aac4611

Browse files
committed
Unify and migrate to ES modules in turms-admin
1 parent 5f5638c commit aac4611

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

turms-admin/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"type": ""
77
},
88
"license": "Apache-2.0",
9+
"type": "module",
910
"scripts": {
1011
"build": "npm run build:admin",
1112
"build:admin": "vite build",

turms-admin/script/generate-client-ast.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
const fs = require('fs');
2-
const path = require('path');
3-
const parser = require('./typescript-parser.js');
1+
import fs from 'fs';
2+
import path from 'path';
3+
import { fileURLToPath } from 'node:url';
4+
import parser from './typescript-parser.js';
45

5-
const rootDir = path.dirname(path.dirname(__filename));
6+
const filename = fileURLToPath(import.meta.url);
7+
const rootDir = path.dirname(path.dirname(filename));
68

79
const declarations = parser.parse(path.join(rootDir, 'node_modules/turms-client-js/dist/turms-client.d.ts'));
810
const data = `${JSON.stringify(declarations, null, 2)}`;

turms-admin/script/typescript-parser.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
const {readFileSync} = require('fs');
1+
import {readFileSync} from 'fs';
2+
import typescript from 'typescript';
3+
24
const {
35
createSourceFile,
46
isArrayBindingPattern,
@@ -16,7 +18,7 @@ const {
1618
ScriptKind,
1719
ScriptTarget,
1820
SyntaxKind
19-
} = require('typescript');
21+
} = typescript;
2022

2123
const Visibility = {
2224
Private: 'private',
@@ -250,7 +252,7 @@ function parseClass(node) {
250252
return declaration;
251253
}
252254

253-
module.exports = {
255+
export default {
254256
parse(filePath) {
255257
const source = createSourceFile(
256258
filePath,

0 commit comments

Comments
 (0)