Skip to content

Commit

Permalink
fix: convert pr-check to ES modules and update Python config
Browse files Browse the repository at this point in the history
Co-Authored-By: Michael Latman <[email protected]>
  • Loading branch information
devin-ai-integration[bot] and michaellatman committed Dec 11, 2024
1 parent d1a2a6d commit 4f1d9da
Show file tree
Hide file tree
Showing 4 changed files with 220 additions and 15 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ jobs:
node-version: '18'

- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: '3.x'
python-version: '3.12'

- name: Configure pip
- name: Configure pip for uvx
run: |
python -m pip install --upgrade pip
pip config set global.extra-index-url https://uvx.org/pypi/simple/
pip config set global.index-url https://uvx.org/pypi/simple/
pip config set global.trusted-host uvx.org
- name: Install dependencies
run: npm ci
Expand Down
206 changes: 203 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
},
"dependencies": {
"@iarna/toml": "^2.2.5",
"@octokit/rest": "^18.12.0",
"@types/iarna__toml": "^2.0.5",
"chalk": "^4.1.2",
"cli-table3": "^0.6.5",
Expand Down
18 changes: 11 additions & 7 deletions src/scripts/pr-check.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
const { execSync } = require('child_process');
const fs = require('fs');
const path = require('path');
const { Octokit } = require('@octokit/rest');
import { execSync } from 'child_process';
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
import { Octokit } from '@octokit/rest';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

const REQUIRED_FIELDS = ['name', 'description', 'vendor', 'sourceUrl', 'homepage', 'license', 'runtime'];
const VALID_RUNTIMES = ['node', 'python'];
Expand Down Expand Up @@ -32,7 +36,7 @@ async function validatePackages() {
await provideFeedback(newPackages);
}

function validateJsonFormatting(content) {
export function validateJsonFormatting(content) {
const lines = content.split('\n');
for (const line of lines) {
if (line.trim() && line.match(/^( +)/)) {
Expand Down Expand Up @@ -80,7 +84,7 @@ function getNewPackages(packageList) {
return newPackages;
}

function validateRequiredFields(pkg) {
export function validateRequiredFields(pkg) {
console.log('Checking required fields...');
for (const field of REQUIRED_FIELDS) {
if (!pkg[field]) {
Expand All @@ -99,7 +103,7 @@ function validateRequiredFields(pkg) {
}
}

function validateRuntime(pkg) {
export function validateRuntime(pkg) {
console.log('Validating runtime...');
if (!VALID_RUNTIMES.includes(pkg.runtime)) {
throw new Error(`Package ${pkg.name} has invalid runtime: ${pkg.runtime}. Must be one of: ${VALID_RUNTIMES.join(', ')}`);
Expand Down

0 comments on commit 4f1d9da

Please sign in to comment.