@appxdigital/appx-core-cli 1.0.7 → 1.0.9

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@appxdigital/appx-core-cli",
4
- "version": "1.0.7",
4
+ "version": "1.0.9",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
7
  "npm:publish": "npm publish --access public",
@@ -5,6 +5,7 @@ const componentLoader = new ComponentLoader();
5
5
 
6
6
  export const AdminConfig: AdminConfigType = {
7
7
  componentLoader,
8
+ adminRoles: ['ADMIN'],
8
9
  resources: [
9
10
  {
10
11
  name: 'User',
package/wizard.js CHANGED
@@ -10,6 +10,7 @@ import { fileURLToPath } from 'url';
10
10
  import cliProgress from 'cli-progress';
11
11
  import { gatherFileUploadSettings, insertFileUploadConfiguration } from './utils/fileUploadConfig.js';
12
12
  import packageJson from './package.json' assert { type: 'json' };
13
+ import crypto from 'crypto';
13
14
 
14
15
  const __filename = fileURLToPath(import.meta.url);
15
16
  const __dirname = path.dirname(__filename);
@@ -24,7 +25,6 @@ const phaseDurations = {
24
25
  installDependencies: 80,
25
26
  installCore: 120,
26
27
  prismaSetup: 10,
27
- adminSetup: 40,
28
28
  setupConcluded: 5,
29
29
  end: 5
30
30
  };
@@ -37,9 +37,6 @@ const calculateTotalETA = (includeBackoffice) => {
37
37
  phaseDurations.prismaSetup +
38
38
  phaseDurations.setupConcluded
39
39
  + phaseDurations.end;
40
- if (includeBackoffice) {
41
- totalTime += phaseDurations.adminSetup;
42
- }
43
40
  return totalTime;
44
41
  };
45
42
 
@@ -151,12 +148,6 @@ async function promptUser() {
151
148
  message: 'Database Name:',
152
149
  default: 'generic'
153
150
  },
154
- {
155
- type: 'confirm',
156
- name: 'backoffice',
157
- message: 'Create backoffice?',
158
- default: true
159
- },
160
151
  {
161
152
  type: 'confirm',
162
153
  name: 'showOutput',
@@ -227,7 +218,7 @@ APP_PORT=3000
227
218
  USE_TRANSACTION=true
228
219
 
229
220
  #Session secret
230
- SESSION_SECRET="${require('crypto').randomBytes(32).toString('hex')}"
221
+ SESSION_SECRET="${crypto.randomBytes(32).toString('hex')}"
231
222
 
232
223
  #Cookie name for the session token
233
224
  SESSION_COOKIE_NAME="APPXCORE"
@@ -236,8 +227,8 @@ SESSION_COOKIE_NAME="APPXCORE"
236
227
  SESSION_TTL=86400
237
228
 
238
229
  # JWT
239
- JWT_SECRET="${require('crypto').randomBytes(32).toString('hex')}"
240
- JWT_REFRESH_SECRET="${require('crypto').randomBytes(32).toString('hex')}"
230
+ JWT_SECRET="${crypto.randomBytes(32).toString('hex')}"
231
+ JWT_REFRESH_SECRET="${crypto.randomBytes(32).toString('hex')}"
241
232
  `;
242
233
 
243
234
  fs.writeFileSync(`${projectPath}/.env`, envContent);
@@ -315,13 +306,8 @@ function setupProjectStructure(projectPath, answers) {
315
306
  incrementProgress(answers?.showOutput, "prismaSetup");
316
307
  createPrismaModule(projectPath);
317
308
  createPermissionsConfig(projectPath);
309
+ createAdminConfig(projectPath);
318
310
  addScriptsToPackageJson(projectPath);
319
-
320
- if (includeBackoffice) {
321
- executeCommand('npm install adminjs @adminjs/express @adminjs/import-export @adminjs/nestjs @adminjs/prisma @prisma/sdk react express-formidable @adminjs/passwords', answers?.showOutput);
322
- setupAdminJS(projectPath);
323
- incrementProgress(answers?.showOutput, "adminSetup");
324
- }
325
311
  }
326
312
 
327
313
  function ensureAndRunNestCli(projectPath, showOutput = false) {
@@ -355,52 +341,6 @@ function getAppModuleTemplate() {
355
341
  return fs.readFileSync(appModuleTemplatePath, 'utf8');
356
342
  }
357
343
 
358
- function setupAdminJS(projectPath) {
359
- const backoffice = path.join(projectPath, 'src/backoffice');
360
- fs.ensureDirSync(backoffice);
361
-
362
- const backofficeComponents = path.join(backoffice, 'components');
363
- fs.ensureDirSync(backofficeComponents);
364
-
365
- const componentLoaderContent = getComponentLoaderTemplate();
366
- fs.writeFileSync(path.join(backoffice, 'component-loader.ts'), componentLoaderContent);
367
-
368
- const dashboardContent = getDashboardTemplate();
369
- fs.writeFileSync(path.join(backofficeComponents, 'dashboard.tsx'), dashboardContent);
370
-
371
- const utilsContent = getUtilsTemplate();
372
- fs.writeFileSync(path.join(backoffice, 'utils.ts'), utilsContent);
373
-
374
- const adminContent = getAdminTemplate();
375
- fs.writeFileSync(path.join(backoffice, 'admin.ts'), adminContent);
376
-
377
- const tsConfigPath = path.join(projectPath, 'tsconfig.json');
378
- const tsConfig = fs.readJsonSync(tsConfigPath);
379
-
380
- tsConfig.compilerOptions.jsx = 'react';
381
- fs.writeJsonSync(tsConfigPath, tsConfig, { spaces: 2 });
382
- }
383
-
384
- function getComponentLoaderTemplate() {
385
- const template = path.join(__dirname, 'templates', 'adminjs', 'component-loader.template.js');
386
- return fs.readFileSync(template, 'utf8');
387
- }
388
-
389
- function getDashboardTemplate() {
390
- const template = path.join(__dirname, 'templates', 'adminjs', 'dashboard.template.js');
391
- return fs.readFileSync(template, 'utf8');
392
- }
393
-
394
- function getUtilsTemplate() {
395
- const template = path.join(__dirname, 'templates', 'adminjs', 'utils.template.js');
396
- return fs.readFileSync(template, 'utf8');
397
- }
398
-
399
- function getAdminTemplate() {
400
- const template = path.join(__dirname, 'templates', 'adminjs', 'admin.template.js');
401
- return fs.readFileSync(template, 'utf8');
402
- }
403
-
404
344
  function createPermissionsConfig(projectPath) {
405
345
  const configDir = path.join(projectPath, 'src/config');
406
346
  fs.ensureDirSync(configDir);