-
Notifications
You must be signed in to change notification settings - Fork 4
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
feat: Add language
to appmap.yml
#152
Conversation
test/codeBlock/appmap.yml
Outdated
- path: . | ||
exclude: | ||
- node_modules |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because appmap-node always puts this exclude entry in the generated config file, you could consider testing for the presence of “node_modules” in the config file string before performing the language fix up. Probably not needed but would add a bit of protection.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's only setting language
if it's currently missing. In other words, if it's set to something like ruby
, nothing will happen. Do you think we need to go beyond that?
By default, this is set to `javascript`. Any existing configurations will be migrated automatically.
facc4e1
to
a9f37b3
Compare
test/libraryCalls/appmap.yml
Outdated
exclude: | ||
- warn | ||
- assert # exclude because this is captured only in windows No newline at end of file | ||
- assert # exclude because this is captured only in windows | ||
language: javascript |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes automatically migrated during yarn jest
|
||
function readConfigFile(document: Document): ConfigFile { | ||
const config = document.toJSON() as Record<string, unknown>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't do a forced coercion like that. Instead, coerce to unknown
and let assert
s below carve the actual type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be fair, TypeScript doesn't provide great options for this situation. When loading data from a file, there is not much alternative to type coercion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not true. What I suggested is literally how to do it and it works really well:
const input: unknown = JSON.parse(inputText);
assert(input && typeof input === "object");
// typescript knows input is object here
if ("key" in input && typeof input.key === "string")
process(input.key /* TypeScript knows it's a string here! */);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK but I mean, so what? If the file is somehow mangled or corrupted, it's still going to error.
import { basename, join, resolve } from "node:path"; | ||
import { cwd } from "node:process"; | ||
|
||
import { PackageJson } from "type-fest"; | ||
import YAML from "yaml"; | ||
import YAML, { Document } from "yaml"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably only need type Document
here.
YAML.stringify({ | ||
name: "test-package", | ||
appmap_dir: "appmap", | ||
packages: [{ path: "." }], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a test of migration with user comments, to check they're preserved?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say skip this. Let's get this out the door.
🎉 This PR is included in version 2.23.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
By default, this is set to
javascript
. Any existing configurations will be migrated automatically.