Skip to content

Commit 6bedada

Browse files
committed
feat: ✨ Add version bumping workflow and enhance project setup scripts
1 parent c5a2315 commit 6bedada

File tree

11 files changed

+162
-8
lines changed

11 files changed

+162
-8
lines changed

.github/workflows/publish.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
- uses: pnpm/action-setup@v4
4040
name: Install pnpm
4141
with:
42-
version: 10.8.0
42+
version: 10.10.0
4343

4444
- name: Install Node.js
4545
uses: actions/setup-node@v4

.github/workflows/test.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Test publish version
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
release:
7+
description: stable, canary, or release candidate?
8+
required: true
9+
type: choice
10+
options:
11+
- canary
12+
- stable
13+
- release-candidate
14+
type:
15+
description: 'Type of package to publish'
16+
required: true
17+
type: choice
18+
options:
19+
- patch
20+
- minor
21+
- major
22+
skip_bump_version:
23+
description: 'Skip bumping version in package.json and release notes?'
24+
required: false
25+
type: boolean
26+
27+
jobs:
28+
bump-version:
29+
name: 'Bump Version'
30+
runs-on: ubuntu-latest
31+
permissions:
32+
contents: write
33+
id-token: write
34+
35+
steps:
36+
- name: Checkout
37+
uses: actions/checkout@v4
38+
39+
- name: Configure Git
40+
run: |
41+
git config --global user.name "${{ github.actor }}"
42+
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
43+
44+
- uses: pnpm/action-setup@v4
45+
name: Install pnpm
46+
with:
47+
version: 10.10.0
48+
49+
- name: Install Node.js
50+
uses: actions/setup-node@v4
51+
with:
52+
registry-url: 'https://registry.npmjs.org/'
53+
node-version: 22
54+
55+
- name: Install dependencies
56+
run: pnpm install --frozen-lockfile
57+
58+
- name: Run script to bump version & copy files
59+
run: pnpm run release
60+
id: version-bump
61+
env:
62+
VERSION_TYPE: ${{ github.event.inputs.type }}
63+
RELEASE_TYPE: ${{ github.event.inputs.release }}
64+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
65+
GITHUB_USER: ${{ github.actor }}
66+
GITHUB_EMAIL: ${{ github.actor }}@users.noreply.github.com

bump-version.mjs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const ALLOWED_VERSION_TYPES = ['major', 'minor', 'patch'];
2+
const WORKSPACE = process.env.GITHUB_WORKSPACE || process.cwd();
3+
const GIT_USER = {
4+
NAME: process.env.GITHUB_USER ?? 'Automated Version Bump',
5+
EMAIL: process.env.GITHUB_EMAIL
6+
? `${process.env.GITHUB_USER}@users.noreply.github.com`
7+
: 'gh-action-bump-version@users.noreply.github.com',
8+
};
9+
10+
const init = () => {
11+
console.log(
12+
'Initializing build version script...',
13+
GIT_USER.EMAIL,
14+
GIT_USER.NAME,
15+
);
16+
};
17+
18+
init();

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "vitnode",
33
"private": true,
44
"scripts": {
5+
"release": "node ./bump-version.mjs",
56
"db:migrate": "turbo db:migrate",
67
"db:push": "turbo db:push",
78
"docker:dev": "docker compose -f ./docker-compose.yml -p vitnode-dev-dun up -d",
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import vitnodePrettier from "eslint-config-typescript-vitnode/prettierrc";
2+
3+
/**
4+
* @see https://prettier.io/docs/en/configuration.html
5+
* @type {import("prettier").Config}
6+
*/
7+
const config = {
8+
...vitnodePrettier,
9+
};
10+
11+
export default config;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import eslintVitNode from 'eslint-config-typescript-vitnode/eslint';
2+
3+
export default [...eslintVitNode];
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import type { NextConfig } from 'next';
2+
import { vitNodeNextConfig } from '@vitnode/core/config/next.config';
3+
4+
const nextConfig: NextConfig = {
5+
experimental: {
6+
inlineCss: true,
7+
reactCompiler: true,
8+
},
9+
};
10+
11+
export default vitNodeNextConfig(nextConfig);
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { buildApiConfig } from '@vitnode/core/vitnode.config';
2+
3+
export const vitNodeApiConfig = buildApiConfig({
4+
plugins: [],
5+
});

packages/create-vitnode-app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"create-vitnode-app": "dist/src/index.js"
1616
},
1717
"scripts": {
18-
"build:cli": "tsc",
18+
"build:cli": "tsc && node dist/src/prepare/prepare.js",
1919
"cli": "node dist/src/index.js",
2020
"lint": "eslint .",
2121
"lint:fix": "eslint . --fix"

packages/create-vitnode-app/src/create/create-vitnode.ts

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
import { mkdir } from 'fs/promises';
2-
import ora from 'ora';
1+
import { existsSync } from 'fs';
2+
import { cp, mkdir } from 'fs/promises';
3+
import { dirname, join } from 'path';
4+
import { fileURLToPath } from 'url';
5+
36
import color from 'picocolors';
7+
import ora from 'ora';
48

59
import type { CreateCliReturn } from '../questions.js';
610

@@ -18,15 +22,29 @@ export const createVitNode = async ({
1822
`Creating a new VitNode app in ${color.green(root)}. Using ${color.green(packageManager)}...`,
1923
).start();
2024

21-
/**
22-
* Create the folder
23-
*/
25+
const __filename = fileURLToPath(import.meta.url);
26+
const __dirname = dirname(__filename);
27+
const templatePath = join(__dirname, '..', '..', '..', 'copy-of-vitnode-app');
28+
if (!existsSync(templatePath)) {
29+
spinner.fail(
30+
`\n${color.red('Error!')} Template path ${color.cyan(templatePath)} does not exist.`,
31+
);
32+
process.exit(1);
33+
}
34+
35+
// Create the folder
2436
await mkdir(root, { recursive: true });
2537
if (!isFolderEmpty(root, appName)) {
2638
process.exit(1);
2739
}
2840

41+
// Copy the template files
42+
spinner.text = 'Copying files...';
43+
await cp(join(templatePath, 'root'), root, {
44+
recursive: true,
45+
});
46+
2947
spinner.succeed(
30-
` ${color.green('Success!')} Created ${color.cyan(appName)} at ${color.cyan(root)}`,
48+
`${color.green('Success!')} Created ${color.cyan(appName)} at ${color.cyan(root)}`,
3149
);
3250
};

0 commit comments

Comments
 (0)