auth0 / auth0-deploy-cli

The Auth0 Deploy CLI is a tool that helps you manage your Auth0 tenant configuration. It integrates into your development workflows as a standalone CLI or as a node module.
MIT License
236 stars 147 forks source link

Looking for action file in root folder during import #873

Open schazza opened 6 months ago

schazza commented 6 months ago

Checklist

Description

Since updating to 7.20.0 I get the following error when trying to import (a0deploy import --input_file ./src --config_file ./config/config-file.json): Unable to load file C:\Git\auth0-cicd\src\code.js due to Error: ENOENT: no such file or directory, access 'C:\Git\auth0-cicd\src\code.js'

Expectation

The import should work with this command without a code.js file in the src folder. Alternatively if this file is required some information on what it should include should have been added in the release notes for 7.20.0.

Reproduction

  1. Given a source folder that a repo has been exported to on version 7.18.0
  2. When running the command a0deploy import --input_file ./src --config_file ./config/config-file.json
  3. Then the tenant should be updated

Deploy CLI version

7.20.0

Node version

18.17.1

willvedd commented 6 months ago

As noted by the changelog for 7.20.0, there was added support for actions code files to be imported relative to the configuration file (#866). There must've been a regression included in that.

Looking closer, there is a loadFile function that allows for an absolute path or a path relative to the actions folder. The code that was added in #866 only accounts for the latter of the cases, which may explain this bug. Especially since you nest the config file in a config directory. I'm unable to recreate your specific issue, can you provide the action configuration file and the path of the exported code.js file?

schazza commented 6 months ago

Thanks for a fast response.

We have three actions that all look roughly like this:

{
  "name": "Add roles to ID token",
  "code": "code.js",
  "runtime": "node18",
  "status": "built",
  "dependencies": [],
  "secrets": [],
  "supported_triggers": [
    {
      "id": "post-login",
      "version": "v2"
    }
  ],
  "deployed": true
}

Path to the action configuration file is C:\Git\auth0-cicd\src\actions\Add roles to ID token.json Path to the code.js file is C:\Git\auth0-cicd\src\actions\Add roles to ID token\code.js

We set this up following this example: https://github.com/auth0/auth0-deploy-cli/tree/master/examples/directory/actions