Skip to content

feat(config): allow external config files in js/ts format #68

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

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

Conversation

bezoerb
Copy link
Member

@bezoerb bezoerb commented May 15, 2025

No description provided.

Copy link

socket-security bot commented May 15, 2025

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedjiti@​2.4.29810010085100

View full report

Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 20%)
3.1% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

Comment on lines +90 to +97
userConfigFileOptions = {
directory: path.resolve(path.dirname(filepath || ''), args.directory || 'migrations'),
...(config || {}),
};

if (userConfigFileOptions.directory && !path.isAbsolute(userConfigFileOptions.directory)) {
userConfigFileOptions.directory = path.resolve(path.dirname(filepath || ''), userConfigFileOptions.directory);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This whole getConfig function got quite long and is hard to digest.
It seems this block is the same logic as above where configFileOptions is created. I think it could help to extract this code into a little helper function.

Comment on lines +99 to +101
if (configFileOptions.directory) {
delete userConfigFileOptions.directory;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

It's not clear why the config directory takes precedence over the user config directory. Would be nice to have a comment that explains that.

args || {}
);

if (result.managementToken) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems to be done to help with compatibility.
But could it not be that some user config set the accessToken?
So probably better to only overwrite it if it is not set?

@@ -26,7 +26,7 @@
"author": "Ben Zörb <benjamin.zoerb@jvm.de>",
"license": "MIT",
"engines": {
"node": ">=14"
"node": ">=18"
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to increment the version with all those changes.
Is it done later when the whole thing is released?
This is a breaking change, is it not?
So we would require a new mayor version, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, would be minor but as we increased the required node version this needs to be major. Version will be bumped in the release process

try {
let config = {};
let filepath = '';
if (args.config.endsWith('.js') || args.config.endsWith('.ts')) {
Copy link
Contributor

Choose a reason for hiding this comment

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

When we now support ts files, that must be documented in the readme

@@ -40,7 +43,7 @@ const getConfig = async (args) => {
const { managementToken, activeSpaceId, activeEnvironmentId, host } = config || {};
contentfulCliOptions = {
spaceId: activeSpaceId,
accessToken: managementToken,
managementToken: managementToken,
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably also should be documented, that we now expect managementToken as the name (but still support accessToken?)

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