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
5 changes: 5 additions & 0 deletions .changeset/chilly-pugs-cross.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@cloudflare/sandbox': patch
---

Update dependencies
7 changes: 7 additions & 0 deletions .changeset/giant-paths-enjoy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@cloudflare/sandbox': patch
---

Fix type generation

We inline types from `@repo/shared` so that it includes the types we reexport. Fixes #165
10 changes: 5 additions & 5 deletions .github/changeset-publish.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { execSync } from "node:child_process";
import { execSync } from 'node:child_process';

execSync("npx tsx ./.github/resolve-workspace-versions.ts", {
stdio: "inherit",
execSync('npx tsx ./.github/resolve-workspace-versions.ts', {
stdio: 'inherit'
});
execSync("npx changeset publish", {
stdio: "inherit",
execSync('npx changeset publish', {
stdio: 'inherit'
});
91 changes: 51 additions & 40 deletions .github/changeset-version.ts
Original file line number Diff line number Diff line change
@@ -1,102 +1,106 @@
import { execSync } from "node:child_process";
import * as fs from "node:fs";
import fg from "fast-glob";
import { execSync } from 'node:child_process';
import * as fs from 'node:fs';
import fg from 'fast-glob';

// This script is used by the `release.yml` workflow to update the version of the packages being released.
// The standard step is only to run `changeset version` but this does not update the package-lock.json file.
// So we also run `npm install`, which does this update.
// This is a workaround until this is handled automatically by `changeset version`.
// See https://github.com/changesets/changesets/issues/421.
execSync("npx changeset version", {
stdio: "inherit",
execSync('npx changeset version', {
stdio: 'inherit'
});
execSync("npm install", {
stdio: "inherit",
execSync('npm install', {
stdio: 'inherit'
});

// Update all version references across the codebase after changeset updates package.json
try {
const packageJson = JSON.parse(fs.readFileSync("./packages/sandbox/package.json", "utf-8"));
const packageJson = JSON.parse(
fs.readFileSync('./packages/sandbox/package.json', 'utf-8')
);
const newVersion = packageJson.version;

console.log(`\n🔍 Searching for version references to update to ${newVersion}...\n`);
console.log(
`\n🔍 Searching for version references to update to ${newVersion}...\n`
);

// Patterns to match version references in different contexts
const versionPatterns = [
// SDK version constant
{
pattern: /export const SDK_VERSION = '[\d.]+';/g,
replacement: `export const SDK_VERSION = '${newVersion}';`,
description: "SDK version constant in version.ts",
description: 'SDK version constant in version.ts'
},
// Docker image versions (production and test)
{
pattern: /FROM docker\.io\/cloudflare\/sandbox:[\d.]+/g,
replacement: `FROM docker.io/cloudflare/sandbox:${newVersion}`,
description: "Production Docker image",
description: 'Production Docker image'
},
{
pattern: /# FROM docker\.io\/cloudflare\/sandbox:[\d.]+/g,
replacement: `# FROM docker.io/cloudflare/sandbox:${newVersion}`,
description: "Commented production Docker image",
description: 'Commented production Docker image'
},
{
pattern: /FROM cloudflare\/sandbox-test:[\d.]+/g,
replacement: `FROM cloudflare/sandbox-test:${newVersion}`,
description: "Test Docker image",
description: 'Test Docker image'
},
{
pattern: /docker\.io\/cloudflare\/sandbox-test:[\d.]+/g,
replacement: `docker.io/cloudflare/sandbox-test:${newVersion}`,
description: "Test Docker image (docker.io)",
description: 'Test Docker image (docker.io)'
},
// Image tags in docker commands
{
pattern: /cloudflare\/sandbox:[\d.]+/g,
replacement: `cloudflare/sandbox:${newVersion}`,
description: "Docker image reference",
description: 'Docker image reference'
},
{
pattern: /cloudflare\/sandbox-test:[\d.]+/g,
replacement: `cloudflare/sandbox-test:${newVersion}`,
description: "Test Docker image reference",
description: 'Test Docker image reference'
},
// Example package.json dependencies
{
pattern: /"@cloudflare\/sandbox":\s*"\^[\d.]+"/g,
replacement: `"@cloudflare/sandbox": "^${newVersion}"`,
description: "Example package.json @cloudflare/sandbox dependencies",
},
description: 'Example package.json @cloudflare/sandbox dependencies'
}
];

// Files to search and update
const filePatterns = [
"**/*.md", // All markdown files
"**/Dockerfile", // All Dockerfiles
"**/Dockerfile.*", // Dockerfile variants
"**/*.ts", // TypeScript files (for documentation comments)
"**/*.js", // JavaScript files
"**/*.json", // JSON configs (but not package.json/package-lock.json)
"**/*.yaml", // YAML configs
"**/*.yml", // YML configs
"examples/**/package.json", // Example package.json files (exception to ignore rule below)
'**/*.md', // All markdown files
'**/Dockerfile', // All Dockerfiles
'**/Dockerfile.*', // Dockerfile variants
'**/*.ts', // TypeScript files (for documentation comments)
'**/*.js', // JavaScript files
'**/*.json', // JSON configs (but not package.json/package-lock.json)
'**/*.yaml', // YAML configs
'**/*.yml', // YML configs
'examples/**/package.json' // Example package.json files (exception to ignore rule below)
];

// Ignore patterns
const ignorePatterns = [
"**/node_modules/**",
"**/dist/**",
"**/build/**",
"**/.git/**",
"**/package.json", // Don't modify package.json (changeset does this)
"**/package-lock.json", // Don't modify package-lock.json (npm install does this)
"**/.github/changeset-version.ts", // Don't modify this script itself
'**/node_modules/**',
'**/dist/**',
'**/build/**',
'**/.git/**',
'**/package.json', // Don't modify package.json (changeset does this)
'**/package-lock.json', // Don't modify package-lock.json (npm install does this)
'**/.github/changeset-version.ts' // Don't modify this script itself
];

// Find all matching files
const files = await fg(filePatterns, {
ignore: ignorePatterns,
onlyFiles: true,
onlyFiles: true
});

console.log(`📁 Found ${files.length} files to check\n`);
Expand All @@ -105,7 +109,7 @@ try {
let totalReplacementsCount = 0;

for (const file of files) {
let content = fs.readFileSync(file, "utf-8");
let content = fs.readFileSync(file, 'utf-8');
let fileModified = false;
let fileReplacementsCount = 0;

Expand All @@ -123,14 +127,21 @@ try {
fs.writeFileSync(file, content);
updatedFilesCount++;
totalReplacementsCount += fileReplacementsCount;
console.log(` ✅ ${file} (${fileReplacementsCount} replacement${fileReplacementsCount > 1 ? 's' : ''})`);
console.log(
` ✅ ${file} (${fileReplacementsCount} replacement${
fileReplacementsCount > 1 ? 's' : ''
})`
);
}
}

console.log(`\n✨ Updated ${totalReplacementsCount} version reference${totalReplacementsCount !== 1 ? 's' : ''} across ${updatedFilesCount} file${updatedFilesCount !== 1 ? 's' : ''}`);
console.log(
`\n✨ Updated ${totalReplacementsCount} version reference${
totalReplacementsCount !== 1 ? 's' : ''
} across ${updatedFilesCount} file${updatedFilesCount !== 1 ? 's' : ''}`
);
console.log(` New version: ${newVersion}\n`);

} catch (error) {
console.error("❌ Failed to update file versions:", error);
console.error('❌ Failed to update file versions:', error);
// Don't fail the whole release for this
}
20 changes: 10 additions & 10 deletions .github/resolve-workspace-versions.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// this looks for all package.jsons in /packages/**/package.json
// and replaces it with the actual version ids

import * as fs from "node:fs";
import fg from "fast-glob";
import * as fs from 'node:fs';
import fg from 'fast-glob';

// we do this in 2 passes
// first let's cycle through all packages and get thier version numbers
Expand All @@ -11,12 +11,12 @@ import fg from "fast-glob";
const packageJsons: Record<string, any> = {};

for await (const file of await fg.glob(
"./(packages|examples|guides)/*/package.json"
'./(packages|examples|guides)/*/package.json'
)) {
const packageJson = JSON.parse(fs.readFileSync(file, "utf8"));
const packageJson = JSON.parse(fs.readFileSync(file, 'utf8'));
packageJsons[packageJson.name] = {
file,
packageJson,
packageJson
};
}

Expand All @@ -28,17 +28,17 @@ for (const [packageName, { file, packageJson }] of Object.entries(
)) {
let changed = false;
for (const field of [
"dependencies",
"devDependencies",
"peerDependencies",
"optionalDependencies",
'dependencies',
'devDependencies',
'peerDependencies',
'optionalDependencies'
]) {
for (const [dependencyName, dependencyVersion] of Object.entries(
packageJson[field] || {}
)) {
if (dependencyName in packageJsons) {
let actualVersion = packageJsons[dependencyName].packageJson.version;
if (!actualVersion.startsWith("0.0.0-")) {
if (!actualVersion.startsWith('0.0.0-')) {
actualVersion = `^${actualVersion}`;
}

Expand Down
14 changes: 7 additions & 7 deletions .github/version-script.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import * as fs from "node:fs";
import { execSync } from "node:child_process";
import * as fs from 'node:fs';
import { execSync } from 'node:child_process';
async function main() {
try {
console.log("Getting current git hash...");
const stdout = execSync("git rev-parse --short HEAD").toString();
console.log("Git hash:", stdout.trim());
console.log('Getting current git hash...');
const stdout = execSync('git rev-parse --short HEAD').toString();
console.log('Git hash:', stdout.trim());

for (const path of ["./packages/sandbox/package.json"]) {
const packageJson = JSON.parse(fs.readFileSync(path, "utf-8"));
for (const path of ['./packages/sandbox/package.json']) {
const packageJson = JSON.parse(fs.readFileSync(path, 'utf-8'));
packageJson.version = `0.0.0-${stdout.trim()}`;
fs.writeFileSync(path, `${JSON.stringify(packageJson, null, 2)}\n`);
}
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/claude-code-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,3 @@ jobs:
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
# or https://docs.claude.com/en/docs/claude-code/cli-reference for available options
claude_args: '--allowed-tools "Bash(gh issue view:*),Bash(gh search:*),Bash(gh issue list:*),Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh pr list:*),Bash(gh api:*)"'

1 change: 0 additions & 1 deletion .github/workflows/claude.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,3 @@ jobs:
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
# or https://docs.claude.com/en/docs/claude-code/cli-reference for available options
# claude_args: '--allowed-tools Bash(gh pr:*)'

2 changes: 1 addition & 1 deletion .github/workflows/cleanup-stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: 24
cache: "npm"
cache: 'npm'

- name: Install dependencies
run: npm ci
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cleanup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: 24
cache: "npm"
cache: 'npm'

- name: Install dependencies
run: npm ci
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/pkg-pr-new.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ on:
- '!**/*.md'
- '!.changeset/**'


jobs:
publish-preview:
runs-on: ubuntu-latest
Expand All @@ -28,7 +27,7 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: 24
cache: "npm"
cache: 'npm'

- name: Setup Bun
uses: oven-sh/setup-bun@v2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pullrequest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: 24
cache: "npm"
cache: 'npm'

- uses: oven-sh/setup-bun@v2
with:
Expand Down Expand Up @@ -72,7 +72,7 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: 24
cache: "npm"
cache: 'npm'

- uses: oven-sh/setup-bun@v2
with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: 24
cache: "npm"
cache: 'npm'

- uses: oven-sh/setup-bun@v2
with:
Expand Down Expand Up @@ -78,7 +78,7 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: 24
cache: "npm"
cache: 'npm'

- uses: oven-sh/setup-bun@v2
with:
Expand Down Expand Up @@ -131,7 +131,7 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: 24
cache: "npm"
cache: 'npm'

- uses: oven-sh/setup-bun@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .mcp.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
}
}
}
}
}
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
packages/sandbox/CHANGELOG.md

# Auto-generated Wrangler type files
**/worker-configuration.d.ts
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"trailingComma": "none",
"singleQuote": true
}
Loading
Loading