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(modules): ports outdated command #62

Merged
merged 11 commits into from
May 31, 2024
Merged

Conversation

destifo
Copy link
Contributor

@destifo destifo commented May 7, 2024

add ports outdated command which shows the outdated installs in the env, with options to update specific installs or all at once.

Describe your change

  • change reducedRecipe schema to hold installSetIds.
  • read from recipe.json and get current ports versions.
  • get latest versions from PortBase and log outdated ports table.
  • add --update-no-confirm and --update-all flags.
  • refactor and clean-up
  • write tests for subcommand and flags

Motivation and context

MET-485

Migration notes

No Migrations Needed

Checklist

  • The change come with new or modified tests
  • Hard-to-understand functions have explanatory comments
  • End-user documentation is updated to reflect the change

Summary by CodeRabbit

  • New Features

    • Added support for installing a plugin for CMake.
    • Introduced new functions for updating and installing dependencies.
  • Bug Fixes

    • Improved error messages to include additional context information.
    • Updated dependency versions and platform specifications for better compatibility.
  • Improvements

    • Enhanced environment context management.
    • Refined handling of provision types in POSIX environments.
    • Optimized the PortsModule class with new utility functions.
  • Documentation

    • Updated type declarations and import statements for better clarity and maintainability.

@destifo destifo marked this pull request as draft May 7, 2024 18:57
@destifo destifo self-assigned this May 7, 2024
modules/envs/types.ts Outdated Show resolved Hide resolved
modules/envs/mod.ts Outdated Show resolved Hide resolved
@destifo destifo requested a review from Yohe-Am May 24, 2024 12:31
@Yohe-Am
Copy link
Contributor

Yohe-Am commented May 24, 2024

@coderabbitai review

Copy link

coderabbitai bot commented May 25, 2024

Actions Performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

coderabbitai bot commented May 25, 2024

Important

Review Skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The recent changes introduce new dependencies and modules to the project, update platform specifications, and enhance functionality across various files. Key updates include adding new TypeScript files, refining error messages, modifying type imports, and implementing new functions for context retrieval and dependency management. These alterations collectively aim to improve the project's robustness, compatibility, and maintainability.

Changes

File(s) Change Summary
.ghjk/deno.lock, .ghjk/lock.json Added new URLs for TypeScript files, updated platform from x86_64-linux to aarch64-darwin, and modified dependency versions.
deps/cli.ts Added export statement for the Table entity from the cliffy module.
examples/cmake/ghjk.ts Introduced functionality for installing a CMake plugin and imported relevant modules.
files/mod.ts Updated error message in the Ghjkfile class to include additional context information.
modules/envs/mod.ts, modules/envs/posix.ts, modules/envs/reducer.ts, modules/envs/types.ts Adjusted type imports, added new functions, modified class methods, and updated handling of provision types.
modules/ports/db.ts Updated conf property in installRowValidator object to use installConfigResolved.
modules/ports/mod.ts Added new imports and functions, and modified PortsModule class methods.
modules/ports/reducers.ts Updated imports and types, and modified handling of provision types.
modules/ports/sync.ts Added AllowedPortDep type and updated function parameters.
modules/ports/types.ts Added new fields, constants, and types for installation provisions.
modules/ports/utils.ts Introduced functions for updating and installing dependencies.
modules/tasks/mod.ts Modified import statements and refactored return statements in TasksModule class.
modules/types.ts Added declarations for context blackboard keys.
modules/utils.ts Added functions for retrieving context objects and active environment installation set IDs.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 9

Outside diff range and nitpick comments (23)
modules/envs/reducer.ts (2)

Line range hint 59-59: Consider specifying a more explicit type instead of any to improve type safety.

