alexis-cli 1.0.0 → 1.0.2
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/bin/cli/entity-types.js +8 -0
- package/commands/make-auth.js +14 -6
- package/commands/make-entity.js +1 -1
- package/package.json +2 -2
package/commands/make-auth.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
|
+
const projectRoot = process.cwd();
|
|
4
|
+
const srcDir = path.join(projectRoot, 'src');
|
|
3
5
|
|
|
4
6
|
module.exports = () => {
|
|
5
7
|
console.log('🔐 Generating Auth system...');
|
|
@@ -8,7 +10,7 @@ module.exports = () => {
|
|
|
8
10
|
1. USER ENTITY
|
|
9
11
|
========================= */
|
|
10
12
|
|
|
11
|
-
const entityDir = path.join(
|
|
13
|
+
const entityDir = path.join(srcDir, 'entities');
|
|
12
14
|
const userEntityPath = path.join(entityDir, 'User.entity.js');
|
|
13
15
|
|
|
14
16
|
if (!fs.existsSync(entityDir)) {
|
|
@@ -41,7 +43,7 @@ module.exports = new EntitySchema({
|
|
|
41
43
|
2. AUTH MODULE
|
|
42
44
|
========================= */
|
|
43
45
|
|
|
44
|
-
const authDir = path.join(
|
|
46
|
+
const authDir = path.join(srcDir, 'modules/v1/auth');
|
|
45
47
|
|
|
46
48
|
if (!fs.existsSync(authDir)) {
|
|
47
49
|
fs.mkdirSync(authDir, { recursive: true });
|
|
@@ -216,7 +218,7 @@ module.exports = router;
|
|
|
216
218
|
3. AUTH MIDDLEWARE
|
|
217
219
|
========================= */
|
|
218
220
|
|
|
219
|
-
const middlewareDir = path.join(
|
|
221
|
+
const middlewareDir = path.join(srcDir, 'middlewares');
|
|
220
222
|
const middlewarePath = path.join(middlewareDir, 'auth.middleware.js');
|
|
221
223
|
|
|
222
224
|
if (!fs.existsSync(middlewareDir)) {
|
|
@@ -250,7 +252,13 @@ module.exports = (req, res, next) => {
|
|
|
250
252
|
4. JWT CONFIG
|
|
251
253
|
========================= */
|
|
252
254
|
|
|
253
|
-
const
|
|
255
|
+
const configDir = path.join(srcDir, 'config');
|
|
256
|
+
|
|
257
|
+
if (!fs.existsSync(configDir)) {
|
|
258
|
+
fs.mkdirSync(configDir, { recursive: true });
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
const jwtConfigPath = path.join(configDir, 'jwt.js');
|
|
254
262
|
|
|
255
263
|
if (!fs.existsSync(jwtConfigPath)) {
|
|
256
264
|
fs.writeFileSync(
|
|
@@ -274,8 +282,8 @@ module.exports = (req, res, next) => {
|
|
|
274
282
|
========================= */
|
|
275
283
|
|
|
276
284
|
const routesIndexPath = path.join(
|
|
277
|
-
|
|
278
|
-
'
|
|
285
|
+
srcDir,
|
|
286
|
+
'routes/v1/index.js'
|
|
279
287
|
);
|
|
280
288
|
|
|
281
289
|
if (!fs.existsSync(routesIndexPath)) {
|
package/commands/make-entity.js
CHANGED
package/package.json
CHANGED