mirror of
https://github.com/keathmilligan/obsidian-paste-reformatter.git
synced 2026-07-22 05:43:44 +00:00
build cleanup (#17)
* style: cleanup file formatting * chore: simplify build * chore: cleanup package.json
This commit is contained in:
parent
7435a160b7
commit
62a1893a97
6 changed files with 740 additions and 774 deletions
|
|
@ -1,34 +0,0 @@
|
|||
// copy-styles.mjs
|
||||
import { promises as fs } from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
// Ensure the dist directory exists
|
||||
async function ensureDir(dir) {
|
||||
try {
|
||||
await fs.mkdir(dir, { recursive: true });
|
||||
} catch (error) {
|
||||
if (error.code !== 'EEXIST') {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function copyFiles() {
|
||||
const distDir = path.resolve('./dist');
|
||||
await ensureDir(distDir);
|
||||
|
||||
try {
|
||||
// Copy styles.css to dist directory
|
||||
await fs.copyFile('./styles.css', path.join(distDir, 'styles.css'));
|
||||
console.log('Successfully copied styles.css to dist directory');
|
||||
|
||||
// Copy manifest.json to dist directory
|
||||
await fs.copyFile('./manifest.json', path.join(distDir, 'manifest.json'));
|
||||
console.log('Successfully copied manifest.json to dist directory');
|
||||
} catch (error) {
|
||||
console.error('Error copying files:', error);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
copyFiles();
|
||||
|
|
@ -3,7 +3,7 @@ import process from "process";
|
|||
import builtins from "builtin-modules";
|
||||
|
||||
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
|
||||
*/
|
||||
|
|
@ -12,38 +12,38 @@ if you want to view the source, please visit the github repository of this plugi
|
|||
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: "dist/main.js",
|
||||
minify: prod,
|
||||
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",
|
||||
minify: prod,
|
||||
});
|
||||
|
||||
if (prod) {
|
||||
await context.rebuild();
|
||||
process.exit(0);
|
||||
await context.rebuild();
|
||||
process.exit(0);
|
||||
} else {
|
||||
await context.watch();
|
||||
await context.watch();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
{
|
||||
"id": "paste-reformatter",
|
||||
"name": "Paste Reformatter",
|
||||
"version": "1.4.0",
|
||||
"minAppVersion": "0.15.0",
|
||||
"description": "Reformat pasted text for precise control.",
|
||||
"author": "Keath Milligan",
|
||||
"authorUrl": "https://github.com/keathmilligan",
|
||||
"isDesktopOnly": false
|
||||
"id": "paste-reformatter",
|
||||
"name": "Paste Reformatter",
|
||||
"version": "1.4.0",
|
||||
"minAppVersion": "0.15.0",
|
||||
"description": "Reformat pasted text for precise control.",
|
||||
"author": "Keath Milligan",
|
||||
"authorUrl": "https://github.com/keathmilligan",
|
||||
"isDesktopOnly": false
|
||||
}
|
||||
44
package.json
44
package.json
|
|
@ -1,24 +1,24 @@
|
|||
{
|
||||
"name": "obsidian-sample-plugin",
|
||||
"version": "1.4.0",
|
||||
"description": "This is a sample plugin for Obsidian (https://obsidian.md)",
|
||||
"main": "dist/main.js",
|
||||
"scripts": {
|
||||
"dev": "node esbuild.config.mjs && node copy-styles.mjs",
|
||||
"build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production && node copy-styles.mjs",
|
||||
"version": "node version-bump.mjs && git add manifest.json versions.json"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@types/node": "^16.11.6",
|
||||
"@typescript-eslint/eslint-plugin": "5.29.0",
|
||||
"@typescript-eslint/parser": "5.29.0",
|
||||
"builtin-modules": "3.3.0",
|
||||
"esbuild": "0.17.3",
|
||||
"obsidian": "latest",
|
||||
"tslib": "2.4.0",
|
||||
"typescript": "4.7.4"
|
||||
}
|
||||
"name": "obsidian-paste-reformatter",
|
||||
"version": "1.4.0",
|
||||
"description": "Reformat pasted text for precise control.",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
"dev": "node esbuild.config.mjs",
|
||||
"build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production",
|
||||
"version": "node version-bump.mjs && git add manifest.json versions.json"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@types/node": "^16.11.6",
|
||||
"@typescript-eslint/eslint-plugin": "5.29.0",
|
||||
"@typescript-eslint/parser": "5.29.0",
|
||||
"builtin-modules": "3.3.0",
|
||||
"esbuild": "0.17.3",
|
||||
"obsidian": "latest",
|
||||
"tslib": "2.4.0",
|
||||
"typescript": "4.7.4"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
1198
src/main.ts
1198
src/main.ts
File diff suppressed because it is too large
Load diff
|
|
@ -1,10 +1,10 @@
|
|||
{
|
||||
"1.0.0": "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.2.2": "0.15.0",
|
||||
"1.3.0": "0.15.0",
|
||||
"1.4.0": "0.15.0"
|
||||
"1.0.0": "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.2.2": "0.15.0",
|
||||
"1.3.0": "0.15.0",
|
||||
"1.4.0": "0.15.0"
|
||||
}
|
||||
Loading…
Reference in a new issue