Skip to content

Commit

Permalink
🐛 fix: export-type scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
frostime committed Dec 3, 2024
1 parent c4ae739 commit aae65e2
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ node_modules
dev
dist
build
types/**/*
22 changes: 16 additions & 6 deletions scripts/export-types.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { exec } from 'child_process';
import { glob } from 'glob';
import { exec, execSync } from 'child_process';
import fs from 'fs';
import path from 'path';

Expand All @@ -11,16 +12,23 @@ const __dirname = path.dirname(__filename);
// chdir 到上层 plugin.json 所在的目录
process.chdir(path.join(__dirname, '..'));
console.log(process.cwd());
// list current directory
console.log(fs.readdirSync('./'));
const dirname = process.cwd();

const removeTypesDir = () => {
if (fs.existsSync('./types')) {
fs.rmSync('./types', { recursive: true, force: true });
console.debug('remove ./types');
}
}

const tsc = `tsc --declaration --emitDeclarationOnly --skipLibCheck --target ES2022 --project tsconfig.json --outDir ./types --noEmitOnError false --stripInternal`;

await exec(tsc);
removeTypesDir();

let outputDir = './public';

const tsc = `tsc --declaration --emitDeclarationOnly --skipLibCheck --target ES2022 --project tsconfig.json --outDir ./types --noEmitOnError false --stripInternal`;

execSync(tsc);


const fileWriter = (filepath) => {
let fd = fs.openSync(filepath, 'w');
Expand Down Expand Up @@ -115,4 +123,6 @@ for (let i = 0; i < lines.length - 1; i++) {
}
}
}

// removeTypesDir();
fs.writeFileSync(path.join(outputDir, 'types.d.ts'), lines.join('\n'));
4 changes: 3 additions & 1 deletion src/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @Author : frostime
* @Date : 2024-05-08 15:00:37
* @FilePath : /src/core/index.ts
* @LastEditTime : 2024-12-03 12:59:19
* @LastEditTime : 2024-12-03 18:06:19
* @Description :
* - Fork from project https://github.com/zxhd863943427/siyuan-plugin-data-query
* - 基于该项目的 v0.0.7 版本进行修改
Expand All @@ -18,6 +18,8 @@ import { embedBlockEvent } from "./editor";
import Query from "./query";
import { onProtyleDestroyed } from "./gc";
import { loadUserCustomView } from "./custom-view";

import { i18n } from '@/index';
/**************************************** Func ****************************************/


Expand Down
2 changes: 0 additions & 2 deletions types/.gitignore

This file was deleted.

0 comments on commit aae65e2

Please sign in to comment.