Coder Social home page Coder Social logo

paperdave / various Goto Github PK

View Code? Open in Web Editor NEW
31.0 1.0 3.0 1010 KB

Various libraries and applications related to TypeScript. Everything is contained in a monorepo to improve productivity and reduce boilerplate.

License: MIT License

JavaScript 9.09% TypeScript 90.35% Shell 0.56%
bun nodejs typescript various web

various's Introduction

Various Web Stuff

Discord Code Climate Badge

This is a monorepo of various libraries and programs I've authored, all surrounding TypeScript and other web technologies. A handful of them are published under the @paperdave namespace, but not a hard requirement. Most of the packages are reusable utilities for my other projects, as well as configurations. I use a monorepo so I don't have dozens of repositories on GitHub, and I can centralize the automation and workflow- It makes my life easier.

Runtime targets:

  • Node 16+
  • The latest release of Bun
  • Latest release of Firefox, Chrome/Edge, and Safari

The exception of the above would be packages that don't make sense in some environments, such as reading a file from a browser, or doing something DOM-oriented inside of Bun or Node.

Package Status Description
npm brightgreen Extremely thorough, but opinionated ESLint config.
npm brightgreen Extremely thorough, but opinionated Prettier config.
npm brightgreen Common utility functions and TypeScript types.
npm brightgreen Another event emitter library, with easy TS types.
npm brightgreen Versitle logging with spinners and progress bars.
npm brightgreen automatically manage index.js files that export all files in the directory
npm brightgreen Port of Next.js' metadata object API to use in other frameworks.
npm brightgreen Simple plugin to set externals for libraries.
npm yellow Port of Next.js' metadata object API to use in other frameworks.
npm yellow OpenAI API Library
npm red tricks programs to run js with bun instead of node.js

project status meaning

Status Description
Stable Ready to use and maintained by me.
LTS I will fix bugs, but likely not add features .
Dead I will likely not work on this at all, but still accept contributions.
WIP The package is still in development. Will not even be on NPM

contributing

  • use pnpm for deps. (will switch to bun once workspaces are stable)
  • use changesets for making changelogs.
  • run eslint and prettier before opening a pr.
  • don't write bad code.
  • i'm pretty chill in this repo so don't worry.

license

Everything here is under MIT

various's People

Contributors

bergerapi avatar github-actions[bot] avatar paperdave avatar xhyrom avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

various's Issues

logger: print uncaught errors

When using injectLogger, it should use process.on("uncaughtError") and unhandledRejection to print to the console. we can make the inject function take an object of arguments with these configurations

  • console: typeof console = console
  • uncaughtErrors: boolean = true
  • unhandledRejections: boolean = true
  • exitOnError: boolean = true

`@paperdave/types` cannot be installed by npm

npm ERR! Cannot read properties of null (reading 'package')

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/dave/.npm/_logs/2022-07-28T08_14_41_320Z-debug-0.log

logger: spinner looks off in this weird case

What package(s) does this bug target?

@paperdave/logger

Describe the bug and how to reproduce it.

I'm not sure what causes this since it works fine.

to reproduce. use npm to install package and watch weird encoding happen, node.js v16.17

2022-08-20-20-28-16-Code.mp4

logger: nullish coalescing operator (`??`) isn't available in Node 12

What package(s) does this bug target?

@paperdave/logger

Describe the bug and how to reproduce it.

Running in an Ubuntu-Docker-Container and after installing npm and nodejs, I tried to install my own package, which uses @paperdave/logger, globally and encountered, that apt install Node v12.22.9 by default. The nullish coalescing operator (??) exists since Node 14 and therefore causes an error.

You can reproduce this by running following commands:

docker run -i --rm -t ubuntu /bin/bash

# In Container
apt update
apt install nodejs
apt install npm

# Installing my package globally
npm i -g dokument

# Running my package
dokument

This causes an error which is caused by @paperdave/logger
image

[eslint-config-dave] use typescript-eslint rules

code from capslaw repository is causing two lint errors.

export abstract class ComponentLogic<T = unknown> {
  constructor(readonly definition: DeepReadonly<ComponentData>) {
    throw new Error('Not implemented');
  }
  abstract init(data: DeepReadonly<T>): void;
}

this ones from no-unused-vars since eslint doesn't know that these variables don't need to be used to be used, since it's abstract. i need to go through all ts eslint rules and set it up properly.

