Code Monkey home page Code Monkey logo

assembler's Introduction

@adonisjs/assembler


gh-workflow-image npm-image license-image

Introduction

AdonisJS Assembler is a development toolkit used by AdonisJS to perform tasks like starting the dev server in watch mode, running tests in watch mode, and applying codemods to modify source files.

Assembler should always be installed as a development dependency. If your project needs Assembler APIs in production, you must reconsider your approach.

Goals

Assembler is built around the following goals.

  • Expose a coding interface and not a user interface. In other words, Assembler will never expose any CLI commands.
  • Encapsulate tasks under a single API. Instead of providing ten different utilities to run a dev server, Assembler will expose one API to run the dev server.
  • House all development APIs needed by AdonisJS. Therefore, the scope of the Assembler might increase over time.

Dev server

You can start the HTTP server of an AdonisJS application using the node --loader=ts-node/esm bin/server.ts file. However, this approach has some limitations and may not provide the best DX.

Using a file watcher

You might be tempted to use the Node.js built-in file watcher with the --watch flag. However, the Node.js file watcher does not integrate with TypeScript. As a result, you will be tweaking its configuration options to get an ideal experience.

On the other hand, the Assembler file watcher takes the following approach.

  • Parses the tsconfig.json file to collect the list of files that are part of your TypeScript project. As a result, if you ever want to ignore any file, you do it directly within the tsconfig.json file, and the watcher will pick it up.
  • It uses the metaFiles array defined inside the adonisrc.ts file to watch additional files that are not .js or .ts. It may be the Edge templates, markdown files, YAML files, etc.

Starting the asset bundler server

If you create a full-stack application, the chances of using Webpack or Vite are high. Instead of starting your assets bundler inside a separate process, you can also rely on Assembler to start a parallel process for the assets bundler.

The node ace serve command detects the assets bundler used by your AdonisJS project and passes it to Assembler.

Therefore, if you run the serve command with a vite.config.js file, you will notice that the Assembler will start both Vite and the AdonisJS HTTP server.

Picking a random port

The PORT on which an AdonisJS application should run is configured inside the .env file of your AdonisJS application. However, you will often start multiple projects together and have to edit the .env file to ensure both projects run on different ports.

With Assembler, you do not have to edit the .env files since Assembler will pick a random port of your application if the configured one is already in use.

Usage

You may import and use the DevServer as follows.

import ts from 'typescript'
import { DevServer } from '@adonisjs/assembler'

const appRoot = new URL('./', import.meta.url)

const devServer = new DevServer(appRoot, {
  /**
   * Arguments to pass to the "bin/server.ts" file
   */
  scriptArgs: [],

  /**
   * Arguments to pass to the Node.js CLI
   */
  nodeArgs: [],

  /**
   * An array of metaFiles to watch and re-start the
   * HTTP server only if the "reloadServer" flag is
   * true.
   */
  metaFiles: [
    {
      pattern: 'resources/views/**/*.edge',
      reloadServer: false,
    }
  ],

  /**
   * The assets bundler process to start
   */
  assets: {
    enabled: true,
    name: 'vite',
    cmd: 'vite',
    args: []
  }
})

devServer.onError((error) => {
  process.exitCode = 1
})
devServer.onClose((exitCode) => {
  process.exitCode = exitCode
})

await devServer.runAndWatch(ts)

You may start the dev server and assets bundler dev server using the start method.

await devServer.start()

Test runner

The TestRunner is used to execute the bin/test.ts file of your AdonisJS application. Like the DevServer, the TestRunner allows you to watch for file changes and re-run the tests. The following steps are taken to re-run tests in watch mode.

Note

Read Using a file watcher section to understand which files are watched by the file watcher.

  • If the changed file is a test file, only tests for that file will be re-run.
  • Otherwise, all tests will re-run with respect to the initial filters applied when running the node ace test command.

Usage

You may import and use the TestRunner as follows.

import ts from 'typescript'
import { TestRunner } from '@adonisjs/assembler'

const appRoot = new URL('./', import.meta.url)

const runner = new TestRunner(appRoot, {
  /**
   * Arguments to pass to the "bin/test.ts" file
   */
  scriptArgs: [],

  /**
   * Arguments to pass to the Node.js CLI
   */
  nodeArgs: [],

  /**
   * An array of suites and their glob patterns
   */
  suites: [
    {
      name: 'unit',
      files: ['tests/unit/**/*.spec.ts']
    },
    {
      name: 'functional',
      files: ['tests/functional/**/*.spec.ts']
    }
  ],

  /**
   * Initial set of filters to apply. These filters
   * will be re-applied when re-running tests in
   * watch mode
   */
  filters: {
    suites: ['unit'],
    tags: ['@slow']
  }
})

await runner.runAndWatch(ts)

You can run tests without the watcher using the run method.

await runner.run()

Bundler

The Bundler is used to create the production build of an AdonisJS application. The following steps are performed to generate the build.

  • Clean up the existing build directory.
  • Compile frontend assets (if an assets bundler is configured).
  • Create JavaScript build using tsc (The TypeScript's official compiler).
  • Copy the ace.js file to the build folder. Since the ace file ends with the .js extension, it is not compiled by the TypeScript compiler.
  • Copy package.json and the lock-file of the package manager you are using to the build folder. This operation only supports bun | npm | yarn | pnpm. For other bundlers, you will have to copy the lock file manually.
  • The end.

Usage

You may import and use the Bundler as follows.

import ts from 'typescript'
import { Bundler } from '@adonisjs/assembler'

const appRoot = new URL('./', import.meta.url)

const bundler = new Bundler(appRoot, ts, {
  /**
   * Metafiles to copy to the build folder
   */
  metaFiles: [
    {
      pattern: 'resources/views/**/*.edge',
      reloadServer: false,
    }
  ],

  /**
   * The assets bundler to use to bundle the frontend
   * assets
   */
  assets: {
    enabled: true,
    name: 'vite',
    cmd: 'vite',
    args: ['build']
  }
})

Codemods

Assembler also exports certain codemods to modify the source files of an AdonisJS project to configure packages.

The codemods relies on the defaults of AdonisJS and will not work if a project does not follow the defaults. This is an intentional limit since we only have limited time to craft codemods that work with every possible setup.

Usage

You may import and use the Codemods as follows.

import { CodeTransformer } from '@adonisjs/assembler/code_transformer'

const appRoot = new URL('./', import.meta.url)

const transformer = new CodeTransformer(appRoot)

defineEnvValidations

Define validation rules for environment variables. The method accepts a key-value pair of variables. The key is the env variable name, and the value is the validation expression as a string.

Important

This codemod expects the start/env.ts file to exist and must have the export default await Env.create method call.

Also, the codemod does not overwrite the existing validation rule for a given environment variable. This is done to respect in-app modifications.

const transformer = new CodeTransformer(appRoot)

try {
  await transformer.defineEnvValidations({
    leadingComment: 'App environment variables',
    variables: {
      PORT: 'Env.schema.number()',
      HOST: 'Env.schema.string()',
    }
  })
} catch (error) {
  console.error('Unable to define env validations')
  console.error(error)
}

Output

import { Env } from '@adonisjs/core/env'

export default await Env.create(new URL('../', import.meta.url), {
  PORT: Env.schema.number(),
  HOST: Env.schema.string(),
})

addMiddlewareToStack

Register AdonisJS middleware to one of the known middleware stacks. The method accepts the middleware stack and an array of middleware to register.

The middleware stack could be one of server | router | named.

Important

This codemod expects the start/kernel.ts file to exist and must have a function call for the middleware stack for which you are trying to register a middleware.

const transformer = new CodeTransformer(appRoot)

try {
  await transformer.addMiddlewareToStack('router', [
    {
      path: '@adonisjs/core/bodyparser_middleware'
    }
  ])
} catch (error) {
  console.error('Unable to register middleware')
  console.error(error)
}

Output

import router from '@adonisjs/core/services/router'

router.use([
  () => import('@adonisjs/core/bodyparser_middleware')
])

You may define named middleware as follows.

const transformer = new CodeTransformer(appRoot)

try {
  await transformer.addMiddlewareToStack('named', [
    {
      name: 'auth',
      path: '@adonisjs/auth/auth_middleware'
    }
  ])
} catch (error) {
  console.error('Unable to register middleware')
  console.error(error)
}

updateRcFile

Register providers, commands, define metaFiles and commandAliases to the adonisrc.ts file.

Important

This codemod expects the adonisrc.ts file to exist and must have an export default defineConfig function call.

const transformer = new CodeTransformer(appRoot)

try {
  await transformer.updateRcFile((rcFile) => {
    rcFile
      .addProvider('@adonisjs/lucid/db_provider')
      .addCommand('@adonisjs/lucid/commands'),
      .setCommandAlias('migrate', 'migration:run')
  })
} catch (error) {
  console.error('Unable to update adonisrc.ts file')
  console.error(error)  
}

Output

import { defineConfig } from '@adonisjs/core/app'

export default defineConfig({
  commands: [
    () => import('@adonisjs/lucid/commands')
  ],
  providers: [
    () => import('@adonisjs/lucid/db_provider')
  ],
  commandAliases: {
    migrate: 'migration:run'
  }
})

addJapaPlugin

Register a Japa plugin to the tests/bootstrap.ts file.

Important

This codemod expects the tests/bootstrap.ts file to exist and must have the export const plugins: Config['plugins'] export.

const transformer = new CodeTransformer(appRoot)

const imports = [
  {
    isNamed: false,
    module: '@adonisjs/core/services/app',
    identifier: 'app'
  },
  {
    isNamed: true,
    module: '@adonisjs/session/plugins/api_client',
    identifier: 'sessionApiClient'
  }
]
const pluginUsage = 'sessionApiClient(app)'

try {
  await transformer.addJapaPlugin(pluginUsage, imports)
} catch (error) {
  console.error('Unable to register japa plugin')
  console.error(error)
}

Output

import app from '@adonisjs/core/services/app'
import { sessionApiClient } from '@adonisjs/session/plugins/api_client'

export const plugins: Config['plugins'] = [
  sessionApiClient(app)
]

addVitePlugin

Register a Vite plugin to the vite.config.ts file.

Important

This codemod expects the vite.config.ts file to exist and must have the export default defineConfig function call.

const transformer = new CodeTransformer(appRoot)
const imports = [
  {
    isNamed: false,
    module: '@vitejs/plugin-vue',
    identifier: 'vue'
  },
]
const pluginUsage = 'vue({ jsx: true })'

try {
  await transformer.addVitePlugin(pluginUsage, imports)
} catch (error) {
  console.error('Unable to register vite plugin')
  console.error(error)
}

Output

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

export default defineConfig({
  plugins: [
    vue({ jsx: true })
  ]
})

addPolicies

Register AdonisJS bouncer policies to the list of policies object exported from the app/policies/main.ts file.

Important

This codemod expects the app/policies/main.ts file to exist and must export a policies object from it.

const transformer = new CodeTransformer(appRoot)

try {
  await transformer.addPolicies([
    {
      name: 'PostPolicy',
      path: '#policies/post_policy'
    }
  ])
} catch (error) {
  console.error('Unable to register policy')
  console.error(error)
}

Output

export const policies = {
  UserPolicy: () => import('#policies/post_policy')
}

Contributing

One of the primary goals of AdonisJS is to have a vibrant community of users and contributors who believe in the framework's principles.

We encourage you to read the contribution guide before contributing to the framework.

Code of Conduct

To ensure that the AdonisJS community is welcoming to all, please review and abide by the Code of Conduct.

License

AdonisJS Assembler is open-sourced software licensed under the MIT license.

assembler's People

Contributors

brkn avatar dependabot[bot] avatar julien-r44 avatar karimsan avatar lookingit avatar maxgalbu avatar mcsneaky avatar rault-a avatar romainlanz avatar rubenmoya avatar snyk-bot avatar targos avatar thetutlage avatar tibianmod avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

assembler's Issues

Incorrect exit code when build fails

@thetutlage

When an error happens during the build execution, the command send the incorrect exit code.

If you ar using a CI to release your app you will get a false positive, and will send a bad release to the server.

Package version

"devDependencies": {
  "@adonisjs/assembler": "^5.0.0",
  "adonis-preset-ts": "^2.1.0",
  "eslint": "^7.29.0",
  "eslint-config-prettier": "^8.3.0",
  "eslint-plugin-adonis": "^1.3.2",
  "eslint-plugin-prettier": "^3.4.0",
  "pino-pretty": "^5.0.2",
  "prettier": "^2.3.1",
  "typescript": "~4.2",
  "youch": "^2.2.2",
  "youch-terminal": "^1.1.1"
},
"dependencies": {
  "@adonisjs/core": "^5.1.0",
  "@adonisjs/repl": "^3.0.0",
  "proxy-addr": "^2.0.7",
  "reflect-metadata": "^0.1.13",
  "source-map-support": "^0.5.19"
}

Node.js and npm version

Node.js: v14.17.1
npm: 6.14.12

Sample Code (to reproduce the issue)

Create a new project

npm init adonis-ts-app blog
// API Server
// blog
// y
// y

Create a new controller with some error:

// import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'

export default class PagesController {
    public index() {
        var value = void 0;

        this.doNothing(value); // Argument of type 'undefined' is not assignable to parameter of type 'string'.

        return "Hello World";
    }

    private doNothing(value: string) {
        console.log(value)
    }
}

Run the command

cd blog
yarn build
echo $? # should be != 0

The result of echo will be 0 for failure.

image

image

BONUS (a sample repo to reproduce the issue)

You can clone my repository with the example of error during yarn build.

https://github.com/RodolfoSilva/demo-adonisjs/tree/bug/build-invalid-exit-code

git clone [email protected]:RodolfoSilva/demo-adonisjs.git
cd demo-adonisjs
git checkout bug/build-invalid-exit-code
yarn install
yarn build
echo $? # should be != 0

generate:manifest errors silently during production build

Package version

@adonisjs/assembler": "5.4.1"

Node.js and npm version

node --version
v16.6.2
npm --version
7.20.3

Sample Code (to reproduce the issue)

generate:manifest seems to be called during build but fails silently. I accidentally imported an ES module in one of my custom commands. That correctly threw an error when running generate:manifest but didn't error when running node ace build.

That resulted in commands missing in a production build (and deploy) which I only noticed as node ace migration:run resulted in an also non-fatal

[ error ]  "migration:run" command not found

Attempting to make a validator using ace results in an exception

Attempting to make a validator using ace results in an exception.

λ ~/Sites/adonis5/api node ace make:validator Creative
✖  fatal     Error: Error in template /Users/benswinburne/Sites/adonis5/api/node_modules/@adonisjs/assembler/build/templates/validator.txt:19
Unexpected token '*'
    at template (/Users/benswinburne/Sites/adonis5/api/node_modules/@adonisjs/ace/build/src/utils/template.js:43:15)
    at Object.templateFromFile (/Users/benswinburne/Sites/adonis5/api/node_modules/@adonisjs/ace/build/src/utils/template.js:53:12)
    at GeneratorFile.toJSON (/Users/benswinburne/Sites/adonis5/api/node_modules/@adonisjs/ace/build/src/Generator/File.js:115:30)
    at Generator.run (/Users/benswinburne/Sites/adonis5/api/node_modules/@adonisjs/ace/build/src/Generator/index.js:40:35)
    at MakeValidator.generate (/Users/benswinburne/Sites/adonis5/api/node_modules/@adonisjs/assembler/build/commands/Make/Base.js:71:30)
    at MakeValidator.handle (/Users/benswinburne/Sites/adonis5/api/node_modules/@adonisjs/assembler/build/commands/Make/Validator.js:51:9)
    at Kernel.runCommand (/Users/benswinburne/Sites/adonis5/api/node_modules/@adonisjs/ace/build/src/Kernel/index.js:239:26)
    at CoreCommands.handle (/Users/benswinburne/Sites/adonis5/api/node_modules/@adonisjs/core/build/src/Ignitor/Ace/CoreCommands.js:95:9)
    at Ace.handle (/Users/benswinburne/Sites/adonis5/api/node_modules/@adonisjs/core/build/src/Ignitor/Ace/index.js:117:17)

Package version

"@adonisjs/assembler": "^1.3.8",
"@adonisjs/ace": "^6.9.2",
"@adonisjs/core": "^5.0.0-preview-rc-1.3",
"@adonisjs/fold": "^6.3.5",
"@adonisjs/lucid": "^8.0.2",

Node.js and npm version

λ ~/Sites/adonis5/api node -v
v13.11.0
λ ~/Sites/adonis5/api yarn -v
1.22.4

Sample Code (to reproduce the issue)

node ace make:validator Creative

Error running npm run build in Adonis 6

Package version

@adonisjs/[email protected]

Describe the bug

Hello there,

I'm not able to build the application using npm run build command:

node version: 21.6.1

image

├── @adonisjs/[email protected]
├── @adonisjs/[email protected]
├── @adonisjs/[email protected]
├── @adonisjs/[email protected]
├── @adonisjs/[email protected]
├── @adonisjs/[email protected]
├── @adonisjs/[email protected]
├── @adonisjs/[email protected]
├── @adonisjs/[email protected]
├── @adonisjs/[email protected]

Reproduction repo

npm run build

Remove the host rewrite on dev_server to allow running the application on Digital Ocean apps

Package version

7.1.1

Describe the bug

I'm trying to deploy the application using Digital Ocean Apps.

Firstly I tried to deploy it using the build, but for other reasons, the build isn't fully working right now... So I'm trying to deploy using the dev server, the thing is that the dev_server is rewriting the host from 0.0.0.0 to 127.0.0.1 which breaks the deployment for the DO apps...

There's really a need to rewrite it?

https://github.com/adonisjs/assembler/blob/develop/src/dev_server.ts

Reproduction repo

No response

Add flag for copying .env file after build

Something I always keep forgetting to do. After my build, I constantly come and copy my .env file into the generated build folder.

Is it ok if I add a copyEnv flag on the build command? Any better suggestions?

TypeError: global[Symbol.for(...)] is not a function

Package version

3.0.6

Node.js and npm version

  • Node v14.5.0
  • NPM 6.14.5

Sample Code (to reproduce the issue)

https://github.com/duartealexf/adonisjs5-test

BONUS (a sample repo to reproduce the issue)

Just run npm run test from the repository. The console should show the error:

TypeError: global[Symbol.for(...)] is not a function

All I did was follow instructions from:

Typo in error message for production build

Here is the message that appears:

Cannot complete the build process as there are typescript errors. Use "--ignore-ts-error" flag to ignore Typescript errors

Should be --ignore-ts-errors.

Missing publication of templates

What if the developers had the possibility to publish the templates related to the "make" commands. For example.

node ace publish:templates

This would copy the contents of the "templates" directory to a root directory of the project where the developer could establish a pre-defined structure and add it to version control.

AdonisJS cannot be configured with Turborepo

I am sending this issue here as this is where the node ace configure tests is invocated, and where the problem is located.

When creating a new Adonis application, Adonis will try to set up tests (no matter which project structure you have chosen), but tests are dependents of the adonis-preset-ts module, and Adonis will try to retrieve the tsconfig of this module by searching in the node_modules he has created in his folder. However, the problem with Turborepo is that it will usually install dependencies/modules in the root folder of the repo, like this:

my_turborepot/
├─ apps/
│  ├─ adonis_app/
│  │  ├─ node_modules/   <-- Where Adonis think dependencies goes
│  │  ├─ package.json
│  ├─ my_other_app/
│  │  ├─ node_modules/
│  │  ├─ package.json
├─ node_modules/         <-- Where dependencies goes
├─ README.md

As such, if you try to set up an Adonis application using create-adonis-ts-app, the following error is raised:
image

I have no real idea on how to support those, and this is why I'm just dropping an issue rather than a PR.

Package version

version: 5.6.2

Node.js and npm version

Node: v16.14.0 npm: v8.5.2 Yarn: 1.22.18

Sample Code (to reproduce the issue)

Not relevant

BONUS (a sample repo to reproduce the issue)

Not relevant

still reload server when typescript file that match metaFiles in rc that has `reloadServer` to false

Package version

@adonisjs/[email protected]

Describe the bug

here

i don't know which it a bug or feature request but when --watch even i ignore resources/** typescript file inside there still reload.

should we change to this?

  /**
   * Handles TypeScript source file change
   */
  #handleSourceFileChange(action, port, relativePath) {
    const isMatch = this.#options.metaFiles.find((item) => {
      if (!item.reloadServer) {
        return picomatch(item.pattern)(relativePath)
      }
      return false
    })

    this.#clearScreen();
    this.#logger.log(`${this.#colors.green(action)} ${relativePath}`);
    if (typeof isMatch === 'undefined') {
      this.#restartHTTPServer(port);
    }
  }

