chore: Remove the unused dependencies

This commit is contained in:
BluJ
2023-04-28 08:52:44 -06:00
parent 38eccbaf44
commit 0e86e44bc3
6 changed files with 51 additions and 26 deletions

View File

@@ -10,7 +10,8 @@ lib/test/output.ts: lib/test/makeOutput.ts scripts/oldSpecToBuilder.ts
npm run buildOutput npm run buildOutput
buildOutput: lib/test/output.ts fmt buildOutput: lib/test/output.ts fmt
echo 'done' echo 'done'
bundle: clean $(TS_FILES) package.json .FORCE node_modules test fmt bundle: clean $(TS_FILES) package.json .FORCE node_modules test fmt
npx tsc npx tsc

View File

@@ -1,6 +1,6 @@
import { writeConvertedFileFromOld } from "../../scripts/oldSpecToBuilder" import { oldSpecToBuilder } from "../../scripts/oldSpecToBuilder"
writeConvertedFileFromOld( oldSpecToBuilder(
"./lib/test/output.ts", // Make the location "./lib/test/output.ts", // Make the location
{ {
// Put the config here // Put the config here

View File

@@ -7,6 +7,7 @@ import {
import { deepMerge } from "../util" import { deepMerge } from "../util"
import { InputSpec, matchInputSpec } from "./output" import { InputSpec, matchInputSpec } from "./output"
import * as _I from "../index" import * as _I from "../index"
import { camelCase } from "../../scripts/oldSpecToBuilder"
export type IfEquals<T, U, Y = unknown, N = never> = (<G>() => G extends T export type IfEquals<T, U, Y = unknown, N = never> = (<G>() => G extends T
? 1 ? 1
@@ -127,3 +128,24 @@ describe("Inputs", () => {
).toThrowError() ).toThrowError()
}) })
}) })
describe("camelCase", () => {
test("'EquipmentClass name'", () => {
expect(camelCase("EquipmentClass name")).toEqual("equipmentClassName")
})
test("'Equipment className'", () => {
expect(camelCase("Equipment className")).toEqual("equipmentClassName")
})
test("'equipment class name'", () => {
expect(camelCase("equipment class name")).toEqual("equipmentClassName")
})
test("'Equipment Class Name'", () => {
expect(camelCase("Equipment Class Name")).toEqual("equipmentClassName")
})
test("'hyphen-name-format'", () => {
expect(camelCase("hyphen-name-format")).toEqual("hyphenNameFormat")
})
test("'underscore_name_format'", () => {
expect(camelCase("underscore_name_format")).toEqual("underscoreNameFormat")
})
})

15
package-lock.json generated
View File