logger: Prompting the user

To reduce the use of multiple packages, one could implement a prompt system. It should be similar to this package.

I'm suggesting following functions:

  • confirm(text: string) (Simple yes/no prompt)
  • prompt(text: string) (Asking a question)
  • select(text: string, choices: string[]) (Selecting a single value from a list of values)
  • multi(text: string, choices: string[]) (Selecting multiple values from a list of values)

Examples can be found on the mentioned NPM-Package.

Unit tests across the entire repository

i want to setup cross-runtime unit tests, specifically to run in node.js and bun. do stuff so we can run the suite on node 16, 18, or even earlier things. i moved logger (and all packages) to requiring node 16 as that is the version of node i use personally and can easily test on.

estimate of a list of tests i want

  • @paperdave/utils
    • some tests written, but not with node support
    • unique
    • shuffle
    • createArray
    • moveArrayValue
    • removeArrayValue
    • insertArrayValue
    • range
    • debounce
    • throttle
    • tryOrFallback
    • getNativeModule
    • pathExists
    • readJSONSync
    • writeJSONSync
    • readJSON
    • writeJSON
    • ensureDir
    • walk
    • hashDirectoryContents
    • clamp
    • lerp
    • pipe
    • pipeAsync
    • delay
    • deferred
    • asyncMap
    • randomInt
    • randomFloat
    • capitalize
  • @paperdave/events
    • we already have tests with bun:test
    • support node.js in the testing.
  • @paperdave/logger
    • some of this might be really hard to test
    • logging with info, warn, error, debug, success all produce expected results.
    • new Logger
    • colorization on custom logs is as expected
    • DEBUG env var and setLogFilter works
    • Error formatting is as expected
    • CLIError and PrintableError work
    • LogWidget class
    • injectLogger
    • withSpinner and withProgress
  • eslint-config-dave
    • not as important but it would be cool to throw some unit tests to sanity check the config
  • prettier-config-dave
    • not as important but it would be cool to throw some unit tests to sanity check the config

logger: shorten paths if possible

What package(s) does this bug target?

@paperdave/logger

Describe the bug and how to reproduce it.

formatStackTrace either uses a short built in name for stuff like node:fs but if it's a js file, it'l print the whole path. we should do some detection of a package.json or .git, or going off the npm_package_json env var (yarn and pnpm do not set this var, but bun and npm do)

utils: vite cannot import due to tla

What package(s) does this bug target?

@paperdave/utils

Describe the bug and how to reproduce it.

to reproduce, use in a vite/sveltekit project

new package: cli for setting up projects

have a cli with subcommands that could set up certain project aspects like:

  • init a library project (setup rollup etc)
  • add my prettier config
  • add my eslint config
  • whatever else

utils: add `fs` utilities.

stuff like exists(): Promise<boolean>, walk(): <string iterator>, and so on. they're buried around my projects.

one key is that whatever implementation should handle not having the fs import available. so maybe like @paperdave/utils/fs, or even a new package @paperdave/node, but i don't like having node as a package name as it would imply a lock in to node, which im not really ok with since i would rather focus on bun, but the apis i want to add don't depend on anything bun-specific.

utils: `lerpClamped`

version of lerp which interpolates between two values without allowing overshoots.

logger: support browser environment

i'm looking into embedding logger in more places for debug purposes, such as within @purplet/rest, and maybe some other places. this package needs to be as stable as possible and run in every environment, right out of the box with any module bundler, node and bun, import and require.

for browser build, we have to
-[ ] detect environment somehow. maybe we can fallback to a global window.DEBUG = 'filters'

  • fs.writeSync -> correct console.* methods so devtools formats it.
  • LogWidget needs a reimplementation (lol imagine we give DOM support)
  • Spinner, Progress will probably get their own browser implementation

new package: cli for checking dependencies

I've had issues with depcheck in the past. this is the tool I want to have:

  • scan for all used imports like chalk or @paperdave/types, and how they are used.
  • scan for dependencies specified in package.json scripts
  • print dependencies specified in package.json but not actually used
  • types imported count as a dev dependency unless the type in question is referenced in an exported type (i had an issue in Purplet where ForceSimplify was never resolved due to @paperdave/types being missing. this dependency lint tool should be able to catch that)
  • a --write param to write the package.json file.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.