cc-core-cli 1.0.3 → 1.0.5

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/index.js CHANGED
@@ -23,8 +23,8 @@ if (action === 'init') {
23
23
  const project = options['_'][1] || '.'
24
24
  const path = options['_'][2] || '.'
25
25
 
26
- if (!['core', 'admin'].includes(project)) {
27
- console.log('Project should be one of [core|admin]!')
26
+ if (!['core', 'admin', 'module'].includes(project)) {
27
+ console.log('Project should be one of [core|admin|module]!')
28
28
  return false
29
29
  }
30
30
 
@@ -32,15 +32,15 @@ if (action === 'init') {
32
32
  fs.ensureDirSync(path)
33
33
  }
34
34
 
35
- const spinner = ora('(1/2) Copying files!').start();
35
+ const spinner = ora('(1/1) Copying files!').start();
36
36
  fs.copySync(`${__dirname}/../template/${project}`, path)
37
- spinner.succeed('(1/2) Copying files!')
37
+ spinner.succeed('(1/1) Copying files!')
38
38
 
39
39
  if (path !== '.') {
40
40
  process.chdir(path)
41
41
  }
42
42
 
43
- spinner.succeed('(2/2) Ignore run npm install!')
43
+ // spinner.succeed('(2/2) Ignore run npm install!')
44
44
  // spinner.start('(2/2) Running npm install!')
45
45
 
46
46
  // exec('npm install', (err) => {
@@ -54,21 +54,12 @@ if (action === 'init') {
54
54
 
55
55
  if (action === 'upgrade') {
56
56
  const project = options['_'][1] || '.'
57
- if (!['core', 'admin'].includes(project)) {
58
- console.log('Project should be one of [core|admin]!')
57
+ if (!['core', 'admin', 'module'].includes(project)) {
58
+ console.log('Project should be one of [core|admin|module]!')
59
59
  return false
60
60
  }
61
61
 
62
- const spinner = ora('(1/2) Running npm install!').start();
63
- exec('npm install', (err) => {
64
- if (err) {
65
- return spinner.fail('(1/2) Running npm install!')
66
- }
67
-
68
- spinner.succeed('(1/2) Running npm install!')
69
- })
70
-
71
- spinner.start('(2/2) Copying files!')
62
+ spinner.start('(1/2) Copying files!')
72
63
 
73
64
  fs.copySync(`${__dirname}/../template/${project}`, '.', {
74
65
  recursive: true,
@@ -77,7 +68,18 @@ if (action === 'upgrade') {
77
68
  }
78
69
  })
79
70
 
80
- spinner.succeed('(2/2) Copying files!')
71
+ spinner.succeed('(1/2) Copying files!')
72
+
73
+ const spinner = ora('(2/2) Running npm install!').start();
74
+ exec('npm install', (err) => {
75
+ if (err) {
76
+ return spinner.fail('(2/2) Running npm install!')
77
+ }
78
+
79
+ spinner.succeed('(2/2) Running npm install!')
80
+ })
81
+
82
+
81
83
 
82
84
  }
83
85
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cc-core-cli",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "Command Line Interface tool for generating project templates for the (Your Platform's Name) platform.",
5
5
  "main": "bin/index.js",
6
6
  "scripts": {
@@ -14,6 +14,7 @@ import {
14
14
  NestFastifyApplication
15
15
  } from "@nestjs/platform-fastify";
16
16
  import { AppModule } from "./app.module";
17
+ import { StoragePrivateModule, StoragePublicModule } from "./storage.module";
17
18
  import { join } from "path";
18
19
  import { AppClusterService } from "./app_cluster.service";
19
20
  import { CUSTOM_MODULES as LIB_CUSTOM_MODULES } from '@shopstack/cc-core-lib/module'
@@ -292,6 +293,26 @@ async function bootstrap() {
292
293
  await app.listen(parseInt(process.env.PORT, 10), "0.0.0.0");
293
294
  CONST.HEALTH_CHECK = true;
294
295
  CONST.SYSTEM_NAME = process.env.SYSTEM_NAME || _.get(packageData, "name");
296
+
297
+ const storagePublic = await NestFactory.create<NestFastifyApplication>(
298
+ StoragePublicModule,
299
+ new FastifyAdapter()
300
+ );
301
+ if (process.env.SERVE_STATIC === "true") {
302
+ storagePublic.useStaticAssets({
303
+ root: `${process.cwd()}/storage/public`
304
+ });
305
+ }
306
+ await storagePublic.listen(3001, "0.0.0.0");
307
+
308
+ const storagePrivate = await NestFactory.create<NestFastifyApplication>(
309
+ StoragePrivateModule,
310
+ new FastifyAdapter()
311
+ );
312
+ const spReflector = storagePrivate.get(Reflector);
313
+ const spAuth = storagePrivate.get(AuthService);
314
+ storagePrivate.useGlobalGuards(new JWTAuthGuard(spReflector, spAuth));
315
+ await storagePrivate.listen(3002, "0.0.0.0");
295
316
  }
296
317
 
297
318
  AppClusterService.clusterize(bootstrap);
@@ -0,0 +1,103 @@
1
+ import * as _ from "lodash";
2
+ import * as dotenv from "dotenv";
3
+
4
+ import { Controller, Get, Module, Param } from "@nestjs/common";
5
+ import { MongooseModule } from "@nestjs/mongoose";
6
+
7
+ import { ClsModule } from "nestjs-cls";
8
+ import { AttachmentService, AuthModule, AttachmentModule } from "@shopstack/cc-core-lib/core";
9
+
10
+ const mongoConfig = {};
11
+ if (+process.env.MONGODB_MIN_POOL_SIZE) {
12
+ mongoConfig["minPoolSize"] = +process.env.MONGODB_MIN_POOL_SIZE;
13
+ }
14
+ if (+process.env.MONGODB_MAX_POOL_SIZE) {
15
+ mongoConfig["maxPoolSize"] = +process.env.MONGODB_MAX_POOL_SIZE;
16
+ }
17
+
18
+ @Controller()
19
+ export class StoragePrivateController {
20
+ constructor(private readonly attachment: AttachmentService) {}
21
+
22
+ // @Public()
23
+ // @Get("/health_check")
24
+ // healthCheck(): boolean {
25
+ // return this.appService.healthCheck();
26
+ // }
27
+
28
+ // @Public()
29
+ // @Get("/health_check/init")
30
+ // init(): string {
31
+ // return this.appService.init();
32
+ // }
33
+
34
+ @Get("/*")
35
+ getMedia(@Param() params: any): any {
36
+ const filename = params["*"]
37
+ .split("/")
38
+ .slice(-1)
39
+ .toString();
40
+ const path = params["*"].replace(`/${filename}`, "");
41
+
42
+ return this.attachment.downloadStream(path, filename);
43
+ }
44
+ }
45
+
46
+ @Module({
47
+ imports: [
48
+ MongooseModule.forRoot(process.env.MONGODB_URI, mongoConfig),
49
+ ClsModule.forRoot({
50
+ middleware: {
51
+ // automatically mount the
52
+ // ClsMiddleware for all routes
53
+ mount: true,
54
+ // and use the setup method to
55
+ // provide default store values.
56
+ setup: (cls, req) => {
57
+ cls.set("request", {
58
+ api_key: _.get(req, "api_key", {}),
59
+ profile: _.get(req, "profile", {}),
60
+ permissions: _.get(req, "permissions", []),
61
+ headers: _.get(req, "headers", {}),
62
+ ip: _.get(req, "ip"),
63
+ hostname: _.get(req, "hostname"),
64
+ body: _.get(req, "body", {}),
65
+ action_profile: _.get(req, "action_profile", {})
66
+ });
67
+ }
68
+ },
69
+ interceptor: {
70
+ mount: true,
71
+ setup: (cls, ctx) => {
72
+ const req = ctx.switchToHttp().getRequest();
73
+ cls.set("request", {
74
+ api_key: _.get(req, "api_key", {}),
75
+ profile: _.get(req, "profile", {}),
76
+ permissions: _.get(req, "permissions", []),
77
+ roles: _.get(req, "roles", []),
78
+ headers: _.get(req, "headers", {}),
79
+ // ip: req.connection.remoteAddress,
80
+ ip:
81
+ _.get(req, "socket.remoteAddress") ||
82
+ _.get(req, "connection.remoteAddress"),
83
+ hostname: req.hostname,
84
+ body: _.get(req, "body", {}),
85
+ action_profile: _.get(req, "action_profile", {})
86
+ });
87
+ }
88
+ }
89
+ }),
90
+ AuthModule,
91
+ AttachmentModule
92
+ ],
93
+ controllers: [StoragePrivateController],
94
+ providers: []
95
+ })
96
+ export class StoragePrivateModule {}
97
+
98
+ @Module({
99
+ imports: [],
100
+ controllers: [],
101
+ providers: []
102
+ })
103
+ export class StoragePublicModule {}
@@ -0,0 +1 @@
1
+ <svg id="Layer_1" enable-background="new 0 0 48 48" height="512" viewBox="0 0 48 48" width="512" xmlns="http://www.w3.org/2000/svg"><g><g><path d="m24 47.5c-2.3 0-4.4-.9-6-2.5-1.2-1.2-2.9-1.9-4.6-1.9-4.7 0-8.5-3.8-8.5-8.5 0-1.7-.7-3.4-1.9-4.6-3.3-3.3-3.3-8.7 0-12 1.2-1.2 1.9-2.9 1.9-4.6 0-4.7 3.8-8.5 8.5-8.5 1.7 0 3.4-.7 4.6-1.9 1.6-1.6 3.7-2.5 6-2.5s4.4.9 6 2.5c1.2 1.2 2.9 1.9 4.6 1.9 4.7 0 8.5 3.8 8.5 8.5 0 1.7.7 3.4 1.9 4.6 3.3 3.3 3.3 8.7 0 12-1.2 1.2-1.9 2.9-1.9 4.6 0 4.7-3.8 8.5-8.5 8.5-1.7 0-3.4.7-4.6 1.9-1.6 1.6-3.7 2.5-6 2.5zm0-45c-1.7 0-3.4.7-4.6 1.9-1.6 1.6-3.7 2.5-6 2.5-3.6 0-6.5 2.9-6.5 6.5 0 2.3-.9 4.4-2.5 6-2.5 2.5-2.5 6.7 0 9.2 1.6 1.6 2.5 3.7 2.5 6 0 3.6 2.9 6.5 6.5 6.5 2.3 0 4.4.9 6 2.5 1.2 1.2 2.9 1.9 4.6 1.9 1.7 0 3.4-.7 4.6-1.9 1.6-1.6 3.7-2.5 6-2.5 3.6 0 6.5-2.9 6.5-6.5 0-2.3.9-4.4 2.5-6 2.5-2.5 2.5-6.7 0-9.2-1.6-1.6-2.5-3.7-2.5-6 0-3.6-2.9-6.5-6.5-6.5-2.3 0-4.4-.9-6-2.5-1.2-1.2-2.9-1.9-4.6-1.9z" fill="rgb(0,0,0)"/></g><g><g><path d="m11.4 33.8-3.4-9.1 1.8-.7 6 4.8-2.2-6.1 1.7-.6 3.3 9.2-1.9.7-5.9-4.6 2.2 6z" fill="rgb(0,0,0)"/></g><g><path d="m20.6 30.5-3.3-9.2 6.8-2.5.6 1.5-4.9 1.8.7 2 4.6-1.7.6 1.5-4.7 1.9.9 2.5 5.1-1.9.6 1.5z" fill="rgb(0,0,0)"/></g><g><path d="m30.4 26.9-5.5-8.4 1.9-.7 3.7 5.8-.6-6.9 2.2-.8 3.9 5.8-1-6.9 1.9-.7 1.1 10-2 .7-4.3-6.2.7 7.5z" fill="rgb(0,0,0)"/></g></g></g></svg>
@@ -0,0 +1,65 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
+ <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
4
+ viewBox="0 0 512 512" style="enable-background:new 0 0 512 512;" xml:space="preserve">
5
+ <g>
6
+ <g>
7
+ <g>
8
+ <path d="M496.659,312.128l-47.061-36.8c0.619-5.675,1.109-12.309,1.109-19.328s-0.512-13.653-1.109-19.328l47.104-36.821
9
+ c8.747-6.912,11.157-19.179,5.568-29.397l-48.939-84.672c-5.355-9.749-17.365-14.208-28.309-10.176l-55.531,22.293
10
+ c-10.624-7.68-21.781-14.165-33.323-19.349l-8.448-58.901C326.334,8.448,316.606,0,305.107,0h-98.133
11
+ c-11.499,0-21.227,8.448-22.592,19.435l-8.469,59.115c-11.179,5.056-22.165,11.435-33.28,19.371l-55.68-22.357
12
+ c-10.645-4.16-22.763,0.235-28.096,10.005l-49.003,84.8c-5.781,9.771-3.413,22.443,5.547,29.525l47.061,36.779
13
+ c-0.747,7.211-1.109,13.461-1.109,19.328s0.363,12.117,1.067,19.328l-47.104,36.843C6.59,319.083,4.2,331.349,9.768,341.568
14
+ l48.939,84.672c5.312,9.728,17.301,14.165,28.309,10.176l55.531-22.293c10.624,7.659,21.803,14.144,33.344,19.349l8.448,58.88
15
+ c1.387,11.2,11.115,19.648,22.613,19.648h98.133c11.499,0,21.227-8.448,22.592-19.435l8.469-59.093
16
+ c11.179-5.056,22.165-11.435,33.28-19.371l55.68,22.357c10.603,4.117,22.763-0.235,28.096-10.005l49.195-85.099
17
+ C507.838,331.371,505.448,319.104,496.659,312.128z M483.752,330.901l-50.816,85.717l-61.077-24.533
18
+ c-3.456-1.387-7.381-0.853-10.368,1.365c-13.227,9.899-26.005,17.344-39.104,22.699c-3.499,1.429-5.995,4.608-6.528,8.363
19
+ l-10.773,66.155l-99.563-1.131l-9.323-65.003c-0.555-3.755-3.029-6.933-6.528-8.363c-13.632-5.589-26.752-13.205-39.019-22.635
20
+ c-1.899-1.472-4.203-2.219-6.507-2.219c-1.344,0-2.688,0.235-3.989,0.768l-62.827,23.701l-48.939-84.672
21
+ c-0.448-0.832-0.363-1.792,0.149-2.197l51.776-40.469c2.944-2.304,4.48-6.016,4.011-9.728c-1.131-8.939-1.643-16.171-1.643-22.72
22
+ s0.533-13.76,1.643-22.72c0.469-3.733-1.067-7.424-4.011-9.728L28.286,181.12l50.816-85.717l61.077,24.533
23
+ c3.477,1.408,7.381,0.875,10.389-1.365c13.205-9.92,26.005-17.344,39.104-22.699c3.499-1.451,5.973-4.629,6.507-8.363
24
+ l10.795-66.176l99.584,1.152l9.301,65.024c0.555,3.755,3.029,6.933,6.528,8.363c13.611,5.568,26.731,13.184,39.019,22.635
25
+ c3.008,2.304,6.955,2.859,10.475,1.429l62.827-23.701l48.939,84.672c0.448,0.832,0.363,1.771-0.149,2.176l-51.776,40.469
26
+ c-2.944,2.304-4.48,5.995-4.011,9.728c0.811,6.485,1.643,14.272,1.643,22.72c0,8.469-0.832,16.235-1.643,22.72
27
+ c-0.469,3.712,1.067,7.424,4.011,9.728l51.712,40.448C483.987,329.344,484.094,330.304,483.752,330.901z"/>
28
+ <path d="M256.019,149.333c-58.816,0-106.667,47.851-106.667,106.667s47.851,106.667,106.667,106.667
29
+ c58.816,0,106.667-47.851,106.667-106.667S314.835,149.333,256.019,149.333z M256.019,341.333
30
+ c-47.061,0-85.333-38.272-85.333-85.333s38.272-85.333,85.333-85.333c47.061,0,85.333,38.272,85.333,85.333
31
+ S303.08,341.333,256.019,341.333z"/>
32
+ </g>
33
+ </g>
34
+ </g>
35
+ <g>
36
+ </g>
37
+ <g>
38
+ </g>
39
+ <g>
40
+ </g>
41
+ <g>
42
+ </g>
43
+ <g>
44
+ </g>
45
+ <g>
46
+ </g>
47
+ <g>
48
+ </g>
49
+ <g>
50
+ </g>
51
+ <g>
52
+ </g>
53
+ <g>
54
+ </g>
55
+ <g>
56
+ </g>
57
+ <g>
58
+ </g>
59
+ <g>
60
+ </g>
61
+ <g>
62
+ </g>
63
+ <g>
64
+ </g>
65
+ </svg>
@@ -0,0 +1,12 @@
1
+ [
2
+ {
3
+ "name": "Settings",
4
+ "description": "",
5
+ "icon": "/demo/setting.svg",
6
+ "module": "demo",
7
+ "permission_key": "setting",
8
+ "layout": "setting",
9
+ "form_filters": [],
10
+ "restrict_roles": []
11
+ }
12
+ ]
@@ -0,0 +1,25 @@
1
+ {
2
+ "type": "column",
3
+ "layout": {
4
+ "num_of_col": 6,
5
+ "fields": [
6
+ [
7
+ {
8
+ "field": "switch",
9
+ "type": "standard_component",
10
+ "key": "manage_setting",
11
+ "label": "Manage Settings",
12
+ "default_value": false,
13
+ "link_type": "key",
14
+ "yes_label": "Yes",
15
+ "no_label": "No"
16
+ }
17
+ ],
18
+ [],
19
+ [],
20
+ [],
21
+ [],
22
+ []
23
+ ]
24
+ }
25
+ }
@@ -0,0 +1,36 @@
1
+ {
2
+ "detail": {
3
+ "title": {
4
+ "format": "Module Settings"
5
+ },
6
+ "blocks": [],
7
+ "is_popup": false,
8
+ "redirect_mode": "not_redirect"
9
+ },
10
+ "list": {
11
+ "allow_search": false,
12
+ "allow_sort": false,
13
+ "allow_filter": false,
14
+ "allow_bulk": false,
15
+ "entries_per_page": 10,
16
+ "default_sort": "_translates",
17
+ "columns": []
18
+ },
19
+ "name": "Setting",
20
+ "code": "setting",
21
+ "type": [
22
+ "form"
23
+ ],
24
+ "allow_actions": [
25
+ {
26
+ "action": "create",
27
+ "role_restrictions": []
28
+ },
29
+ {
30
+ "action": "update",
31
+ "role_restrictions": []
32
+ }
33
+ ],
34
+ "restriction": [],
35
+ "allow_workflow_actions": false
36
+ }
@@ -0,0 +1,19 @@
1
+ import * as _ from "lodash";
2
+ import * as moduleConfig from "./module.json";
3
+
4
+ import { Module } from "@nestjs/common";
5
+ import { EntitiesModule, SettingModule } from "@shopstack/cc-core-lib/core";
6
+ import { ClsModule } from "nestjs-cls";
7
+
8
+ const { code } = moduleConfig;
9
+
10
+ @Module({
11
+ imports: [
12
+ ClsModule,
13
+ EntitiesModule,
14
+ SettingModule,
15
+ ],
16
+ controllers: [],
17
+ providers: [],
18
+ })
19
+ export class DemoModule {}
@@ -0,0 +1,7 @@
1
+ {
2
+ "name": "Demo Project",
3
+ "description": "",
4
+ "code": "demo",
5
+ "icon": "icon.svg",
6
+ "version": "1.0.0"
7
+ }