Skip to content

Commit

Permalink
ci: 发布
Browse files Browse the repository at this point in the history
  • Loading branch information
baicie committed Nov 28, 2023
1 parent bacc0a8 commit 64a28d3
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 20 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"scripts": {
"cz": "bcz",
"update-version": "tsx scripts/update-version.ts",
"publish-script": "tsx scripts/publish-script.ts",
"build": "turbo run build",
"start": "turbo run start",
"prepare": "is-ci || husky install",
Expand Down
5 changes: 4 additions & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,8 @@
"jest-cli": "^29.7.0",
"puppeteer": "^21.5.2"
},
"license": "MIT"
"license": "MIT",
"config": {
"publish": true
}
}
7 changes: 5 additions & 2 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,8 @@
"files": [
"dist/",
"css/"
]
}
],
"config": {
"publish": true
}
}
5 changes: 4 additions & 1 deletion packages/svelte-output-target/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,8 @@
"devDependencies": {
"estree-walker": "^3.0.3",
"svelte": "^4.2.7"
},
"config": {
"publish": true
}
}
}
2 changes: 1 addition & 1 deletion packages/svelte-output-target/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
"jsx": "preserve"
},
"include": ["src"],
"exclude": ["node_modules", "src/resources"]
"exclude": ["node_modules", "src/resources"],
}
7 changes: 5 additions & 2 deletions packages/svelte/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,8 @@
"files": [
"dist/",
"css/"
]
}
],
"config": {
"publish": true
}
}
7 changes: 5 additions & 2 deletions packages/vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,8 @@
"files": [
"dist/",
"css/"
]
}
],
"config": {
"publish": true
}
}
40 changes: 40 additions & 0 deletions scripts/publish-script.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import type { Project } from '@pnpm/find-workspace-packages';
import { findWorkspacePackages } from '@pnpm/find-workspace-packages';
import chalk from 'chalk';
import consola from 'consola';
import process from 'node:process';
import { rootPath } from './paths';
import {exec, execSync} from 'node:child_process';

const getWorkspacePackages = () => findWorkspacePackages(rootPath);

function errorAndExit(err: Error): void {
consola.error(err);
process.exit(1);
}

async function main() {
consola.debug(chalk.yellow('publish-script started'));

const pkgs = Object.fromEntries((await getWorkspacePackages()).map(pkg => [pkg.manifest.name!, pkg]));

const publishPackage = async (project: Project) => {
const config:any = project.manifest.config
if(config && config.publish && config.publish === true) {
execSync('pnpm publish --access public --no-git-checks', {cwd: project.dir, stdio: 'inherit'})
return;
}
};

try {
for (const [name, project] of Object.entries(pkgs)) {
await publishPackage(project);
}
} catch (error) {
errorAndExit(error as Error);
}

consola.success(chalk.green(`packages published successfully`));
}

main();
12 changes: 1 addition & 11 deletions scripts/publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,6 @@ pnpm update-version

pnpm build

cd packages/core
pnpm publish --access public --no-git-checks
cd -

cd packages/react
pnpm publish --access public --no-git-checks
cd -

cd packages/vue
pnpm publish --access public --no-git-checks
cd -
pnpm publish-script

echo "✅ Publish completed"

0 comments on commit 64a28d3

Please sign in to comment.