Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use tegg v4 #769

Merged
merged 16 commits into from
Mar 9, 2025
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
36 changes: 36 additions & 0 deletions .docker/alpine/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
FROM node:22-alpine

# Create app directory
WORKDIR /usr/src/app

# Install app dependencies
COPY . .

RUN chmod +x .docker/build.sh && .docker/build.sh

ENV NODE_ENV=production \
EGG_SERVER_ENV=prod \
CNPMCORE_CONFIG_REGISTRY= \
CNPMCORE_CONFIG_SOURCE_REGISTRY=https://registry.npmmirror.com \
CNPMCORE_CONFIG_SOURCE_REGISTRY_IS_CNPM=true \
CNPMCORE_DATABASE_TYPE= \
CNPMCORE_DATABASE_NAME= \
CNPMCORE_DATABASE_HOST= \
CNPMCORE_DATABASE_PORT=3306 \
CNPMCORE_DATABASE_USER= \
CNPMCORE_DATABASE_PASSWORD= \
CNPMCORE_REDIS_HOST= \
CNPMCORE_REDIS_PORT=6379 \
CNPMCORE_REDIS_PASSWORD= \
CNPMCORE_REDIS_DB= \
CNPMCORE_NFS_TYPE=s3 \
CNPMCORE_NFS_S3_CLIENT_ENDPOINT= \
CNPMCORE_NFS_S3_CLIENT_BUCKET= \
CNPMCORE_NFS_S3_CLIENT_ID= \
CNPMCORE_NFS_S3_CLIENT_SECRET= \
CNPMCORE_NFS_S3_CLIENT_FORCE_PATH_STYLE=true \
CNPMCORE_NFS_S3_CLIENT_DISABLE_URL=true \
TZ=Asia/Shanghai

EXPOSE 7001
CMD ["npm", "run", "start:foreground"]
6 changes: 6 additions & 0 deletions .docker/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

npm install -g npminstall --registry=https://registry.npmmirror.com \
&& npminstall -c \
&& npm run tsc \
&& npmupdate -c --production
36 changes: 36 additions & 0 deletions .docker/debian/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
FROM node:22

# Create app directory
WORKDIR /usr/src/app

# Install app dependencies
COPY . .

RUN chmod +x .docker/build.sh && .docker/build.sh

ENV NODE_ENV=production \
EGG_SERVER_ENV=prod \
CNPMCORE_CONFIG_REGISTRY= \
CNPMCORE_CONFIG_SOURCE_REGISTRY=https://registry.npmmirror.com \
CNPMCORE_CONFIG_SOURCE_REGISTRY_IS_CNPM=true \
CNPMCORE_DATABASE_TYPE= \
CNPMCORE_DATABASE_NAME= \
CNPMCORE_DATABASE_HOST= \
CNPMCORE_DATABASE_PORT=3306 \
CNPMCORE_DATABASE_USER= \
CNPMCORE_DATABASE_PASSWORD= \
CNPMCORE_REDIS_HOST= \
CNPMCORE_REDIS_PORT=6379 \
CNPMCORE_REDIS_PASSWORD= \
CNPMCORE_REDIS_DB= \
CNPMCORE_NFS_TYPE=s3 \
CNPMCORE_NFS_S3_CLIENT_ENDPOINT= \
CNPMCORE_NFS_S3_CLIENT_BUCKET= \
CNPMCORE_NFS_S3_CLIENT_ID= \
CNPMCORE_NFS_S3_CLIENT_SECRET= \
CNPMCORE_NFS_S3_CLIENT_FORCE_PATH_STYLE=true \
CNPMCORE_NFS_S3_CLIENT_DISABLE_URL=true \
TZ=Asia/Shanghai

EXPOSE 7001
CMD ["npm", "run", "start:foreground"]
41 changes: 41 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,44 @@
# CNPMCORE_DATABASE_USER=postgres
# CNPMCORE_DATABASE_PASSWORD=postgres
# CNPMCORE_DATABASE_NAME=cnpmcore

