Archived
0
0
Fork 0

fix: istg typings better work

This commit is contained in:
Daryl Ronningen 2021-07-06 13:18:38 -05:00
parent 6238a21d65
commit 59bf99d274
Signed by: Daryl Ronningen
GPG key ID: FD23F0C934A5EC6B
4 changed files with 8 additions and 104 deletions

View file

@ -3,8 +3,8 @@
"version": "0.0.1", "version": "0.0.1",
"description": "Discord API Wrapper", "description": "Discord API Wrapper",
"license": "MIT", "license": "MIT",
"main": "dist/src/index.js", "main": "dist/index.js",
"types": "dist/src/index.d.ts", "types": "dist/index.d.ts",
"repository": "https://code.relms.dev/NeonJS/library", "repository": "https://code.relms.dev/NeonJS/library",
"bugs": "https://code.relms.dev/NeonJS/library/issues", "bugs": "https://code.relms.dev/NeonJS/library/issues",
"homepage": "https://code.relms.dev/NeonJS/library/src/branch/master/README.md", "homepage": "https://code.relms.dev/NeonJS/library/src/branch/master/README.md",
@ -26,7 +26,7 @@
"dist/*" "dist/*"
], ],
"scripts": { "scripts": {
"build": "tsc && node terser.js", "build": "tsc",
"commit": "cz", "commit": "cz",
"lint": "eslint --format=pretty src", "lint": "eslint --format=pretty src",
"postinstall": "husky install", "postinstall": "husky install",
@ -39,7 +39,6 @@
"async": "^3.2.0", "async": "^3.2.0",
"form-data": "^4.0.0", "form-data": "^4.0.0",
"node-fetch": "^2.6.1", "node-fetch": "^2.6.1",
"tslib": "^2.3.0",
"ws": "^7.5.2" "ws": "^7.5.2"
}, },
"devDependencies": { "devDependencies": {
@ -83,7 +82,6 @@
"semantic-release": "^17.4.4", "semantic-release": "^17.4.4",
"sinon": "^11.1.1", "sinon": "^11.1.1",
"source-map-support": "^0.5.19", "source-map-support": "^0.5.19",
"terser": "^5.7.1",
"ts-node": "^10.0.0", "ts-node": "^10.0.0",
"tsconfig-paths": "^3.9.0", "tsconfig-paths": "^3.9.0",
"typescript": "^4.3.5" "typescript": "^4.3.5"

View file

@ -1,55 +0,0 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const { minify } = require('terser');
const { readFile, readdir, writeFile, stat, mkdir, rm } = require('fs');
const { resolve, sep, dirname } = require('path');
const walk = function(dir, done) {
let results = [];
readdir(dir, function(err, list) {
if(err) return done(err);
let pending = list.length;
if(!pending) return done(null, results);
list.forEach(function(file) {
file = resolve(dir, file);
stat(file, function(err, stat) {
if(stat && stat.isDirectory()) {
walk(file, function(err, res) {
results = results.concat(res);
if(!--pending) done(null, results);
});
} else {
results.push(file);
if(!--pending) done(null, results);
}
});
});
});
};
walk('dist', (err, files) => {
if(err) throw err;
files.forEach((file) => {
if(file.endsWith('js')) {
readFile(file, async (err, fileBuf) => {
if(err) throw err;
const minifyCode = (await minify(fileBuf.toString('utf8'), { ecma: 5, compress: true, mangle: false })).code;
writeFile(file, minifyCode, { encoding: 'utf8' }, (err) => {
if(err && err.message.includes('ENOENT')) {
mkdir(`dist/${dirname(file).split(sep).pop()}`, (err) => {
if(err) throw err;
});
writeFile(file, minifyCode, { encoding: 'utf8' }, (err) => {
if(err) throw err;
});
} else if(err) {
throw err;
}
});
});
}
});
});

View file

@ -1,19 +1,15 @@
{ {
"compilerOptions": { "compilerOptions": {
"declaration": true, "declaration": true,
"composite": true,
"tsBuildInfoFile": ".tsbuildinfo",
"downlevelIteration": true, "downlevelIteration": true,
"importHelpers": true,
"incremental": true,
"lib": [ "lib": [
"ESNext", "ESNext",
"DOM" "DOM"
], ],
"module": "CommonJS", "module": "CommonJS",
"outDir": "dist", "outDir": "dist",
"removeComments": true, "removeComments": false,
"target": "ES2015", "target": "ES2019",
"alwaysStrict": true, "alwaysStrict": true,
"noImplicitAny": true, "noImplicitAny": true,
"noImplicitThis": true, "noImplicitThis": true,
@ -45,7 +41,8 @@
"noEmitOnError": false, "noEmitOnError": false,
"preserveConstEnums": true, "preserveConstEnums": true,
"traceResolution": false, "traceResolution": false,
"moduleResolution": "Node" "moduleResolution": "Node",
"baseUrl": "."
}, },
"include": [ "include": [
"src/**/*.ts" "src/**/*.ts"

View file

@ -581,10 +581,8 @@ __metadata:
semantic-release: ^17.4.4 semantic-release: ^17.4.4
sinon: ^11.1.1 sinon: ^11.1.1
source-map-support: ^0.5.19 source-map-support: ^0.5.19
terser: ^5.7.1
ts-node: ^10.0.0 ts-node: ^10.0.0
tsconfig-paths: ^3.9.0 tsconfig-paths: ^3.9.0
tslib: ^2.3.0
typescript: ^4.3.5 typescript: ^4.3.5
utf-8-validate: ^5.0.5 utf-8-validate: ^5.0.5
ws: ^7.5.2 ws: ^7.5.2
@ -2452,13 +2450,6 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"commander@npm:^2.20.0":
version: 2.20.3
resolution: "commander@npm:2.20.3"
checksum: ab8c07884e42c3a8dbc5dd9592c606176c7eb5c1ca5ff274bcf907039b2c41de3626f684ea75ccf4d361ba004bbaff1f577d5384c155f3871e456bdf27becf9e
languageName: node
linkType: hard
"commander@npm:^7.2.0": "commander@npm:^7.2.0":
version: 7.2.0 version: 7.2.0
resolution: "commander@npm:7.2.0" resolution: "commander@npm:7.2.0"
@ -7678,7 +7669,7 @@ fsevents@~2.3.2:
languageName: node languageName: node
linkType: hard linkType: hard
"source-map-support@npm:^0.5.17, source-map-support@npm:^0.5.19, source-map-support@npm:~0.5.19": "source-map-support@npm:^0.5.17, source-map-support@npm:^0.5.19":
version: 0.5.19 version: 0.5.19
resolution: "source-map-support@npm:0.5.19" resolution: "source-map-support@npm:0.5.19"
dependencies: dependencies:
@ -7702,13 +7693,6 @@ fsevents@~2.3.2:
languageName: node languageName: node
linkType: hard linkType: hard
"source-map@npm:~0.7.2":
version: 0.7.3
resolution: "source-map@npm:0.7.3"
checksum: cd24efb3b8fa69b64bf28e3c1b1a500de77e84260c5b7f2b873f88284df17974157cc88d386ee9b6d081f08fdd8242f3fc05c953685a6ad81aad94c7393dedea
languageName: node
linkType: hard
"spawn-error-forwarder@npm:~1.0.0": "spawn-error-forwarder@npm:~1.0.0":
version: 1.0.0 version: 1.0.0
resolution: "spawn-error-forwarder@npm:1.0.0" resolution: "spawn-error-forwarder@npm:1.0.0"
@ -8105,19 +8089,6 @@ fsevents@~2.3.2:
languageName: node languageName: node
linkType: hard linkType: hard
"terser@npm:^5.7.1":
version: 5.7.1
resolution: "terser@npm:5.7.1"
dependencies:
commander: ^2.20.0
source-map: ~0.7.2
source-map-support: ~0.5.19
bin:
terser: bin/terser
checksum: 9354af5c22ade95004c103893606968cbd5390824c9d89df540f9e578c6e6559a5e9c56a1bf23ed055cdb61c60defdbc2c29e773514f9f2fbc7fd7ed335f1f58
languageName: node
linkType: hard
"test-exclude@npm:^6.0.0": "test-exclude@npm:^6.0.0":
version: 6.0.0 version: 6.0.0
resolution: "test-exclude@npm:6.0.0" resolution: "test-exclude@npm:6.0.0"
@ -8299,13 +8270,6 @@ fsevents@~2.3.2:
languageName: node languageName: node
linkType: hard linkType: hard
"tslib@npm:^2.3.0":
version: 2.3.0
resolution: "tslib@npm:2.3.0"
checksum: 8869694c26e4a7b56d449662fd54a4f9ba872c889d991202c74462bd99f10e61d5bd63199566c4284c0f742277736292a969642cc7b590f98727a7cae9529122
languageName: node
linkType: hard
"tsutils@npm:^3.21.0": "tsutils@npm:^3.21.0":
version: 3.21.0 version: 3.21.0
resolution: "tsutils@npm:3.21.0" resolution: "tsutils@npm:3.21.0"