From 4e2aa201b1fbf16a80638e6369830df1f8030cb8 Mon Sep 17 00:00:00 2001 From: haril song Date: Thu, 12 Dec 2024 13:26:51 +0900 Subject: [PATCH] style: force formatting --- .github/ISSUE_TEMPLATE/bug_report.md | 1 - .github/ISSUE_TEMPLATE/feature_request.md | 1 - .github/auto_assign.yml | 1 - .github/dependabot.yml | 10 +- .github/pull_request_template.md | 3 +- .github/workflows/auto-approve.yml | 2 +- .github/workflows/auto-assign-action.yml | 1 - .github/workflows/ci.yml | 14 +- .github/workflows/linter.yml | 15 +- CODE_OF_CONDUCT.md | 20 +- README.md | 1 - esbuild.config.mjs | 70 +++--- eslint.config.mjs | 82 +++---- jest.config.js | 4 +- manifest.json | 20 +- src/CalloutConverter.ts | 16 +- src/CommentsConverter.ts | 12 +- src/CurlyBraceConverter.ts | 11 +- src/FootnotesConverter.ts | 1 - src/FrontMatterConverter.ts | 38 ++-- src/ResourceLinkConverter.ts | 39 ++-- src/WikiLinkConverter.ts | 11 +- src/core/ConverterChain.ts | 3 +- src/core/ObsidianRegex.ts | 2 +- src/core/validation.ts | 49 +++-- src/docusaurus/DateExtractionPattern.ts | 5 +- src/docusaurus/docusaurus.ts | 66 +++--- src/docusaurus/settings/DocusaurusSettings.ts | 11 +- src/jekyll/chirpy.ts | 3 +- src/jekyll/settings/JekyllSettings.ts | 7 +- src/main.ts | 25 ++- src/settings.ts | 200 ++++++++++-------- src/tests/CalloutConverter.test.ts | 117 +++++++--- src/tests/ConverterChain.test.ts | 1 - src/tests/DateExtractionPattern.test.ts | 38 +++- src/tests/EmbedsConverter.test.ts | 11 +- src/tests/FrontMatterConverter.test.ts | 67 +++--- src/tests/ResourceLinkConverter.test.ts | 40 ++-- src/tests/WikiLinkConverter.test.ts | 1 - src/utils.ts | 69 +++--- sweep.yaml | 1 - tsconfig.json | 20 +- version-bump.mjs | 10 +- versions.json | 54 ++--- 44 files changed, 685 insertions(+), 488 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index f660e90e..d5f053fc 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -4,7 +4,6 @@ about: Create a report to help us improve title: '' labels: bug assignees: '' - --- **Describe the bug** diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index bbcbbe7d..2f28cead 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -4,7 +4,6 @@ about: Suggest an idea for this project title: '' labels: '' assignees: '' - --- **Is your feature request related to a problem? Please describe.** diff --git a/.github/auto_assign.yml b/.github/auto_assign.yml index cfd74378..08296899 100644 --- a/.github/auto_assign.yml +++ b/.github/auto_assign.yml @@ -11,7 +11,6 @@ reviewers: # A number of reviewers added to the pull request # Set 0 to add all the reviewers (default: 0) numberOfReviewers: 0 - # A list of assignees, overrides reviewers if set # assignees: # - assigneeA diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 31d18cdc..9d08dec6 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,13 +5,13 @@ --- version: 2 updates: - - package-ecosystem: "npm" # See documentation for possible values - directory: "/" # Location of package manifests + - package-ecosystem: 'npm' # See documentation for possible values + directory: '/' # Location of package manifests schedule: - interval: "monthly" + interval: 'monthly' labels: - - "dependencies" + - 'dependencies' groups: dev-dependencies: patterns: - - "@type*" + - '@type*' diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 19765c26..bbead3c1 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -22,15 +22,14 @@ What kind of change does this PR introduce? - [ ] Other... Please describe: ## What is the current behavior? + Issue Number: N/A - ## What is the new behavior? - ## Does this PR introduce a breaking change? - [ ] Yes diff --git a/.github/workflows/auto-approve.yml b/.github/workflows/auto-approve.yml index 38afaa9d..8fd49b12 100644 --- a/.github/workflows/auto-approve.yml +++ b/.github/workflows/auto-approve.yml @@ -16,7 +16,7 @@ jobs: id: metadata uses: dependabot/fetch-metadata@v1 with: - github-token: "${{ secrets.GITHUB_TOKEN }}" + github-token: '${{ secrets.GITHUB_TOKEN }}' - name: Approve a PR run: gh pr review --approve "$PR_URL" env: diff --git a/.github/workflows/auto-assign-action.yml b/.github/workflows/auto-assign-action.yml index b8e2c0d2..1d925b54 100644 --- a/.github/workflows/auto-assign-action.yml +++ b/.github/workflows/auto-assign-action.yml @@ -8,4 +8,3 @@ jobs: runs-on: ubuntu-latest steps: - uses: kentaro-m/auto-assign-action@v2.0.0 - diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5c4c2e8b..25510133 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,11 +2,11 @@ name: CI on: push: - branches: [ "main" ] + branches: ['main'] pull_request: - branches: [ "main" ] + branches: ['main'] -permissions: { } +permissions: {} jobs: run: @@ -26,9 +26,9 @@ jobs: - uses: actions/checkout@v4 - uses: codecov/codecov-action@v4 with: -# fail_ci_if_error: true # optional (default = false) -# files: ./coverage1.xml,./coverage2.xml # optional -# flags: unittests # optional -# name: codecov-umbrella # optional + # fail_ci_if_error: true # optional (default = false) + # files: ./coverage1.xml,./coverage2.xml # optional + # flags: unittests # optional + # name: codecov-umbrella # optional token: ${{ secrets.CODECOV_TOKEN }} # required verbose: true # optional (default = false) diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 97ff53dd..f1883d61 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -3,11 +3,11 @@ name: Lint Code Base on: push: - branches-ignore: [ main ] + branches-ignore: [main] pull_request: - branches: [ main ] + branches: [main] -permissions: { } +permissions: {} jobs: build: @@ -29,11 +29,10 @@ jobs: fetch-depth: 0 - name: Super-linter - uses: super-linter/super-linter@v7.2.0 # x-release-please-version + uses: super-linter/super-linter@v7.2.0 # x-release-please-version env: # To report GitHub Actions status checks GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - VALIDATE_JAVASCRIPT_STANDARD: "false" - VALIDATE_TYPESCRIPT_STANDARD: "false" - VALIDATE_CHECKOV: "false" - + VALIDATE_JAVASCRIPT_STANDARD: 'false' + VALIDATE_TYPESCRIPT_STANDARD: 'false' + VALIDATE_CHECKOV: 'false' diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 8f2b2d2d..93c4b784 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -17,23 +17,23 @@ diverse, inclusive, and healthy community. Examples of behavior that contributes to a positive environment for our community include: -* Demonstrating empathy and kindness toward other people -* Being respectful of differing opinions, viewpoints, and experiences -* Giving and gracefully accepting constructive feedback -* Accepting responsibility and apologizing to those affected by our mistakes, +- Demonstrating empathy and kindness toward other people +- Being respectful of differing opinions, viewpoints, and experiences +- Giving and gracefully accepting constructive feedback +- Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience -* Focusing on what is best not just for us as individuals, but for the +- Focusing on what is best not just for us as individuals, but for the overall community Examples of unacceptable behavior include: -* The use of sexualized language or imagery, and sexual attention or +- The use of sexualized language or imagery, and sexual attention or advances of any kind -* Trolling, insulting or derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or email +- Trolling, insulting or derogatory comments, and personal or political attacks +- Public or private harassment +- Publishing others' private information, such as a physical or email address, without their explicit permission -* Other conduct which could reasonably be considered inappropriate in a +- Other conduct which could reasonably be considered inappropriate in a professional setting ## Enforcement Responsibilities diff --git a/README.md b/README.md index 035769c9..453eb193 100644 --- a/README.md +++ b/README.md @@ -70,4 +70,3 @@ This project is published under [MIT](https://choosealicense.com/licenses/mit/) If you ever want to buy me a coffee, don't hesitate. [![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/V7V8KX38Q) - diff --git a/esbuild.config.mjs b/esbuild.config.mjs index dc2e9e80..bfa89245 100644 --- a/esbuild.config.mjs +++ b/esbuild.config.mjs @@ -1,48 +1,48 @@ -import esbuild from "esbuild"; -import process from "process"; -import builtins from "builtin-modules"; +import esbuild from 'esbuild'; +import process from 'process'; +import builtins from 'builtin-modules'; -const banner = -`/* +const banner = `/* THIS IS A GENERATED/BUNDLED FILE BY ESBUILD if you want to view the source, please visit the github repository of this plugin */ `; -const prod = (process.argv[2] === "production"); +const prod = process.argv[2] === 'production'; const context = await esbuild.context({ - banner: { - js: banner, - }, - entryPoints: ["src/main.ts"], - bundle: true, - external: [ - "obsidian", - "electron", - "@codemirror/autocomplete", - "@codemirror/collab", - "@codemirror/commands", - "@codemirror/language", - "@codemirror/lint", - "@codemirror/search", - "@codemirror/state", - "@codemirror/view", - "@lezer/common", - "@lezer/highlight", - "@lezer/lr", - ...builtins], - format: "cjs", - target: "es2018", - logLevel: "info", - sourcemap: prod ? false : "inline", - treeShaking: true, - outfile: "main.js", + banner: { + js: banner, + }, + entryPoints: ['src/main.ts'], + bundle: true, + external: [ + 'obsidian', + 'electron', + '@codemirror/autocomplete', + '@codemirror/collab', + '@codemirror/commands', + '@codemirror/language', + '@codemirror/lint', + '@codemirror/search', + '@codemirror/state', + '@codemirror/view', + '@lezer/common', + '@lezer/highlight', + '@lezer/lr', + ...builtins, + ], + format: 'cjs', + target: 'es2018', + logLevel: 'info', + sourcemap: prod ? false : 'inline', + treeShaking: true, + outfile: 'main.js', }); if (prod) { - await context.rebuild(); - process.exit(0); + await context.rebuild(); + process.exit(0); } else { - await context.watch(); + await context.watch(); } diff --git a/eslint.config.mjs b/eslint.config.mjs index 50d1262d..751546a9 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -1,56 +1,62 @@ -import typescriptEslint from "@typescript-eslint/eslint-plugin"; -import globals from "globals"; -import tsParser from "@typescript-eslint/parser"; -import path from "node:path"; -import { fileURLToPath } from "node:url"; -import js from "@eslint/js"; -import { FlatCompat } from "@eslint/eslintrc"; +import typescriptEslint from '@typescript-eslint/eslint-plugin'; +import globals from 'globals'; +import tsParser from '@typescript-eslint/parser'; +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; +import js from '@eslint/js'; +import { FlatCompat } from '@eslint/eslintrc'; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); const compat = new FlatCompat({ - baseDirectory: __dirname, - recommendedConfig: js.configs.recommended, - allConfig: js.configs.all + baseDirectory: __dirname, + recommendedConfig: js.configs.recommended, + allConfig: js.configs.all, }); -export default [{ - files: ["**/*.ts", "**/*.tsx"], - ignores: ["**/node_modules/", "**/main.js"], -}, ...compat.extends( - "eslint:recommended", - "plugin:@typescript-eslint/eslint-recommended", - "plugin:@typescript-eslint/recommended", -), { +export default [ + { + files: ['**/*.ts', '**/*.tsx'], + ignores: ['**/node_modules/', '**/main.js'], + }, + ...compat.extends( + 'eslint:recommended', + 'plugin:@typescript-eslint/eslint-recommended', + 'plugin:@typescript-eslint/recommended', + ), + { plugins: { - "@typescript-eslint": typescriptEslint, + '@typescript-eslint': typescriptEslint, }, languageOptions: { - globals: { - ...globals.node, - }, + globals: { + ...globals.node, + }, - parser: tsParser, - ecmaVersion: 2018, - sourceType: "module", + parser: tsParser, + ecmaVersion: 2018, + sourceType: 'module', - parserOptions: { - project: "./tsconfig.json", - }, + parserOptions: { + project: './tsconfig.json', + }, }, rules: { - "no-unused-vars": "off", + 'no-unused-vars': 'off', - "@typescript-eslint/no-unused-vars": ["error", { - args: "none", - }], + '@typescript-eslint/no-unused-vars': [ + 'error', + { + args: 'none', + }, + ], - "@typescript-eslint/ban-ts-comment": "off", - "no-prototype-builtins": "off", - "@typescript-eslint/no-empty-function": "off", - semi: ["error", "always"], + '@typescript-eslint/ban-ts-comment': 'off', + 'no-prototype-builtins': 'off', + '@typescript-eslint/no-empty-function': 'off', + semi: ['error', 'always'], }, -}]; - + }, +]; diff --git a/jest.config.js b/jest.config.js index 000703b9..13827a89 100644 --- a/jest.config.js +++ b/jest.config.js @@ -2,10 +2,10 @@ module.exports = { preset: 'ts-jest', testEnvironment: 'node', transform: { - '^.+\\.ts?$': 'ts-jest' + '^.+\\.ts?$': 'ts-jest', }, transformIgnorePatterns: ['/node_modules'], moduleDirectories: ['node_modules', 'src'], collectCoverage: true, - coverageReporters: ['text', 'cobertura'] + coverageReporters: ['text', 'cobertura'], }; diff --git a/manifest.json b/manifest.json index 7633e21e..b1d5ae84 100644 --- a/manifest.json +++ b/manifest.json @@ -1,11 +1,11 @@ { - "id": "o2", - "name": "O2", - "version": "2.1.0", - "minAppVersion": "0.15.0", - "description": "This is a plugin to make obsidian markdown syntax compatible with other markdown syntax.", - "author": "haril song", - "authorUrl": "https://github.com/songkg7", - "fundingUrl": "", - "isDesktopOnly": true -} \ No newline at end of file + "id": "o2", + "name": "O2", + "version": "2.1.0", + "minAppVersion": "0.15.0", + "description": "This is a plugin to make obsidian markdown syntax compatible with other markdown syntax.", + "author": "haril song", + "authorUrl": "https://github.com/songkg7", + "fundingUrl": "", + "isDesktopOnly": true +} diff --git a/src/CalloutConverter.ts b/src/CalloutConverter.ts index 6e58c088..56049119 100644 --- a/src/CalloutConverter.ts +++ b/src/CalloutConverter.ts @@ -7,9 +7,11 @@ export class CalloutConverter implements Converter { } } -const jekyllReplacer = (match: string, p1: string, p2: string, p3: string) => `${p3}\n{: .prompt-${replaceKeyword(p1)}}`; +const jekyllReplacer = (match: string, p1: string, p2: string, p3: string) => + `${p3}\n{: .prompt-${replaceKeyword(p1)}}`; -const convertCalloutSyntaxToChirpy = (content: string) => content.replace(ObsidianRegex.CALLOUT, jekyllReplacer); +const convertCalloutSyntaxToChirpy = (content: string) => + content.replace(ObsidianRegex.CALLOUT, jekyllReplacer); const jekyllCalloutMap = new Map(); jekyllCalloutMap.set('note', 'info'); @@ -41,12 +43,18 @@ function replaceKeyword(target: string) { return jekyllCalloutMap.get(target.toLowerCase()) || 'info'; } -const docusaurusReplacer = (match: string, p1: string, p2: string, p3: string) => { +const docusaurusReplacer = ( + match: string, + p1: string, + p2: string, + p3: string, +) => { const title = p2 ? `[${p2.trim()}]` : ''; return `:::${replaceDocusaurusKeyword(p1)}${title}\n\n${replaceDocusaurusContents(p3)}\n\n:::`; }; -export const convertDocusaurusCallout = (input: string) => input.replace(ObsidianRegex.CALLOUT, docusaurusReplacer); +export const convertDocusaurusCallout = (input: string) => + input.replace(ObsidianRegex.CALLOUT, docusaurusReplacer); const replaceDocusaurusKeyword = (target: string) => docusaurusCalloutMap[target.toLowerCase()] || 'note'; diff --git a/src/CommentsConverter.ts b/src/CommentsConverter.ts index aa7b400c..f5958539 100644 --- a/src/CommentsConverter.ts +++ b/src/CommentsConverter.ts @@ -2,10 +2,16 @@ import { Converter } from './core/Converter'; import { ObsidianRegex } from './core/ObsidianRegex'; export class CommentsConverter implements Converter { - public convert(input: string): string { - return input.replace(ObsidianRegex.COMMENT, (match, comments) => ``); + return input.replace( + ObsidianRegex.COMMENT, + (match, comments) => ``, + ); } } -export const convertComments = (input: string) => input.replace(ObsidianRegex.COMMENT, (match, comments) => ``); +export const convertComments = (input: string) => + input.replace( + ObsidianRegex.COMMENT, + (match, comments) => ``, + ); diff --git a/src/CurlyBraceConverter.ts b/src/CurlyBraceConverter.ts index eda8de3b..0d78e2dd 100644 --- a/src/CurlyBraceConverter.ts +++ b/src/CurlyBraceConverter.ts @@ -2,7 +2,6 @@ import { Converter } from './core/Converter'; import { ObsidianRegex } from './core/ObsidianRegex'; export class CurlyBraceConverter implements Converter { - private readonly isEnable: boolean; constructor(isEnable = false) { @@ -13,7 +12,10 @@ export class CurlyBraceConverter implements Converter { if (!this.isEnable) { return input; } - return input.replace(ObsidianRegex.DOUBLE_CURLY_BRACES, (match, content) => `{% raw %}${match}{% endraw %}`); + return input.replace( + ObsidianRegex.DOUBLE_CURLY_BRACES, + (match, content) => `{% raw %}${match}{% endraw %}`, + ); } } @@ -21,5 +23,8 @@ export const convertCurlyBrace = (isEnable: boolean, input: string) => { if (!isEnable) { return input; } - return input.replace(ObsidianRegex.DOUBLE_CURLY_BRACES, (match, content) => `{% raw %}${match}{% endraw %}`); + return input.replace( + ObsidianRegex.DOUBLE_CURLY_BRACES, + (match, content) => `{% raw %}${match}{% endraw %}`, + ); }; diff --git a/src/FootnotesConverter.ts b/src/FootnotesConverter.ts index 1d2a37dd..4be934fb 100644 --- a/src/FootnotesConverter.ts +++ b/src/FootnotesConverter.ts @@ -2,7 +2,6 @@ import { ObsidianRegex } from './core/ObsidianRegex'; import { Converter } from './core/Converter'; export class FootnotesConverter implements Converter { - convert(input: string): string { return input.replace(ObsidianRegex.SIMPLE_FOOTNOTE, (match, key) => { return `[^fn-nth-${key}]`; diff --git a/src/FrontMatterConverter.ts b/src/FrontMatterConverter.ts index dd791d17..4bcfe5f4 100644 --- a/src/FrontMatterConverter.ts +++ b/src/FrontMatterConverter.ts @@ -46,25 +46,26 @@ const convert = (frontMatter: FrontMatter) => { if (fm.categories && JSON.stringify(fm.categories).startsWith('[')) { fm.categories = `${JSON.stringify(fm.categories) .replace(/,/g, ', ') - .replace(/"/g, '') - }`; + .replace(/"/g, '')}`; } if (fm.authors) { const authorList = fm.authors.split(',').map(author => author.trim()); - fm.authors = authorList.length > 1 ? `[${authorList.join(', ')}]` : authorList[0]; + fm.authors = + authorList.length > 1 ? `[${authorList.join(', ')}]` : authorList[0]; } // if fm.tags is array if (fm.tags) { - fm.tags = Array.isArray(fm.tags) ? `[${fm.tags.join(', ')}]` : `[${fm.tags}]`; + fm.tags = Array.isArray(fm.tags) + ? `[${fm.tags.join(', ')}]` + : `[${fm.tags}]`; } return fm; }; export class FrontMatterConverter implements Converter { - private readonly fileName: string; private readonly resourcePath: string; private readonly isEnableBanner: boolean; @@ -79,7 +80,8 @@ export class FrontMatterConverter implements Converter { this.fileName = fileName; this.resourcePath = resourcePath; this.isEnableBanner = isEnableBanner; - this.isEnableUpdateFrontmatterTimeOnEdit = isEnableUpdateFrontmatterTimeOnEdit; + this.isEnableUpdateFrontmatterTimeOnEdit = + isEnableUpdateFrontmatterTimeOnEdit; } parseFrontMatter(content: string): [FrontMatter, string] { @@ -111,7 +113,6 @@ export class FrontMatterConverter implements Converter { return join(result, body); } - } function convertImageFrontMatter( @@ -132,16 +133,26 @@ function convertImageFrontMatter( if (match) { frontMatter.image = `${match[1]}.${match[2]}`; } - frontMatter.image = convertImagePath(fileName, frontMatter.image, resourcePath); + frontMatter.image = convertImagePath( + fileName, + frontMatter.image, + resourcePath, + ); return frontMatter; } - -function convertImagePath(postTitle: string, imagePath: string, resourcePath: string): string { +function convertImagePath( + postTitle: string, + imagePath: string, + resourcePath: string, +): string { return `/${resourcePath}/${postTitle}/${imagePath}`; } -function replaceDateFrontMatter(frontMatter: FrontMatter, isEnable: boolean): FrontMatter { +function replaceDateFrontMatter( + frontMatter: FrontMatter, + isEnable: boolean, +): FrontMatter { if (!isEnable || frontMatter.updated === undefined) { return frontMatter; } @@ -172,8 +183,5 @@ export const convertFrontMatter = (input: string, authors?: string) => { frontMatter.authors = authors; } - return join( - convert({ ...frontMatter }), - body, - ); + return join(convert({ ...frontMatter }), body); }; diff --git a/src/ResourceLinkConverter.ts b/src/ResourceLinkConverter.ts index c0540d7f..c0f15d1f 100644 --- a/src/ResourceLinkConverter.ts +++ b/src/ResourceLinkConverter.ts @@ -35,11 +35,11 @@ export class ResourceLinkConverter implements Converter { if (!(resourceNames === undefined || resourceNames.length === 0)) { fs.mkdirSync(resourcePath, { recursive: true }); } - resourceNames?.forEach((resourceName) => { + resourceNames?.forEach(resourceName => { fs.copyFile( `${this.absolutePath}/${this.attachmentsFolder}/${resourceName}`, - `${resourcePath}/${(resourceName.replace(/\s/g, '-'))}`, - (err) => { + `${resourcePath}/${resourceName.replace(/\s/g, '-')}`, + err => { if (err) { // ignore error console.error(err); @@ -49,20 +49,24 @@ export class ResourceLinkConverter implements Converter { ); }); - const replacer = (match: string, - contents: string, - suffix: string, - width: string | undefined, - height: string | undefined, - space: string | undefined, - caption: string | undefined) => { + const replacer = ( + match: string, + contents: string, + suffix: string, + width: string | undefined, + height: string | undefined, + space: string | undefined, + caption: string | undefined, + ) => { const imagePath = `/${this.relativeResourcePath}/${sanitizedFileName}/${contents.replace(/\s/g, '-')}.${suffix}`; const imageUrl = this.liquidFilterOptions.useRelativeUrl ? `{{ "${imagePath}" | relative_url }}` : imagePath; - return `![image](${imageUrl})` - + `${convertImageSize(width, height)}` - + `${convertImageCaption(caption)}`; + return ( + `![image](${imageUrl})` + + `${convertImageSize(width, height)}` + + `${convertImageCaption(caption)}` + ); }; return input.replace(ObsidianRegex.ATTACHMENT_LINK, replacer); @@ -74,10 +78,15 @@ export function extractResourceNames(content: string) { if (result === null) { return undefined; } - return result.map((imageLink) => imageLink.replace(ObsidianRegex.ATTACHMENT_LINK, '$1.$2')); + return result.map(imageLink => + imageLink.replace(ObsidianRegex.ATTACHMENT_LINK, '$1.$2'), + ); } -function convertImageSize(width: string | undefined, height: string | undefined) { +function convertImageSize( + width: string | undefined, + height: string | undefined, +) { if (width === undefined || width.length === 0) { return ''; } diff --git a/src/WikiLinkConverter.ts b/src/WikiLinkConverter.ts index bf663c49..ed6e4482 100644 --- a/src/WikiLinkConverter.ts +++ b/src/WikiLinkConverter.ts @@ -3,12 +3,11 @@ import { Converter } from './core/Converter'; export class WikiLinkConverter implements Converter { convert(input: string): string { - return input.replace(ObsidianRegex.WIKI_LINK, (match, p1, p2) => (p2 ? p2 : p1)); + return input.replace(ObsidianRegex.WIKI_LINK, (match, p1, p2) => + p2 ? p2 : p1, + ); } } -export const convertWikiLink = - (input: string) => input.replace( - ObsidianRegex.WIKI_LINK, - (match, p1, p2) => (p2 ? p2 : p1), - ); +export const convertWikiLink = (input: string) => + input.replace(ObsidianRegex.WIKI_LINK, (match, p1, p2) => (p2 ? p2 : p1)); diff --git a/src/core/ConverterChain.ts b/src/core/ConverterChain.ts index 96bea690..da95b08d 100644 --- a/src/core/ConverterChain.ts +++ b/src/core/ConverterChain.ts @@ -3,8 +3,7 @@ import { Contents, Converter } from './Converter'; export class ConverterChain { private converters: Converter[] = []; - private constructor() { - } + private constructor() {} public static create(): ConverterChain { return new ConverterChain(); diff --git a/src/core/ObsidianRegex.ts b/src/core/ObsidianRegex.ts index 5c071f52..12e6a8d4 100644 --- a/src/core/ObsidianRegex.ts +++ b/src/core/ObsidianRegex.ts @@ -2,7 +2,7 @@ export const ObsidianRegex = { ATTACHMENT_LINK: /!\[\[([^|\]]+)\.(\w+)\|?(\d*)x?(\d*)]](\n{0,2}(_.*_))?/g, EMBEDDED_LINK: /!\[\[([\w\s-]+)[#^]*([\w\s]*)]]/g, WIKI_LINK: /(? \[!(.*)](.*)?\n(>.*)/ig, + CALLOUT: /> \[!(.*)](.*)?\n(>.*)/gi, SIMPLE_FOOTNOTE: /\[\^(\d+)]/g, COMMENT: /%%(.*?)%%/g, DOUBLE_CURLY_BRACES: /{{(.*?)}}/g, diff --git a/src/core/validation.ts b/src/core/validation.ts index bfa6ca09..04c4ea4b 100644 --- a/src/core/validation.ts +++ b/src/core/validation.ts @@ -3,32 +3,55 @@ import { Notice } from 'obsidian'; export default async (plugin: O2Plugin) => { const adapter = plugin.app.vault.adapter; - if (!await adapter.exists(plugin.obsidianPathSettings.attachmentsFolder)) { + if (!(await adapter.exists(plugin.obsidianPathSettings.attachmentsFolder))) { if (plugin.obsidianPathSettings.isAutoCreateFolder) { - new Notice(`Auto create attachments folder: ${plugin.obsidianPathSettings.attachmentsFolder}.`, 5000); + new Notice( + `Auto create attachments folder: ${plugin.obsidianPathSettings.attachmentsFolder}.`, + 5000, + ); await adapter.mkdir(plugin.obsidianPathSettings.attachmentsFolder); } else { - new Notice(`Attachments folder ${plugin.obsidianPathSettings.attachmentsFolder} does not exist.`, 5000); - throw new Error(`Attachments folder ${plugin.obsidianPathSettings.attachmentsFolder} does not exist.`); + new Notice( + `Attachments folder ${plugin.obsidianPathSettings.attachmentsFolder} does not exist.`, + 5000, + ); + throw new Error( + `Attachments folder ${plugin.obsidianPathSettings.attachmentsFolder} does not exist.`, + ); } } - if (!await adapter.exists(plugin.obsidianPathSettings.readyFolder)) { + if (!(await adapter.exists(plugin.obsidianPathSettings.readyFolder))) { if (plugin.obsidianPathSettings.isAutoCreateFolder) { - new Notice(`Auto create ready folder: ${plugin.obsidianPathSettings.readyFolder}.`, 5000); + new Notice( + `Auto create ready folder: ${plugin.obsidianPathSettings.readyFolder}.`, + 5000, + ); await adapter.mkdir(plugin.obsidianPathSettings.readyFolder); } else { - new Notice(`Ready folder ${plugin.obsidianPathSettings.readyFolder} does not exist.`, 5000); - throw new Error(`Ready folder ${plugin.obsidianPathSettings.readyFolder} does not exist.`); + new Notice( + `Ready folder ${plugin.obsidianPathSettings.readyFolder} does not exist.`, + 5000, + ); + throw new Error( + `Ready folder ${plugin.obsidianPathSettings.readyFolder} does not exist.`, + ); } } - if (!await adapter.exists(plugin.obsidianPathSettings.archiveFolder)) { + if (!(await adapter.exists(plugin.obsidianPathSettings.archiveFolder))) { if (plugin.obsidianPathSettings.isAutoCreateFolder) { - new Notice(`Auto create backup folder: ${plugin.obsidianPathSettings.archiveFolder}.`, 5000); + new Notice( + `Auto create backup folder: ${plugin.obsidianPathSettings.archiveFolder}.`, + 5000, + ); await adapter.mkdir(plugin.obsidianPathSettings.archiveFolder); } else { - new Notice(`Backup folder ${plugin.obsidianPathSettings.archiveFolder} does not exist.`, 5000); - throw new Error(`Backup folder ${plugin.obsidianPathSettings.archiveFolder} does not exist.`); + new Notice( + `Backup folder ${plugin.obsidianPathSettings.archiveFolder} does not exist.`, + 5000, + ); + throw new Error( + `Backup folder ${plugin.obsidianPathSettings.archiveFolder} does not exist.`, + ); } } }; - diff --git a/src/docusaurus/DateExtractionPattern.ts b/src/docusaurus/DateExtractionPattern.ts index a083e143..bb3d1672 100644 --- a/src/docusaurus/DateExtractionPattern.ts +++ b/src/docusaurus/DateExtractionPattern.ts @@ -8,7 +8,10 @@ * Nested folders + index.md: YYYY/MM/DD/my-blog-post-title/index.md * Date in the middle of path: category/YYYY/MM-DD-my-blog-post-title.md */ -export const DateExtractionPattern: Record = { +export const DateExtractionPattern: Record< + string, + DateExtractionPatternInterface +> = { // default pattern SINGLE: { pattern: 'YYYY-MM-DD-my-blog-post-title.md', diff --git a/src/docusaurus/docusaurus.ts b/src/docusaurus/docusaurus.ts index 78b438ed..d072dcca 100644 --- a/src/docusaurus/docusaurus.ts +++ b/src/docusaurus/docusaurus.ts @@ -1,5 +1,11 @@ import O2Plugin from '../main'; -import { copyMarkdownFile, getFilesInReady, moveFiles, parseLocalDate, vaultAbsolutePath } from '../utils'; +import { + copyMarkdownFile, + getFilesInReady, + moveFiles, + parseLocalDate, + vaultAbsolutePath, +} from '../utils'; import { Contents } from '../core/Converter'; import { convertWikiLink } from '../WikiLinkConverter'; import { convertFootnotes } from '../FootnotesConverter'; @@ -11,30 +17,24 @@ import { convertFrontMatter } from '../FrontMatterConverter'; const markPublished = async (plugin: O2Plugin) => { const filesInReady = getFilesInReady(plugin); for (const file of filesInReady) { - await plugin.app.fileManager.processFrontMatter( - file, - fm => { - if (fm.published) { - return fm; - } - fm.published = new Date().toISOString().split('T')[0]; + await plugin.app.fileManager.processFrontMatter(file, fm => { + if (fm.published) { return fm; - }, - ); + } + fm.published = new Date().toISOString().split('T')[0]; + return fm; + }); } }; const checkPublished = async (plugin: O2Plugin, file: TFile) => { let publishedDate = new Date().toISOString().split('T')[0]; - await plugin.app.fileManager.processFrontMatter( - file, - fm => { - if (fm.published) { - publishedDate = fm.published; - return fm; - } - }, - ); + await plugin.app.fileManager.processFrontMatter(file, fm => { + if (fm.published) { + publishedDate = fm.published; + return fm; + } + }); return publishedDate; }; @@ -46,24 +46,19 @@ export const convertToDocusaurus = async (plugin: O2Plugin) => { const publishedDate = await checkPublished(plugin, file); const contents: Contents = await plugin.app.vault.read(file); - const result = - convertComments( - convertDocusaurusCallout( - convertFootnotes( - convertWikiLink( - convertFrontMatter( - contents, - plugin.docusaurus.authors, - ), - ), + const result = convertComments( + convertDocusaurusCallout( + convertFootnotes( + convertWikiLink( + convertFrontMatter(contents, plugin.docusaurus.authors), ), ), - ); + ), + ); - await plugin.app.vault.modify(file, result) - .then(() => { - new Notice('Converted to Docusaurus successfully.', 5000); - }); + await plugin.app.vault.modify(file, result).then(() => { + new Notice('Converted to Docusaurus successfully.', 5000); + }); // move files to docusaurus folder await moveFiles( @@ -71,8 +66,7 @@ export const convertToDocusaurus = async (plugin: O2Plugin) => { plugin.docusaurus.targetPath(), plugin.docusaurus.pathReplacer, parseLocalDate(publishedDate), - ) - .then(async () => await markPublished(plugin)); + ).then(async () => await markPublished(plugin)); } new Notice('Moved files to Docusaurus successfully.', 5000); diff --git a/src/docusaurus/settings/DocusaurusSettings.ts b/src/docusaurus/settings/DocusaurusSettings.ts index dec4b76f..4f420ab8 100644 --- a/src/docusaurus/settings/DocusaurusSettings.ts +++ b/src/docusaurus/settings/DocusaurusSettings.ts @@ -15,10 +15,17 @@ export default class DocusaurusSettings implements O2PluginSettings { } afterPropertiesSet(): boolean { - return this.docusaurusPath !== undefined && this.docusaurusPath.length !== 0; + return ( + this.docusaurusPath !== undefined && this.docusaurusPath.length !== 0 + ); } - pathReplacer = (year: string, month: string, day: string, title: string): string => { + pathReplacer = ( + year: string, + month: string, + day: string, + title: string, + ): string => { const patternInterface = DateExtractionPattern[this.dateExtractionPattern]; return patternInterface.replacer(year, month, day, title); }; diff --git a/src/jekyll/chirpy.ts b/src/jekyll/chirpy.ts index 6d70fdfb..2325f49a 100644 --- a/src/jekyll/chirpy.ts +++ b/src/jekyll/chirpy.ts @@ -56,8 +56,7 @@ export async function convertToChirpy(plugin: O2Plugin) { `${vaultAbsolutePath(plugin)}/${plugin.obsidianPathSettings.readyFolder}`, settings.targetPath(), settings.pathReplacer, - ) - .then(() => new Notice('Moved files to Chirpy successfully.', 5000)); + ).then(() => new Notice('Moved files to Chirpy successfully.', 5000)); } } catch (e) { console.error(e); diff --git a/src/jekyll/settings/JekyllSettings.ts b/src/jekyll/settings/JekyllSettings.ts index 07691df4..2bd4e3e7 100644 --- a/src/jekyll/settings/JekyllSettings.ts +++ b/src/jekyll/settings/JekyllSettings.ts @@ -3,7 +3,12 @@ import { O2PluginSettings } from '../../settings'; export default class JekyllSettings implements O2PluginSettings { private _jekyllPath: string; private _jekyllRelativeResourcePath: string; - pathReplacer(year: string, month: string, day: string, title: string): string { + pathReplacer( + year: string, + month: string, + day: string, + title: string, + ): string { return `${year}-${month}-${day}-${title}.md`; } diff --git a/src/main.ts b/src/main.ts index 179c404f..f1ac9a25 100644 --- a/src/main.ts +++ b/src/main.ts @@ -19,7 +19,10 @@ export default class O2Plugin extends Plugin { id: 'grammar-transformation', name: 'Grammar Transformation', checkCallback: (checking: boolean) => { - if (this.jekyll.afterPropertiesSet() || this.docusaurus.afterPropertiesSet()) { + if ( + this.jekyll.afterPropertiesSet() || + this.docusaurus.afterPropertiesSet() + ) { if (checking) { return true; } @@ -37,14 +40,18 @@ export default class O2Plugin extends Plugin { this.addSettingTab(new O2SettingTab(this.app, this)); } - onunload() { - - } + onunload() {} async loadSettings() { - this.obsidianPathSettings = Object.assign(new ObsidianPathSettings(), await this.loadData()); + this.obsidianPathSettings = Object.assign( + new ObsidianPathSettings(), + await this.loadData(), + ); this.jekyll = Object.assign(new JekyllSettings(), await this.loadData()); - this.docusaurus = Object.assign(new DocusaurusSettings(), await this.loadData()); + this.docusaurus = Object.assign( + new DocusaurusSettings(), + await this.loadData(), + ); } async saveSettings() { @@ -59,12 +66,10 @@ export default class O2Plugin extends Plugin { const o2ConversionCommand = async (plugin: O2Plugin) => { await validateSettings(plugin); if (plugin.jekyll.afterPropertiesSet()) { - await convertToChirpy(plugin) - .finally(() => cleanUp(plugin)); + await convertToChirpy(plugin).finally(() => cleanUp(plugin)); } if (plugin.docusaurus.afterPropertiesSet()) { - await convertToDocusaurus(plugin) - .finally(() => cleanUp(plugin)); + await convertToDocusaurus(plugin).finally(() => cleanUp(plugin)); } }; diff --git a/src/settings.ts b/src/settings.ts index e26dd54f..ecbf90b8 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -76,39 +76,49 @@ export class O2SettingTab extends PluginSettingTab { const docusaurus = this.plugin.docusaurus as DocusaurusSettings; new Setting(this.containerEl) .setName('Docusaurus authors') - .setDesc('Author(s) for Docusaurus front matter. For multiple authors, separate with commas.') - .addText(text => text - .setPlaceholder('jmarcey, slorber') - .setValue(docusaurus.authors) - .onChange(async (value) => { - docusaurus.authors = value; - await this.plugin.saveSettings(); - })); + .setDesc( + 'Author(s) for Docusaurus front matter. For multiple authors, separate with commas.', + ) + .addText(text => + text + .setPlaceholder('jmarcey, slorber') + .setValue(docusaurus.authors) + .onChange(async value => { + docusaurus.authors = value; + await this.plugin.saveSettings(); + }), + ); } private enableUpdateFrontmatterTimeOnEditSetting() { const jekyllSetting = this.plugin.jekyll as JekyllSettings; new Setting(this.containerEl) .setName('Replace date frontmatter to updated time') - .setDesc('If \'updated\' frontmatter exists, replace the value of \'date\' frontmatter with the value of \'updated\' frontmatter.') - .addToggle(toggle => toggle - .setValue(jekyllSetting.isEnableUpdateFrontmatterTimeOnEdit) - .onChange(async (value) => { - jekyllSetting.isEnableUpdateFrontmatterTimeOnEdit = value; - await this.plugin.saveSettings(); - })); + .setDesc( + "If 'updated' frontmatter exists, replace the value of 'date' frontmatter with the value of 'updated' frontmatter.", + ) + .addToggle(toggle => + toggle + .setValue(jekyllSetting.isEnableUpdateFrontmatterTimeOnEdit) + .onChange(async value => { + jekyllSetting.isEnableUpdateFrontmatterTimeOnEdit = value; + await this.plugin.saveSettings(); + }), + ); } private enableAutoCreateFolderSetting() { new Setting(this.containerEl) .setName('Auto create folders') .setDesc('Automatically create necessary folders if they do not exist.') - .addToggle(toggle => toggle - .setValue(this.plugin.obsidianPathSettings.isAutoCreateFolder) - .onChange(async (value) => { - this.plugin.obsidianPathSettings.isAutoCreateFolder = value; - await this.plugin.saveSettings(); - })); + .addToggle(toggle => + toggle + .setValue(this.plugin.obsidianPathSettings.isAutoCreateFolder) + .onChange(async value => { + this.plugin.obsidianPathSettings.isAutoCreateFolder = value; + await this.plugin.saveSettings(); + }), + ); } private enableCurlyBraceSetting() { @@ -116,12 +126,14 @@ export class O2SettingTab extends PluginSettingTab { new Setting(this.containerEl) .setName('Curly Brace Conversion') .setDesc('Convert double curly braces to jekyll raw tag.') - .addToggle(toggle => toggle - .setValue(jekyllSetting.isEnableCurlyBraceConvertMode) - .onChange(async (value) => { - jekyllSetting.isEnableCurlyBraceConvertMode = value; - await this.plugin.saveSettings(); - })); + .addToggle(toggle => + toggle + .setValue(jekyllSetting.isEnableCurlyBraceConvertMode) + .onChange(async value => { + jekyllSetting.isEnableCurlyBraceConvertMode = value; + await this.plugin.saveSettings(); + }), + ); } private addJekyllPathSetting() { @@ -129,66 +141,78 @@ export class O2SettingTab extends PluginSettingTab { new Setting(this.containerEl) .setName('Jekyll path') .setDesc('The absolute path where Jekyll workspace is located.') - .addText(text => text - .setPlaceholder('Enter path') - .setValue(jekyllSetting.jekyllPath) - .onChange(async (value) => { - jekyllSetting.jekyllPath = value; - await this.plugin.saveSettings(); - })); + .addText(text => + text + .setPlaceholder('Enter path') + .setValue(jekyllSetting.jekyllPath) + .onChange(async value => { + jekyllSetting.jekyllPath = value; + await this.plugin.saveSettings(); + }), + ); } private addJekyllRelativeResourcePathSetting() { const jekyllSetting = this.plugin.jekyll as JekyllSettings; new Setting(this.containerEl) .setName('Relative resource path') - .setDesc('The relative path where resources are stored. (default: assets/img)') - .addText(text => text - .setPlaceholder('Enter path') - .setValue(jekyllSetting.jekyllRelativeResourcePath) - .onChange(async (value) => { - jekyllSetting.jekyllRelativeResourcePath = value; - await this.plugin.saveSettings(); - })); + .setDesc( + 'The relative path where resources are stored. (default: assets/img)', + ) + .addText(text => + text + .setPlaceholder('Enter path') + .setValue(jekyllSetting.jekyllRelativeResourcePath) + .onChange(async value => { + jekyllSetting.jekyllRelativeResourcePath = value; + await this.plugin.saveSettings(); + }), + ); } private addAttachmentsFolderSetting() { new Setting(this.containerEl) .setName('Folder to store attachments in') .setDesc('Where the attachments will be stored.') - .addText(text => text - .setPlaceholder('Enter folder name') - .setValue(this.plugin.obsidianPathSettings.attachmentsFolder) - .onChange(async (value) => { - this.plugin.obsidianPathSettings.attachmentsFolder = value; - await this.plugin.saveSettings(); - })); + .addText(text => + text + .setPlaceholder('Enter folder name') + .setValue(this.plugin.obsidianPathSettings.attachmentsFolder) + .onChange(async value => { + this.plugin.obsidianPathSettings.attachmentsFolder = value; + await this.plugin.saveSettings(); + }), + ); } private addReadyFolderSetting() { new Setting(this.containerEl) .setName('Folder to convert notes to another syntax in') .setDesc('Where the notes will be converted to another syntax.') - .addText(text => text - .setPlaceholder('Enter folder name') - .setValue(this.plugin.obsidianPathSettings.readyFolder) - .onChange(async (value) => { - this.plugin.obsidianPathSettings.readyFolder = value; - await this.plugin.saveSettings(); - })); + .addText(text => + text + .setPlaceholder('Enter folder name') + .setValue(this.plugin.obsidianPathSettings.readyFolder) + .onChange(async value => { + this.plugin.obsidianPathSettings.readyFolder = value; + await this.plugin.saveSettings(); + }), + ); } private addArchiveFolderSetting() { new Setting(this.containerEl) .setName('Folder to Archive notes in') .setDesc('Where the notes will be archived after conversion.') - .addText(text => text - .setPlaceholder('Enter folder name') - .setValue(this.plugin.obsidianPathSettings.archiveFolder) - .onChange(async (value) => { - this.plugin.obsidianPathSettings.archiveFolder = value; - await this.plugin.saveSettings(); - })); + .addText(text => + text + .setPlaceholder('Enter folder name') + .setValue(this.plugin.obsidianPathSettings.archiveFolder) + .onChange(async value => { + this.plugin.obsidianPathSettings.archiveFolder = value; + await this.plugin.saveSettings(); + }), + ); } private addDocusaurusPathSetting() { @@ -196,13 +220,15 @@ export class O2SettingTab extends PluginSettingTab { new Setting(this.containerEl) .setName('Docusaurus path') .setDesc('The absolute path where Docusaurus workspace is located.') - .addText(text => text - .setPlaceholder('Enter path') - .setValue(docusaurus.docusaurusPath) - .onChange(async (value) => { - docusaurus.docusaurusPath = value; - await this.plugin.saveSettings(); - })); + .addText(text => + text + .setPlaceholder('Enter path') + .setValue(docusaurus.docusaurusPath) + .onChange(async value => { + docusaurus.docusaurusPath = value; + await this.plugin.saveSettings(); + }), + ); } private dateExtractionPatternSetting() { @@ -215,7 +241,7 @@ export class O2SettingTab extends PluginSettingTab { dropdown.addOption(key, DateExtractionPattern[key].pattern); } dropdown.setValue(docusaurus.dateExtractionPattern); - dropdown.onChange(async (value) => { + dropdown.onChange(async value => { docusaurus.dateExtractionPattern = value; await this.plugin.saveSettings(); }); @@ -226,24 +252,30 @@ export class O2SettingTab extends PluginSettingTab { new Setting(this.containerEl) .setName('Auto archive') .setDesc('Automatically move files to archive folder after converting.') - .addToggle(toggle => toggle - .setValue(this.plugin.obsidianPathSettings.isAutoArchive) - .onChange(async (value) => { - this.plugin.obsidianPathSettings.isAutoArchive = value; - await this.plugin.saveSettings(); - })); + .addToggle(toggle => + toggle + .setValue(this.plugin.obsidianPathSettings.isAutoArchive) + .onChange(async value => { + this.plugin.obsidianPathSettings.isAutoArchive = value; + await this.plugin.saveSettings(); + }), + ); } private addJekyllRelativeUrlSetting() { const jekyllSetting = this.plugin.jekyll as JekyllSettings; new Setting(this.containerEl) .setName('Enable relative URL for images') - .setDesc('Use Jekyll\'s relative_url filter for image paths. Required when using baseurl.') - .addToggle(toggle => toggle - .setValue(jekyllSetting.isEnableRelativeUrl) - .onChange(async (value) => { - jekyllSetting.isEnableRelativeUrl = value; - await this.plugin.saveSettings(); - })); + .setDesc( + "Use Jekyll's relative_url filter for image paths. Required when using baseurl.", + ) + .addToggle(toggle => + toggle + .setValue(jekyllSetting.isEnableRelativeUrl) + .onChange(async value => { + jekyllSetting.isEnableRelativeUrl = value; + await this.plugin.saveSettings(); + }), + ); } } diff --git a/src/tests/CalloutConverter.test.ts b/src/tests/CalloutConverter.test.ts index 9879216c..d06f322c 100644 --- a/src/tests/CalloutConverter.test.ts +++ b/src/tests/CalloutConverter.test.ts @@ -1,12 +1,28 @@ -import { CalloutConverter, convertDocusaurusCallout } from '../CalloutConverter'; +import { + CalloutConverter, + convertDocusaurusCallout, +} from '../CalloutConverter'; const calloutConverter = new CalloutConverter(); describe('Jekyll: convert callout syntax', () => { - it.each([ - ['note'], ['todo'], ['example'], ['quote'], ['cite'], ['success'], ['done'], ['check'], - ['NOTE'], ['TODO'], ['EXAMPLE'], ['QUOTE'], ['CITE'], ['SUCCESS'], ['DONE'], ['CHECK'], + ['note'], + ['todo'], + ['example'], + ['quote'], + ['cite'], + ['success'], + ['done'], + ['check'], + ['NOTE'], + ['TODO'], + ['EXAMPLE'], + ['QUOTE'], + ['CITE'], + ['SUCCESS'], + ['DONE'], + ['CHECK'], ])('%s => info', callout => { const context = `> [!${callout}] title\n> content`; @@ -15,8 +31,18 @@ describe('Jekyll: convert callout syntax', () => { }); it.each([ - ['tip'], ['hint'], ['important'], ['question'], ['help'], ['faq'], - ['TIP'], ['HINT'], ['IMPORTANT'], ['QUESTION'], ['HELP'], ['FAQ'], + ['tip'], + ['hint'], + ['important'], + ['question'], + ['help'], + ['faq'], + ['TIP'], + ['HINT'], + ['IMPORTANT'], + ['QUESTION'], + ['HELP'], + ['FAQ'], ])('%s => tip', callout => { const context = `> [!${callout}] title\n> content`; @@ -25,8 +51,12 @@ describe('Jekyll: convert callout syntax', () => { }); it.each([ - ['warning'], ['caution'], ['attention'], - ['WARNING'], ['CAUTION'], ['ATTENTION'], + ['warning'], + ['caution'], + ['attention'], + ['WARNING'], + ['CAUTION'], + ['ATTENTION'], ])('%s => warning', callout => { const context = `> [!${callout}] title\n> content`; @@ -34,14 +64,15 @@ describe('Jekyll: convert callout syntax', () => { expect(result).toBe(`> content\n{: .prompt-warning}`); }); - it.each([ - ['unknown'], - ])('Unregistered keywords should be converted to info keyword', callout => { - const context = `> [!${callout}] title\n> content`; + it.each([['unknown']])( + 'Unregistered keywords should be converted to info keyword', + callout => { + const context = `> [!${callout}] title\n> content`; - const result = calloutConverter.convert(context); - expect(result).toBe(`> content\n{: .prompt-info}`); - }); + const result = calloutConverter.convert(context); + expect(result).toBe(`> content\n{: .prompt-info}`); + }, + ); it('info => info, not exist custom title', () => { const context = `> [!INFO]\n> info content`; @@ -55,13 +86,24 @@ describe('Jekyll: convert callout syntax', () => { const result = calloutConverter.convert(context); expect(result).toBe(`> content\n{: .prompt-tip}`); }); - }); describe('Docusaurus: convert callout syntax', () => { it.each([ - ['todo'], ['example'], ['quote'], ['cite'], ['success'], ['done'], ['check'], - ['TODO'], ['EXAMPLE'], ['QUOTE'], ['CITE'], ['SUCCESS'], ['DONE'], ['CHECK'], + ['todo'], + ['example'], + ['quote'], + ['cite'], + ['success'], + ['done'], + ['check'], + ['TODO'], + ['EXAMPLE'], + ['QUOTE'], + ['CITE'], + ['SUCCESS'], + ['DONE'], + ['CHECK'], ])('%s => info', callout => { const context = `> [!${callout}] This is Title!\n> content`; @@ -69,10 +111,7 @@ describe('Docusaurus: convert callout syntax', () => { expect(result).toBe(`:::note[This is Title!]\n\ncontent\n\n:::`); }); - it.each([ - ['note'], - ['NOTE'], - ])('%s => note', callout => { + it.each([['note'], ['NOTE']])('%s => note', callout => { const context = `> [!${callout}] This is Title!\n> content`; const result = convertDocusaurusCallout(context); @@ -80,8 +119,16 @@ describe('Docusaurus: convert callout syntax', () => { }); it.each([ - ['tip'], ['hint'], ['important'], ['question'], ['help'], - ['TIP'], ['HINT'], ['IMPORTANT'], ['QUESTION'], ['HELP'], + ['tip'], + ['hint'], + ['important'], + ['question'], + ['help'], + ['TIP'], + ['HINT'], + ['IMPORTANT'], + ['QUESTION'], + ['HELP'], ])('%s => tip', callout => { const context = `> [!${callout}] This is Title!\n> content`; @@ -90,8 +137,12 @@ describe('Docusaurus: convert callout syntax', () => { }); it.each([ - ['warning'], ['caution'], ['attention'], - ['WARNING'], ['CAUTION'], ['ATTENTION'], + ['warning'], + ['caution'], + ['attention'], + ['WARNING'], + ['CAUTION'], + ['ATTENTION'], ])('%s => warning', callout => { const context = `> [!${callout}] This is Title!\n> content`; @@ -116,8 +167,18 @@ describe('Docusaurus: convert callout syntax', () => { describe('danger callout', () => { const dangerKeyword = [ - ['error'], ['danger'], ['bug'], ['failure'], ['fail'], ['missing'], - ['ERROR'], ['DANGER'], ['BUG'], ['FAILURE'], ['FAIL'], ['MISSING'], + ['error'], + ['danger'], + ['bug'], + ['failure'], + ['fail'], + ['missing'], + ['ERROR'], + ['DANGER'], + ['BUG'], + ['FAILURE'], + ['FAIL'], + ['MISSING'], ]; it.each(dangerKeyword)('%s => danger', callout => { diff --git a/src/tests/ConverterChain.test.ts b/src/tests/ConverterChain.test.ts index 9a96d615..c75dbea4 100644 --- a/src/tests/ConverterChain.test.ts +++ b/src/tests/ConverterChain.test.ts @@ -42,5 +42,4 @@ describe('ConverterChain', () => { .chaining(new TestRepeatConverter()); expect(chain.converting('test')).toEqual('TESTTEST'); }); - }); diff --git a/src/tests/DateExtractionPattern.test.ts b/src/tests/DateExtractionPattern.test.ts index 4cf1f304..bfd50b6a 100644 --- a/src/tests/DateExtractionPattern.test.ts +++ b/src/tests/DateExtractionPattern.test.ts @@ -17,7 +17,9 @@ describe('SINGLE', () => { it('should replace YYYY-MM-DD-my-blog-post-title.md', () => { const replacer = DateExtractionPattern['SINGLE'].replacer; - expect(replacer('2021', '02', '01', 'my-blog-post-title')).toBe('2021-02-01-my-blog-post-title.md'); + expect(replacer('2021', '02', '01', 'my-blog-post-title')).toBe( + '2021-02-01-my-blog-post-title.md', + ); }); }); @@ -29,7 +31,9 @@ describe('MDX', () => { it('should replace YYYY-MM-DD-my-blog-post-title.mdx', () => { const replacer = DateExtractionPattern['MDX'].replacer; - expect(replacer('2021', '02', '01', 'my-blog-post-title')).toBe('2021-02-01-my-blog-post-title.mdx'); + expect(replacer('2021', '02', '01', 'my-blog-post-title')).toBe( + '2021-02-01-my-blog-post-title.mdx', + ); }); }); @@ -41,7 +45,9 @@ describe('SINGLE_FOLDER_INDEX', () => { it('should replace YYYY-MM-DD-my-blog-post-title/index.md', () => { const replacer = DateExtractionPattern['SINGLE_FOLDER_INDEX'].replacer; - expect(replacer('2021', '02', '01', 'my-blog-post-title')).toBe('2021-02-01-my-blog-post-title/index.md'); + expect(replacer('2021', '02', '01', 'my-blog-post-title')).toBe( + '2021-02-01-my-blog-post-title/index.md', + ); }); }); @@ -53,7 +59,9 @@ describe('FOLDER_NAMED_BY_DATE', () => { it('should replace YYYY-MM-DD/my-blog-post-title.md', () => { const replacer = DateExtractionPattern['FOLDER_NAMED_BY_DATE'].replacer; - expect(replacer('2021', '02', '01', 'my-blog-post-title')).toBe('2021-02-01/my-blog-post-title.md'); + expect(replacer('2021', '02', '01', 'my-blog-post-title')).toBe( + '2021-02-01/my-blog-post-title.md', + ); }); }); @@ -65,19 +73,25 @@ describe('NESTED_FOLDERS_BY_DATE', () => { it('should replace YYYY/MM/DD/my-blog-post-title.md', () => { const replacer = DateExtractionPattern['NESTED_FOLDERS_BY_DATE'].replacer; - expect(replacer('2021', '02', '01', 'my-blog-post-title')).toBe('2021/02/01/my-blog-post-title.md'); + expect(replacer('2021', '02', '01', 'my-blog-post-title')).toBe( + '2021/02/01/my-blog-post-title.md', + ); }); }); describe('PARTIALLY_NESTED_FOLDERS_BY_DATE', () => { it('should match YYYY/MM-DD/my-blog-post-title.md', () => { - const regex = DateExtractionPattern['PARTIALLY_NESTED_FOLDERS_BY_DATE'].regexp; + const regex = + DateExtractionPattern['PARTIALLY_NESTED_FOLDERS_BY_DATE'].regexp; expect('o2-temp.2021/02-01/my-blog-post-title.md').toMatch(regex); }); it('should replace YYYY/MM-DD/my-blog-post-title.md', () => { - const replacer = DateExtractionPattern['PARTIALLY_NESTED_FOLDERS_BY_DATE'].replacer; - expect(replacer('2021', '02', '01', 'my-blog-post-title')).toBe('2021/02-01/my-blog-post-title.md'); + const replacer = + DateExtractionPattern['PARTIALLY_NESTED_FOLDERS_BY_DATE'].replacer; + expect(replacer('2021', '02', '01', 'my-blog-post-title')).toBe( + '2021/02-01/my-blog-post-title.md', + ); }); }); @@ -89,7 +103,9 @@ describe('NESTED_FOLDERS_INDEX', () => { it('should replace YYYY/MM/DD/my-blog-post-title/index.md', () => { const replacer = DateExtractionPattern['NESTED_FOLDERS_INDEX'].replacer; - expect(replacer('2021', '02', '01', 'my-blog-post-title')).toBe('2021/02/01/my-blog-post-title/index.md'); + expect(replacer('2021', '02', '01', 'my-blog-post-title')).toBe( + '2021/02/01/my-blog-post-title/index.md', + ); }); }); @@ -101,6 +117,8 @@ describe('DATE_IN_MIDDLE_OF_PATH', () => { it('should replace category/YYYY/MM-DD-my-blog-post-title.md', () => { const replacer = DateExtractionPattern['DATE_IN_MIDDLE_OF_PATH'].replacer; - expect(replacer('2021', '02', '01', 'my-blog-post-title')).toBe('category/2021/02-01-my-blog-post-title.md'); + expect(replacer('2021', '02', '01', 'my-blog-post-title')).toBe( + 'category/2021/02-01-my-blog-post-title.md', + ); }); }); diff --git a/src/tests/EmbedsConverter.test.ts b/src/tests/EmbedsConverter.test.ts index c90d82f2..14ebb4d0 100644 --- a/src/tests/EmbedsConverter.test.ts +++ b/src/tests/EmbedsConverter.test.ts @@ -3,14 +3,15 @@ import { EmbedsConverter } from '../EmbedsConverter'; const converter = new EmbedsConverter(); describe('convert called', () => { - it.each([ ['![[test]]', 'test'], ['![[Obsidian#What is Obsidian]]', 'Obsidian'], ['![[Obsidian#^asdf1234]]', 'Obsidian'], ['![[Obsidian#What is Obsidian]]', 'Obsidian'], - ])('should remove brackets if does not exist extension keyword', (input, expected) => { - expect(converter.convert(input)).toEqual(expected); - }); - + ])( + 'should remove brackets if does not exist extension keyword', + (input, expected) => { + expect(converter.convert(input)).toEqual(expected); + }, + ); }); diff --git a/src/tests/FrontMatterConverter.test.ts b/src/tests/FrontMatterConverter.test.ts index 58eb957c..3f0926cf 100644 --- a/src/tests/FrontMatterConverter.test.ts +++ b/src/tests/FrontMatterConverter.test.ts @@ -1,7 +1,18 @@ -import { convertFrontMatter, FrontMatterConverter } from '../FrontMatterConverter'; - -const frontMatterConverter = new FrontMatterConverter('2023-01-01-test-title', 'assets/img', true); -const disableImageConverter = new FrontMatterConverter('2023-01-01-test-title', 'assets/img', false); +import { + convertFrontMatter, + FrontMatterConverter, +} from '../FrontMatterConverter'; + +const frontMatterConverter = new FrontMatterConverter( + '2023-01-01-test-title', + 'assets/img', + true, +); +const disableImageConverter = new FrontMatterConverter( + '2023-01-01-test-title', + 'assets/img', + false, +); describe('convert front matter', () => { const contents = `--- title: "test" @@ -35,22 +46,23 @@ image: /assets/img/2023-01-01-test-title/test.png --- # test -`, - ); +`); }); describe('when isEnable option is false', () => { - const frontMatterConverter = new FrontMatterConverter('2023-01-01-test-title', 'assets/img', false); + const frontMatterConverter = new FrontMatterConverter( + '2023-01-01-test-title', + 'assets/img', + false, + ); it('should Nothing', () => { const result = frontMatterConverter.convert(contents); expect(result).toEqual(contents); }); }); - }); describe('mermaid front matter', () => { - it('should create mermaid key value if body contains mermaid block', () => { const contents = `--- title: "test" @@ -77,8 +89,7 @@ graph TD A-->B \`\`\` -`, - ); +`); }); it('should not create mermaid key value if body does not contain mermaid block', () => { @@ -96,8 +107,7 @@ title: "test" # test -`, - ); +`); }); it('should not create mermaid key value if body contains mermaid block but front matter already has mermaid key', () => { @@ -125,12 +135,10 @@ mermaid: true graph TD A-->B \`\`\` -`, - ); +`); }); }); - describe('if does not exist front matter', () => { const contents = `# test image: test.png @@ -162,8 +170,7 @@ image: /assets/img/2023-01-01-test-title/test.png # test --- -`, - ); +`); }); describe('when end of front matter is not exist', () => { @@ -181,7 +188,12 @@ image: test.png }); describe('updated front matter', () => { - const updatedConverter = new FrontMatterConverter('2023-01-01-test-title', 'assets/img', true, true); + const updatedConverter = new FrontMatterConverter( + '2023-01-01-test-title', + 'assets/img', + true, + true, + ); it('should be converted', () => { const contents = `--- title: "test" @@ -198,8 +210,7 @@ date: 2022-01-02 12:00:00 +0900 --- # test -`, - ); +`); }); it('should be not converted', () => { @@ -217,14 +228,11 @@ date: 2021-01-01 12:00:00 +0900 --- # test -`, - ); +`); }); - }); describe('tags', () => { - const expected = `--- title: "test" date: 2021-01-01 12:00:00 +0900 @@ -270,7 +278,7 @@ tags: test1, test2 describe('convertFrontMatter', () => { it('should passthroughs', () => { - const mockContents = `--- + const mockContents = `--- title: "test" date: 2021-01-01 12:00:00 +0900 categories: [test] @@ -278,10 +286,9 @@ categories: [test] # test `; - const result = convertFrontMatter(mockContents); - expect(result).toEqual(mockContents); - }, - ); + const result = convertFrontMatter(mockContents); + expect(result).toEqual(mockContents); + }); it('should converted tags', () => { const contents = `--- diff --git a/src/tests/ResourceLinkConverter.test.ts b/src/tests/ResourceLinkConverter.test.ts index d03d807e..2a02e85c 100644 --- a/src/tests/ResourceLinkConverter.test.ts +++ b/src/tests/ResourceLinkConverter.test.ts @@ -1,4 +1,7 @@ -import { extractResourceNames, ResourceLinkConverter } from '../ResourceLinkConverter'; +import { + extractResourceNames, + ResourceLinkConverter, +} from '../ResourceLinkConverter'; jest.mock('obsidian', () => ({}), { virtual: true }); jest.mock('fs', () => ({ @@ -7,7 +10,6 @@ jest.mock('fs', () => ({ })); describe('extract image name', () => { - it('should return image name array', () => { const context = `![[test.png]] @@ -23,7 +25,6 @@ describe('extract image name', () => { const result = extractResourceNames(context); expect(result).toBeUndefined(); }); - }); describe('convert called', () => { @@ -36,9 +37,10 @@ describe('convert called', () => { ); it('should return converted post', () => { - expect(converter.convert(`![[test.png]]`)).toEqual(`![image](/assets/2023-01-01-post-mock/test.png)`); + expect(converter.convert(`![[test.png]]`)).toEqual( + `![image](/assets/2023-01-01-post-mock/test.png)`, + ); }); - }); describe('resize image', () => { @@ -51,19 +53,22 @@ describe('resize image', () => { ); it('should return converted attachments with width', () => { - expect(converter.convert(`![[test.png|100]]`)).toEqual(`![image](/assets/2023-01-01-post-mock/test.png){: width="100" }`); + expect(converter.convert(`![[test.png|100]]`)).toEqual( + `![image](/assets/2023-01-01-post-mock/test.png){: width="100" }`, + ); }); it('should return converted attachments with width and height', () => { - expect(converter.convert(`![[test.png|100x200]]`)) - .toEqual(`![image](/assets/2023-01-01-post-mock/test.png){: width="100" height="200" }`); + expect(converter.convert(`![[test.png|100x200]]`)).toEqual( + `![image](/assets/2023-01-01-post-mock/test.png){: width="100" height="200" }`, + ); }); it('should ignore size when image resize syntax was invalid', () => { - expect(converter.convert(`![[test.png|x100]]`)) - .toEqual(`![image](/assets/2023-01-01-post-mock/test.png)`); + expect(converter.convert(`![[test.png|x100]]`)).toEqual( + `![image](/assets/2023-01-01-post-mock/test.png)`, + ); }); - }); describe('image caption', () => { @@ -130,7 +135,6 @@ _This is a test image._ `); }); - }); describe('liquid filter with relative_url', () => { @@ -146,18 +150,24 @@ describe('liquid filter with relative_url', () => { it('should wrap image path with relative_url filter', () => { const context = `![[test.png]]`; const result = converter.convert(context); - expect(result).toEqual(`![image]({{ "/assets/2023-01-01-post-mock/test.png" | relative_url }})`); + expect(result).toEqual( + `![image]({{ "/assets/2023-01-01-post-mock/test.png" | relative_url }})`, + ); }); it('should handle images with size specifications', () => { const context = `![[test.png|100x200]]`; const result = converter.convert(context); - expect(result).toEqual(`![image]({{ "/assets/2023-01-01-post-mock/test.png" | relative_url }}){: width="100" height="200" }`); + expect(result).toEqual( + `![image]({{ "/assets/2023-01-01-post-mock/test.png" | relative_url }}){: width="100" height="200" }`, + ); }); it('should handle images with captions', () => { const context = `![[test.png]]\n_Image caption_`; const result = converter.convert(context); - expect(result).toEqual(`![image]({{ "/assets/2023-01-01-post-mock/test.png" | relative_url }})\n_Image caption_`); + expect(result).toEqual( + `![image]({{ "/assets/2023-01-01-post-mock/test.png" | relative_url }})\n_Image caption_`, + ); }); }); diff --git a/src/tests/WikiLinkConverter.test.ts b/src/tests/WikiLinkConverter.test.ts index 9f940e9e..9e42f4b4 100644 --- a/src/tests/WikiLinkConverter.test.ts +++ b/src/tests/WikiLinkConverter.test.ts @@ -52,7 +52,6 @@ describe('WikiLinkConverter', () => { `); }); - it('should not match if string starts with !', () => { const input = '![[tests]]'; const result = converter.convert(input); diff --git a/src/utils.ts b/src/utils.ts index ebb05b7e..9ab4b109 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -26,21 +26,24 @@ export const copyMarkdownFile = async (plugin: O2Plugin): Promise => { .replace(/,+/g, '') .replace(/\s/g, '-'); - await plugin.app.vault.copy(file, newPath) - .catch((error) => { - console.error(error); - new Notice('Failed to copy file, see console for more information.'); - }); + await plugin.app.vault.copy(file, newPath).catch(error => { + console.error(error); + new Notice('Failed to copy file, see console for more information.'); + }); } // collect copied files - return plugin.app.vault.getMarkdownFiles() + return plugin.app.vault + .getMarkdownFiles() .filter((file: TFile) => file.path.includes(TEMP_PREFIX)); }; export const getFilesInReady = (plugin: O2Plugin): TFile[] => - plugin.app.vault.getMarkdownFiles() - .filter((file: TFile) => file.path.startsWith(plugin.obsidianPathSettings.readyFolder)); + plugin.app.vault + .getMarkdownFiles() + .filter((file: TFile) => + file.path.startsWith(plugin.obsidianPathSettings.readyFolder), + ); const copyFile = (sourceFilePath: string, targetFilePath: string) => { // if directory not exist create it @@ -59,7 +62,7 @@ export const copy = ( ) => { fs.readdirSync(sourceFolderPath) .filter(filename => filename.startsWith(TEMP_PREFIX)) - .forEach((filename) => { + .forEach(filename => { const transformedFileName = transformPath( filename, replacer, @@ -67,7 +70,10 @@ export const copy = ( ); const sourceFilePath = path.join(sourceFolderPath, filename); - const targetFilePath = path.join(targetFolderPath, transformedFileName.replace(TEMP_PREFIX, '').replace(/\s/g, '-')); + const targetFilePath = path.join( + targetFolderPath, + transformedFileName.replace(TEMP_PREFIX, '').replace(/\s/g, '-'), + ); copyFile(sourceFilePath, targetFilePath); }); @@ -81,36 +87,40 @@ export const archiving = async (plugin: O2Plugin) => { // move files to archive folder const readyFiles = getFilesInReady(plugin); readyFiles.forEach((file: TFile) => { - plugin.app.fileManager.renameFile(file, file.path.replace(plugin.obsidianPathSettings.readyFolder, plugin.obsidianPathSettings.archiveFolder)); + plugin.app.fileManager.renameFile( + file, + file.path.replace( + plugin.obsidianPathSettings.readyFolder, + plugin.obsidianPathSettings.archiveFolder, + ), + ); }); }; export const moveFiles = async ( sourceFolderPath: string, targetFolderPath: string, - pathReplacer: (year: string, month: string, day: string, title: string) => string, + pathReplacer: ( + year: string, + month: string, + day: string, + title: string, + ) => string, publishedDate?: LocalDate, ) => { - - copy( - sourceFolderPath, - targetFolderPath, - pathReplacer, - publishedDate, - ); + copy(sourceFolderPath, targetFolderPath, pathReplacer, publishedDate); }; - export const cleanUp = async (plugin: O2Plugin) => { // remove temp files - const markdownFiles = plugin.app.vault.getMarkdownFiles() - .filter((file) => file.path.includes(TEMP_PREFIX)); + const markdownFiles = plugin.app.vault + .getMarkdownFiles() + .filter(file => file.path.includes(TEMP_PREFIX)); for (const file of markdownFiles) { - await plugin.app.vault.delete(file) - .then(() => { - console.log(`Deleted temp file: ${file.path}`); - }); + await plugin.app.vault.delete(file).then(() => { + console.log(`Deleted temp file: ${file.path}`); + }); } }; @@ -119,7 +129,12 @@ export const cleanUp = async (plugin: O2Plugin) => { // return path to be created, and this path is target path const transformPath = ( input: string, - replacer: (year: string | number, month: string | number, day: string | number, title: string) => string, + replacer: ( + year: string | number, + month: string | number, + day: string | number, + title: string, + ) => string, date?: LocalDate, ): string => { const match = input.match(DateExtractionPattern['SINGLE'].regexp); diff --git a/sweep.yaml b/sweep.yaml index 4f98c727..d46d7571 100644 --- a/sweep.yaml +++ b/sweep.yaml @@ -8,5 +8,4 @@ gha_enabled: True # This is the description of your project. It will be used by sweep when creating PRs. You can tell Sweep what's unique about your project, what frameworks you use, or anything else you want. # Here's an example: sweepai/sweep is a python project. The main api endpoints are in sweepai/api.py. Write code that adheres to PEP8. description: '' - # Default Values: https://github.com/sweepai/sweep/blob/main/sweep.yaml diff --git a/tsconfig.json b/tsconfig.json index 6897b914..da7633a2 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,9 +2,7 @@ "compilerOptions": { "esModuleInterop": true, "paths": { - "src": [ - "src/*" - ] + "src": ["src/*"] }, "baseUrl": ".", "inlineSourceMap": true, @@ -17,18 +15,8 @@ "importHelpers": true, "isolatedModules": true, "strictNullChecks": true, - "lib": [ - "DOM", - "ES5", - "ES6", - "ES7" - ] + "lib": ["DOM", "ES5", "ES6", "ES7"] }, - "include": [ - "src/**/*" - ], - "exclude": [ - "node_modules", - "**/*.spec.ts" - ] + "include": ["src/**/*"], + "exclude": ["node_modules", "**/*.spec.ts"] } diff --git a/version-bump.mjs b/version-bump.mjs index d409fa0e..3f6c9058 100644 --- a/version-bump.mjs +++ b/version-bump.mjs @@ -1,14 +1,14 @@ -import { readFileSync, writeFileSync } from "fs"; +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")); +let manifest = JSON.parse(readFileSync('manifest.json', 'utf8')); const { minAppVersion } = manifest; manifest.version = targetVersion; -writeFileSync("manifest.json", JSON.stringify(manifest, null, "\t")); +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")); +let versions = JSON.parse(readFileSync('versions.json', 'utf8')); versions[targetVersion] = minAppVersion; -writeFileSync("versions.json", JSON.stringify(versions, null, "\t")); +writeFileSync('versions.json', JSON.stringify(versions, null, '\t')); diff --git a/versions.json b/versions.json index 5660925c..7cf71996 100644 --- a/versions.json +++ b/versions.json @@ -1,28 +1,28 @@ { - "1.0.0": "0.15.0", - "1.0.1": "0.15.0", - "1.1.0": "0.15.0", - "1.1.1": "0.15.0", - "1.2.0": "0.15.0", - "1.2.1": "0.15.0", - "1.3.0": "0.15.0", - "1.4.0": "0.15.0", - "1.4.1": "0.15.0", - "1.5.0": "0.15.0", - "1.6.0": "0.15.0", - "1.6.1": "0.15.0", - "1.6.2": "0.15.0", - "1.7.0": "0.15.0", - "1.7.1": "0.15.0", - "1.8.0": "0.15.0", - "1.8.1": "0.15.0", - "1.9.0": "0.15.0", - "1.9.1": "0.15.0", - "1.9.2": "0.15.0", - "1.9.3": "0.15.0", - "2.0.0": "0.15.0", - "2.0.1": "0.15.0", - "2.0.2": "0.15.0", - "2.0.3": "0.15.0", - "2.1.0": "0.15.0" -} \ No newline at end of file + "1.0.0": "0.15.0", + "1.0.1": "0.15.0", + "1.1.0": "0.15.0", + "1.1.1": "0.15.0", + "1.2.0": "0.15.0", + "1.2.1": "0.15.0", + "1.3.0": "0.15.0", + "1.4.0": "0.15.0", + "1.4.1": "0.15.0", + "1.5.0": "0.15.0", + "1.6.0": "0.15.0", + "1.6.1": "0.15.0", + "1.6.2": "0.15.0", + "1.7.0": "0.15.0", + "1.7.1": "0.15.0", + "1.8.0": "0.15.0", + "1.8.1": "0.15.0", + "1.9.0": "0.15.0", + "1.9.1": "0.15.0", + "1.9.2": "0.15.0", + "1.9.3": "0.15.0", + "2.0.0": "0.15.0", + "2.0.1": "0.15.0", + "2.0.2": "0.15.0", + "2.0.3": "0.15.0", + "2.1.0": "0.15.0" +}