Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues and v2 work updates #189

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open

Issues and v2 work updates #189

wants to merge 15 commits into from

Conversation

karnthis
Copy link
Contributor

src/utils/misc.ts Outdated Show resolved Hide resolved
Comment on lines +55 to +56
"test": "[ -f ./dist/index.js ] || npm run test:build",
"test:build": "npm run build && vitest",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't doing quite what you expect - previously it was running the build if it hadn't run already - we actually don't need that conditional run, so can just have vitest on its own - I was mixing up vite preview and vitest!

Suggested change
"test": "[ -f ./dist/index.js ] || npm run test:build",
"test:build": "npm run build && vitest",
"start:test": "vitest",
"test": "vitest run",

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

run build is required to capture changes to the codebase because tests run specifically against the files in /dist, and without it the test system will only reflect changes to the tests themselves. test:build forces a build of the codebase to ensure all tests run successfully against the latest code.

if there is another way to capture code changes in list I would love to use it because this honestly isn't great.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point - it still needs that ternary for the moment then - I'm about to be pushing a test update that tests the built cjs (currently) via the new commandline tool and a bash script (the intention is that other implementations can support the same arguments and then run the same tests) - currently I can't get nodejs to load binary data properly though, so raw and uint8array both fail to decode :-(

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the test code has been updated and fixed, so it works properly - the test strategy will be changing slightly for the production code so it'll only run when it can (and force it on github itself) - so I'll clean up this when I get to it - can undo the change in the meantime :-)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can now be removed - the test stategy has been updated (including better tests for built code, and an external test tool here - I'll get it running in github actions soon!)

@karnthis karnthis marked this pull request as ready for review January 25, 2024 02:27
@karnthis
Copy link
Contributor Author

@Rycochet your thoughts, if you would please.

@@ -39,6 +39,39 @@ export function getTestData(name: string) {
return cachedTestData[name] || (cachedTestData[name] = readFileSync(`testdata/${name}/data.bin`).toString());
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
function runGeneralTests(identifier: string, compressFunc: (input: any) => any, decompressFunc: (input: any) => any) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typedocs to be added, and use generics rather than any - but abstraction is good :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the reason for the any is because there are 2 incompatible function signatures, and I haven't been able to find a way to reconcile them. do you have any suggestions?

examples:
compress: (input: string | null) => T | null and (input: string) => T
decompress: (input: T | null) => string | null and (input: T) => string

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sure it's possible, but might be worth merging this in and fixing later

@@ -0,0 +1,9 @@
type VERSIONS = "v2.0.0";

export function deprecated(thing: string, version: VERSIONS, opts?: { replacement?: string }): void {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cache whether the notice has been written for this function before, otherwise it can spam the console.

I'd actually suggest making this into a decorator instead which makes the code "cleaner" - it also means you can replace the function call with the original after the first call so no need to cache it (hmu if you need to!)

I've opened a poll on #190 which will decide whether to do this style, or fix them and provide legacy endpoints (I'm leaning towards this personally, and it's the more "lz-string" way, but if we get a strong opinion another way I'll happily go with it)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you could pm or email me that would be great, I'm not actually sure what you are suggesting.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I started to write a reply and go through the various ways it could be done (as we can't use a real typescript / javascript decorator outside of a class) - and realised that it's premature optimisation and we can worry about this later - plus it's far more useful for developers than for the end-user, so we've got until the final release of v2 to improve matters, with this as a good place to start from :-)

@Rycochet
Copy link
Collaborator

Almost there I think :-D

Comment on lines +8 to +9
import { compressToBase64, compressToBase64_fixed } from ".";
import { decompressFromBase64, decompressFromBase64_fixed } from ".";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should merge into one import (format might want to play though!)

Suggested change
import { compressToBase64, compressToBase64_fixed } from ".";
import { decompressFromBase64, decompressFromBase64_fixed } from ".";
import {
compressToBase64,
compressToBase64_fixed,
decompressFromBase64,
decompressFromBase64_fixed,
} from ".";

Copy link
Collaborator

@Rycochet Rycochet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is good to merge once updated and tests are run :-)

@karnthis
Copy link
Contributor Author

karnthis commented Feb 5, 2024

I have everything done except the tests. since you redid the library I am having issues as my tests no longer work but the code being tested did not change. @Rycochet can you go into details on your process for setting up the base64 tests, since that is very similar to what the new tests need?

@Rycochet
Copy link
Collaborator

Rycochet commented Feb 5, 2024

@karnthis The biggest thing is that the tests will fail when there is a fix to the underlying code - they're comparing against a "known good" binary output, but in reality the fix means that's not correct any more - you should be able to delete the files for the two fixed encoders, and re-run the test.sh script with the -u option to update those files - which will then be used by the actual vitest tests - do feel free to update things and push with those tests still failing if it's not clear (and then I can checkout locally and give any other pointers that might be needed) :-)

@Rycochet
Copy link
Collaborator

Rycochet commented Feb 5, 2024

(Note that once this is merged I want to add specific handling for the legacy versions into the test scripts - but not entirely sure what form that needs to take!)

Copy link

@Beeloo0011 Beeloo0011 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deny

@karnthis
Copy link
Contributor Author

considering the significant number of changes that have happened to the master branch since this started I am considering scrapping what is here and starting fresh. The work still needs to be done but it will need to be approached differently now that things have stabilized a bit.

@Beeloo0011 what?

@wkrick
Copy link

wkrick commented May 30, 2024

Beeloo0011 what?

@karnthis

I think this is a bot. Their GitHub history is really bizarre. Like they're probing for insecure repos or something.

@karnthis
Copy link
Contributor Author

yeah that was my assessment too, was curious to see if I would get a response. didn't expect someone else to reply lol.

@karnthis
Copy link
Contributor Author

karnthis commented Oct 9, 2024

@Rycochet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants