mirror of
https://github.com/mayurankv/Obsidian-Code-Styler.git
synced 2026-07-22 08:10:29 +00:00
Automatic updating
This commit is contained in:
parent
5d5c72340a
commit
f43b2f213e
8 changed files with 40 additions and 8 deletions
|
|
@ -27,6 +27,10 @@ See this project's [releases](/../../../releases).
|
|||
|
||||
- Refactored editing view codeblock parsing to use callbacks in a loop function
|
||||
|
||||
### Fixed
|
||||
|
||||
- Compatibility with the [blur plugin](https://github.com/gapmiss/blur)
|
||||
|
||||
## [1.0.7] - 2023-08-16
|
||||
|
||||
### Added
|
||||
|
|
|
|||
10
main.js
10
main.js
File diff suppressed because one or more lines are too long
9
manual-update.mjs
Normal file
9
manual-update.mjs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
import { readFileSync, writeFileSync } from "fs";
|
||||
|
||||
const url = "https://raw.githubusercontent.com/twibiral/obsidian-execute-code/master/src/main.ts";
|
||||
let settingsText = readFileSync("src/Settings.ts", "utf8");
|
||||
fetch(url).then(r => r.text()).then(text=>{
|
||||
const languageAliases = /export const languageAliases = \[([\s\S]*?)\]/.exec(text)?.[1]?.replace(/\s*/g,"");
|
||||
const canonicalLanguages = /export const canonicalLanguages = \[([\s\S]*?)\]/.exec(text)?.[1]?.replace(/\s*/g,"");
|
||||
writeFileSync("src/Settings.ts",settingsText.replace(/const EXECUTE_CODE_LANGUAGE_ALIASES: Array<string> = \[([\s\S]*?)\]/,`const EXECUTE_CODE_LANGUAGE_ALIASES: Array<string> = [${languageAliases}]`).replace(/const EXECUTE_CODE_CANONICAL_LANGUAGES: Array<string> = \[([\s\S]*?)\]/,`const EXECUTE_CODE_CANONICAL_LANGUAGES: Array<string> = [${canonicalLanguages}]`));
|
||||
});
|
||||
|
|
@ -6,9 +6,9 @@
|
|||
"scripts": {
|
||||
"dev": "node esbuild.config.mjs",
|
||||
"build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production",
|
||||
"update": "ncu -u && npm install",
|
||||
"update": "ncu -u && npm install && node manual-update.mjs",
|
||||
"lint": "eslint --fix --max-warnings=0 src && stylelint --fix --max-warnings=0 src/styles.css src/css",
|
||||
"version": "node version-bump.mjs"
|
||||
"version": "node version-bump.mjs",
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "Mayuran Visakan",
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { Plugin, TFile } from "obsidian";
|
||||
|
||||
import CodeStylerPlugin from "./main";
|
||||
import { CodeStylerTheme } from "./Settings";
|
||||
import { CodeStylerTheme, EXECUTE_CODE_SUPPORTED_LANGUAGES } from "./Settings";
|
||||
|
||||
export interface CodeblockParameters {
|
||||
language: string;
|
||||
|
|
@ -39,6 +39,7 @@ export interface Highlights {
|
|||
}
|
||||
|
||||
interface ExternalPlugin extends Plugin {
|
||||
supportedLanguages?: Array<string>;
|
||||
code?: (source: string, sourcePath: string)=>{
|
||||
start: number;
|
||||
code: string;
|
||||
|
|
@ -170,6 +171,11 @@ export async function pluginAdjustParameters(codeblockParameters: CodeblockParam
|
|||
if (typeof fileIncludeLanguage !== "undefined")
|
||||
codeblockParameters.language = fileIncludeLanguage;
|
||||
}
|
||||
} else if (/run-\w*/.test(codeblockParameters.language)) {
|
||||
if ("execute-code" in plugins) {
|
||||
if (codeblockParameters.language.slice(4) in EXECUTE_CODE_SUPPORTED_LANGUAGES)
|
||||
codeblockParameters.language = codeblockParameters.language.slice(4);
|
||||
}
|
||||
}
|
||||
return codeblockParameters;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1351,3 +1351,8 @@ export const LANGUAGE_COLOURS : {[key: string]: string} = {
|
|||
"YANG": "#231f20",
|
||||
"Zig": "#f7a41d"
|
||||
};
|
||||
|
||||
const EXECUTE_CODE_LANGUAGE_ALIASES: Array<string> = ["javascript","typescript","bash","csharp","wolfram","nb","wl","hs","py"];
|
||||
const EXECUTE_CODE_CANONICAL_LANGUAGES: Array<string> = ["js","ts","cs","lean","lua","python","cpp","prolog","shell","groovy","r","go","rust","java","powershell","kotlin","mathematica","haskell","scala","racket","fsharp","c","dart","ruby","batch","sql","octave","maxima"];
|
||||
|
||||
export const EXECUTE_CODE_SUPPORTED_LANGUAGES = [...EXECUTE_CODE_LANGUAGE_ALIASES,...EXECUTE_CODE_CANONICAL_LANGUAGES];
|
||||
|
|
|
|||
|
|
@ -16,10 +16,10 @@ versions[newVersion] = minAppVersion;
|
|||
writeFileSync("versions.json", JSON.stringify(versions, null, "\t"));
|
||||
|
||||
// Update CHANGELOG.md
|
||||
let changelog = readFileSync("CHANGELOG.md", "utf8");
|
||||
const lastVersion = /\[Unreleased\]: \/..\/..\/compare\/(\d+.\d+.\d+)...HEAD/.exec(changelog)?.[1] ?? "0.0.0";
|
||||
process.env.release_notes = /(?<=## \[Unreleased\])[\s\S]*?\n(?=## )/.exec(changelog)[0].trim();
|
||||
writeFileSync("CHANGELOG.md",changelog.replace(/## \[Unreleased\]/,`## [Unreleased]\n\n## [${newVersion}] - ${new Date().toISOString().slice(0, 10)}`).replace(/(?<=\[Unreleased\]: \/..\/..\/compare\/)(\d+.\d+.\d+)...HEAD/,`${newVersion}...HEAD\n[${newVersion}]: /../../compare/${lastVersion}...${newVersion}`));
|
||||
let changelogText = readFileSync("CHANGELOG.md", "utf8");
|
||||
const lastVersion = /\[Unreleased\]: \/..\/..\/compare\/(\d+.\d+.\d+)...HEAD/.exec(changelogText)?.[1] ?? "0.0.0";
|
||||
process.env.release_notes = /(?<=## \[Unreleased\])[\s\S]*?\n(?=## )/.exec(changelogText)[0].trim();
|
||||
writeFileSync("CHANGELOG.md",changelogText.replace(/## \[Unreleased\]/,`## [Unreleased]\n\n## [${newVersion}] - ${new Date().toISOString().slice(0, 10)}`).replace(/(?<=\[Unreleased\]: \/..\/..\/compare\/)(\d+.\d+.\d+)...HEAD/,`${newVersion}...HEAD\n[${newVersion}]: /../../compare/${lastVersion}...${newVersion}`));
|
||||
|
||||
// Push to origin
|
||||
exec(`git add . && git commit -m 'Ready release ${newVersion}' && git push && git tag -a $npm_package_version -F- <<EOF && git push origin $npm_package_version && git push origin $npm_package_version
|
||||
|
|
|
|||
Loading…
Reference in a new issue