Code Monkey home page Code Monkey logo

adonis-vscode-extension's People

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  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

adonis-vscode-extension's Issues

Error "Unexpected token S in JSON at position 0" after v0.6.0 update

Package version

v0.6.0

Node.js and npm version

Node: v18.7.0
Npm: 8.15.0
Installed through NVM

Description

Hello. I'm getting these errors after yesterday update. My routes are completely standard, I didn't change their location and etc.
node ace list:routes works just fine.
I'm using vscode remote development extension.

image
image

App/Start/Routes.ts

import Route from '@ioc:Adonis/Core/Route';
import HealthCheck from '@ioc:Adonis/Core/HealthCheck';
import './routes/users';

Route.get('/', async () => {

  return { hello: 'world' }

});

Route.get('test', async () => {

  return { app: 'is working.' }
  
});

Route.get('health', async ({ response }) => {
  const report = await HealthCheck.getReport()

  return report.healthy
    ? response.ok(report)
    : response.badRequest(report)
});

App/Start/routes/users.ts

import Route from '@ioc:Adonis/Core/Route';

Route.group(() => {

  Route.group(() => {

    Route.get('login', 'SignInController.create');

    Route.post('login', 'SignInController.store');

    Route.post('register', 'SignUpController.store');

    Route.get('logout', 'SignInController.destroy');

    Route.get('forgot', 'ForgotPasswordController.getForm');

    Route.post('forgot', 'ForgotPasswordController.postEmail');

    Route.get('forgot/:hash', 'ForgotPasswordController.checkHash');

    Route.post('forgot/:hash', 'ForgotPasswordController.changePassword');

  }).prefix('web');

}).prefix('u');

Route.resource('u', 'UsersController')
  .except(['index', 'create', 'store'])
  .paramFor('u', 'userId');

Thanks in advance.

Add svelte and react to InertiaSuggester

Prerequisites

We do our best to reply to all the issues on time. If you will follow the given guidelines, the turn around time will be faster.

Consider an RFC

Please create an RFC instead, if

  • Feature introduces a breaking change
  • Demands lots of time and changes in the current code base.

Delete the above section and the instructions in the sections below before submitting

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

Currently it seems like the suggester only picks up vue files. I'm currently setting up a adonis project with inertia and svelte and the extension is always yelling at me with Missing inertia page. Inertia supports multiple frameworks, i think the extension should handle all of them.

Have you tried any other work arounds?

No

Are you willing to work on it with little guidance?

I can probably work on this if you like my suggestion.

Running commands on click is risky

