Skip to content

Sets up CLI testing#41

Draft
brob wants to merge 4 commits into
mainfrom
testing
Draft

Sets up CLI testing#41
brob wants to merge 4 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)

Comment thread src/utils.ts
}
}

type ConfigObject = {
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.

If we decide to change the format of this file at some point we'll want to put a version number in here. Not necessary to do it now, unless you want to indicate to future devs that this is the intent and that we have the pattern established.

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.

Just so I'm clear (the referenced code lines are odd), you're suggesting versioning the utils file or the config file?

Comment thread src/utils.ts

}

export function createConfig(dir: string, configObject: ConfigObject = { id: randomUUID(), telemetry: true}) {
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 you default dir to ./ since it's referenced in a few places below?

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.

Does it make sense to have a default or require it to be added?

If we want to default, I think we may want it to default to ./dist/.fa/ since that's the main use case

mock.restore();
})

test('No config creates dir', (t) => {
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 you add a test for calling createConfig() with out a directory?

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.

Makes sense

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