-
-
Notifications
You must be signed in to change notification settings - Fork 672
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
1 parent
d8ecb37
commit 45b1a35
Showing
30 changed files
with
248 additions
and
44 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
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
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
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
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
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
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,93 @@ | ||
import { existsSync, writeFileSync, readdirSync } from "fs"; | ||
import { join, resolve } from "path"; | ||
import { version } from "../packages/theme/package.json"; | ||
|
||
const packagesDir = resolve(__dirname, "../packages/"); | ||
const files = readdirSync(packagesDir); | ||
|
||
files.forEach((pkgName) => { | ||
if (pkgName.charAt(0) === "." || pkgName === "theme") return; | ||
|
||
const desc = `${pkgName} plugin for vuepress-theme-hope`; | ||
const pkgPath = join(packagesDir, pkgName, "package.json"); | ||
|
||
// generate package.json | ||
if (!existsSync(pkgPath)) { | ||
const pkgJSON = { | ||
name: `@mr-hope/vuepress-plugin-${pkgName}`, | ||
version, | ||
description: desc, | ||
main: "node/index.js", | ||
types: "node/index.d.ts", | ||
publishConfig: { | ||
access: "public", | ||
}, | ||
repository: { | ||
type: "git", | ||
url: "git+https://github.com/vuepress-theme-hope/vuepress-theme-hope.git", | ||
directory: `packages/${pkgName}`, | ||
}, | ||
keywords: [ | ||
"vuepress-plugin", | ||
"vuepress", | ||
pkgName, | ||
"vuepress-theme-hope", | ||
"mr-hope", | ||
], | ||
author: { | ||
email: "zhangbowang1998@gmail.com", | ||
name: "Mr.Hope", | ||
url: "https://mrhope.site", | ||
}, | ||
license: "MIT", | ||
bugs: { | ||
url: "https://github.com/vuepress-theme-hope/vuepress-theme-hope/issues", | ||
}, | ||
homepage: `https://github.com/vuepress-theme-hope/vuepress-theme-hope/packages/${pkgName}#readme`, | ||
}; | ||
|
||
writeFileSync(pkgPath, `${JSON.stringify(pkgJSON, null, 2)}\n`); | ||
} | ||
|
||
const readmePath = join(packagesDir, pkgName, "readme.md"); | ||
|
||
// generate readme.md | ||
if (!existsSync(readmePath)) | ||
writeFileSync( | ||
readmePath, | ||
`# @mr-hope/vuepress-plugin-${pkgName} | ||
[![Version](https://img.shields.io/npm/v/@mr-hope/vuepress-plugin-${pkgName}.svg?style=flat-square&logo=npm) ![Downloads](https://img.shields.io/npm/dm/@mr-hope/vuepress-plugin-${pkgName}.svg?style=flat-square&logo=npm) ![Size](https://img.shields.io/bundlephobia/min/@mr-hope/vuepress-plugin-${pkgName}?style=flat-square&logo=npm)](https://www.npmjs.com/package/@mr-hope/vuepress-plugin-${pkgName}) | ||
${desc}. | ||
## Usage | ||
\`\`\`bash | ||
yarn add @mr-hope/vuepress-plugin-${pkgName} | ||
\`\`\` | ||
Or | ||
\`\`\`bash | ||
npm i @mr-hope/vuepress-plugin-${pkgName} | ||
\`\`\` | ||
--- | ||
vuepress-theme-hope 的 ${pkgName} 插件。 | ||
## 使用 | ||
\`\`\`bash | ||
yarn add @mr-hope/vuepress-plugin-${pkgName} | ||
\`\`\` | ||
或 | ||
\`\`\`bash | ||
npm i @mr-hope/vuepress-plugin-${pkgName} | ||
\`\`\` | ||
` | ||
); | ||
}); |
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,6 @@ | ||
import { release } from "./release"; | ||
|
||
release().catch((err) => { | ||
console.error(err); | ||
process.exit(1); | ||
}); |
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,93 @@ | ||
import execa = require("execa"); | ||
import { black, cyan, green, red } from "chalk"; | ||
import { prompt } from "inquirer"; | ||
import { ReleaseType, inc } from "semver"; | ||
import { version as currentVersion } from "../../lerna.json"; | ||
import { getNpmTags, getVersion, versions } from "./version"; | ||
import { sync } from "./sync"; | ||
import type { Answers } from "./version"; | ||
|
||
export const release = async (): Promise<void> => { | ||
console.log(black.bgYellow("wait"), "Building project..."); | ||
await execa("yarn", ["run", "clean"]); | ||
await execa("yarn", ["run", "build"]); | ||
|
||
console.log(`Current version: ${green(currentVersion)}`); | ||
|
||
const bumps: ReleaseType[] = [ | ||
"patch", | ||
"minor", | ||
"major", | ||
"prerelease", | ||
"premajor", | ||
]; | ||
|
||
bumps.forEach((bump) => { | ||
versions[bump] = inc(currentVersion, bump) as string; | ||
}); | ||
|
||
const bumpChoices = bumps.map((bump) => ({ | ||
name: `${bump} (${versions[bump]})`, | ||
value: bump, | ||
})); | ||
|
||
const { bump, customVersion, npmTag } = await prompt<Answers>([ | ||
{ | ||
name: "bump", | ||
message: "Select release type:", | ||
type: "list", | ||
choices: [...bumpChoices, { name: "custom", value: "custom" }], | ||
}, | ||
{ | ||
name: "customVersion", | ||
message: "Input version:", | ||
type: "input", | ||
when: (answers): boolean => answers.bump === "custom", | ||
}, | ||
{ | ||
name: "npmTag", | ||
message: "Input npm tag:", | ||
type: "list", | ||
default: (answers: Answers): string => getNpmTags(getVersion(answers))[0], | ||
choices: (answers: Answers): string[] => getNpmTags(getVersion(answers)), | ||
}, | ||
]); | ||
|
||
const version = customVersion || versions[bump]; | ||
|
||
const { confirm } = await prompt<{ confirm: "Y" | "N" }>([ | ||
{ | ||
name: "confirm", | ||
message: `Confirm releasing ${version} (${npmTag})?`, | ||
type: "list", | ||
choices: ["N", "Y"], | ||
}, | ||
]); | ||
|
||
if (confirm === "N") return console.log(red("Release canceled.")); | ||
|
||
const releaseArguments = [ | ||
"publish", | ||
version, | ||
"--dist-tag", | ||
npmTag, | ||
"--registry", | ||
"https://registry.npmjs.org/", | ||
]; | ||
|
||
console.log(cyan(`lerna ${releaseArguments.join(" ")}`)); | ||
|
||
await execa(require.resolve("lerna/cli"), releaseArguments, { | ||
stdio: "inherit", | ||
}); | ||
|
||
console.log(black.bgYellow("wait"), "Syncing npm.taobao.org..."); | ||
|
||
await sync(); | ||
|
||
console.log(black.bgYellow("wait"), "Generating changelog..."); | ||
|
||
await execa("yarn", ["run", "changelog"]); | ||
|
||
console.log(green("Release complete")); | ||
}; |
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,20 @@ | ||
import { readdirSync } from "fs"; | ||
import { get } from "https"; | ||
import { resolve } from "path"; | ||
|
||
const packages = readdirSync(resolve(__dirname, "../../packages")); | ||
|
||
export const sync = (): Promise<void[]> => { | ||
const promises = packages.map((packageName) => { | ||
return import(`../../packages/${packageName}/package.json`).then( | ||
(content: Record<string, unknown>) => | ||
new Promise<void>((resolve) => { | ||
get(`https://npm.taobao.org/sync/${content.name as string}`, () => | ||
resolve() | ||
); | ||
}) | ||
); | ||
}); | ||
|
||
return Promise.all(promises); | ||
}; |
Oops, something went wrong.