- if (wellKnownProvisionTypes.includes(ty as any)) {
+ if (wellKnownProvisionTypes.includes(ty as WellKnownProvision)) {

Line range hint 77-77: Avoid using template literals when not necessary for string construction.

- throw new Error(`no provider reducer found for ty: ${ty}`, {
+ throw new Error("no provider reducer found for ty: " + ty, {
modules/tasks/mod.ts (1)

Line range hint 100-100: Use strict equality check (!==) instead of loose equality (!=) to avoid potential type coercion issues.

- if (entry.version != "0") {
+ if (entry.version !== "0") {
modules/ports/reducers.ts (1)

Line range hint 74-77: The non-null assertion operator ! is used, which can lead to runtime errors if installArts.get(instId) returns undefined. Consider adding error handling or checks before using !.

- const { binPaths, libPaths, includePaths, installPath, env } = installArts.get(instId)!;
+ const installArt = installArts.get(instId);
+ if (!installArt) {
+   throw new Error(`Install artifacts not found for ID: ${instId}`);
+ }
+ const { binPaths, libPaths, includePaths, installPath, env } = installArt;
modules/envs/posix.ts (1)

Line range hint 209-209: Replace == with === for strict equality checks to avoid potential bugs due to type coercion.

- if (cmd == "ghjk") {
+ if (cmd === "ghjk") {
- if (cmd == "ghjk") {
+ if (cmd === "ghjk") {

Also applies to: 214-214

modules/ports/mod.ts (4)

Line range hint 134-142: This function expression can be turned into an arrow function for consistency and to potentially improve readability.

- .action(async function () {
+ .action(async () => {

Line range hint 218-220: Consider converting this function expression into an arrow function for consistency and potential readability improvements.

- .action(function () {
+ .action(() => {

Line range hint 230-230: Use strict equality check (!==) instead of loose equality (!=) to avoid unexpected type coercion.

- if (entry.version != "0") {
+ if (entry.version !== "0") {

Line range hint 231-231: Avoid using template literals when not necessary. It can lead to less clean code and slight performance overhead.

- throw new Error(`unexepected version tag deserializing lockEntry`);
+ throw new Error("unexepected version tag deserializing lockEntry");
files/mod.ts (6)

Line range hint 79-79: Specify a more appropriate type instead of any.

-  ) => Promise<any> | any;
+  ) => Promise<YourSpecificType> | YourSpecificType;

Using any can lead to potential type safety issues. Replace YourSpecificType with the actual expected type.


Line range hint 155-155: Avoid using template literals where not necessary.

Consider using regular string literals or other string handling mechanisms if template literals are not required for dynamic expressions.

Also applies to: 294-294, 473-473


Line range hint 178-178: Use strict equality checks.

- if (typeof args.base == "string") {
+ if (typeof args.base === "string") {

Replace == with === to avoid coercion and ensure strict type comparison.

Also applies to: 426-426, 555-555, 559-559


Line range hint 218-218: Avoid non-null assertions.

Non-null assertions may lead to runtime errors if not handled properly. Consider adding null checks or handling potential null values gracefully.

Also applies to: 359-359, 378-380, 521-521, 522-522, 560-560, 624-624


Line range hint 252-252: Use strict inequality checks.

- if (task.ty != "denoFile@v1") {
+ if (task.ty !== "denoFile@v1") {

Replace != with !== to ensure strict type comparison and avoid coercion.

Also applies to: 336-336


Line range hint 605-605: Use strict equality for consistency.

- if (revDepDeps.length == 0) {
+ if (revDepDeps.length === 0) {

It's best practice to use === for equality checks to avoid unexpected type coercion.

modules/ports/sync.ts (8)

Line range hint 172-172: Use strict equality comparison.

- const idx = parentDeps.findIndex(([instId, _]) => instId == installId);
+ const idx = parentDeps.findIndex(([instId, _]) => instId === installId);

Line range hint 178-178: Use strict equality comparison.

- if (parentDeps.length == 0) {
+ if (parentDeps.length === 0) {

Line range hint 196-196: Use strict equality comparison.

- if (cached && cached.progress == "installed") {
+ if (cached && cached.progress === "installed") {

Line range hint 383-383: Use strict equality comparison.

- if (!manifest.buildDeps || manifest.buildDeps.length == 0) {
+ if (!manifest.buildDeps || manifest.buildDeps.length === 0) {

Line range hint 431-431: Use strict equality comparison.

- if (depDeps.some(([depInstId, _]) => depInstId == instId)) {
+ if (depDeps.some(([depInstId, _]) => depInstId === instId)) {

Line range hint 444-444: Avoid unnecessary template literals.

- throw new Error(`cyclic dependency detected`, {
+ throw new Error("cyclic dependency detected", {

Line range hint 194-194: Variables implicitly have the 'any' type.

Consider specifying explicit types for these variables to enhance type safety and code maintainability.

Also applies to: 227-227, 509-509


Line range hint 93-93: Forbidden non-null assertions are used.

Non-null assertions may lead to runtime errors if not handled properly. Consider adding null checks or handling potential null values gracefully.

Also applies to: 110-110, 169-169, 173-173, 191-191, 198-198, 200-200, 202-202, 362-362, 401-401, 440-440

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 30c5914 and ca83137.
Files selected for processing (18)
  • .ghjk/deno.lock (1 hunks)
  • .ghjk/lock.json (4 hunks)
  • deps/cli.ts (1 hunks)
  • examples/cmake/ghjk.ts (1 hunks)
  • files/mod.ts (1 hunks)
  • modules/envs/mod.ts (5 hunks)
  • modules/envs/posix.ts (2 hunks)
  • modules/envs/reducer.ts (1 hunks)
  • modules/envs/types.ts (4 hunks)
  • modules/ports/db.ts (1 hunks)
  • modules/ports/mod.ts (5 hunks)
  • modules/ports/reducers.ts (4 hunks)
  • modules/ports/sync.ts (14 hunks)
  • modules/ports/types.ts (4 hunks)
  • modules/ports/utils.ts (1 hunks)
  • modules/tasks/mod.ts (2 hunks)
  • modules/types.ts (1 hunks)
  • modules/utils.ts (1 hunks)
Files skipped from review due to trivial changes (2)
  • deps/cli.ts
  • modules/types.ts
Additional Context Used
Biome (89)
files/mod.ts (20)

79-79: Unexpected any. Specify a different type.


79-79: Unexpected any. Specify a different type.


155-155: Do not use template literals if interpolation and special-character handling are not needed.


178-178: Use === instead of ==.
== is only allowed when comparing against null


218-218: The assignment should not be in an expression.


219-219: Forbidden non-null assertion.


252-252: Use !== instead of !=.
!= is only allowed when comparing against null


294-294: Do not use template literals if interpolation and special-character handling are not needed.


336-336: Use !== instead of !=.
!= is only allowed when comparing against null


359-359: Forbidden non-null assertion.


378-380: Forbidden non-null assertion.


426-426: Use === instead of ==.
== is only allowed when comparing against null


473-473: Do not use template literals if interpolation and special-character handling are not needed.


521-521: Forbidden non-null assertion.


522-522: Forbidden non-null assertion.


555-555: Use === instead of ==.
== is only allowed when comparing against null


559-559: Use === instead of ==.
== is only allowed when comparing against null


560-560: Forbidden non-null assertion.


605-605: Use === instead of ==.
== is only allowed when comparing against null


624-624: Forbidden non-null assertion.

modules/envs/mod.ts (13)

52-52: Use !== instead of !=.
!= is only allowed when comparing against null


83-83: Template literals are preferred over string concatenation.


100-113: This function expression can be turned into an arrow function.


122-125: This function expression can be turned into an arrow function.


136-144: This function expression can be turned into an arrow function.


166-166: Use !== instead of !=.
!= is only allowed when comparing against null


157-169: This function expression can be turned into an arrow function.


179-179: Use !== instead of !=.
!= is only allowed when comparing against null


180-180: Do not use template literals if interpolation and special-character handling are not needed.


245-245: Use === instead of ==.
== is only allowed when comparing against null


257-257: Unexpected any. Specify a different type.


3-4: Some named imports are only used as types.


10-11: All these imports are only used as types.

modules/envs/posix.ts (8)

87-87: Unexpected any. Specify a different type.


157-157: Forbidden non-null assertion.


209-209: Use === instead of ==.
== is only allowed when comparing against null


214-214: Use === instead of ==.
== is only allowed when comparing against null


281-281: Do not use template literals if interpolation and special-character handling are not needed.


282-282: Do not use template literals if interpolation and special-character handling are not needed.


1-6: Some named imports are only used as types.


6-7: Some named imports are only used as types.

modules/envs/reducer.ts (2)

59-59: Unexpected any. Specify a different type.


77-77: Do not use template literals if interpolation and special-character handling are not needed.

modules/ports/mod.ts (7)

134-142: This function expression can be turned into an arrow function.


192-192: Forbidden non-null assertion.


218-220: This function expression can be turned into an arrow function.


230-230: Use !== instead of !=.
!= is only allowed when comparing against null


231-231: Do not use template literals if interpolation and special-character handling are not needed.


3-4: Some named imports are only used as types.


18-19: All these imports are only used as types.

modules/ports/reducers.ts (3)

74-77: Forbidden non-null assertion.


3-4: All these imports are only used as types.


4-5: All these imports are only used as types.

modules/ports/sync.ts (20)

93-93: Forbidden non-null assertion.


110-110: Forbidden non-null assertion.


169-169: Forbidden non-null assertion.


172-172: Use === instead of ==.
== is only allowed when comparing against null


173-173: Forbidden non-null assertion.


178-178: Use === instead of ==.
== is only allowed when comparing against null


191-191: Forbidden non-null assertion.


194-194: This variable implicitly has the any type.


196-196: Use === instead of ==.
== is only allowed when comparing against null


198-198: Forbidden non-null assertion.


200-200: Forbidden non-null assertion.


202-202: Forbidden non-null assertion.


227-227: This variable implicitly has the any type.


362-362: Forbidden non-null assertion.


383-383: Use === instead of ==.
== is only allowed when comparing against null


401-401: Forbidden non-null assertion.


431-431: Use === instead of ==.
== is only allowed when comparing against null


440-440: Forbidden non-null assertion.


444-444: Do not use template literals if interpolation and special-character handling are not needed.


509-509: This variable implicitly has the any type.

modules/ports/utils.ts (6)

107-107: This variable implicitly has the any type.


122-122: This variable implicitly has the any type.


3-4: All these imports are only used as types.


4-5: All these imports are only used as types.


5-14: Some named imports are only used as types.


14-15: All these imports are only used as types.

modules/tasks/mod.ts (5)

100-100: Use !== instead of !=.
!= is only allowed when comparing against null


101-101: Do not use template literals if interpolation and special-character handling are not needed.


3-4: Some named imports are only used as types.


7-8: All these imports are only used as types.


11-12: All these imports are only used as types.

modules/utils.ts (5)

1-1: All these imports are only used as types.


1-2: All these imports are only used as types.


2-6: Some named imports are only used as types.


6-7: All these imports are only used as types.


7-13: Some named imports are only used as types.

Additional comments not posted (17)
examples/cmake/ghjk.ts (3)

1-1: Export statement looks good.


2-3: Import statements are correctly formatted and appropriate for the usage in this file.


5-11: The function call to install is correctly implemented with appropriate parameters.

modules/envs/reducer.ts (1)

13-16: The updated type declaration for ProvisionReducerStore correctly includes a second generic parameter, enhancing its flexibility.

modules/utils.ts (2)

36-53: The function getPortsCtx is implemented correctly, ensuring proper management of ports context.


55-79: The function getTasksCtx effectively manages the tasks context, ensuring it is retrieved or initialized as needed.

modules/envs/types.ts (1)

Line range hint 19-58: The type definitions in this file are comprehensive and correctly structured to support the functionality described in the PR.

modules/ports/db.ts (1)

16-16: The InstallsDb class is correctly implemented to manage installation records efficiently.

modules/ports/reducers.ts (2)

19-19: Ensure that the import from ./types.ts is necessary as it seems to be importing validators which might not be used directly here.

Verification successful

The validators import from ./types.ts is indeed used in modules/ports/reducers.ts.

  • modules/ports/reducers.ts
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify if validators from `./types.ts` are used in `modules/ports/reducers.ts`.

# Test: Search for `validators` usage. Expect: At least one occurrence.
rg --type typescript --files-with-matches 'validators' modules/ports/reducers.ts

Length of output: 115



Script:

#!/bin/bash
# Description: Verify if validators from `./types.ts` are used in `modules/ports/reducers.ts`.

# Test: Search for `validators` usage. Expect: At least one occurrence.
rg --type ts --files-with-matches 'validators' modules/ports/reducers.ts

Length of output: 98


67-67: The use of as Provision[] is a type assertion that could potentially hide type mismatches. Ensure that this is the best approach or consider a more robust type handling mechanism.

Verification successful

The type Provision is defined as zod.input<typeof validators.provision>, which means it is derived from a Zod schema. The type assertion as Provision[] is used to initialize an empty array with this type. Given that Provision is a complex type derived from a Zod schema, the type assertion is necessary to ensure the array is correctly typed from the start.

  • modules/envs/types.ts:90: export type Provision = zod.input<typeof validators.provision>;
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify if the type assertion for `Provision[]` is necessary.

# Test: Check for type mismatches that could be hidden by this assertion.
ast-grep --lang typescript --pattern $'const out = [] as Provision[]; $$$'

Length of output: 532



Script:

#!/bin/bash
# Description: Verify if the type assertion for `Provision[]` is necessary.

# Test: Check for type mismatches that could be hidden by this assertion.
ast-grep --lang typescript --pattern 'const out: Provision[] = [];'

Length of output: 69



Script:

#!/bin/bash
# Description: Search for the definition and usage of `Provision` in the codebase.

# Find the definition of `Provision`.
ast-grep --lang typescript --pattern 'type Provision = $_;' --pattern 'interface Provision { $$$ }'

# Find all usages of `Provision`.
rg 'Provision'

Length of output: 7969



Script:

#!/bin/bash
# Description: Search for the definition of `Provision` and related types in the codebase.

# Find the definition of `Provision`.
ast-grep --lang typescript --pattern 'type Provision = $_;' || ast-grep --lang typescript --pattern 'interface Provision { $$$ }'

# Find the definition of related types.
ast-grep --lang typescript --pattern 'type WellKnownProvision = $_;' || ast-grep --lang typescript --pattern 'interface WellKnownProvision { $$$ }'
ast-grep --lang typescript --pattern 'type InstallSetProvision = $_;' || ast-grep --lang typescript --pattern 'interface InstallSetProvision { $$$ }'
ast-grep --lang typescript --pattern 'type InstallSetRefProvision = $_;' || ast-grep --lang typescript --pattern 'interface InstallSetRefProvision { $$$ }'

Length of output: 893

modules/ports/utils.ts (1)

1-1: Ensure that the import from ../../deps/cli.ts is necessary as it seems to be importing std_path which might not be used directly here.

Verification successful

The std_path import from ../../deps/cli.ts is indeed used in modules/ports/utils.ts.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify if `std_path` from `../../deps/cli.ts` is used in `modules/ports/utils.ts`.

# Test: Search for `std_path` usage. Expect: At least one occurrence.
rg --type typescript --files-with-matches 'std_path' modules/ports/utils.ts

Length of output: 110



Script:

#!/bin/bash
# Description: Verify if `std_path` from `../../deps/cli.ts` is used in `modules/ports/utils.ts`.

# Test: Search for `std_path` usage. Expect: At least one occurrence.
rg --type ts --files-with-matches 'std_path' modules/ports/utils.ts

Length of output: 90

modules/envs/posix.ts (1)

50-88: The switch statement handles different types of provisions. Ensure that all cases are covered and that the default case throws an informative error for unsupported types.

Verification successful

The switch statement handling the provision types in modules/envs/posix.ts appears to cover all specified cases, including a default case that throws an error for unsupported types. This ensures that any unrecognized provision type will be flagged appropriately.

  • The switch statement at line 55 handles various provision types such as "posix.exec", "posix.sharedLib", "posix.headerFile", "posix.envVar", "hook.onEnter.posixExec", "hook.onExit.posixExec", and "ghjk.ports.Install".
  • The default case at line 85 throws an error for unsupported provision types, ensuring that any unrecognized type is caught.

Based on the provided context and the results from the shell scripts, it appears that all provision types are adequately handled.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify if all provision types are handled in the switch statement.

# Test: Check for unhandled provision types.
ast-grep --lang typescript --pattern $'switch ($$$) { case "posix.exec": $$$; case "posix.sharedLib": $$$; case "posix.headerFile": $$$; case "posix.envVar": $$$; case "hook.onEnter.posixExec": $$$; case "hook.onExit.posixExec": $$$; case "ghjk.ports.Install": $$$; default: throw Error($$$); }'

Length of output: 296



Script:

#!/bin/bash
# Description: Find all switch statements in the file to manually verify the cases.

# Locate the file
file_path=$(fd posix.ts)

# Extract all switch statements from the file
ast-grep --lang typescript --pattern 'switch ($$$) { $$$ }' $file_path

Length of output: 2723

modules/envs/mod.ts (2)

161-161: Typographical error in the error message. Correct "detct" to "detect".

- "unable to detct shell in use. Use `--shell` flag to explicitly pass shell program.",
+ "unable to detect shell in use. Use `--shell` flag to explicitly pass shell program.",

Likely invalid or redundant comment.


21-21: The function getEnvsCtx is imported here. Verify that it is used appropriately and that its effects are well-understood in the context of this module.

Verification successful

The function getEnvsCtx is used appropriately in modules/envs/mod.ts. It is called to initialize the envsCtx object, which is then populated with activeEnv and config properties. This usage aligns with the expected behavior of setting up the environment context.

  • getEnvsCtx is imported from ../utils.ts.
  • It is used to create the envsCtx object.
  • The envsCtx object is then populated with activeEnv and config.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the usage of `getEnvsCtx` in `modules/envs/mod.ts`.

# Test: Search for `getEnvsCtx` usage. Expect: At least one occurrence.
rg --type typescript --files-with-matches 'getEnvsCtx' modules/envs/mod.ts

Length of output: 109



Script:

#!/bin/bash
# Description: Verify the usage of `getEnvsCtx` in `modules/envs/mod.ts`.

# Test: Search for `getEnvsCtx` usage. Expect: At least one occurrence.
rg --type ts --files-with-matches 'getEnvsCtx' modules/envs/mod.ts

Length of output: 86



Script:

#!/bin/bash
# Description: Display the usage of `getEnvsCtx` in `modules/envs/mod.ts` with surrounding lines for context.

# Test: Search for `getEnvsCtx` usage and display 5 lines before and after each occurrence.
rg 'getEnvsCtx' -C 5 modules/envs/mod.ts

Length of output: 659

modules/ports/types.ts (1)

182-186: New types installProvisionTy and installProvision are defined. Ensure that these types are integrated correctly across the module and that they adhere to the expected structure and usage patterns.

Verification successful

The types installProvisionTy and installProvision are correctly integrated and used across the module in the following files:

  • modules/ports/types.ts
  • modules/ports/reducers.ts
  • modules/ports/mod.ts

These usages indicate that the new types are properly referenced and utilized within the module.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the usage and integration of `installProvisionTy` and `installProvision`.

# Test: Search for usages of these types across the module.
rg --type typescript --files-with-matches 'installProvisionTy|installProvision' modules/ports

Length of output: 130



Script:

#!/bin/bash
# Description: Verify the usage and integration of `installProvisionTy` and `installProvision`.

# Test: Search for usages of these types across the module.
rg --type ts --files-with-matches 'installProvisionTy|installProvision' modules/ports

Length of output: 157



Script:

#!/bin/bash
# Description: Extract and review the relevant lines from the identified files to ensure proper integration and usage of `installProvisionTy` and `installProvision`.

# Extract lines from modules/ports/types.ts
echo "modules/ports/types.ts:"
rg 'installProvisionTy|installProvision' modules/ports/types.ts

# Extract lines from modules/ports/reducers.ts
echo "modules/ports/reducers.ts:"
rg 'installProvisionTy|installProvision' modules/ports/reducers.ts

# Extract lines from modules/ports/mod.ts
echo "modules/ports/mod.ts:"
rg 'installProvisionTy|installProvision' modules/ports/mod.ts

Length of output: 882

.ghjk/lock.json (2)

3-3: Platform updated to aarch64-darwin.

This change aligns with the PR's objective to support the aarch64-darwin platform.


20-20: Version updated to 3.5 for tar_aa.

Ensure that all dependencies and configurations that rely on tar_aa are compatible with this new version.

Also applies to: 40-40, 53-53

.ghjk/deno.lock Outdated
Comment on lines 572 to 596
"https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/deps/cli.ts": "4eacc555cf80686b487e7502db63a4cfbc2060a7b847d15b14cf1cc008a3b65c",
"https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/deps/common.ts": "46d30782086ccc79e4a2633fe859723e7686ebc5adb4101e76c4bf2d6d2e94ff",
"https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/host/deno.ts": "330c62197c7af0a01d3ec96705367b789d538f3c820b730c63bb2820fabda7d7",
"https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/host/mod.ts": "2bc9f273262e1c4fb434b1a0389f24464f8b986816ce9480e8e2d63d910e8253",
"https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/host/types.ts": "22c06b190172d08092717ad788ed04b050af58af0cf3f8c78b1511984101e9e4",
"https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/main.ts": "8d6985e59db0b5baf67c9dc330bf8b25ad556341b9ef6088038e8ebb37ed75e5",
"https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/modules/mod.ts": "6aa0b765ce5684842ea531e026926836ffde7d2513e62457bffe9cb4ec7eb0df",
"https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/modules/ports/ambient.ts": "25623410c535e2bfaf51fca1e582e7325a00a7690d5b5e763a12be9407f619cf",
"https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/modules/ports/base.ts": "8ef8a8de372420bddcd63a1b363937f43d898059e99478a58621e8432bcd5891",
"https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/modules/ports/db.ts": "3f4541d6874c434f2f869774a17fd41c3d86914ed190d412e2f63f564b58ce95",
"https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/modules/ports/mod.ts": "e38ad2d3599b6a5522da436b52e5945bb85cabba2aca27f633eae43e465b5794",
"https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/modules/ports/sync.ts": "46447c2c51c085193f567ddcd2451b14bb33ee2d761edeb91a6153e2ba642f42",
"https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/modules/ports/types.ts": "b3967d9d75def187b3b55f2b0b1357c9cb69a70e475a9280fc66717193b8b43c",
"https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/modules/ports/types/platform.ts": "0ecffeda71919293f9ffdb6c564ddea4f23bc85c4e640b08ea78225d34387fdc",
"https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/modules/ports/worker.ts": "25c01e3afddd97d48af89d9c97a9a5188e7db09fceb26a69eac4dabacd8ac4fc",
"https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/modules/std.ts": "ddb2c134c080bb0e762a78f2f2edd69536991cc4257bd29a6fc95944b2f105a9",
"https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/modules/tasks/deno.ts": "f988a4d1062364b99272087fa0c7d54e699944ead3790c5b83140577bda089de",
"https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/modules/tasks/exec.ts": "7a07f2cce79fe16e86f0b74df6d57f0160bac75a8c6d58a03f2883a5ecccddf0",
"https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/modules/tasks/mod.ts": "0edbe1ce953a44b6b0fd45aa9c9dd52c11b12053eef21307eac3b24b6db4745e",
"https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/modules/tasks/types.ts": "536495a17c7a917bdd1c316ecc98ce2947b4959a713f92a175d372196dcaafc0",
"https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/modules/types.ts": "b44609942d7ad66c925c24485057c5b4b2ffcad20c0a94e14dc6af34cf9e8241",
"https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/setup_logger.ts": "f8a206bda0595497d6f4718032d4a959000b32ef3346d4b507777eec6a169458",
"https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/utils/logger.ts": "86fdf651123d00ea1081bf8001ed9039cd41a79940e6ebadb8484952ab390e73",
"https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/utils/mod.ts": "1ee68d9390259c065144c10663f6e360d29aec36db2af38d02647e304eeeaedc",
"https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/utils/url.ts": "e1ada6fd30fc796b8918c88456ea1b5bbd87a07d0a0538b092b91fd2bb9b7623",
Copy link

Choose a reason for hiding this comment

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

Tip

Codebase Verification

The updates to the .ghjk/deno.lock file have introduced potential issues:

  • Multiple versions of @david/which (0.3.0 and 0.4.1) and zod-validation-error (3.1.0 and 3.2.0) are present, which could lead to version conflicts.

  • The integrity check returned null, indicating that no integrity hashes were found, which means the integrity of the dependencies cannot be verified.

  • Ensure that the versions of @david/which and zod-validation-error are compatible and do not cause conflicts.

  • Add integrity hashes for all dependencies to verify their integrity.

Analysis chain

The updates to the dependencies in the .ghjk/deno.lock file include several new entries and updates to existing ones. Ensure that these changes are compatible with the rest of the project and that there are no version conflicts.


The output indicates potential version conflicts with the following packages:

  • @david/which has versions 0.3.0 and 0.4.1.
  • zod-validation-error has versions 3.1.0 and 3.2.0.

We need to verify if these versions are compatible and do not cause issues. Additionally, we should check the integrity of the dependencies by comparing the hash values.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Check for any version conflicts or integrity mismatches in the updated dependencies.

# Test: List all dependencies and their versions. Expect: No conflicts or mismatches.
cat .ghjk/deno.lock | jq '.packages.specifiers'

Length of output: 1020



Script:

#!/bin/bash
# Description: Check for multiple versions of the same package and verify their compatibility.

# List all dependencies and their versions
cat .ghjk/deno.lock | jq '.packages.specifiers' > dependencies.json

# Check for multiple versions of the same package
jq 'to_entries | group_by(.key | split("@")[0]) | map(select(length > 1))' dependencies.json

# Verify the integrity of the dependencies by comparing the hash values
cat .ghjk/deno.lock | jq '.packages.integrity'

Length of output: 1641

Comment on lines +18 to +19
} from "./types.ts";
import { type GhjkCtx, type ModuleManifest } from "../types.ts";
Copy link

Choose a reason for hiding this comment

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

All these imports are only used as types. Consider using type-only imports to clarify their usage and potentially optimize bundling.

- import { type GhjkCtx, type ModuleManifest } from "../types.ts";
+ import type { GhjkCtx, ModuleManifest } from "../types.ts";

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
} from "./types.ts";
import { type GhjkCtx, type ModuleManifest } from "../types.ts";
} from "./types.ts";
import type { GhjkCtx, ModuleManifest } from "../types.ts";

modules/ports/mod.ts Show resolved Hide resolved
const _installName = _opts.updateInstall;
// TODO: convert from install name to install id, after port module refactor
let installId!: string;
const newVersion = latest.get(installId)!;
Copy link

Choose a reason for hiding this comment

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

Avoid using non-null assertions. It's safer to handle potential null or undefined values explicitly.

- const newVersion = latest.get(installId)!;
+ const newVersion = latest.get(installId);
+ if (!newVersion) {
+   throw new Error(`No version found for install ID: ${installId}`);
+ }

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
const newVersion = latest.get(installId)!;
const newVersion = latest.get(installId);
if (!newVersion) {
throw new Error(`No version found for install ID: ${installId}`);
}

Comment on lines +15 to +34
export function getEnvsCtx(
gcx: GhjkCtx,
): EnvsCtx {
let envsCtx = gcx.blackboard.get(envsCtxBlackboardKey) as
| EnvsCtx
| undefined;

if (!envsCtx) {
envsCtx = {
activeEnv: "",
config: {
defaultEnv: "",
envs: {},
},
};
gcx.blackboard.set(envsCtxBlackboardKey, envsCtx);
}

return envsCtx;
}
Copy link

Choose a reason for hiding this comment

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

The function getEnvsCtx correctly handles the retrieval or initialization of the environment context.

Consider using import type for imports that are only used for type annotations to clarify their usage and potentially optimize bundling.

- import { EnvsCtx } from "./envs/mod.ts";
+ import type { EnvsCtx } from "./envs/mod.ts";

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
export function getEnvsCtx(
gcx: GhjkCtx,
): EnvsCtx {
let envsCtx = gcx.blackboard.get(envsCtxBlackboardKey) as
| EnvsCtx
| undefined;
if (!envsCtx) {
envsCtx = {
activeEnv: "",
config: {
defaultEnv: "",
envs: {},
},
};
gcx.blackboard.set(envsCtxBlackboardKey, envsCtx);
}
return envsCtx;
}
import type { EnvsCtx } from "./envs/mod.ts";
export function getEnvsCtx(
gcx: GhjkCtx,
): EnvsCtx {
let envsCtx = gcx.blackboard.get(envsCtxBlackboardKey) as
| EnvsCtx
| undefined;
if (!envsCtx) {
envsCtx = {
activeEnv: "",
config: {
defaultEnv: "",
envs: {},
},
};
gcx.blackboard.set(envsCtxBlackboardKey, envsCtx);
}
return envsCtx;
}

@@ -1,7 +1,7 @@
//! Integration between Ports and Envs module

import { expandGlobsAndAbsolutize, unwrapParseRes } from "../../utils/mod.ts";
import type { WellKnownProvision } from "../envs/types.ts";
import { Provision } from "../envs/types.ts";
Copy link

Choose a reason for hiding this comment

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

Consider using import type for Provision as it is only used as a type.

- import { Provision } from "../envs/types.ts";
+ import type { Provision } from "../envs/types.ts";

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
import { Provision } from "../envs/types.ts";
import type { Provision } from "../envs/types.ts";

conf: config,
manifest,
};
let downloadArts;
Copy link

Choose a reason for hiding this comment

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

Variables downloadArts and installArtifacts are implicitly typed as any. Consider specifying explicit types for better type safety and maintainability.

- let downloadArts;
+ let downloadArts: DownloadArtifacts;
- let installArtifacts;
+ let installArtifacts: InstallArtifacts;

Also applies to: 122-122

Committable suggestion was skipped due low confidence.

Comment on lines +17 to +56
export async function updateInstall(
gcx: GhjkCtx,
installId: string,
newVersion: string,
allowedDeps: Record<string, AllowedPortDep>,
) {
await using scx = await syncCtxFromGhjk(gcx);

const db = scx.db.val;

const install = await db.get(installId);

if (!install) {
throw new Error("InstallSetId not found in InstallsDb", {
cause: {
installId,
},
});
}

const config = install.conf;

if (config.version === newVersion) {
logger().info("Skipping update. Install is already uptodate");
return;
}

// it's a user specified install, so skip
if (config.specifiedVersion) {
logger().info(`Skipping Version Specified Install: ${installId}`);
return;
}

config.version = newVersion;
logger().info(`Updating installId ${installId} to version ${newVersion}...`);
await doInstall(installId, scx, install.manifest, allowedDeps, config);
logger().info(
`Successfully updated installId ${installId} to version ${newVersion}`,
);
}
Copy link

Choose a reason for hiding this comment

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

Tip

Codebase Verification

The verification scripts did not find any explicit error handling around the asynchronous operations in the updateInstall function. This indicates that the function might lack proper error handling for these operations.

  • Ensure that all asynchronous operations, such as await syncCtxFromGhjk(gcx) and await db.get(installId), are wrapped in try-catch blocks to handle potential errors.
  • Add appropriate logging within the catch blocks to aid in debugging.
Analysis chain

This function updateInstall handles various aspects of updating an installation. Ensure that all error paths are adequately handled and that logging is sufficient for debugging purposes.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the error handling paths in `updateInstall`.

# Test: Check for error handling in the function.
ast-grep --lang typescript --pattern $'export async function updateInstall($$$) { $$$ }'

Length of output: 2216



Script:

#!/bin/bash
# Description: Verify comprehensive error handling in the `updateInstall` function.

# Test: Check for error handling in all asynchronous operations within the function.
ast-grep --lang typescript --pattern $'await $_' --json | jq '.[] | select(.path == "modules/ports/utils.ts" and .lines[0] >= 17 and .lines[0] <= 56)'

Length of output: 151



Script:

#!/bin/bash
# Description: Verify error handling around specific asynchronous operations in the `updateInstall` function.

# Test: Check for error handling around `await syncCtxFromGhjk(gcx)` and `await db.get(installId)` within the function.
ast-grep --lang typescript --pattern $'try { await syncCtxFromGhjk($_); } catch ($_error) { $$$ }' --json | jq '.[] | select(.path == "modules/ports/utils.ts" and .lines[0] >= 17 and .lines[0] <= 56)'
ast-grep --lang typescript --pattern $'try { await db.get($_); } catch ($_error) { $$$ }' --json | jq '.[] | select(.path == "modules/ports/utils.ts" and .lines[0] >= 17 and .lines[0] <= 56)'

Length of output: 394

modules/envs/mod.ts Show resolved Hide resolved
@destifo destifo marked this pull request as ready for review May 28, 2024 13:41
Copy link
Contributor

@Yohe-Am Yohe-Am left a comment

Choose a reason for hiding this comment

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

Good stuff. Go ahead a merge it on top of the envs PR.

@destifo destifo merged commit 4722129 into feat/envs-module May 31, 2024
4 of 8 checks passed
@destifo destifo deleted the feat/ports-outdated branch May 31, 2024 07:56
Yohe-Am added a commit that referenced this pull request Jun 21, 2024
* feat(envs): Envs module

* feat: rework `ghjk.ts` interface and integrate with other modules

* wip: minor fixup

* fix: improve uninited dir experience

* wip: `$ ghjk envs sync`

* refactor(envs,cli)!: envs first cli (#48)

* refactor(envs): envs first CLI

* wip: missing file

* wip: wip

* wip: wip 2

* feat(tests): basic tests

* docs: some snippets for `README.md`

* doc: typo

* fix: `Deno.Command` troubles

* fix: cross platform shell fn for getting ctime

* fix: `!` as instId separator

* fix(tests): missing flag

* wip: wip

* feat: `ghjk p resolve`

* refactor: polish CLI code

* wip: clearEnv fix

* fix: vendor dax patch

* fix: forgotten change

* fix: use `@ghjk/dax` fork

* fix: remove vendor dir from Dockerfile

* feat: env hooks (#59)

* feat(envs,tasks): env `onEnter`/`onExit` hooks

* wip: anon tasks

* feat: anonymous tasks

* tests: anon tasks

* wip: wip

* feat: env onEnter/onExit hooks

* tests: env hook tests

* fix: bug in path outputs

* fix: use latest setup-ghjk

* fix: bug on check task

* chore: bump deno to 1.43.1

* fix: miss field in test harness

* fix: use `no-prune` on docker tests

* fix: don't rmi at all

* fix: timeout

* docs: metatype ecosystem banner in README.md (#49)

* docs: metatype ecosystem banner in README.md

* fix: utm

---------

Co-authored-by: Teo Stocco <[email protected]>

* fix(port): `cpy_bs` doesn't work on arm (#60)

* wip: linux/arm in docker on mac-14

* wip: try `custom-macos`

* wip: try inline docker

* wip: try `custom-macos`

* fix: remove unnecessary action

* fix: move platform flags into tests

* refactor: merge new job into matrix

* fix: broken aarch64 ports

* wip: log

* fix: diambiguate platforms in harness

* fix: silly ci bug

* fix: env depending on itself case

* fix: lint issue

* fix: use 5m timeout for everything

* refactor(envs): `GHJK_NEXTFILE` based env reloading (#83)

* wip: nextfile

* tests: nextfile

* refactor: pid based nextfile

* refactor: replace with ghjkdir vars instead of $HOME

* fix: env hook tests

* fix: bashisms

* feat(modules): ports outdated command (#62)

* wip(modules): add installSetIds to

* wip(modules-ports): read recipe.json and get cooked installSetIds

* wip(ports): wip for version getter func

* feat(modules): restrcutre ctx tree and recipe.json content

* feat(ports): add table to show version diff

* fix: fix unhandled prov type in envs/posix cook

* wip: wip update outdated installs

* wip: add ghjk file with multiple installs

* chore(test): wip add test

* refactor: refactor table structure and update cargo_binstall

* refactor(ghjk.ts): replace `secureConfig` with `hack.ts` (#87)

* refactor(ghjk.ts): replace secureConfig with hack.ts

* docs: improve README

* fix(ci): update action job

* fix: address llm feedback

* fix: cargo-binstall bug

* fix: ports outdated test fix

* feat!: metatype integration polish (#91)

* feat: multipl env inheritance

* refactor: handle GHJK_CLEANUP_POSIX edgecases

* feat: task on task inheritance

* fix: bugs!

* feat(port): `deno_ghrel`

* fix: `portsOutdated` tests

* fix: diamond inheritance bug

* small stuff

* fix: apply llm feedback

* fix: minor fixes

* fix: path var merging

* feat: `std.ts` and `sedLock`

* fix: task path combinations

* fix: task path combinations 2

* chore: set version 0.2.0

* fix: more target sed pattern

* fix(ci): pre-commit issue

* fix: 10m timeout

* fix: explicit GITHUB_TOKEN

---------

Co-authored-by: Teo Stocco <[email protected]>
Co-authored-by: Estifanos Bireda <[email protected]>
@coderabbitai coderabbitai bot mentioned this pull request Dec 29, 2024
4 tasks
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