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

Build If-env #790

Merged
merged 73 commits into from
Jun 26, 2024
Merged

Build If-env #790

merged 73 commits into from
Jun 26, 2024

Conversation

manushak
Copy link
Contributor

@manushak manushak commented Jun 7, 2024

Types of changes

  • Enhancement (project structure, spelling, grammar, formatting)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

A description of the changes proposed in the Pull Request

  • Buld if-env CLI to allow the user to setup a local environment to run a manifest file.

@manushak manushak self-assigned this Jun 7, 2024
@manushak manushak linked an issue Jun 7, 2024 that may be closed by this pull request
6 tasks
@jmcook1186
Copy link
Contributor

@manushak still reviewing this - seems good so far but an observation is that it takes quite a while to complete and during that time the user does not know what is happening - can we add some execution logs?

@manushak
Copy link
Contributor Author

manushak commented Jun 7, 2024

@manushak still reviewing this - seems good so far but an observation is that it takes quite a while to complete and during that time the user does not know what is happening - can we add some execution logs?

sure. I'll add logs

src/env/env.ts Outdated
/**
* Updates package.json dependencies.
*/
async function updatePackageJsonDependencies(
Copy link
Member

Choose a reason for hiding this comment

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

why not arrow function?

src/env/env.ts Outdated
@@ -0,0 +1,211 @@
#!/usr/bin/env node
/* eslint-disable no-process-exit */
import * as fs from 'fs/promises';
Copy link
Member

Choose a reason for hiding this comment

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

please move the file to src folder. We don't have specific folders for each script

Copy link
Contributor Author

Choose a reason for hiding this comment

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

in this case, where the if-env template manifest be placed?
@jmcook1186 should it be moved to the ./manifests/examples folder with the name if-env-template.yml?

Copy link
Contributor

Choose a reason for hiding this comment

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

no, it should just be saved to the top level src directory. if-env is not supposed to be run inside the if source repository

src/env/env.ts Outdated

const FOLDER_NAME = 'if-environment';

type EnvironmentOptions = {
Copy link
Member

Choose a reason for hiding this comment

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

type can be moved

src/env/env.ts Outdated
): {[path: string]: string} => {
const paths = Object.keys(plugins).map(plugin => plugins[plugin].path);
const uniquePaths = [...new Set(paths)].filter(path => path !== 'builtin');
const pathsWithVersion: {[path: string]: string} = {};
Copy link
Member

Choose a reason for hiding this comment

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

extract as a type

src/env/env.ts Outdated
/**
* Installs packages from the specified dependencies in the specified folder.
*/
async function installDependencies(
Copy link
Member

Choose a reason for hiding this comment

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

this kind of helpers can be moved to utils

@narekhovhannisyan
Copy link
Member

@manushak why in one case we are listing them and in another don't?

@manushak
Copy link
Contributor Author

@narekhovhannisyan, we decided that when running with the --cwd flag, it should add dependencies to the existing package.json. For example, if another manifest file already exists in the root directory, running the command should append dependencies so that both manifests can be run properly.

cc: @jmcook1186

@jmcook1186
Copy link
Contributor

jmcook1186 commented Jun 24, 2024

Let's bring this to a close asap please. @manushak please address the outstanding comments as your priority task on IF. @narekhovhannisyan please approve unless there are changes that negatively affect the behaviour - no blocking on cosmetic issues that can be tidied up later.

@zanete

@manushak
Copy link
Contributor Author

@jmcook1186, @narekhovhannisyan, I've pushed the latest changes. Some functions don't have unit tests yet, but I'll add them later. I couldn't add the custom Error from if-core for throw new Error(FAILURE_MESSAGE_DEPENDENCIES);. There is a problem with husky; I couldn't link if-core with if.

@narekhovhannisyan
Copy link
Member

@jmcook1186 all my feedback is about the architecture and consequential poor unit test coverage (huge amount of functions were in env.ts which is not covered with unit tests), nothing cosmetic there.

@manushak
Copy link
Contributor Author

@manushak Noticed such an issue. When running from outside of IF ,with prefix and cwd, unnecessary dependencies are added into the generated package.json file. Expecting to NOT see the framework dependencies there. Please check.

Used command: npm run --prefix=./if if-env -- -m manifests/testing/testing.yaml --cwd

Screenshot 2024-06-23 at 9 45 10 PM

@MariamKhalatova, @narekhovhannisyan sorry, I got it wrong from the screenshot. I thought the selected dependencies were missing and you wanted them to persist. Thanks for noticing. It's fixed now.

package.json Outdated Show resolved Hide resolved
Signed-off-by: Narek Hovhannisyan <[email protected]>
@MariamKhalatova MariamKhalatova merged commit 62928e7 into main Jun 26, 2024
2 checks passed
@MariamKhalatova MariamKhalatova deleted the if-env branch June 26, 2024 08:23
This was referenced Jun 28, 2024
@github-actions github-actions bot mentioned this pull request Aug 9, 2024
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.

Build if-env
4 participants