diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..9ee3ee3 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,3 @@ +node_modules/ + +main.js \ No newline at end of file diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..d5e5590 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,23 @@ +{ + "root": true, + "parser": "@typescript-eslint/parser", + "env": { "node": true }, + "plugins": [ + "@typescript-eslint" + ], + "extends": [ + "eslint:recommended", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended" + ], + "parserOptions": { + "sourceType": "module" + }, + "rules": { + "no-unused-vars": "off", + "@typescript-eslint/no-unused-vars": ["error", { "args": "none" }], + "@typescript-eslint/ban-ts-comment": "off", + "no-prototype-builtins": "off", + "@typescript-eslint/no-empty-function": "off" + } +} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..906fc88 --- /dev/null +++ b/.gitignore @@ -0,0 +1,22 @@ +# vscode +.vscode + +# Intellij +*.iml +.idea + +# npm +node_modules + +# Don't include the compiled main.js file in the repo. +# They should be uploaded to GitHub releases instead. +main.js + +# Exclude sourcemaps +*.map + +# obsidian +data.json + +# Exclude macOS Finder (System Explorer) View States +.DS_Store \ No newline at end of file diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..b973752 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +tag-version-prefix="" \ No newline at end of file diff --git a/esbuild.config.mjs b/esbuild.config.mjs index 4c8a482..6316958 100644 --- a/esbuild.config.mjs +++ b/esbuild.config.mjs @@ -1,8 +1,6 @@ import esbuild from "esbuild"; import process from "process"; -import builtins from 'builtin-modules' -import { writeFileSync } from 'fs'; - +import builtins from "builtin-modules"; const banner = `/* @@ -13,7 +11,7 @@ if you want to view the source, please visit the github repository of this plugi const prod = (process.argv[2] === 'production'); -const buildConfig = { +const context = await esbuild.context({ banner: { js: banner, }, @@ -33,23 +31,21 @@ const buildConfig = { '@lezer/common', '@lezer/highlight', '@lezer/lr', - ...builtins - ], + ...builtins], format: 'cjs', - target: 'chrome106', + target: 'es2018', logLevel: "info", sourcemap: prod ? false : 'inline', treeShaking: true, - outdir: prod ? 'dist' : '../../dev-vault/.obsidian/plugins/obsidian-confluence', + outdir: prod ? 'dist' : 'dev-dist', mainFields: ['module', 'main'], minify: true, metafile: true, -}; +}); if (prod) { - const buildResult = await esbuild.build(buildConfig); - writeFileSync("./dist/meta.json", JSON.stringify(buildResult.metafile)); + await context.rebuild(); + process.exit(0); } else { - const context = await esbuild.context(buildConfig); await context.watch(); -} +} \ No newline at end of file diff --git a/manifest.json b/manifest.json index a41f281..d5079c8 100644 --- a/manifest.json +++ b/manifest.json @@ -1,10 +1,10 @@ { "id": "confluence-integration", "name": "Confluence Integration", - "version": "5.5.2", + "version": "5.5.3", "minAppVersion": "1.0.0", "description": "This plugin allows you to publish your notes to Confluence", "author": "andymac4182", "authorUrl": "https://github.com/andymac4182", "isDesktopOnly": true -} +} \ No newline at end of file diff --git a/package.json b/package.json index a409db2..84525df 100644 --- a/package.json +++ b/package.json @@ -1,15 +1,16 @@ { "name": "obsidian-confluence", - "version": "5.5.2", + "version": "5.5.3", "description": "This library allows you to publish your notes to Confluence", "main": "main.js", "type": "module", "scripts": { "dev": "node esbuild.config.mjs", - "build": "tsc && node esbuild.config.mjs production", + "build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production", "fmt": "npx prettier --write src/", "lint": "eslint --ignore-path ../../.eslintignore --ext .jsx,tsx,.js,.ts src/", - "prettier-check": "npx prettier --check src/" + "prettier-check": "npx prettier --check src/", + "version": "node version-bump.mjs && git add manifest.json versions.json" }, "keywords": [], "author": "andymac4182", @@ -17,18 +18,18 @@ "devDependencies": { "@types/mime-types": "^2.1.1", "@types/react-dom": "^18.0.11", - "obsidian": "1.1.1" + "obsidian": "^1.1.1" }, "dependencies": { - "confluence.js": "^1.6.3", - "mime-types": "^2.1.35", - "react": "^16.14.0", - "react-dom": "^16.14.0", - "@markdown-confluence/lib": "5.5.2", - "@markdown-confluence/mermaid-electron-renderer": "5.5.2" - }, - "resolutions": { - "prosemirror-model": "1.14.3" + "@markdown-confluence/lib": "^5.5.1", + "@markdown-confluence/mermaid-electron-renderer": "^5.5.1", + "@types/node": "^20.0.0", + "@typescript-eslint/eslint-plugin": "^5.29.0", + "@typescript-eslint/parser": "^5.29.0", + "builtin-modules": "^3.3.0", + "esbuild": "^0.17.3", + "react": "^18.3.1", + "tslib": "^2.4.0", + "typescript": "^4.7.4" } } - \ No newline at end of file diff --git a/src/ConfluencePerPageForm.tsx b/src/ConfluencePerPageForm.tsx index e000923..4d31dbb 100644 --- a/src/ConfluencePerPageForm.tsx +++ b/src/ConfluencePerPageForm.tsx @@ -1,8 +1,8 @@ -import { Modal, App, FrontMatterCache } from "obsidian"; +import {Modal, App, FrontMatterCache} from "obsidian"; import ReactDOM from "react-dom"; -import React, { useState, ChangeEvent } from "react"; -import { ConfluencePageConfig } from "@markdown-confluence/lib"; -import { Property } from "csstype"; +import React, {useState, ChangeEvent} from "react"; +import {ConfluencePageConfig} from "@markdown-confluence/lib"; +import {Property} from "csstype"; export type ConfluencePerPageUIValues = { [K in keyof ConfluencePageConfig.ConfluencePerPageConfig]: { @@ -31,7 +31,7 @@ export function mapFrontmatterToConfluencePerPageUIValues( default: defaultValue, } = config[ propertyKey as keyof ConfluencePageConfig.ConfluencePerPageConfig - ]; + ]; const frontmatterValue = frontmatter[key]; if (frontmatterValue !== undefined) { @@ -44,12 +44,14 @@ export function mapFrontmatterToConfluencePerPageUIValues( case "options": case "array-text": result[propertyKey as keyof ConfluencePerPageUIValues] = - { value: defaultValue as never, isSet: false }; + // @ts-ignore + {value: defaultValue as never, isSet: false}; break; case "boolean": case "text": result[propertyKey as keyof ConfluencePerPageUIValues] = - { value: undefined, isSet: false }; + // @ts-ignore + {value: undefined, isSet: false}; break; default: throw new Error("Missing case for inputType"); @@ -82,14 +84,14 @@ const handleChange = ( ) => { const validationResult = inputValidator(value); - setValues((prevValues) => ({ + setValues((prevValues: any) => ({ ...prevValues, [key]: { ...prevValues[key as keyof ConfluencePerPageUIValues], - ...(isSetValue ? { isSet: value } : { value }), + ...(isSetValue ? {isSet: value} : {value}), }, })); - setErrors((prevErrors) => ({ + setErrors((prevErrors: any) => ({ ...prevErrors, [key]: validationResult.valid ? [] : validationResult.errors, })); @@ -196,7 +198,7 @@ const renderArrayText = ( const newArray = [ ...(values[ key as keyof ConfluencePerPageUIValues - ].value as unknown as string[]), + ].value as unknown as string[]), ]; newArray[index] = e.target.value; handleChange( @@ -411,10 +413,10 @@ const renderOptions = ( ); const ConfluenceForm: React.FC = ({ - config, - initialValues, - onSubmit, -}) => { + config, + initialValues, + onSubmit, + }: { config: any, initialValues: any, onSubmit: any }) => { const [values, setValues] = useState(initialValues); const [errors, setErrors] = useState>({}); @@ -429,67 +431,67 @@ const ConfluenceForm: React.FC = ({

Update Confluence Page Settings

- - - - - + + + + + - {Object.entries(config).map(([key, config]) => { - switch (config.inputType) { - case "text": - return renderTextInput( - key, - config as ConfluencePageConfig.FrontmatterConfig< - string, - "text" - >, - values, - errors, - setValues, - setErrors, - ); - case "array-text": - return renderArrayText( - key, - config as ConfluencePageConfig.FrontmatterConfig< - string[], - "array-text" - >, - values, - errors, - setValues, - setErrors, - ); - case "boolean": - return renderBoolean( - key, - config as ConfluencePageConfig.FrontmatterConfig< - boolean, - "boolean" - >, - values, - errors, - setValues, - setErrors, - ); - case "options": - return renderOptions( - key, - config as ConfluencePageConfig.FrontmatterConfig< - ConfluencePageConfig.PageContentType, - "options" - >, - values, - errors, - setValues, - setErrors, - ); - default: - return null; - } - })} + {Object.entries(config).map(([key, config]: [string, any]) => { + switch (config.inputType) { + case "text": + return renderTextInput( + key, + config as ConfluencePageConfig.FrontmatterConfig< + string, + "text" + >, + values, + errors, + setValues, + setErrors, + ); + case "array-text": + return renderArrayText( + key, + config as ConfluencePageConfig.FrontmatterConfig< + string[], + "array-text" + >, + values, + errors, + setValues, + setErrors, + ); + case "boolean": + return renderBoolean( + key, + config as ConfluencePageConfig.FrontmatterConfig< + boolean, + "boolean" + >, + values, + errors, + setValues, + setErrors, + ); + case "options": + return renderOptions( + key, + config as ConfluencePageConfig.FrontmatterConfig< + ConfluencePageConfig.PageContentType, + "options" + >, + values, + errors, + setValues, + setErrors, + ); + default: + return null; + } + })}
YAML KeyValueUpdate
YAML KeyValueUpdate
@@ -506,7 +508,7 @@ export class ConfluencePerPageForm extends Modal { } override onOpen() { - const { contentEl } = this; + const {contentEl} = this; const test: FormProps = { ...this.modalProps, onSubmit: (values) => { @@ -518,7 +520,7 @@ export class ConfluencePerPageForm extends Modal { } override onClose() { - const { contentEl } = this; + const {contentEl} = this; ReactDOM.unmountComponentAtNode(contentEl); contentEl.empty(); } diff --git a/tsconfig.json b/tsconfig.json index 55bc5f3..1f49485 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,13 +1,31 @@ { - "extends": "../../tsconfig.json", - "compilerOptions":{ - "baseUrl":".", - "rootDir": "src", - "outDir": "dist", - "declarationDir": "dist", - "noEmit": true, - "skipLibCheck": true, + "compilerOptions": { + "baseUrl": ".", + "rootDir": "src", + "outDir": "dist", + "declarationDir": "dist", + "jsx": "react-jsx", + "inlineSourceMap": true, + "inlineSources": true, + "module": "ESNext", + "target": "ES6", + "allowJs": true, + "noImplicitAny": true, + "moduleResolution": "node", + "importHelpers": true, + "isolatedModules": true, + "strictNullChecks": true, + "allowSyntheticDefaultImports": true, + "lib": [ + "DOM", + "ES5", + "ES6", + "ES7" + ] }, - "include":[ "**/*.ts", "**/*.tsx" ], - "exclude": ["node_modules", "packages/**/dist/*", "dist/*", "**/*.test.ts", "**/jest.config.ts"] + "include": [ + "**/*.ts", "**/*.tsx" + ], + "exclude": ["node_modules", "packages/**/dist/*", "dist/*", "**/*.test.ts", "**/jest.config.ts"] + } \ No newline at end of file diff --git a/version-bump.mjs b/version-bump.mjs new file mode 100644 index 0000000..8747610 --- /dev/null +++ b/version-bump.mjs @@ -0,0 +1,15 @@ + +import { readFileSync, writeFileSync } from "fs"; + +const targetVersion = process.env.npm_package_version; + +// read minAppVersion from manifest.json and bump version to target version +let manifest = JSON.parse(readFileSync("manifest.json", "utf8")); +const { minAppVersion } = manifest; +manifest.version = targetVersion; +writeFileSync("manifest.json", JSON.stringify(manifest, null, "\t")); + +// update versions.json with target version and minAppVersion from manifest.json +let versions = JSON.parse(readFileSync("versions.json", "utf8")); +versions[targetVersion] = minAppVersion; +writeFileSync("versions.json", JSON.stringify(versions, null, "\t")); diff --git a/versions.json b/versions.json new file mode 100644 index 0000000..fe52713 --- /dev/null +++ b/versions.json @@ -0,0 +1,4 @@ +{ + "5.5.3": "1.0.0", + "5.5.2": "1.0.0" +} \ No newline at end of file