# CNPMCORE_CONFIG_ENABLE_ES=true
# CNPMCORE_CONFIG_ES_CLIENT_NODE=http://localhost:9200
# CNPMCORE_CONFIG_ES_CLIENT_AUTH_USERNAME=elastic
# CNPMCORE_CONFIG_ES_CLIENT_AUTH_PASSWORD=abcdef

# https://github.com/cnpm/cnpmcore/blob/next/docs/elasticsearch-setup.md#%E6%96%B0%E5%BB%BA-env-%E6%96%87%E4%BB%B6
# Password for the 'elastic' user (at least 6 characters)
ELASTIC_PASSWORD="abcdef"

# Password for the 'kibana_system' user (at least 6 characters)
KIBANA_PASSWORD="abcdef"

# Version of Elastic products
STACK_VERSION=8.7.1
# enable for arm64
# STACK_VERSION_ARM64=-arm64
# STACK_PLATFORM=linux/arm64

# Set the cluster name
CLUSTER_NAME=docker-cluster

# Set to 'basic' or 'trial' to automatically start the 30-day trial
LICENSE=basic
#LICENSE=trial

# Port to expose Elasticsearch HTTP API to the host
ES_PORT=9200
#ES_PORT=127.0.0.1:9200

# Port to expose Kibana to the host
KIBANA_PORT=5601
#KIBANA_PORT=80

# Increase or decrease based on the available host memory (in bytes)
ES_MEM_LIMIT=1073741824
KB_MEM_LIMIT=1073741824
LS_MEM_LIMIT=1073741824

# SAMPLE Predefined Key only to be used in POC environments
ENCRYPTION_KEY=c34d38b3a14956121ff2170e5030b471551370178f43e5626eec58b04a30fae2
8 changes: 4 additions & 4 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"extends": "eslint-config-egg/typescript",
"rules": {

}
"extends": [
"eslint-config-egg/typescript",
"eslint-config-egg/lib/rules/enforce-node-prefix"
]
}
75 changes: 63 additions & 12 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ name: Node.js CI

on:
push:
branches: [ master ]
branches: [ master, next ]
pull_request:
branches: [ master ]
branches: [ master, next ]

jobs:
test-postgresql-fs-nfs:
Expand Down Expand Up @@ -41,7 +41,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [18.20.0, 18, 20, 22]
node-version: [20.18.0, 20, 22]
os: [ubuntu-latest]

steps:
Expand All @@ -67,7 +67,7 @@ jobs:
POSTGRES_PORT: 5432

- name: Code Coverage
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}

Expand All @@ -93,7 +93,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [18.20.0, 18, 20, 22]
node-version: [20.18.0, 20, 22]
os: [ubuntu-latest]

steps:
Expand All @@ -112,16 +112,16 @@ jobs:
run: npm run ci

- name: Code Coverage
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}

test-mysql57-oss-nfs:
runs-on: ${{ matrix.os }}
if: |
contains('
refs/heads/master
refs/heads/dev
refs/heads/master-skip-oss
refs/heads/dev-skip-oss
', github.ref)

services:
Expand All @@ -135,16 +135,14 @@ jobs:
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=5

redis:
# https://docs.github.com/en/actions/using-containerized-services/about-service-containers#example-mapping-redis-ports
image: redis
ports:
# Opens tcp port 6379 on the host and service container
- 6379:6379

strategy:
fail-fast: false
matrix:
node-version: [18.20.0, 18, 20, 22]
node-version: [20, 22]
os: [ubuntu-latest]

steps:
Expand All @@ -169,6 +167,59 @@ jobs:
CNPMCORE_NFS_OSS_SECRET: ${{ secrets.CNPMCORE_NFS_OSS_SECRET }}

- name: Code Coverage
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}

test-mysql57-s3-nfs:
runs-on: ${{ matrix.os }}

services:
mysql:
image: mysql:5.7
env:
MYSQL_ALLOW_EMPTY_PASSWORD: true
MYSQL_DATABASE: cnpmcore_unittest
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=5

