Skip to content

Commit

Permalink
Merge branch 'ci/templates'
Browse files Browse the repository at this point in the history
  • Loading branch information
zbeyens committed Nov 1, 2024
1 parent a92afd7 commit d39c118
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 13 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "[email protected]",
Expand All @@ -130,4 +131,4 @@
]
}
}
}
}
30 changes: 18 additions & 12 deletions scripts/sync-plate.cjs → scripts/sync.mts
Original file line number Diff line number Diff line change
@@ -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');

Expand All @@ -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`);

Expand All @@ -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) => {
Expand All @@ -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<string, { currentVersion: string; version: string }>
) {
const updatedPackages: any[] = [];

for (const [name, versions] of versionMap) {
if (packageJson.dependencies[name]) {
Expand Down Expand Up @@ -88,7 +95,7 @@ async function main() {
// Update package.json with new versions
const updatedPackages = await updatePackageVersions(
packageJson,
versionMap
versionMap as any
);

// Log results
Expand All @@ -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);
Expand Down
14 changes: 14 additions & 0 deletions scripts/tsconfig.scripts.json
Original file line number Diff line number Diff line change
@@ -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"]
}

0 comments on commit d39c118

Please sign in to comment.