that maybe we can ignore http server restart save time on development
and reproduce:

  • create adonisjs v6 using web-starter-kit
  • in adonisrc add meta
  metaFiles: [
    // {
    //   pattern: 'resources/views/**/*.edge',
    //   reloadServer: false,
    // },
    {
      pattern: 'public/**',
      reloadServer: false,
    },
    {
      pattern: 'resources/**',
      reloadServer: false,
    },
  ],
  • create typescript file in /resources folder
  • start web server using --watch
  • save typescript file in /resources folder

you will see the server reload then /resources folder you completed ignore, it not getting full potential of @adonisjs/vite hot-reload

Reproduction repo

https://github.com/SH8GH/ssembler.file

The glob-parent vulnerability issue

Package version

5.6.2

Node.js and npm version

v16.13.2 and 8.1.2

Sample Code (to reproduce the issue)

Core issue on npm install

BONUS (a sample repo to reproduce the issue)

Running any npm i will raise 5 high severity issues, output of npm audit:

npm audit report

glob-parent <5.1.2
Severity: high
Regular expression denial of service in glob-parent - GHSA-ww39-953v-wcq6
No fix available
node_modules/cpy/node_modules/glob-parent
fast-glob <=2.2.7
Depends on vulnerable versions of glob-parent
node_modules/cpy/node_modules/fast-glob
globby 8.0.0 - 9.2.0
Depends on vulnerable versions of fast-glob
node_modules/cpy/node_modules/globby
cpy 7.0.0 - 8.1.2
Depends on vulnerable versions of globby
node_modules/cpy
@adonisjs/assembler *
Depends on vulnerable versions of cpy
node_modules/@adonisjs/assembler

5 high severity vulnerabilities

Is there a way of mitigating/fix this?

Add `make:test-suite` command

Why this feature is required (specific use-cases will be appreciated)?

Swiftly bootstrapping other test suites. Right now assembler only creates a functional suite. Adding new suites requires manually editing file(s?).

Have you tried any other work arounds?

Other workaround could be doing this manually.

Are you willing to work on it with little guidance?

Sure!

doesn't recognize build command

Package version

7.1.1

Describe the bug

# Missing "build" command in node ace

## Description

When running node ace build --production, I'm encountering the following error:

[ error ]  "build" command not found
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `node ace build --production`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

## Steps to Reproduce

  1. Update assembler to "@adonisjs/assembler": "^7.1.1",
  2. Run node ace build --production in the project directory.
  3. Observe the error message.

## Environment

  • Node.js version: V14.15.5
  • npm version: V6.14.11
  • Adonis version: V5
  • Operating system: macOS
image

Reproduction repo

No response

Build command should work regardless of the app key

Package version

^2.0.3

Node.js and npm version

14.1.0
6.14.4

Sample Code (to reproduce the issue)

Run the commande node ace build without an APP_KEY in your .env file give you this error:

✖ fatal ✖ fatal Exception: E_MISSING_ENV_KEY: Make sure to define environment variable APP_KEY at Env.getOrFail (/home/valentin/www/website/server/node_modules/@adonisjs/env/build/src/Env.js:200:19) at Object.<anonymous> (/home/valentin/www/website/server/config/app.ts:29:35) at Module._compile (internal/modules/cjs/loader.js:1176:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1196:10) at Module.load (internal/modules/cjs/loader.js:1040:32) at Function.Module._load (internal/modules/cjs/loader.js:929:14) at Module.require (internal/modules/cjs/loader.js:1080:19) at require (internal/modules/cjs/helpers.js:72:18) at /home/valentin/www/website/server/node_modules/require-all/index.js:56:46 at Array.forEach (<anonymous>)

Improve codemod error state

Hi! 👋🏻

Currently, when codemod cannot achieve its task, it throws an error that is displayed in the console and leaves the user without any other indication.

In this case, I have simply changed the location of those files.

I would expect the following:

  • If I only move the file to some other place, I would expect to be able to configure the new path
  • If the codemod cannot modify nor find the file, I would expect to display what has to be done in the CLI

Doing those modifications will ensure that the user will not feel lost if the codemod cannot achieve what was planned.

ace serve --watch results error on Raspberry Pi

When I start node ace serve --watch on Raspberry Pi then I get an error.

I've already explained the situation on this discussion: adonisjs/core#1914

Package version

├── @adonisjs/[email protected]
├── @adonisjs/[email protected]
├── @adonisjs/[email protected]
├── @adonisjs/[email protected]
├── @adonisjs/[email protected]
├── @adonisjs/[email protected]
├── @adonisjs/[email protected]
├── @adonisjs/[email protected]
├── @adonisjs/[email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]

Node.js and npm version

NodeJS: v14.15.0
NPM: 6.14.8

Sample Code (to reproduce the issue)

adonisjs/core#1914

5 high severity vulnerabilities

Package version

  • 5.9.5

Node.js and npm version

  • node: v16.14.0
  • npm: v8.9.0

