@craftnotion/init-project
Version:
A CLI tool to initialize a new project with AdonisJS, NextJS, NestJS, React Native, Strapi, TypeScript, Husky, Git-CZ and more.
66 lines (65 loc) • 2.4 kB
JavaScript
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const inquirer_1 = __importDefault(require("inquirer"));
const base_1 = require("../base");
const functions_1 = require("../../functions");
class Nextjs extends base_1.Base {
static supportedPackageManagers = ['npm', 'yarn', 'pnpm'];
node = '18.18.0';
/**
* Base command for adonisjs
*/
constructor(data) {
let { packageManager = 'npm', projectName } = data;
super(`npm init next-app@latest ${projectName} --use-${packageManager}`);
}
async handle() {
const useTypeScript = await (0, functions_1.askUseTypeScript)();
const data = await inquirer_1.default.prompt([
{
type: 'confirm',
name: 'tailwind',
message: 'Initialize with Tailwind CSS config. (default)',
default: false,
},
{
type: 'confirm',
name: 'eslint',
message: 'Enable/disable eslint setup:',
default: true,
},
{
type: 'confirm',
name: 'app',
message: 'Initialize as an App Router project.',
default: true,
},
{
type: 'confirm',
name: 'src-dir',
message: 'Initialize inside a `src/` directory',
default: true,
},
]);
//Nextjs does not use boolean. So we have to do this
let options = [];
Object.keys(data).map((key) => {
options.push(data[key] ? key : `no-${key}`);
});
options.push(useTypeScript ? 'ts' : 'js');
this.updateCommand('alias', options);
let { alias } = await inquirer_1.default.prompt({
type: 'input',
name: 'alias',
message: 'What import alias would you like configured? (default @/*)',
default: '@/*',
validate: (value) => /.+\/\*/.test(value) ? true : 'Import alias must follow the pattern <prefix>/*',
});
this.updateCommand('alias', { 'import-alias': alias || '@/*' });
await this.scaffold();
}
}
exports.default = Nextjs;
;