adonisjs-community / create-adonis-ts-app Goto Github PK
View Code? Open in Web Editor NEWBoilerplate to create a new AdonisJs typescript project
License: MIT License
Boilerplate to create a new AdonisJs typescript project
License: MIT License
In the README, the name
parameter example says --boilerplate=my-app
where it should say --name=my-app
.
As it is, in full:
npm init adonis-ts-app hello-world -- --boilerplate=my-app
As it should be:
npm init adonis-ts-app hello-world -- --name=my-app
npm ├─┬ [email protected]
v12.16.1 and v6.13.4
npx create-adonis-ts-app blog
➜ npx create-adonis-ts-app adonis-mongoose-boilerplate
npx: installed 107 in 11.474s
_ _ _ _
/ \ __| | ___ _ __ (_)___ | |___
/ _ \ / _` |/ _ \| '_ \| / __|_ | / __|
/ ___ \ (_| | (_) | | | | \__ \ |_| \__ \
/_/ \_\__,_|\___/|_| |_|_|___/\___/|___/
✔ Select the project structure · api
✔ Enter the project name · blog
✔ Setup eslint? (y/N) · true
create .adonisrc.json
create .env, .env.example
create .gitignore
create tsconfig.json
create .eslintrc.json, .eslintignore
create ace
create app/Exceptions/Handler.ts
create commands/index.ts
create providers/AppProvider.ts
create server.ts
create start/kernel.ts
create start/routes.ts
create .editorconfig
install typescript, @adonisjs/assembler, eslint, eslint-plugin-adonis, youch, youch-terminal, pino-pretty, and 1 other [dev]
install @adonisjs/core, @adonisjs/ace, @adonisjs/fold, reflect-metadata, proxy-addr, source-map-support [prod]
fatal npm ERR! Unexpected end of JSON input while parsing near '...odule-name":"^2.1.0",'
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/eco/.npm/_logs/2020-03-23T13_36_35_131Z-debug.log
error Unable to create new project. Rolling back
fatal Error: Installation failed
at task (/Users/eco/.npm/_npx/3184/lib/node_modules/create-adonis-ts-app/build/tasks/createPackageFile.js:82:15)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async Object.runTasks (/Users/eco/.npm/_npx/3184/lib/node_modules/create-adonis-ts-app/build/index.js:138:13)
Latest at 21 September 2022
Node: 14.17.3
Npm: 6.14.13
npm init adonis-ts-app@latest hello-world
Select the project structure · web
Enter the project name · hello-world
Setup eslint? (y/N) · false
Configure webpack encore for compiling frontend assets? (y/N) · true
node ace serve --watch
[ encore ] internal/modules/cjs/loader.js:905
throw err;
^
Error: Cannot find module '@babel/core'
Require stack:
- node_modules\@symfony\webpack-encore\lib\config\parse-runtime.js
"@symfony/webpack-encore": "^4.0.0"
npm install webpack webpack-cli @babel/core @babel/preset-env --save-dev
Received the following error when running the installation command on both Windows and linux systems:
TypeError: Cannot read property 'update' of undefined
at instructions (/mnt/d/Repos/yardstick/node_modules/@adonisjs/view/build/instructions.js:7:12)
at Object.executeInstructions (/mnt/c/Users/Simon/AppData/Local/Yarn/Data/global/node_modules/@adonisjs/sink/src/executeInstructions.js:23:15)
at processTicksAndRejections (internal/process/task_queues.js:86:5)
I guess Adonis updated something?
4.02
node 14.5.0
npm 6.14.5
yarn 1.22.10
I've tried to create a new app with both yarn and npm and get the same issue:
Package subpath './package.json' is not defined by "exports" in /Users/richard_weaver/Projects/enotria-adonisjs/node_modules/@adonisjs/core/package.json
Hi,
while creating application using typescript.
I am facing problem while using script tag to load any external js which is declared in public folder but it always says script is not function. please guide me where i need to configure to access script tag.
Ex -
suppose i have created example.js file in public folder but while using in view edge file - {{script('example')}}
it not work, script is not function.
SIGINT
seems to be ignored by server. HTTP server exposes .kill()
and .close()
but default listener for SIGINT seems to be missing
Adonis packages
"@adonisjs/assembler": "^1.3.4",
"@adonisjs/ace": "^6.8.4",
"@adonisjs/core": "^5.0.0-preview.4",
"@adonisjs/fold": "^6.3.4",
NodeJS: 13.9.0
NPM: 6.13.7
When building container and setting start command as CMD [ "node", "./build/server.js" ]
Container does not die gracefully with SIGINT
since SIGINT
is sent to process, which just ignores it
Fix is to add process.on('SIGINT')
yourself to some part of application, server.ts
for example
// server.ts (original)
new Ignitor(__dirname)
.httpServer()
.start()
.catch(console.error)
Workaround is to chop it into multiple pieces and adding SIGINT
listener
// server.ts (workaround)
const server = new Ignitor(__dirname)
.httpServer()
server.start()
.catch(console.error)
// Without it process won't die in container
process.on('SIGINT', () => {
server.kill(10)
})
pnpm
workspaces currently can't use the starter template as the installer uses npm to install the dependencies.pnpm import
@mrsauravsahu/blogs
packagepnpx create-adonis-ts-app sample
)rm -rf node_modules
)pnpm import
)pnpm i
)The start command node ace serve --watch
should give you an error like shown.
The workaround is to carefully install package into devDependencies with pnpm i -D <package-name>
Installation with pnpm appears to have been an issue in the past but looked like it had been resolved.
Unfortunately the install process still seems to use NPM to install dependancies.
I discovered this when I tried adding Lucid via pnpm i
and the result is a lot of ugly warnings and unmet peer dependancies
Latest at 29 August 2022
node v16.17.0
pnpm 7.9.3
Run the install instructions from in an empty directory
pnpm create adonis-ts-app hello-world
❯ Select the project structure · api
❯ Enter the project name · hello-world
❯ Setup eslint? (y/N) · true
❯ Setup prettier? (y/N) · true
Change directory to project root
cd hello-world
Check for lock files
ls | grep lock
Output:
package-lock.json
NPM lock file present
PNPM lock file absent
Run PNPM installer
pnpm i
Output:
WARN Moving @adonisjs/assembler that was installed by a different package manager to "node_modules/.ignored
WARN Moving @japa/preset-adonis that was installed by a different package manager to "node_modules/.ignored
WARN Moving @japa/runner that was installed by a different package manager to "node_modules/.ignored
WARN Moving adonis-preset-ts that was installed by a different package manager to "node_modules/.ignored
WARN Moving eslint that was installed by a different package manager to "node_modules/.ignored
WARN 10 other warnings
WARN deprecated [email protected]: See https://github.com/lydell/source-map-resolve#deprecated
WARN deprecated [email protected]: https://github.com/lydell/resolve-url#deprecated
WARN deprecated [email protected]: See https://github.com/lydell/source-map-url#deprecated
WARN deprecated [email protected]: Please see https://github.com/lydell/urix#deprecated
Packages: +662
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Packages are hard linked from the content-addressable store to the virtual store.
Content-addressable store is at: /Users/adrian/Library/pnpm/store/v3
Virtual store is at: node_modules/.pnpm
Progress: resolved 662, reused 662, downloaded 0, added 662, done
dependencies:
+ @adonisjs/core 5.8.6
+ @adonisjs/repl 3.1.11
+ proxy-addr 2.0.7
+ reflect-metadata 0.1.13
+ source-map-support 0.5.21
devDependencies:
+ @adonisjs/assembler 5.8.1
+ @japa/preset-adonis 1.1.0
+ @japa/runner 2.0.9
+ adonis-preset-ts 2.1.0
+ eslint 8.23.0
+ eslint-plugin-adonis 2.1.0
+ pino-pretty 9.1.0
+ typescript 4.6.4 (4.8.2 is available)
+ youch 3.2.0
+ youch-terminal 2.1.4
ERR_PNPM_PEER_DEP_ISSUES Unmet peer dependencies
.
└─┬ @japa/preset-adonis 1.1.0
└─┬ @japa/assert 1.3.4
└─┬ api-contract-validator 2.2.8
└─┬ api-schema-builder 2.0.11
└─┬ swagger-parser 10.0.3
└─┬ @apidevtools/swagger-parser 10.0.3
└── ✕ missing peer openapi-types@>=7
Peer dependencies that should be installed:
openapi-types@>=7
hint: If you want peer dependencies to be automatically installed, add "auto-install-peers=true" to an .npmrc file at the root of your project.
hint: If you don't want pnpm to fail on peer dependency issues, add "strict-peer-dependencies=false" to an .npmrc file at the root of your project.
This is a minor issue, but a curious one. I wouldn't expect an NPM lock file to be made while installing with Yarn, and Yarn will also complain if you try to install dependencies while a package-lock.json exists in the same directory.
4.2.0
Node.js 16.16.0
npm 8.1.1
yarn 1.22.19
yarn create adonis-ts-app hello-world
as described in the Adonis install docs.npm: 7.18.1
node: v16.4.2
output:
_ _ _ _
/ \ __| | ___ _ __ (_)___ | |___
/ _ \ / _` |/ _ \| '_ \| / __|_ | / __|
/ ___ \ (_| | (_) | | | | \__ \ |_| \__ \
/_/ \_\__,_|\___/|_| |_|_|___/\___/|___/
CUSTOMIZE PROJECT
❯ Select the project structure · api
❯ Enter the project name · hello-world
❯ Setup eslint? (y/N) · true
❯ Setup prettier? (y/N) · true
RUNNING TASKS
❯ Scaffold project 48 ms
❯ Install dependencies 1.28 s
npm install failed
❯ Configure installed packages
[ error ] Unable to create project. Cleaning up
It finishes correctly if I don't install eslint + prettier
When I'm trying to create an Adonis App inside a monorepo, it returns the following error [ error ] Unable to create project. Cleaning up
:
Latest at this date 2nd November 2022
Node.js: v16.18.0
Pnpm: v7.14.1
https://github.com/gurvan-guss/turborepo-nuxt-boilerplate
cd apps
pnpm create adonis-ts-app hello-world
For now I create an Adonis app outside of the monorepo and move it inside my monorepo, however like mentioned in this issue #47, it will not use pnpm but npm to install the dependencies.
pnpm create adonis-ts-app hello-world
node_modules
& package-lock.json
from the app and move it to my monorepo in the apps
folderpnpm i
(if you already have defined e.g: shamefully-hoist) or pnpm i --shamefully-hoist
After generating the project, a start
script is created: node server.js
But this leads to an error because the target file is in the build
subdirectory: node build/server.js
16/13 and 8.1
Today the process for using adonis sail is as follows:
What I would like to do is to merge all this in one step, a bit like how Laravel works ( https://laravel.com/docs/9.x#getting-started-on-linux ), maybe something like this :
npx adonis-sail create-app --postgres --minio --mailhog
This command would run in the background create-adonis-ts-app with the following arguments:
npm init create-adonis-ts-app --lucid --mailer --drive
And therefore it would install and configure lucid/mailer and drive.
After that, Adonis Sail and its CLI would take over to automate the creation of docker containers etc
With this, we will be able to have an Adonis application with docker containers for each of the services we are interested in with a single command.
So the possible solutions:
create-adonis-ts-app offers the user to install packages in addition like :
> Setup eslint (y/n) :
> Setup Lucid (y/n) :
> Setup Mailer (y/n) :
etc...
I don't thin this is great because we have a lot of packages and it could be quite long and boring to answer all these questions
That we can install/configure additional packages only with the arguments of the command, so basically, add all packages as optional parameters to create-adonis-ts-app :
Options :
--lucid <boolean> Install and configure @adonisjs/lucid
--redis <boolean> Install and configure @adonisjs/redis
etc ...
We will end up with a lot of arguments but it seems to me to be the best solution
One another option could be to install and configure these packages directly from the Adonis Sail code but I'm sure that this feature of being able to bootstrap an Adonis application with lucid/mailer already installed ( even without Sail ) could interest people.
Personally, when I create a new Adonis application, I always find it quite annoying to come and do install/configure on drive/mailer/redis/lucid that I use on 90% of my applications
Let me know if you have any better suggestions please !
Yep, that's the goal! I'm just looking for opinions or better alternatives if you have any
1.3.6
❯ node -v
v12.16.1
❯ npm -v
6.14.4
❯ yarn -v
1.22.4
I'm also using nvm
:
❯ nvm --version
0.35.3
❯ npx create-adonis-ts-app hello-world
npx: installed 129 in 7.306s
Cannot find module 'ms'
Require stack:
- /home/thiago/.npm/_npx/155699/lib/node_modules/create-adonis-ts-app/node_modules/@poppinss/utils/build/src/MessageBuilder.js
- /home/thiago/.npm/_npx/155699/lib/node_modules/create-adonis-ts-app/node_modules/@poppinss/utils/build/index.js
- /home/thiago/.npm/_npx/155699/lib/node_modules/create-adonis-ts-app/node_modules/@adonisjs/sink/src/executeInstructions.js
- /home/thiago/.npm/_npx/155699/lib/node_modules/create-adonis-ts-app/node_modules/@adonisjs/sink/index.js
- /home/thiago/.npm/_npx/155699/lib/node_modules/create-adonis-ts-app/build/index.js
- /home/thiago/.npm/_npx/155699/lib/node_modules/create-adonis-ts-app/build/bin/run.js
❯ yarn create adonis-ts-app hello-world
yarn create v1.22.4
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
warning "create-adonis-ts-app > @adonisjs/[email protected]" has unmet peer dependency "@adonisjs/fold@^6.0.0".
[4/4] Building fresh packages...
success Installed "[email protected]" with binaries:
- create-adonis-ts-app
[#################################################################################################################################] 129/129internal/modules/cjs/loader.js:985
throw err;
^
Error: Cannot find module 'ms'
Require stack:
- /home/thiago/.config/yarn/global/node_modules/@poppinss/utils/build/src/MessageBuilder.js
- /home/thiago/.config/yarn/global/node_modules/@poppinss/utils/build/index.js
- /home/thiago/.config/yarn/global/node_modules/@adonisjs/sink/src/executeInstructions.js
- /home/thiago/.config/yarn/global/node_modules/@adonisjs/sink/index.js
- /home/thiago/.config/yarn/global/node_modules/create-adonis-ts-app/build/index.js
- /home/thiago/.config/yarn/global/node_modules/create-adonis-ts-app/build/bin/run.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:982:15)
at Function.Module._load (internal/modules/cjs/loader.js:864:27)
at Module.require (internal/modules/cjs/loader.js:1044:19)
at require (internal/modules/cjs/helpers.js:77:18)
at Object.<anonymous> (/home/thiago/.config/yarn/global/node_modules/@poppinss/utils/build/src/MessageBuilder.js:14:30)
at Module._compile (internal/modules/cjs/loader.js:1158:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
at Module.load (internal/modules/cjs/loader.js:1002:32)
at Function.Module._load (internal/modules/cjs/loader.js:901:14)
at Module.require (internal/modules/cjs/loader.js:1044:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/home/thiago/.config/yarn/global/node_modules/@poppinss/utils/build/src/MessageBuilder.js',
'/home/thiago/.config/yarn/global/node_modules/@poppinss/utils/build/index.js',
'/home/thiago/.config/yarn/global/node_modules/@adonisjs/sink/src/executeInstructions.js',
'/home/thiago/.config/yarn/global/node_modules/@adonisjs/sink/index.js',
'/home/thiago/.config/yarn/global/node_modules/create-adonis-ts-app/build/index.js',
'/home/thiago/.config/yarn/global/node_modules/create-adonis-ts-app/build/bin/run.js'
]
}
error Command failed.
Exit code: 1
Command: /home/thiago/.yarn/bin/create-adonis-ts-app
Arguments: hello-world
Directory: /home/thiago/Projetos
Output:
info Visit https://yarnpkg.com/en/docs/cli/create for documentation about this command.
Tried running npm cache clean --force
before the commands, without success.
Also tried with node v13 just in case, without success.
Also tried npx [email protected] hello-world
without success.
The issue occurs at the "Configure installed packages" step.
I'm using an M2 Pro Macbook, running macOs 13.2.1.
┌ Configure installed packages
│ CREATE: config/app.ts
│ CREATE: .env,.env.example
│ SKIP: env.ts
│ CREATE: config/bodyparser.ts
│ CREATE: config/drive.ts
│ CREATE: config/cors.ts
│ CREATE: config/hash.ts
│ CREATE: contracts/events.ts
│ CREATE: contracts/drive.ts
│ CREATE: contracts/hash.ts
│ CREATE: contracts/env.ts
│ UPDATE: tsconfig.json
│ UPDATE: .adonisrc.json
│ UPDATE: .adonisrc.json
│ UPDATE: tsconfig.json
│ UPDATE: .adonisrc.json
│ UPDATE: .adonisrc.json
[ error ] "configure" command not found
│ [ error ] Command failed with exit code 1: node ace configure tests
│ at makeError (/Users/benhepburn/Library/pnpm/store/v3/tmp/dlx-37071/node_modules/.pnpm/[email protected]/node_modules/execa/lib/error.js:60:11)
│ at handlePromise (/Users/benhepburn/Library/pnpm/store/v3/tmp/dlx-37071/node_modules/.pnpm/[email protected]/node_modules/execa/index.js:118:26)
│ at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
│ at async task (/Users/benhepburn/Library/pnpm/store/v3/tmp/dlx-37071/node_modules/.pnpm/[email protected]/node_modules/create-adonis-ts-app/build/Tasks/ConfigureTests/index.js:24:9)
│ at async Object.callback (/Users/benhepburn/Library/pnpm/store/v3/tmp/dlx-37071/node_modules/.pnpm/[email protected]/node_modules/create-adonis-ts-app/build/index.js:95:17)
│ at async TaskManager.runTask (/Users/benhepburn/Library/pnpm/store/v3/tmp/dlx-37071/node_modules/.pnpm/@[email protected]/node_modules/@poppinss/cliui/build/src/Task/Manager.js:99:13)
│ at async Object.complete (/Users/benhepburn/Library/pnpm/store/v3/tmp/dlx-37071/node_modules/.pnpm/@[email protected]/node_modules/@poppinss/cliui/build/src/Task/Manager.js:82:13)
│ at async Object.callback (/Users/benhepburn/Library/pnpm/store/v3/tmp/dlx-37071/node_modules/.pnpm/[email protected]/node_modules/create-adonis-ts-app/build/index.js:97:13)
│ at async TaskManager.runTask (/Users/benhepburn/Library/pnpm/store/v3/tmp/dlx-37071/node_modules/.pnpm/@[email protected]/node_modules/@poppinss/cliui/build/src/Task/Manager.js:99:13)
│ at async Object.complete (/Users/benhepburn/Library/pnpm/store/v3/tmp/dlx-37071/node_modules/.pnpm/@[email protected]/node_modules/@poppinss/cliui/build/src/Task/Manager.js:82:13)
└ failed (247 ms)
[ error ] Unable to create project. Cleaning up
Latest at 11th Sept 2023
Problem occurs in:
pnpm create adonis-ts-app myy-api
Hello
I'd like to begin using typescript in an existing adonis v4 app and I'm not sure how to go about.
Any help would be appreciated.
I love Adonis very much and have always missed TypeScript.
Congratulations for the starter.
How can I help you?
Hello,
First of all, I want to thank you for the amazing work you are doing in this framework.
I wanted to start testing the new version, but couldn't create a new project using npx
(creating it using yarn
went just fine).
1.3.5
Node: 12.16.1
npm: 6.12.1
TypeError: Cannot read property 'create' of undefined
at instructions (/home/webneat/workspace/personal/blog/node_modules/@adonisjs/core/build/instructions.js:26:16)
at Object.executeInstructions (/usr/lib/node_modules/create-adonis-ts-app/node_modules/@adonisjs/sink/src/executeInstructions.js:15:11)
at task (/usr/lib/node_modules/create-adonis-ts-app/build/tasks/executeInstructions.js:7:22)
at Object.runTasks (/usr/lib/node_modules/create-adonis-ts-app/build/index.js:30:19)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
Unable to create new project. Rolling back
NPM: 6.7, Node: 11.15, Yarn: 1.17
yarn create adonis-ts-app yardstick
yarn start
Attempting to run the template using "yarn start" or "npm start" returns the error message:
Make sure you are inside an adonisjs app to start the server
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.