@@ -10,14 +10,11 @@
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@iarna/toml": "^2.2.5", "@iarna/toml": "^2.2.5",
"deepmerge": "^4.3.1",
"lodash": "^4.17.21",
"ts-matches": "^5.4.1", "ts-matches": "^5.4.1",
"yaml": "^2.2.1" "yaml": "^2.2.1"
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "^29.4.0", "@types/jest": "^29.4.0",
"@types/lodash": "^4.14.191",
"jest": "^29.4.3", "jest": "^29.4.3",
"ts-jest": "^29.0.5", "ts-jest": "^29.0.5",
"ts-node": "^10.9.1", "ts-node": "^10.9.1",
@@ -1529,12 +1526,6 @@
"integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==", "integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==",
"dev": true "dev": true
}, },
"node_modules/@types/lodash": {
"version": "4.14.192",
"resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.192.tgz",
"integrity": "sha512-km+Vyn3BYm5ytMO13k9KTp27O75rbQ0NFw+U//g+PX7VZyjCioXaRFisqSIJRECljcTv73G3i6BpglNGHgUQ5A==",
"dev": true
},
"node_modules/@types/node": { "node_modules/@types/node": {
"version": "18.15.10", "version": "18.15.10",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.15.10.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-18.15.10.tgz",
@@ -2252,6 +2243,7 @@
"version": "4.3.1", "version": "4.3.1",
"resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz", "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz",
"integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==", "integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==",
"dev": true,
"engines": { "engines": {
"node": ">=0.10.0" "node": ">=0.10.0"
} }
@@ -3572,11 +3564,6 @@
"node": ">=8" "node": ">=8"
} }
}, },
"node_modules/lodash": {
"version": "4.17.21",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
},
"node_modules/lodash.memoize": { "node_modules/lodash.memoize": {
"version": "4.1.2", "version": "4.1.2",
"resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz", "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz",

View File

@@ -21,8 +21,6 @@
"homepage": "https://github.com/Start9Labs/start-sdk#readme", "homepage": "https://github.com/Start9Labs/start-sdk#readme",
"dependencies": { "dependencies": {
"@iarna/toml": "^2.2.5", "@iarna/toml": "^2.2.5",
"deepmerge": "^4.3.1",
"lodash": "^4.17.21",
"ts-matches": "^5.4.1", "ts-matches": "^5.4.1",
"yaml": "^2.2.1" "yaml": "^2.2.1"
}, },
@@ -34,7 +32,6 @@
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "^29.4.0", "@types/jest": "^29.4.0",
"@types/lodash": "^4.14.191",
"jest": "^29.4.3", "jest": "^29.4.3",
"ts-jest": "^29.0.5", "ts-jest": "^29.0.5",
"ts-node": "^10.9.1", "ts-node": "^10.9.1",

View File

@@ -1,11 +1,19 @@
import camelCase from "lodash/camelCase"
import * as fs from "fs" import * as fs from "fs"
import { string } from "ts-matches"
export async function writeConvertedFileFromOld( export function camelCase(value: string) {
return value.replace(
/^([A-Z])|[\s-_](\w)/g,
function (match, p1, p2, offset) {
if (p2) return p2.toUpperCase()
return p1.toLowerCase()
},
)
}
export async function oldSpecToBuilder(
file: string, file: string,
inputData: Promise<any> | any, inputData: Promise<any> | any,
options: Parameters<typeof makeFileContentFromOld>[1], options?: Parameters<typeof makeFileContentFromOld>[1],
) { ) {
await fs.writeFile( await fs.writeFile(
file, file,
@@ -14,6 +22,10 @@ export async function writeConvertedFileFromOld(
) )
} }
function isString(x: unknown): x is string {
return typeof x === "string"
}
export default async function makeFileContentFromOld( export default async function makeFileContentFromOld(
inputData: Promise<any> | any, inputData: Promise<any> | any,
{ startSdk = "start-sdk", nested = true } = {}, { startSdk = "start-sdk", nested = true } = {},
@@ -145,7 +157,7 @@ export default async function makeFileContentFromOld(
]) ])
const values = Object.fromEntries( const values = Object.fromEntries(
Array.from(allValueNames) Array.from(allValueNames)
.filter(string.test) .filter(isString)
.map((key) => [key, value?.spec?.["value-names"]?.[key] || key]), .map((key) => [key, value?.spec?.["value-names"]?.[key] || key]),
) )
return `Value.select(${JSON.stringify( return `Value.select(${JSON.stringify(
@@ -264,7 +276,7 @@ export default async function makeFileContentFromOld(
) )
const values = Object.fromEntries( const values = Object.fromEntries(
Array.from(allValueNames) Array.from(allValueNames)
.filter(string.test) .filter(isString)
.map((key: string) => [ .map((key: string) => [
key, key,
value?.spec?.["value-names"]?.[key] || key, value?.spec?.["value-names"]?.[key] || key,
@@ -383,3 +395,9 @@ function rangeToTodoComment(range: string | undefined) {
if (!range) return "" if (!range) return ""
return `/* TODO: Convert range for this value (${range})*/` return `/* TODO: Convert range for this value (${range})*/`
} }
// oldSpecToBuilder(
// "./config.ts",
// // Put config here
// {},
// )