From 31df1331a699f75c4bffda5f54a41617a028d73d Mon Sep 17 00:00:00 2001 From: hihangeol Date: Thu, 2 Jan 2025 00:34:18 +0900 Subject: [PATCH] =?UTF-8?q?[TEST]=20=ED=95=A8=EC=88=98=20=EC=9D=B4?= =?UTF-8?q?=EB=A6=84=20=EB=93=B1=EB=A1=9D=20=EB=B0=A9=EC=8B=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.sh | 23 +++++++++++++++++++++++ main.ts | 45 +++++++++++++++++++++++++++++++++++++++------ manifest.json | 2 +- 3 files changed, 63 insertions(+), 7 deletions(-) create mode 100644 build.sh diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..33f090e --- /dev/null +++ b/build.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +# npm build 실행 +echo "Building the project..." +npm run build + +# 빌드 성공 여부 확인 +if [ $? -ne 0 ]; then + echo "Build failed. Exiting." + exit 1 +fi + +# Python 스크립트 실행 +echo "Running Python script to copy files..." +python3 copy_to_obsidian.py + +# Python 스크립트 성공 여부 확인 +if [ $? -ne 0 ]; then + echo "Python script execution failed. Exiting." + exit 1 +fi + +echo "Build and copy process completed successfully!" diff --git a/main.ts b/main.ts index ab51ab8..f8c67b0 100644 --- a/main.ts +++ b/main.ts @@ -1,4 +1,8 @@ -import { App, Editor, MarkdownView, Modal, Notice, Plugin, PluginSettingTab, Setting } from 'obsidian'; +import { + App, Editor, MarkdownView, + Modal, Notice, Plugin, PluginSettingTab, Setting, + TFile, +} from 'obsidian'; // Remember to rename these classes and interfaces! @@ -13,15 +17,43 @@ const DEFAULT_SETTINGS: CsvPluginSettings = { export default class CsvPlugin extends Plugin { settings: CsvPluginSettings; - testFunction(arg: string): string { - return `Test function called with argument: ${arg}`; + // testFunction(arg: string): string { + // return `Test function called with argument: ${arg}`; + // } + + // 등록하는 이름 말고 정의한 함수 이름으로 호출됨. + async saveFile(app: App, fileName: string, content: string): Promise { + const vault = app.vault; + await vault.create(fileName, content); + + // 파일이 이미 존재하는지 확인 + // const existingFile = vault.getAbstractFileByPath(fileName); + // if (existingFile instanceof TFile) { + // // 파일이 존재하면 덮어쓰기 + // await vault.modify(existingFile, content); + + // } else { + // // 파일이 존재하지 않으면 새로 생성 + // await vault.create(fileName, content); + // } } async onload() { await this.loadSettings(); - (window as any).testFunction = this.testFunction; - + // custom 함수 추가. + // (window as any).testFunction = this.testFunction; + // (window as any).saveFileFromDataview = async (fileName: string, content: string) => { + // if(!this.app || !this.app.vault) { + // console.error('app or vault is not ready'); + // return; + // } + // try { + // await this.saveFile(this.app, fileName, content); + // } catch (error) { + // console.error(error); + // } + // }; // This creates an icon in the left ribbon. const ribbonIconEl = this.addRibbonIcon('dice', 'Sample Plugin', (evt: MouseEvent) => { // Called when the user clicks the icon. @@ -86,7 +118,8 @@ export default class CsvPlugin extends Plugin { } onunload() { - delete (window as any).testFunction; + // delete (window as any).testFunction; + delete (window as any).saveFileFromDataview; } async loadSettings() { diff --git a/manifest.json b/manifest.json index 74982c4..bd10535 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "csv-allinone", "name": "CSV All-in-One", - "version": "0.1.0", + "version": "0.1.1", "minAppVersion": "1.7.7", "description": "all about csv.", "author": "hihangeol",