@appxdigital/appx-core-cli 1.0.12 → 1.0.13
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/{wizard.js → cli.js} +23 -20
- package/package.json +2 -2
- package/scaffold/src/app.module.ts +4 -4
- package/scaffold/src/backoffice/components/dashboard.js +0 -2
- package/scaffold/src/config/permissions.config.ts +1 -4
- package/scaffold/src/main.ts +6 -7
- package/scaffold/src/prisma/prisma.module.ts +3 -3
- package/utils/fileUploadConfig.js +11 -11
package/{wizard.js → cli.js}
RENAMED
|
@@ -44,12 +44,12 @@ const calculateTotalETA = () => {
|
|
|
44
44
|
};
|
|
45
45
|
|
|
46
46
|
const logo = `\x1b[36m
|
|
47
|
-
_ _______ _______ ____ ____
|
|
48
|
-
/ \\ |_ __ \\|_ __ \\|_ _||_ _|
|
|
49
|
-
/ _ \\ | |__) | | |__) | \\ \\ / /
|
|
50
|
-
/ ___ \\ | ___/ | ___/ > \`' <
|
|
51
|
-
_/ / \\ \\_ _| |_ _| |_ _/ /'\\ \\_
|
|
52
|
-
|____| |____||_____| |_____| |____||____|
|
|
47
|
+
_ _______ _______ ____ ____
|
|
48
|
+
/ \\ |_ __ \\|_ __ \\|_ _||_ _|
|
|
49
|
+
/ _ \\ | |__) | | |__) | \\ \\ / /
|
|
50
|
+
/ ___ \\ | ___/ | ___/ > \`' <
|
|
51
|
+
_/ / \\ \\_ _| |_ _| |_ _/ /'\\ \\_
|
|
52
|
+
|____| |____||_____| |_____| |____||____|
|
|
53
53
|
\x1b[0m
|
|
54
54
|
CLI Version: ${packageJson.version}
|
|
55
55
|
`;
|
|
@@ -66,7 +66,7 @@ program
|
|
|
66
66
|
promptUser();
|
|
67
67
|
});
|
|
68
68
|
|
|
69
|
-
function coreGenerate
|
|
69
|
+
function coreGenerate(showOutput) {
|
|
70
70
|
// run file inside node_modules/appx-core/dist/config/generate-all.js
|
|
71
71
|
const generatePath = path.join(process.cwd(), 'node_modules', '@appxdigital/appx-core', 'dist', 'config', 'generate-all.js');
|
|
72
72
|
if (!fsCore.existsSync(generatePath)) {
|
|
@@ -108,7 +108,7 @@ program.command('setup:fileupload')
|
|
|
108
108
|
}
|
|
109
109
|
});
|
|
110
110
|
|
|
111
|
-
async function checkDb
|
|
111
|
+
async function checkDb(config) {
|
|
112
112
|
const {dbProvider, dbHost, dbPort, dbUser, dbPassword, dbName} = config;
|
|
113
113
|
|
|
114
114
|
if (dbProvider === "mysql") {
|
|
@@ -206,7 +206,7 @@ async function checkDb (config) {
|
|
|
206
206
|
return {ok: false, reason: "Unsupported dbProvider."};
|
|
207
207
|
}
|
|
208
208
|
|
|
209
|
-
async function promptDbConfig
|
|
209
|
+
async function promptDbConfig() {
|
|
210
210
|
return inquirer.prompt([
|
|
211
211
|
{
|
|
212
212
|
type: "list",
|
|
@@ -249,7 +249,7 @@ async function promptDbConfig () {
|
|
|
249
249
|
]);
|
|
250
250
|
}
|
|
251
251
|
|
|
252
|
-
async function promptDbUntilValid
|
|
252
|
+
async function promptDbUntilValid() {
|
|
253
253
|
while (true) {
|
|
254
254
|
const dbConfig = await promptDbConfig();
|
|
255
255
|
|
|
@@ -280,7 +280,7 @@ async function promptDbUntilValid () {
|
|
|
280
280
|
}
|
|
281
281
|
}
|
|
282
282
|
|
|
283
|
-
async function promptUser
|
|
283
|
+
async function promptUser() {
|
|
284
284
|
let fileUploadConfigData = {};
|
|
285
285
|
try {
|
|
286
286
|
const baseAnswers = await inquirer.prompt([
|
|
@@ -322,7 +322,7 @@ async function promptUser () {
|
|
|
322
322
|
}
|
|
323
323
|
}
|
|
324
324
|
|
|
325
|
-
async function createProject
|
|
325
|
+
async function createProject(answers, fileUploadConfigData) {
|
|
326
326
|
const {projectName, showOutput, backoffice} = answers;
|
|
327
327
|
|
|
328
328
|
console.log(`Creating project: ${projectName}`);
|
|
@@ -442,7 +442,7 @@ async function createProject (answers, fileUploadConfigData) {
|
|
|
442
442
|
}
|
|
443
443
|
}
|
|
444
444
|
|
|
445
|
-
function createPackageJson
|
|
445
|
+
function createPackageJson(projectPath, projectName) {
|
|
446
446
|
const packageJsonContent = {
|
|
447
447
|
name: projectName,
|
|
448
448
|
version: "0.0.1",
|
|
@@ -464,17 +464,20 @@ function createPackageJson (projectPath, projectName) {
|
|
|
464
464
|
devDependencies: {
|
|
465
465
|
"@nestjs/cli": "~11.0.0",
|
|
466
466
|
"cross-env": "~10.1.0",
|
|
467
|
+
},
|
|
468
|
+
engines: {
|
|
469
|
+
"node": ">=20.0.0"
|
|
467
470
|
}
|
|
468
471
|
};
|
|
469
472
|
|
|
470
473
|
fs.writeJsonSync(path.join(projectPath, 'package.json'), packageJsonContent, {spaces: 2});
|
|
471
474
|
}
|
|
472
475
|
|
|
473
|
-
function setupProjectStructure
|
|
476
|
+
function setupProjectStructure(projectPath, project_config) {
|
|
474
477
|
// Create scaffold files from scaffold directory recursively, replacing placeholders from *.template files
|
|
475
478
|
const scaffoldDir = path.join(__dirname, 'scaffold');
|
|
476
479
|
|
|
477
|
-
function copyAndReplaceTemplates
|
|
480
|
+
function copyAndReplaceTemplates(srcDir, destDir) {
|
|
478
481
|
fs.readdirSync(srcDir).forEach((item) => {
|
|
479
482
|
const srcPath = path.join(srcDir, item);
|
|
480
483
|
let destPath = path.join(destDir, item.replace('.template', ''));
|
|
@@ -498,7 +501,7 @@ function setupProjectStructure (projectPath, project_config) {
|
|
|
498
501
|
copyAndReplaceTemplates(scaffoldDir, projectPath);
|
|
499
502
|
}
|
|
500
503
|
|
|
501
|
-
function initializeGitRepo
|
|
504
|
+
function initializeGitRepo(projectPath, showOutput = false) {
|
|
502
505
|
// If git is installed in the system, initialize a git repository and make the initial commit
|
|
503
506
|
let installed = true;
|
|
504
507
|
try {
|
|
@@ -518,7 +521,7 @@ function initializeGitRepo (projectPath, showOutput = false) {
|
|
|
518
521
|
}
|
|
519
522
|
}
|
|
520
523
|
|
|
521
|
-
async function createGitignore
|
|
524
|
+
async function createGitignore(projectPath) {
|
|
522
525
|
const envFilesToAdd = ['.env', '.env.production'];
|
|
523
526
|
|
|
524
527
|
const {defaultGitIgnore} = await import(path.join(projectPath, 'node_modules', '@nestjs/cli/lib/configuration/defaults.js'));
|
|
@@ -535,7 +538,7 @@ async function createGitignore (projectPath) {
|
|
|
535
538
|
fs.writeFileSync(gitignorePath, finalContent, 'utf-8');
|
|
536
539
|
}
|
|
537
540
|
|
|
538
|
-
function createTsConfig
|
|
541
|
+
function createTsConfig(projectPath) {
|
|
539
542
|
let tsConfig = fs.readFileSync(path.join(projectPath, 'node_modules/@nestjs/schematics/dist/lib/application/files/ts/tsconfig.json'), 'utf-8');
|
|
540
543
|
// Replace '<%= strict %>' with 'false'
|
|
541
544
|
tsConfig = tsConfig.replaceAll("<%= strict %>", 'false');
|
|
@@ -555,14 +558,14 @@ function createTsConfig (projectPath) {
|
|
|
555
558
|
}
|
|
556
559
|
|
|
557
560
|
|
|
558
|
-
function incrementProgress
|
|
561
|
+
function incrementProgress(showOutput, phase) {
|
|
559
562
|
if (!showOutput) {
|
|
560
563
|
remainingETA -= phaseDurations[phase];
|
|
561
564
|
progressBar.update(progressBar.value + phase === 'end' ? 0 : 1, {remainingETA});
|
|
562
565
|
}
|
|
563
566
|
}
|
|
564
567
|
|
|
565
|
-
function executeCommand
|
|
568
|
+
function executeCommand(command, showOutput = answers?.showOutput) {
|
|
566
569
|
const options = showOutput ? {stdio: 'inherit'} : {stdio: 'ignore'};
|
|
567
570
|
try {
|
|
568
571
|
execSync(command, options);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@appxdigital/appx-core-cli",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.13",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"npm:publish": "npm publish --access public",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"author": "",
|
|
12
12
|
"license": "ISC",
|
|
13
13
|
"bin": {
|
|
14
|
-
"appx-core": "./
|
|
14
|
+
"appx-core": "./cli.js"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@inquirer/prompts": "^7.0.0",
|
|
@@ -2,9 +2,9 @@ import {MiddlewareConsumer, Module, NestModule, RequestMethod} from '@nestjs/com
|
|
|
2
2
|
import {AppController} from './app.controller';
|
|
3
3
|
import {AppService} from './app.service';
|
|
4
4
|
import {ConfigModule} from '@nestjs/config';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
5
|
+
import {AppxCoreAdminModule, AppxCoreModule, AuthModule, PrismaInterceptor, UserPopulationGuard} from '@appxdigital/appx-core';
|
|
6
|
+
import {APP_GUARD, APP_INTERCEPTOR} from '@nestjs/core';
|
|
7
|
+
import {RequestContextMiddleware, RequestContextModule} from 'nestjs-request-context'
|
|
8
8
|
import {PermissionsConfig} from './config/permissions.config';
|
|
9
9
|
import {AdminConfig} from './config/admin.config';
|
|
10
10
|
|
|
@@ -35,7 +35,7 @@ import {AdminConfig} from './config/admin.config';
|
|
|
35
35
|
],
|
|
36
36
|
})
|
|
37
37
|
export class AppModule implements NestModule {
|
|
38
|
-
configure
|
|
38
|
+
configure(consumer: MiddlewareConsumer) {
|
|
39
39
|
consumer
|
|
40
40
|
.apply(RequestContextMiddleware)
|
|
41
41
|
.forRoutes({path: '*', method: RequestMethod.ALL});
|
package/scaffold/src/main.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import {NestFactory} from '@nestjs/core';
|
|
2
|
+
import {AppModule} from './app.module';
|
|
3
|
+
import {ConfigService} from '@nestjs/config';
|
|
4
4
|
import session from 'express-session';
|
|
5
5
|
import passport from 'passport';
|
|
6
|
-
import {PrismaService} from '@appxdigital/appx-core';
|
|
7
|
-
import {
|
|
8
|
-
import {CorePrismaSessionStore} from '@appxdigital/appx-core';
|
|
6
|
+
import {CorePrismaSessionStore, PrismaService} from '@appxdigital/appx-core';
|
|
7
|
+
import {ValidationPipe} from '@nestjs/common';
|
|
9
8
|
import morgan from 'morgan';
|
|
10
9
|
|
|
11
10
|
async function bootstrap() {
|
|
@@ -41,7 +40,7 @@ async function bootstrap() {
|
|
|
41
40
|
origin: 'http://localhost:3000',
|
|
42
41
|
credentials: true,
|
|
43
42
|
});
|
|
44
|
-
app.useGlobalPipes(new ValidationPipe({
|
|
43
|
+
app.useGlobalPipes(new ValidationPipe({transform: true}));
|
|
45
44
|
await app.listen(port);
|
|
46
45
|
console.log(`Your application is successfully running on: http://www.localhost:${port} 🚀`);
|
|
47
46
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import {Global, Module} from '@nestjs/common';
|
|
2
|
+
import {PrismaClient} from '@prisma/client';
|
|
3
3
|
import {PERMISSIONS_CONFIG_TOKEN, PermissionsConfigType, PrismaService} from '@appxdigital/appx-core';
|
|
4
|
-
import {
|
|
4
|
+
import {PermissionsConfig} from '../config/permissions.config';
|
|
5
5
|
|
|
6
6
|
@Global()
|
|
7
7
|
@Module({
|
|
@@ -35,7 +35,7 @@ function getEnvVariables(provider, providerOptions) {
|
|
|
35
35
|
export async function gatherFileUploadSettings() {
|
|
36
36
|
const config = {};
|
|
37
37
|
|
|
38
|
-
const {
|
|
38
|
+
const {provider} = await inquirer.prompt([
|
|
39
39
|
{
|
|
40
40
|
type: 'list',
|
|
41
41
|
name: 'provider',
|
|
@@ -47,20 +47,20 @@ export async function gatherFileUploadSettings() {
|
|
|
47
47
|
|
|
48
48
|
if (provider === 'aws') {
|
|
49
49
|
config.providerOptions = await inquirer.prompt([
|
|
50
|
-
{
|
|
51
|
-
{
|
|
52
|
-
{
|
|
53
|
-
{
|
|
50
|
+
{type: 'input', name: 'bucket', message: 'Enter AWS S3 bucket name:'},
|
|
51
|
+
{type: 'input', name: 'region', message: 'Enter AWS region:'},
|
|
52
|
+
{type: 'input', name: 'accessKeyId', message: 'Enter AWS access key ID:'},
|
|
53
|
+
{type: 'input', name: 'secretAccessKey', message: 'Enter AWS secret access key:'},
|
|
54
54
|
]);
|
|
55
55
|
} else if (provider === 'gcp') {
|
|
56
56
|
config.providerOptions = await inquirer.prompt([
|
|
57
|
-
{
|
|
58
|
-
{
|
|
59
|
-
{
|
|
57
|
+
{type: 'input', name: 'bucket', message: 'Enter GCP bucket name:'},
|
|
58
|
+
{type: 'input', name: 'projectId', message: 'Enter GCP project ID:'},
|
|
59
|
+
{type: 'input', name: 'keyFilePath', message: 'Enter the path to the GCP service account key file:'},
|
|
60
60
|
]);
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
const {
|
|
63
|
+
const {endpoint, maxSize, fileType, multiple} = await inquirer.prompt([
|
|
64
64
|
{
|
|
65
65
|
type: 'input',
|
|
66
66
|
name: 'endpoint',
|
|
@@ -96,7 +96,7 @@ export async function gatherFileUploadSettings() {
|
|
|
96
96
|
config.multiple = multiple;
|
|
97
97
|
|
|
98
98
|
if (fileType in MimeTypes) {
|
|
99
|
-
const {
|
|
99
|
+
const {selectedMimeTypes} = await inquirer.prompt([
|
|
100
100
|
{
|
|
101
101
|
type: 'checkbox',
|
|
102
102
|
name: 'selectedMimeTypes',
|
|
@@ -108,7 +108,7 @@ export async function gatherFileUploadSettings() {
|
|
|
108
108
|
config.allowedTypes = selectedMimeTypes;
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
const {
|
|
111
|
+
const {roles} = await inquirer.prompt([
|
|
112
112
|
{
|
|
113
113
|
type: 'input',
|
|
114
114
|
name: 'roles',
|