-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
324 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,22 @@ | ||
#! /usr/bin/env node | ||
import chalk from 'chalk'; | ||
|
||
import { CliCommand } from './types.js'; | ||
|
||
const command = process.argv[2]; | ||
|
||
if (command === CliCommand.Create) { | ||
await import('./commands/create/cli.js'); | ||
} else if (command === CliCommand.Help) { | ||
// eslint-disable-next-line no-console | ||
console.log(`${chalk.underline.blue(`${chalk.yellow('@adminjs/cli')} Commands List`)} | ||
• ${chalk.underline('create')} Create an AdminJS project | ||
• ${chalk.underline('help')} List available CLI commands | ||
`); | ||
} else { | ||
console.log('unknown command', command); | ||
// eslint-disable-next-line no-console | ||
console.log(chalk.red(`Unknown command: ${command}`)); | ||
// eslint-disable-next-line no-console | ||
console.log(chalk.cyan(`Run ${chalk.yellow('adminjs help')} to see available commands.`)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import chalk from 'chalk'; | ||
|
||
import { logger } from '../../../index.js'; | ||
|
||
import { LibrarySetupHandler } from './LibrarySetup.handler.js'; | ||
|
||
export class NestSetupHandler extends LibrarySetupHandler { | ||
public async run() { | ||
await super.run(); | ||
await this.setupAdapter(); | ||
} | ||
|
||
public async setupAdapter() { | ||
logger.info(chalk.red('--------------- IMPORTANT ---------------')); | ||
logger.info(`The CLI does not support adapter setup for: ${chalk.yellow('@adminjs/nestjs')}`); | ||
// eslint-disable-next-line max-len | ||
logger.info(`${chalk.yellow('@adminjs/cli')} will bootstrap a ${chalk.yellow('NestJS + AdminJS')} application, but you will have to set up the adapter manually.`); | ||
// eslint-disable-next-line max-len | ||
logger.info(`Please refer to ${chalk.underline.magenta(`https://docs.adminjs.co/installation/adapters/${this.options.adapter}`)} for instructions.`); | ||
logger.info(chalk.red('-----------------------------------------')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
export * from './BaseSetup.handler.js'; | ||
export * from './CreateCommand.handler.js'; | ||
export * from './DatabaseDriverSetup.handler.js'; | ||
export * from './EnvironmentVariables.handler.js'; | ||
export * from './LibrarySetup.handler.js'; | ||
export * from './NestSetup.handler.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/commands/create/templates/plugin/nestjs/_config/custom.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"jest": { | ||
"moduleFileExtensions": [ | ||
"js", | ||
"json", | ||
"ts" | ||
], | ||
"rootDir": "src", | ||
"testRegex": ".*\\.spec\\.ts$", | ||
"transform": { | ||
"^.+\\.(t|j)s$": "ts-jest" | ||
}, | ||
"collectCoverageFrom": [ | ||
"**/*.(t|j)s" | ||
], | ||
"coverageDirectory": "../coverage", | ||
"testEnvironment": "node" | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/commands/create/templates/plugin/nestjs/_config/dependencies.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"@adminjs/express": "^6.1.0", | ||
"@adminjs/nestjs": "^6.1.0", | ||
"@nestjs/common": "^10.0.0", | ||
"@nestjs/config": "^3.1.1", | ||
"@nestjs/core": "^10.0.0", | ||
"@nestjs/platform-express": "^10.0.0", | ||
"adminjs": "^7.4.0", | ||
"express-formidable": "^1.2.0", | ||
"express-session": "^1.17.3", | ||
"reflect-metadata": "^0.1.13", | ||
"rxjs": "^7.8.1" | ||
} |
23 changes: 23 additions & 0 deletions
23
src/commands/create/templates/plugin/nestjs/_config/devDependencies.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"@nestjs/cli": "^10.0.0", | ||
"@nestjs/schematics": "^10.0.0", | ||
"@nestjs/testing": "^10.0.0", | ||
"@types/express": "^4.17.17", | ||
"@types/jest": "^29.5.2", | ||
"@types/node": "^20.3.1", | ||
"@types/supertest": "^2.0.12", | ||
"@typescript-eslint/eslint-plugin": "^6.0.0", | ||
"@typescript-eslint/parser": "^6.0.0", | ||
"eslint": "^8.42.0", | ||
"eslint-config-prettier": "^9.0.0", | ||
"eslint-plugin-prettier": "^5.0.0", | ||
"jest": "^29.5.0", | ||
"prettier": "^3.0.0", | ||
"source-map-support": "^0.5.21", | ||
"supertest": "^6.3.3", | ||
"ts-jest": "^29.1.0", | ||
"ts-loader": "^9.4.3", | ||
"ts-node": "^10.9.1", | ||
"tslib": "^2.5.0", | ||
"tsconfig-paths": "^4.2.0" | ||
} |
13 changes: 13 additions & 0 deletions
13
src/commands/create/templates/plugin/nestjs/_config/scripts.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"build": "nest build", | ||
"start": "nest start", | ||
"start:dev": "nest start --watch", | ||
"start:debug": "nest start --debug --watch", | ||
"start:prod": "node dist/main", | ||
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix", | ||
"test": "jest", | ||
"test:watch": "jest --watch", | ||
"test:cov": "jest --coverage", | ||
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", | ||
"test:e2e": "jest --config ./test/jest-e2e.json" | ||
} |
8 changes: 8 additions & 0 deletions
8
src/commands/create/templates/plugin/nestjs/_content/nest-cli.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"$schema": "https://json.schemastore.org/nest-cli", | ||
"collection": "@nestjs/schematics", | ||
"sourceRoot": "src", | ||
"compilerOptions": { | ||
"deleteOutDir": true | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/commands/create/templates/plugin/nestjs/_content/src/app.controller.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Test, TestingModule } from '@nestjs/testing'; | ||
|
||
import { AppController } from './app.controller'; | ||
import { AppService } from './app.service'; | ||
|
||
describe('AppController', () => { | ||
let appController: AppController; | ||
|
||
beforeEach(async () => { | ||
const app: TestingModule = await Test.createTestingModule({ | ||
controllers: [AppController], | ||
providers: [AppService], | ||
}).compile(); | ||
|
||
appController = app.get<AppController>(AppController); | ||
}); | ||
|
||
describe('root', () => { | ||
it('should return "Hello World!"', () => { | ||
expect(appController.getHello()).toBe('Hello World!'); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.