From 0b9d7b34c8f53a45d5a34a9cf4f927243c94ca28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E4=BA=91=E8=8B=8D=E7=8B=97?= Date: Mon, 30 Oct 2023 13:51:37 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=8E=20ci:=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=A4=B9=E5=90=8C=E5=90=8D=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/publish-cli.yml | 30 +++++++++++++++++++ .../{publish.yml => publish-theme.yml} | 0 packages/async-cli/README.md | 15 ---------- packages/create-theme/README.md | 15 ++++++++++ .../{async-cli => create-theme}/package.json | 5 ++-- .../public/move/bunfig.toml | 0 .../public/move/gitignore | 0 .../public/move/npmrc | 0 .../public/move/package | 0 .../public/template/.vitepress/config.ts | 0 .../public/template/.vitepress/theme/index.ts | 0 .../public/template/about.md | 0 .../public/template/index.md | 0 .../public/template/posts/hello-world.md | 0 .../public/template/public/favicon.svg | 0 .../{async-cli => create-theme}/src/index.ts | 9 +++++- .../tsup.config.ts | 0 scripts/publish.mjs | 10 +++++-- 18 files changed, 63 insertions(+), 21 deletions(-) create mode 100644 .github/workflows/publish-cli.yml rename .github/workflows/{publish.yml => publish-theme.yml} (100%) delete mode 100644 packages/async-cli/README.md create mode 100644 packages/create-theme/README.md rename packages/{async-cli => create-theme}/package.json (90%) rename packages/{async-cli => create-theme}/public/move/bunfig.toml (100%) rename packages/{async-cli => create-theme}/public/move/gitignore (100%) rename packages/{async-cli => create-theme}/public/move/npmrc (100%) rename packages/{async-cli => create-theme}/public/move/package (100%) rename packages/{async-cli => create-theme}/public/template/.vitepress/config.ts (100%) rename packages/{async-cli => create-theme}/public/template/.vitepress/theme/index.ts (100%) rename packages/{async-cli => create-theme}/public/template/about.md (100%) rename packages/{async-cli => create-theme}/public/template/index.md (100%) rename packages/{async-cli => create-theme}/public/template/posts/hello-world.md (100%) rename packages/{async-cli => create-theme}/public/template/public/favicon.svg (100%) rename packages/{async-cli => create-theme}/src/index.ts (90%) rename packages/{async-cli => create-theme}/tsup.config.ts (100%) diff --git a/.github/workflows/publish-cli.yml b/.github/workflows/publish-cli.yml new file mode 100644 index 0000000..4d0ef83 --- /dev/null +++ b/.github/workflows/publish-cli.yml @@ -0,0 +1,30 @@ +name: NPM Publish + +on: + push: + tags: + - "cli-v*" +jobs: + build: + permissions: + contents: write + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v3 + with: + node-version: 16 + registry-url: "https://registry.npmjs.org" + cache: yarn + - run: yarn install --frozen-lockfile + + - name: Build + run: | + node ./scripts/publish.mjs + cd ./packages/create-theme + npm run build + npm publish + env: + RELEASE_VERSION: ${{ github.ref }} + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish-theme.yml similarity index 100% rename from .github/workflows/publish.yml rename to .github/workflows/publish-theme.yml diff --git a/packages/async-cli/README.md b/packages/async-cli/README.md deleted file mode 100644 index 6091cca..0000000 --- a/packages/async-cli/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# vitepress theme async - -```bash -# npm -npm create async-cli@latest my-first-blog - -# yarn -yarn create async-cli my-first-blog - -# pnpm -pnpm create async-cli my-first-blog - -# bun -bunx async-cli my-first-blog --bun -``` diff --git a/packages/create-theme/README.md b/packages/create-theme/README.md new file mode 100644 index 0000000..e5a0005 --- /dev/null +++ b/packages/create-theme/README.md @@ -0,0 +1,15 @@ +# vitepress theme async + +```bash +# npm +npm create async-theme@latest my-first-blog + +# yarn +yarn create async-theme my-first-blog + +# pnpm +pnpm create async-theme my-first-blog + +# bun +bunx create-async-theme my-first-blog --bun +``` diff --git a/packages/async-cli/package.json b/packages/create-theme/package.json similarity index 90% rename from packages/async-cli/package.json rename to packages/create-theme/package.json index 143818f..9b14bff 100644 --- a/packages/async-cli/package.json +++ b/packages/create-theme/package.json @@ -1,12 +1,13 @@ { - "name": "async-cli", + "name": "create-async-theme", "version": "0.0.0", "repository": "git@github.com:MaLuns/vitepress-theme-async.git", "author": "白云苍狗 ", "license": "MIT", "keywords": [ "vitepress-theme", - "blog-theme" + "blog-theme", + "create-theme" ], "bin": { "async-cli": "./dist/index.js" diff --git a/packages/async-cli/public/move/bunfig.toml b/packages/create-theme/public/move/bunfig.toml similarity index 100% rename from packages/async-cli/public/move/bunfig.toml rename to packages/create-theme/public/move/bunfig.toml diff --git a/packages/async-cli/public/move/gitignore b/packages/create-theme/public/move/gitignore similarity index 100% rename from packages/async-cli/public/move/gitignore rename to packages/create-theme/public/move/gitignore diff --git a/packages/async-cli/public/move/npmrc b/packages/create-theme/public/move/npmrc similarity index 100% rename from packages/async-cli/public/move/npmrc rename to packages/create-theme/public/move/npmrc diff --git a/packages/async-cli/public/move/package b/packages/create-theme/public/move/package similarity index 100% rename from packages/async-cli/public/move/package rename to packages/create-theme/public/move/package diff --git a/packages/async-cli/public/template/.vitepress/config.ts b/packages/create-theme/public/template/.vitepress/config.ts similarity index 100% rename from packages/async-cli/public/template/.vitepress/config.ts rename to packages/create-theme/public/template/.vitepress/config.ts diff --git a/packages/async-cli/public/template/.vitepress/theme/index.ts b/packages/create-theme/public/template/.vitepress/theme/index.ts similarity index 100% rename from packages/async-cli/public/template/.vitepress/theme/index.ts rename to packages/create-theme/public/template/.vitepress/theme/index.ts diff --git a/packages/async-cli/public/template/about.md b/packages/create-theme/public/template/about.md similarity index 100% rename from packages/async-cli/public/template/about.md rename to packages/create-theme/public/template/about.md diff --git a/packages/async-cli/public/template/index.md b/packages/create-theme/public/template/index.md similarity index 100% rename from packages/async-cli/public/template/index.md rename to packages/create-theme/public/template/index.md diff --git a/packages/async-cli/public/template/posts/hello-world.md b/packages/create-theme/public/template/posts/hello-world.md similarity index 100% rename from packages/async-cli/public/template/posts/hello-world.md rename to packages/create-theme/public/template/posts/hello-world.md diff --git a/packages/async-cli/public/template/public/favicon.svg b/packages/create-theme/public/template/public/favicon.svg similarity index 100% rename from packages/async-cli/public/template/public/favicon.svg rename to packages/create-theme/public/template/public/favicon.svg diff --git a/packages/async-cli/src/index.ts b/packages/create-theme/src/index.ts similarity index 90% rename from packages/async-cli/src/index.ts rename to packages/create-theme/src/index.ts index f42e6d7..afd67c9 100644 --- a/packages/async-cli/src/index.ts +++ b/packages/create-theme/src/index.ts @@ -16,11 +16,15 @@ console.log(); function createThemeProject(destination: string) { const templatePath = path.join(__dirname, 'template'); + if (fs.existsSync(destination)) { + console.log(`❌ The ${projectName} folder already exists.!`); + console.log(); + return; + } fs.copy(templatePath, destination, async err => { // 同步创建.gitignore文件和配置文件 await fs.copy(path.join(__dirname, 'move/gitignore'), path.join(destination, '.gitignore')); - await fs.copy(path.join(__dirname, 'move/package'), path.join(destination, 'package.json')); const sourceRc = isBun ? 'bunfig.toml' : 'npmrc'; @@ -40,6 +44,9 @@ function createThemeProject(destination: string) { console.log('🎉 🎉 created successfully!'); console.log(); + console.log('📚 📚 docs: https://vitepress-theme-async.imalun.com'); + console.log(); + console.log(`project in ${destination}`); console.log(); diff --git a/packages/async-cli/tsup.config.ts b/packages/create-theme/tsup.config.ts similarity index 100% rename from packages/async-cli/tsup.config.ts rename to packages/create-theme/tsup.config.ts diff --git a/scripts/publish.mjs b/scripts/publish.mjs index 0809ec1..1df938b 100644 --- a/scripts/publish.mjs +++ b/scripts/publish.mjs @@ -1,11 +1,15 @@ import { writeFileSync } from "fs"; import { resolve } from "path"; import { fileURLToPath } from "url"; -import pkg from "../packages/vitepress-theme-async/package.json" assert { type: "json" }; +import themepkg from "../packages/vitepress-theme-async/package.json" assert { type: "json" }; +import clipkg from "../packages/create-theme/package.json" assert { type: "json" }; + if (process.env.RELEASE_VERSION) { const version = process.env.RELEASE_VERSION.split("/").reverse()[0]; console.log("当前版本:", version); - pkg.version = version.replace("v", ""); - writeFileSync(resolve(fileURLToPath(import.meta.url), "../../packages/vitepress-theme-async/package.json"), JSON.stringify(pkg, null, 4), "utf-8"); + themepkg.version = version.replace("v", ""); + clipkg.version = version.replace("cli-v", ""); + writeFileSync(resolve(fileURLToPath(import.meta.url), "../../packages/vitepress-theme-async/package.json"), JSON.stringify(themepkg, null, 4), "utf-8"); + writeFileSync(resolve(fileURLToPath(import.meta.url), "../../packages/create-theme/package.json"), JSON.stringify(clipkg, null, 4), "utf-8"); }