-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: split binaries into multiple packages
- Loading branch information
Showing
14 changed files
with
245 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ node_modules/ | |
target/ | ||
|
||
# Build | ||
!bin/todoctor.js | ||
packages/ | ||
dist/ | ||
bin/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
link-workspace-packages = true | ||
prefer-workspace-packages = true | ||
recursive-install = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
packages: | ||
- packages/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* eslint-disable perfectionist/sort-objects */ | ||
|
||
import fs from 'node:fs/promises' | ||
import path from 'node:path' | ||
|
||
import { getPackageJson } from './get-package-json.js' | ||
import { platforms } from './platforms.js' | ||
|
||
let packagesDir = path.join(import.meta.dirname, '../packages') | ||
let rootPackageJson = await getPackageJson() | ||
|
||
for (let platform of platforms) { | ||
for (let arch of platform.arch) { | ||
let packageDir = path.join(packagesDir, `${platform.name}-${arch}`) | ||
|
||
await fs.mkdir(packageDir, { | ||
recursive: true, | ||
}) | ||
|
||
let name = `@todoctor/${platform.name}-${arch}` | ||
|
||
fs.writeFile( | ||
path.join(packageDir, 'package.json'), | ||
JSON.stringify( | ||
{ | ||
name, | ||
description: `Platform-specific binary for Todoctor (${platform.name}, ${arch})`, | ||
version: rootPackageJson.version, | ||
repository: rootPackageJson.repository, | ||
author: rootPackageJson.author, | ||
license: rootPackageJson.license, | ||
keywords: rootPackageJson.keywords, | ||
os: [platform.name], | ||
cpu: [arch], | ||
}, | ||
null, | ||
2, | ||
), | ||
) | ||
|
||
fs.writeFile( | ||
path.join(packageDir, 'readme.md'), | ||
[ | ||
`# Todoctor (${platform.name[0].toUpperCase() + platform.name.slice(1)}, ${arch.toUpperCase()})`, | ||
'', | ||
'<img', | ||
' src="https://raw.githubusercontent.com/azat-io/todoctor/main/assets/logo-light.webp"', | ||
' alt="Todoctor Logo"', | ||
' align="right"', | ||
' height="160"', | ||
' width="160"', | ||
'/>', | ||
'', | ||
`[![Version](https://img.shields.io/npm/v/${name}.svg?color=2c7f50&labelColor=353c3c)](https://npmjs.com/package/${name})`, | ||
'[![GitHub License](https://img.shields.io/badge/license-MIT-232428.svg?color=2c7f50&labelColor=353c3c)](https://github.com/azat-io/todoctor/blob/main/license)', | ||
'', | ||
'This is a platform-specific binary package for Todoctor. It contains the pre-compiled binary executable for your operating system and architecture.', | ||
'', | ||
'**Note:** This package is not meant to be installed directly by users. Instead, please install the main Todoctor package, which will automatically download the correct binary for your platform.', | ||
'', | ||
'## Usage', | ||
'', | ||
'```sh', | ||
'npx todoctor', | ||
'```', | ||
'', | ||
'## License', | ||
'', | ||
'MIT © [Azat S.](https://azat.io)', | ||
].join('\n'), | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import fs from 'node:fs/promises' | ||
import path from 'node:path' | ||
|
||
export let getPackageJson = async () => { | ||
let rootPackageJsonPath = path.join(import.meta.dirname, '../package.json') | ||
return JSON.parse(await fs.readFile(rootPackageJsonPath, 'utf-8')) | ||
} |
Oops, something went wrong.