julien-r44 / adonis-vscode-extension Goto Github PK
View Code? Open in Web Editor NEW๐ป VSCode Extension for AdonisJS
Home Page: https://marketplace.visualstudio.com/items?itemName=jripouteau.adonis-vscode-extension
License: MIT License
๐ป VSCode Extension for AdonisJS
Home Page: https://marketplace.visualstudio.com/items?itemName=jripouteau.adonis-vscode-extension
License: MIT License
v0.6.0
Node: v18.7.0
Npm: 8.15.0
Installed through NVM
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.
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.
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.
Please create an RFC instead, if
Delete the above section and the instructions in the sections below before submitting
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.
No
I can probably work on this if you like my suggestion.
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).
1.1.7
Node: v16.20.0
NPM: 8.19.4
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
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)
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).
v0.9.1
Node.js: v18.12.1
Yarn: v3.3.0
I don't know how to debug this. There is only one line in the logs:
TypeError: Cannot read properties of undefined (reading 'uri')
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: v14.17.6
Yarn: 1.22.19
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
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'])
Note that the following routes are missing:
/admin/reports
/admin/sessions
/admin/tickets
v0.3.0
v16.15.0
v8.5.5
0.9.1
N/A
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.
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: []
}
Couldn't think of one.
Maybe, but I'm short on time at the moment.
1.1.7
Node: v16.20.0
NPM: 8.19.4
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()))
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. =/
1.83.0
0.9.2
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.
file:///Users/xxx/xxx/ace.js:22
import { register } from 'node:module'
The requested module 'node:module' does not provide an export named 'register'
1.2.0 | Adonis v5
Node: 18.16.0 | npm: 9.5.1
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.
N/A
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:
v1.1.9
Using NVM with default node v20.0.0 and npm v9.6.4
// 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');
Using AdonisJS Extension v0.9.1
/app/Controllers/Http/StripeController.ts
/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');
StripeController.generatePaymentIntent
and it opens /app/controllers/Http/Stripecontroller.ts
/app/Controllers/Http/StripeController.ts
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:
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.
0.8.0
16.14.2 & 8.5.0
Not able to see routes list, getting this error Error: Command failed: "node" ace list:routes --json
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>
AdonisJS Extension v0.9.1
Node v18.14.0
NPM 8.19.4
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.
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.
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",
},
}
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",
},
}
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.
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.
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.
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.
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.
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.