@base44-preview/vite-plugin 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/claude-code-review.yml +78 -0
- package/.github/workflows/claude.yml +63 -0
- package/.github/workflows/main-publish.yml +119 -0
- package/.github/workflows/manual-publish.yml +127 -0
- package/.github/workflows/preview-publish.yml +210 -0
- package/.github/workflows/unit-tests.yml +27 -0
- package/compat/base44Client.cjs +6 -0
- package/compat/entities.cjs +11 -0
- package/compat/functions.cjs +9 -0
- package/compat/integrations.cjs +9 -0
- package/package.json +18 -0
- package/src/index.ts +82 -0
- package/tsconfig.json +36 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
name: Claude Code Review
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
types: [opened, synchronize]
|
|
6
|
+
# Optional: Only run on specific file changes
|
|
7
|
+
# paths:
|
|
8
|
+
# - "src/**/*.ts"
|
|
9
|
+
# - "src/**/*.tsx"
|
|
10
|
+
# - "src/**/*.js"
|
|
11
|
+
# - "src/**/*.jsx"
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
claude-review:
|
|
15
|
+
if: |
|
|
16
|
+
github.actor != 'github-actions[bot]' &&
|
|
17
|
+
github.actor != 'claude-code[bot]' &&
|
|
18
|
+
github.actor != 'claude[bot]' &&
|
|
19
|
+
github.actor != 'claude' &&
|
|
20
|
+
github.event.pull_request.head.commit.parents[1] == null
|
|
21
|
+
|
|
22
|
+
runs-on: ubuntu-latest
|
|
23
|
+
permissions:
|
|
24
|
+
contents: read
|
|
25
|
+
pull-requests: read
|
|
26
|
+
issues: read
|
|
27
|
+
id-token: write
|
|
28
|
+
|
|
29
|
+
steps:
|
|
30
|
+
- name: Checkout repository
|
|
31
|
+
uses: actions/checkout@v4
|
|
32
|
+
with:
|
|
33
|
+
fetch-depth: 1
|
|
34
|
+
|
|
35
|
+
- name: Run Claude Code Review
|
|
36
|
+
id: claude-review
|
|
37
|
+
uses: anthropics/claude-code-action@beta
|
|
38
|
+
with:
|
|
39
|
+
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
|
40
|
+
|
|
41
|
+
# Optional: Specify model (defaults to Claude Sonnet 4, uncomment for Claude Opus 4)
|
|
42
|
+
model: "claude-opus-4-20250514"
|
|
43
|
+
|
|
44
|
+
# Direct prompt for automated review (no @claude mention needed)
|
|
45
|
+
direct_prompt: |
|
|
46
|
+
Please review this pull request and provide feedback on:
|
|
47
|
+
- Code quality and best practices
|
|
48
|
+
- Potential bugs or issues
|
|
49
|
+
- Performance considerations
|
|
50
|
+
- Security concerns
|
|
51
|
+
- Test coverage
|
|
52
|
+
|
|
53
|
+
Be constructive and helpful in your feedback.
|
|
54
|
+
|
|
55
|
+
# Optional: Use sticky comments to make Claude reuse the same comment on subsequent pushes to the same PR
|
|
56
|
+
# use_sticky_comment: true
|
|
57
|
+
|
|
58
|
+
# Optional: Customize review based on file types
|
|
59
|
+
# direct_prompt: |
|
|
60
|
+
# Review this PR focusing on:
|
|
61
|
+
# - For TypeScript files: Type safety and proper interface usage
|
|
62
|
+
# - For API endpoints: Security, input validation, and error handling
|
|
63
|
+
# - For React components: Performance, accessibility, and best practices
|
|
64
|
+
# - For tests: Coverage, edge cases, and test quality
|
|
65
|
+
|
|
66
|
+
# Optional: Different prompts for different authors
|
|
67
|
+
# direct_prompt: |
|
|
68
|
+
# ${{ github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR' &&
|
|
69
|
+
# 'Welcome! Please review this PR from a first-time contributor. Be encouraging and provide detailed explanations for any suggestions.' ||
|
|
70
|
+
# 'Please provide a thorough code review focusing on our coding standards and best practices.' }}
|
|
71
|
+
|
|
72
|
+
# Optional: Add specific tools for running tests or linting
|
|
73
|
+
# allowed_tools: "Bash(npm run test),Bash(npm run lint),Bash(npm run typecheck)"
|
|
74
|
+
|
|
75
|
+
# Optional: Skip review for certain conditions
|
|
76
|
+
# if: |
|
|
77
|
+
# !contains(github.event.pull_request.title, '[skip-review]') &&
|
|
78
|
+
# !contains(github.event.pull_request.title, '[WIP]')
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
name: Claude Code
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
issue_comment:
|
|
5
|
+
types: [created]
|
|
6
|
+
pull_request_review_comment:
|
|
7
|
+
types: [created]
|
|
8
|
+
issues:
|
|
9
|
+
types: [opened, assigned]
|
|
10
|
+
pull_request_review:
|
|
11
|
+
types: [submitted]
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
claude:
|
|
15
|
+
if: |
|
|
16
|
+
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
|
|
17
|
+
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
|
|
18
|
+
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
|
|
19
|
+
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
|
|
20
|
+
runs-on: ubuntu-latest
|
|
21
|
+
permissions:
|
|
22
|
+
contents: read
|
|
23
|
+
pull-requests: read
|
|
24
|
+
issues: read
|
|
25
|
+
id-token: write
|
|
26
|
+
actions: read # Required for Claude to read CI results on PRs
|
|
27
|
+
steps:
|
|
28
|
+
- name: Checkout repository
|
|
29
|
+
uses: actions/checkout@v4
|
|
30
|
+
with:
|
|
31
|
+
fetch-depth: 1
|
|
32
|
+
|
|
33
|
+
- name: Run Claude Code
|
|
34
|
+
id: claude
|
|
35
|
+
uses: anthropics/claude-code-action@beta
|
|
36
|
+
with:
|
|
37
|
+
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
|
38
|
+
|
|
39
|
+
# This is an optional setting that allows Claude to read CI results on PRs
|
|
40
|
+
additional_permissions: |
|
|
41
|
+
actions: read
|
|
42
|
+
|
|
43
|
+
# Optional: Specify model (defaults to Claude Sonnet 4, uncomment for Claude Opus 4)
|
|
44
|
+
model: "claude-opus-4-20250514"
|
|
45
|
+
|
|
46
|
+
# Optional: Customize the trigger phrase (default: @claude)
|
|
47
|
+
# trigger_phrase: "/claude"
|
|
48
|
+
|
|
49
|
+
# Optional: Trigger when specific user is assigned to an issue
|
|
50
|
+
# assignee_trigger: "claude-bot"
|
|
51
|
+
|
|
52
|
+
# Optional: Allow Claude to run specific commands
|
|
53
|
+
allowed_tools: "Bash(npm install),Bash(npm run build),Bash(npm run test:*),Bash(npm run lint:*)"
|
|
54
|
+
|
|
55
|
+
# Optional: Add custom instructions for Claude to customize its behavior for your project
|
|
56
|
+
# custom_instructions: |
|
|
57
|
+
# Follow our coding standards
|
|
58
|
+
# Ensure all new code has tests
|
|
59
|
+
# Use TypeScript for new files
|
|
60
|
+
|
|
61
|
+
# Optional: Custom environment variables for Claude
|
|
62
|
+
# claude_env: |
|
|
63
|
+
# NODE_ENV: test
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
name: Package Main Preview Publish
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
publish-main-preview:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
|
|
11
|
+
steps:
|
|
12
|
+
- name: Checkout code
|
|
13
|
+
uses: actions/checkout@v4
|
|
14
|
+
|
|
15
|
+
- name: Enable corepack
|
|
16
|
+
run: corepack enable
|
|
17
|
+
|
|
18
|
+
- name: Setup Node.js
|
|
19
|
+
uses: actions/setup-node@v4
|
|
20
|
+
with:
|
|
21
|
+
node-version: 20
|
|
22
|
+
cache: "npm"
|
|
23
|
+
registry-url: "https://registry.npmjs.org"
|
|
24
|
+
|
|
25
|
+
- name: Install dependencies
|
|
26
|
+
run: npm install
|
|
27
|
+
|
|
28
|
+
- name: Build package
|
|
29
|
+
run: npm run build
|
|
30
|
+
|
|
31
|
+
- name: Generate preview package name and version
|
|
32
|
+
id: preview_info
|
|
33
|
+
run: |
|
|
34
|
+
COMMIT_HASH="${{ github.sha }}"
|
|
35
|
+
SHORT_COMMIT="${COMMIT_HASH:0:7}"
|
|
36
|
+
|
|
37
|
+
# Get current version from package.json
|
|
38
|
+
BASE_VERSION=$(node -p "require('./package.json').version")
|
|
39
|
+
|
|
40
|
+
# Format: 0.3.0-dev.abc1234 (valid semver prerelease)
|
|
41
|
+
PREVIEW_VERSION="$BASE_VERSION-dev.$SHORT_COMMIT"
|
|
42
|
+
|
|
43
|
+
echo "version=$PREVIEW_VERSION" >> $GITHUB_OUTPUT
|
|
44
|
+
echo "package_name=@base44-preview/vite-plugin" >> $GITHUB_OUTPUT
|
|
45
|
+
echo "full_package=@base44-preview/vite-plugin@$PREVIEW_VERSION" >> $GITHUB_OUTPUT
|
|
46
|
+
|
|
47
|
+
- name: Update package.json for preview
|
|
48
|
+
run: |
|
|
49
|
+
# Create a backup of original package.json
|
|
50
|
+
cp package.json package.json.bak
|
|
51
|
+
|
|
52
|
+
# Get the official package name for safety checks
|
|
53
|
+
OFFICIAL_PACKAGE=$(node -p "require('./package.json').name")
|
|
54
|
+
PREVIEW_PACKAGE="${{ steps.preview_info.outputs.package_name }}"
|
|
55
|
+
|
|
56
|
+
echo "Official package: $OFFICIAL_PACKAGE"
|
|
57
|
+
echo "Preview package: $PREVIEW_PACKAGE"
|
|
58
|
+
|
|
59
|
+
# Safety check: Ensure we're not accidentally using the official package name
|
|
60
|
+
if [ "$PREVIEW_PACKAGE" = "$OFFICIAL_PACKAGE" ]; then
|
|
61
|
+
echo "❌ ERROR: Preview package name matches official package name!"
|
|
62
|
+
echo "This would overwrite the official package. Aborting."
|
|
63
|
+
exit 1
|
|
64
|
+
fi
|
|
65
|
+
|
|
66
|
+
# Update name with error handling
|
|
67
|
+
if ! npm pkg set name="$PREVIEW_PACKAGE"; then
|
|
68
|
+
echo "❌ ERROR: Failed to set package name to $PREVIEW_PACKAGE"
|
|
69
|
+
exit 1
|
|
70
|
+
fi
|
|
71
|
+
|
|
72
|
+
# Update version with error handling
|
|
73
|
+
if ! npm pkg set version="${{ steps.preview_info.outputs.version }}"; then
|
|
74
|
+
echo "❌ ERROR: Failed to set package version to ${{ steps.preview_info.outputs.version }}"
|
|
75
|
+
exit 1
|
|
76
|
+
fi
|
|
77
|
+
|
|
78
|
+
echo "✅ Package.json updated successfully"
|
|
79
|
+
|
|
80
|
+
- name: Final safety check before publish
|
|
81
|
+
run: |
|
|
82
|
+
# Double-check package name one more time before publishing
|
|
83
|
+
CURRENT_PACKAGE_NAME=$(node -p "require('./package.json').name")
|
|
84
|
+
OFFICIAL_PACKAGE=$(jq -r '.name' package.json.bak)
|
|
85
|
+
|
|
86
|
+
echo "About to publish: $CURRENT_PACKAGE_NAME"
|
|
87
|
+
|
|
88
|
+
if [ "$CURRENT_PACKAGE_NAME" = "$OFFICIAL_PACKAGE" ]; then
|
|
89
|
+
echo "❌ CRITICAL ERROR: About to publish to official package name!"
|
|
90
|
+
echo "This is not allowed. Check the workflow configuration."
|
|
91
|
+
exit 1
|
|
92
|
+
fi
|
|
93
|
+
|
|
94
|
+
echo "✅ Safety check passed. Package name is safe to publish."
|
|
95
|
+
|
|
96
|
+
- name: Publish preview package
|
|
97
|
+
run: |
|
|
98
|
+
if npm publish --tag preview; then
|
|
99
|
+
echo "✅ Package published successfully"
|
|
100
|
+
else
|
|
101
|
+
echo "❌ Package publish failed"
|
|
102
|
+
exit 1
|
|
103
|
+
fi
|
|
104
|
+
env:
|
|
105
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
106
|
+
|
|
107
|
+
- name: Restore original package.json
|
|
108
|
+
if: always()
|
|
109
|
+
run: |
|
|
110
|
+
if [ -f package.json.bak ]; then
|
|
111
|
+
mv package.json.bak package.json
|
|
112
|
+
echo "✅ Original package.json restored"
|
|
113
|
+
else
|
|
114
|
+
echo "❌ WARNING: Backup file package.json.bak not found"
|
|
115
|
+
echo "This could indicate an earlier step failed"
|
|
116
|
+
fi
|
|
117
|
+
|
|
118
|
+
permissions:
|
|
119
|
+
contents: read
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
name: Manual Package Publish
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch:
|
|
5
|
+
inputs:
|
|
6
|
+
version:
|
|
7
|
+
description: "Version to publish (e.g., 1.0.0, patch, minor, major)"
|
|
8
|
+
required: true
|
|
9
|
+
default: "patch"
|
|
10
|
+
type: string
|
|
11
|
+
npm_tag:
|
|
12
|
+
description: "NPM tag to publish with (e.g., latest, beta, alpha)"
|
|
13
|
+
required: true
|
|
14
|
+
default: "latest"
|
|
15
|
+
type: string
|
|
16
|
+
dry_run:
|
|
17
|
+
description: "Run in dry-run mode (no actual publish)"
|
|
18
|
+
required: false
|
|
19
|
+
default: false
|
|
20
|
+
type: boolean
|
|
21
|
+
|
|
22
|
+
jobs:
|
|
23
|
+
publish:
|
|
24
|
+
runs-on: ubuntu-latest
|
|
25
|
+
|
|
26
|
+
steps:
|
|
27
|
+
- name: Checkout code
|
|
28
|
+
uses: actions/checkout@v4
|
|
29
|
+
with:
|
|
30
|
+
fetch-depth: 0
|
|
31
|
+
|
|
32
|
+
- name: Enable corepack
|
|
33
|
+
run: corepack enable
|
|
34
|
+
|
|
35
|
+
- name: Setup Node.js
|
|
36
|
+
uses: actions/setup-node@v4
|
|
37
|
+
with:
|
|
38
|
+
node-version: 20
|
|
39
|
+
cache: "npm"
|
|
40
|
+
registry-url: "https://registry.npmjs.org"
|
|
41
|
+
|
|
42
|
+
- name: Install dependencies
|
|
43
|
+
run: npm ci
|
|
44
|
+
|
|
45
|
+
- name: Build package
|
|
46
|
+
run: npm run build
|
|
47
|
+
|
|
48
|
+
- name: Check if version needs to be bumped
|
|
49
|
+
id: check-version
|
|
50
|
+
run: |
|
|
51
|
+
if [[ "${{ github.event.inputs.version }}" =~ ^(patch|minor|major)$ ]]; then
|
|
52
|
+
echo "bump_version=true" >> $GITHUB_OUTPUT
|
|
53
|
+
echo "version_type=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
|
|
54
|
+
else
|
|
55
|
+
echo "bump_version=false" >> $GITHUB_OUTPUT
|
|
56
|
+
echo "version_type=" >> $GITHUB_OUTPUT
|
|
57
|
+
fi
|
|
58
|
+
|
|
59
|
+
- name: Bump version
|
|
60
|
+
if: steps.check-version.outputs.bump_version == 'true'
|
|
61
|
+
run: |
|
|
62
|
+
npm version ${{ steps.check-version.outputs.version_type }} --no-git-tag-version
|
|
63
|
+
echo "NEW_VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV
|
|
64
|
+
|
|
65
|
+
- name: Set version manually
|
|
66
|
+
if: steps.check-version.outputs.bump_version == 'false'
|
|
67
|
+
run: |
|
|
68
|
+
npm version ${{ github.event.inputs.version }} --no-git-tag-version
|
|
69
|
+
echo "NEW_VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV
|
|
70
|
+
|
|
71
|
+
- name: Show package info
|
|
72
|
+
run: |
|
|
73
|
+
echo "Package name: $(node -p "require('./package.json').name")"
|
|
74
|
+
echo "Version: ${{ env.NEW_VERSION }}"
|
|
75
|
+
echo "NPM tag: ${{ github.event.inputs.npm_tag }}"
|
|
76
|
+
echo "Dry run: ${{ github.event.inputs.dry_run }}"
|
|
77
|
+
|
|
78
|
+
- name: Publish to NPM
|
|
79
|
+
if: github.event.inputs.dry_run == 'false'
|
|
80
|
+
run: |
|
|
81
|
+
npm publish --tag ${{ github.event.inputs.npm_tag }}
|
|
82
|
+
env:
|
|
83
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
84
|
+
|
|
85
|
+
- name: Dry run publish
|
|
86
|
+
if: github.event.inputs.dry_run == 'true'
|
|
87
|
+
run: |
|
|
88
|
+
npm publish --dry-run --tag ${{ github.event.inputs.npm_tag }}
|
|
89
|
+
|
|
90
|
+
- name: Create Git tag
|
|
91
|
+
if: github.event.inputs.dry_run == 'false'
|
|
92
|
+
run: |
|
|
93
|
+
git config --local user.email "action@github.com"
|
|
94
|
+
git config --local user.name "GitHub Action"
|
|
95
|
+
git add package.json package-lock.json
|
|
96
|
+
git commit -m "chore: bump version to ${{ env.NEW_VERSION }}"
|
|
97
|
+
git tag v${{ env.NEW_VERSION }}
|
|
98
|
+
git push origin HEAD:${{ github.ref }}
|
|
99
|
+
git push origin v${{ env.NEW_VERSION }}
|
|
100
|
+
|
|
101
|
+
- name: Create Release
|
|
102
|
+
if: github.event.inputs.dry_run == 'false'
|
|
103
|
+
uses: actions/create-release@v1
|
|
104
|
+
env:
|
|
105
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
106
|
+
with:
|
|
107
|
+
tag_name: v${{ env.NEW_VERSION }}
|
|
108
|
+
release_name: Release v${{ env.NEW_VERSION }}
|
|
109
|
+
body: |
|
|
110
|
+
## What's Changed
|
|
111
|
+
|
|
112
|
+
This release includes the latest updates to the Base44 Vite Plugin.
|
|
113
|
+
|
|
114
|
+
### Installation
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
npm install @base44/vite-plugin@${{ github.event.inputs.npm_tag }}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Version: ${{ env.NEW_VERSION }}
|
|
121
|
+
### NPM Tag: ${{ github.event.inputs.npm_tag }}
|
|
122
|
+
draft: false
|
|
123
|
+
prerelease: false
|
|
124
|
+
|
|
125
|
+
permissions:
|
|
126
|
+
contents: write
|
|
127
|
+
packages: write
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
name: Package Preview Publish
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
types: [opened, synchronize, reopened]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
publish-preview:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
|
|
11
|
+
steps:
|
|
12
|
+
- name: Checkout code
|
|
13
|
+
uses: actions/checkout@v4
|
|
14
|
+
|
|
15
|
+
- name: Enable corepack
|
|
16
|
+
run: corepack enable
|
|
17
|
+
|
|
18
|
+
- name: Setup Node.js
|
|
19
|
+
uses: actions/setup-node@v4
|
|
20
|
+
with:
|
|
21
|
+
node-version: 20
|
|
22
|
+
cache: "npm"
|
|
23
|
+
registry-url: "https://registry.npmjs.org"
|
|
24
|
+
|
|
25
|
+
- name: Install dependencies
|
|
26
|
+
run: npm install
|
|
27
|
+
|
|
28
|
+
- name: Build package
|
|
29
|
+
run: npm run build
|
|
30
|
+
|
|
31
|
+
- name: Generate preview package name and version
|
|
32
|
+
id: preview_info
|
|
33
|
+
run: |
|
|
34
|
+
PR_NUMBER="${{ github.event.number }}"
|
|
35
|
+
COMMIT_HASH="${{ github.sha }}"
|
|
36
|
+
SHORT_COMMIT="${COMMIT_HASH:0:7}"
|
|
37
|
+
|
|
38
|
+
# Get current version from package.json
|
|
39
|
+
BASE_VERSION=$(node -p "require('./package.json').version")
|
|
40
|
+
|
|
41
|
+
if [ ! -z "$PR_NUMBER" ]; then
|
|
42
|
+
# Format: 0.3.0-pr.123.abc1234 (valid semver prerelease)
|
|
43
|
+
PREVIEW_VERSION="$BASE_VERSION-pr.$PR_NUMBER.$SHORT_COMMIT"
|
|
44
|
+
else
|
|
45
|
+
# Format: 0.3.0-dev.abc1234 (valid semver prerelease)
|
|
46
|
+
PREVIEW_VERSION="$BASE_VERSION-dev.$SHORT_COMMIT"
|
|
47
|
+
fi
|
|
48
|
+
|
|
49
|
+
echo "version=$PREVIEW_VERSION" >> $GITHUB_OUTPUT
|
|
50
|
+
echo "package_name=@base44-preview/vite-plugin" >> $GITHUB_OUTPUT
|
|
51
|
+
echo "full_package=@base44-preview/vite-plugin@$PREVIEW_VERSION" >> $GITHUB_OUTPUT
|
|
52
|
+
|
|
53
|
+
- name: Update package.json for preview
|
|
54
|
+
run: |
|
|
55
|
+
# Create a backup of original package.json
|
|
56
|
+
cp package.json package.json.bak
|
|
57
|
+
|
|
58
|
+
# Get the official package name for safety checks
|
|
59
|
+
OFFICIAL_PACKAGE=$(node -p "require('./package.json').name")
|
|
60
|
+
PREVIEW_PACKAGE="${{ steps.preview_info.outputs.package_name }}"
|
|
61
|
+
|
|
62
|
+
echo "Official package: $OFFICIAL_PACKAGE"
|
|
63
|
+
echo "Preview package: $PREVIEW_PACKAGE"
|
|
64
|
+
|
|
65
|
+
# Safety check: Ensure we're not accidentally using the official package name
|
|
66
|
+
if [ "$PREVIEW_PACKAGE" = "$OFFICIAL_PACKAGE" ]; then
|
|
67
|
+
echo "❌ ERROR: Preview package name matches official package name!"
|
|
68
|
+
echo "This would overwrite the official package. Aborting."
|
|
69
|
+
exit 1
|
|
70
|
+
fi
|
|
71
|
+
|
|
72
|
+
# Update name with error handling
|
|
73
|
+
if ! npm pkg set name="$PREVIEW_PACKAGE"; then
|
|
74
|
+
echo "❌ ERROR: Failed to set package name to $PREVIEW_PACKAGE"
|
|
75
|
+
exit 1
|
|
76
|
+
fi
|
|
77
|
+
|
|
78
|
+
# Update version with error handling
|
|
79
|
+
if ! npm pkg set version="${{ steps.preview_info.outputs.version }}"; then
|
|
80
|
+
echo "❌ ERROR: Failed to set package version to ${{ steps.preview_info.outputs.version }}"
|
|
81
|
+
exit 1
|
|
82
|
+
fi
|
|
83
|
+
|
|
84
|
+
echo "✅ Package.json updated successfully"
|
|
85
|
+
|
|
86
|
+
- name: Final safety check before publish
|
|
87
|
+
run: |
|
|
88
|
+
# Double-check package name one more time before publishing
|
|
89
|
+
CURRENT_PACKAGE_NAME=$(node -p "require('./package.json').name")
|
|
90
|
+
OFFICIAL_PACKAGE=$(jq -r '.name' package.json.bak)
|
|
91
|
+
|
|
92
|
+
echo "About to publish: $CURRENT_PACKAGE_NAME"
|
|
93
|
+
|
|
94
|
+
if [ "$CURRENT_PACKAGE_NAME" = "$OFFICIAL_PACKAGE" ]; then
|
|
95
|
+
echo "❌ CRITICAL ERROR: About to publish to official package name!"
|
|
96
|
+
echo "This is not allowed. Check the workflow configuration."
|
|
97
|
+
exit 1
|
|
98
|
+
fi
|
|
99
|
+
|
|
100
|
+
echo "✅ Safety check passed. Package name is safe to publish."
|
|
101
|
+
|
|
102
|
+
- name: Publish preview package
|
|
103
|
+
run: |
|
|
104
|
+
if npm publish --tag preview; then
|
|
105
|
+
echo "✅ Package published successfully"
|
|
106
|
+
else
|
|
107
|
+
echo "❌ Package publish failed"
|
|
108
|
+
exit 1
|
|
109
|
+
fi
|
|
110
|
+
env:
|
|
111
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
112
|
+
|
|
113
|
+
- name: Restore original package.json
|
|
114
|
+
if: always()
|
|
115
|
+
run: |
|
|
116
|
+
if [ -f package.json.bak ]; then
|
|
117
|
+
mv package.json.bak package.json
|
|
118
|
+
echo "✅ Original package.json restored"
|
|
119
|
+
else
|
|
120
|
+
echo "❌ WARNING: Backup file package.json.bak not found"
|
|
121
|
+
echo "This could indicate an earlier step failed"
|
|
122
|
+
fi
|
|
123
|
+
|
|
124
|
+
- name: Comment PR with install instructions
|
|
125
|
+
uses: actions/github-script@v6
|
|
126
|
+
with:
|
|
127
|
+
script: |
|
|
128
|
+
const fullPackage = '${{ steps.preview_info.outputs.full_package }}';
|
|
129
|
+
const installCmd = `npm i ${fullPackage}`;
|
|
130
|
+
const aliasInstallCmd = `npm i "@base44/vite-plugin@npm:${fullPackage}"`;
|
|
131
|
+
|
|
132
|
+
const body = `### 🚀 Package Preview Available!
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
**Install this PR's preview build with npm:**
|
|
137
|
+
|
|
138
|
+
\`\`\`sh
|
|
139
|
+
${installCmd}
|
|
140
|
+
\`\`\`
|
|
141
|
+
|
|
142
|
+
**Prefer not to change any import paths? Install using npm alias so your code still imports \`@base44/vite-plugin\`:**
|
|
143
|
+
|
|
144
|
+
\`\`\`sh
|
|
145
|
+
${aliasInstallCmd}
|
|
146
|
+
\`\`\`
|
|
147
|
+
|
|
148
|
+
Or add it to your \`package.json\` dependencies:
|
|
149
|
+
|
|
150
|
+
\`\`\`json
|
|
151
|
+
{
|
|
152
|
+
"dependencies": {
|
|
153
|
+
"@base44/vite-plugin": "npm:${fullPackage}"
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
\`\`\`
|
|
157
|
+
|
|
158
|
+
- 📦 **Preview Package**: \`${fullPackage}\`
|
|
159
|
+
- 🔗 [View this commit on GitHub](https://github.com/${{ github.repository }}/commit/${{ github.sha }})
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
<sub>Preview published to npm registry — try new features instantly!</sub>`;
|
|
163
|
+
|
|
164
|
+
const botCommentIdentifier = '### 🚀 Package Preview Available!';
|
|
165
|
+
|
|
166
|
+
async function findBotComment(issueNumber) {
|
|
167
|
+
if (!issueNumber) return null;
|
|
168
|
+
const comments = await github.rest.issues.listComments({
|
|
169
|
+
owner: context.repo.owner,
|
|
170
|
+
repo: context.repo.repo,
|
|
171
|
+
issue_number: issueNumber,
|
|
172
|
+
});
|
|
173
|
+
return comments.data.find((comment) =>
|
|
174
|
+
comment.body.includes(botCommentIdentifier)
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
async function createOrUpdateComment(issueNumber) {
|
|
179
|
+
if (!issueNumber) {
|
|
180
|
+
console.log('No issue number provided. Cannot post or update comment.');
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const existingComment = await findBotComment(issueNumber);
|
|
185
|
+
if (existingComment) {
|
|
186
|
+
await github.rest.issues.updateComment({
|
|
187
|
+
owner: context.repo.owner,
|
|
188
|
+
repo: context.repo.repo,
|
|
189
|
+
comment_id: existingComment.id,
|
|
190
|
+
body: body,
|
|
191
|
+
});
|
|
192
|
+
} else {
|
|
193
|
+
await github.rest.issues.createComment({
|
|
194
|
+
issue_number: issueNumber,
|
|
195
|
+
owner: context.repo.owner,
|
|
196
|
+
repo: context.repo.repo,
|
|
197
|
+
body: body,
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
if (context.eventName === 'pull_request') {
|
|
203
|
+
if (context.issue.number) {
|
|
204
|
+
await createOrUpdateComment(context.issue.number);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
permissions:
|
|
209
|
+
contents: read
|
|
210
|
+
pull-requests: write
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
name: Unit Tests
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
|
|
13
|
+
steps:
|
|
14
|
+
- name: Checkout code
|
|
15
|
+
uses: actions/checkout@v4
|
|
16
|
+
|
|
17
|
+
- name: Use Node.js 20.x
|
|
18
|
+
uses: actions/setup-node@v4
|
|
19
|
+
with:
|
|
20
|
+
node-version: "20.x"
|
|
21
|
+
cache: "npm"
|
|
22
|
+
|
|
23
|
+
- name: Install dependencies
|
|
24
|
+
run: npm ci
|
|
25
|
+
|
|
26
|
+
- name: Run unit tests
|
|
27
|
+
run: npm run test:unit
|
package/package.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@base44-preview/vite-plugin",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "The Vite plugin for base44 based applications",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc"
|
|
12
|
+
},
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"@types/node": "^24.6.2",
|
|
15
|
+
"typescript": "^5.9.3",
|
|
16
|
+
"vite": "^7.1.9"
|
|
17
|
+
}
|
|
18
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { Plugin } from "vite";
|
|
2
|
+
import { loadEnv } from "vite";
|
|
3
|
+
|
|
4
|
+
export default function vitePlugin() {
|
|
5
|
+
return {
|
|
6
|
+
name: "base44",
|
|
7
|
+
config: ({ mode }) => {
|
|
8
|
+
const env = loadEnv(mode ?? "development", process.cwd(), "");
|
|
9
|
+
|
|
10
|
+
return {
|
|
11
|
+
resolve: {
|
|
12
|
+
alias: {
|
|
13
|
+
"@/": "/src/",
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
server: {
|
|
17
|
+
host: "0.0.0.0", // Bind to all interfaces for container access
|
|
18
|
+
port: 5173,
|
|
19
|
+
strictPort: true,
|
|
20
|
+
// Allow all hosts - essential for Modal tunnel URLs
|
|
21
|
+
allowedHosts: true,
|
|
22
|
+
watch: {
|
|
23
|
+
// Enable polling for better file change detection in containers
|
|
24
|
+
usePolling: true,
|
|
25
|
+
interval: 100, // Check every 100ms for responsive HMR
|
|
26
|
+
},
|
|
27
|
+
hmr: {
|
|
28
|
+
protocol: "wss",
|
|
29
|
+
clientPort: 443,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
optimizeDeps: {
|
|
33
|
+
esbuildOptions: {
|
|
34
|
+
define: {
|
|
35
|
+
"process.env.VITE_BASE44_APP_ID": JSON.stringify(
|
|
36
|
+
env.VITE_BASE44_APP_ID
|
|
37
|
+
),
|
|
38
|
+
"process.env.VITE_BASE44_BACKEND_URL": JSON.stringify(
|
|
39
|
+
env.VITE_BASE44_SERVER_URL
|
|
40
|
+
),
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
},
|
|
46
|
+
configureServer(server) {
|
|
47
|
+
server.middlewares.use((req, res, next) => {
|
|
48
|
+
// Allow iframe embedding
|
|
49
|
+
res.setHeader("X-Frame-Options", "ALLOWALL");
|
|
50
|
+
res.setHeader("Content-Security-Policy", "frame-ancestors *;");
|
|
51
|
+
next();
|
|
52
|
+
});
|
|
53
|
+
},
|
|
54
|
+
resolveId(source, importer, options) {
|
|
55
|
+
if (source.includes("/entities")) {
|
|
56
|
+
return this.resolve(
|
|
57
|
+
"@base44/vite-plugin/compat/entities.cjs",
|
|
58
|
+
importer,
|
|
59
|
+
options
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (source.includes("/functions")) {
|
|
64
|
+
return this.resolve(
|
|
65
|
+
"@base44/vite-plugin/compat/functions.cjs",
|
|
66
|
+
importer,
|
|
67
|
+
options
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (source.includes("/integrations")) {
|
|
72
|
+
return this.resolve(
|
|
73
|
+
"@base44/vite-plugin/compat/integrations.cjs",
|
|
74
|
+
importer,
|
|
75
|
+
options
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return null;
|
|
80
|
+
},
|
|
81
|
+
} as Plugin;
|
|
82
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"outDir": "./dist",
|
|
4
|
+
|
|
5
|
+
// Environment Settings
|
|
6
|
+
"module": "nodenext",
|
|
7
|
+
"lib": ["esnext"],
|
|
8
|
+
"types": ["node"],
|
|
9
|
+
|
|
10
|
+
// Other Outputs
|
|
11
|
+
"sourceMap": true,
|
|
12
|
+
"declaration": true,
|
|
13
|
+
"declarationMap": true,
|
|
14
|
+
|
|
15
|
+
// Stricter Typechecking Options
|
|
16
|
+
"noUncheckedIndexedAccess": true,
|
|
17
|
+
"exactOptionalPropertyTypes": true,
|
|
18
|
+
|
|
19
|
+
// Style Options
|
|
20
|
+
// "noImplicitReturns": true,
|
|
21
|
+
// "noImplicitOverride": true,
|
|
22
|
+
// "noUnusedLocals": true,
|
|
23
|
+
// "noUnusedParameters": true,
|
|
24
|
+
// "noFallthroughCasesInSwitch": true,
|
|
25
|
+
// "noPropertyAccessFromIndexSignature": true,
|
|
26
|
+
|
|
27
|
+
// Recommended Options
|
|
28
|
+
"strict": true,
|
|
29
|
+
"jsx": "react-jsx",
|
|
30
|
+
"verbatimModuleSyntax": true,
|
|
31
|
+
"isolatedModules": true,
|
|
32
|
+
"noUncheckedSideEffectImports": true,
|
|
33
|
+
"moduleDetection": "force",
|
|
34
|
+
"skipLibCheck": true,
|
|
35
|
+
}
|
|
36
|
+
}
|