Skip to content

feat!: metatype integration polish #91

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

Merged
merged 14 commits into from
Jun 20, 2024

Conversation

Yohe-Am
Copy link
Contributor

@Yohe-Am Yohe-Am commented Jun 13, 2024

Describe your change

  • Tasks and env can inherit from more than one env
  • Tasks and envs can now can inherit from tasks
  • Envs who's name is prefixed by an underscore no longer shop up in ghjk envs ls
  • Activate scrips are now more resilient to different shopts
  • deno_ghrel port
  • $GHJK_RE env var will force ghjk recreate lockfile
  • $GHJK_LOCKED env var will force ghjk to avoid re-serialization/use lockfile
  • Update deno to 1.44.2

Motivation and context

MET-347

Migration notes

  • task field on the object argument to the file function now takes an object instead of an array.
  • allowedBuildDeps builder function for envs now takes varargs instead of an array.
  • Lockfile format change that requires removing .ghjk/lock.json

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

    • Introduced a module for handling GitHub releases in Deno, enabling functions for downloading and installing Deno releases based on platform and architecture.
  • Refactor

    • Restructured environment and task handling for better maintainability and performance.
    • Updated import and export paths to reflect new module organization.
  • Bug Fixes

    • Fixed file handling logic to improve reliability and performance in various scripts and modules.
  • Chores

    • Updated dependencies and version numbers in the lock file for consistency and security.
  • Enhancements

    • Improved environment variable and task management, including better error handling and logging.
    • Enhanced CLI functionality with new flags and refined command handling.

Copy link

coderabbitai bot commented Jun 13, 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

This update introduces numerous changes to dependencies, configurations, and logic throughout the project. Key changes include dependency version adjustments, new dependencies, revisions in environment and task handling, refined control flows, and enhancements to CLI commands. Significant modifications to environment activation processes and task definitions are present, leading to a more flexible and robust system.

Changes

File Change Summary
.ghjk/lock.json Dependency version changes: downgraded tar_aa and zstd_aa, added deno_ghrel.
.github/workflows/tests.yml Changed OS configuration from custom-macos to custom-arm for jobs.
deps/cli.ts Removed export of zod_val_err from the deps/cli.ts file.
deps/common.ts Added export of zod_val_err from a different source.
examples/kitchen/ghjk.ts Updated tasks property, modified method calls, inheritance mechanisms, dependencies installation, and task definitions.
files/deno/worker.ts Added import and structured shimDenoNamespace function to set properties on Deno.
files/mod.ts Numerous changes: imports, variable declarations, type definitions, class methods, environment configurations, and task handling.
ghjk.ts Removed some imports and added ports.deno_ghrel function call.
host/mod.ts Introduced new flags, updated CLI function to handle flags and added version resolution.
host/types.ts Removed portsValidator import.
install/hook.fish Adjusted logic related to environment switching, file comparisons, and command substitution syntax.
install/hook.sh precmd() function now unsets GHJK_ENV before calling ghjk_reload when switching directories.
main.ts Introduced reFlagSet and lockedFlagSet flags, adjusted flag handling and default values.
mod.ts Updated configurations, build dependencies handling, task handling, and type definitions.
modules/envs/inter.ts Introduced function getEnvsCtx.
modules/envs/mod.ts Updated environment management, adjustments to environment activation, and enhancements to CLI commands.
modules/envs/posix.ts Updated variable names and refined logic for environment setup and activation, with improved script reliability.
modules/envs/types.ts Adjusted declarations to use moduleValidators.envVarName and updated installSetHashed.
modules/ports/inter.ts Renamed getInstallSetStore to getPortsCtx and updated context object.
modules/ports/mod.ts Updated imports and restructured function calls and variable assignments.
modules/ports/sync.ts Updated type definitions and refactored variable names for correct reference.
modules/tasks/deno.ts Added import of shimDenoNamespace and added _shimHandle variable assignment.
modules/tasks/exec.ts Removed DePromisify, added getEnvsCtx, commented pre-checks, updated error messages, and refined function call parameters.
modules/tasks/inter.ts Introduced function getTasksCtx.
modules/tasks/mod.ts Updated imports and sorted task definition keys for command creation.
modules/tasks/types.ts Adjusted validation schema, made env field optional, renamed envHash to envKey, and removed envs field.
modules/types.ts Refactored constants to include envVarName with validation regex, included in default export.
ports/act.ts Refactored file operations, updated file handling logic to use $.path, and restructured the file copying process.
ports/cargo-binstall.ts Updated logic for handling directories and file names, creating binDir for organization.
ports/deno_ghrel.ts Added a new module for handling GitHub releases in Deno.

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.

@Yohe-Am Yohe-Am changed the title feat: metatyp integration polish feat: metatype integration polish Jun 13, 2024
@Yohe-Am Yohe-Am force-pushed the refactor/metatyp-integ-work branch from a6c373d to f9342fa Compare June 13, 2024 08:50
@Yohe-Am Yohe-Am force-pushed the refactor/metatyp-integ-work branch from c410d01 to 225a971 Compare June 15, 2024 05:49
@Yohe-Am Yohe-Am changed the title feat: metatype integration polish feat! metatype integration polish Jun 15, 2024
@Yohe-Am Yohe-Am changed the title feat! metatype integration polish feat!: metatype integration polish Jun 15, 2024
@Yohe-Am Yohe-Am marked this pull request as ready for review June 15, 2024 14:35
@Yohe-Am
Copy link
Contributor Author

