create-adonisjs 2.4.0 → 3.0.0-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -10,22 +10,21 @@ Scaffold a new AdonisJS application using starter kits
10
10
 
11
11
  You can use between one of the following official starter kits, or bring your own using the `--kit` flag.
12
12
 
13
- - `api` : AdonisJS application tailored for building HTTP APIs.
14
- - `web` : AdonisJS application tailored for building server-side rendered applications.
15
- - `slim` : Smallest possible AdonisJS application. Still way more powerful and batteries included than a express application.
16
- - `inertia`: AdonisJS application tailored for building applications using InertiaJS and your favorite frontend framework (Vue, React, Svelte, Solid).
13
+ - `hypermedia` : A fullstack application using server-side templates, alongside Alpine.js and optionally Unpoly.
14
+ - `react`: A fullstack React application with E2E type-safety. Inertia is used as a bridge between the frontend and the backend.
15
+ - `vue`: A fullstack Vue application with E2E type-safety. Inertia is used as a bridge between the frontend and the backend.
17
16
 
18
17
  ## Usage
19
18
 
20
19
  ```sh
21
20
  # Using npm
22
- npm init adonisjs
21
+ npm init adonisjs@next
23
22
 
24
23
  # Using yarn
25
- yarn create adonisjs
24
+ yarn create adonisjs@next
26
25
 
27
26
  # Using pnpm
28
- pnpm create adonisjs
27
+ pnpm create adonisjs@next
29
28
  ```
30
29
 
31
30
  ## Options
@@ -35,7 +34,7 @@ pnpm create adonisjs
35
34
  You can pass the destination directory as the first argument to the command. For example:
36
35
 
37
36
  ```sh
38
- npm init adonisjs my-app
37
+ npm init adonisjs@next my-app
39
38
  ```
40
39
 
41
40
  This argument is optional and the command will prompt you to enter the directory name if not provided.
@@ -48,26 +47,26 @@ If you want to use your own starter kit hosted on Github, Gitlab, or Bitbucket,
48
47
 
49
48
  ```sh
50
49
  # Download from GitHub
51
- npm init adonisjs -- --kit="github:github_user/repo"
50
+ npm init adonisjs@next -- --kit="github:github_user/repo"
52
51
 
53
52
  # Github is the default provider, so if not specified, it will be assumed as github
54
- npm init adonisjs -- --kit="github_user/repo"
53
+ npm init adonisjs@next -- --kit="github_user/repo"
55
54
 
56
55
  # Download from GitLab
57
- npm init adonisjs -- --kit="gitlab:user/repo"
56
+ npm init adonisjs@next -- --kit="gitlab:user/repo"
58
57
 
59
58
  # Download from BitBucket
60
- npm init adonisjs -- --kit="bitbucket:user/repo"
59
+ npm init adonisjs@next -- --kit="bitbucket:user/repo"
61
60
  ```
62
61
 
63
62
  You can also pass specify the branch or tag name as follows:
64
63
 
65
64
  ```sh
66
65
  # Branch name
67
- npm init adonisjs -- --kit="github:github_user/repo#branch-name"
66
+ npm init adonisjs@next -- --kit="github:github_user/repo#branch-name"
68
67
 
69
68
  # Tag name
70
- npm init adonisjs -- --kit="github:github_user/repo#v1.0.0"
69
+ npm init adonisjs@next -- --kit="github:github_user/repo#v1.0.0"
71
70
  ```
72
71
 
73
72
  ### `--token` (Default: undefined)
@@ -75,7 +74,7 @@ npm init adonisjs -- --kit="github:github_user/repo#v1.0.0"
75
74
  If you are using a custom starter kit hosted on a private repository, then you can pass the authentication token as follows:
76
75
 
77
76
  ```sh
78
- npm init adonisjs -- --kit="github:github_user/repo" --token="github_token"
77
+ npm init adonisjs@next -- --kit="github:github_user/repo" --token="github_token"
79
78
  ```
80
79
 
81
80
  ### `--pkg` (Default: Auto detects)
@@ -83,31 +82,7 @@ npm init adonisjs -- --kit="github:github_user/repo" --token="github_token"
83
82
  We are trying to detect the package manager used by your project. However, if you want to force a specific package manager, then you can pass it as follows:
84
83
 
85
84
  ```sh
86
- npm init adonisjs -- --pkg="yarn"
87
- ```
88
-
89
- ### `--auth-guard` (Default: Triggers prompt for selection)
90
-
91
- Specify a custom auth guard to use when using the `api` stater kit. One of the following options are allowed
92
-
93
- - `session`
94
- - `access_tokens`
95
-
96
- ```sh
97
- npm init adonisjs -- --kit="api" --auth-guard="access_tokens"
98
- ```
99
-
100
- ### `--db` (Default: Triggers prompt for selection)
101
-
102
- Specify the database dialect to configure with Lucid. One of the following options are allowd.
103
-
104
- - `sqlite`
105
- - `mysql`
106
- - `mssql`
107
- - `postgres`
108
-
109
- ```sh
110
- npm init adonisjs -- --kit="web" --db="mysql"
85
+ npm init adonisjs@next -- --pkg="yarn"
111
86
  ```
112
87
 
113
88
  ### Other options
@@ -122,7 +97,7 @@ npm init adonisjs -- --kit="web" --db="mysql"
122
97
  If creating a new project fails, then you must re-run the same command with the `--verbose` flag to view all the logs.
123
98
 
124
99
  ```sh
125
- npm init adonisjs -- --verbose
100
+ npm init adonisjs@next -- --verbose
126
101
  ```
127
102
 
128
103
  ## Contributing
package/build/bin/run.js CHANGED
@@ -1,3 +1,7 @@
1
1
  #!/usr/bin/env node
