From c96495ad4ef778a006f0307a9e0a4bf47d0bfdc7 Mon Sep 17 00:00:00 2001 From: Gao Sun Date: Sun, 16 Oct 2022 00:49:16 +0800 Subject: [PATCH] chore!: update scripts --- .github/workflows/integration-test.yml | 33 ++++++++++---------------- .gitpod.yml | 2 +- Dockerfile | 4 +--- package.json | 11 +++++---- packages/core/package.json | 4 ---- pnpm-lock.yaml | 3 +++ 6 files changed, 24 insertions(+), 33 deletions(-) diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index e61b976bf..48db00dee 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -19,18 +19,11 @@ jobs: - uses: actions/checkout@v3 - name: Setup Node and pnpm - uses: silverhand-io/actions-node-pnpm-run-steps@v1.2.3 + uses: silverhand-io/actions-node-pnpm-run-steps@v2 - name: Build run: pnpm -- lerna run build --stream - - name: Add the mock connectors for integration tests only - run: | - pnpm add-connector @logto/connector-mock-sms - pnpm add-connector @logto/connector-mock-email - pnpm add-connector @logto/connector-mock-social - working-directory: packages/core - - name: Package run: ./package.sh @@ -60,15 +53,14 @@ jobs: cp tests/package.json ./ - name: Setup Node and pnpm - uses: silverhand-io/actions-node-pnpm-run-steps@v1.2.3 + uses: silverhand-io/actions-node-pnpm-run-steps@v2 with: run-install: false # Setup integration test - name: Install dependencies run: | - mv tests /tmp/tests - cd /tmp/tests + cd tests pnpm i pnpm prepack @@ -81,17 +73,18 @@ jobs: name: integration-test-${{ github.sha }} - name: Extract - run: tar -xzf logto.tar.gz - - - name: Seed database - working-directory: logto/packages/core - run: npm run cli db seed - env: - DB_URL: postgres://postgres:postgres@localhost:5432 + working-directory: tests + run: | + npm run cli init -- -p ../logto --db postgres://postgres:postgres@localhost:5432 --no-oc --du ../logto.tar.gz + + - name: Add mock connectors + working-directory: tests + run: | + npm run cli connector add @logto/connector-mock-sms @logto/connector-mock-email @logto/connector-mock-social -- -p ../logto - name: Run Logto working-directory: logto/packages/core - run: node . --from-root --all-yes & + run: node . & env: INTEGRATION_TEST: true NODE_ENV: production @@ -103,7 +96,7 @@ jobs: # Test - name: Run tests run: | - cd /tmp/tests/packages/integration-tests + cd tests/packages/integration-tests pnpm start env: INTEGRATION_TESTS_LOGTO_URL: http://localhost:3001 diff --git a/.gitpod.yml b/.gitpod.yml index 7d5eaf0c7..3a8dfd86e 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -8,8 +8,8 @@ tasks: pnpm prepack cd packages/core pnpm build - pnpm add-official-connectors cd - + pnpm cli connector add --official command: | export ENDPOINT=$(gp url 3001) pnpm cli db seed diff --git a/Dockerfile b/Dockerfile index 16310305d..2b13c5b99 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,9 +14,8 @@ RUN pnpm i RUN pnpm -- lerna run build --stream # Add official connectors -WORKDIR /etc/logto/packages/core -RUN pnpm add-official-connectors WORKDIR /etc/logto +RUN pnpm cli connector add --official # Prune dependencies for production RUN rm -rf node_modules packages/*/node_modules @@ -30,5 +29,4 @@ FROM node:16-alpine as app WORKDIR /etc/logto COPY --from=builder /etc/logto . EXPOSE 3001 -ENV NO_INQUIRY true ENTRYPOINT ["npm", "start"] diff --git a/package.json b/package.json index 0e80c2971..f7a6a9aac 100644 --- a/package.json +++ b/package.json @@ -10,11 +10,9 @@ "prepare": "if test \"$NODE_ENV\" != \"production\" && test \"$CI\" != \"true\" ; then husky install ; fi", "prepack": "lerna run --stream prepack", "dev": "lerna run --stream prepack -- --incremental && lerna --ignore=@logto/integration-tests run --parallel dev", - "start": "cd packages/core && NODE_ENV=production node . --from-root", - "//": "For production, use NPM instead", - "cli": "cd packages/core && npm run cli", - "//": "For production, use NPM instead", - "alteration": "cd packages/core && npm run alteration", + "start": "cd packages/core && NODE_ENV=production node .", + "cli": "logto", + "alteration": "logto db alt", "ci:build": "lerna run --stream build", "ci:lint": "lerna run --parallel lint", "ci:stylelint": "lerna run --parallel stylelint", @@ -52,5 +50,8 @@ "jest": "^29.1.2" } } + }, + "dependencies": { + "@logto/cli": "^1.0.0-beta.10" } } diff --git a/packages/core/package.json b/packages/core/package.json index 94f0f3e97..6a14d4501 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -14,10 +14,6 @@ "lint:report": "pnpm lint --format json --output-file report.json", "dev": "rm -rf build/ && pnpm run copyfiles && nodemon", "start": "NODE_ENV=production node build/index.js", - "add-connector": "logto connector add -p ../../", - "add-official-connectors": "logto connector add -o -p ../../", - "alteration": "logto db alt", - "cli": "logto", "test": "jest", "test:ci": "jest --coverage --silent", "test:report": "codecov -F core" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 094016d14..e35ae8c6d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -7,9 +7,12 @@ importers: '@commitlint/cli': ^17.0.0 '@commitlint/config-conventional': ^17.0.0 '@commitlint/types': ^17.0.0 + '@logto/cli': ^1.0.0-beta.10 husky: ^8.0.0 lerna: ^5.0.0 typescript: ^4.7.4 + dependencies: + '@logto/cli': link:packages/cli devDependencies: '@commitlint/cli': 17.0.0 '@commitlint/config-conventional': 17.0.0