Add project files
This commit is contained in:
66
scripts/README.md
Normal file
66
scripts/README.md
Normal file
@@ -0,0 +1,66 @@
|
||||
# Scripts
|
||||
|
||||
This directory contains utility scripts for the project.
|
||||
|
||||
## extract-codebase.ts
|
||||
|
||||
A script that extracts code files from a directory, respecting `.gitignore` rules, and outputs them in a format suitable for LLM consumption.
|
||||
|
||||
### Usage
|
||||
|
||||
```bash
|
||||
# Make the script executable first
|
||||
chmod +x scripts/extract-codebase.ts
|
||||
|
||||
# Run with default options (current directory, output to codebase-extract.md)
|
||||
./scripts/extract-codebase.ts
|
||||
|
||||
# Specify a source directory and output file
|
||||
./scripts/extract-codebase.ts ./src ./output.md
|
||||
```
|
||||
|
||||
### Features
|
||||
|
||||
- Walks through the specified directory recursively
|
||||
- Respects all `.gitignore` rules
|
||||
- Extracts files with extensions: .ts, .tsx, .js, .jsx, .css
|
||||
- Formats output with markdown code blocks, including file paths
|
||||
- Writes all extracted code to a single markdown file
|
||||
|
||||
## verify-release-assets.js
|
||||
|
||||
A script that verifies all expected binary assets are present in the GitHub release for the current version in `package.json`.
|
||||
|
||||
### Usage
|
||||
|
||||
```bash
|
||||
# Set GITHUB_TOKEN environment variable
|
||||
export GITHUB_TOKEN=your_github_token
|
||||
|
||||
# Run the verification script
|
||||
npm run verify-release
|
||||
|
||||
# Or run directly
|
||||
node scripts/verify-release-assets.js
|
||||
```
|
||||
|
||||
### Expected Assets
|
||||
|
||||
The script verifies the presence of these 7 assets for each release:
|
||||
|
||||
1. `dyad-{version}-1.x86_64.rpm` (Linux RPM)
|
||||
2. `dyad-{version}-full.nupkg` (Windows NuGet package)
|
||||
3. `dyad-{version}.Setup.exe` (Windows installer)
|
||||
4. `dyad-darwin-arm64-{version}.zip` (macOS Apple Silicon)
|
||||
5. `dyad-darwin-x64-{version}.zip` (macOS Intel)
|
||||
6. `dyad_{version}_amd64.deb` (Linux DEB)
|
||||
7. `RELEASES` (Windows update manifest)
|
||||
|
||||
### Features
|
||||
|
||||
- Reads version from `package.json` automatically
|
||||
- Fetches release information from GitHub API
|
||||
- Lists all expected vs actual assets
|
||||
- Fails with clear error messages if assets are missing
|
||||
- Shows warnings for unexpected assets
|
||||
- Provides detailed release summary on success
|
||||
30
scripts/clear_console_logs.py
Normal file
30
scripts/clear_console_logs.py
Normal file
@@ -0,0 +1,30 @@
|
||||
import re
|
||||
import os
|
||||
|
||||
def remove_console_logs_from_file(file_path):
|
||||
# Read the contents of the file
|
||||
with open(file_path, 'r') as file:
|
||||
content = file.read()
|
||||
|
||||
# Regular expression to match console.log statements
|
||||
pattern = r'console\.log\(.*?\);?'
|
||||
|
||||
# Remove all console.log statements
|
||||
modified_content = re.sub(pattern, '', content)
|
||||
|
||||
# Write the modified content back to the file
|
||||
with open(file_path, 'w') as file:
|
||||
file.write(modified_content)
|
||||
|
||||
print(f"Removed all console.log statements from {file_path}")
|
||||
|
||||
def remove_console_logs_from_directory(directory):
|
||||
for root, _, files in os.walk(directory):
|
||||
for file in files:
|
||||
if file.endswith('.ts') or file.endswith(".tsx"):
|
||||
file_path = os.path.join(root, file)
|
||||
remove_console_logs_from_file(file_path)
|
||||
|
||||
if __name__ == "__main__":
|
||||
src_directory = 'src' # Change this to the path of your src directory
|
||||
remove_console_logs_from_directory(src_directory)
|
||||
12
scripts/tsconfig.json
Normal file
12
scripts/tsconfig.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"target": "ES2020",
|
||||
"outDir": "../dist/scripts",
|
||||
"esModuleInterop": true,
|
||||
"allowSyntheticDefaultImports": true
|
||||
},
|
||||
"include": ["./**/*.ts"]
|
||||
}
|
||||
148
scripts/verify-release-assets.js
Executable file
148
scripts/verify-release-assets.js
Executable file
@@ -0,0 +1,148 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
|
||||
/**
|
||||
* Verifies that all expected binary assets are present in the GitHub release
|
||||
* for the version specified in package.json
|
||||
*/
|
||||
async function verifyReleaseAssets() {
|
||||
try {
|
||||
// Read version from package.json
|
||||
const packagePath = path.join(__dirname, "..", "package.json");
|
||||
const packageJson = JSON.parse(fs.readFileSync(packagePath, "utf8"));
|
||||
const version = packageJson.version;
|
||||
|
||||
console.log(`🔍 Verifying release assets for version ${version}...`);
|
||||
|
||||
// GitHub API configuration
|
||||
const owner = "dyad-sh";
|
||||
const repo = "dyad";
|
||||
const token = process.env.GITHUB_TOKEN;
|
||||
|
||||
if (!token) {
|
||||
throw new Error("GITHUB_TOKEN environment variable is required");
|
||||
}
|
||||
|
||||
// Fetch all releases (including drafts)
|
||||
const tagName = `v${version}`;
|
||||
|
||||
console.log(`📡 Fetching all releases to find: ${tagName}`);
|
||||
|
||||
const allReleasesUrl = `https://api.github.com/repos/${owner}/${repo}/releases`;
|
||||
const response = await fetch(allReleasesUrl, {
|
||||
headers: {
|
||||
Authorization: `token ${token}`,
|
||||
Accept: "application/vnd.github.v3+json",
|
||||
"User-Agent": "dyad-release-verifier",
|
||||
},
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(
|
||||
`GitHub API error: ${response.status} ${response.statusText}`,
|
||||
);
|
||||
}
|
||||
|
||||
const allReleases = await response.json();
|
||||
const release = allReleases.find((r) => r.tag_name === tagName);
|
||||
|
||||
if (!release) {
|
||||
throw new Error(
|
||||
`Release ${tagName} not found in published releases or drafts. Make sure the release exists.`,
|
||||
);
|
||||
}
|
||||
|
||||
const assets = release.assets || [];
|
||||
|
||||
console.log(`📦 Found ${assets.length} assets in release ${tagName}`);
|
||||
console.log(`📄 Release status: ${release.draft ? "DRAFT" : "PUBLISHED"}`);
|
||||
|
||||
// Handle different beta naming conventions across platforms
|
||||
const normalizeVersionForPlatform = (version, platform) => {
|
||||
if (!version.includes("beta")) {
|
||||
return version;
|
||||
}
|
||||
|
||||
switch (platform) {
|
||||
case "rpm":
|
||||
case "deb":
|
||||
// RPM and DEB use dots: 0.14.0-beta.1 -> 0.14.0.beta.1
|
||||
return version.replace("-beta.", ".beta.");
|
||||
case "nupkg":
|
||||
// NuGet removes the dot: 0.14.0-beta.1 -> 0.14.0-beta1
|
||||
return version.replace("-beta.", "-beta");
|
||||
default:
|
||||
// Windows installer and macOS zips keep original format
|
||||
return version;
|
||||
}
|
||||
};
|
||||
|
||||
// Define expected assets with platform-specific version handling
|
||||
const expectedAssets = [
|
||||
`dyad-${normalizeVersionForPlatform(version, "rpm")}-1.x86_64.rpm`,
|
||||
`dyad-${normalizeVersionForPlatform(version, "nupkg")}-full.nupkg`,
|
||||
`dyad-${version}.Setup.exe`,
|
||||
`dyad-darwin-arm64-${version}.zip`,
|
||||
`dyad-darwin-x64-${version}.zip`,
|
||||
`dyad_${normalizeVersionForPlatform(version, "deb")}_amd64.deb`,
|
||||
"RELEASES",
|
||||
];
|
||||
|
||||
console.log("📋 Expected assets:");
|
||||
expectedAssets.forEach((asset) => console.log(` - ${asset}`));
|
||||
console.log("");
|
||||
|
||||
// Get actual asset names
|
||||
const actualAssets = assets.map((asset) => asset.name);
|
||||
|
||||
console.log("📋 Actual assets:");
|
||||
actualAssets.forEach((asset) => console.log(` - ${asset}`));
|
||||
console.log("");
|
||||
|
||||
// Check for missing assets
|
||||
const missingAssets = expectedAssets.filter(
|
||||
(expected) => !actualAssets.includes(expected),
|
||||
);
|
||||
|
||||
if (missingAssets.length > 0) {
|
||||
console.error("❌ VERIFICATION FAILED!");
|
||||
console.error("📭 Missing assets:");
|
||||
missingAssets.forEach((asset) => console.error(` - ${asset}`));
|
||||
console.error("");
|
||||
console.error(
|
||||
"Please ensure all platforms have completed their builds and uploads.",
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// Check for unexpected assets (optional warning)
|
||||
const unexpectedAssets = actualAssets.filter(
|
||||
(actual) => !expectedAssets.includes(actual),
|
||||
);
|
||||
|
||||
if (unexpectedAssets.length > 0) {
|
||||
console.warn("⚠️ Unexpected assets found:");
|
||||
unexpectedAssets.forEach((asset) => console.warn(` - ${asset}`));
|
||||
console.warn("");
|
||||
}
|
||||
|
||||
console.log("✅ VERIFICATION PASSED!");
|
||||
console.log(
|
||||
`🎉 All ${expectedAssets.length} expected assets are present in release ${tagName}`,
|
||||
);
|
||||
console.log("");
|
||||
console.log("📊 Release Summary:");
|
||||
console.log(` Release: ${release.name || tagName}`);
|
||||
console.log(` Tag: ${release.tag_name}`);
|
||||
console.log(` Published: ${release.published_at}`);
|
||||
console.log(` URL: ${release.html_url}`);
|
||||
} catch (error) {
|
||||
console.error("❌ Error verifying release assets:", error.message);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
// Run the verification
|
||||
verifyReleaseAssets();
|
||||
Reference in New Issue
Block a user