Skip to content

Commit

Permalink
build: switch to tsup, un-bundle dependencies, and support cjs
Browse files Browse the repository at this point in the history
  • Loading branch information
GeekyEggo committed Jun 26, 2024
1 parent a7036ac commit 3faab16
Show file tree
Hide file tree
Showing 8 changed files with 1,565 additions and 1,261 deletions.
2,595 changes: 1,488 additions & 1,107 deletions package-lock.json

Large diffs are not rendered by default.

61 changes: 30 additions & 31 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,26 @@
"streamdeck": "bin/streamdeck.mjs",
"sd": "bin/streamdeck.mjs"
},
"main": "./dist/index.js",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"require": "./dist/index.cjs"
},
"./package.json": "./package.json"
},
"files": [
"./bin/streamdeck.mjs",
"./dist/*.js",
"./dist/*.d.ts",
"./{bin,dist}/*.{js,cjs,mjs}",
"./{bin,dist}/*.d.{cts,ts}",
"./template"
],
"type": "module",
"engines": {
"node": "^20.1.0"
},
"scripts": {
"build": "rm -rf ./dist && rollup --config rollup.config.ts --configPlugin typescript",
"watch": "rollup --config rollup.config.ts --configPlugin typescript --watch",
"build": "tsup",
"watch": "tsup --watch",
"lint": "eslint . --ext .ts --max-warnings 0",
"lint:fix": "prettier \"./src/**/*.ts\" --write",
"preversion": "npm run build && npm run lint"
Expand All @@ -46,45 +52,38 @@
"url": "https://github.com/elgatosf/cli/issues"
},
"homepage": "https://github.com/elgatosf/cli#readme",
"devDependencies": {
"@elgato/prettier-config": "^0.2.1",
"dependencies": {
"@elgato/schemas": "^0.3.5",
"@humanwhocodes/momoa": "^3.0.0",
"@rollup/plugin-commonjs": "^25.0.5",
"@rollup/plugin-json": "^6.0.1",
"@rollup/plugin-node-resolve": "^15.2.2",
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "^11.1.5",
"@tsconfig/node20": "^20.1.2",
"@types/ejs": "^3.1.3",
"@types/inquirer": "^9.0.3",
"@types/lodash": "^4.14.199",
"@types/node": "^20.8.10",
"@typescript-eslint/eslint-plugin": "^6.7.4",
"@typescript-eslint/parser": "^6.7.4",
"@zip.js/zip.js": "^2.7.34",
"ajv": "^8.12.0",
"chalk": "^5.3.0",
"commander": "^11.0.0",
"ejs": "^3.1.10",
"eslint": "^8.51.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-jsdoc": "^46.8.2",
"eslint-plugin-prettier": "^5.0.0",
"find-process": "^1.4.7",
"ignore": "^5.3.1",
"inquirer": "^9.2.11",
"is-interactive": "^2.0.0",
"lodash": "^4.17.21",
"log-symbols": "^5.1.0",
"rage-edit": "^1.2.0",
"rollup": "^4.0.2",
"rollup-plugin-dts": "^6.1.0",
"semver": "^7.6.0",
"tar": "^7.0.1",
"tslib": "^2.6.2",
"typescript": "^5.2.2"
"tar": "^7.0.1"
},
"dependencies": {
"@elgato/schemas": "^0.3.5"
"devDependencies": {
"@elgato/prettier-config": "^0.2.1",
"@tsconfig/node20": "^20.1.2",
"@types/ejs": "^3.1.3",
"@types/inquirer": "^9.0.3",
"@types/lodash": "^4.14.199",
"@types/node": "^20.8.10",
"@typescript-eslint/eslint-plugin": "^7.14.1",
"@typescript-eslint/parser": "^7.14.1",
"eslint": "^8.51.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-jsdoc": "^46.8.2",
"eslint-plugin-prettier": "^5.0.0",
"tsup": "^8.1.0",
"typescript": "^5.5.2"
}
}
117 changes: 0 additions & 117 deletions rollup.config.ts

This file was deleted.

1 change: 1 addition & 0 deletions src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env node
import { program } from "commander";

import { config, create, link, pack, restart, setDeveloperMode, stop, validate } from "./commands";
Expand Down
2 changes: 1 addition & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Ajv, { JTDSchemaType } from "ajv/dist/jtd";
import Ajv, { JTDSchemaType } from "ajv/dist/jtd.js";
import chalk from "chalk";
import _ from "lodash";
import logSymbols from "log-symbols";
Expand Down
File renamed without changes.
10 changes: 5 additions & 5 deletions src/json/schema.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { keywordDefinitions } from "@elgato/schemas";
import { parse } from "@humanwhocodes/momoa";
import Ajv, { type AnySchema, AnySchemaObject, type DefinedError, ErrorObject, KeywordDefinition } from "ajv";
import { type AnyValidateFunction, DataValidationCxt } from "ajv/dist/types";
import Ajv, { AnySchemaObject, ErrorObject, KeywordDefinition, type AnySchema, type DefinedError } from "ajv";
import { DataValidationCxt, type AnyValidateFunction } from "ajv/dist/types";
import { type LimitNumberError } from "ajv/dist/vocabularies/validation/limitNumber";
import { isEqual, uniqWith } from "lodash";
import _ from "lodash";

import { type JsonLocation, type LocationRef } from "../common/location";
import { colorize } from "../common/stdout";
Expand Down Expand Up @@ -129,9 +129,9 @@ export class JsonSchema<T extends object> {
const ignoredKeywords = ["allOf", "anyOf", "if"];

// Remove ignored keywords, and remove duplicate errors.
return uniqWith(
return _.uniqWith(
errors.filter(({ keyword }) => !ignoredKeywords.includes(keyword)),
(a, b) => a.instancePath === b.instancePath && a.keyword === b.keyword && isEqual(a.params, b.params),
(a, b) => a.instancePath === b.instancePath && a.keyword === b.keyword && _.isEqual(a.params, b.params),
);
}

Expand Down
40 changes: 40 additions & 0 deletions tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { defineConfig } from "tsup";

const banner = {
js: `/**!
* @author Elgato
* @module elgato/streamdeck
* @license MIT
* @copyright Copyright (c) Corsair Memory Inc.
*/`,
};

export default defineConfig([
{
/**
* Programmatic interface.
*/
entry: {
index: "src/index.ts",
},
outDir: "dist",
format: ["cjs", "esm"],
banner,
clean: true,
dts: true,
},
{
/**
* CLI interface.
*/
entry: {
streamdeck: "src/cli.ts",
},
outDir: "bin",
format: "esm",
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
outExtension: () => ({ js: ".mjs" }),
banner,
clean: true,
},
]);

0 comments on commit 3faab16

Please sign in to comment.