create-adonisjs 2.3.0 → 3.0.0-next.0
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 +20 -47
- package/build/bin/run.js +6 -2
- package/build/chunk-KJKWYPWV.js +257 -0
- package/build/commands/main.d.ts +0 -21
- package/build/index.js +6 -21
- package/package.json +85 -62
- package/build/bin/test.js +0 -31
- package/build/commands/main.js +0 -485
- package/build/src/auth_guards.d.ts +0 -8
- package/build/src/auth_guards.js +0 -26
- package/build/src/databases.d.ts +0 -11
- package/build/src/databases.js +0 -25
- package/build/src/inertia_adapters.d.ts +0 -12
- package/build/src/inertia_adapters.js +0 -34
- package/build/src/templates.js +0 -37
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
|
-
- `
|
|
14
|
-
- `
|
|
15
|
-
- `
|
|
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,48 +82,22 @@ 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
|
|
114
89
|
|
|
115
|
-
| Option
|
|
116
|
-
|
|
|
117
|
-
| `--
|
|
118
|
-
| `--
|
|
119
|
-
| `--no-install` | Explicitly opt out from installing dependencies and skip the prompt |
|
|
120
|
-
| `--verbose` | Enable verbose mode to display all logs |
|
|
90
|
+
| Option | Description |
|
|
91
|
+
| ------------ | --------------------------------------- |
|
|
92
|
+
| `--git-init` | Initialize git repository. |
|
|
93
|
+
| `--verbose` | Enable verbose mode to display all logs |
|
|
121
94
|
|
|
122
95
|
## Debugging errors
|
|
123
96
|
|
|
124
97
|
If creating a new project fails, then you must re-run the same command with the `--verbose` flag to view all the logs.
|
|
125
98
|
|
|
126
99
|
```sh
|
|
127
|
-
npm init adonisjs -- --verbose
|
|
100
|
+
npm init adonisjs@next -- --verbose
|
|
128
101
|
```
|
|
129
102
|
|
|
130
103
|
## Contributing
|
package/build/bin/run.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
kernel
|
|
2
|
+
import {
|
|
3
|
+
kernel
|
|
4
|
+
} from "../chunk-KJKWYPWV.js";
|
|
5
|
+
|
|
6
|
+
// bin/run.ts
|
|
7
|
+
kernel.handle(["create-adonisjs", ...process.argv.slice(2)]).catch(console.error);
|
|
@@ -0,0 +1,257 @@
|
|
|
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/web-starter-kit#7.x"
|
|
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/react-starter-kit#7.x"
|
|
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/vue-starter-kit#7.x"
|
|
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 matchingTemplatingFromAlias = templates.find((t) => t.alias === this.kit);
|
|
107
|
+
if (matchingTemplatingFromAlias) {
|
|
108
|
+
this.kit = matchingTemplatingFromAlias.source;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Replace the package.json name with the destination directory name.
|
|
114
|
+
* Errors are ignored.
|
|
115
|
+
*/
|
|
116
|
+
async #replacePackageJsonName() {
|
|
117
|
+
const pkgJsonPath = join(this.destination, "package.json");
|
|
118
|
+
const pkgJson = await readFile(pkgJsonPath, "utf-8").then(JSON.parse);
|
|
119
|
+
pkgJson.name = basename(this.destination);
|
|
120
|
+
await writeFile(pkgJsonPath, JSON.stringify(pkgJson, null, 2));
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Optionally removes readme file. Errors are ignored
|
|
124
|
+
*/
|
|
125
|
+
async #removeReadmeFile() {
|
|
126
|
+
await unlink(join(this.destination, "README.md"));
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Optionally remove existing lock file. Errors are ignored
|
|
130
|
+
*/
|
|
131
|
+
async #removeLockFile() {
|
|
132
|
+
await Promise.allSettled([
|
|
133
|
+
unlink(join(this.destination, "package-lock.json")),
|
|
134
|
+
unlink(join(this.destination, "yarn.lock")),
|
|
135
|
+
unlink(join(this.destination, "pnpm-lock.yaml"))
|
|
136
|
+
]);
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* If starter template has a `.env.example` file, then copy it to `.env`
|
|
140
|
+
*/
|
|
141
|
+
async #copyEnvExampleFile() {
|
|
142
|
+
const envPath = join(this.destination, ".env");
|
|
143
|
+
const envExamplePath = join(this.destination, ".env.example");
|
|
144
|
+
if (existsSync(envExamplePath)) {
|
|
145
|
+
await copyFile(envExamplePath, envPath);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Generate a fresh app key. Errors are ignored
|
|
150
|
+
*/
|
|
151
|
+
async #generateFreshAppKey() {
|
|
152
|
+
await this.#runBashCommand("node", ["ace", "generate:key"]);
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Main method
|
|
156
|
+
*/
|
|
157
|
+
async run() {
|
|
158
|
+
this.packageManager = this.packageManager || detectPackageManager()?.name || "npm";
|
|
159
|
+
this.#printBannerArt();
|
|
160
|
+
await this.#promptForDestination();
|
|
161
|
+
await this.#promptForStarterKit();
|
|
162
|
+
const tasks = this.ui.tasks({ verbose: this.verbose === true });
|
|
163
|
+
tasks.add("Download starter kit", async (task) => {
|
|
164
|
+
task.update(`Downloading "${this.kit}"`);
|
|
165
|
+
await downloadTemplate(this.kit, {
|
|
166
|
+
dir: this.destination,
|
|
167
|
+
auth: this.token,
|
|
168
|
+
registry: false
|
|
169
|
+
});
|
|
170
|
+
await this.#removeLockFile();
|
|
171
|
+
return `Downloaded "${this.kit}"`;
|
|
172
|
+
}).addIf(this.gitInit === true, "Initialize git repository", async () => {
|
|
173
|
+
await this.#runBashCommand("git", ["init"]);
|
|
174
|
+
return "Initialized git repository";
|
|
175
|
+
}).add("Install packages", async (task) => {
|
|
176
|
+
const spinner = this.logger.await(`installing dependencies (${this.packageManager})`, {
|
|
177
|
+
silent: this.verbose
|
|
178
|
+
});
|
|
179
|
+
spinner.tap((line) => task.update(line));
|
|
180
|
+
spinner.start();
|
|
181
|
+
try {
|
|
182
|
+
await this.#runBashCommand(this.packageManager, ["install"]);
|
|
183
|
+
return `Packages installed using "${this.packageManager}"`;
|
|
184
|
+
} finally {
|
|
185
|
+
spinner.stop();
|
|
186
|
+
}
|
|
187
|
+
}).add("Prepare application", async () => {
|
|
188
|
+
try {
|
|
189
|
+
await this.#replacePackageJsonName();
|
|
190
|
+
await this.#removeReadmeFile();
|
|
191
|
+
await this.#copyEnvExampleFile();
|
|
192
|
+
await this.#generateFreshAppKey();
|
|
193
|
+
return "Application ready";
|
|
194
|
+
} catch (error) {
|
|
195
|
+
if (this.verbose) {
|
|
196
|
+
this.logger.fatal(error);
|
|
197
|
+
}
|
|
198
|
+
return "Unable to prepare application";
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
await tasks.run();
|
|
202
|
+
if (tasks.getState() === "succeeded") {
|
|
203
|
+
this.#printSuccessMessage();
|
|
204
|
+
} else {
|
|
205
|
+
this.exitCode = 1;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
__decorateClass([
|
|
210
|
+
args.string({ description: "Destination directory", required: false })
|
|
211
|
+
], CreateNewApp.prototype, "destination", 2);
|
|
212
|
+
__decorateClass([
|
|
213
|
+
flags.string({
|
|
214
|
+
description: "Define path to a custom git repository to download the starter kit",
|
|
215
|
+
alias: "K"
|
|
216
|
+
})
|
|
217
|
+
], CreateNewApp.prototype, "kit", 2);
|
|
218
|
+
__decorateClass([
|
|
219
|
+
flags.string({
|
|
220
|
+
description: "Auth token to download private repositories",
|
|
221
|
+
alias: "t"
|
|
222
|
+
})
|
|
223
|
+
], CreateNewApp.prototype, "token", 2);
|
|
224
|
+
__decorateClass([
|
|
225
|
+
flags.boolean({
|
|
226
|
+
description: "Init git repository"
|
|
227
|
+
})
|
|
228
|
+
], CreateNewApp.prototype, "gitInit", 2);
|
|
229
|
+
__decorateClass([
|
|
230
|
+
flags.string({
|
|
231
|
+
description: "Define the package manager to install dependencies",
|
|
232
|
+
flagName: "pkg"
|
|
233
|
+
})
|
|
234
|
+
], CreateNewApp.prototype, "packageManager", 2);
|
|
235
|
+
__decorateClass([
|
|
236
|
+
flags.boolean({
|
|
237
|
+
description: "Execute tasks in verbose mode",
|
|
238
|
+
alias: "v"
|
|
239
|
+
})
|
|
240
|
+
], CreateNewApp.prototype, "verbose", 2);
|
|
241
|
+
|
|
242
|
+
// index.ts
|
|
243
|
+
Kernel.defaultCommand = CreateNewApp;
|
|
244
|
+
var kernel = Kernel.create();
|
|
245
|
+
kernel.defineFlag("help", {
|
|
246
|
+
type: "boolean",
|
|
247
|
+
description: HelpCommand.description
|
|
248
|
+
});
|
|
249
|
+
kernel.on("help", async (command, $kernel, parsed) => {
|
|
250
|
+
parsed.args.unshift(command.commandName);
|
|
251
|
+
await new HelpCommand($kernel, parsed, kernel.ui, kernel.prompt).exec();
|
|
252
|
+
return $kernel.shortcircuit();
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
export {
|
|
256
|
+
kernel
|
|
257
|
+
};
|
package/build/commands/main.d.ts
CHANGED
|
@@ -23,11 +23,6 @@ export declare class CreateNewApp extends BaseCommand {
|
|
|
23
23
|
* Authentication token to download private templates
|
|
24
24
|
*/
|
|
25
25
|
token?: string;
|
|
26
|
-
/**
|
|
27
|
-
* Auto install packages after creating the project. Display prompt
|
|
28
|
-
* when flag is not mentioned.
|
|
29
|
-
*/
|
|
30
|
-
install?: boolean;
|
|
31
26
|
/**
|
|
32
27
|
* Init git repository. Do not init when flag is not mentioned.
|
|
33
28
|
*/
|
|
@@ -37,22 +32,6 @@ export declare class CreateNewApp extends BaseCommand {
|
|
|
37
32
|
* mentioned.
|
|
38
33
|
*/
|
|
39
34
|
packageManager: string;
|
|
40
|
-
/**
|
|
41
|
-
* Database dialect for Lucid. Defaults to "sqlite"
|
|
42
|
-
*/
|
|
43
|
-
db?: string;
|
|
44
|
-
/**
|
|
45
|
-
* Auth guard for auth package.
|
|
46
|
-
*/
|
|
47
|
-
authGuard?: string;
|
|
48
|
-
/**
|
|
49
|
-
* Inertia adapter to use
|
|
50
|
-
*/
|
|
51
|
-
adapter?: string;
|
|
52
|
-
/**
|
|
53
|
-
* Inertia adapter to use
|
|
54
|
-
*/
|
|
55
|
-
ssr?: boolean;
|
|
56
35
|
/**
|
|
57
36
|
* Execute tasks in verbose mode. Defaults to false.
|
|
58
37
|
*/
|
package/build/index.js
CHANGED
|
@@ -1,21 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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-KJKWYPWV.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": "
|
|
4
|
+
"version": "3.0.0-next.0",
|
|
5
5
|
"engines": {
|
|
6
|
-
"node": ">=
|
|
6
|
+
"node": ">=24.0.0"
|
|
7
7
|
},
|
|
8
8
|
"main": "build/index.js",
|
|
9
9
|
"type": "module",
|
|
10
10
|
"files": [
|
|
11
|
-
"build
|
|
12
|
-
"build/
|
|
13
|
-
"build/
|
|
14
|
-
"build/
|
|
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
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
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": "^
|
|
39
|
-
"@adonisjs/prettier-config": "^1.
|
|
40
|
-
"@adonisjs/tsconfig": "^
|
|
41
|
-
"@japa/assert": "^
|
|
42
|
-
"@japa/file-system": "^2.3.
|
|
43
|
-
"@japa/runner": "^
|
|
44
|
-
"@
|
|
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": "^
|
|
49
|
+
"@types/node": "^24.5.2",
|
|
47
50
|
"@types/which-pm-runs": "^1.0.2",
|
|
48
|
-
"c8": "^10.1.
|
|
49
|
-
"
|
|
50
|
-
"del-cli": "^
|
|
51
|
-
"eslint": "^
|
|
52
|
-
"prettier": "^3.
|
|
53
|
-
"release-it": "
|
|
54
|
-
"
|
|
55
|
-
"typescript": "^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": "^
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
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
|
-
"
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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
|
-
"
|
|
86
|
+
"provenance": true
|
|
90
87
|
},
|
|
91
|
-
"
|
|
92
|
-
"
|
|
93
|
-
"
|
|
94
|
-
"
|
|
88
|
+
"tsup": {
|
|
89
|
+
"entry": [
|
|
90
|
+
"./index.ts",
|
|
91
|
+
"./bin/run.ts"
|
|
95
92
|
],
|
|
96
|
-
"
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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
|
-
|
|
111
|
-
|
|
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();
|
package/build/commands/main.js
DELETED
|
@@ -1,485 +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
|
-
* Prompt to check if we should install dependencies?
|
|
153
|
-
*/
|
|
154
|
-
async #promptForInstallingDeps() {
|
|
155
|
-
if (this.install === undefined) {
|
|
156
|
-
this.install = await this.prompt.confirm(`Do you want to install dependencies using "${this.packageManager}"`, {
|
|
157
|
-
default: true,
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* Replace the package.json name with the destination directory name.
|
|
163
|
-
* Errors are ignored.
|
|
164
|
-
*/
|
|
165
|
-
async #replacePackageJsonName() {
|
|
166
|
-
const pkgJsonPath = join(this.destination, 'package.json');
|
|
167
|
-
const pkgJson = await readFile(pkgJsonPath, 'utf-8').then(JSON.parse);
|
|
168
|
-
pkgJson.name = basename(this.destination);
|
|
169
|
-
await writeFile(pkgJsonPath, JSON.stringify(pkgJson, null, 2));
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Optionally removes readme file. Errors are ignored
|
|
173
|
-
*/
|
|
174
|
-
async #removeReadmeFile() {
|
|
175
|
-
await unlink(join(this.destination, 'README.md'));
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* Optionally remove existing lock file. Errors are ignored
|
|
179
|
-
*/
|
|
180
|
-
async #removeLockFile() {
|
|
181
|
-
await Promise.allSettled([
|
|
182
|
-
unlink(join(this.destination, 'package-lock.json')),
|
|
183
|
-
unlink(join(this.destination, 'yarn.lock')),
|
|
184
|
-
unlink(join(this.destination, 'pnpm-lock.yaml')),
|
|
185
|
-
]);
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* If starter template has an `.env.example` file, then copy it to `.env`
|
|
189
|
-
*/
|
|
190
|
-
async #copyEnvExampleFile() {
|
|
191
|
-
const envPath = join(this.destination, '.env');
|
|
192
|
-
const envExamplePath = join(this.destination, '.env.example');
|
|
193
|
-
if (existsSync(envExamplePath)) {
|
|
194
|
-
await copyFile(envExamplePath, envPath);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* Generate a fresh app key. Errors are ignored
|
|
199
|
-
*/
|
|
200
|
-
async #generateFreshAppKey() {
|
|
201
|
-
if (this.install === false) {
|
|
202
|
-
return;
|
|
203
|
-
}
|
|
204
|
-
await this.#runBashCommand('node', ['ace', 'generate:key']);
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* Configures the Lucid package
|
|
208
|
-
*/
|
|
209
|
-
async #configureLucid() {
|
|
210
|
-
const argv = ['ace', 'configure', '@adonisjs/lucid', '--db', this.db, '--install'];
|
|
211
|
-
if (this.verbose) {
|
|
212
|
-
argv.push('--verbose');
|
|
213
|
-
}
|
|
214
|
-
await this.#runBashCommand('node', argv);
|
|
215
|
-
}
|
|
216
|
-
/**
|
|
217
|
-
* Configures the session package
|
|
218
|
-
*/
|
|
219
|
-
async #configureSession() {
|
|
220
|
-
await installPackage(['@adonisjs/session@latest'], {
|
|
221
|
-
cwd: this.destination,
|
|
222
|
-
packageManager: this.packageManager,
|
|
223
|
-
silent: !this.verbose,
|
|
224
|
-
});
|
|
225
|
-
const argv = ['ace', 'configure', '@adonisjs/session'];
|
|
226
|
-
if (this.verbose) {
|
|
227
|
-
argv.push('--verbose');
|
|
228
|
-
}
|
|
229
|
-
await this.#runBashCommand('node', argv);
|
|
230
|
-
}
|
|
231
|
-
/**
|
|
232
|
-
* Configures the Auth package
|
|
233
|
-
*/
|
|
234
|
-
async #configureAuth() {
|
|
235
|
-
/**
|
|
236
|
-
* Install the session package when using api starter kit with session
|
|
237
|
-
* guard. This needs to be done, since the api starter kit does
|
|
238
|
-
* not install the session package by default.
|
|
239
|
-
*/
|
|
240
|
-
if (this.authGuard === 'session' && this.kit === API_STARTER_KIT) {
|
|
241
|
-
await this.#configureSession();
|
|
242
|
-
}
|
|
243
|
-
/**
|
|
244
|
-
* Next configure the auth package
|
|
245
|
-
*/
|
|
246
|
-
const argv = ['ace', 'configure', '@adonisjs/auth', '--guard', this.authGuard];
|
|
247
|
-
if (this.verbose) {
|
|
248
|
-
argv.push('--verbose');
|
|
249
|
-
}
|
|
250
|
-
await this.#runBashCommand('node', argv);
|
|
251
|
-
}
|
|
252
|
-
/**
|
|
253
|
-
* Configures the Inertia package
|
|
254
|
-
*/
|
|
255
|
-
async #configureInertia() {
|
|
256
|
-
const argv = [
|
|
257
|
-
'ace',
|
|
258
|
-
'configure',
|
|
259
|
-
'@adonisjs/inertia',
|
|
260
|
-
'--adapter',
|
|
261
|
-
this.adapter,
|
|
262
|
-
this.ssr ? '--ssr' : '--no-ssr',
|
|
263
|
-
this.install ? '--install' : '--no-install',
|
|
264
|
-
];
|
|
265
|
-
if (this.verbose) {
|
|
266
|
-
argv.push('--verbose');
|
|
267
|
-
}
|
|
268
|
-
await this.#runBashCommand('node', argv);
|
|
269
|
-
}
|
|
270
|
-
/**
|
|
271
|
-
* Main method
|
|
272
|
-
*/
|
|
273
|
-
async run() {
|
|
274
|
-
this.packageManager = this.packageManager || detectPackageManager()?.name || 'npm';
|
|
275
|
-
/**
|
|
276
|
-
* Print ASCII art
|
|
277
|
-
*/
|
|
278
|
-
this.#printBannerArt();
|
|
279
|
-
/**
|
|
280
|
-
* Display prompts
|
|
281
|
-
*/
|
|
282
|
-
await this.#promptForDestination();
|
|
283
|
-
await this.#promptForStarterKit();
|
|
284
|
-
if (this.kit === WEB_STARTER_KIT ||
|
|
285
|
-
this.kit === API_STARTER_KIT ||
|
|
286
|
-
this.kit === INERTIA_STARTER_KIT) {
|
|
287
|
-
await this.#promptForAuthGuard();
|
|
288
|
-
await this.#promptForDatabaseDriver();
|
|
289
|
-
}
|
|
290
|
-
if (this.kit === INERTIA_STARTER_KIT) {
|
|
291
|
-
await this.#promptForInertiaAdapter();
|
|
292
|
-
await this.#promptForInertiaSsr();
|
|
293
|
-
}
|
|
294
|
-
await this.#promptForInstallingDeps();
|
|
295
|
-
/**
|
|
296
|
-
* Create tasks instance for displaying
|
|
297
|
-
* actions as tasks
|
|
298
|
-
*/
|
|
299
|
-
const tasks = this.ui.tasks({ verbose: this.verbose === true });
|
|
300
|
-
/**
|
|
301
|
-
* Configure lucid when using our own starter kits
|
|
302
|
-
* and installing dependencies
|
|
303
|
-
*/
|
|
304
|
-
const configureLucid = [WEB_STARTER_KIT, API_STARTER_KIT, INERTIA_STARTER_KIT].includes(this.kit || '') &&
|
|
305
|
-
this.db !== 'skip' &&
|
|
306
|
-
this.install !== false;
|
|
307
|
-
/**
|
|
308
|
-
* Configure auth when using our own starter kits
|
|
309
|
-
* and installing dependencies
|
|
310
|
-
*/
|
|
311
|
-
const configureAuth = [WEB_STARTER_KIT, API_STARTER_KIT, INERTIA_STARTER_KIT].includes(this.kit || '') &&
|
|
312
|
-
this.authGuard !== 'skip' &&
|
|
313
|
-
this.install !== false;
|
|
314
|
-
/**
|
|
315
|
-
* Configure inertia when using our inertia starter kit
|
|
316
|
-
*/
|
|
317
|
-
const configureInertia = this.kit === INERTIA_STARTER_KIT && this.adapter !== 'skip' && this.install !== false;
|
|
318
|
-
tasks
|
|
319
|
-
.add('Download starter kit', async (task) => {
|
|
320
|
-
task.update(`Downloading "${this.kit}"`);
|
|
321
|
-
await downloadTemplate(this.kit, {
|
|
322
|
-
dir: this.destination,
|
|
323
|
-
auth: this.token,
|
|
324
|
-
registry: false,
|
|
325
|
-
});
|
|
326
|
-
await this.#removeLockFile();
|
|
327
|
-
return `Downloaded "${this.kit}"`;
|
|
328
|
-
})
|
|
329
|
-
.addIf(this.gitInit === true, 'Initialize git repository', async () => {
|
|
330
|
-
await this.#runBashCommand('git', ['init']);
|
|
331
|
-
return 'Initialized git repository';
|
|
332
|
-
})
|
|
333
|
-
.addIf(this.install !== false, 'Install packages', async (task) => {
|
|
334
|
-
const spinner = this.logger.await('installing dependencies', {
|
|
335
|
-
silent: this.verbose,
|
|
336
|
-
});
|
|
337
|
-
spinner.tap((line) => task.update(line));
|
|
338
|
-
spinner.start();
|
|
339
|
-
try {
|
|
340
|
-
await this.#runBashCommand(this.packageManager, ['install']);
|
|
341
|
-
return `Packages installed using "${this.packageManager}"`;
|
|
342
|
-
}
|
|
343
|
-
finally {
|
|
344
|
-
spinner.stop();
|
|
345
|
-
}
|
|
346
|
-
})
|
|
347
|
-
.add('Prepare application', async () => {
|
|
348
|
-
try {
|
|
349
|
-
await this.#replacePackageJsonName();
|
|
350
|
-
await this.#removeReadmeFile();
|
|
351
|
-
await this.#copyEnvExampleFile();
|
|
352
|
-
await this.#generateFreshAppKey();
|
|
353
|
-
return 'Application ready';
|
|
354
|
-
}
|
|
355
|
-
catch (error) {
|
|
356
|
-
if (this.verbose) {
|
|
357
|
-
this.logger.fatal(error);
|
|
358
|
-
}
|
|
359
|
-
return 'Unable to prepare application';
|
|
360
|
-
}
|
|
361
|
-
})
|
|
362
|
-
.addIf(configureLucid, 'Configure Lucid', async (task) => {
|
|
363
|
-
const spinner = this.logger.await('configuring @adonisjs/lucid', {
|
|
364
|
-
silent: this.verbose,
|
|
365
|
-
});
|
|
366
|
-
spinner.tap((line) => task.update(line));
|
|
367
|
-
spinner.start();
|
|
368
|
-
try {
|
|
369
|
-
await this.#configureLucid();
|
|
370
|
-
spinner.stop();
|
|
371
|
-
return `Lucid configured to use "${this.db}" database`;
|
|
372
|
-
}
|
|
373
|
-
catch (error) {
|
|
374
|
-
spinner.stop();
|
|
375
|
-
if (this.verbose) {
|
|
376
|
-
this.logger.fatal(error);
|
|
377
|
-
}
|
|
378
|
-
return `Unable to configure "@adonisjs/lucid"`;
|
|
379
|
-
}
|
|
380
|
-
})
|
|
381
|
-
.addIf(configureAuth, 'Configure Auth', async (task) => {
|
|
382
|
-
const spinner = this.logger.await('configuring @adonisjs/auth', {
|
|
383
|
-
silent: this.verbose,
|
|
384
|
-
});
|
|
385
|
-
spinner.tap((line) => task.update(line));
|
|
386
|
-
spinner.start();
|
|
387
|
-
try {
|
|
388
|
-
await this.#configureAuth();
|
|
389
|
-
spinner.stop();
|
|
390
|
-
return `Auth configured to use "${this.authGuard}" guard`;
|
|
391
|
-
}
|
|
392
|
-
catch (error) {
|
|
393
|
-
spinner.stop();
|
|
394
|
-
if (this.verbose) {
|
|
395
|
-
this.logger.fatal(error);
|
|
396
|
-
}
|
|
397
|
-
return `Unable to configure "@adonisjs/auth"`;
|
|
398
|
-
}
|
|
399
|
-
})
|
|
400
|
-
.addIf(configureInertia, 'Configure Inertia', async (task) => {
|
|
401
|
-
const spinner = this.logger.await('configuring @adonisjs/inertia', {
|
|
402
|
-
silent: this.verbose,
|
|
403
|
-
});
|
|
404
|
-
spinner.tap((line) => task.update(line));
|
|
405
|
-
spinner.start();
|
|
406
|
-
try {
|
|
407
|
-
await this.#configureInertia();
|
|
408
|
-
spinner.stop();
|
|
409
|
-
return 'Inertia configured';
|
|
410
|
-
}
|
|
411
|
-
catch (error) {
|
|
412
|
-
spinner.stop();
|
|
413
|
-
if (this.verbose) {
|
|
414
|
-
this.logger.fatal(error);
|
|
415
|
-
}
|
|
416
|
-
return `Unable to configure "@adonisjs/inertia"`;
|
|
417
|
-
}
|
|
418
|
-
});
|
|
419
|
-
await tasks.run();
|
|
420
|
-
if (tasks.getState() === 'succeeded') {
|
|
421
|
-
this.#printSuccessMessage();
|
|
422
|
-
}
|
|
423
|
-
else {
|
|
424
|
-
this.exitCode = 1;
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
__decorate([
|
|
429
|
-
args.string({ description: 'Destination directory', required: false })
|
|
430
|
-
], CreateNewApp.prototype, "destination", void 0);
|
|
431
|
-
__decorate([
|
|
432
|
-
flags.string({
|
|
433
|
-
description: 'Define path to a custom git repository to download the starter kit',
|
|
434
|
-
alias: 'K',
|
|
435
|
-
})
|
|
436
|
-
], CreateNewApp.prototype, "kit", void 0);
|
|
437
|
-
__decorate([
|
|
438
|
-
flags.string({
|
|
439
|
-
description: 'Auth token to download private repositories',
|
|
440
|
-
alias: 't',
|
|
441
|
-
})
|
|
442
|
-
], CreateNewApp.prototype, "token", void 0);
|
|
443
|
-
__decorate([
|
|
444
|
-
flags.boolean({
|
|
445
|
-
description: 'Force install or skip dependencies installation',
|
|
446
|
-
showNegatedVariantInHelp: true,
|
|
447
|
-
})
|
|
448
|
-
], CreateNewApp.prototype, "install", void 0);
|
|
449
|
-
__decorate([
|
|
450
|
-
flags.boolean({
|
|
451
|
-
description: 'Init git repository',
|
|
452
|
-
})
|
|
453
|
-
], CreateNewApp.prototype, "gitInit", void 0);
|
|
454
|
-
__decorate([
|
|
455
|
-
flags.string({
|
|
456
|
-
description: 'Define the package manager to install dependencies',
|
|
457
|
-
flagName: 'pkg',
|
|
458
|
-
})
|
|
459
|
-
], CreateNewApp.prototype, "packageManager", void 0);
|
|
460
|
-
__decorate([
|
|
461
|
-
flags.string({
|
|
462
|
-
description: 'Define the database dialect to use with Lucid',
|
|
463
|
-
})
|
|
464
|
-
], CreateNewApp.prototype, "db", void 0);
|
|
465
|
-
__decorate([
|
|
466
|
-
flags.string({
|
|
467
|
-
description: 'Define the authentication guard with the Auth package',
|
|
468
|
-
})
|
|
469
|
-
], CreateNewApp.prototype, "authGuard", void 0);
|
|
470
|
-
__decorate([
|
|
471
|
-
flags.string({
|
|
472
|
-
description: 'Define the Inertia frontend adapter',
|
|
473
|
-
})
|
|
474
|
-
], CreateNewApp.prototype, "adapter", void 0);
|
|
475
|
-
__decorate([
|
|
476
|
-
flags.boolean({
|
|
477
|
-
description: 'Enable SSR for Inertia',
|
|
478
|
-
})
|
|
479
|
-
], CreateNewApp.prototype, "ssr", void 0);
|
|
480
|
-
__decorate([
|
|
481
|
-
flags.boolean({
|
|
482
|
-
description: 'Execute tasks in verbose mode',
|
|
483
|
-
alias: 'v',
|
|
484
|
-
})
|
|
485
|
-
], CreateNewApp.prototype, "verbose", void 0);
|
package/build/src/auth_guards.js
DELETED
|
@@ -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
|
-
];
|
package/build/src/databases.d.ts
DELETED
package/build/src/databases.js
DELETED
|
@@ -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,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
|
-
];
|
package/build/src/templates.js
DELETED
|
@@ -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
|
-
];
|