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

feat: ingestion #64

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

marco-ippolito
Copy link
Contributor

This features allows customer to send their package.json.
Bikeshedding or error messages, prompts, naming welcome 😄

@marco-ippolito
Copy link
Contributor Author

marco-ippolito commented Nov 22, 2024

Apparently the errors are caused by Apollo client not being supported in Node v14 and v16

Copy link
Contributor

@jeremymwells jeremymwells left a comment

Choose a reason for hiding this comment

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

Looks good. One small suggestion.

Also wondering if we should either 1) take a directory as a flag, or 2) prompt the user to run in the root of the project. Apologize if I've missed that.

libs/report/ingestion/src/lib/ingestion.ts Outdated Show resolved Hide resolved
Copy link
Member

@dwelch2344 dwelch2344 left a comment

Choose a reason for hiding this comment

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

Looks great! Few thoughts/suggestions. Alll are up for debate (minus the url config and user-agent bit)

README.md Outdated Show resolved Hide resolved
libs/report/ingestion/src/lib/send-manifest.ts Outdated Show resolved Hide resolved
libs/report/ingestion/src/lib/send-manifest.ts Outdated Show resolved Hide resolved
libs/report/ingestion/src/lib/queries.ts Show resolved Hide resolved
@marco-ippolito
Copy link
Contributor Author

@marco-ippolito
Copy link
Contributor Author

Also wondering if we should either 1) take a directory as a flag, or 2) prompt the user to run in the root of the project. > Apologize if I've missed that.

I'd add that as next step and pass it as argument like -c ./foo/bar

README.md Outdated Show resolved Hide resolved

```bash
# Send information about your project manifest files
NES_REPORT_URL="https://example.com/graphql" hdcli report generate
Copy link
Contributor

Choose a reason for hiding this comment

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

This syntax does not work acorss all OSes (e.g. on Windows). Do we care about showing instructions that might not work for many users in the README?

(In general, I am a bigger fan of expliit options rather than environment variables, since (a) they tend to behave more consistent across systems, (b) the make the commands more self-contained (and avoid a form of "spookie action at a distance" kind of behavior) and (c) it is easy to turn an env var into a cli arg (--some-arg=$MY_ENV_VAR), while the opposite is not possible 😁

Just my two cents on the subject 🪙

Copy link
Contributor Author

@marco-ippolito marco-ippolito Nov 22, 2024

Choose a reason for hiding this comment

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

I mean this is just for development reasons, why a customer would ever want to change the endpoint?
Agree its not cross platform, we could change it to use crossenv, but I would not change it to a flag

| JSONValue[];

export type Options = {
all: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we really use the all option?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope I should drop it 😁 copy/paste error

@@ -0,0 +1,39 @@
import { type ArgumentsCamelCase, type CommandModule } from 'yargs';
import { askConsent, promptClientName, promptToProceedUploadFile } from './prompts';
Copy link
Contributor

Choose a reason for hiding this comment

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

promptToProceedUploadFile() doesn't seem to be used 😱

Copy link
Contributor Author

@marco-ippolito marco-ippolito Nov 22, 2024

Choose a reason for hiding this comment

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

It is used in the sendManifest which is in another file 🤔 formatter should have removed it

aliases: ['gen', 'g'],
builder: {
consent: {
describe: 'I understand that sensitive data may be uploaded to the server',
Copy link
Contributor

Choose a reason for hiding this comment

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

I think there was a misunderstanding in #64 (comment). This is not a message to be shown to the user when prompting them to consent. This is the description of the CLI --consent option, which the user can pass to the command to avoid being prompted to give their consent.

So, I think that something along the lines of Agree to understanding that sensitive data may be sent to the server (similar to the diagnostics one is more appropriate.

libs/report/ingestion/src/lib/send-manifest.ts Outdated Show resolved Hide resolved
libs/report/ingestion/src/lib/send-manifest.ts Outdated Show resolved Hide resolved
libs/report/ingestion/src/lib/send-manifest.ts Outdated Show resolved Hide resolved
};

async function run(args: ArgumentsCamelCase<Options>): Promise<void> {
const consent = await askConsent(args);
Copy link
Contributor

Choose a reason for hiding this comment

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

FWIW, I find the current process wrt consent somewhat confusing and inconsistent.

Why do we need to have two consent prompts and also why only suppress the one of them if the --consent option is passed?

I suggest the following:

  1. Look for the manifest file (without concerning ourselves with consent first).
  2. If they have passed the --consent option, upload the data.
  3. If the have not passed the --consent option, prompt them for consent to upload the specific file we have found (so that they have a chance to review it if needed).
  4. If they give consent, upload the data.
flowchart TB
  A[Start] --> B
  B[Find manifest file] --> C
  C{'--consent' option?} -- Yes --> D
  D[Upload data] --> E[End]
  C -- No --> F
  F[Prompt for consent] --> G
  G{Given consent?} -- Yes --> D
  G -- No --> E
Loading

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not about asking consent twice, is that in case of multiple manifest found the user can choose which one to send , and avoid sending the wrong one by mistake. I could immagine in a php project there might be pckage.json or composer.json. So asking the user to confirm he wants to send that specific package makes sense to me.

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