create-aomex 0.0.32 → 0.0.34

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,6 +1,6 @@
1
1
  {
2
2
  "name": "create-aomex",
3
- "version": "0.0.32",
3
+ "version": "0.0.34",
4
4
  "repository": "git@github.com:aomex/create-aomex.git",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,3 +1,7 @@
1
1
  volumes/
2
2
  node_modules/
3
3
  coverage/
4
+ .git/
5
+ .vscode/
6
+ .husky/
7
+ .idea/
@@ -1,7 +1,7 @@
1
1
  services:
2
2
  migration:
3
3
  image: {{projectName}}:integration
4
- command: prisma migrate deploy
4
+ command: npx prisma migrate deploy
5
5
  api:
6
6
  image: {{projectName}}:integration
7
7
  restart: always
@@ -9,5 +9,4 @@ services:
9
9
  - 3000:3000
10
10
  cron:
11
11
  image: {{projectName}}:integration
12
- container_name: {{projectName}}-cron-integration
13
- command: aomex cron:start
12
+ command: npx aomex cron:start
@@ -1,7 +1,7 @@
1
1
  services:
2
2
  migration:
3
3
  image: {{projectName}}:production
4
- command: prisma migrate deploy
4
+ command: npx prisma migrate deploy
5
5
  api:
6
6
  image: {{projectName}}:production
7
7
  restart: always
@@ -9,5 +9,4 @@ services:
9
9
  - 3000:3000
10
10
  cron:
11
11
  image: {{projectName}}:production
12
- container_name: {{projectName}}-cron-production
13
- command: aomex cron:start
12
+ command: npx aomex cron:start
@@ -1,6 +1,6 @@
1
1
  services:
2
- db:
3
- image: mysql:8.4
2
+ mysql:
3
+ image: mysql:8
4
4
  environment:
5
5
  # 修改后需要同步修改.env里的参数
6
6
  MYSQL_DATABASE: '{{projectName}}'
@@ -10,8 +10,17 @@ services:
10
10
  ports:
11
11
  - 3306:3306
12
12
  command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
13
+ mongo:
14
+ image: mongo:7
15
+ environment:
16
+ MONGO_INITDB_ROOT_USERNAME: root
17
+ MONGO_INITDB_ROOT_PASSWORD: abcde
18
+ volumes:
19
+ - ./volumes/mongo:/data/db
20
+ ports:
21
+ - 27017:27017
13
22
  redis:
14
- image: redis:7.4
23
+ image: redis:7
15
24
  volumes:
16
25
  - ./volumes/redis:/data
17
26
  ports:
@@ -8,6 +8,7 @@
8
8
  },
9
9
  "scripts": {
10
10
  "start": "node scripts/start.mjs",
11
+ "cron:stats": "sh scripts/docker-cron-stats.sh",
11
12
  "deploy:production": "sh scripts/deploy.sh production",
12
13
  "deploy:integration": "sh scripts/deploy.sh integration",
13
14
  "prepare": "npx husky",
@@ -11,5 +11,3 @@ rm -rf src
11
11
  mv build/src .
12
12
  pnpm install --prod
13
13
  rm -rf node_modules/@types node_modules/*/*.d.ts
14
- ln -s $PWD/node_modules/.bin/aomex /usr/local/bin/aomex
15
- ln -s $PWD/node_modules/.bin/prisma /usr/local/bin/prisma
@@ -3,15 +3,16 @@
3
3
  set -ex
4
4
 
5
5
  env="$1"
6
- projectName="{{projectName}}"
6
+ project_name="{{projectName}}"
7
+ docker_compose_file="docker-compose-$env.yml"
7
8
 
8
- sudo docker build --tag "$projectName:$env" --file "Dockerfile.$env" .
9
+ sudo docker build --tag "$project_name:$env" --file "Dockerfile.$env" .
9
10
 
10
- cron_container_name="$projectName-cron-$env"
11
- container_exist=$(sudo docker ps | { grep $cron_container_name || :; })
12
- if [ -n "$container_exist" ];
11
+ cron_service_name=cron
12
+ if [ -n "$(sudo docker compose --file $docker_compose_file ps | { grep $cron_service_name || :; })" ]
13
13
  then
14
- sudo docker exec it $cron_container_name /bin/sh -c "aomex cron:stop"
14
+ # exit 137 SIGKILL
15
+ { sudo docker compose --file $docker_compose_file exec -it $cron_service_name /bin/sh -c "npx aomex cron:stop" || :; }
15
16
  fi
16
17
 
17
- sudo docker compose --file "docker-compose-$env.yml" up -d --timeout=1 --remove-orphans
18
+ sudo docker compose --file $docker_compose_file up -d --timeout=1 --remove-orphans
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env sh
2
+
3
+ # exit 130 SIGINT
4
+ { sudo docker compose exec -it cron /bin/sh -c "npx aomex cron:stats" || :; }
@@ -5,7 +5,7 @@ execSync('docker compose -f docker-compose.yml down', { stdio: 'inherit' });
5
5
 
6
6
  const docker = spawn('docker compose -f docker-compose.yml up', {
7
7
  stdio: ['inherit', 'inherit', 'pipe'],
8
- shell: 'zsh',
8
+ shell: true,
9
9
  });
10
10
 
11
11
  await new Promise((resolve) => {
@@ -19,10 +19,10 @@ await new Promise((resolve) => {
19
19
 
20
20
  const server = spawn(
21
21
  'npx prisma migrate deploy && npx prisma generate && node --import tsx/esm --watch src/web.ts',
22
- { stdio: 'inherit', shell: 'zsh' },
22
+ { stdio: 'inherit', shell: true },
23
23
  );
24
24
 
25
- const cron = spawn('npx', ['aomex', 'cron:start'], { stdio: 'inherit', shell: 'zsh' });
25
+ const cron = spawn('npx aomex cron:start', { stdio: 'inherit', shell: true });
26
26
 
27
27
  // 防止被其它逻辑清除监听
28
28
  setTimeout(() => {
@@ -3,9 +3,11 @@ import { Caching } from '@aomex/cache';
3
3
  import { redisAdapter } from '@aomex/cache-redis-adapter';
4
4
  import { configs } from '@configs';
5
5
 
6
- export const cache = new Caching(redisAdapter(configs.redis));
6
+ const cache = new Caching(redisAdapter(configs.redis));
7
7
 
8
8
  export class CacheService extends Service {
9
+ public readonly instance = cache;
10
+
9
11
  protected readonly demoKey = 'demo';
10
12
 
11
13
  getHotRankings() {