Sample Code (to reproduce the issue)

npm audit OR npm install

# npm audit report

glob-parent  <5.1.2
Severity: high
glob-parent before 5.1.2 vulnerable to Regular Expression Denial of Service in enclosure regex - https://github.com/advisories/GHSA-ww39-953v-wcq6
No fix available
node_modules/globby/node_modules/glob-parent
  fast-glob  <=2.2.7
  Depends on vulnerable versions of glob-parent
  node_modules/globby/node_modules/fast-glob
    globby  8.0.0 - 9.2.0
    Depends on vulnerable versions of fast-glob
    node_modules/globby
      cpy  7.0.0 - 8.1.2
      Depends on vulnerable versions of globby
      node_modules/cpy
        @adonisjs/assembler  <=5.9.5
        Depends on vulnerable versions of cpy
        node_modules/@adonisjs/assembler

5 high severity vulnerabilities

Some issues need review, and may require choosing
a different dependency.

AdonisJS requires "@adonisjs/assembler" in deploy on heroku

I'm trying to deploy my API in AdonisJS 5.0 on heroku, but when heroku try to run my migrations using node ace migration:run --force I always get the error below
Error: AdonisJS requires "@adonisjs/assembler" in order to run typescript source directly

I really dont know how to fix it, already tried manually add the @adonisjs/assembler on "dependencies" in package.json.

