Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
version: 10.8.0
version: 10.10.0

- name: Install Node.js
uses: actions/setup-node@v4
Expand Down
66 changes: 66 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Test publish version

on:
workflow_dispatch:
inputs:
release:
description: stable, canary, or release candidate?
required: true
type: choice
options:
- canary
- stable
- release-candidate
type:
description: 'Type of package to publish'
required: true
type: choice
options:
- patch
- minor
- major
skip_bump_version:
description: 'Skip bumping version in package.json and release notes?'
required: false
type: boolean

jobs:
bump-version:
name: 'Bump Version'
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Configure Git
run: |
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor }}@users.noreply.github.com"

- uses: pnpm/action-setup@v4
name: Install pnpm
with:
version: 10.10.0

- name: Install Node.js
uses: actions/setup-node@v4
with:
registry-url: 'https://registry.npmjs.org/'
node-version: 22

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Run script to bump version & copy files
run: pnpm run release
id: version-bump
env:
VERSION_TYPE: ${{ github.event.inputs.type }}
RELEASE_TYPE: ${{ github.event.inputs.release }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_USER: ${{ github.actor }}
GITHUB_EMAIL: ${{ github.actor }}@users.noreply.github.com
18 changes: 18 additions & 0 deletions bump-version.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const ALLOWED_VERSION_TYPES = ['major', 'minor', 'patch'];
const WORKSPACE = process.env.GITHUB_WORKSPACE || process.cwd();
const GIT_USER = {
NAME: process.env.GITHUB_USER ?? 'Automated Version Bump',
EMAIL: process.env.GITHUB_EMAIL
? `${process.env.GITHUB_USER}@users.noreply.github.com`
: 'gh-action-bump-version@users.noreply.github.com',
};

const init = () => {
console.log(
'Initializing build version script...',
GIT_USER.EMAIL,
GIT_USER.NAME,
);
};

init();
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "vitnode",
"private": true,
"scripts": {
"release": "node ./bump-version.mjs",
"db:migrate": "turbo db:migrate",
"db:push": "turbo db:push",
"docker:dev": "docker compose -f ./docker-compose.yml -p vitnode-dev-dun up -d",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import vitnodePrettier from "eslint-config-typescript-vitnode/prettierrc";

/**
* @see https://prettier.io/docs/en/configuration.html
* @type {import("prettier").Config}
*/
const config = {
...vitnodePrettier,
};

export default config;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import eslintVitNode from 'eslint-config-typescript-vitnode/eslint';

export default [...eslintVitNode];
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { NextConfig } from 'next';
import { vitNodeNextConfig } from '@vitnode/core/config/next.config';

const nextConfig: NextConfig = {
experimental: {
inlineCss: true,
reactCompiler: true,
},
};

export default vitNodeNextConfig(nextConfig);
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { buildApiConfig } from '@vitnode/core/vitnode.config';

export const vitNodeApiConfig = buildApiConfig({
plugins: [],
});
3 changes: 3 additions & 0 deletions packages/create-vitnode-app/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ export default [
'no-console': 'off',
},
},
{
ignores: ['copy-of-vitnode-app'],
},
];
2 changes: 1 addition & 1 deletion packages/create-vitnode-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"create-vitnode-app": "dist/src/index.js"
},
"scripts": {
"build:cli": "tsc",
"build:cli": "tsc && node dist/src/prepare/prepare.js",
"cli": "node dist/src/index.js",
"lint": "eslint .",
"lint:fix": "eslint . --fix"
Expand Down
27 changes: 22 additions & 5 deletions packages/create-vitnode-app/src/create/create-vitnode.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { mkdir } from 'fs/promises';
import { existsSync } from 'fs';
import { cp, mkdir } from 'fs/promises';
import ora from 'ora';
import { dirname, join } from 'path';
import color from 'picocolors';
import { fileURLToPath } from 'url';

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

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

/**
* Create the folder
*/
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const templatePath = join(__dirname, '..', '..', '..', 'copy-of-vitnode-app');
if (!existsSync(templatePath)) {
spinner.fail(
`\n${color.red('Error!')} Template path ${color.cyan(templatePath)} does not exist.`,
);
process.exit(1);
}

// Create the folder
await mkdir(root, { recursive: true });
if (!isFolderEmpty(root, appName)) {
process.exit(1);
}

// Copy the template files
spinner.text = 'Copying files...';
await cp(join(templatePath, 'root'), root, {
recursive: true,
});

spinner.succeed(
` ${color.green('Success!')} Created ${color.cyan(appName)} at ${color.cyan(root)}`,
`${color.green('Success!')} Created ${color.cyan(appName)} at ${color.cyan(root)}`,
);
};
21 changes: 21 additions & 0 deletions packages/create-vitnode-app/src/prepare/prepare.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { existsSync } from 'fs';
import { mkdir } from 'fs/promises';
import { join } from 'path';

const prepare = async () => {
const toRootPath = join(process.cwd(), 'copy-of-vitnode-app');
if (!existsSync(toRootPath)) {
await mkdir(toRootPath);
}
const fromRootPath = join(process.cwd(), '..', '..', 'apps', 'web');
if (!existsSync(fromRootPath)) {
console.error(
`\x1b[31mThe path ${fromRootPath} does not exist. Please check the directory structure.\x1b[0m`,
);
process.exit(1);
}

console.log(`Project path: ${fromRootPath}`);
};

void prepare();
Loading