cc-core-cli 1.0.133 → 1.0.136
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 +4 -4
- package/package.json +1 -1
- package/template/admin_v3/src/pages/api/database/[type]/index.ts +23 -0
- package/template/admin_v3/src/pages/api/layout_chart_widget/[name]/index.ts +18 -0
- package/template/admin_v3/src/pages/api/layout_chart_widget/compare_matrix.ts +17 -0
- package/template/admin_v3/src/pages/api/redis/[type]/[connect]/index.ts +20 -0
- package/template/admin_v3/src/pages/api/redis/custom.ts +10 -0
- package/template/admin_v3/src/pages/api/setting/module/[code].ts +34 -0
- package/template/admin_v3/src/pages/api/template/[type].ts +21 -0
- package/template/admin_v3/src/pages/api/template/bulk_print/[id].ts +15 -0
- package/template/admin_v3/src/pages/api/template/print/[id]/[doc_ref].ts +11 -0
- package/template/core/src/main.ts +4 -1
- package/template/core_v3/Dockerfile +60 -0
- package/template/core_v3/_env +12 -0
- package/template/core_v3/_gitignore +52 -0
- package/template/core_v3/_npmrc +1 -0
- package/template/core_v3/buildspec.yml +29 -0
- package/template/core_v3/docker-compose.yml +11 -0
- package/template/core_v3/jest.config.js +43 -0
- package/template/core_v3/newrelic.sh +15 -0
- package/template/core_v3/package.json +54 -0
- package/template/core_v3/post-install.js +34 -0
- package/template/core_v3/sonar-project.properties +27 -0
- package/template/core_v3/src/app.controller.ts +39 -0
- package/template/core_v3/src/app.module.ts +174 -0
- package/template/core_v3/src/app.service.ts +21 -0
- package/template/core_v3/src/app_cluster.service.ts +61 -0
- package/template/core_v3/src/core/core.controller.ts +444 -0
- package/template/core_v3/src/core/core.module.ts +90 -0
- package/template/core_v3/src/core/core.service.ts +737 -0
- package/template/core_v3/src/core/setting/_settings/about.layout.json +105 -0
- package/template/core_v3/src/core/setting/_settings/cache.layout.json +309 -0
- package/template/core_v3/src/core/setting/_settings/global_login.json +299 -0
- package/template/core_v3/src/core/setting/_settings/header_footer.json +83 -0
- package/template/core_v3/src/core/setting/_settings/import_export.layout.json +69 -0
- package/template/core_v3/src/core/setting/_settings/list_detail.json +685 -0
- package/template/core_v3/src/core/setting/_settings/logs.layout.json +39 -0
- package/template/core_v3/src/core/setting/_settings/queue.layout.json +63 -0
- package/template/core_v3/src/core/setting/_settings/schedule.layout.json +132 -0
- package/template/core_v3/src/core/setting/_settings/security.layout.json +1110 -0
- package/template/core_v3/src/core/setting/_settings/storage.layout.json +158 -0
- package/template/core_v3/src/core/setting/_settings/swagger.layout.json +128 -0
- package/template/core_v3/src/core/setting/_settings/toast.json +344 -0
- package/template/core_v3/src/main.ts +308 -0
- package/template/core_v3/src/modules/modules.ts +16 -0
- package/template/core_v3/src/private.controller.ts +18 -0
- package/template/core_v3/storage/documents/index.html +14 -0
- package/template/core_v3/storage/public/system/menu/icons/company.svg +1 -0
- package/template/core_v3/storage/public/system/menu/icons/deploy.svg +2 -0
- package/template/core_v3/storage/public/system/menu/icons/entities.svg +55 -0
- package/template/core_v3/storage/public/system/menu/icons/files.svg +1 -0
- package/template/core_v3/storage/public/system/menu/icons/gateway.svg +1 -0
- package/template/core_v3/storage/public/system/menu/icons/import-export.svg +41 -0
- package/template/core_v3/storage/public/system/menu/icons/integration.svg +1 -0
- package/template/core_v3/storage/public/system/menu/icons/master_data.svg +53 -0
- package/template/core_v3/storage/public/system/menu/icons/modules.svg +79 -0
- package/template/core_v3/storage/public/system/menu/icons/monitoring.svg +114 -0
- package/template/core_v3/storage/public/system/menu/icons/pipeline.svg +1 -0
- package/template/core_v3/storage/public/system/menu/icons/provider.svg +1 -0
- package/template/core_v3/storage/public/system/menu/icons/report.svg +69 -0
- package/template/core_v3/storage/public/system/menu/icons/schedule.svg +1 -0
- package/template/core_v3/storage/public/system/menu/icons/security.svg +1 -0
- package/template/core_v3/storage/public/system/menu/icons/storage.svg +1 -0
- package/template/core_v3/storage/public/system/menu/icons/template.svg +44 -0
- package/template/core_v3/storage/public/system/menu/icons/theme-layout.svg +1 -0
- package/template/core_v3/test/__mocks__/cc-core-lib.d.ts +161 -0
- package/template/core_v3/test/__mocks__/cc-core-lib.js +311 -0
- package/template/core_v3/test/__mocks__/pdf-img-convert.js +5 -0
- package/template/core_v3/test/jest.setup.ts +25 -0
- package/template/core_v3/tsconfig.build.json +4 -0
- package/template/core_v3/tsconfig.json +22 -0
- package/template/core_v3/tsconfig.test.json +17 -0
- package/template/core_v3/version.json +5 -0
- package/template/admin_v3/src/pages/api/redis/[connect]/index.ts +0 -0
- package/template/admin_v3/src/pages/api/redis/index.ts +0 -0
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', 'module', 'admin_module', 'admin_v3'].includes(project)) {
|
|
27
|
-
console.log('Project should be one of [core|admin|admin_v3|module|admin_module]!')
|
|
26
|
+
if (!['core', 'core_v3', 'admin', 'module', 'admin_module', 'admin_v3'].includes(project)) {
|
|
27
|
+
console.log('Project should be one of [core|core_v3|admin|admin_v3|module|admin_module]!')
|
|
28
28
|
return false
|
|
29
29
|
}
|
|
30
30
|
|
|
@@ -34,7 +34,7 @@ if (action === 'init') {
|
|
|
34
34
|
|
|
35
35
|
const spinner = ora('(1/1) Copying files!').start();
|
|
36
36
|
fs.copySync(`${__dirname}/../template/${project}`, path)
|
|
37
|
-
if (['core', 'admin', 'admin_v3'].includes(project)) {
|
|
37
|
+
if (['core', 'core_v3', 'admin', 'admin_v3'].includes(project)) {
|
|
38
38
|
fs.renameSync(`${path}/_env`, `${path}/.env`)
|
|
39
39
|
fs.renameSync(`${path}/_gitignore`, `${path}/.gitignore`)
|
|
40
40
|
fs.renameSync(`${path}/_npmrc`, `${path}/.npmrc`)
|
|
@@ -59,7 +59,7 @@ if (action === 'init') {
|
|
|
59
59
|
|
|
60
60
|
if (action === 'upgrade') {
|
|
61
61
|
const project = options['_'][1] || '.'
|
|
62
|
-
if (!['core', 'admin', 'admin_v3', 'module'].includes(project)) {
|
|
62
|
+
if (!['core', 'core_v3', 'admin', 'admin_v3', 'module'].includes(project)) {
|
|
63
63
|
console.log('Project should be one of [core|admin|admin_v3|module]!')
|
|
64
64
|
return false
|
|
65
65
|
}
|
package/package.json
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { requestCollections, requestListCommand, requestRunCommand } from "@shopstack/cs-admin-lib/server"
|
|
2
|
+
import { getHeadersFromRequest } from "@shopstack/cs-admin-lib/server"
|
|
3
|
+
import { NextApiRequest, NextApiResponse } from "next"
|
|
4
|
+
|
|
5
|
+
export default async (req: NextApiRequest, res: NextApiResponse) => {
|
|
6
|
+
if (req.method === 'GET') {
|
|
7
|
+
if (req.query.type === 'collections') {
|
|
8
|
+
const result = await requestCollections(getHeadersFromRequest(req))
|
|
9
|
+
return res.status(200).json(result)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
if (req.query.type === 'list_command') {
|
|
13
|
+
const result = await requestListCommand(getHeadersFromRequest(req))
|
|
14
|
+
return res.status(200).json(result)
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (req.query.type === 'command') {
|
|
19
|
+
const result = await requestRunCommand(req.body, getHeadersFromRequest(req))
|
|
20
|
+
return res.status(200).json(result)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { NextApiRequest, NextApiResponse } from "next";
|
|
2
|
+
import { getHeadersFromRequest } from "@shopstack/cs-admin-lib/server";
|
|
3
|
+
import { requestGetSummary } from "@shopstack/cs-admin-lib/server";
|
|
4
|
+
|
|
5
|
+
export default async (req: NextApiRequest, res: NextApiResponse) => {
|
|
6
|
+
if (req.method === "PATCH") {
|
|
7
|
+
try {
|
|
8
|
+
const result = await requestGetSummary(
|
|
9
|
+
req.query.name as string,
|
|
10
|
+
req.body,
|
|
11
|
+
getHeadersFromRequest(req)
|
|
12
|
+
);
|
|
13
|
+
return res.status(200).json(result);
|
|
14
|
+
} catch (e) {
|
|
15
|
+
return res.status(e.status).json(e.error);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { NextApiRequest, NextApiResponse } from "next";
|
|
2
|
+
import { getHeadersFromRequest } from "@shopstack/cs-admin-lib/server";
|
|
3
|
+
import { requestGetCompareMatrix } from "@shopstack/cs-admin-lib/server";
|
|
4
|
+
|
|
5
|
+
export default async (req: NextApiRequest, res: NextApiResponse) => {
|
|
6
|
+
if (req.method === "POST") {
|
|
7
|
+
try {
|
|
8
|
+
const result = await requestGetCompareMatrix(
|
|
9
|
+
req.body,
|
|
10
|
+
getHeadersFromRequest(req)
|
|
11
|
+
);
|
|
12
|
+
return res.status(200).json(result);
|
|
13
|
+
} catch (e) {
|
|
14
|
+
return res.status(e.status).json(e.error);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { NextApiRequest, NextApiResponse } from "next"
|
|
2
|
+
import { requestDeleteRedisByKey, requestFlushRedis, requestRedisList } from "@shopstack/cs-admin-lib/server"
|
|
3
|
+
import { getHeadersFromRequest } from "@shopstack/cs-admin-lib/server"
|
|
4
|
+
|
|
5
|
+
export default async (req: NextApiRequest, res: NextApiResponse) => {
|
|
6
|
+
if (req.method === 'GET') {
|
|
7
|
+
if (req.query.type === 'list') {
|
|
8
|
+
const result = await requestRedisList(req.query.connect as string, req.query, getHeadersFromRequest(req))
|
|
9
|
+
return res.status(200).json(result)
|
|
10
|
+
}
|
|
11
|
+
if (req.query.type === 'flush') {
|
|
12
|
+
const result = await requestFlushRedis(req.query.connect as string, getHeadersFromRequest(req))
|
|
13
|
+
return res.status(200).json(result)
|
|
14
|
+
}
|
|
15
|
+
if (req.query.type === 'delete') {
|
|
16
|
+
const result = await requestDeleteRedisByKey(req.query.connect as string, req.query.key as string, getHeadersFromRequest(req))
|
|
17
|
+
return res.status(200).json(result)
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { NextApiRequest, NextApiResponse } from "next"
|
|
2
|
+
import { requestRedisCustom } from "@shopstack/cs-admin-lib/server"
|
|
3
|
+
import { getHeadersFromRequest } from "@shopstack/cs-admin-lib/server"
|
|
4
|
+
|
|
5
|
+
export default async (req: NextApiRequest, res: NextApiResponse) => {
|
|
6
|
+
if (req.method === 'POST') {
|
|
7
|
+
const result = await requestRedisCustom(req.body, getHeadersFromRequest(req))
|
|
8
|
+
return res.status(200).json(result)
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { getHeadersFromRequest } from '@shopstack/cs-admin-lib/server';
|
|
2
|
+
import {
|
|
3
|
+
requestGetModuleSetting,
|
|
4
|
+
requestSetModuleSetting
|
|
5
|
+
} from '@shopstack/cs-admin-lib/server';
|
|
6
|
+
import { NextApiRequest, NextApiResponse } from "next";
|
|
7
|
+
|
|
8
|
+
export default async (req: NextApiRequest, res: NextApiResponse) => {
|
|
9
|
+
if (req.method === 'GET') {
|
|
10
|
+
try {
|
|
11
|
+
const result = await requestGetModuleSetting(
|
|
12
|
+
req.query.code as string,
|
|
13
|
+
req.query.name as string,
|
|
14
|
+
getHeadersFromRequest(req)
|
|
15
|
+
)
|
|
16
|
+
return res.status(200).json(result)
|
|
17
|
+
} catch (e) {
|
|
18
|
+
return res.status(e.status).json(e.error)
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
if (req.method === 'PUT') {
|
|
22
|
+
try {
|
|
23
|
+
const result = await requestSetModuleSetting(
|
|
24
|
+
req.query.code as string,
|
|
25
|
+
req.query.name as string,
|
|
26
|
+
req.body,
|
|
27
|
+
getHeadersFromRequest(req)
|
|
28
|
+
)
|
|
29
|
+
return res.status(200).json(result)
|
|
30
|
+
} catch (e) {
|
|
31
|
+
return res.status(e.status).json(e.error)
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { getHeadersFromRequest } from '@shopstack/cs-admin-lib/server';
|
|
2
|
+
import { requestListPrintTemplate, requestPrintMultipleData } from '@shopstack/cs-admin-lib/server';
|
|
3
|
+
import { NextApiRequest, NextApiResponse } from "next";
|
|
4
|
+
|
|
5
|
+
export default async (req: NextApiRequest, res: NextApiResponse) => {
|
|
6
|
+
if (req.method === 'PATCH') {
|
|
7
|
+
const { type } = req.query
|
|
8
|
+
try {
|
|
9
|
+
if (type === 'print') {
|
|
10
|
+
const result = await requestPrintMultipleData(req.body, getHeadersFromRequest(req))
|
|
11
|
+
return res.status(200).json(result)
|
|
12
|
+
}
|
|
13
|
+
if (type === 'list_print_template') {
|
|
14
|
+
const result = await requestListPrintTemplate(req.body, getHeadersFromRequest(req))
|
|
15
|
+
return res.status(200).json(result)
|
|
16
|
+
}
|
|
17
|
+
} catch (e) {
|
|
18
|
+
return res.status(e.status).json(e.error)
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { getHeadersFromRequest } from '@shopstack/cs-admin-lib/server';
|
|
2
|
+
import { requestBulkPrint } from '@shopstack/cs-admin-lib/server';
|
|
3
|
+
import { NextApiRequest, NextApiResponse } from "next";
|
|
4
|
+
|
|
5
|
+
export default async (req: NextApiRequest, res: NextApiResponse) => {
|
|
6
|
+
if (req.method === 'POST') {
|
|
7
|
+
const { id } = req.query as { id: string }
|
|
8
|
+
try {
|
|
9
|
+
const result = await requestBulkPrint(id, req.body, getHeadersFromRequest(req))
|
|
10
|
+
return res.status(200).json(result)
|
|
11
|
+
} catch (e) {
|
|
12
|
+
return res.status(e.status).json(e.error)
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { requestPrint } from "@shopstack/cs-admin-lib/server";
|
|
2
|
+
import { getHeadersFromRequest } from "@shopstack/cs-admin-lib/server";
|
|
3
|
+
import { NextApiRequest, NextApiResponse } from "next";
|
|
4
|
+
|
|
5
|
+
export default async (req: NextApiRequest, res: NextApiResponse) => {
|
|
6
|
+
if (req.method === 'GET') {
|
|
7
|
+
const { id, doc_ref } = req.query as { id: string, doc_ref: string }
|
|
8
|
+
const result = await requestPrint(id, doc_ref, getHeadersFromRequest(req))
|
|
9
|
+
return res.status(200).json(result)
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -83,7 +83,8 @@ import {
|
|
|
83
83
|
PipelineLogService,
|
|
84
84
|
PrintLogService,
|
|
85
85
|
redisCache,
|
|
86
|
-
RewriteUrlService
|
|
86
|
+
RewriteUrlService,
|
|
87
|
+
SearchTextService
|
|
87
88
|
} from '@shopstack/cc-core-lib/core'
|
|
88
89
|
|
|
89
90
|
import { CUSTOM_MODULES } from "src/modules/modules";
|
|
@@ -193,6 +194,8 @@ async function initial(app: NestFastifyApplication) {
|
|
|
193
194
|
|
|
194
195
|
await initialService(app, LayoutShareWidgetService);
|
|
195
196
|
|
|
197
|
+
await initialService(app, SearchTextService);
|
|
198
|
+
|
|
196
199
|
await initialCustomModules();
|
|
197
200
|
await initialCustomProviders();
|
|
198
201
|
await initialSettingLayouts();
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
FROM node:22.14.0-alpine3.20 as development
|
|
2
|
+
|
|
3
|
+
RUN apk update
|
|
4
|
+
RUN apk add --no-cache build-base g++ cairo-dev jpeg-dev pango-dev giflib-dev
|
|
5
|
+
RUN apk add --update --repository http://dl-3.alpinelinux.org/alpine/edge/testing libmount ttf-dejavu ttf-droid ttf-freefont ttf-liberation fontconfig
|
|
6
|
+
|
|
7
|
+
WORKDIR /usr/src/app
|
|
8
|
+
COPY package.json .
|
|
9
|
+
COPY .npmrc .
|
|
10
|
+
COPY . .
|
|
11
|
+
RUN npm install -g @nestjs/cli && npm install
|
|
12
|
+
RUN npm run build
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
FROM node:22.14.0-alpine3.20 as production
|
|
17
|
+
|
|
18
|
+
ARG NODE_ENV=production
|
|
19
|
+
ENV NODE_ENV=${NODE_ENV}\
|
|
20
|
+
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true \
|
|
21
|
+
PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser
|
|
22
|
+
# Install latest chrome dev package and fonts to support major charsets (Chinese, Japanese, Arabic, Hebrew, Thai and a few others)
|
|
23
|
+
# Note: this installs the necessary libs to make the bundled version of Chromium that Puppeteer
|
|
24
|
+
# installs, work.
|
|
25
|
+
RUN apk update && apk add --no-cache chromium
|
|
26
|
+
RUN apk update && apk upgrade -U -a --ignore alpine-baselayout
|
|
27
|
+
RUN apk add --no-cache build-base g++ cairo-dev jpeg-dev pango-dev giflib-dev
|
|
28
|
+
RUN apk add --update --repository http://dl-3.alpinelinux.org/alpine/edge/testing libmount ttf-dejavu ttf-droid ttf-freefont ttf-liberation fontconfig wget
|
|
29
|
+
RUN mkdir -p /usr/share/fonts/truetype/sarabun
|
|
30
|
+
|
|
31
|
+
# Download the Sarabun fonts and install them
|
|
32
|
+
RUN wget -q -O /usr/share/fonts/truetype/sarabun/Sarabun-Regular.ttf \
|
|
33
|
+
https://github.com/google/fonts/raw/main/ofl/sarabun/Sarabun-Regular.ttf && \
|
|
34
|
+
wget -q -O /usr/share/fonts/truetype/sarabun/Sarabun-Bold.ttf \
|
|
35
|
+
https://github.com/google/fonts/raw/main/ofl/sarabun/Sarabun-Bold.ttf && \
|
|
36
|
+
wget -q -O /usr/share/fonts/truetype/sarabun/Sarabun-Italic.ttf \
|
|
37
|
+
https://github.com/google/fonts/raw/main/ofl/sarabun/Sarabun-Italic.ttf && \
|
|
38
|
+
wget -q -O /usr/share/fonts/truetype/sarabun/Sarabun-BoldItalic.ttf \
|
|
39
|
+
https://github.com/google/fonts/raw/main/ofl/sarabun/Sarabun-BoldItalic.ttf
|
|
40
|
+
|
|
41
|
+
# Update font cache
|
|
42
|
+
RUN fc-cache -f -v
|
|
43
|
+
|
|
44
|
+
# Verify if Sarabun font was installed (for debugging)
|
|
45
|
+
RUN fc-list | grep "Sarabun"
|
|
46
|
+
|
|
47
|
+
WORKDIR /usr/src/app
|
|
48
|
+
COPY package.json .
|
|
49
|
+
COPY .npmrc .
|
|
50
|
+
COPY . .
|
|
51
|
+
RUN npm install --only=production
|
|
52
|
+
COPY --from=development /usr/src/app/dist ./dist
|
|
53
|
+
|
|
54
|
+
RUN find /usr/local/lib/node_modules -name "yarn.lock" -type f -delete
|
|
55
|
+
RUN find /usr/local/lib/node_modules -name "package-lock.json" -type f -delete
|
|
56
|
+
|
|
57
|
+
RUN find /usr/src/app/node_modules -name "yarn.lock" -type f -delete
|
|
58
|
+
RUN find /usr/src/app/node_modules -name "package-lock.json" -type f -delete
|
|
59
|
+
|
|
60
|
+
CMD ["npm", "run", "start:prod"]
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
NODE_ENV=dev
|
|
2
|
+
PORT=3000
|
|
3
|
+
LOOP_BACK_IP=0.0.0.0
|
|
4
|
+
MONGODB_URI=mongodb://{username}:{password}@127.0.0.1:27017/dev_db?authSource=admin
|
|
5
|
+
SESSION_REDIS_URL=redis://127.0.0.1:6379/1
|
|
6
|
+
CACHE_REDIS_URL=redis://127.0.0.1:6379/1
|
|
7
|
+
QUEUE_REDIS_URL=redis://127.0.0.1:6379/2
|
|
8
|
+
QUEUE_CONCURRENCY=1
|
|
9
|
+
MAX_WORKER=1
|
|
10
|
+
CUSTOM_MODULES=
|
|
11
|
+
DEFAULT_API_KEY=0939f325-e24f-4de3-8796-4d5e7243849c
|
|
12
|
+
DEFAULT_SECRET_KEY=ogi6xld0kftb5yvm6t17x2a6bmyipnfja6s7v5v2
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# These are some examples of commonly ignored file patterns.
|
|
2
|
+
# You should customize this list as applicable to your project.
|
|
3
|
+
# Learn more about .gitignore:
|
|
4
|
+
# https://www.atlassian.com/git/tutorials/saving-changes/gitignore
|
|
5
|
+
|
|
6
|
+
# Node artifact files
|
|
7
|
+
node_modules/
|
|
8
|
+
dist/
|
|
9
|
+
tmp/
|
|
10
|
+
temp/
|
|
11
|
+
lib/
|
|
12
|
+
storage/*
|
|
13
|
+
!storage/public/
|
|
14
|
+
storage/public/*
|
|
15
|
+
!storage/public/system/
|
|
16
|
+
storage/public/system/*
|
|
17
|
+
!storage/public/system/menu/
|
|
18
|
+
storage/public/system/menu/*
|
|
19
|
+
!storage/public/system/menu/icons/
|
|
20
|
+
!storage/documents/
|
|
21
|
+
|
|
22
|
+
# Generated by MacOS
|
|
23
|
+
.DS_Store
|
|
24
|
+
|
|
25
|
+
# Generated by Windows
|
|
26
|
+
Thumbs.db
|
|
27
|
+
|
|
28
|
+
# Applications
|
|
29
|
+
*.app
|
|
30
|
+
*.exe
|
|
31
|
+
*.war
|
|
32
|
+
|
|
33
|
+
# Large media files
|
|
34
|
+
*.mp4
|
|
35
|
+
*.tiff
|
|
36
|
+
*.avi
|
|
37
|
+
*.flv
|
|
38
|
+
*.mov
|
|
39
|
+
*.wmv
|
|
40
|
+
|
|
41
|
+
# Environment file
|
|
42
|
+
.env
|
|
43
|
+
|
|
44
|
+
# Log fiels
|
|
45
|
+
*.log
|
|
46
|
+
|
|
47
|
+
# Package lock file
|
|
48
|
+
package-lock.json
|
|
49
|
+
|
|
50
|
+
# Test files
|
|
51
|
+
.scannerwork/
|
|
52
|
+
coverage/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//registry.npmjs.org/:_authToken={{SHOPSTACK_TOKEN}}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
version: 0.2
|
|
2
|
+
|
|
3
|
+
phases:
|
|
4
|
+
pre_build:
|
|
5
|
+
commands:
|
|
6
|
+
- echo Logging in to Amazon ECR...
|
|
7
|
+
- $(aws ecr get-login --no-include-email --region ap-southeast-1)
|
|
8
|
+
- REPOSITORY_URI=$ECR_URI
|
|
9
|
+
- COMMIT_HASH=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7)
|
|
10
|
+
- IMAGE_TAG=${COMMIT_HASH:=latest}
|
|
11
|
+
build:
|
|
12
|
+
commands:
|
|
13
|
+
- echo logging in dockerhub...
|
|
14
|
+
- docker login -u $dockeruser -p $dockerpassword
|
|
15
|
+
- echo Build started on `date`
|
|
16
|
+
- echo Building the Docker image...
|
|
17
|
+
- sed -i "s|{{SHOPSTACK_TOKEN}}|$SHOPSATCK_TOKEN|g" .npmrc
|
|
18
|
+
- cat .npmrc
|
|
19
|
+
- docker build --no-cache -t $REPOSITORY_URI:latest --build-arg commit_hash=$COMMIT_HASH .
|
|
20
|
+
- docker tag $REPOSITORY_URI:latest $REPOSITORY_URI:$IMAGE_TAG
|
|
21
|
+
post_build:
|
|
22
|
+
commands:
|
|
23
|
+
- echo Build completed on `date`
|
|
24
|
+
- echo Pushing the Docker image...
|
|
25
|
+
- docker push $REPOSITORY_URI:$IMAGE_TAG
|
|
26
|
+
- echo Writing image definitions file...
|
|
27
|
+
- printf '[{"name":"%s","imageUri":"%s"}]' $IMAGE_CONTAINER_NAME $REPOSITORY_URI:$IMAGE_TAG > imagedefinitions.json
|
|
28
|
+
artifacts:
|
|
29
|
+
files: imagedefinitions.json
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
preset: 'ts-jest',
|
|
3
|
+
testEnvironment: 'node',
|
|
4
|
+
roots: ['<rootDir>/src/modules'],
|
|
5
|
+
testRegex: '.*\\.spec\\.ts$',
|
|
6
|
+
transform: {
|
|
7
|
+
'^.+\\.(t|j)s$': 'ts-jest'
|
|
8
|
+
},
|
|
9
|
+
transformIgnorePatterns: [
|
|
10
|
+
'node_modules/(?!(@shopstack/cc-core-lib)/.*)',
|
|
11
|
+
],
|
|
12
|
+
moduleNameMapper: {
|
|
13
|
+
'^@/(.*)$': '<rootDir>/src/$1',
|
|
14
|
+
'^(\\.{1,2}/.*)\\.js$': '$1',
|
|
15
|
+
'pdf-img-convert': '<rootDir>/test/__mocks__/pdf-img-convert.js',
|
|
16
|
+
'@shopstack/cc-core-lib/core': '<rootDir>/test/__mocks__/cc-core-lib.js'
|
|
17
|
+
},
|
|
18
|
+
setupFilesAfterEnv: ['<rootDir>/test/jest.setup.ts'],
|
|
19
|
+
collectCoverageFrom: [
|
|
20
|
+
'src/**/*.ts',
|
|
21
|
+
'!src/**/*.spec.ts',
|
|
22
|
+
'!src/**/*.module.ts',
|
|
23
|
+
'!src/main.ts',
|
|
24
|
+
'!src/**/index.ts',
|
|
25
|
+
'!src/modules/aws-s3/**/*',
|
|
26
|
+
'!src/**/*.enum.ts',
|
|
27
|
+
'!src/**/*.layout.ts',
|
|
28
|
+
'!src/**/*.workflow.ts',
|
|
29
|
+
'!src/**/*.custom_action.ts',
|
|
30
|
+
'!src/modules/modules.ts'
|
|
31
|
+
],
|
|
32
|
+
coverageDirectory: './coverage',
|
|
33
|
+
coverageReporters: ['lcov', 'text', 'text-summary'],
|
|
34
|
+
moduleFileExtensions: ['js', 'json', 'ts'],
|
|
35
|
+
globals: {
|
|
36
|
+
'ts-jest': {
|
|
37
|
+
tsconfig: 'tsconfig.test.json'
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
verbose: true,
|
|
41
|
+
testTimeout: 30000,
|
|
42
|
+
moduleDirectories: ['node_modules', 'src/__tests__/mocks', 'test/__mocks__']
|
|
43
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
export NEW_RELIC_NO_CONFIG_FILE=true
|
|
4
|
+
|
|
5
|
+
if [ -z "$NEW_RELIC_LICENSE_KEY" ] || [ -z "$NEW_RELIC_APP_NAME" ]; then
|
|
6
|
+
export NEW_RELIC_ENABLED=false
|
|
7
|
+
echo "Don't enable newrelic because some variable is not set"
|
|
8
|
+
return 0
|
|
9
|
+
fi
|
|
10
|
+
|
|
11
|
+
export NEW_RELIC_ENABLED=true
|
|
12
|
+
export NEW_RELIC_DISTRIBUTED_TRACING_ENABLED=true
|
|
13
|
+
export NEW_RELIC_LOG=stdout
|
|
14
|
+
|
|
15
|
+
echo "Enable newrelic"
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "cs-core",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"author": "",
|
|
6
|
+
"private": true,
|
|
7
|
+
"license": "UNLICENSED",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"prebuild": "rimraf dist",
|
|
10
|
+
"postinstall": "node post-install.js",
|
|
11
|
+
"build": "source ./newrelic.sh && nest build",
|
|
12
|
+
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
13
|
+
"start": "nest start",
|
|
14
|
+
"start:dev": "source ./newrelic.sh && nest start --watch",
|
|
15
|
+
"start:debug": "nest start --debug --watch",
|
|
16
|
+
"start:prod": "source ./newrelic.sh && node dist/src/main",
|
|
17
|
+
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
|
|
18
|
+
"test": "jest",
|
|
19
|
+
"test:watch": "jest --watch",
|
|
20
|
+
"test:cov": "jest --coverage",
|
|
21
|
+
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
|
|
22
|
+
"sonar": "node -r dotenv/config ./node_modules/.bin/jest --coverage && node -r dotenv/config ./node_modules/.bin/sonar-scanner",
|
|
23
|
+
"sonar:coverage": "jest --coverage --coverageReporters=lcov --coverageDirectory=coverage"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@shopstack/cs-core-lib": "^3.0.0",
|
|
27
|
+
"reflect-metadata": "^0.1.14"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@nestjs/testing": "^10.3.5",
|
|
31
|
+
"@types/bcrypt": "^5.0.2",
|
|
32
|
+
"@types/bull": "^3.14.4",
|
|
33
|
+
"@types/chroma-js": "^2.4.0",
|
|
34
|
+
"@types/express": "^4.17.8",
|
|
35
|
+
"@types/jest": "^29.5.14",
|
|
36
|
+
"@types/node": "^13.13.27",
|
|
37
|
+
"@types/numeral": "^2.0.2",
|
|
38
|
+
"@types/supertest": "^2.0.10",
|
|
39
|
+
"@typescript-eslint/eslint-plugin": "^6.1.0",
|
|
40
|
+
"@typescript-eslint/parser": "^6.1.0",
|
|
41
|
+
"eslint": "^8.44.0",
|
|
42
|
+
"eslint-config-prettier": "^6.13.0",
|
|
43
|
+
"eslint-plugin-import": "^2.22.1",
|
|
44
|
+
"jest": "^29.7.0",
|
|
45
|
+
"prettier": "^1.19.1",
|
|
46
|
+
"sonarqube-scanner": "^4.3.0",
|
|
47
|
+
"supertest": "^4.0.2",
|
|
48
|
+
"ts-jest": "^29.3.4",
|
|
49
|
+
"ts-loader": "^6.2.1",
|
|
50
|
+
"ts-node": "^10.9.1",
|
|
51
|
+
"tsconfig-paths": "^3.9.0",
|
|
52
|
+
"typescript": "^5.8.2"
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const fs = require("fs-extra");
|
|
2
|
+
const ora = require("ora");
|
|
3
|
+
const { exec } = require("child_process");
|
|
4
|
+
|
|
5
|
+
const mainPath = "./src/modules";
|
|
6
|
+
const moduleDependencies = [];
|
|
7
|
+
const spinner = ora("Checking module dependencies").start();
|
|
8
|
+
|
|
9
|
+
const modules = fs.readdirSync(mainPath);
|
|
10
|
+
for (const folder of modules) {
|
|
11
|
+
if (!fs.lstatSync(`${mainPath}/${folder}`).isDirectory()) continue;
|
|
12
|
+
if (!fs.existsSync(`${mainPath}/${folder}/module.json`)) continue;
|
|
13
|
+
|
|
14
|
+
const moduleConfig = require(`${mainPath}/${folder}/module.json`);
|
|
15
|
+
if (!moduleConfig.dependencies) continue;
|
|
16
|
+
|
|
17
|
+
for (const lib in moduleConfig.dependencies) {
|
|
18
|
+
moduleDependencies.push(`${lib}@${moduleConfig.dependencies[lib]}`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
spinner.succeed("Checking module depencies done.");
|
|
23
|
+
|
|
24
|
+
if (!moduleDependencies.length) return true;
|
|
25
|
+
|
|
26
|
+
spinner.start(`Install module dependencies`);
|
|
27
|
+
|
|
28
|
+
exec(`npm install --no-save ${moduleDependencies.join(" ")}`, err => {
|
|
29
|
+
if (err) {
|
|
30
|
+
return spinner.fail(`Install module dependencies failed ${err.message}`);
|
|
31
|
+
}
|
|
32
|
+
spinner.succeed("Install module dependencies done.");
|
|
33
|
+
return true;
|
|
34
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Project identification
|
|
2
|
+
sonar.projectKey=demo-points-core
|
|
3
|
+
sonar.projectName=Demo Points Core
|
|
4
|
+
sonar.projectVersion=1.0.0
|
|
5
|
+
|
|
6
|
+
# Source code location
|
|
7
|
+
sonar.sources=src
|
|
8
|
+
sonar.tests=src
|
|
9
|
+
sonar.test.inclusions=**/*.spec.ts
|
|
10
|
+
sonar.exclusions=**/*.layout.ts,**/*.workflow.ts,**/*.custom_action.ts,**/*.module.ts,**/main.ts,**/index.ts,**/aws-s3/**,**/*.enum.ts
|
|
11
|
+
|
|
12
|
+
# Language
|
|
13
|
+
sonar.language=ts
|
|
14
|
+
sonar.typescript.lcov.reportPaths=coverage/lcov.info
|
|
15
|
+
|
|
16
|
+
# Encoding of the source files
|
|
17
|
+
sonar.sourceEncoding=UTF-8
|
|
18
|
+
|
|
19
|
+
# Coverage report path
|
|
20
|
+
sonar.javascript.lcov.reportPaths=coverage/lcov.info
|
|
21
|
+
|
|
22
|
+
# SonarCloud configuration
|
|
23
|
+
sonar.host.url=https://sonarcloud.io
|
|
24
|
+
sonar.organization=your-organization-key # You need to replace this with your organization key
|
|
25
|
+
|
|
26
|
+
# Authentication token should be provided via environment variable SONAR_TOKEN
|
|
27
|
+
# DO NOT add the token directly in this file for security reasons
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as _ from "lodash";
|
|
2
|
+
|
|
3
|
+
import { Controller, Get, Param } from "@nestjs/common";
|
|
4
|
+
import { AppService } from "./app.service";
|
|
5
|
+
|
|
6
|
+
import { Public, CONST } from "@shopstack/cc-core-lib/core";
|
|
7
|
+
@Controller()
|
|
8
|
+
export class AppController {
|
|
9
|
+
constructor(private readonly appService: AppService) { }
|
|
10
|
+
|
|
11
|
+
@Public()
|
|
12
|
+
@Get("/health_check")
|
|
13
|
+
healthCheck(): boolean {
|
|
14
|
+
return this.appService.healthCheck();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
@Public()
|
|
18
|
+
@Get("/health_check/init")
|
|
19
|
+
init(): string {
|
|
20
|
+
return this.appService.init();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@Get("/all_x_routes/:method/:entity")
|
|
24
|
+
listAllRoutes(@Param() params: any): any {
|
|
25
|
+
const { method, entity } = params;
|
|
26
|
+
if (_.isEmpty(method)) {
|
|
27
|
+
return [];
|
|
28
|
+
}
|
|
29
|
+
const result = CONST.ENDPOINT_PATHS.filter(
|
|
30
|
+
p => p.method.toLowerCase() === method.toLowerCase()
|
|
31
|
+
);
|
|
32
|
+
if (_.isEmpty(entity) || entity === "undefined") {
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
return result.filter(
|
|
36
|
+
r => r.path.indexOf(entity) === 0 || r.path.indexOf(":entity") === 0
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
}
|