Versions

Adonis JS: 5
Core: 5.0.4-preview-rc-2
Assembler: 3.0.6
Node: 12.18.2
Npm: 6.14.5

Sample Code

My procfile
release: ENV_SILENT=true node ace migration:run --force

My entire error
Error: AdonisJS requires "@adonisjs/assembler" in order to run typescript source directly at Object.registerTsHook (/app/node_modules/@adonisjs/core/build/src/utils/index.js:30:19) at App.onFind (/app/node_modules/@adonisjs/core/build/src/Ignitor/Ace/App/index.js:138:21) at /app/node_modules/@adonisjs/core/build/src/Ignitor/Ace/App/index.js:191:60 at Hooks.excute (/app/node_modules/@adonisjs/ace/build/src/Hooks/index.js:44:19) at Kernel.find (/app/node_modules/@adonisjs/ace/build/src/Kernel/index.js:151:30) at Kernel.exec (/app/node_modules/@adonisjs/ace/build/src/Kernel/index.js:313:34) at Kernel.handle (/app/node_modules/@adonisjs/ace/build/src/Kernel/index.js:302:21) at async App.handle (/app/node_modules/@adonisjs/core/build/src/Ignitor/Ace/App/index.js:307:13) at async Ace.handle (/app/node_modules/@adonisjs/core/build/src/Ignitor/Ace/index.js:33:9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.