-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
443 additions
and
347 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Copyright (c) 2024 by frostime. All Rights Reserved. | ||
# @Author : frostime | ||
# @Date : 2024-09-06 19:15:53 | ||
# @FilePath : /scripts/elevate.ps1 | ||
# @LastEditTime : 2024-09-06 19:39:13 | ||
# @Description : Force to elevate the script to admin privilege. | ||
|
||
param ( | ||
[string]$scriptPath | ||
) | ||
|
||
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Definition | ||
$projectDir = Split-Path -Parent $scriptDir | ||
|
||
if (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { | ||
$args = "-NoProfile -ExecutionPolicy Bypass -File `"" + $MyInvocation.MyCommand.Path + "`" -scriptPath `"" + $scriptPath + "`"" | ||
Start-Process powershell.exe -Verb RunAs -ArgumentList $args -WorkingDirectory $projectDir | ||
exit | ||
} | ||
|
||
Set-Location -Path $projectDir | ||
& node $scriptPath | ||
|
||
pause |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Copyright (c) 2024 by frostime. All Rights Reserved. | ||
* @Author : frostime | ||
* @Date : 2024-03-28 20:03:59 | ||
* @FilePath : /scripts/make_install.js | ||
* @LastEditTime : 2024-09-06 18:08:19 | ||
* @Description : | ||
*/ | ||
// make_install.js | ||
import fs from 'fs'; | ||
import { log, error, getSiYuanDir, chooseTarget, copyDirectory, getThisPluginName } from './utils.js'; | ||
|
||
let targetDir = ''; | ||
|
||
/** | ||
* 1. Get the parent directory to install the plugin | ||
*/ | ||
log('>>> Try to visit constant "targetDir" in make_install.js...'); | ||
if (targetDir === '') { | ||
log('>>> Constant "targetDir" is empty, try to get SiYuan directory automatically....'); | ||
let res = await getSiYuanDir(); | ||
|
||
if (res === null || res === undefined || res.length === 0) { | ||
error('>>> Can not get SiYuan directory automatically'); | ||
process.exit(1); | ||
} else { | ||
targetDir = await chooseTarget(res); | ||
} | ||
log(`>>> Successfully got target directory: ${targetDir}`); | ||
} | ||
if (!fs.existsSync(targetDir)) { | ||
error(`Failed! Plugin directory not exists: "${targetDir}"`); | ||
error('Please set the plugin directory in scripts/make_install.js'); | ||
process.exit(1); | ||
} | ||
|
||
/** | ||
* 2. The dist directory, which contains the compiled plugin code | ||
*/ | ||
const distDir = `${process.cwd()}/dist`; | ||
if (!fs.existsSync(distDir)) { | ||
fs.mkdirSync(distDir); | ||
} | ||
|
||
/** | ||
* 3. The target directory to install the plugin | ||
*/ | ||
const name = getThisPluginName(); | ||
if (name === null) { | ||
process.exit(1); | ||
} | ||
const targetPath = `${targetDir}/${name}`; | ||
|
||
/** | ||
* 4. Copy the compiled plugin code to the target directory | ||
*/ | ||
copyDirectory(distDir, targetPath); |
Oops, something went wrong.