Files
studio-desktop/scripts/prepareTypes.js
Chenlei HuandGitHub c210d2ec68 Sort imports with prettier (#638)
* Sort imports with prettier

* sort imports

* Add as dev dependency

* Apply separation

* nit
2025-01-16 12:01:56 -05:00

37 lines
1.1 KiB
JavaScript

import fs from 'node:fs';
import path from 'node:path';
import mainPackage from './getPackage.js';
// Create the types-only package.json
const typesPackage = {
name: `${mainPackage.name}-types`,
version: mainPackage.version,
type: 'module',
main: './index.js',
types: './index.d.ts',
files: ['index.d.ts', 'index.js'],
publishConfig: {
access: 'public',
},
repository: mainPackage.repository,
homepage: mainPackage.homepage,
description: `TypeScript definitions for ${mainPackage.name}`,
author: mainPackage.author,
license: mainPackage.license,
};
// Ensure dist directory exists
const distDir = path.join(import.meta.dirname, '../dist');
if (!fs.existsSync(distDir)) {
fs.mkdirSync(distDir, { recursive: true });
}
// Write the new package.json to the dist directory
fs.writeFileSync(path.join(distDir, 'package.json'), JSON.stringify(typesPackage, null, 2));
// Create an empty yarn.lock file
fs.writeFileSync(path.join(distDir, 'yarn.lock'), '');
console.log('Types package.json and yarn.lock have been prepared in the dist directory');