commit 9b2ab3928f93cd45553fb6bf4d3b9b72779b2014 Author: ipshing Date: Tue Aug 22 13:29:36 2023 -0700 first commit diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..32909b2 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,2 @@ +npm node_modules +build \ No newline at end of file diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..0807290 --- /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..4a615d7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,24 @@ +# vscode +.vscode + +# Intellij +*.iml +.idea + +# npm +node_modules +package-lock.json + +# Build +main.js +*.js.map +/build/* + +# Exclude sourcemaps +*.map + +# obsidian +data.json + +# Exclude macOS Finder (System Explorer) View States +.DS_Store 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/manifest.json b/manifest.json new file mode 100644 index 0000000..ab73348 --- /dev/null +++ b/manifest.json @@ -0,0 +1,10 @@ +{ + "id": "obsidian-text-transform", + "name": "Text Transform", + "version": "1.0.0", + "minAppVersion": "1.0.0", + "description": "This plugin adds options to transform text to different casings using keyboard shortcuts.", + "author": "ipshing", + "authorUrl": "https://github.com/ipshing", + "isDesktopOnly": false +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..929c1ac --- /dev/null +++ b/package.json @@ -0,0 +1,29 @@ +{ + "name": "obsidian-text-transform", + "version": "1.0.0", + "description": "Adds formatting features to transform text casing.", + "main": "main.js", + "scripts": { + "dev": "rollup --config rollup.config.js -w", + "build": "rollup --config rollup.config.js --environment BUILD:production", + "version": "node version-bump.mjs && git add manifest.json versions.json" + }, + "keywords": [], + "author": "", + "license": "MIT", + "devDependencies": { + "@rollup/plugin-commonjs": "^21.0.1", + "@rollup/plugin-json": "^4.1.0", + "@rollup/plugin-node-resolve": "^13.1.3", + "@rollup/plugin-typescript": "^8.3.0", + "@types/node": "^16.11.6", + "@typescript-eslint/eslint-plugin": "^5.2.0", + "@typescript-eslint/parser": "^5.2.0", + "builtin-modules": "^3.2.0", + "obsidian": "^1.4.0", + "rollup": "^2.67.0", + "rollup-plugin-copy": "^3.4.0", + "tslib": "2.3.1", + "typescript": "4.4.4" + } +} diff --git a/rollup.config.js b/rollup.config.js new file mode 100644 index 0000000..f4c5897 --- /dev/null +++ b/rollup.config.js @@ -0,0 +1,38 @@ +import commonjs from "@rollup/plugin-commonjs"; +import json from "@rollup/plugin-json"; +import { nodeResolve } from "@rollup/plugin-node-resolve"; +import typescript from "@rollup/plugin-typescript"; +import copy from "rollup-plugin-copy"; + +const isProd = process.env.BUILD === "production"; + +const banner = `/* +THIS IS A GENERATED/BUNDLED FILE BY ROLLUP +if you want to view the source visit the plugins github repository +*/ +`; + +export default { + input: "src/main.ts", + output: { + file: "build/main.js", + sourcemap: "inline", + sourcemapExcludeSources: isProd, + format: "cjs", + exports: "default", + banner, + }, + external: ["obsidian"], + plugins: [ + typescript(), + nodeResolve({ browser: true }), + commonjs(), + json(), + copy({ + targets: [ + { src: "manifest.json", dest: "build" }, + { src: "src/styles.css", dest: "build" } + ], + }), + ], +}; diff --git a/src/main.ts b/src/main.ts new file mode 100644 index 0000000..fe190ba --- /dev/null +++ b/src/main.ts @@ -0,0 +1,27 @@ +import { Plugin } from "obsidian"; + +interface TextTransformSettings { + mySetting: string; +} + +const DEFAULT_SETTINGS: TextTransformSettings = { + mySetting: "default", +}; + +export default class TextTransform extends Plugin { + settings: TextTransformSettings; + + async onload() { + await this.loadSettings(); + } + + onunload() {} + + async loadSettings() { + this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData()); + } + + async saveSettings() { + await this.saveData(this.settings); + } +} diff --git a/src/styles.css b/src/styles.css new file mode 100644 index 0000000..e69de29 diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..b50f455 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "baseUrl": ".", + "inlineSourceMap": true, + "inlineSources": true, + "module": "ESNext", + "target": "ES6", + "allowJs": true, + "noImplicitAny": true, + "moduleResolution": "node", + "importHelpers": true, + "isolatedModules": true, + "lib": [ + "DOM", + "ES5", + "ES6", + "ES7" + ] + }, + "include": [ + "**/*.ts" + ] +} diff --git a/version-bump.mjs b/version-bump.mjs new file mode 100644 index 0000000..d409fa0 --- /dev/null +++ b/version-bump.mjs @@ -0,0 +1,14 @@ +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..88ccb40 --- /dev/null +++ b/versions.json @@ -0,0 +1,3 @@ +{ + "1.0.0": "1.0.0" +}