Yohe-Am commented Jun 15, 2024

@coderabbitai review

Copy link

coderabbitai bot commented Jun 15, 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 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: 20

Outside diff range and nitpick comments (11)
modules/ports/inter.ts (1)

Line range hint 24-39: Consider verifying the existence of id in graph.all before accessing it to avoid potential runtime errors.

- const inst = graph.all[id]!;
+ const inst = graph.all[id];
+ if (!inst) throw new Error(`Install ID ${id} not found in graph.`);
tests/envHooks.ts (1)

56-56: The addition of new test cases in envHooks.ts is crucial for ensuring the robustness of environment handling in different shell contexts. Consider adding more detailed comments explaining each test case scenario for better maintainability.

tests/reloadHooks.ts (1)

10-35: Ensure consistent error handling and messaging across tests for clarity and maintainability.

Consider using a centralized mechanism or constants for error codes and messages to avoid magic numbers and improve maintainability.

mod.ts (1)

Line range hint 132-173: Refactor the environment setup logic to improve clarity and maintainability.

-  const mainEnv = builder.addEnv(DEFAULT_BASE_ENV_NAME, {
-    name: DEFAULT_BASE_ENV_NAME,
-    inherit: args.defaultBaseEnv && args.defaultBaseEnv != DEFAULT_BASE_ENV_NAME
-      ? args.defaultBaseEnv
-      : false,
-    installs: args.installs,
-    desc: "the default default environment.",
-  });
-
-  const replaceDefaultBuildDeps = (args: SecureConfigArgs) => {
-    defaultBuildDepsSet.length = 0;
-    defaultBuildDepsSet.push(
-      ...reduceAllowedDeps(args.allowedBuildDeps ?? []),
-    );
-    const seenPorts = new Set(
-      defaultBuildDepsSet.map((dep) => dep.manifest.name),
-    );
-    for (
-      const dep of args.stdDeps !== false
-        ? stdDeps({ enableRuntimes: args.enableRuntimes ?? false })
-        : []
-    ) {
-      if (seenPorts.has(dep.manifest.name)) {
-        continue;
-      }
-      defaultBuildDepsSet.push(dep);
-    }
-    if (args.defaultBaseEnv) {
-      builder.addEnv(args.defaultBaseEnv, {
-        allowedBuildDeps: defaultBuildDepsSet,
-      });
-    } else {
-      mainEnv.allowedBuildDeps(...defaultBuildDepsSet);
-    }
-  };
+  function setupMainEnv() {
+    return builder.addEnv(DEFAULT_BASE_ENV_NAME, {
+      name: DEFAULT_BASE_ENV_NAME,
+      inherit: args.defaultBaseEnv && args.defaultBaseEnv != DEFAULT_BASE_ENV_NAME
+        ? args.defaultBaseEnv
+        : false,
+      installs: args.installs,
+      desc: "the default default environment.",
+    });
+  }
+
+  function replaceDefaultBuildDeps(args: SecureConfigArgs) {
+    defaultBuildDepsSet.length = 0;
+    defaultBuildDepsSet.push(
+      ...reduceAllowedDeps(args.allowedBuildDeps ?? []),
+    );
+    const seenPorts = new Set(
+      defaultBuildDepsSet.map((dep) => dep.manifest.name),
+    );
+    for (
+      const dep of args.stdDeps !== false
+        ? stdDeps({ enableRuntimes: args.enableRuntimes ?? false })
+        : []
+    ) {
+      if (seenPorts.has(dep.manifest.name)) {
+        continue;
+      }
+      defaultBuildDepsSet.push(dep);
+    }
+    if (args.defaultBaseEnv) {
+      builder.addEnv(args.defaultBaseEnv, {
+        allowedBuildDeps: defaultBuildDepsSet,
+      });
+    } else {
+      mainEnv.allowedBuildDeps(...defaultBuildDepsSet);
+    }
+  }
+
+  const mainEnv = setupMainEnv();
+  replaceDefaultBuildDeps(args);
modules/ports/mod.ts (1)

Line range hint 132-140: Convert function expressions to arrow functions where appropriate to improve readability and reduce verbosity.

