6 Commits

Author SHA1 Message Date
J H
87d3e83eb4 chores 2024-02-13 15:49:31 -07:00
J H
599da8f52c chore: Update some things to make a single export? 2024-02-12 15:15:25 -07:00
J H
17ec714277 Convert back to old common js 2024-02-08 13:35:56 -07:00
Aiden McClelland
dc7a86a8e8 fixes from testing 2024-02-08 13:30:32 -07:00
J H
4b1834a490 test 2024-02-02 08:51:56 -07:00
J H
dae4748659 chore: Beta 7 2024-02-02 08:42:57 -07:00
24 changed files with 178 additions and 115 deletions

View File

@@ -13,8 +13,16 @@ buildOutput: lib/test/output.ts fmt
echo 'done' echo 'done'
bundle: clean $(TS_FILES) package.json .FORCE node_modules test fmt bundle: $(TS_FILES) package.json .FORCE node_modules test fmt
npx tsc npx tsc
npx tsc --project tsconfig-cjs.json
cp package.json dist/package.json
cp README.md dist/README.md
cp LICENSE dist/LICENSE
full-bundle:
make clean
make bundle
cp package.json dist/package.json cp package.json dist/package.json
cp README.md dist/README.md cp README.md dist/README.md
cp LICENSE dist/LICENSE cp LICENSE dist/LICENSE

View File

@@ -14,6 +14,7 @@ export type ValueType =
| "union" | "union"
export type ValueSpec = ValueSpecOf<ValueType> export type ValueSpec = ValueSpecOf<ValueType>
/** core spec types. These types provide the metadata for performing validations */ /** core spec types. These types provide the metadata for performing validations */
// prettier-ignore
export type ValueSpecOf<T extends ValueType> = T extends "text" export type ValueSpecOf<T extends ValueType> = T extends "text"
? ValueSpecText ? ValueSpecText
: T extends "textarea" : T extends "textarea"

View File

@@ -2,7 +2,7 @@ import { Effects, ExpectedExports } from "../types"
import { SDKManifest } from "../manifest/ManifestTypes" import { SDKManifest } from "../manifest/ManifestTypes"
import * as D from "./configDependencies" import * as D from "./configDependencies"
import { Config, ExtractConfigType } from "./builder/config" import { Config, ExtractConfigType } from "./builder/config"
import { Utils, utils } from "../util/utils" import { Utils, createUtils } from "../util/utils"
import nullIfEmpty from "../util/nullIfEmpty" import nullIfEmpty from "../util/nullIfEmpty"
import { InterfaceReceipt } from "../interfaces/interfaceReceipt" import { InterfaceReceipt } from "../interfaces/interfaceReceipt"
import { InterfacesReceipt as InterfacesReceipt } from "../interfaces/setupInterfaces" import { InterfacesReceipt as InterfacesReceipt } from "../interfaces/setupInterfaces"
@@ -72,7 +72,7 @@ export function setupConfig<
const { restart } = await write({ const { restart } = await write({
input: JSON.parse(JSON.stringify(input)), input: JSON.parse(JSON.stringify(input)),
effects, effects,
utils: utils(effects), utils: createUtils(effects),
dependencies: D.configDependenciesSet<Manifest>(), dependencies: D.configDependenciesSet<Manifest>(),
}) })
if (restart) { if (restart) {
@@ -80,7 +80,7 @@ export function setupConfig<
} }
}) as ExpectedExports.setConfig, }) as ExpectedExports.setConfig,
getConfig: (async ({ effects }) => { getConfig: (async ({ effects }) => {
const myUtils = utils<Manifest, Store>(effects) const myUtils = createUtils<Manifest, Store>(effects)
const configValue = nullIfEmpty( const configValue = nullIfEmpty(
(await read({ effects, utils: myUtils })) || null, (await read({ effects, utils: myUtils })) || null,
) )

View File

@@ -3,7 +3,7 @@ import {
DeepPartial, DeepPartial,
Effects, Effects,
} from "../types" } from "../types"
import { Utils, utils } from "../util/utils" import { Utils, createUtils } from "../util/utils"
import { deepEqual } from "../util/deepEqual" import { deepEqual } from "../util/deepEqual"
import { deepMerge } from "../util/deepMerge" import { deepMerge } from "../util/deepMerge"
import { SDKManifest } from "../manifest/ManifestTypes" import { SDKManifest } from "../manifest/ManifestTypes"
@@ -41,7 +41,7 @@ export class DependencyConfig<
return this.dependencyConfig({ return this.dependencyConfig({
localConfig: options.localConfig as Input, localConfig: options.localConfig as Input,
effects: options.effects, effects: options.effects,
utils: utils<Manifest, Store>(options.effects), utils: createUtils<Manifest, Store>(options.effects),
}) })
} }
} }

