diff --git a/Makefile b/Makefile
index 8835b82..58bc1a4 100644
--- a/Makefile
+++ b/Makefile
@@ -13,8 +13,16 @@ buildOutput: lib/test/output.ts fmt
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 --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 README.md dist/README.md
cp LICENSE dist/LICENSE
diff --git a/lib/index.ts b/lib/index.ts
index f8a076a..746bc12 100644
--- a/lib/index.ts
+++ b/lib/index.ts
@@ -1,20 +1,22 @@
-import "./backup"
-import "./config"
-import "./config/builder"
-import "./config/configTypes"
-import "./health"
-import "./health/checkFns"
-import "./mainFn"
-import "ts-matches"
-import "./types"
-import "@iarna/toml"
-import "./types"
-import "./util"
-import "yaml"
-import "./dependencyConfig"
-import "./actions"
-import "./manifest"
-import "./inits"
+export { Daemons } from "./mainFn/Daemons"
+export { EmVer } from "./emverLite/mod"
+export { Overlay } from "./util/Overlay"
+export { Utils } from "./util/utils"
+export * as actions from "./actions"
+export * as backup from "./backup"
+export * as config from "./config"
+export * as configBuilder from "./config/builder"
+export * as configTypes from "./config/configTypes"
+export * as dependencyConfig from "./dependencyConfig"
+export * as health from "./health"
+export * as healthFns from "./health/checkFns"
+export * as inits from "./inits"
+export * as mainFn from "./mainFn"
+export * as manifest from "./manifest"
+export * as toml from "@iarna/toml"
+export * as types from "./types"
+export * as util from "./util"
+export * as yaml from "yaml"
export * as matches from "ts-matches"
export * as YAML from "yaml"
diff --git a/lib/util/Overlay.ts b/lib/util/Overlay.ts
index dee14ca..ee85542 100644
--- a/lib/util/Overlay.ts
+++ b/lib/util/Overlay.ts
@@ -1,6 +1,6 @@
-import fs from "fs/promises"
+import * as fs from "fs/promises"
import * as T from "../types"
-import cp from "child_process"
+import * as cp from "child_process"
import { promisify } from "util"
import { Buffer } from "node:buffer"
export const execFile = promisify(cp.execFile)
diff --git a/lib/util/fileHelper.ts b/lib/util/fileHelper.ts
index 3e0b88d..56706f9 100644
--- a/lib/util/fileHelper.ts
+++ b/lib/util/fileHelper.ts
@@ -2,7 +2,7 @@ import * as matches from "ts-matches"
import * as YAML from "yaml"
import * as TOML from "@iarna/toml"
import * as T from "../types"
-import fs from "fs"
+import * as fs from "fs"
const previousPath = /(.+?)\/([^/]*)$/
@@ -60,12 +60,12 @@ export class FileHelper {
async write(data: A, effects: T.Effects) {
if (previousPath.exec(this.path)) {
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) =>
- fs.writeFile(this.path, this.writeData(data), (err) =>
+ fs.writeFile(this.path, this.writeData(data), (err: any) =>
!err ? resolve(null) : reject(err),
),
)
@@ -76,7 +76,7 @@ export class FileHelper {
}
return this.readData(
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),
),
),
diff --git a/lib/util/getRandomCharInSet.ts b/lib/util/getRandomCharInSet.ts
index d380e28..b26eef6 100644
--- a/lib/util/getRandomCharInSet.ts
+++ b/lib/util/getRandomCharInSet.ts
@@ -1,6 +1,6 @@
// a,g,h,A-Z,,,,-
-import crypto from "crypto"
+import * as crypto from "crypto"
export function getRandomCharInSet(charset: string): string {
const set = stringToCharSet(charset)
let charIdx = crypto.randomInt(0, set.len)
diff --git a/lib/util/utils.ts b/lib/util/utils.ts
index a4bb80c..1af8293 100644
--- a/lib/util/utils.ts
+++ b/lib/util/utils.ts
@@ -235,14 +235,14 @@ export const createUtils = <
env: options.env,
})
const answer = new Promise((resolve, reject) => {
- childProcess.stdout.on("data", (data) => {
+ childProcess.stdout.on("data", (data: any) => {
console.log(data.toString())
})
- childProcess.stderr.on("data", (data) => {
+ childProcess.stderr.on("data", (data: any) => {
console.error(data.toString())
})
- childProcess.on("close", (code) => {
+ childProcess.on("close", (code: any) => {
if (code === 0) {
return resolve(null)
}
diff --git a/package.json b/package.json
index 636b8cf..5164857 100644
--- a/package.json
+++ b/package.json
@@ -2,8 +2,24 @@
"name": "@start9labs/start-sdk",
"version": "0.4.0-rev0.lib0.rc8.beta7",
"description": "Software development kit to facilitate packaging services for StartOS",
- "main": "./lib/index.js",
- "types": "./lib/index.d.ts",
+ "main": "./cjs/lib/index.js",
+ "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": {
"test": "jest -c ./jest.config.js --coverage",
"buildOutput": "ts-node ./lib/test/makeOutput.ts && npx prettier --write '**/*.ts'",
@@ -40,6 +56,5 @@
"tsconfig-paths": "^3.14.2",
"typescript": "^5.0.4",
"vitest": "^0.29.2"
- },
- "declaration": true
+ }
}
diff --git a/tsc-multi.json b/tsc-multi.json
deleted file mode 100644
index 36d52c1..0000000
--- a/tsc-multi.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "targets": [
- {
- "extname": ".cjs",
- "module": "commonjs"
- },
- {
- "extname": ".mjs",
- "module": "esnext"
- }
- ],
- "projects": [
- "./tsconfig.json"
- ]
-}
\ No newline at end of file
diff --git a/tsconfig-base.json b/tsconfig-base.json
new file mode 100644
index 0000000..cc14a81
--- /dev/null
+++ b/tsconfig-base.json
@@ -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"]
+}
diff --git a/tsconfig-cjs.json b/tsconfig-cjs.json
new file mode 100644
index 0000000..8413cf2
--- /dev/null
+++ b/tsconfig-cjs.json
@@ -0,0 +1,8 @@
+{
+ "extends": "./tsconfig-base.json",
+ "compilerOptions": {
+ "module": "commonjs",
+ "outDir": "dist/cjs",
+ "target": "es2018"
+ }
+}
diff --git a/tsconfig.json b/tsconfig.json
index 4ada3b0..8ae7d62 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -1,20 +1,8 @@
{
- "include": ["./lib/**/*.ts", "scripts/oldSpecToBuilder.ts"],
- "inputs": ["./lib/index.ts"],
+ "extends": "./tsconfig-base.json",
"compilerOptions": {
- "target": "es2022",
- "module": "Node16",
- "moduleResolution": "Node16",
- "declaration": true,
- "outDir": "./dist/",
- "esModuleInterop": true,
- "forceConsistentCasingInFileNames": true,
- "strict": true,
- "skipLibCheck": true
- },
- "ts-node": {
- "compilerOptions": {
- "module": "commonjs"
- }
+ "module": "esnext",
+ "outDir": "dist/mjs",
+ "target": "esnext"
}
}