-
Notifications
You must be signed in to change notification settings - Fork 1
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
tigerzh
committed
Jan 31, 2023
1 parent
ebbc13c
commit 095a3f4
Showing
11 changed files
with
138 additions
and
11 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
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,74 @@ | ||
#!/usr/bin/env node | ||
/** | ||
* node 部署前端脚本 | ||
*/ | ||
// pnpm i -D child_process@1.0.2 ora@5.4.0 inquirer@8.0.0 | ||
// # From 1.0.0 -> 1.0.1 | ||
// npm version patch | ||
|
||
// # From 1.0.1 -> 1.1.0 | ||
// npm version minor | ||
|
||
// # From 1.1.0 -> 2.0.0 | ||
// npm version major | ||
// 此脚本仅适用个人 | ||
// import { exec } from "child_process"; | ||
// import ora from "ora"; | ||
// import inquirer from "inquirer"; | ||
// import _package from "../package.json" | ||
// import envs from "./env.json" | ||
// import dayjs from "dayjs"; | ||
// 此脚本仅适用个人 | ||
const { exec } = require('child_process') | ||
const ora = require("ora"); | ||
const inquirer = require("inquirer"); | ||
const _package = require("../package.json"); | ||
// const { outputDir } = require("../vue.config"); | ||
const envs = require("./env.json"); | ||
// 当前版本 | ||
const version = _package.version; | ||
// 项目目录 | ||
const dirPath = `${process.cwd()}/.vitepress/dist`; | ||
// 版本目录 | ||
const versionPath = `${dirPath}-${version}`; | ||
const dayjs = require("dayjs"); | ||
|
||
inquirer | ||
.prompt({ | ||
type: "rawlist", | ||
name: "commit", | ||
message: "请选择部署环境:", | ||
default: "stage", | ||
choices: envs.map((it) => `${it.name}: ${it.website}`), | ||
}) | ||
.then(async (answers) => { | ||
const [name] = answers.commit.split(":"); | ||
const index = envs.findIndex((it) => it.name === name); | ||
|
||
|
||
if (index > -1) { | ||
const it = envs[index]; | ||
console.log(`pnpm build; | ||
cp -r ${dirPath} ${versionPath}; | ||
scp -r ${dirPath} ${it.sshNmae}:${it.targetPath}; | ||
scp -r ${versionPath} ${it.sshNmae}:${it.targetPath}; | ||
rm -rf ${versionPath}; | ||
`) | ||
const spinner = ora({ | ||
text: `${answers.commit}:部署中...`, | ||
}).start(); | ||
exec( | ||
`pnpm build; | ||
cp -r ${dirPath} ${versionPath}; | ||
scp -r ${dirPath} ${it.sshNmae}:${it.targetPath}; | ||
scp -r ${versionPath} ${it.sshNmae}:${it.targetPath}; | ||
rm -rf ${versionPath}; | ||
`, | ||
function (err) { | ||
if (err) throw err; | ||
spinner.succeed("部署完成"); | ||
spinner.succeed(dayjs().format("YYYY-MM-DD HH:mm:ss")); | ||
} | ||
); | ||
} | ||
}); |
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,9 @@ | ||
[ | ||
{ | ||
"name": "document", | ||
"targetPath": "/home/app/document", | ||
"website": "https://tigerzh.com/document", | ||
"sshNmae": "zorg", | ||
"mpmModel": "build" | ||
} | ||
] |
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,16 @@ | ||
import os | ||
import json | ||
# print(os.path.abspath(os.getcwd(), './.vitepress//dist/hashmap.json')) | ||
with open('./.vitepress/dist/hashmap.json') as f: | ||
url_obj = json.load(f) | ||
keys = url_obj.keys() | ||
|
||
# def get_urls(url): | ||
# return url.replace('_', '/').replace('md', 'html') | ||
# map(get_urls, keys) | ||
|
||
for [i, key] in enumerate(keys): | ||
print(key) | ||
key = key.replace('_', '/').replace('md', 'html') | ||
# keys[i] = keys[i].replace('_', '/').replace('md', 'html') | ||
print(keys) |
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
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 |
---|---|---|
@@ -1,5 +1,3 @@ | ||
|
||
|
||
## 超级比较 | ||
|
||
|
||
|
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