From d39c118947e7a9dead67be92b760898587e0259a Mon Sep 17 00:00:00 2001 From: zbeyens Date: Fri, 1 Nov 2024 02:18:54 +0000 Subject: [PATCH] Merge branch 'ci/templates' --- package.json | 3 ++- scripts/{sync-plate.cjs => sync.mts} | 30 +++++++++++++++++----------- scripts/tsconfig.scripts.json | 14 +++++++++++++ 3 files changed, 34 insertions(+), 13 deletions(-) rename scripts/{sync-plate.cjs => sync.mts} (81%) create mode 100644 scripts/tsconfig.scripts.json diff --git a/package.json b/package.json index e8ca6d8..eadace3 100644 --- a/package.json +++ b/package.json @@ -116,6 +116,7 @@ "postcss": "^8.4.45", "prettier": "^3.3.3", "tailwindcss": "^3.4.14", + "tsx": "^4.19.1", "typescript": "5.6.3" }, "packageManager": "pnpm@9.2.0", @@ -130,4 +131,4 @@ ] } } -} \ No newline at end of file +} diff --git a/scripts/sync-plate.cjs b/scripts/sync.mts similarity index 81% rename from scripts/sync-plate.cjs rename to scripts/sync.mts index 6d08bc1..a3f3e31 100644 --- a/scripts/sync-plate.cjs +++ b/scripts/sync.mts @@ -1,10 +1,14 @@ // sync plate packages -const { exec } = require('node:child_process'); -const fs = require('node:fs/promises'); -const path = require('node:path'); -const util = require('node:util'); +import { exec, execSync } from 'node:child_process'; +import fs from 'node:fs/promises'; +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; +import { promisify } from 'node:util'; -const execPromise = util.promisify(exec); +const execPromise = promisify(exec); + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); const TARGET_PATH = path.join(__dirname, '../', './package.json'); @@ -20,7 +24,7 @@ async function getPackageJson() { } } -async function fetchPackageVersion(pkg) { +async function fetchPackageVersion(pkg: string) { try { const { stdout } = await execPromise(`npm view ${pkg} version`); @@ -32,7 +36,7 @@ async function fetchPackageVersion(pkg) { } } -async function fetchLatestVersions(packages, packageJson) { +async function fetchLatestVersions(packages: string[], packageJson: any) { console.info('Fetching latest plate versions in parallel...'); const versionPromises = packages.map(async (pkg) => { @@ -50,11 +54,14 @@ async function fetchLatestVersions(packages, packageJson) { const results = await Promise.all(versionPromises); - return new Map(results.filter(Boolean)); + return new Map(results.filter(Boolean) as any); } -async function updatePackageVersions(packageJson, versionMap) { - const updatedPackages = []; +async function updatePackageVersions( + packageJson: any, + versionMap: Map +) { + const updatedPackages: any[] = []; for (const [name, versions] of versionMap) { if (packageJson.dependencies[name]) { @@ -88,7 +95,7 @@ async function main() { // Update package.json with new versions const updatedPackages = await updatePackageVersions( packageJson, - versionMap + versionMap as any ); // Log results @@ -102,7 +109,6 @@ async function main() { }); console.info('\nRunning pnpm install...'); - const { execSync } = require('node:child_process'); try { const args = process.argv.slice(2); diff --git a/scripts/tsconfig.scripts.json b/scripts/tsconfig.scripts.json new file mode 100644 index 0000000..3c37e88 --- /dev/null +++ b/scripts/tsconfig.scripts.json @@ -0,0 +1,14 @@ +{ + "$schema": "https://json.schemastore.org/tsconfig", + "extends": "../tsconfig.json", + "compilerOptions": { + "baseUrl": "..", + "target": "es6", + "module": "commonjs", + "outDir": "dist", + "esModuleInterop": true, + "isolatedModules": false + }, + "include": [".contentlayer/generated", "scripts/**/*.ts"], + "exclude": ["node_modules"] +}