mirror of
https://github.com/gavvvr/obsidian-timecodes-plugin.git
synced 2026-07-22 05:38:08 +00:00
build: prepare minimal environment for timecodes plugin development
This commit is contained in:
commit
0f2422bb5f
11 changed files with 218 additions and 0 deletions
13
.gitignore
vendored
Normal file
13
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
# Intellij
|
||||
*.iml
|
||||
.idea/
|
||||
|
||||
# package managers
|
||||
node_modules/
|
||||
.pnpm-store/
|
||||
package-lock.json
|
||||
pnpm-lock.yaml
|
||||
yarn.lock
|
||||
|
||||
# build
|
||||
out/
|
||||
21
LICENSE
Normal file
21
LICENSE
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2025 Kirill Gavrilov
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
1
README.md
Normal file
1
README.md
Normal file
|
|
@ -0,0 +1 @@
|
|||
# Obsidian Timecodes Plugin
|
||||
10
manifest.json
Normal file
10
manifest.json
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"id": "timecodes",
|
||||
"name": "Timecodes",
|
||||
"version": "0.0.1",
|
||||
"minAppVersion": "0.13.8",
|
||||
"description": "Converts raw text timecodes into clickable URLs if a note contains a link to a video",
|
||||
"author": "Kirill Gavrilov",
|
||||
"authorUrl": "https://github.com/gavvvr",
|
||||
"isDesktopOnly": false
|
||||
}
|
||||
25
package.json
Normal file
25
package.json
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"name": "obsidian-timecodes-plugin",
|
||||
"type": "module",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "node scripts/dev.js",
|
||||
"build": "tsc -noEmit -skipLibCheck && node scripts/esbuild.build.js production"
|
||||
},
|
||||
"keywords": [
|
||||
"obsidian.md",
|
||||
"youtube",
|
||||
"timecodes"
|
||||
],
|
||||
"author": "Kirill Gavrilov",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@types/node": "22.10.7",
|
||||
"enquirer": "2.4.1",
|
||||
"esbuild": "0.24.2",
|
||||
"obsidian": "1.7.2",
|
||||
"obsidian-utils": "0.10.2",
|
||||
"typescript": "5.7.3"
|
||||
},
|
||||
"packageManager": "pnpm@9.15.4"
|
||||
}
|
||||
51
scripts/dev.js
Normal file
51
scripts/dev.js
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
// @ts-check
|
||||
|
||||
import fs from 'node:fs/promises'
|
||||
import path from 'node:path'
|
||||
import { exit } from 'node:process'
|
||||
|
||||
import enquirer from 'enquirer'
|
||||
import esbuild from 'esbuild'
|
||||
import obsidianUtils from 'obsidian-utils'
|
||||
|
||||
import { sharedEsbuildConfig } from './esbuild.config.js'
|
||||
|
||||
const { findVault, installPluginFromGithub, isPluginInstalled } = obsidianUtils
|
||||
|
||||
let vaults
|
||||
try {
|
||||
vaults = await findVault()
|
||||
} catch (e) {
|
||||
console.error('Failed to find vaults', e)
|
||||
exit(1)
|
||||
}
|
||||
|
||||
const vaultsOptions = vaults.map(v => ({ message: v.name, name: v.path }))
|
||||
|
||||
/** @type {{ selectedVaultPath: string }} */
|
||||
const { selectedVaultPath } = await enquirer.prompt({
|
||||
type: 'select',
|
||||
name: 'selectedVaultPath',
|
||||
message: 'Select Obsidian Vault for development',
|
||||
choices: vaultsOptions,
|
||||
})
|
||||
|
||||
if (!await isPluginInstalled('hot-reload', selectedVaultPath)) {
|
||||
console.log('Installing hot-reload from github...')
|
||||
await installPluginFromGithub('pjeby/hot-reload', 'latest', selectedVaultPath)
|
||||
}
|
||||
|
||||
const localManifestPath = path.join(process.cwd(), 'manifest.json')
|
||||
const manifest = JSON.parse(await fs.readFile(localManifestPath, { encoding: 'utf-8' }))
|
||||
|
||||
const pluginPath = path.join(selectedVaultPath, '.obsidian', 'plugins', manifest.id)
|
||||
|
||||
fs.mkdir(pluginPath, { recursive: true })
|
||||
await fs.copyFile(localManifestPath, path.join(pluginPath, 'manifest.json'))
|
||||
await fs.writeFile(path.join(pluginPath, '.hotreload'), '')
|
||||
|
||||
const esbuildCtx = await esbuild.context({
|
||||
...sharedEsbuildConfig,
|
||||
...{ outfile: path.join(pluginPath, 'main.js') },
|
||||
})
|
||||
esbuildCtx.watch()
|
||||
25
scripts/esbuild.build.js
Normal file
25
scripts/esbuild.build.js
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
// @ts-check
|
||||
|
||||
import process from 'node:process'
|
||||
|
||||
import esbuild from 'esbuild'
|
||||
|
||||
import { sharedEsbuildConfig } from './esbuild.config.js'
|
||||
|
||||
const config = sharedEsbuildConfig
|
||||
|
||||
const prod = process.argv[2] === 'production'
|
||||
|
||||
const context = await esbuild.context({
|
||||
...config,
|
||||
...prod
|
||||
? { minify: true, sourcemap: false }
|
||||
: {},
|
||||
})
|
||||
|
||||
if (prod) {
|
||||
await context.rebuild()
|
||||
process.exit(0)
|
||||
} else {
|
||||
await context.watch()
|
||||
}
|
||||
40
scripts/esbuild.config.js
Normal file
40
scripts/esbuild.config.js
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
// @ts-check
|
||||
|
||||
import path from 'node:path'
|
||||
|
||||
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
|
||||
*/
|
||||
`
|
||||
|
||||
/** @type {import("esbuild").BuildOptions} */
|
||||
export const sharedEsbuildConfig = {
|
||||
logLevel: 'info',
|
||||
banner: {
|
||||
js: banner,
|
||||
},
|
||||
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',
|
||||
],
|
||||
bundle: true,
|
||||
entryPoints: ['src/TimecodesPlugin.ts'],
|
||||
format: 'cjs',
|
||||
target: 'es2018',
|
||||
minify: false,
|
||||
sourcemap: 'inline',
|
||||
treeShaking: true,
|
||||
outfile: path.join('out', 'main.js'),
|
||||
}
|
||||
7
src/TimecodesPlugin.ts
Normal file
7
src/TimecodesPlugin.ts
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import { Plugin } from 'obsidian'
|
||||
|
||||
export default class TimecodesPlugin extends Plugin {
|
||||
override onload() {
|
||||
console.log('Timecodes Plugin has started')
|
||||
}
|
||||
}
|
||||
22
tsconfig.json
Normal file
22
tsconfig.json
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "node",
|
||||
"target": "ES6",
|
||||
"noImplicitAny": true,
|
||||
"isolatedModules": true,
|
||||
"strict": true,
|
||||
"strictBindCallApply": true,
|
||||
"strictNullChecks": true,
|
||||
"lib": [
|
||||
"DOM",
|
||||
"DOM.Iterable",
|
||||
"ES5",
|
||||
"ES6",
|
||||
"ES7"
|
||||
],
|
||||
},
|
||||
"include": [
|
||||
"**/*.ts"
|
||||
],
|
||||
}
|
||||
3
versions.json
Normal file
3
versions.json
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"0.0.1": "0.13.8"
|
||||
}
|
||||
Loading…
Reference in a new issue