redis:
image: redis
ports:
- 6379:6379

strategy:
fail-fast: false
matrix:
node-version: [20, 22]
os: [ubuntu-latest]

steps:
- name: Checkout Git Source
uses: actions/checkout@v4

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Install Dependencies
run: npm i

- name: Continuous Integration
run: npm run ci "test/cli/npm/install.test.ts"
env:
CNPMCORE_NFS_TYPE: s3
CNPMCORE_NFS_REMOVE_BEFORE_UPLOAD: true
CNPMCORE_NFS_S3_CLIENT_BUCKET: cnpmcore-unittest-github-nodejs-${{ matrix.node-version }}
CNPMCORE_NFS_S3_CLIENT_ENDPOINT: ${{ secrets.CNPMCORE_NFS_S3_ENDPOINT }}
CNPMCORE_NFS_S3_CLIENT_ID: ${{ secrets.CNPMCORE_NFS_S3_ID }}
CNPMCORE_NFS_S3_CLIENT_SECRET: ${{ secrets.CNPMCORE_NFS_S3_SECRET }}
CNPMCORE_NFS_S3_CLIENT_FORCE_PATH_STYLE: true
# CNPMCORE_NFS_S3_CLIENT_DISABLE_URL: true

- name: Code Coverage
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Release
on:
push:
branches: [ master ]
branches: [ master, next ]

jobs:
release:
Expand Down
6 changes: 6 additions & 0 deletions .oxlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"plugins": ["import"],
"rules": {
"import/no-cycle": "error"
}
}
27 changes: 26 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,32 @@
# Changelog

## [3.75.1](https://github.com/cnpm/cnpmcore/compare/v3.75.0...v3.75.1) (2025-03-09)
## [4.0.2](https://github.com/cnpm/cnpmcore/compare/v4.0.1...v4.0.2) (2025-02-10)

* should return default value when env is empty string ([#759](https://github.com/cnpm/cnpmcore/issues/759)) ([b6c781e](https://github.com/cnpm/cnpmcore/commit/b6c781ec250150a689a9d04080ebca716f0840dd))

## [4.0.1](https://github.com/cnpm/cnpmcore/compare/v4.0.0...v4.0.1) (2025-02-09)


### Bug Fixes

* remove npm-cli-login for ssri security ([#754](https://github.com/cnpm/cnpmcore/issues/754)) ([d18981e](https://github.com/cnpm/cnpmcore/commit/d18981e658902dab54297cc5cc4798a6a9e1c84f))

## [4.0.0](https://github.com/cnpm/cnpmcore/compare/v3.74.0...v4.0.0) (2025-02-09)


### ⚠ BREAKING CHANGES

* only support egg >= 4.0.0

the first app on egg v4

https://github.com/eggjs/egg/issues/3644

### Features

* use egg v4 ([#747](https://github.com/cnpm/cnpmcore/issues/747)) ([4427a4f](https://github.com/cnpm/cnpmcore/commit/4427a4fca58e3d1aca4c27f817798f3820db89b9))

## [3.75.1](https://github.com/cnpm/cnpmcore/compare/v3.75.0...v3.75.1) (2025-03-09)

### Bug Fixes

Expand Down
3 changes: 0 additions & 3 deletions DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ npm run dev

# 访问
curl -v http://127.0.0.1:7001

# cnpmcore_admin 注册管理员
npm login --registry=http://127.0.0.1:7001
```

### 开发运行 - PostgreSQL
Expand Down
17 changes: 0 additions & 17 deletions Dockerfile

This file was deleted.

4 changes: 2 additions & 2 deletions INTEGRATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
{
redis: {
enable: true,
package: 'egg-redis',
package: '@eggjs/redis',
},
teggOrm: {
enable: true,
Expand All @@ -71,7 +71,7 @@
},
tracer: {
enable: true,
package: 'egg-tracer',
package: '@eggjs/tracer',
},
typeboxValidate: {
enable: true,
Expand Down
Loading
Loading