I have a few commands that wipe out the data/db. A simple missclick can end up with bad consequences (even if it's just the local dev environment, time can be lost).

List routes command fails

Happy to provide more information if you need it. node ace list:routes (with or without --json) works fine in the terminal.

image

Formatting does not preserve indents in tag blocks

Package version

1.1.7

Node.js and npm version

Node: v16.20.0
NPM: 8.19.4

Sample Code (to reproduce the issue)

This Edge code:

@section('body')
  <section class="section">
    <div>
      <h1 class="title">{{title}}</h1>
      <ul>
        <li>
          @if(isLoggedIn(session))
            <a href="/schedule">Go to my schedule</a>
          @else
            <a href="/verify">Sign In</a>
          @endif
        </li>
      </ul>
    </div>
  </section>
@end

loses its indentation when formatted:

@section('body')
<section class="section">
  <div>
    <h1 class="title">{{title}}</h1>
    <ul>
      <li>
        @if(isLoggedIn(session))
        <a href="/schedule">Go to my schedule</a>
        @else
        <a href="/verify">Sign In</a>
        @endif
      </li>
    </ul>
  </div>
</section>
@end

Can you upgrade the open-vsx extension version ?

Hi, can you upgrade the open-vsx extension version ? I was trying to understand why it's doesn't work and after few hour debugging I find out that it wasn't the latest version ๐Ÿ˜„. If someone got the same problem you can download the latest .vsix file on the Microsoft marketplace here or you can go on the extension page (adonis-vscode-extension) click on the "Version History" tab and click on the most recent download button.

Any pointers on how to automate this? Are there any Github actions already built to do this easily?

here you go :

I can try to setup a Github Action but i never did it before.

Thank you for your work !

Originally posted by @Sliverside in #17 (comment)

Extension don't work with Yarn PnP

An error occurs when executing a command or checking the route list in an AdonisJS application that uses Yarn PnP:

Error: Command failed: "node" ace list:routes --json
node:internal/modules/cjs/loader:998
  throw err;
  ^

Error: Cannot find module 'reflect-metadata'
Require stack:
- /home/user/adonis-app/ace
    at Module._resolveFilename (node:internal/modules/cjs/loader:995:15)
    at Module._load (node:internal/modules/cjs/loader:841:27)
    at Module.require (node:internal/modules/cjs/loader:1061:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at Object.<anonymous> (/home/user/adonis-app/ace:10:1)
    at Module._compile (node:internal/modules/cjs/loader:1159:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
    at Module.load (node:internal/modules/cjs/loader:1037:32)
    at Module._load (node:internal/modules/cjs/loader:878:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/home/user/adonis-app/ace' ]
}

In fact, the extension runs the Ace cli file using Node and not Yarn, so the installed packages are not found. It would be great to add a system to detect the package manager used by the user (as it is the case in the create-adonis-ts-app package).

Package version

v0.9.1

Node.js and Yarn version

Node.js: v18.12.1
Yarn: v3.3.0

Issue loading extension in project

Package version

yarn list v1.22.19
โ”œโ”€ @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]
โ”œโ”€ @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]
โ”œโ”€ @adonisjs/[email protected]
โ”œโ”€ @adonisjs/[email protected]
โ”œโ”€ @adonisjs/[email protected]
โ”œโ”€ @adonisjs/[email protected]
โ”œโ”€ @adonisjs/[email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”‚  โ”œโ”€ @adonisjs/[email protected]
โ”‚  โ””โ”€ @adonisjs/[email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ””โ”€ [email protected]

Node.js and npm version

Node: v14.17.6
Yarn: 1.22.19

Description

When open my project i get a error for the extension with the message Cannot convert undefined or null to object and not show any more information

List Routes does not show routes with .domain()

The "list routes" table is missing routes that use .domain(), e.g.

Route.get('/', ({ view }) => view.render('landing/index'))
Route.get('/caddy/allowed-domain', 'TenantsController.checkAllowedDomain')

// Tenant routes
Route.group(() => {
    Route.get('/admin/reports', 'ReportsController.index')
    Route.get('/admin/sessions', 'SessionsController.index')
    Route.get('/admin/tickets', 'TicketsController.index')
})
  .domain(`:tenantSlug.${Env.get('BASE_DOMAIN')}`) // ๐Ÿ‘ˆ without this line, it seems to work fine
  .middleware(['auth:web'])

The result

Note that the following routes are missing:

  • /admin/reports
  • /admin/sessions
  • /admin/tickets

image

Package versions

  • adonis-vscode-extension - v0.3.0
  • Node.js - v16.15.0
  • NPM - v8.5.5

Formatting is broken for `<` character

Package version

0.9.1

Node.js and npm version

N/A

Sample Code (to reproduce the issue)

When formatting this code:

@if(paintings.lastPage > paintings.currentPage)
<li>
  Whatever
</li>
@end

is correctly formatted (remains the same), while the following one just get mad:

@if(paintings.lastPage < paintings.currentPage)
<li>
  Whatever
</li>
@end

and end up formatted like this:

@if(paintings.lastPage < paintings.currentPage) <li>
  Whatever
  </li>
  @end

I think it related to the < character.

Support monorepo structures

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

It would be nice to be able to use the extension with a monorepo structure where the AdonisJS files are in a subdirectory.
For example, I have an app where there is an AdonisJS API in ./api and a React frontend in ./front.

I get this kind of error:

Error: Command failed: cd /d "d:/Git/project" && node ace generate:manifest
node:internal/modules/cjs/loader:936
  throw err;
  ^

Error: Cannot find module 'd:\Git\project\ace'
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
    at node:internal/main/run_main_module:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Have you tried any other work arounds?

Couldn't think of one.

Are you willing to work on it with little guidance?

Maybe, but I'm short on time at the moment.

Views in @unless tag not parsed correctly

Package version

1.1.7

Node.js and npm version

Node: v16.20.0
NPM: 8.19.4

Sample Code (to reproduce the issue)

This Edge code gives a "missing-view" warning:

@unless(['/verify', '/signin'].includes(request.url()))

while this semantically identical code is fine:

@if(!['/verify', '/signin'].includes(request.url()))

Formatting ident stop working

There was another .edge extension for vscode, this all happens, whenever vscode updates the identification it stops working, I don't know what I could do to get around this problem, it was working correctly. =/

vscode version

1.83.0

Version extension

0.9.2

Running commands doesn't work on Windows

PS C:\git\project> cd /d "c:\git\project\api" && "node" ace playground  
ParserError: 
Line |
   1 |  cd /d "c:\git\project\api" && "node" ace playground
     |                                       ~~~
     | Unexpected token 'ace' in expression or statement.

v1.2 broke some Edge template features.

Package version

1.2.0 | Adonis v5

Node.js and npm version

Node: 18.16.0 | npm: 9.5.1

Sample Code (to reproduce the issue)

Just update the extension to 1.2.0 and try to format or autocomplete.

Here's an example of attempting to stub out an <a> tag:
https://i.imgur.com/o3fvVOb.png

Here's the response received when attempting to auto format the file with alt + shift + f
https://i.imgur.com/kGMie1C.png

Reverting back to the previous version solved these issues for me.

BONUS (a sample repo to reproduce the issue)

N/A

Controllers not detected if in namespaced group

I've got a namespaced group for some user-related controllers but when I switch to the pre-release version of the AdonisJS extension, it underlines the ones in the group with a "Missing controller" message:
image

Package version

v1.1.9

Node.js and npm version

Using NVM with default node v20.0.0 and npm v9.6.4

Sample Code (to reproduce the issue)

// Namespace the controllers so they're not all in the same folder
Route.group(() => {
  // Authentication (login/logout/register) routes
  Route.group(() => {
    // Log in page and post route
    Route.get('/login', 'AuthController.loginShow').as('login.show');
    Route.post('/login', 'AuthController.loginSubmit').as('login.submit');
    // Register in page and post route
    Route.get('/register', 'AuthController.registerShow').as('register.show');
    Route.post('/register', 'AuthController.registerSubmit').as('register.submit');
    // log out route
    Route.get('/logout', 'AuthController.logout').as('logout');
  }).as('auth');
}).namespace('App/Controllers/Http/Users');

"Go to route controller" opens with improper path casing

Notes:

  • I'm using macOS 13.1
  • When I cmd+click, it opens the controller file fine (since macOS is case-insensitive), but the folder and filename casings in the breadcrumbs and tab name are incorrect.
  • I'm not sure if this is a bug with the extension or VS Code itself.

Package version

Using AdonisJS Extension v0.9.1

Node.js and npm version

  • node: 16.14.0
  • npm: 8.3.1

Sample Code (to reproduce the issue)

  • Add /app/Controllers/Http/StripeController.ts
  • In /start/routes.ts:
Route.group(() => {
  Route.post('/add-customer', 'StripeController.addCustomer').as('add-customer');
  Route.post('/payment-intent', 'StripeController.generatePaymentIntent').as('add-payment-intent');
}).prefix('/stripe').as('stripe');
  • Then cmd + click on StripeController.generatePaymentIntent and it opens /app/controllers/Http/Stripecontroller.ts
  • The proper path is /app/Controllers/Http/StripeController.ts

image

image

npm workspaces detection should not find the same workspace twice

When npm workspaces are used, npm creates for each workspace a symbolic link under node_modules that points to the module in the workspace. The problem is that this extension finds it and then proposes two options when you try for example to list routes:
Screenshot 2022-04-30 at 13 25 51

If there are no use cases for looking inside node_modules, these folders can just be ignored. Otherwise, it may be possible to use fs.realpath to make sure the same absolute path isn't listed twice.

Whitespace bug in edge formatting for route name

I'm attempting to format the .edge file that contains route helper, which will introduce a space between route(" and name. This will throw a route not found error.
See an example of this is shown below:

Before:

<a href="{{ route("users") }}">Users</a>

After:

<a href="{{ route(" users") }}">Users</a>

Package version

AdonisJS Extension v0.9.1

Node.js and npm version

Node v18.14.0
NPM 8.19.4

Wish list

As we progress with v6, I have some ideas about how to make the extension even more awesome. Also, we might have to change a few things considering the changes in v6.

So this issue captures a wish list, discusses some essential changes, and can be used to further take requests from AdonisJS users.

๐Ÿ”ง Routes listing changes

Since routes controller binding in v6 can be done in many different ways, the list:routes command does its best to find the path to the controller file but may not be able to do it every time. Let's look at some examples.

Magic strings

No changes from v5. We are now using Node.js subpath imports to alias the controllers directory.

import router from '@adonisjs/core/services/router'
router.get('users', '#controllers/users_controller.index')

Output

{
  "handler": {
	"type": "controller",
    "moduleNameOrPath": "#controllers/users_controller",
    "method": "index",
  },
}

Binding controller class

In the following example, there is no way for the list:routes command to know the import path for the controller. All it knows is the class name.

import router from '@adonisjs/core/services/router'
import UsersController from '#controllers/users_controller'

router.get('users', [UsersController, 'index'])

Output

{
  "handler": {
	"type": "controller",
    "moduleNameOrPath": "UsersController",
    "method": "index",
  },
}

Lazy loading controller

In the following example, we parse the import method from the function that lazy loads the controller. The process is straightforward, call the toString() method on the function and parse the import statement.

import router from '@adonisjs/core/services/router'
const UsersController = () => import('#controllers/users_controller')

router.get('users', [UsersController, 'index'])

Output (same as magic string)

{
  "handler": {
	"type": "controller",
    "moduleNameOrPath": "#controllers/users_controller",
    "method": "index",
  },
}

Right now, the VSCode extension displaying routes in the activity sidebar takes the user to the controller file based on the controller path. However, in v6, we will have instances where we will not have the controller file path.

I am still trying to figure out a good answer on how to handle it. So let's keep it open for discussion.

๐Ÿ’Œ Refactor standard import to lazy import

This will be a great addition if we can support it. First, look at the examples of Standard import and Lazy import.

// Standard Import
import UsersController from '#controllers/users_controller'
// Lazy import
const UsersController = () => import('#controllers/users_controller')

Lazy import is preferred, as it keeps the boot phase of the application fast. However, typing the complete import statement and variable assignment by hand is tiring.

VSCode has auto imports, so if I type Users, it will show me a suggestion to import the UsersController from the controller file. First, however, the auto import will write a Standard import statement.

So, adding a command to our extension that converts the Standard import to Lazy import will be freaking cool.

๐Ÿ’Œ Go to component from Edge tags

Right now, in the edge template files, I can jump to template references inside the includes and the component tags. However, we also allow components to be used as tags. For example:

Instead of writing

@component('button')
@end

I can write

@button()
@end

So it will be nice if clicking on the @button can take me to the component file. If needed, we can expose some APIs from Edge or AdonisJS to make it happen. But I don't know how to start approaching it.

๐Ÿ’Œ Bunch of snippets

I have a rough collection of snippets in mind that I would love to see and use. Also, we can take feedback from the community and ask for snippets they would love to use.

I can take care of doing a PR for snippets.

๐Ÿ”ง Does Edge syntax highlighting need improvements?

I remember we used some existing template syntax files inside the AdonisJS extension, and that syntax file has some rough edges like it does not highlight the @end tag correctly. It does highlight @end<something>, but not the standalone @end tag.

For me, just fixing the one quirk is enough. Unless Julien you have some plans to write it from scratch.

adding the extension on vscodium oss store

vscodium is bloatware free VSCODE. A lot of extensions from massive companies popular for OSS are on https://open-vsx.org/ (some including RedHat, Gitlab etc)

I have just started learning Adonis and we use it for our product. It would be really helpful if the extension can be made available on opne-vsx store. It's not very difficult or time consuming task. It's a matter of just uploading vsix

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.