Skip to content

Sets up CLI testing#41

Merged
brob merged 14 commits into
mainfrom
testing
May 18, 2026
Merged

Sets up CLI testing#41
brob merged 14 commits into
mainfrom
testing

Conversation

@brob
Copy link
Copy Markdown
Contributor

@brob brob commented May 11, 2026

First test cases and setup for testing.

Run either

npm run test
of
node --test

Locally to try

Currently, this tests the postinstall script

Comment thread src/utils.ts
if (!config.id || !config.telemetry) {
// If no id OR telemetry,
// still write the file with a new ID and/or telemetry
fs.writeFileSync(configPath, JSON.stringify({
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we worry at this point that we're about to overwrite a file that isn't a CLI config and error out?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't know that it's a huge concern...

I kind of want to keep the directory flexible in this function, but we could make it less likely to be an issue of wiping something non-cli related by refactoring the config file to be named fa.config.json or faconfig.json to make it more intentional?

Looking at this now, we probably also want to keep any additional data intact for future proofing by spreading the rest of the data from the object (if it exists)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we just ask for confirmation? Something like

WARNING: you're about to overwrite ../whatever/something.json but this doesn't look like a FusionAuth CLI config file. Continue (y/n)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@andrewpai looking at this again, this is not happening via CLI commands, but instead via postInstall and via loadConfig (when a config file doesn't exist).

There's currently no mechanism for warning, and it actually doesn't make sense in that regard, since it'll only ever be run in the package

Comment thread src/utils.ts
Comment thread src/utils.ts
Comment thread __tests__/postInstall/index.js
@brob brob marked this pull request as ready for review May 18, 2026 16:18
@brob brob merged commit 090604a into main May 18, 2026
@brob brob deleted the testing branch May 18, 2026 18:07
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.

2 participants