- function (args) {
+ (args) => {

Also applies to: 266-268

modules/envs/posix.ts (1)

Line range hint 324-374: The array contains an empty slot, which can lead to unexpected behavior or errors in runtime.

- ...onEnterHooksEscaped.map((line) => `    ${line}`),
+ ...onEnterHooksEscaped.map((line) => `    ${line}`),  // Ensure no empty slots

Ensure that no empty slots are present in the array.

host/mod.ts (3)

22-23: Add documentation for the new flags reFlagSet and lockedFlagSet.

It would be beneficial for maintainability to add comments explaining the purpose of these flags both in the CliArgs and HostCtx structures.

Also applies to: 29-30


310-314: Add logging for hash file changes.

It would be useful to add debug logging here to trace when hash files are being written, which can help in understanding the flow of data and debugging.


Line range hint 328-352: Ensure proper handling of lockfile updates.

Consider adding more robust checks or a transaction mechanism to ensure that the lockfile updates are atomic and consistent, especially in environments where multiple instances might be accessing the file simultaneously.

modules/ports/sync.ts (2)

51-51: Clarify the purpose of SyncCtx with additional documentation.

Adding a brief comment describing the SyncCtx type's role would enhance code readability and maintainability.


275-275: Document the structure of InstallGraph.

It would be helpful to document the InstallGraph type, explaining its components and their interactions, especially since it seems central to the installation logic.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 0c5f785 and 5bb0d24.

Files ignored due to path filters (1)
  • deno.lock is excluded by !**/*.lock
Files selected for processing (43)
  • .ghjk/deno.lock (1 hunks)
  • .ghjk/lock.json (7 hunks)
  • .github/workflows/tests.yml (1 hunks)
  • deps/cli.ts (1 hunks)
  • deps/common.ts (1 hunks)
  • examples/kitchen/ghjk.ts (3 hunks)
  • files/deno/worker.ts (2 hunks)
  • files/mod.ts (26 hunks)
  • ghjk.ts (2 hunks)
  • host/mod.ts (10 hunks)
  • host/types.ts (1 hunks)
  • install/hook.fish (3 hunks)
  • install/hook.sh (1 hunks)
  • main.ts (1 hunks)
  • mod.ts (7 hunks)
  • modules/envs/inter.ts (1 hunks)
  • modules/envs/mod.ts (13 hunks)
  • modules/envs/posix.ts (7 hunks)
  • modules/envs/types.ts (3 hunks)
  • modules/ports/inter.ts (1 hunks)
  • modules/ports/mod.ts (9 hunks)
  • modules/ports/sync.ts (7 hunks)
  • modules/ports/types.ts (3 hunks)
  • modules/tasks/deno.ts (2 hunks)
  • modules/tasks/exec.ts (5 hunks)
  • modules/tasks/inter.ts (1 hunks)
  • modules/tasks/mod.ts (2 hunks)
  • modules/tasks/types.ts (2 hunks)
  • modules/types.ts (2 hunks)
  • ports/act.ts (2 hunks)
  • ports/cargo-binstall.ts (1 hunks)
  • ports/deno_ghrel.ts (1 hunks)
  • ports/mod.ts (1 hunks)
  • ports/temporal_cli.ts (2 hunks)
  • tests/envHooks.ts (1 hunks)
  • tests/envs.ts (2 hunks)
  • tests/ports.ts (2 hunks)
  • tests/portsOutdated.ts (2 hunks)
  • tests/reloadHooks.ts (2 hunks)
  • tests/tasks.ts (1 hunks)
  • tests/utils.ts (1 hunks)
  • utils/mod.ts (6 hunks)
  • utils/worker.ts (1 hunks)
Files not summarized due to errors (1)
  • .ghjk/deno.lock: Error: Message exceeds token limit
Files skipped from review due to trivial changes (3)
  • deps/cli.ts
  • host/types.ts
  • ports/mod.ts
Additional context used
Biome
tests/utils.ts

[error] 79-80: The call chain .map().flat() can be replaced with a single .flatMap() call. (lint/complexity/useFlatMap)

Safe fix: Replace the chain with .flatMap().

modules/ports/mod.ts

[error] 132-140: This function expression can be turned into an arrow function. (lint/complexity/useArrowFunction)

Function expressions that don't use this can be turned into arrow functions.
Safe fix: Use an arrow function instead.


[error] 266-268: This function expression can be turned into an arrow function. (lint/complexity/useArrowFunction)

Function expressions that don't use this can be turned into arrow functions.
Safe fix: Use an arrow function instead.

modules/envs/mod.ts

[error] 136-142: This function expression can be turned into an arrow function. (lint/complexity/useArrowFunction)

Function expressions that don't use this can be turned into arrow functions.
Safe fix: Use an arrow function instead.


[error] 156-162: This function expression can be turned into an arrow function. (lint/complexity/useArrowFunction)

Function expressions that don't use this can be turned into arrow functions.
Safe fix: Use an arrow function instead.


[error] 178-189: This function expression can be turned into an arrow function. (lint/complexity/useArrowFunction)

Function expressions that don't use this can be turned into arrow functions.
Safe fix: Use an arrow function instead.


[error] 203-215: This function expression can be turned into an arrow function. (lint/complexity/useArrowFunction)

Function expressions that don't use this can be turned into arrow functions.
Safe fix: Use an arrow function instead.

modules/envs/posix.ts

[error] 324-374: This array contains an empty slot. (lint/suspicious/noSparseArray)

Unsafe fix: Replace hole with undefined

host/mod.ts

[error] 121-125: This function expression can be turned into an arrow function. (lint/complexity/useArrowFunction)

Function expressions that don't use this can be turned into arrow functions.
Safe fix: Use an arrow function instead.


[error] 138-144: This function expression can be turned into an arrow function. (lint/complexity/useArrowFunction)

Function expressions that don't use this can be turned into arrow functions.
Safe fix: Use an arrow function instead.


[error] 150-156: This function expression can be turned into an arrow function. (lint/complexity/useArrowFunction)

Function expressions that don't use this can be turned into arrow functions.
Safe fix: Use an arrow function instead.


[error] 162-168: This function expression can be turned into an arrow function. (lint/complexity/useArrowFunction)

Function expressions that don't use this can be turned into arrow functions.
Safe fix: Use an arrow function instead.


[error] 180-190: This function expression can be turned into an arrow function. (lint/complexity/useArrowFunction)

Function expressions that don't use this can be turned into arrow functions.
Safe fix: Use an arrow function instead.


[error] 416-417: This case is falling through to the next case. (lint/suspicious/noFallthroughSwitchClause)

Add a break or return statement to the end of this case to prevent fallthrough.


[error] 497-499: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)

Unsafe fix: Omit the else clause.

modules/ports/sync.ts

[error] 813-823: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)

Unsafe fix: Omit the else clause.


[error] 817-823: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)

files/mod.ts

[error] 255-255: The assignment should not be in an expression. (lint/suspicious/noAssignInExpressions)

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

Gitleaks
.ghjk/deno.lock

130-130: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key)

Additional comments not posted (45)
ghjk.ts (1)

2-2: Integration of ports.deno_ghrel() appears correct and aligns with the new dependency addition mentioned in the PR.

Also applies to: 18-18

modules/envs/inter.ts (1)

4-26: The implementation of getEnvsCtx function is robust and follows good practices in managing shared state using a blackboard pattern.

modules/tasks/inter.ts (1)

4-25: The getTasksCtx function is well-implemented, utilizing a consistent pattern with other context management functions in the system.

modules/types.ts (1)

7-7: The addition of envVarName is a thoughtful extension to the type definitions, supporting the enhanced environment and task management features introduced in this PR.

Also applies to: 26-26

modules/ports/inter.ts (1)

5-16: Well implemented context retrieval pattern using the blackboard.

tests/portsOutdated.ts (1)

13-13: Please clarify or resolve the FIXME note here.

files/deno/worker.ts (1)

10-10: Proper handling of Deno namespace modification before other operations.

deps/common.ts (2)

13-13: Revised export of zod_val_err aligns with the new architectural decisions as mentioned in the AI-generated summary. Ensure this change is consistently reflected in all files that use zod_val_err.


5-13: Ensure that all dependencies are appropriately used in the project to prevent any potential issues due to unused imports.

ports/deno_ghrel.ts (1)

1-76: The implementation in deno_ghrel.ts for handling Deno-specific GitHub releases is well-structured. The use of osXarch and error handling in the downloadUrls method are particularly noteworthy. Ensure that the error messages are descriptive enough to aid in debugging.

.github/workflows/tests.yml (1)

47-47: Ensure the new ARM environment is fully supported and integrated.

The addition of a custom ARM environment (line 47) is a significant change. It's important to verify that all dependencies, scripts, and tools used in the tests are compatible with ARM architecture. This verification might include checking compatibility of software installed during the test, ensuring that all scripts run correctly, and that performance metrics are within expected ranges.

Verification successful

The custom-arm environment has been added to the matrix strategy in the test-e2e job. However, there are no architecture-specific configurations or dependencies that would impact the ARM environment's integration.

  • The platform is set appropriately for ARM (linux/aarch64).
  • The e2eType is set to docker, which should work across different architectures as long as the Docker setup is compatible.
  • The steps in the test-e2e job do not contain any architecture-specific commands or dependencies that would fail on ARM.

Thus, it appears that the addition of the custom-arm environment is properly integrated and should work as expected.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify ARM compatibility for all tools and scripts used in tests.

# Check for any scripts or dependencies specific to architecture in the test setup
rg --type yaml "script|dependency" --files-with-matches .github/workflows/tests.yml | xargs cat

Length of output: 97



Script:

#!/bin/bash
# Description: Verify ARM compatibility by searching for architecture-specific references and commands in the CI workflow.

# Display the entire content of the workflow file to manually inspect for architecture-specific configurations
cat .github/workflows/tests.yml

# Search for any usage of the 'custom-arm' environment in the workflow file
rg 'custom-arm' .github/workflows/tests.yml

Length of output: 2502

modules/tasks/types.ts (1)

16-16: Validate the implications of making the env field optional and introducing envKey.

The changes to the task definition types (lines 16 and 20) could have significant implications on how tasks are configured and validated. It's crucial to ensure that these changes do not introduce any inconsistencies or unexpected behaviors in task configurations. Consider verifying the integration and behavior of these new fields with existing task setups.

Also applies to: 20-20

Verification successful

The results show that the env field has been made optional and the envKey field has been introduced and integrated into the task definitions and execution flow. The integration appears to be consistent, as the envKey is used in the task execution process to fetch and cook the environment configurations.

  • The env field being optional is handled appropriately in the taskDefFullBase schema.
  • The envKey field is correctly used in the task execution flow to reference environment configurations.

No inconsistencies or missing implementations related to these fields were found in the task creation and execution process.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the integration of `env` and `envKey` fields in task configurations.

# Check for any task configurations that might be impacted by the changes in validation.
rg --type ts "taskDef" --files-with-matches modules/tasks/*.ts | xargs cat

Length of output: 8454



Script:

#!/bin/bash
# Description: Verify task creation and modification instances for handling `env` and `envKey` fields.

# Search for task creation and modification instances in the codebase.
rg --type ts "taskDef" --files-with-matches | xargs cat

# Check for usages of `envKey` in the codebase to ensure it is correctly integrated.
rg --type ts "envKey" --files-with-matches | xargs cat

Length of output: 85007

modules/tasks/deno.ts (2)

11-11: Import of shimDenoNamespace correctly added for environment adjustments in Deno namespace.


64-64: Proper use of shimDenoNamespace to ensure the Deno namespace is correctly configured before module execution.

modules/tasks/mod.ts (2)

13-13: Import and usage of getTasksCtx correctly implemented for initializing the task context.


57-82: Enhancements to command generation provide dynamic and flexible handling of tasks based on configuration.

modules/envs/types.ts (1)

38-38: Addition of moduleValidators.envVarName enhances the validation of environment variable names, ensuring configuration integrity.

tests/tasks.ts (1)

154-156: Transformation of tasks from an array to an object enhances lookup efficiency and organization in test setups.

examples/kitchen/ghjk.ts (3)

99-108: Significant changes to the python environment to ensure true isolation by not inheriting from defaultBaseEnv. Ensure all dependencies and configurations are correctly isolated as intended.


36-47: Refined the mechanism for specifying allowed build dependencies. Verify that the new configuration does not introduce any unexpected behaviors in build processes.

Verification successful

The new configuration for specifying allowed build dependencies in examples/kitchen/ghjk.ts aligns with the intended behavior and does not introduce unexpected dependencies.

  • env("main") configuration includes ports.node({}), ports.rust({ version: "stable" }), and stdDeps({ enableRuntimes: true }).
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the new allowed build dependencies configuration is correctly used in build processes.
rg --type ts "allowedBuildDeps" --files-with-matches | xargs rg --type ts "ports\..*\(\)"

Length of output: 464



Script:

#!/bin/bash
# Detailed inspection of the allowedBuildDeps configuration in the specific file and lines
rg --type ts "allowedBuildDeps" examples/kitchen/ghjk.ts -A 5 -B 5

Length of output: 1701


111-116: Introduced the ability for environments to inherit from multiple other environments. Confirm that there are no conflicts or overrides that could affect the expected behavior.

Verification successful

The extracted definitions show that the main environment sets a variable (RUST_LOG), installs a program (jq_ghrel), and allows certain build dependencies (node). The python environment installs a specific version of Python and allows it as a build dependency. There are no direct conflicts between these definitions.

  • main environment:

    • Sets RUST_LOG variable.
    • Installs jq_ghrel.
    • Allows node as a build dependency.
  • python environment:

    • Installs Python 3.8.18.
    • Allows Python 3.8.18 as a build dependency.

No conflicts or overrides were found that could affect the expected behavior of the dev environment.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the multiple inheritance in the `dev` environment is handled correctly without conflicts.
rg --type ts "env\(\"dev\"\)" --files-with-matches | xargs rg --type ts "\.inherit"

Length of output: 132



Script:

#!/bin/bash
# Description: Search for variable and build dependency definitions in the `main` and `python` environments to check for conflicts.
rg --type ts 'env\("main"\)' --files-with-matches | xargs rg --type ts 'set\(|build\('
rg --type ts 'env\("python"\)' --files-with-matches | xargs rg --type ts 'set\(|build\('

Length of output: 179



Script:

#!/bin/bash
# Description: Search for all environment configurations and their properties in the `main` and `python` environments to check for conflicts.
rg --type ts 'env\("main"\)' --files-with-matches | xargs rg --type ts 'env\('
rg --type ts 'env\("python"\)' --files-with-matches | xargs rg --type ts 'env\('

Length of output: 515



Script:

#!/bin/bash
# Description: Extract the complete definitions of the `main` and `python` environments to check for conflicts.
rg --type ts 'env\("main"\)' --files-with-matches | xargs rg -A 10 'env\("main"'
rg --type ts 'env\("python"\)' --files-with-matches | xargs rg -A 10 'env\("python"'

Length of output: 1849

install/hook.sh (1)

99-103: Improved handling of environment variables when switching directories. Ensure that this change does not interfere with environment persistence across sessions.

Verification successful

The change to unset GHJK_ENV when switching directories does not interfere with environment persistence across sessions, as there is no mechanism for persisting GHJK_ENV in the script.

  • install/hook.sh: The unset command for GHJK_ENV and its usage.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the environment variable handling does not interfere with persistence.
rg --type sh "GHJK_ENV" --files-with-matches | xargs rg --type sh "unset"

Length of output: 173



Script:

#!/bin/bash
# Find where GHJK_ENV is set
rg --type sh "GHJK_ENV="

# Check the usage of GHJK_ENV throughout the script
rg --type sh "GHJK_ENV"

# Look for any persistence mechanisms for GHJK_ENV
rg --type sh "save" | xargs rg --type sh "GHJK_ENV"

Length of output: 580

install/hook.fish (1)

16-18: Enhanced handling of GHJK_ENV when switching directories in Fish shell. Confirm that this logic aligns with the behavior in other shell environments to maintain consistency.

Verification successful

To ensure consistency in handling GHJK_ENV across different shell scripts, let's gather detailed information on how GHJK_ENV is managed in the Fish script (install/hook.fish) and the corresponding logic in other shell scripts.


The review comment's concern about the consistency of GHJK_ENV handling across different shell environments is valid. The gathered information shows:

  • In install/hook.fish, GHJK_ENV is set conditionally and ignored when switching directories.
  • In install/hook.sh, GHJK_ENV is also conditionally set, and it is explicitly unset when switching directories.

Both scripts handle GHJK_ENV similarly, ensuring that it is ignored or unset when switching directories, maintaining consistency across shell environments.

  • install/hook.fish

    test -z $next_env; and set next_env "$GHJK_ENV"
    # we ignore previously loaded GHJK_ENV when switching 
  • install/hook.sh

    next_env="${1:-${GHJK_ENV:-default}}";
    # we ignore previously loaded GHJK_ENV when switching 
    unset GHJK_ENV

Hence, the logic aligns well across the scripts.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Compare the handling of `GHJK_ENV` in different shell scripts to ensure consistency.
rg --type sh "GHJK_ENV" --files-with-matches | xargs rg --type sh "unset"

Length of output: 173



Script:

#!/bin/bash
# Description: Gather detailed information on handling `GHJK_ENV` in Fish and other shell scripts.

# Search for the handling of `GHJK_ENV` in the Fish script
rg --type fish "GHJK_ENV" install/hook.fish

# Search for the handling of `GHJK_ENV` in other shell scripts
rg --type sh "GHJK_ENV" install/hook.sh

Length of output: 418

tests/reloadHooks.ts (1)

Line range hint 43-77: Review the use of environment variable checks and dummy commands in test scripts.

Verification successful

The search results indicate that the DUMMY_ENV and dummy commands are used extensively throughout the test scripts, including the file tests/reloadHooks.ts. The checks for environment variables and the usage of the dummy command appear to be correctly implemented as per the review comment.

  • The environment variable DUMMY_ENV is checked multiple times using different methods (e.g., [ "\${DUMMY_ENV:-}" = "dummy" ]).
  • The dummy command is invoked and checked to ensure it behaves as expected.

These findings align with the review comment's focus on verifying the correct usage of environment variable checks and dummy commands.

However, the extensive usage across multiple files suggests a thorough review might be necessary to ensure all instances are correctly implemented. Since the verification script results align with the review comment, no immediate issues are found in the provided snippet.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the environment variable and dummy command checks are correctly implemented in the test scripts.

# Test: Search for usage of `DUMMY_ENV` and `dummy` in test scripts. Expect: Correct checks and command usage.
rg --type bash $'DUMMY_ENV|dummy'

Length of output: 63



Script:

#!/bin/bash
# Description: Verify that the environment variable and dummy command checks are correctly implemented in the test scripts.

# Test: Search for usage of `DUMMY_ENV` and `dummy` in all files. Expect: Correct checks and command usage.
rg 'DUMMY_ENV|dummy'

Length of output: 2695

tests/ports.ts (1)

113-117: Added test case for Deno port appears correctly implemented.

Ensure that the deno --version command is available and functions as expected in the testing environment.

modules/tasks/exec.ts (1)

Line range hint 119-163: Review the task execution logic for handling Deno file tasks.

Verification successful

The implementation of execTaskDeno has been successfully retrieved. Here is the relevant function:

export async function execTaskDeno(
  moduleUri: string,
  args: ExecTaskArgs,
) {
  const resp = await rpc(moduleUri, {
    ty: "exec",
    uri: moduleUri,
    args,
  });
  if (resp.ty != "exec") {
    throw new Error(`invalid response type: ${resp.ty}`);
  }
}

This function sends an RPC request to execute a task and checks the response type to ensure it matches the expected "exec" type. If the response type is incorrect, it throws an error.

  • execTaskDeno is correctly handling the execution of tasks by making an RPC call and validating the response.
  • Error handling is in place to catch and report invalid response types.

No issues were found with the task execution logic for handling Deno file tasks.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the task execution logic, especially for Deno file tasks.

# Test: Search for usage of `execTaskDeno` and related logic. Expect: Correct implementation and error handling.
rg --type typescript $'execTaskDeno'

Length of output: 70



Script:

#!/bin/bash
# Description: Verify the task execution logic, especially for Deno file tasks.

# Test: Search for usage of `execTaskDeno` and related logic. Expect: Correct implementation and error handling.
rg --type ts 'execTaskDeno'

Length of output: 197



Script:

#!/bin/bash
# Description: Retrieve the implementation of `execTaskDeno` to verify its logic.

# Extract the implementation of `execTaskDeno` from modules/tasks/deno.ts
ast-grep --lang typescript --pattern $'export async function execTaskDeno($_) {
  $$$
}' 

Length of output: 89



Script:

#!/bin/bash
# Description: Retrieve the implementation of `execTaskDeno` to verify its logic.

# Extract the implementation of `execTaskDeno` from modules/tasks/deno.ts
ast-grep --lang typescript --pattern $'export async function execTaskDeno($_) {
  $$$
}' modules/tasks/deno.ts

Length of output: 111



Script:

#!/bin/bash
# Description: Retrieve the implementation of `execTaskDeno` to verify its logic.

# Directly search for the function implementation in modules/tasks/deno.ts
rg 'export async function execTaskDeno' modules/tasks/deno.ts -A 20

Length of output: 333

mod.ts (1)

92-92: Ensure tasks are properly typed and documented, especially since they now use a Record structure.

Verification successful

The search results show multiple references to tasks across various files. To ensure that the new Record structure is properly implemented and used, we need to verify a few key points:

  1. Definition Consistency: Ensure that tasks is consistently defined as Record<string, DenoTaskDefArgs> where applicable.
  2. Usage Alignment: Verify that the usage of tasks aligns with the new structure, especially in object manipulations and function arguments.

Let's generate a script to check the definitions and usages in detail.


The search results confirm that the tasks property is defined using Record<string, DenoTaskDefArgs> and its usage in object manipulations aligns with the new structure. Specifically:

  • Definition Consistency: The tasks property is defined as Record<string, DenoTaskDefArgs> in mod.ts.
  • Usage Alignment: The usage of tasks in object manipulations (e.g., Object.entries(args.tasks ?? {})) is consistent with the new structure.

No further issues were found based on the provided context and the verification scripts.

  • mod.ts: tasks is defined and used correctly.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the usage of `tasks` throughout the application to ensure they align with the new `Record` structure.

# Test: Search for task usage. Expect: Proper handling of the new structure.
rg --type ts $'tasks'

Length of output: 5386



Script:

#!/bin/bash
# Description: Verify the consistency of `tasks` definition and its usage alignment with the new `Record` structure.

# Check for definitions of `tasks` to ensure they use `Record<string, DenoTaskDefArgs>`
rg --type ts 'tasks\?: Record<string, DenoTaskDefArgs>'

# Check for object manipulations and function arguments involving `tasks`
rg --type ts 'Object\.entries\(\s*args\.tasks' -A 3
rg --type ts 'Object\.entries\(\s*moduleConfig\.tasks' -A 3
rg --type ts 'Object\.fromEntries\(\s*this\.\#tasks' -A 3

Length of output: 685

tests/envs.ts (1)

244-260: Ensure task inheritance is thoroughly tested, especially where tasks inherit environment variables.

Verification successful

To proceed, we need to extract and analyze the specific test cases in tests/envs.ts that involve task inheritance. This will help us determine if the inheritance of environment variables and other properties is thoroughly tested.


The extracted test cases from tests/envs.ts confirm that task inheritance, including the inheritance of environment variables, is thoroughly tested. Here are the relevant sections:

  • env_inherit_from_envs: Tests inheritance of environment variables from one environment to another.
  • task_inherit_from_envs: Tests inheritance of environment variables from an environment to a task.
  • env_inherit_from_tasks: Tests inheritance of environment variables from a task to an environment.
  • task_inherit_from_task: Tests inheritance of environment variables from one task to another.
  • inheritance_diamond: Tests complex inheritance scenarios involving multiple environments.

These test cases cover various scenarios, ensuring that task inheritance is correctly implemented and verified.

  • env_inherit_from_envs:

    {
      name: "env_inherit_from_envs",
      ePoint: "fish",
      envs: [],
      secureConfig: {
        defaultEnv: "e1",
        envs: [
          { name: "e1", inherit: "e2" },
          {
            name: "e2",
            vars: { HEY: "hello" },
          },
        ],
      },
      stdin: `
      test "$GHJK_ENV" = "e1"; or exit 101
      test "$HEY" = "hello"; or exit 102
      `,
    }
  • task_inherit_from_envs:

    {
      name: "task_inherit_from_envs",
      ePoint: "fish",
      envs: [],
      secureConfig: {
        envs: [{ name: "e1", vars: { HEY: "hello" } }],
        tasks: { t1: { inherit: "e1", fn: ($) => $`echo $HEY` } },
      },
      stdin: `
      set fish_trace 1
      test (ghjk x t1) = "hello"; or exit 102
      `,
    }
  • env_inherit_from_tasks:

    {
      name: "env_inherit_from_tasks",
      ePoint: "fish",
      envs: [],
      secureConfig: {
        defaultEnv: "e1",
        envs: [{ name: "e1", inherit: "t1" }],
        tasks: { t1: { vars: { HEY: "hello" } } },
      },
      stdin: `
      set fish_trace 1
      test "$GHJK_ENV" = "e1"; or exit 101
      test "$HEY" = "hello"; or exit 102
      `,
    }
  • task_inherit_from_task:

    {
      name: "task_inherit_from_task",
      ePoint: "fish",
      envs: [],
      secureConfig: {
        tasks: {
          t1: { vars: { HEY: "hello" }, fn: ($) => $`echo fake` },
          t2: {
            inherit: "t1",
            fn: ($) => $`echo $HEY`,
          },
        },
      },
      stdin: `
      set fish_trace 1
      test (ghjk x t2) = "hello"; or exit 102
      `,
    }
  • inheritance_diamond:

    {
      name: "inheritance_diamond",
      ePoint: "fish",
      envs: [
        { name: "e1", vars: { E1: "1" }, installs: [dummy({ output: "e1" })] },
        {
          name: "e2",
          inherit: "e1",
          vars: { E2: "2" },
        },
        {
          name: "e3",
          inherit: "e1",
          vars: { E3: "3" },
        },
        {
          name: "e4",
          inherit: ["e2", "e3"],
          vars: { E4: "4" },
        },
      ],
      stdin: `
      set fish_trace 1
      test "$E1" = "1"; or exit 101
      test "$E2" = "2"; or exit 102
      test "$E3" = "3"; or exit 103
      test "$E4" = "4"; or exit 104
      test (dummy) = "e1"; or exit 105
      `,
    }

These test cases demonstrate that the task inheritance feature is well-covered and verified.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that task inheritance is correctly implemented and covered by tests.

# Test: Search for task inheritance implementation and test coverage.
rg --type ts $'inherit'

Length of output: 3568



Script:

#!/bin/bash
# Extract and display the relevant test cases from tests/envs.ts that involve task inheritance.
rg --context 5 'inherit' tests/envs.ts

Length of output: 3618

modules/envs/mod.ts (3)

15-23: Refactored imports and function usage from ../ports/inter.ts improve modularity by separating concerns.


21-22: Integration of getTasksCtx from ../tasks/inter.ts allows task context to be fetched, enhancing the functionality of environment commands.


112-119: The filtering and mapping logic to exclude environments starting with underscores is clear and effective. This is a good use of chaining array methods for concise data processing.

modules/envs/posix.ts (2)

16-19: The function cookPosixEnv now explicitly requires envKey and envDir parameters, which enhances clarity and ensures that the environment is correctly specified for cooking.


42-42: Explicitly setting GHJK_ENV in the environment variables map is a good practice to ensure that the environment is correctly recognized across different parts of the application.

utils/mod.ts (2)

12-12: Adding zod_val_err to the imports in this file extends the error handling capabilities by utilizing validation error formatting from Zod.


183-183: The use of logger().debug in defaultCommandBuilder provides detailed logging for command execution, which is useful for debugging and ensuring command processes are clear.

.ghjk/lock.json (3)

73-76: Addition of deno_ghrel dependency.

The addition of the deno_ghrel dependency is noted. Please ensure that all necessary documentation and usage examples are updated accordingly to reflect this change.


21-21: Version downgrades for tar_aa and zstd_aa need justification.

Please provide a rationale for downgrading these dependencies. This is crucial to ensure that there are no regressions or loss of features that might affect the stability or security of the system.

Also applies to: 27-27, 45-45, 51-51, 61-61, 67-67


97-98: Configuration changes in the config section.

Configuration changes have been made in the config section, including updates to installation sets and environment provisions. Please verify that these changes align with the intended system architecture and do not introduce configuration drift.

Also applies to: 100-101, 103-104, 120-126, 128-141

host/mod.ts (2)

36-39: Ensure that both flags GHJK_LOCKED and GHJK_RE cannot be set simultaneously.

The logic to prevent both GHJK_LOCKED and GHJK_RE from being set at the same time is correctly implemented.


Line range hint 222-243: Validate module entries during lockfile processing.
[REFACTOR_SUGGESTion]
Consider adding validation for the structure and contents of foundLockObj.config.modules before processing to ensure data integrity.

files/mod.ts (5)

7-7: The addition of imports for deep_eql, multibase32, multibase64, and zod supports the enhanced validation and encoding functionalities introduced in this update.


Line range hint 54-106: The updated type definitions for EnvParent, EnvDefArgs, TaskFnArgs, TaskFn, and TaskDefArgs effectively support the new functionalities around environment inheritance and task configurations.


Line range hint 136-501: The modifications in the Ghjkfile class methods such as addInstall, setAllowedPortDeps, addTask, and addEnv enhance the management of installations, dependencies, tasks, and environments, aligning well with the PR's objectives.


387-501: The implementation of new functionalities for handling environment variable conflicts (#mergeEnvs) and task execution (execTask) is robust and aligns with the enhanced capabilities described in the PR.

Also applies to: 295-306


Line range hint 5-1093: Overall, the changes in files/mod.ts are well-integrated and enhance the project's functionality regarding environment and task management. The code is well-structured and follows best practices in software development.

@Yohe-Am Yohe-Am merged commit 8cbcb3d into feat/envs-module Jun 20, 2024
8 checks passed
@Yohe-Am Yohe-Am deleted the refactor/metatyp-integ-work branch June 20, 2024 23:21
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]>
@Yohe-Am Yohe-Am mentioned this pull request Jun 25, 2024
3 tasks
@coderabbitai coderabbitai bot mentioned this pull request Dec 29, 2024
6 tasks
@coderabbitai coderabbitai bot mentioned this pull request Jun 19, 2025
3 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.

1 participant