generated from RebeccaStevens/template-typescript-node-package
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5bde193
commit 3547c44
Showing
11 changed files
with
879 additions
and
31 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
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,42 @@ | ||
import childProcess from "node:child_process"; | ||
import fs from "node:fs/promises"; | ||
import util from "node:util"; | ||
|
||
import pkg from "../package.json" assert { type: "json" }; | ||
|
||
const exec = util.promisify(childProcess.exec); | ||
|
||
if ( | ||
process.env["CI"] === undefined || | ||
process.env["CI"] === "" || | ||
process.env["CI"] === "0" | ||
) { | ||
throw new Error("Not in CI Environment"); | ||
} | ||
|
||
const releasePkg = Object.fromEntries( | ||
Object.entries(pkg).map(([key, value]): [string, unknown] => { | ||
if (key === "exports") { | ||
return [ | ||
key, | ||
Object.fromEntries( | ||
Object.entries(value).map( | ||
([exportsKey, exportsValue]): [string, unknown] => { | ||
const { default: _, ...updatedExportsValue } = exportsValue; | ||
return [exportsKey, updatedExportsValue]; | ||
}, | ||
), | ||
), | ||
]; | ||
} | ||
|
||
return [key, value]; | ||
}), | ||
); | ||
|
||
await fs.writeFile("./package.json", JSON.stringify(releasePkg, undefined, 2), { | ||
encoding: "utf8", | ||
}); | ||
|
||
await exec("git add package.json"); | ||
await exec('git commit -m "build: package.json"'); |
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,27 @@ | ||
import { type BrandUnit } from "./utils"; | ||
|
||
export type Exponent = -6 | -5 | -4 | -3 | -2 | -1 | 0 | 1 | 2 | 3 | 4 | 5 | 6; | ||
|
||
export type UnitFull<T extends Record<string, UnitValue>> = number & | ||
Readonly<BrandUnit<T>>; | ||
|
||
export type UnitValue = { exponent: Exponent } & Record<string, Exponent>; | ||
|
||
/** | ||
* A unit of measurement. | ||
*/ | ||
export type Unit<T extends Record<string, Exponent | UnitValue>> = UnitFull<{ | ||
[K in keyof T]: T[K] extends Exponent | ||
? { | ||
exponent: T[K]; | ||
} | ||
: T[K] extends UnitValue | ||
? T[K] | ||
: never; | ||
}>; | ||
|
||
export type UnknownUnit = number & | ||
Readonly<{ | ||
__exactKeys: string; | ||
__uom_types: Record<string, {}>; | ||
}>; |
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 |
---|---|---|
@@ -1,3 +1,2 @@ | ||
/* eslint-disable unicorn/no-empty-file */ | ||
|
||
// Write me | ||
export type { Unit, UnknownUnit } from "./core"; | ||
export type { Multiply, Divide, Inverse } from "./utils"; |
Oops, something went wrong.