Skip to content

Commit

Permalink
🐎 ci: 增加文件夹同名校验
Browse files Browse the repository at this point in the history
  • Loading branch information
白云苍狗 committed Oct 30, 2023
1 parent 7faf3a5 commit 0b9d7b3
Show file tree
Hide file tree
Showing 18 changed files with 63 additions and 21 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/publish-cli.yml
Original file line number Diff line number Diff line change
@@ -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 }}
File renamed without changes.
15 changes: 0 additions & 15 deletions packages/async-cli/README.md

This file was deleted.

15 changes: 15 additions & 0 deletions packages/create-theme/README.md
Original file line number Diff line number Diff line change
@@ -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
```
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"name": "async-cli",
"name": "create-async-theme",
"version": "0.0.0",
"repository": "[email protected]:MaLuns/vitepress-theme-async.git",
"author": "白云苍狗 <[email protected]>",
"license": "MIT",
"keywords": [
"vitepress-theme",
"blog-theme"
"blog-theme",
"create-theme"
],
"bin": {
"async-cli": "./dist/index.js"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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();
Expand Down
File renamed without changes.
10 changes: 7 additions & 3 deletions scripts/publish.mjs
Original file line number Diff line number Diff line change
@@ -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");
}

0 comments on commit 0b9d7b3

Please sign in to comment.