chore: Update some things to make a single export?

This commit is contained in:
J H
2024-02-12 15:15:25 -07:00
parent 17ec714277
commit 599da8f52c
11 changed files with 88 additions and 63 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

@@ -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

@@ -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)

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

@@ -235,14 +235,14 @@ export const createUtils = <
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)
} }

View File

@@ -2,8 +2,24 @@
"name": "@start9labs/start-sdk", "name": "@start9labs/start-sdk",
"version": "0.4.0-rev0.lib0.rc8.beta7", "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 ./lib/test/makeOutput.ts && npx prettier --write '**/*.ts'", "buildOutput": "ts-node ./lib/test/makeOutput.ts && npx prettier --write '**/*.ts'",
@@ -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,20 +1,8 @@
{ {
"include": ["./lib/**/*.ts", "scripts/oldSpecToBuilder.ts"], "extends": "./tsconfig-base.json",
"inputs": ["./lib/index.ts"],
"compilerOptions": { "compilerOptions": {
"target": "es2022", "module": "esnext",
"module": "Node16", "outDir": "dist/mjs",
"moduleResolution": "Node16", "target": "esnext"
"declaration": true,
"outDir": "./dist/",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true
},
"ts-node": {
"compilerOptions": {
"module": "commonjs"
}
} }
} }