View File

@@ -1,20 +1,22 @@
import "./backup" export { Daemons } from "./mainFn/Daemons"
import "./config" export { EmVer } from "./emverLite/mod"
import "./config/builder" export { Overlay } from "./util/Overlay"
import "./config/configTypes" export { Utils } from "./util/utils"
import "./health" export * as actions from "./actions"
import "./health/checkFns" export * as backup from "./backup"
import "./mainFn" export * as config from "./config"
import "ts-matches" export * as configBuilder from "./config/builder"
import "./types" export * as configTypes from "./config/configTypes"
import "@iarna/toml" export * as dependencyConfig from "./dependencyConfig"
import "./types" export * as health from "./health"
import "./util" export * as healthFns from "./health/checkFns"
import "yaml" export * as inits from "./inits"
import "./dependencyConfig" export * as mainFn from "./mainFn"
import "./actions" export * as manifest from "./manifest"
import "./manifest" export * as toml from "@iarna/toml"
import "./inits" export * as types from "./types"
export * as util from "./util"
export * as yaml from "yaml"
export * as matches from "ts-matches" export * as matches from "ts-matches"
export * as YAML from "yaml" export * as YAML from "yaml"

View File

@@ -3,7 +3,7 @@ import { Utils } from "../util/utils"
export type SetupExports<Store> = (opts: { export type SetupExports<Store> = (opts: {
effects: Effects effects: Effects
utils: Utils<Store> utils: Utils<any, Store>
}) => }) =>
| { | {
ui: ExposeUiPaths<Store> ui: ExposeUiPaths<Store>

View File

@@ -1,6 +1,6 @@
import { SDKManifest } from "../manifest/ManifestTypes" import { SDKManifest } from "../manifest/ManifestTypes"
import { Effects, ExpectedExports } from "../types" import { Effects, ExpectedExports } from "../types"
import { Utils, utils } from "../util/utils" import { Utils, createUtils } from "../util/utils"
export type InstallFn<Manifest extends SDKManifest, Store> = (opts: { export type InstallFn<Manifest extends SDKManifest, Store> = (opts: {
effects: Effects effects: Effects
@@ -21,7 +21,7 @@ export class Install<Manifest extends SDKManifest, Store> {
if (!previousVersion) if (!previousVersion)
await this.fn({ await this.fn({
effects, effects,
utils: utils(effects), utils: createUtils(effects),
}) })
} }
} }

View File

@@ -1,6 +1,6 @@
import { SDKManifest } from "../manifest/ManifestTypes" import { SDKManifest } from "../manifest/ManifestTypes"
import { Effects, ExpectedExports } from "../types" import { Effects, ExpectedExports } from "../types"
import { Utils, utils } from "../util/utils" import { Utils, createUtils } from "../util/utils"
export type UninstallFn<Manifest extends SDKManifest, Store> = (opts: { export type UninstallFn<Manifest extends SDKManifest, Store> = (opts: {
effects: Effects effects: Effects
@@ -21,7 +21,7 @@ export class Uninstall<Manifest extends SDKManifest, Store> {
if (!nextVersion) if (!nextVersion)
await this.fn({ await this.fn({
effects, effects,
utils: utils(effects), utils: createUtils(effects),
}) })
} }
} }

View File

@@ -52,7 +52,7 @@ Daemons.of({
export class Daemons<Manifest extends SDKManifest, Ids extends string> { export class Daemons<Manifest extends SDKManifest, Ids extends string> {
private constructor( private constructor(
readonly effects: Effects, readonly effects: Effects,
readonly started: (onTerm: () => void) => null, readonly started: (onTerm: () => PromiseLike<void>) => PromiseLike<void>,
readonly daemons?: Daemon<Manifest, Ids, "command", Ids>[], readonly daemons?: Daemon<Manifest, Ids, "command", Ids>[],
) {} ) {}
/** /**
@@ -67,7 +67,7 @@ export class Daemons<Manifest extends SDKManifest, Ids extends string> {
*/ */
static of<Manifest extends SDKManifest>(config: { static of<Manifest extends SDKManifest>(config: {
effects: Effects effects: Effects
started: (onTerm: () => void) => null started: (onTerm: () => PromiseLike<void>) => PromiseLike<void>
healthReceipts: HealthReceipt[] healthReceipts: HealthReceipt[]
}) { }) {
return new Daemons<Manifest, never>(config.effects, config.started) return new Daemons<Manifest, never>(config.effects, config.started)

View File

@@ -1,6 +1,6 @@
import { Effects, ExpectedExports } from "../types" import { Effects, ExpectedExports } from "../types"
import { createMainUtils } from "../util" import { createMainUtils } from "../util"
import { Utils, utils } from "../util/utils" import { Utils, createUtils } from "../util/utils"
import { Daemons } from "./Daemons" import { Daemons } from "./Daemons"
import "../interfaces/NetworkInterfaceBuilder" import "../interfaces/NetworkInterfaceBuilder"
import "../interfaces/Origin" import "../interfaces/Origin"

View File

@@ -9,11 +9,8 @@ import * as _I from "../index"
import { camelCase } from "../../scripts/oldSpecToBuilder" import { camelCase } from "../../scripts/oldSpecToBuilder"
import { deepMerge } from "../util/deepMerge" import { deepMerge } from "../util/deepMerge"
export type IfEquals<T, U, Y = unknown, N = never> = (<G>() => G extends T export type IfEquals<T, U, Y = unknown, N = never> =
? 1 (<G>() => G extends T ? 1 : 2) extends <G>() => G extends U ? 1 : 2 ? Y : N
: 2) extends <G>() => G extends U ? 1 : 2
? Y
: N
export function testOutput<A, B>(): (c: IfEquals<A, B>) => null { export function testOutput<A, B>(): (c: IfEquals<A, B>) => null {
return () => null return () => null
} }

View File

@@ -1,6 +1,6 @@
import { Effects } from "../types" import { Effects } from "../types"
import { createMainUtils } from "../util" import { createMainUtils } from "../util"
import { utils } from "../util/utils" import { createUtils } from "../util/utils"
type Store = { type Store = {
config: { config: {
@@ -15,23 +15,23 @@ const noop = () => {}
describe("Store", () => { describe("Store", () => {
test("types", async () => { test("types", async () => {
;async () => { ;async () => {
utils<Manifest, Store>(todo<Effects>()).store.setOwn("/config", { createUtils<Manifest, Store>(todo<Effects>()).store.setOwn("/config", {
someValue: "a", someValue: "a",
}) })
utils<Manifest, Store>(todo<Effects>()).store.setOwn( createUtils<Manifest, Store>(todo<Effects>()).store.setOwn(
"/config/someValue", "/config/someValue",
"b", "b",
) )
utils<Manifest, Store>(todo<Effects>()).store.setOwn("", { createUtils<Manifest, Store>(todo<Effects>()).store.setOwn("", {
config: { someValue: "b" }, config: { someValue: "b" },
}) })
utils<Manifest, Store>(todo<Effects>()).store.setOwn( createUtils<Manifest, Store>(todo<Effects>()).store.setOwn(
"/config/someValue", "/config/someValue",
// @ts-expect-error Type is wrong for the setting value // @ts-expect-error Type is wrong for the setting value
5, 5,
) )
utils(todo<Effects>()).store.setOwn( createUtils(todo<Effects>()).store.setOwn(
// @ts-expect-error Path is wrong // @ts-expect-error Path is wrong
"/config/someVae3lue", "/config/someVae3lue",
"someValue", "someValue",
@@ -64,31 +64,31 @@ describe("Store", () => {
.const() .const()
/// ----------------- ERRORS ----------------- /// ----------------- ERRORS -----------------
utils<Manifest, Store>(todo<Effects>()).store.setOwn("", { createUtils<Manifest, Store>(todo<Effects>()).store.setOwn("", {
// @ts-expect-error Type is wrong for the setting value // @ts-expect-error Type is wrong for the setting value
config: { someValue: "notInAOrB" }, config: { someValue: "notInAOrB" },
}) })
utils<Manifest, Store>(todo<Effects>()).store.setOwn( createUtils<Manifest, Store>(todo<Effects>()).store.setOwn(
"/config/someValue", "/config/someValue",
// @ts-expect-error Type is wrong for the setting value // @ts-expect-error Type is wrong for the setting value
"notInAOrB", "notInAOrB",
) )
;(await utils<Manifest, Store>(todo<Effects>()) ;(await createUtils<Manifest, Store>(todo<Effects>())
.store.getOwn("/config/someValue") .store.getOwn("/config/someValue")
// @ts-expect-error Const should normally not be callable // @ts-expect-error Const should normally not be callable
.const()) satisfies string .const()) satisfies string
;(await utils<Manifest, Store>(todo<Effects>()) ;(await createUtils<Manifest, Store>(todo<Effects>())
.store.getOwn("/config") .store.getOwn("/config")
// @ts-expect-error Const should normally not be callable // @ts-expect-error Const should normally not be callable
.const()) satisfies Store["config"] .const()) satisfies Store["config"]
await utils<Manifest, Store>(todo<Effects>()) await createUtils<Manifest, Store>(todo<Effects>())
// @ts-expect-error Path is wrong // @ts-expect-error Path is wrong
.store.getOwn("/config/somdsfeValue") .store.getOwn("/config/somdsfeValue")
// @ts-expect-error Const should normally not be callable // @ts-expect-error Const should normally not be callable
.const() .const()
/// ///
;(await utils<Manifest, Store>(todo<Effects>()) ;(await createUtils<Manifest, Store>(todo<Effects>())
.store.getOwn("/config/someValue") .store.getOwn("/config/someValue")
// @ts-expect-error satisfies type is wrong // @ts-expect-error satisfies type is wrong
.const()) satisfies number .const()) satisfies number

View File

@@ -114,8 +114,8 @@ export type ValidIfNoStupidEscape<A> = A extends
| `${string}\\"${string}` | `${string}\\"${string}`
? never ? never
: "" extends A & "" : "" extends A & ""
? never ? never
: A : A
export type ConfigRes = { export type ConfigRes = {
/** This should be the previous config, that way during set config we start with the previous */ /** This should be the previous config, that way during set config we start with the previous */

View File

@@ -1,6 +1,6 @@
import fs from "fs/promises" import * as fs from "fs/promises"
import * as T from "../types" import * as T from "../types"
import cp from "child_process" import * as cp from "child_process"
import { promisify } from "util" import { promisify } from "util"
import { Buffer } from "node:buffer" import { Buffer } from "node:buffer"
export const execFile = promisify(cp.execFile) export const execFile = promisify(cp.execFile)
@@ -8,18 +8,22 @@ export const execFile = promisify(cp.execFile)
export class Overlay { export class Overlay {
private constructor( private constructor(
readonly effects: T.Effects, readonly effects: T.Effects,
readonly imageId: string,
readonly rootfs: string, readonly rootfs: string,
) {} ) {}
static async of(effects: T.Effects, imageId: string) { static async of(effects: T.Effects, imageId: string) {
const rootfs = await effects.createOverlayedImage({ imageId }) const rootfs = await effects.createOverlayedImage({ imageId })
for (const dirPart of ["dev", "sys", "proc", "run"] as const) { for (const dirPart of ["dev", "sys", "proc", "run"] as const) {
const dir = await fs.mkdir(`${rootfs}/${dirPart}`, { recursive: true }) await fs.mkdir(`${rootfs}/${dirPart}`, { recursive: true })
if (!dir) break await execFile("mount", [
await execFile("mount", ["--bind", `/${dirPart}`, dir]) "--rbind",
`/${dirPart}`,
`${rootfs}/${dirPart}`,
])
} }
return new Overlay(effects, rootfs) return new Overlay(effects, imageId, rootfs)
} }
async mount(options: MountOptions, path: string): Promise<Overlay> { async mount(options: MountOptions, path: string): Promise<Overlay> {
@@ -55,20 +59,59 @@ export class Overlay {
command: string[], command: string[],
options?: CommandOptions, options?: CommandOptions,
): Promise<{ stdout: string | Buffer; stderr: string | Buffer }> { ): Promise<{ stdout: string | Buffer; stderr: string | Buffer }> {
return await execFile("chroot", [this.rootfs, ...command], options) let extra: string[] = []
if (options?.cwd) {
extra.push(`--workdir=${options.cwd}`)
delete options.cwd
}
if (options?.user) {
extra.push(`--user=${options.user}`)
delete options.user
}
return await execFile(
"start-cli",
[
"chroot",
`--env=/media/startos/env/${this.imageId}.env`,
...extra,
this.rootfs,
...command,
],
options,
)
} }
spawn( spawn(
command: string[], command: string[],
options?: CommandOptions, options?: CommandOptions,
): cp.ChildProcessWithoutNullStreams { ): cp.ChildProcessWithoutNullStreams {
return cp.spawn("chroot", [this.rootfs, ...command], options) let extra: string[] = []
if (options?.cwd) {
extra.push(`--workdir=${options.cwd}`)
delete options.cwd
}
if (options?.user) {
extra.push(`--user=${options.user}`)
delete options.user
}
return cp.spawn(
"start-cli",
[
"chroot",
`--env=/media/startos/env/${this.imageId}.env`,
...extra,
this.rootfs,
...command,
],
options,
)
} }
} }
export type CommandOptions = { export type CommandOptions = {
env?: { [variable: string]: string } env?: { [variable: string]: string }
cwd?: string cwd?: string
user?: string
} }
export type MountOptions = export type MountOptions =

View File

@@ -2,7 +2,7 @@ import * as matches from "ts-matches"
import * as YAML from "yaml" import * as YAML from "yaml"
import * as TOML from "@iarna/toml" import * as TOML from "@iarna/toml"
import * as T from "../types" import * as T from "../types"
import fs from "fs" import * as fs from "fs"
const previousPath = /(.+?)\/([^/]*)$/ const previousPath = /(.+?)\/([^/]*)$/
@@ -60,12 +60,12 @@ export class FileHelper<A> {
async write(data: A, effects: T.Effects) { async write(data: A, effects: T.Effects) {
if (previousPath.exec(this.path)) { if (previousPath.exec(this.path)) {
await new Promise((resolve, reject) => await new Promise((resolve, reject) =>
fs.mkdir(this.path, (err) => (!err ? resolve(null) : reject(err))), fs.mkdir(this.path, (err: any) => (!err ? resolve(null) : reject(err))),
) )
} }
await new Promise((resolve, reject) => await new Promise((resolve, reject) =>
fs.writeFile(this.path, this.writeData(data), (err) => fs.writeFile(this.path, this.writeData(data), (err: any) =>
!err ? resolve(null) : reject(err), !err ? resolve(null) : reject(err),
), ),
) )
@@ -76,7 +76,7 @@ export class FileHelper<A> {
} }
return this.readData( return this.readData(
await new Promise((resolve, reject) => await new Promise((resolve, reject) =>
fs.readFile(this.path, (err, data) => fs.readFile(this.path, (err: any, data: any) =>
!err ? resolve(data.toString("utf-8")) : reject(err), !err ? resolve(data.toString("utf-8")) : reject(err),
), ),
), ),

View File

@@ -1,6 +1,6 @@
// a,g,h,A-Z,,,,- // a,g,h,A-Z,,,,-
import crypto from "crypto" import * as crypto from "crypto"
export function getRandomCharInSet(charset: string): string { export function getRandomCharInSet(charset: string): string {
const set = stringToCharSet(charset) const set = stringToCharSet(charset)
let charIdx = crypto.randomInt(0, set.len) let charIdx = crypto.randomInt(0, set.len)

View File

@@ -7,7 +7,7 @@ import "./deepEqual"
import "./deepMerge" import "./deepMerge"
import "./Overlay" import "./Overlay"
import "./once" import "./once"
import { utils } from "./utils" import * as utils from "./utils"
import { SDKManifest } from "../manifest/ManifestTypes" import { SDKManifest } from "../manifest/ManifestTypes"
// prettier-ignore // prettier-ignore
@@ -23,7 +23,7 @@ export const isKnownError = (e: unknown): e is T.KnownError =>
declare const affine: unique symbol declare const affine: unique symbol
export const createUtils = utils export const createUtils = utils.createUtils
export const createMainUtils = <Manifest extends SDKManifest, Store>( export const createMainUtils = <Manifest extends SDKManifest, Store>(
effects: T.Effects, effects: T.Effects,
) => createUtils<Manifest, Store, {}>(effects) ) => createUtils<Manifest, Store, {}>(effects)

View File

@@ -125,6 +125,7 @@ export type Utils<
command: ValidIfNoStupidEscape<A> | [string, ...string[]], command: ValidIfNoStupidEscape<A> | [string, ...string[]],
options: CommandOptions & { options: CommandOptions & {
mounts?: { path: string; options: MountOptions }[] mounts?: { path: string; options: MountOptions }[]
overlay?: Overlay
}, },
) => Promise<DaemonReturned> ) => Promise<DaemonReturned>
store: { store: {
@@ -141,7 +142,7 @@ export type Utils<
) => Promise<void> ) => Promise<void>
} }
} }
export const utils = < export const createUtils = <
Manifest extends SDKManifest, Manifest extends SDKManifest,
Store = never, Store = never,
WrapperOverWrite = { const: never }, WrapperOverWrite = { const: never },
@@ -224,10 +225,11 @@ export const utils = <
command: ValidIfNoStupidEscape<A> | [string, ...string[]], command: ValidIfNoStupidEscape<A> | [string, ...string[]],
options: CommandOptions & { options: CommandOptions & {
mounts?: { path: string; options: MountOptions }[] mounts?: { path: string; options: MountOptions }[]
overlay?: Overlay
}, },
): Promise<DaemonReturned> => { ): Promise<DaemonReturned> => {
const commands = splitCommand(command) const commands = splitCommand(command)
const overlay = await Overlay.of(effects, imageId) const overlay = options.overlay || (await Overlay.of(effects, imageId))
for (let mount of options.mounts || []) { for (let mount of options.mounts || []) {
await overlay.mount(mount.options, mount.path) await overlay.mount(mount.options, mount.path)
} }
@@ -235,14 +237,14 @@ export const utils = <
env: options.env, env: options.env,
}) })
const answer = new Promise<null>((resolve, reject) => { const answer = new Promise<null>((resolve, reject) => {
childProcess.stdout.on("data", (data) => { childProcess.stdout.on("data", (data: any) => {
console.log(data.toString()) console.log(data.toString())
}) })
childProcess.stderr.on("data", (data) => { childProcess.stderr.on("data", (data: any) => {
console.error(data.toString()) console.error(data.toString())
}) })
childProcess.on("close", (code) => { childProcess.on("close", (code: any) => {
if (code === 0) { if (code === 0) {
return resolve(null) return resolve(null)
} }

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "@start9labs/start-sdk", "name": "@start9labs/start-sdk",
"version": "0.4.0-rev0.lib0.rc8.beta2", "version": "0.4.0-rev0.lib0.rc8.beta7",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@start9labs/start-sdk", "name": "@start9labs/start-sdk",
"version": "0.4.0-rev0.lib0.rc8.beta2", "version": "0.4.0-rev0.lib0.rc8.beta7",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@iarna/toml": "^2.2.5", "@iarna/toml": "^2.2.5",

View File

@@ -1,12 +1,28 @@
{ {
"name": "@start9labs/start-sdk", "name": "@start9labs/start-sdk",
"version": "0.4.0-rev0.lib0.rc8.beta2", "version": "0.4.0-rev0.lib0.rc8.beta7",
"description": "Software development kit to facilitate packaging services for StartOS", "description": "Software development kit to facilitate packaging services for StartOS",
"main": "./lib/index.js", "main": "./cjs/lib/index.js",
"types": "./lib/index.d.ts", "types": "./cjs/lib/index.d.ts",
"module": "./mjs/lib/index.js",
"sideEffects": true,
"exports": {
".": {
"import": "./mjs/lib/index.js",
"require": "./cjs/lib/index.js",
"types": "./cjs/lib/index.d.ts"
}
},
"typesVersion": {
">=3.1": {
"*": [
"cjs/lib/*"
]
}
},
"scripts": { "scripts": {
"test": "jest -c ./jest.config.js --coverage", "test": "jest -c ./jest.config.js --coverage",
"buildOutput": "ts-node --esm ./lib/test/makeOutput.ts && npx prettier --write '**/*.ts'", "buildOutput": "ts-node ./lib/test/makeOutput.ts && npx prettier --write '**/*.ts'",
"check": "tsc --noEmit" "check": "tsc --noEmit"
}, },
"repository": { "repository": {
@@ -40,6 +56,5 @@
"tsconfig-paths": "^3.14.2", "tsconfig-paths": "^3.14.2",
"typescript": "^5.0.4", "typescript": "^5.0.4",
"vitest": "^0.29.2" "vitest": "^0.29.2"
}, }
"declaration": true
} }

View File

@@ -1,15 +0,0 @@
{
"targets": [
{
"extname": ".cjs",
"module": "commonjs"
},
{
"extname": ".mjs",
"module": "esnext"
}
],
"projects": [
"./tsconfig.json"
]
}

19
tsconfig-base.json Normal file
View File

@@ -0,0 +1,19 @@
{
"compilerOptions": {
"module": "esnext",
"strict": true,
"outDir": "dist",
"preserveConstEnums": true,
"sourceMap": true,
"target": "es2017",
"pretty": true,
"declaration": true,
"noImplicitAny": true,
"esModuleInterop": true,
"types": ["node", "jest"],
"moduleResolution": "node",
"skipLibCheck": true
},
"include": ["lib/**/*"],
"exclude": ["lib/**/*.spec.ts", "lib/**/*.gen.ts", "list", "node_modules"]
}

8
tsconfig-cjs.json Normal file
View File

@@ -0,0 +1,8 @@
{
"extends": "./tsconfig-base.json",
"compilerOptions": {
"module": "commonjs",
"outDir": "dist/cjs",
"target": "es2018"
}
}

View File

@@ -1,25 +1,8 @@
{ {
"include": [ "extends": "./tsconfig-base.json",
"./lib/**/*.ts",
"scripts/oldSpecToBuilder.ts"
],
"inputs": [
"./lib/index.ts"
],
"compilerOptions": { "compilerOptions": {
"target": "es2022", "module": "esnext",
"module": "es2022", "outDir": "dist/mjs",
"moduleResolution": "node", "target": "esnext"
"declaration": true,
"outDir": "./dist/",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true
},
"ts-node": {
"compilerOptions": {
"module": "commonjs"
}
} }
} }