create-adonisjs 1.0.0 → 1.1.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/build/bin/run.js CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
  import { kernel } from '../index.js';
3
- kernel.handle(process.argv.slice(2)).catch(console.error);
3
+ kernel.handle(['create-adonisjs', ...process.argv.slice(2)]).catch(console.error);
package/build/index.js CHANGED
@@ -6,7 +6,16 @@
6
6
  * For the full copyright and license information, please view the LICENSE
7
7
  * file that was distributed with this source code.
8
8
  */
9
- import { Kernel } from '@adonisjs/ace';
9
+ import { HelpCommand, Kernel } from '@adonisjs/ace';
10
10
  import { InstallAdonis } from './src/install_adonis.js';
11
11
  Kernel.defaultCommand = InstallAdonis;
12
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
+ });
@@ -28,6 +28,10 @@ export declare class InstallAdonis extends BaseCommand {
28
28
  * Skip git initialization
29
29
  */
30
30
  skipGitInit: boolean;
31
+ /**
32
+ * Package manager to use
33
+ */
34
+ packageManager: string;
31
35
  /**
32
36
  * Execute the `run` method and catch errors
33
37
  */
@@ -23,12 +23,8 @@ import gradient from 'gradient-string';
23
23
  import { execa } from 'execa';
24
24
  import { templates } from './templates.js';
25
25
  export class InstallAdonis extends BaseCommand {
26
- static commandName = 'install-adonisjs';
26
+ static commandName = 'create-adonisjs';
27
27
  static description = 'Install AdonisJS';
28
- /**
29
- * The detected package manager ( based on agent )
30
- */
31
- #detectedPkgManager;
32
28
  /**
33
29
  * Whether or not dependencies were installed
34
30
  */
@@ -63,7 +59,6 @@ export class InstallAdonis extends BaseCommand {
63
59
  * Prompt and download the selected template
64
60
  */
65
61
  async #downloadTemplate() {
66
- this.logger.log('');
67
62
  let templateSource = this.kit;
68
63
  if (!templateSource) {
69
64
  const template = await this.prompt.choice('Which template do you want to use?', templates);
@@ -85,17 +80,14 @@ export class InstallAdonis extends BaseCommand {
85
80
  async #installDependencies() {
86
81
  if (this.skipInstall)
87
82
  return;
88
- this.logger.log('');
89
- const pkgManager = this.#detectedPkgManager;
90
- this.#hasInstalledDependencies = await this.prompt.confirm('Do you want to install dependencies?', {
91
- hint: pkgManager + ' will be used',
92
- default: true,
93
- });
83
+ this.#hasInstalledDependencies = await this.prompt.confirm('Do you want to install dependencies?', { hint: this.packageManager + ' will be used', default: true });
94
84
  if (!this.#hasInstalledDependencies)
95
85
  return;
96
- const spinner = this.logger.await(`Installing dependencies using ${pkgManager}`).start();
86
+ const spinner = this.logger
87
+ .await(`Installing dependencies using ${this.packageManager}`)
88
+ .start();
97
89
  try {
98
- await execa(pkgManager, ['install'], { cwd: this.destination });
90
+ await execa(this.packageManager, ['install'], { cwd: this.destination });
99
91
  spinner.update('Dependencies installed successfully').stop();
100
92
  }
101
93
  catch (error) {
@@ -110,7 +102,6 @@ export class InstallAdonis extends BaseCommand {
110
102
  async #initGitRepo() {
111
103
  if (this.skipGitInit)
112
104
  return;
113
- this.logger.log('');
114
105
  const shouldInit = await this.prompt.confirm('Do you want to initialize a git repository?', {
115
106
  default: true,
116
107
  });
@@ -134,12 +125,12 @@ export class InstallAdonis extends BaseCommand {
134
125
  .sticker()
135
126
  .heading('Your AdonisJS project was created successfully !')
136
127
  .add(`1. ${this.colors.magenta('cd ' + relative(cwd(), this.destination))}`)
137
- .add(`2. ${this.colors.magenta(`${this.#detectedPkgManager} run dev`)}`)
128
+ .add(`2. ${this.colors.magenta(`${this.packageManager} run dev`)}`)
138
129
  .add(`3. ${this.colors.magenta('Visit http://localhost:3333')}`)
139
130
  .add('')
140
- .add(`Have any questions? Join our Discord server: ${this.colors.magenta('https://discord.gg/vDcEjq6')}`)
131
+ .add(`Have any questions?`)
132
+ .add(`Join our Discord server: ${this.colors.magenta('https://discord.gg/vDcEjq6')}`)
141
133
  .render();
142
- this.logger.log('');
143
134
  }
144
135
  /**
145
136
  * Replace the package.json name with the destination directory name
@@ -191,7 +182,9 @@ export class InstallAdonis extends BaseCommand {
191
182
  * Main method
192
183
  */
193
184
  async run() {
194
- this.#detectedPkgManager = detectPackageManager()?.name || 'npm';
185
+ if (!this.packageManager) {
186
+ this.packageManager = detectPackageManager()?.name || 'npm';
187
+ }
195
188
  this.#printTitle();
196
189
  await this.#promptDestination();
197
190
  await this.#downloadTemplate();
@@ -218,3 +211,6 @@ __decorate([
218
211
  __decorate([
219
212
  flags.boolean({ description: 'Skip git initialization', name: 'skip-git-init' })
220
213
  ], InstallAdonis.prototype, "skipGitInit", void 0);
214
+ __decorate([
215
+ flags.string({ description: 'Force a package manager to be used', name: 'package-manager' })
216
+ ], InstallAdonis.prototype, "packageManager", void 0);
@@ -10,6 +10,11 @@
10
10
  * List of first party templates
11
11
  */
12
12
  export const templates = [
13
+ {
14
+ name: 'Slim Starter Kit',
15
+ hint: 'Smallest possible AdonisJS application with just the core and Japa',
16
+ source: 'github:adonisjs/slim-starter-kit',
17
+ },
13
18
  {
14
19
  name: 'Web Starter Kit',
15
20
  hint: 'for building web applications',
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "create-adonisjs",
3
3
  "description": "Scaffolding tool to create AdonisJS 6 projects",
4
- "version": "1.0.0",
4
+ "version": "1.1.0",
5
5
  "engines": {
6
6
  "node": ">=18.16.0"
7
7
  },
@@ -34,16 +34,15 @@
34
34
  "prepublishOnly": "npm run build"
35
35
  },
36
36
  "devDependencies": {
37
- "@adonisjs/core": "^6.1.5-5",
38
37
  "@adonisjs/eslint-config": "^1.1.7",
39
38
  "@adonisjs/prettier-config": "^1.1.7",
40
39
  "@adonisjs/tsconfig": "^1.1.7",
41
- "@japa/assert": "2.0.0-1",
42
- "@japa/file-system": "2.0.0-1",
43
- "@japa/runner": "3.0.0-3",
40
+ "@japa/assert": "^2.0.0-1",
41
+ "@japa/file-system": "^2.0.0-1",
42
+ "@japa/runner": "^3.0.0-5",
44
43
  "@swc/core": "^1.3.68",
45
44
  "@types/gradient-string": "^1.1.2",
46
- "@types/node": "^20.3.3",
45
+ "@types/node": "^20.4.1",
47
46
  "@types/which-pm-runs": "^1.0.0",
48
47
  "c8": "^8.0.0",
49
48
  "copyfiles": "^2.4.1",