2
- import { kernel } from '../index.js';
3
- kernel.handle(['create-adonisjs', ...process.argv.slice(2)]).catch(console.error);
2
+ import {
3
+ kernel
4
+ } from "../chunk-VYPE5MQ2.js";
5
+
6
+ // bin/run.ts
7
+ kernel.handle(["create-adonisjs", ...process.argv.slice(2)]).catch(console.error);
@@ -0,0 +1,263 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __decorateClass = (decorators, target, key, kind) => {
4
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
5
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
+ if (decorator = decorators[i])
7
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
+ if (kind && result) __defProp(target, key, result);
9
+ return result;
10
+ };
11
+
12
+ // index.ts
13
+ import { HelpCommand, Kernel } from "@adonisjs/ace";
14
+
15
+ // commands/main.ts
16
+ import { cwd } from "process";
17
+ import { existsSync } from "fs";
18
+ import gradient from "gradient-string";
19
+ import { downloadTemplate } from "giget";
20
+ import { execa } from "execa";
21
+ import detectPackageManager from "which-pm-runs";
22
+ import { BaseCommand, args, flags } from "@adonisjs/ace";
23
+ import { basename, isAbsolute, join, relative } from "path";
24
+ import { copyFile, readFile, unlink, writeFile } from "fs/promises";
25
+
26
+ // src/templates.ts
27
+ var templates = [
28
+ {
29
+ name: "Hypermedia app",
30
+ alias: "hypermedia",
31
+ hint: "A fullstack application using server-side templates",
32
+ source: "github:adonisjs/starter-kits/hypermedia"
33
+ },
34
+ {
35
+ name: "React app (using Inertia)",
36
+ alias: "inertia",
37
+ hint: "A fullstack React application with E2E type-safety",
38
+ source: "github:adonisjs/starter-kits/inertia-react"
39
+ },
40
+ {
41
+ name: "Vue app (using Inertia)",
42
+ alias: "inertia",
43
+ hint: "A fullstack Vue application with E2E type-safety",
44
+ source: "github:adonisjs/starter-kits/inertia-vue"
45
+ }
46
+ ];
47
+
48
+ // commands/main.ts
49
+ var CreateNewApp = class extends BaseCommand {
50
+ static commandName = "create-adonisjs";
51
+ static description = "Create a new AdonisJS application";
52
+ /**
53
+ * Runs bash command using execa with shared defaults
54
+ */
55
+ async #runBashCommand(file, cliArgs, options) {
56
+ await execa(file, cliArgs, {
57
+ cwd: this.destination,
58
+ preferLocal: true,
59
+ windowsHide: false,
60
+ buffer: false,
61
+ stdio: this.verbose === true ? "inherit" : "ignore",
62
+ ...options
63
+ });
64
+ }
65
+ /**
66
+ * Prints AdonisJS as ASCII art
67
+ */
68
+ #printBannerArt() {
69
+ const title = Buffer.from(
70
+ "ICAgICBfICAgICAgIF8gICAgICAgICAgICAgXyAgICAgICAgIF8gX19fXyAgCiAgICAvIFwgICBfX3wgfCBfX18gIF8gX18gKF8pX19fICAgIHwgLyBfX198IAogICAvIF8gXCAvIF9gIHwvIF8gXHwgJ18gXHwgLyBfX3xfICB8IFxfX18gXCAKICAvIF9fXyBcIChffCB8IChfKSB8IHwgfCB8IFxfXyBcIHxffCB8X19fKSB8CiAvXy8gICBcX1xfXyxffFxfX18vfF98IHxffF98X19fL1xfX18vfF9fX18vIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA=",
71
+ "base64"
72
+ ).toString();
73
+ this.logger.log("");
74
+ this.logger.log(`${gradient.mind.multiline(title)}`);
75
+ this.logger.log("");
76
+ }
77
+ /**
78
+ * Print the success message
79
+ */
80
+ #printSuccessMessage() {
81
+ this.logger.log("");
82
+ this.ui.instructions().heading("Your AdonisJS project has been created successfully!").add(this.colors.cyan("cd " + relative(cwd(), this.destination))).add(this.colors.cyan(`${this.packageManager} run dev`)).add(this.colors.cyan("Open http://localhost:3333")).add("").add(`Have any questions?`).add(`Join our Discord server - ${this.colors.yellow("https://discord.gg/vDcEjq6")}`).render();
83
+ }
84
+ /**
85
+ * Prompt for the destination directory
86
+ */
87
+ async #promptForDestination() {
88
+ if (!this.destination) {
89
+ this.destination = await this.prompt.ask("Where should we create your new project?", {
90
+ default: "./adonisjs-app"
91
+ });
92
+ }
93
+ this.destination = isAbsolute(this.destination) ? this.destination : join(cwd(), this.destination);
94
+ }
95
+ /**
96
+ * Prompt to configure a starter kit
97
+ */
98
+ async #promptForStarterKit() {
99
+ if (!this.kit) {
100
+ const template = await this.prompt.choice(
101
+ "Select the kind of app you want to create?",
102
+ templates
103
+ );
104
+ this.kit = templates.find((t) => t.name === template).source;
105
+ } else {
106
+ const matchingTemplatesFromAlias = templates.filter((t) => t.alias === this.kit);
107
+ if (matchingTemplatesFromAlias.length > 1) {
108
+ const template = await this.prompt.choice(
109
+ "Which frontend framework do you want to use?",
110
+ matchingTemplatesFromAlias
111
+ );
112
+ this.kit = matchingTemplatesFromAlias.find((t) => t.name === template).source;
113
+ } else if (matchingTemplatesFromAlias.length === 1) {
114
+ this.kit = matchingTemplatesFromAlias[0].source;
115
+ }
116
+ }
117
+ }
118
+ /**
119
+ * Replace the package.json name with the destination directory name.
120
+ * Errors are ignored.
121
+ */
122
+ async #replacePackageJsonName() {
123
+ const pkgJsonPath = join(this.destination, "package.json");
124
+ const pkgJson = await readFile(pkgJsonPath, "utf-8").then(JSON.parse);
125
+ pkgJson.name = basename(this.destination);
126
+ await writeFile(pkgJsonPath, JSON.stringify(pkgJson, null, 2));
127
+ }
128
+ /**
129
+ * Optionally removes readme file. Errors are ignored
130
+ */
131
+ async #removeReadmeFile() {
132
+ await unlink(join(this.destination, "README.md"));
133
+ }
134
+ /**
135
+ * Optionally remove existing lock file. Errors are ignored
136
+ */
137
+ async #removeLockFile() {
138
+ await Promise.allSettled([
139
+ unlink(join(this.destination, "package-lock.json")),
140
+ unlink(join(this.destination, "yarn.lock")),
141
+ unlink(join(this.destination, "pnpm-lock.yaml"))
142
+ ]);
143
+ }
144
+ /**
145
+ * If starter template has a `.env.example` file, then copy it to `.env`
146
+ */
147
+ async #copyEnvExampleFile() {
148
+ const envPath = join(this.destination, ".env");
149
+ const envExamplePath = join(this.destination, ".env.example");
150
+ if (existsSync(envExamplePath)) {
151
+ await copyFile(envExamplePath, envPath);
152
+ }
153
+ }
154
+ /**
155
+ * Generate a fresh app key. Errors are ignored
156
+ */
157
+ async #generateFreshAppKey() {
158
+ await this.#runBashCommand("node", ["ace", "generate:key"]);
159
+ }
160
+ /**
161
+ * Main method
162
+ */
163
+ async run() {
164
+ this.packageManager = this.packageManager || detectPackageManager()?.name || "npm";
165
+ this.#printBannerArt();
166
+ await this.#promptForDestination();
167
+ await this.#promptForStarterKit();
168
+ const tasks = this.ui.tasks({ verbose: this.verbose === true });
169
+ tasks.add("Download starter kit", async (task) => {
170
+ task.update(`Downloading "${this.kit}"`);
171
+ await downloadTemplate(this.kit, {
172
+ dir: this.destination,
173
+ auth: this.token,
174
+ registry: false
175
+ });
176
+ await this.#removeLockFile();
177
+ return `Downloaded "${this.kit}"`;
178
+ }).addIf(this.gitInit === true, "Initialize git repository", async () => {
179
+ await this.#runBashCommand("git", ["init"]);
180
+ return "Initialized git repository";
181
+ }).add("Install packages", async (task) => {
182
+ const spinner = this.logger.await(`installing dependencies (${this.packageManager})`, {
183
+ silent: this.verbose
184
+ });
185
+ spinner.tap((line) => task.update(line));
186
+ spinner.start();
187
+ try {
188
+ await this.#runBashCommand(this.packageManager, ["install"]);
189
+ return `Packages installed using "${this.packageManager}"`;
190
+ } finally {
191
+ spinner.stop();
192
+ }
193
+ }).add("Prepare application", async () => {
194
+ try {
195
+ await this.#replacePackageJsonName();
196
+ await this.#removeReadmeFile();
197
+ await this.#copyEnvExampleFile();
198
+ await this.#generateFreshAppKey();
199
+ return "Application ready";
200
+ } catch (error) {
201
+ if (this.verbose) {
202
+ this.logger.fatal(error);
203
+ }
204
+ return "Unable to prepare application";
205
+ }
206
+ });
207
+ await tasks.run();
208
+ if (tasks.getState() === "succeeded") {
209
+ this.#printSuccessMessage();
210
+ } else {
211
+ this.exitCode = 1;
212
+ }
213
+ }
214
+ };
215
+ __decorateClass([
216
+ args.string({ description: "Destination directory", required: false })
217
+ ], CreateNewApp.prototype, "destination", 2);
218
+ __decorateClass([
219
+ flags.string({
220
+ description: "Define path to a custom git repository to download the starter kit",
221
+ alias: "K"
222
+ })
223
+ ], CreateNewApp.prototype, "kit", 2);
224
+ __decorateClass([
225
+ flags.string({
226
+ description: "Auth token to download private repositories",
227
+ alias: "t"
228
+ })
229
+ ], CreateNewApp.prototype, "token", 2);
230
+ __decorateClass([
231
+ flags.boolean({
232
+ description: "Init git repository"
233
+ })
234
+ ], CreateNewApp.prototype, "gitInit", 2);
235
+ __decorateClass([
236
+ flags.string({
237
+ description: "Define the package manager to install dependencies",
238
+ flagName: "pkg"
239
+ })
240
+ ], CreateNewApp.prototype, "packageManager", 2);
241
+ __decorateClass([
242
+ flags.boolean({
243
+ description: "Execute tasks in verbose mode",
244
+ alias: "v"
245
+ })
246
+ ], CreateNewApp.prototype, "verbose", 2);
247
+
248
+ // index.ts
249
+ Kernel.defaultCommand = CreateNewApp;
250
+ var kernel = Kernel.create();
251
+ kernel.defineFlag("help", {
252
+ type: "boolean",
253
+ description: HelpCommand.description
254
+ });
255
+ kernel.on("help", async (command, $kernel, parsed) => {
256
+ parsed.args.unshift(command.commandName);
257
+ await new HelpCommand($kernel, parsed, kernel.ui, kernel.prompt).exec();
258
+ return $kernel.shortcircuit();
259
+ });
260
+
261
+ export {
262
+ kernel
263
+ };
@@ -32,22 +32,6 @@ export declare class CreateNewApp extends BaseCommand {
32
32
  * mentioned.
33
33
  */
34
34
  packageManager: string;
35
- /**
36
- * Database dialect for Lucid. Defaults to "sqlite"
37
- */
38
- db?: string;
39
- /**
40
- * Auth guard for auth package.
41
- */
42
- authGuard?: string;
43
- /**
44
- * Inertia adapter to use
45
- */
46
- adapter?: string;
47
- /**
48
- * Inertia adapter to use
49
- */
50
- ssr?: boolean;
51
35
  /**
52
36
  * Execute tasks in verbose mode. Defaults to false.
53
37
  */
package/build/index.js CHANGED
@@ -1,21 +1,6 @@
1
- /*
2
- * create-adonisjs
3
- *
4
- * (c) AdonisJS
5
- *
6
- * For the full copyright and license information, please view the LICENSE
7
- * file that was distributed with this source code.
8
- */
9
- import { HelpCommand, Kernel } from '@adonisjs/ace';
10
- import { CreateNewApp } from './commands/main.js';
11
- Kernel.defaultCommand = CreateNewApp;
12
- export const kernel = Kernel.create();
13
- kernel.defineFlag('help', {
14
- type: 'boolean',
15
- description: HelpCommand.description,
16
- });
17
- kernel.on('help', async (command, $kernel, parsed) => {
18
- parsed.args.unshift(command.commandName);
19
- await new HelpCommand($kernel, parsed, kernel.ui, kernel.prompt).exec();
20
- return $kernel.shortcircuit();
21
- });
1
+ import {
2
+ kernel
3
+ } from "./chunk-VYPE5MQ2.js";
4
+ export {
5
+ kernel
6
+ };
package/package.json CHANGED
@@ -1,18 +1,17 @@
1
1
  {
2
2
  "name": "create-adonisjs",
3
3
  "description": "Scaffold new AdonisJS applications using starter kits",
4
- "version": "2.4.0",
4
+ "version": "3.0.0-next.1",
5
5
  "engines": {
6
- "node": ">=18.16.0"
6
+ "node": ">=24.0.0"
7
7
  },
8
8
  "main": "build/index.js",
9
9
  "type": "module",
10
10
  "files": [
11
- "build/bin",
12
- "build/commands",
13
- "build/src",
14
- "build/index.d.ts",
15
- "build/index.js"
11
+ "build",
12
+ "!build/bin/test.js",
13
+ "!build/tests",
14
+ "!build/tests_helpers"
16
15
  ],
17
16
  "bin": {
18
17
  "create-adonisjs": "build/bin/run.js"
@@ -21,50 +20,50 @@
21
20
  ".": "./build/index.js"
22
21
  },
23
22
  "scripts": {
24
- "clean": "del-cli build",
25
- "typecheck": "tsc --noEmit",
26
- "lint": "eslint . --ext=.ts",
27
- "format": "prettier --write .",
28
- "quick:test": "node --enable-source-maps --loader=ts-node/esm bin/test.ts",
29
23
  "pretest": "npm run lint",
30
- "test": "c8 npm run quick:test",
31
- "prebuild": "npm run lint && npm run clean",
32
- "build": "tsc",
33
- "release": "release-it",
24
+ "test": "cross-env NODE_DEBUG=create-adonisjs c8 npm run quick:test",
25
+ "lint": "eslint",
26
+ "format": "prettier --write .",
27
+ "typecheck": "tsc --noEmit",
28
+ "copy:templates": "copyfiles \"stubs/**/*.stub\" --up=\"1\" build",
29
+ "clean": "del-cli build",
30
+ "precompile": "npm run lint && npm run clean",
31
+ "compile": "tsup-node && tsc --emitDeclarationOnly --declaration",
32
+ "build": "npm run compile",
33
+ "docs": "typedoc",
34
34
  "version": "npm run build",
35
- "prepublishOnly": "npm run build"
35
+ "prepublishOnly": "npm run build",
36
+ "release": "release-it",
37
+ "quick:test": "node --import=@poppinss/ts-exec --enable-source-maps bin/test.ts"
36
38
  },
37
39
  "devDependencies": {
38
- "@adonisjs/eslint-config": "^1.3.0",
39
- "@adonisjs/prettier-config": "^1.3.0",
40
- "@adonisjs/tsconfig": "^1.3.0",
41
- "@japa/assert": "^3.0.0",
42
- "@japa/file-system": "^2.3.0",
43
- "@japa/runner": "^3.1.4",
44
- "@swc/core": "^1.6.1",
40
+ "@adonisjs/eslint-config": "^3.0.0-next.2",
41
+ "@adonisjs/prettier-config": "^1.4.5",
42
+ "@adonisjs/tsconfig": "^2.0.0-next.0",
43
+ "@japa/assert": "^4.1.1",
44
+ "@japa/file-system": "^2.3.2",
45
+ "@japa/runner": "^4.4.0",
46
+ "@poppinss/ts-exec": "^1.4.1",
47
+ "@release-it/conventional-changelog": "^10.0.1",
45
48
  "@types/gradient-string": "^1.1.6",
46
- "@types/node": "^20.14.5",
49
+ "@types/node": "^24.5.2",
47
50
  "@types/which-pm-runs": "^1.0.2",
48
- "c8": "^10.1.2",
49
- "copyfiles": "^2.4.1",
50
- "del-cli": "^5.0.0",
51
- "eslint": "^8.56.0",
52
- "prettier": "^3.3.2",
53
- "release-it": "^17.3.0",
54
- "ts-node": "^10.9.2",
55
- "typescript": "^5.4.5"
51
+ "c8": "^10.1.3",
52
+ "cross-env": "^10.0.0",
53
+ "del-cli": "^7.0.0",
54
+ "eslint": "^9.36.0",
55
+ "prettier": "^3.6.2",
56
+ "release-it": "19.0.4",
57
+ "tsup": "^8.5.0",
58
+ "typescript": "^5.9.2"
56
59
  },
57
60
  "dependencies": {
58
- "@adonisjs/ace": "^13.1.0",
59
- "@adonisjs/presets": "^2.6.1",
60
- "@antfu/install-pkg": "^0.3.3",
61
- "execa": "^9.2.0",
62
- "giget": "^1.2.3",
63
- "gradient-string": "^2.0.2",
61
+ "@adonisjs/ace": "^14.0.1-next.2",
62
+ "execa": "^9.6.0",
63
+ "giget": "^2.0.0",
64
+ "gradient-string": "^3.0.0",
64
65
  "which-pm-runs": "^1.1.0"
65
66
  },
66
- "author": "julien-r44,virk",
67
- "license": "MIT",
68
67
  "homepage": "https://github.com/adonisjs/create-adonisjs#readme",
69
68
  "repository": {
70
69
  "type": "git",
@@ -77,38 +76,62 @@
77
76
  "adonisjs",
78
77
  "create-adonisjs-app"
79
78
  ],
80
- "directories": {
81
- "test": "tests"
82
- },
83
- "eslintConfig": {
84
- "extends": "@adonisjs/eslint-config/package"
85
- },
86
- "prettier": "@adonisjs/prettier-config",
79
+ "author": "Harminder Virk <virk@adonisjs.com>",
80
+ "contributors": [
81
+ "julien-r44"
82
+ ],
83
+ "license": "MIT",
87
84
  "publishConfig": {
88
85
  "access": "public",
89
- "tag": "latest"
86
+ "provenance": true
90
87
  },
91
- "c8": {
92
- "reporter": [
93
- "text",
94
- "html"
88
+ "tsup": {
89
+ "entry": [
90
+ "./index.ts",
91
+ "./bin/run.ts"
95
92
  ],
96
- "exclude": [
97
- "tests/**",
98
- "tmp/**",
99
- "bin/**"
100
- ]
93
+ "outDir": "./build",
94
+ "clean": true,
95
+ "format": "esm",
96
+ "dts": false,
97
+ "sourcemap": false,
98
+ "target": "esnext"
101
99
  },
102
100
  "release-it": {
103
101
  "git": {
102
+ "requireCleanWorkingDir": true,
103
+ "requireUpstream": true,
104
104
  "commitMessage": "chore(release): ${version}",
105
105
  "tagAnnotation": "v${version}",
106
+ "push": true,
106
107
  "tagName": "v${version}"
107
108
  },
108
109
  "github": {
109
- "release": true,
110
- "releaseName": "v${version}",
111
- "web": true
110
+ "release": true
111
+ },
112
+ "npm": {
113
+ "publish": true,
114
+ "skipChecks": true
115
+ },
116
+ "plugins": {
117
+ "@release-it/conventional-changelog": {
118
+ "preset": {
119
+ "name": "angular"
120
+ }
121
+ }
112
122
  }
113
- }
123
+ },
124
+ "c8": {
125
+ "reporter": [
126
+ "text",
127
+ "html"
128
+ ],
129
+ "exclude": [
130
+ "tests/**",
131
+ "stubs/**",
132
+ "factories/**",
133
+ "bin/**"
134
+ ]
135
+ },
136
+ "prettier": "@adonisjs/prettier-config"
114
137
  }
package/build/bin/test.js DELETED
@@ -1,31 +0,0 @@
1
- import { assert } from '@japa/assert';
2
- import { processCLIArgs, configure, run } from '@japa/runner';
3
- import { fileSystem } from '@japa/file-system';
4
- /*
5
- |--------------------------------------------------------------------------
6
- | Configure tests
7
- |--------------------------------------------------------------------------
8
- |
9
- | The configure method accepts the configuration to configure the Japa
10
- | tests runner.
11
- |
12
- | The first method call "processCLIArgs" process the command line arguments
13
- | and turns them into a config object. Using this method is not mandatory.
14
- |
15
- | Please consult japa.dev/runner-config for the config docs.
16
- */
17
- processCLIArgs(process.argv.slice(2));
18
- configure({
19
- files: ['tests/**/*.spec.ts'],
20
- plugins: [assert(), fileSystem({ basePath: 'tmp', autoClean: true })],
21
- timeout: 30 * 1000,
22
- });
23
- /*
24
- |--------------------------------------------------------------------------
25
- | Run tests
26
- |--------------------------------------------------------------------------
27
- |
28
- | The following "run" method is required to execute all the tests.
29
- |
30
- */
31
- run();
@@ -1,463 +0,0 @@
1
- /*
2
- * create-adonisjs
3
- *
4
- * (c) AdonisJS
5
- *
6
- * For the full copyright and license information, please view the LICENSE
7
- * file that was distributed with this source code.
8
- */
9
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
10
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
11
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
12
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
13
- return c > 3 && r && Object.defineProperty(target, key, r), r;
14
- };
15
- import { cwd } from 'node:process';
16
- import { existsSync } from 'node:fs';
17
- import gradient from 'gradient-string';
18
- import { downloadTemplate } from 'giget';
19
- import { execa } from 'execa';
20
- import detectPackageManager from 'which-pm-runs';
21
- import { installPackage } from '@antfu/install-pkg';
22
- import { BaseCommand, args, flags } from '@adonisjs/ace';
23
- import { basename, isAbsolute, join, relative } from 'node:path';
24
- import { copyFile, readFile, unlink, writeFile } from 'node:fs/promises';
25
- import { templates } from '../src/templates.js';
26
- import { databases } from '../src/databases.js';
27
- import { authGuards } from '../src/auth_guards.js';
28
- import { adapters } from '../src/inertia_adapters.js';
29
- const API_STARTER_KIT = 'github:adonisjs/api-starter-kit';
30
- const WEB_STARTER_KIT = 'github:adonisjs/web-starter-kit';
31
- const INERTIA_STARTER_KIT = 'github:adonisjs/inertia-starter-kit';
32
- /**
33
- * Creates a new AdonisJS application and configures it
34
- */
35
- export class CreateNewApp extends BaseCommand {
36
- static commandName = 'create-adonisjs';
37
- static description = 'Create a new AdonisJS application';
38
- /**
39
- * Runs bash command using execa with shared defaults
40
- */
41
- async #runBashCommand(file, cliArgs, options) {
42
- await execa(file, cliArgs, {
43
- cwd: this.destination,
44
- preferLocal: true,
45
- windowsHide: false,
46
- buffer: false,
47
- stdio: this.verbose === true ? 'inherit' : 'ignore',
48
- ...options,
49
- });
50
- }
51
- /**
52
- * Prints AdonisJS as ASCII art
53
- */
54
- #printBannerArt() {
55
- const title = Buffer.from('ICAgICBfICAgICAgIF8gICAgICAgICAgICAgXyAgICAgICAgIF8gX19fXyAgCiAgICAvIFwgICBfX3wgfCBfX18gIF8gX18gKF8pX19fICAgIHwgLyBfX198IAogICAvIF8gXCAvIF9gIHwvIF8gXHwgJ18gXHwgLyBfX3xfICB8IFxfX18gXCAKICAvIF9fXyBcIChffCB8IChfKSB8IHwgfCB8IFxfXyBcIHxffCB8X19fKSB8CiAvXy8gICBcX1xfXyxffFxfX18vfF98IHxffF98X19fL1xfX18vfF9fX18vIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA=', 'base64').toString();
56
- this.logger.log('');
57
- this.logger.log(`${gradient.mind.multiline(title)}`);
58
- this.logger.log('');
59
- }
60
- /**
61
- * Print the success message
62
- */
63
- #printSuccessMessage() {
64
- this.logger.log('');
65
- this.ui
66
- .instructions()
67
- .heading('Your AdonisJS project has been created successfully!')
68
- .add(this.colors.cyan('cd ' + relative(cwd(), this.destination)))
69
- .add(this.colors.cyan(`${this.packageManager} run dev`))
70
- .add(this.colors.cyan('Open http://localhost:3333'))
71
- .add('')
72
- .add(`Have any questions?`)
73
- .add(`Join our Discord server - ${this.colors.yellow('https://discord.gg/vDcEjq6')}`)
74
- .render();
75
- }
76
- /**
77
- * Prompt for the destination directory
78
- */
79
- async #promptForDestination() {
80
- if (!this.destination) {
81
- this.destination = await this.prompt.ask('Where should we create your new project', {
82
- default: './my-adonisjs-app',
83
- });
84
- }
85
- this.destination = isAbsolute(this.destination)
86
- ? this.destination
87
- : join(cwd(), this.destination);
88
- }
89
- /**
90
- * Prompt to configure a starter kit
91
- */
92
- async #promptForStarterKit() {
93
- if (!this.kit) {
94
- /**
95
- * Display prompt when "kit" flag is not used.
96
- */
97
- const template = await this.prompt.choice('Which starter kit would you like to use', templates);
98
- this.kit = templates.find((t) => t.name === template).source;
99
- }
100
- else {
101
- /**
102
- * Allowing users to mention aliases via the CLI flag.
103
- */
104
- const matchingTemplatingFromAlias = templates.find((t) => t.alias === this.kit);
105
- if (matchingTemplatingFromAlias) {
106
- this.kit = matchingTemplatingFromAlias.source;
107
- }
108
- }
109
- }
110
- /**
111
- * Prompt to select a database driver
112
- */
113
- async #promptForDatabaseDriver() {
114
- if (!this.db) {
115
- /**
116
- * Display prompt when "db" flag is not used.
117
- */
118
- const database = await this.prompt.choice('Which database driver you want to use', databases);
119
- this.db = database;
120
- }
121
- }
122
- /**
123
- * Prompt to select a auth guard
124
- */
125
- async #promptForAuthGuard() {
126
- if (!this.authGuard) {
127
- /**
128
- * Display prompt when "authGuard" flag is not used.
129
- */
130
- const guard = await this.prompt.choice('Which authentication guard you want to use', authGuards);
131
- this.authGuard = guard;
132
- }
133
- }
134
- /**
135
- * Prompt to select the Inertia adapter
136
- */
137
- async #promptForInertiaAdapter() {
138
- if (!this.adapter) {
139
- const adapter = await this.prompt.choice('Which frontend adapter you want to use with Inertia', adapters);
140
- this.adapter = adapter;
141
- }
142
- }
143
- /**
144
- * Prompt to select the Inertia adapter
145
- */
146
- async #promptForInertiaSsr() {
147
- if (this.ssr === undefined) {
148
- this.ssr = await this.prompt.confirm('Do you want to setup server-side rendering with Inertia');
149
- }
150
- }
151
- /**
152
- * Replace the package.json name with the destination directory name.
153
- * Errors are ignored.
154
- */
155
- async #replacePackageJsonName() {
156
- const pkgJsonPath = join(this.destination, 'package.json');
157
- const pkgJson = await readFile(pkgJsonPath, 'utf-8').then(JSON.parse);
158
- pkgJson.name = basename(this.destination);
159
- await writeFile(pkgJsonPath, JSON.stringify(pkgJson, null, 2));
160
- }
161
- /**
162
- * Optionally removes readme file. Errors are ignored
163
- */
164
- async #removeReadmeFile() {
165
- await unlink(join(this.destination, 'README.md'));
166
- }
167
- /**
168
- * Optionally remove existing lock file. Errors are ignored
169
- */
170
- async #removeLockFile() {
171
- await Promise.allSettled([
172
- unlink(join(this.destination, 'package-lock.json')),
173
- unlink(join(this.destination, 'yarn.lock')),
174
- unlink(join(this.destination, 'pnpm-lock.yaml')),
175
- ]);
176
- }
177
- /**
178
- * If starter template has an `.env.example` file, then copy it to `.env`
179
- */
180
- async #copyEnvExampleFile() {
181
- const envPath = join(this.destination, '.env');
182
- const envExamplePath = join(this.destination, '.env.example');
183
- if (existsSync(envExamplePath)) {
184
- await copyFile(envExamplePath, envPath);
185
- }
186
- }
187
- /**
188
- * Generate a fresh app key. Errors are ignored
189
- */
190
- async #generateFreshAppKey() {
191
- await this.#runBashCommand('node', ['ace', 'generate:key']);
192
- }
193
- /**
194
- * Configures the Lucid package
195
- */
196
- async #configureLucid() {
197
- const argv = ['ace', 'configure', '@adonisjs/lucid', '--db', this.db, '--install'];
198
- if (this.verbose) {
199
- argv.push('--verbose');
200
- }
201
- await this.#runBashCommand('node', argv);
202
- }
203
- /**
204
- * Configures the session package
205
- */
206
- async #configureSession() {
207
- await installPackage(['@adonisjs/session@latest'], {
208
- cwd: this.destination,
209
- packageManager: this.packageManager,
210
- silent: !this.verbose,
211
- });
212
- const argv = ['ace', 'configure', '@adonisjs/session'];
213
- if (this.verbose) {
214
- argv.push('--verbose');
215
- }
216
- await this.#runBashCommand('node', argv);
217
- }
218
- /**
219
- * Configures the Auth package
220
- */
221
- async #configureAuth() {
222
- /**
223
- * Install the session package when using api starter kit with session
224
- * guard. This needs to be done, since the api starter kit does
225
- * not install the session package by default.
226
- */
227
- if (this.authGuard === 'session' && this.kit === API_STARTER_KIT) {
228
- await this.#configureSession();
229
- }
230
- /**
231
- * Next configure the auth package
232
- */
233
- const argv = ['ace', 'configure', '@adonisjs/auth', '--guard', this.authGuard];
234
- if (this.verbose) {
235
- argv.push('--verbose');
236
- }
237
- await this.#runBashCommand('node', argv);
238
- }
239
- /**
240
- * Configures the Inertia package
241
- */
242
- async #configureInertia() {
243
- const argv = [
244
- 'ace',
245
- 'configure',
246
- '@adonisjs/inertia',
247
- '--adapter',
248
- this.adapter,
249
- this.ssr ? '--ssr' : '--no-ssr',
250
- '--install',
251
- ];
252
- if (this.verbose) {
253
- argv.push('--verbose');
254
- }
255
- await this.#runBashCommand('node', argv);
256
- }
257
- /**
258
- * Main method
259
- */
260
- async run() {
261
- this.packageManager = this.packageManager || detectPackageManager()?.name || 'npm';
262
- /**
263
- * Print ASCII art
264
- */
265
- this.#printBannerArt();
266
- /**
267
- * Display prompts
268
- */
269
- await this.#promptForDestination();
270
- await this.#promptForStarterKit();
271
- if (this.kit === WEB_STARTER_KIT ||
272
- this.kit === API_STARTER_KIT ||
273
- this.kit === INERTIA_STARTER_KIT) {
274
- await this.#promptForAuthGuard();
275
- await this.#promptForDatabaseDriver();
276
- }
277
- if (this.kit === INERTIA_STARTER_KIT) {
278
- await this.#promptForInertiaAdapter();
279
- await this.#promptForInertiaSsr();
280
- }
281
- /**
282
- * Create tasks instance for displaying
283
- * actions as tasks
284
- */
285
- const tasks = this.ui.tasks({ verbose: this.verbose === true });
286
- /**
287
- * Configure lucid when using our own starter kits
288
- * and installing dependencies
289
- */
290
- const configureLucid = [WEB_STARTER_KIT, API_STARTER_KIT, INERTIA_STARTER_KIT].includes(this.kit || '') &&
291
- this.db !== 'skip';
292
- /**
293
- * Configure auth when using our own starter kits
294
- * and installing dependencies
295
- */
296
- const configureAuth = [WEB_STARTER_KIT, API_STARTER_KIT, INERTIA_STARTER_KIT].includes(this.kit || '') &&
297
- this.authGuard !== 'skip';
298
- /**
299
- * Configure inertia when using our inertia starter kit
300
- */
301
- const configureInertia = this.kit === INERTIA_STARTER_KIT && this.adapter !== 'skip';
302
- tasks
303
- .add('Download starter kit', async (task) => {
304
- task.update(`Downloading "${this.kit}"`);
305
- await downloadTemplate(this.kit, {
306
- dir: this.destination,
307
- auth: this.token,
308
- registry: false,
309
- });
310
- await this.#removeLockFile();
311
- return `Downloaded "${this.kit}"`;
312
- })
313
- .addIf(this.gitInit === true, 'Initialize git repository', async () => {
314
- await this.#runBashCommand('git', ['init']);
315
- return 'Initialized git repository';
316
- })
317
- .add('Install packages', async (task) => {
318
- const spinner = this.logger.await('installing dependencies', {
319
- silent: this.verbose,
320
- });
321
- spinner.tap((line) => task.update(line));
322
- spinner.start();
323
- try {
324
- await this.#runBashCommand(this.packageManager, ['install']);
325
- return `Packages installed using "${this.packageManager}"`;
326
- }
327
- finally {
328
- spinner.stop();
329
- }
330
- })
331
- .add('Prepare application', async () => {
332
- try {
333
- await this.#replacePackageJsonName();
334
- await this.#removeReadmeFile();
335
- await this.#copyEnvExampleFile();
336
- await this.#generateFreshAppKey();
337
- return 'Application ready';
338
- }
339
- catch (error) {
340
- if (this.verbose) {
341
- this.logger.fatal(error);
342
- }
343
- return 'Unable to prepare application';
344
- }
345
- })
346
- .addIf(configureLucid, 'Configure Lucid', async (task) => {
347
- const spinner = this.logger.await('configuring @adonisjs/lucid', {
348
- silent: this.verbose,
349
- });
350
- spinner.tap((line) => task.update(line));
351
- spinner.start();
352
- try {
353
- await this.#configureLucid();
354
- spinner.stop();
355
- return `Lucid configured to use "${this.db}" database`;
356
- }
357
- catch (error) {
358
- spinner.stop();
359
- if (this.verbose) {
360
- this.logger.fatal(error);
361
- }
362
- return `Unable to configure "@adonisjs/lucid"`;
363
- }
364
- })
365
- .addIf(configureAuth, 'Configure Auth', async (task) => {
366
- const spinner = this.logger.await('configuring @adonisjs/auth', {
367
- silent: this.verbose,
368
- });
369
- spinner.tap((line) => task.update(line));
370
- spinner.start();
371
- try {
372
- await this.#configureAuth();
373
- spinner.stop();
374
- return `Auth configured to use "${this.authGuard}" guard`;
375
- }
376
- catch (error) {
377
- spinner.stop();
378
- if (this.verbose) {
379
- this.logger.fatal(error);
380
- }
381
- return `Unable to configure "@adonisjs/auth"`;
382
- }
383
- })
384
- .addIf(configureInertia, 'Configure Inertia', async (task) => {
385
- const spinner = this.logger.await('configuring @adonisjs/inertia', {
386
- silent: this.verbose,
387
- });
388
- spinner.tap((line) => task.update(line));
389
- spinner.start();
390
- try {
391
- await this.#configureInertia();
392
- spinner.stop();
393
- return 'Inertia configured';
394
- }
395
- catch (error) {
396
- spinner.stop();
397
- if (this.verbose) {
398
- this.logger.fatal(error);
399
- }
400
- return `Unable to configure "@adonisjs/inertia"`;
401
- }
402
- });
403
- await tasks.run();
404
- if (tasks.getState() === 'succeeded') {
405
- this.#printSuccessMessage();
406
- }
407
- else {
408
- this.exitCode = 1;
409
- }
410
- }
411
- }
412
- __decorate([
413
- args.string({ description: 'Destination directory', required: false })
414
- ], CreateNewApp.prototype, "destination", void 0);
415
- __decorate([
416
- flags.string({
417
- description: 'Define path to a custom git repository to download the starter kit',
418
- alias: 'K',
419
- })
420
- ], CreateNewApp.prototype, "kit", void 0);
421
- __decorate([
422
- flags.string({
423
- description: 'Auth token to download private repositories',
424
- alias: 't',
425
- })
426
- ], CreateNewApp.prototype, "token", void 0);
427
- __decorate([
428
- flags.boolean({
429
- description: 'Init git repository',
430
- })
431
- ], CreateNewApp.prototype, "gitInit", void 0);
432
- __decorate([
433
- flags.string({
434
- description: 'Define the package manager to install dependencies',
435
- flagName: 'pkg',
436
- })
437
- ], CreateNewApp.prototype, "packageManager", void 0);
438
- __decorate([
439
- flags.string({
440
- description: 'Define the database dialect to use with Lucid',
441
- })
442
- ], CreateNewApp.prototype, "db", void 0);
443
- __decorate([
444
- flags.string({
445
- description: 'Define the authentication guard with the Auth package',
446
- })
447
- ], CreateNewApp.prototype, "authGuard", void 0);
448
- __decorate([
449
- flags.string({
450
- description: 'Define the Inertia frontend adapter',
451
- })
452
- ], CreateNewApp.prototype, "adapter", void 0);
453
- __decorate([
454
- flags.boolean({
455
- description: 'Enable SSR for Inertia',
456
- })
457
- ], CreateNewApp.prototype, "ssr", void 0);
458
- __decorate([
459
- flags.boolean({
460
- description: 'Execute tasks in verbose mode',
461
- alias: 'v',
462
- })
463
- ], CreateNewApp.prototype, "verbose", void 0);
@@ -1,8 +0,0 @@
1
- /**
2
- * List of known authentication guards
3
- */
4
- export declare const authGuards: {
5
- name: string;
6
- message: string;
7
- hint: string;
8
- }[];
@@ -1,26 +0,0 @@
1
- /*
2
- * create-adonisjs
3
- *
4
- * (c) AdonisJS
5
- *
6
- * For the full copyright and license information, please view the LICENSE
7
- * file that was distributed with this source code.
8
- */
9
- import { GUARDS } from '@adonisjs/presets/auth';
10
- /**
11
- * List of known authentication guards
12
- */
13
- export const authGuards = [
14
- ...Object.keys(GUARDS).map((guard) => {
15
- return {
16
- name: guard,
17
- hint: GUARDS[guard].description,
18
- message: GUARDS[guard].name,
19
- };
20
- }),
21
- {
22
- name: 'skip',
23
- message: 'Skip',
24
- hint: 'I want to configure the Auth package manually',
25
- },
26
- ];
@@ -1,11 +0,0 @@
1
- /**
2
- * List of known databases that can be used with Lucid
3
- */
4
- export declare const databases: ({
5
- name: "sqlite" | "mysql" | "libsql" | "postgres" | "mssql";
6
- message: string;
7
- } | {
8
- name: string;
9
- message: string;
10
- hint: string;
11
- })[];
@@ -1,25 +0,0 @@
1
- /*
2
- * create-adonisjs
3
- *
4
- * (c) AdonisJS
5
- *
6
- * For the full copyright and license information, please view the LICENSE
7
- * file that was distributed with this source code.
8
- */
9
- import { DIALECTS } from '@adonisjs/presets/lucid';
10
- /**
11
- * List of known databases that can be used with Lucid
12
- */
13
- export const databases = [
14
- ...Object.keys(DIALECTS).map((dialect) => {
15
- return {
16
- name: dialect,
17
- message: DIALECTS[dialect].name,
18
- };
19
- }),
20
- {
21
- name: 'skip',
22
- message: 'Skip',
23
- hint: 'I want to configure Lucid manually',
24
- },
25
- ];
@@ -1,12 +0,0 @@
1
- /**
2
- * List of adapters for configuring Inertia
3
- */
4
- export declare const adapters: ({
5
- message: string;
6
- name: string;
7
- hint?: undefined;
8
- } | {
9
- name: string;
10
- message: string;
11
- hint: string;
12
- })[];
@@ -1,34 +0,0 @@
1
- /*
2
- * create-adonisjs
3
- *
4
- * (c) AdonisJS
5
- *
6
- * For the full copyright and license information, please view the LICENSE
7
- * file that was distributed with this source code.
8
- */
9
- /**
10
- * List of adapters for configuring Inertia
11
- */
12
- export const adapters = [
13
- {
14
- message: 'Vue 3',
15
- name: 'vue',
16
- },
17
- {
18
- message: 'React',
19
- name: 'react',
20
- },
21
- {
22
- message: 'Svelte',
23
- name: 'svelte',
24
- },
25
- {
26
- message: 'Solid.js',
27
- name: 'solid',
28
- },
29
- {
30
- name: 'skip',
31
- message: 'Skip',
32
- hint: 'I want to configure Interia manually',
33
- },
34
- ];
@@ -1,37 +0,0 @@
1
- /*
2
- * create-adonisjs
3
- *
4
- * (c) AdonisJS
5
- *
6
- * For the full copyright and license information, please view the LICENSE
7
- * file that was distributed with this source code.
8
- */
9
- /**
10
- * List of first party templates
11
- */
12
- export const templates = [
13
- {
14
- name: 'Slim Starter Kit',
15
- alias: 'slim',
16
- hint: 'A lean AdonisJS application with just the framework core',
17
- source: 'github:adonisjs/slim-starter-kit',
18
- },
19
- {
20
- name: 'Web Starter Kit',
21
- alias: 'web',
22
- hint: 'Everything you need to build a server render app',
23
- source: 'github:adonisjs/web-starter-kit',
24
- },
25
- {
26
- name: 'API Starter Kit',
27
- alias: 'api',
28
- hint: 'AdonisJS app tailored for creating JSON APIs',
29
- source: 'github:adonisjs/api-starter-kit',
30
- },
31
- {
32
- name: 'Inertia Starter Kit',
33
- alias: 'inertia',
34
- hint: 'Inertia app with a frontend framework of your choice',
35
- source: 'github:adonisjs/inertia-starter-kit',
36
- },
37
- ];