Move repo to pnpm based workflow (#14350)

* Use pnpm instead of npm

* Setup workspace

* Replace scripts / lerna root stuff

* Add todo file

* Update lock, start updating packages

* Update todo

* [WIP] Keep going on module resolution in pnpm

* Fix final missing deps/types for complete build

* [WIP] Replace npm commands with pnpm alternatives

* Update jest config for v28

* Fix missing package under schema

* Update workflow

* Run CI on fork

* Use local reference

* Remove version from local workflow

* Add build to prepare

* Add Node's max old space size flag to linter

* Idemdito for codeql

* Hyphens? Underscores?

* Bang

* Only build one thing at a time

* Underscores after all?

* Match 7gb of GH

* Set env on prepare

* Jest is driving me nuts

* Downgrade jest

* Add root jest

* We'll get there, eventually.

* 🥳

* Het houdt niet op, niet vanzelf

* attempt to fix e2e

* fix unit test & shared import

* add `debug: true` to CodeQL action

* Fix dev call in shared

* Add missing cross-env

* Add missing geo-json dependency for app

* add flag to prepare action to skip build

* remove debug flag from codeql action

* fix invalid env syntax

* add tslib to app dependencies for tests

* another attempt

* Added missing rimraf dependency for the api prebuild/cleanup scripts

* Added missing ts-node dependency for the api cli script

* update E2E tests readme to use pnpm

* Undo move of extensions sdk

* Fixes nested groups in accordions not rendering fields (#14369)

* initial fix for nested groups in accordions

* removed debug code

* Fix strict relative dates showing "incorrect" (#14390)

* Set rounding method of relative formatted date to floor when strict option is selected

* Add round fn as an option

Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>

* Don't use locales in generated camelCased values from env (#14401)

Ref https://github.com/directus/directus/discussions/14122

* Fix list panel descending sort (#14396)

* fix list panel descending sort

* Handle missing or explicit desc value

Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>

* Fix query primary field for system tables (#14402)

* New Crowdin updates (#14403)

* Update source file en-US.yaml

* New translations en-US.yaml (Spanish, Chile)

* New translations en-US.yaml (Spanish, Latin America)

* New translations en-US.yaml (Greek)

* New translations en-US.yaml (Italian)

* New translations en-US.yaml (French, Canada)

* Fix/wysiwyg context menu (#14404)

* New translations en-US.yaml (Polish) (#14407)

* Encoded the url using encodeURIComponent, so that the url gets sanitzed and so, we did not get 404 error. (#14418)

* Encoded the url using encodeURIComponent, so that the url gets sanitized and we did not get 404 error.

* Added required changes as stated by the reviewer

* Used encodeURI instead of encodeURIComponent to encode the params only

* Solved linting error

* Solved linting errors

* checked with npm run lint, no linting errors found

* fix generateJoi error due to empty permissions when creating new role (#14416)

* fix empty permissions when creating new role

* basic test

* move logic up

* additional test

* Update api/tests/utils/filter-items.test.ts

Co-authored-by: ian <licitdev@gmail.com>

Co-authored-by: ian <licitdev@gmail.com>

* Recreate lockfile

* Fix build of extensions-sdk

* Add missing dependency

* Add some more missing deps

* Update blackbox to use pnpm

* Update workflow to use main

* Update pack to work with pnpm

* Simplify commands

* Remove todo file (completed)

* ADd missing types dep

* Use local test version

* Remove version from local reference

* Call super with context

* Add missing dep

* Simplify workflows

Ref https://github.com/directus/organization/issues/135

* Simplify some more

* Linter is on root

Co-authored-by: Azri Kahar <42867097+azrikahar@users.noreply.github.com>
Co-authored-by: brainslug <tim@brainslug.nl>
Co-authored-by: Brainslug <br41nslug@users.noreply.github.com>
Co-authored-by: Gerard Lamusse <gerardlamo@gmail.com>
Co-authored-by: José Varela <joselcvarela@gmail.com>
Co-authored-by: ian <licitdev@gmail.com>
Co-authored-by: Zeel Pathak <60271095+zeel-pathak@users.noreply.github.com>
This commit is contained in:
Rijk van Zanten
2022-07-15 17:41:49 -04:00
committed by GitHub
parent c691c4c7b2
commit 27cc3e1bec
41 changed files with 16235 additions and 45939 deletions

50
.github/actions/prepare/action.yml vendored Normal file
View File

@@ -0,0 +1,50 @@
name: Prepare
description: Install and build the app
inputs:
build:
description: 'Build the production bundle of the platform'
required: false
default: 'true'
runs:
using: 'composite'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 16
- uses: pnpm/action-setup@v2.0.1
name: Install pnpm
id: pnpm-install
with:
version: 7
run_install: false
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
shell: bash
run: pnpm install
- name: Build
if: inputs.build == 'true'
shell: bash
run: pnpm run -r --workspace-concurrency=1 build
env:
NODE_OPTIONS: --max_old_space_size=6144

38
.github/workflows/blackbox-main.yml vendored Normal file
View File

@@ -0,0 +1,38 @@
name: Blackbox Tests
on:
push:
branches:
- main
paths:
- api/**
env:
NODE_OPTIONS: --max_old_space_size=6144
jobs:
test:
name: All Databases
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Prepare
uses: ./.github/actions/prepare
- name: Install Oracle client
run: |
sudo apt update -y && sudo apt install -y alien libaio1 && \
wget https://download.oracle.com/otn_software/linux/instantclient/214000/$ORACLE_DL && \
sudo alien -i $ORACLE_DL
env:
ORACLE_DL: oracle-instantclient-basic-21.4.0.0.0-1.el8.x86_64.rpm
- name: Start Databases
shell: bash
run: docker compose -f tests-blackbox/docker-compose.yml up -d --quiet-pull --wait
- name: Run Tests
shell: bash
run: pnpm run -w test:blackbox

26
.github/workflows/blackbox-pr.yml vendored Normal file
View File

@@ -0,0 +1,26 @@
name: Blackbox Tests
on:
pull_request:
branches:
- main
paths:
- api/**
env:
NODE_OPTIONS: --max_old_space_size=6144
jobs:
test:
name: SQLite Only
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Prepare
uses: ./.github/actions/prepare
- name: Run Tests
shell: bash
run: TEST_DB=sqlite3 pnpm run -w test:blackbox

54
.github/workflows/check.yml vendored Normal file
View File

@@ -0,0 +1,54 @@
name: Check
on:
push:
branches:
- main
pull_request:
branches:
- main
env:
NODE_OPTIONS: --max_old_space_size=6144
jobs:
cancel:
name: Cancel Previous Runs
runs-on: ubuntu-latest
steps:
- name: Cancel
uses: styfle/cancel-workflow-action@0.9.1
with:
access_token: ${{ github.token }}
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Prepare
uses: ./.github/actions/prepare
- name: Run Linter
shell: bash
run: pnpm lint
unit:
name: Unit Tests
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Prepare
uses: ./.github/actions/prepare
- name: Run Tests
shell: bash
run: pnpm -r test
analyze:
name: CodeQL Analysis
uses: ./.github/workflows/codeql-analysis.yml

View File

@@ -1,111 +0,0 @@
# ### Continuous Integration
#
# Entrypoint for all CI related workflows
#
name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
pre_check:
name: Pre-Check
runs-on: ubuntu-latest
outputs:
# Returns 'true' if the whole workflow is skippable for one of the following reasons:
# - Exact same files have been successfully checked in older workflow run
# - Only files that do not require checks ('paths_ignore') have been changed and
# workflow run on previous commit has been successful (backtracking)
should_skip: ${{ steps.skip_check.outputs.should_skip }}
# Returns information about the defined filter in 'paths_filter'
paths_result: ${{ steps.skip_check.outputs.paths_result }}
steps:
- name: Check for skippable jobs
id: skip_check
# Switch back to fkirc/skip-duplicate-actions@master once https://github.com/fkirc/skip-duplicate-actions/pull/159 has been merged
uses: paescuj/skip-duplicate-actions@path-filters
# Don't skip any jobs if the pre-check should fail for any reason
# (setting this on step-level makes sure the pre-check will still be marked as 'passed',
# better solution pending at https://github.com/actions/toolkit/issues/399)
continue-on-error: true
with:
# Cancel outdated workflow runs
cancel_others: 'true'
# Ignore changes in the following files globally
paths_ignore: '["app/src/lang/translations/*.yaml"]'
# Paths filter
paths_filter: |
e2e_tests:
paths:
- 'api/**/*'
- 'tests/**/*'
- 'docker-compose.yml'
- '.github/workflows/{ci,e2e-tests}.yml'
e2e_blackbox_tests:
paths:
- 'api/**/*'
- 'tests-blackbox/**/*'
- 'docker-compose.yml'
- '.github/workflows/{ci,e2e-blackbox-tests}.yml'
e2e_blackbox_tests_updated:
paths:
- 'tests-blackbox/**/*'
# Workflows are called in every case and need to handle the value of should_skip themselves.
# This is needed to pass required checks on pull requests.
lint:
name: Lint
needs: pre_check
uses: directus/directus/.github/workflows/lint.yml@main
with:
should_skip: ${{ needs.pre_check.outputs.should_skip }}
codeql_analysis:
name: CodeQL Analysis
needs: pre_check
uses: directus/directus/.github/workflows/codeql-analysis.yml@main
with:
should_skip: ${{ needs.pre_check.outputs.should_skip }}
unit_tests:
name: Unit Tests
needs: pre_check
uses: directus/directus/.github/workflows/unit-tests.yml@main
with:
should_skip: ${{ needs.pre_check.outputs.should_skip }}
e2e_tests:
name: End-to-End Tests
needs: pre_check
uses: directus/directus/.github/workflows/e2e-tests.yml@main
with:
should_skip:
${{ needs.pre_check.outputs.should_skip == 'true' ||
fromJSON(needs.pre_check.outputs.paths_result).e2e_tests.should_skip }}
e2e_blackbox_tests:
name: End-to-End Blackbox Tests
needs: pre_check
uses: directus/directus/.github/workflows/e2e-blackbox-tests.yml@main
with:
should_skip:
${{ (github.event_name == 'pull_request' && fromJSON(needs.pre_check.outputs.paths_result).e2e_blackbox_tests_updated.should_skip) ||
needs.pre_check.outputs.should_skip == 'true' ||
fromJSON(needs.pre_check.outputs.paths_result).e2e_blackbox_tests.should_skip }}
e2e_blackbox_tests_quick:
name: End-to-End Blackbox Tests (Quick)
needs: pre_check
uses: directus/directus/.github/workflows/e2e-blackbox-tests-quick.yml@main
with:
should_skip:
${{ (github.event_name == 'pull_request' && !fromJSON(needs.pre_check.outputs.paths_result).e2e_blackbox_tests_updated.should_skip) ||
github.event_name == 'push' ||
needs.pre_check.outputs.should_skip == 'true' ||
fromJSON(needs.pre_check.outputs.paths_result).e2e_blackbox_tests.should_skip }}

View File

@@ -2,17 +2,15 @@ name: CodeQL Analysis
on:
workflow_call:
inputs:
should_skip:
required: false
type: string
schedule:
- cron: '42 23 * * 5'
env:
NODE_OPTIONS: --max_old_space_size=6144
jobs:
analyze:
name: Analyze
if: inputs.should_skip != 'true'
runs-on: ubuntu-latest
permissions:
actions: read
@@ -24,16 +22,18 @@ jobs:
language:
- javascript
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v3
- name: Prepare
uses: ./.github/actions/prepare
with:
build: 'false'
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
config-file: ./.github/codeql/codeql-config.yml
- name: Autobuild
uses: github/codeql-action/autobuild@v2
- name: Perform CodeQL analysis
uses: github/codeql-action/analyze@v2

View File

@@ -1,51 +0,0 @@
name: End-to-End Blackbox Tests (Quick)
on:
workflow_dispatch:
workflow_call:
inputs:
should_skip:
required: false
type: string
jobs:
test:
name: Test
if: inputs.should_skip != 'true'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version:
- '16'
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: npm
- name: Install dependencies
run: npm ci --prefer-offline
- name: Build packages
run: npm run build:api
- name: Start databases
run: docker compose -f tests-blackbox/docker-compose.yml up -d --quiet-pull --wait
- name: Run tests
run: TEST_DB=sqlite3,postgres npm run test:blackbox
result:
name: Result
if: inputs.should_skip != 'true' && always()
runs-on: ubuntu-latest
needs: test
steps:
- name: Mark result as failed
if: needs.test.result != 'success'
run: exit 1

View File

@@ -1,59 +0,0 @@
name: End-to-End Blackbox Tests
on:
workflow_dispatch:
workflow_call:
inputs:
should_skip:
required: false
type: string
jobs:
test:
name: Test
if: inputs.should_skip != 'true'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version:
- '16'
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: npm
- name: Install dependencies
run: npm ci --prefer-offline
- name: Build packages
run: npm run build:api
- name: Install oracle client
run: |
sudo apt update -y && sudo apt install -y alien libaio1 && \
wget https://download.oracle.com/otn_software/linux/instantclient/214000/$ORACLE_DL && \
sudo alien -i $ORACLE_DL
env:
ORACLE_DL: oracle-instantclient-basic-21.4.0.0.0-1.el8.x86_64.rpm
- name: Start databases
run: docker compose -f tests-blackbox/docker-compose.yml up -d --quiet-pull --wait
- name: Run tests
run: npm run test:blackbox
result:
name: Result
if: inputs.should_skip != 'true' && always()
runs-on: ubuntu-latest
needs: test
steps:
- name: Mark result as failed
if: needs.test.result != 'success'
run: exit 1

View File

@@ -1,59 +0,0 @@
name: End-to-End Tests
on:
workflow_dispatch:
workflow_call:
inputs:
should_skip:
required: false
type: string
jobs:
test:
name: Test
if: inputs.should_skip != 'true'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version:
- '16'
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: npm
- name: Install dependencies
run: npm ci --prefer-offline
- name: Build packages
run: npm run build:api
- name: Install oracle client
run: |
sudo apt update -y && sudo apt install -y alien libaio1 && \
wget https://download.oracle.com/otn_software/linux/instantclient/214000/$ORACLE_DL && \
sudo alien -i $ORACLE_DL
env:
ORACLE_DL: oracle-instantclient-basic-21.4.0.0.0-1.el8.x86_64.rpm
- name: Start databases
run: docker compose -f tests/docker-compose.yml up -d --quiet-pull --wait
- name: Run tests
run: npm run test:e2e
result:
name: Result
if: inputs.should_skip != 'true' && always()
runs-on: ubuntu-latest
needs: test
steps:
- name: Mark result as failed
if: needs.test.result != 'success'
run: exit 1

View File

@@ -1,29 +0,0 @@
name: Lint
on:
workflow_call:
inputs:
should_skip:
required: false
type: string
jobs:
lint:
name: Lint
if: inputs.should_skip != 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '16'
cache: npm
- name: Install dependencies
run: npm ci --workspaces=false --prefer-offline
- name: Run linters
run: npm run lint

View File

@@ -8,7 +8,7 @@ on:
env:
GHCR_IMAGE: ghcr.io/${{ github.repository }}
DOCKERHUB_IMAGE: ${{ github.repository }}
NODE_OPTIONS: --max_old_space_size=8192
NODE_OPTIONS: --max_old_space_size=6144
jobs:
create-release:
@@ -35,24 +35,14 @@ jobs:
name: Build Packages
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '16.15'
cache: npm
- name: Setup NPM cache
uses: c-hive/gha-npm-cache@v1
- name: Install dependencies
run: npm ci
- name: Prepare
uses: ./.github/actions/prepare
- name: Build
run: |
npm run build
node docker/pack
- name: Cache build artifacts
@@ -78,19 +68,28 @@ jobs:
key: build-artifacts-${{ github.sha }}
- name: Setup Node.js
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: '16.15'
registry-url: https://registry.npmjs.org
cache: npm
- uses: pnpm/action-setup@v2.0.1
name: Install pnpm
id: pnpm-install
with:
version: 7
run_install: false
- name: Install dependencies
run: npm ci
run: pnpm i
- name: Publish packages to NPM
run: npx lerna publish from-git --no-verify-access --yes
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
pnpm config set "//registry.npmjs.org/:_authToken" "${NPM_TOKEN}"
pnpm -r publish --access=public --no-git-checks
build-images:
name: Build Images

View File

@@ -4,7 +4,6 @@ on:
push:
branches:
- main
# Ensures this workflow only runs when the readme.md or workflow file itself changes
paths:
- readme.md
- .github/workflows/sync-dockerhub-readme.yml

View File

@@ -1,48 +0,0 @@
name: Unit Tests
on:
workflow_call:
inputs:
should_skip:
required: false
type: string
jobs:
test:
name: Test
if: inputs.should_skip != 'true'
runs-on: ubuntu-latest
strategy:
matrix:
node-version:
- '16'
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: npm
- name: Install dependencies
run: npm ci --prefer-offline
- name: Build packages
run: npm run build:api
- name: Run tests
run: npm run test
env:
SECRET: TEST_SECRET
result:
name: Result
if: inputs.should_skip != 'true' && always()
runs-on: ubuntu-latest
needs: test
steps:
- name: Mark result as failed
if: needs.test.result != 'success'
run: exit 1

View File

@@ -7,6 +7,8 @@ module.exports = {
roots: ['<rootDir>/tests', '<rootDir>/src'],
verbose: true,
setupFiles: ['dotenv/config'],
testURL: process.env.TEST_URL || 'http://localhost',
collectCoverageFrom: ['src/**/*.ts'],
testEnvironmentOptions: {
url: process.env.TEST_URL || 'http://localhost',
},
};

View File

@@ -58,7 +58,7 @@
},
"scripts": {
"start": "npx directus start",
"prebuild": "npm run cleanup",
"prebuild": "pnpm cleanup",
"build": "tsc --build && copyfiles \"src/**/*.*\" -e \"src/**/*.ts\" -u 1 dist",
"cleanup": "rimraf dist",
"dev": "cross-env NODE_ENV=development SERVE_APP=false ts-node-dev --files --transpile-only --respawn --watch \".env\" --inspect=0 --exit-child -- src/start.ts",
@@ -77,16 +77,16 @@
],
"dependencies": {
"@aws-sdk/client-ses": "^3.107.0",
"@directus/app": "9.14.1",
"@directus/drive": "9.14.1",
"@directus/drive-azure": "9.14.1",
"@directus/drive-gcs": "9.14.1",
"@directus/drive-s3": "9.14.1",
"@directus/extensions-sdk": "9.14.1",
"@directus/format-title": "9.14.1",
"@directus/schema": "9.14.1",
"@directus/shared": "9.14.1",
"@directus/specs": "9.14.1",
"@directus/app": "workspace:*",
"@directus/drive": "workspace:*",
"@directus/drive-azure": "workspace:*",
"@directus/drive-gcs": "workspace:*",
"@directus/drive-s3": "workspace:*",
"@directus/extensions-sdk": "^9.14.1",
"@directus/format-title": "^9.15.0",
"@directus/schema": "workspace:*",
"@directus/shared": "workspace:*",
"@directus/specs": "workspace:*",
"@godaddy/terminus": "^4.10.2",
"@rollup/plugin-alias": "^3.1.9",
"@rollup/plugin-virtual": "^2.1.0",
@@ -170,28 +170,32 @@
"memcached": "^2.2.2",
"mysql": "^2.18.1",
"nodemailer-mailgun-transport": "^2.1.4",
"oracledb": "5.3.0",
"pg": "^8.7.3",
"sqlite3": "^5.0.8",
"tedious": "^13.0.0"
},
"gitHead": "24621f3934dc77eb23441331040ed13c676ceffd",
"devDependencies": {
"@otplib/preset-default": "^12.0.1",
"@types/async": "3.2.13",
"@types/body-parser": "1.19.2",
"@types/busboy": "1.5.0",
"@types/bytes": "3.1.1",
"@types/cookie-parser": "1.4.3",
"@types/cors": "2.8.12",
"@types/deep-diff": "1.0.1",
"@types/destroy": "1.0.0",
"@types/express": "4.17.13",
"@types/express-pino-logger": "4.0.3",
"@types/express-serve-static-core": "^4.17.29",
"@types/express-session": "1.17.4",
"@types/fast-redact": "^3.0.1",
"@types/flat": "5.0.2",
"@types/fs-extra": "9.0.13",
"@types/inquirer": "8.2.1",
"@types/ioredis": "^4.28.10",
"@types/jest": "27.4.1",
"@types/jest": "27.5.2",
"@types/js-yaml": "4.0.5",
"@types/json2csv": "5.0.3",
"@types/jsonwebtoken": "8.5.8",
@@ -218,9 +222,11 @@
"copyfiles": "2.4.1",
"cross-env": "7.0.3",
"form-data": "^4.0.0",
"jest": "27.5.1",
"jest": "28.1.2",
"knex-mock-client": "1.8.4",
"ts-jest": "27.1.3",
"rimraf": "3.0.2",
"ts-jest": "28.0.5",
"ts-node": "^10.8.2",
"ts-node-dev": "1.1.8",
"typescript": "4.7.3"
}

View File

@@ -3,7 +3,7 @@ import execa from 'execa';
import inquirer from 'inquirer';
import { Knex } from 'knex';
import ora from 'ora';
import { v4 as uuidV4 } from 'uuid';
import { v4 as uuid } from 'uuid';
import Joi from 'joi';
import runMigrations from '../../../database/migrations/run';
import runSeed from '../../../database/seeds/run';
@@ -97,8 +97,8 @@ export default async function init(): Promise<void> {
firstUser.password = await generateHash(firstUser.password);
const userID = uuidV4();
const roleID = uuidV4();
const userID = uuid();
const roleID = uuid();
await db('directus_roles').insert({
id: roleID,

View File

@@ -3,7 +3,7 @@ import { Liquid } from 'liquidjs';
import { nanoid } from 'nanoid';
import path from 'path';
import { promisify } from 'util';
import { v4 as uuidv4 } from 'uuid';
import { v4 as uuid } from 'uuid';
import { Credentials } from '../create-db-connection';
import { drivers } from '../drivers';
@@ -18,7 +18,7 @@ const liquidEngine = new Liquid({
const defaults = {
security: {
KEY: uuidv4(),
KEY: uuid(),
SECRET: nanoid(32),
},
};

View File

@@ -1,6 +1,6 @@
import { parseJSON, toArray } from '@directus/shared/utils';
import { Knex } from 'knex';
import { v4 as uuidv4 } from 'uuid';
import { v4 as uuid } from 'uuid';
export async function up(knex: Knex): Promise<void> {
await knex.schema.createTable('directus_flows', (table) => {
@@ -39,7 +39,7 @@ export async function up(knex: Knex): Promise<void> {
const operations = [];
for (const webhook of webhooks) {
const flowID = uuidv4();
const flowID = uuid();
flows.push({
id: flowID,
@@ -55,7 +55,7 @@ export async function up(knex: Knex): Promise<void> {
});
operations.push({
id: uuidv4(),
id: uuid(),
name: 'Request',
key: 'request',
type: 'request',

View File

@@ -80,11 +80,11 @@ export class ImportService {
return new Promise<void>((resolve, reject) => {
stream.pipe(extractJSON);
extractJSON.on('data', ({ value }) => {
extractJSON.on('data', ({ value }: Record<string, any>) => {
saveQueue.push(value);
});
extractJSON.on('error', (err) => {
extractJSON.on('error', (err: any) => {
destroyStream(stream);
destroyStream(extractJSON);
@@ -140,7 +140,7 @@ export class ImportService {
saveQueue.push(obj);
})
.on('error', (err) => {
.on('error', (err: any) => {
destroyStream(stream);
reject(new InvalidPayloadException(err.message));
})

View File

@@ -5,7 +5,7 @@ import { unflatten } from 'flat';
import Joi from 'joi';
import { Knex } from 'knex';
import { clone, cloneDeep, isNil, isObject, isPlainObject, omit, pick } from 'lodash';
import { v4 as uuidv4 } from 'uuid';
import { v4 as uuid } from 'uuid';
import { parse as wktToGeoJSON } from 'wellknown';
import getDatabase from '../database';
import { getHelpers, Helpers } from '../database/helpers';
@@ -59,7 +59,7 @@ export class PayloadService {
},
async uuid({ action, value }) {
if (action === 'create' && !value) {
return uuidv4();
return uuid();
}
return value;

View File

@@ -11,7 +11,8 @@
"lib": ["es2019"],
"skipLibCheck": true,
"declaration": true,
"resolveJsonModule": true
"resolveJsonModule": true,
"types": ["jest"]
},
"exclude": ["node_modules", "dist", "extensions", "tests"]
}

View File

@@ -31,9 +31,9 @@
"gitHead": "24621f3934dc77eb23441331040ed13c676ceffd",
"devDependencies": {
"@directus/docs": "^9.13.2",
"@directus/extensions-sdk": "9.14.1",
"@directus/format-title": "9.14.1",
"@directus/shared": "9.14.1",
"@directus/extensions-sdk": "^9.14.1",
"@directus/format-title": "^9.15.0",
"@directus/shared": "workspace:*",
"@fortawesome/fontawesome-svg-core": "1.2.36",
"@fortawesome/free-brands-svg-icons": "5.15.4",
"@fullcalendar/core": "5.11.0",
@@ -59,7 +59,7 @@
"@types/dompurify": "2.3.1",
"@types/file-saver": "^2.0.5",
"@types/geojson": "7946.0.8",
"@types/jest": "27.4.0",
"@types/jest": "28.1.4",
"@types/json2csv": "^5.0.3",
"@types/lodash": "4.14.177",
"@types/mapbox__mapbox-gl-draw": "1.2.3",
@@ -75,30 +75,41 @@
"apexcharts": "3.30.0",
"axios": "0.24.0",
"base-64": "1.0.0",
"bytes": "^3.1.2",
"camelcase": "^7.0.0",
"caret-pos": "2.0.0",
"codemirror": "5.64.0",
"color": "^4.2.3",
"copyfiles": "2.4.1",
"cropperjs": "1.5.12",
"date-fns": "2.24.0",
"diacritics": "1.3.0",
"diff": "^5.1.0",
"dompurify": "2.3.3",
"escape-string-regexp": "5.0.0",
"file-saver": "^2.0.5",
"flatpickr": "4.6.9",
"front-matter": "4.0.2",
"geojson": "^0.5.0",
"highlight.js": "^11.5.1",
"html-entities": "2.3.2",
"jest": "27.4.7",
"jest": "28.1.2",
"joi": "^17.6.0",
"json-to-graphql-query": "^2.2.4",
"json2csv": "^5.0.7",
"jsonlint-mod": "1.7.6",
"lodash": "^4.17.21",
"mapbox-gl": "^2.9.1",
"maplibre-gl": "1.15.2",
"markdown-it": "^13.0.1",
"markdown-it-anchor": "^8.6.4",
"markdown-it-container": "^3.0.0",
"markdown-it-table-of-contents": "^0.6.0",
"marked": "4.0.10",
"micromustache": "8.0.3",
"mime": "3.0.0",
"mitt": "3.0.0",
"ms": "^2.1.3",
"nanoid": "3.1.30",
"p-queue": "7.1.0",
"pinia": "2.0.14",
@@ -106,9 +117,11 @@
"pretty-ms": "7.0.1",
"qrcode": "1.4.4",
"rimraf": "3.0.2",
"rollup": "^2.75.6",
"sass": "1.43.4",
"tinymce": "5.10.2",
"ts-jest": "27.1.3",
"ts-jest": "28.0.5",
"tslib": "^2.4.0",
"typescript": "4.7.3",
"vite": "2.9.9",
"vite-plugin-vue-markdown": "0.1.1",

View File

@@ -15,7 +15,8 @@
"types": ["vite/client", "jest"],
"paths": {
"@/*": ["src/*"],
"preact/*": ["stub/empty.d.ts"]
"preact/*": ["stub/empty.d.ts"],
"tslib": ["node_modules/tslib/tslib.d.ts"]
},
"lib": ["esnext", "dom", "dom.iterable", "scripthost"]
},

View File

@@ -2,9 +2,10 @@ const { execSync } = require('child_process');
const { writeFileSync, mkdirSync, existsSync } = require('fs');
const path = require('path');
const lernaListResult = execSync('npx lerna list --json'); //The "proper" way to do this with --include-dependencies and --scope won't work here because it includes devDependencies!
const packagesInWorkSpace = execSync('pnpm ls --depth -1 -r --json');
const list = JSON.parse(String(packagesInWorkSpace)).filter((pkg) => pkg.name !== 'directus-monorepo');
const list = JSON.parse(String(lernaListResult));
const apiPackageJson = require(path.resolve(__dirname, '../api/package.json'));
const projectPackageJson = {
@@ -20,15 +21,19 @@ if (!existsSync('dist')) {
mkdirSync('dist');
}
const distFolder = path.resolve(__dirname, '..', 'dist');
function addPackageRecursive(package) {
const tarName = String(
execSync(`npm pack ${package.location}`, { cwd: path.resolve(__dirname, '..', 'dist') })
).trim();
const tarName = String(execSync(`pnpm -F ${package.name} exec pnpm pack --pack-destination ${distFolder}`)).trim();
projectPackageJson.dependencies[package.name] = `file:${tarName}`;
const packageJson = require(path.join(package.location, 'package.json'));
const packageJson = require(path.join(package.path, 'package.json'));
Object.keys(packageJson.dependencies || {}).forEach((dependencyName) => {
if (!projectPackageJson.dependencies[dependencyName]) {
const package = list.find((list) => list.name === dependencyName);
if (package) {
addPackageRecursive(package);
}

View File

@@ -1,17 +0,0 @@
{
"packages": [
"packages/*",
"app",
"docs",
"api"
],
"version": "9.14.1",
"command": {
"bootstrap": {
"npmClientArgs": [
"--no-package-lock",
"--legacy-peer-deps"
]
}
}
}

45406
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,74 +1,27 @@
{
"name": "directus-monorepo",
"private": true,
"version": "9.14.1",
"workspaces": [
"./app",
"./api",
"./packages/*"
],
"scripts": {
"lint": "npm-run-all --parallel --continue-on-error lint:*",
"lint:eslint": "eslint .",
"lint": "eslint .",
"format": "prettier --write \"**/*.{js,ts,vue,md,yaml}\"",
"dev": "lerna run dev --stream --parallel",
"build": "lerna run build",
"build:api": "lerna run build --ignore @directus/app",
"pack": "node docker/pack",
"release": "lerna version --force-publish --exact",
"test": "lerna run test",
"test:e2e": "jest tests -c tests/jest.config.js",
"test:e2e:watch": "npm run test:e2e -- --watch",
"test:e2e:watch": "jest tests -c tests/jest.config.js --watch",
"posttest:e2e:watch": "ts-node --project ./tests/tsconfig.json --transpile-only ./tests/setup/teardown.ts",
"test:blackbox": "jest tests -c tests-blackbox/jest.config.js",
"test:blackbox:watch": "npm run test:blackbox -- --watch",
"posttest:blackbox:watch": "ts-node --project ./-blackbox/tsconfig.json --transpile-only ./-blackbox/setup/teardown.ts",
"test:blackbox:watch": "jest tests -c tests-blackbox/jest.config.js --watch",
"posttest:blackbox:watch": "ts-node --project ./tests-blackbox/tsconfig.json --transpile-only ./tests-blackbox/setup/teardown.ts",
"cli": "cross-env NODE_ENV=development SERVE_APP=false DOTENV_CONFIG_PATH=api/.env ts-node -r dotenv/config --script-mode --transpile-only api/src/cli/run.ts"
},
"engines": {
"node": ">=16.0.0",
"npm": ">=8.5.0"
},
"devDependencies": {
"@directus/app": "^9.13.0",
"@types/dockerode": "3.3.0",
"@types/jest": "27.4.1",
"@types/listr": "0.14.4",
"@types/node": "16.11.9",
"@types/seedrandom": "^3.0.2",
"@types/supertest": "2.0.11",
"@typescript-eslint/eslint-plugin": "5.27.0",
"@typescript-eslint/parser": "5.27.0",
"axios": "0.24.0",
"dockerode": "3.3.1",
"eslint": "^8.17.0",
"eslint-config-prettier": "8.5.0",
"eslint-plugin-prettier": "4.0.0",
"eslint-plugin-vue": "9.1.0",
"globby": "11.0.4",
"jest": "27.5.1",
"knex": "2.1.0",
"lerna": "4.0.0",
"lint-staged": "11.2.6",
"listr": "0.14.3",
"markdown-it-anchor": "^8.6.4",
"markdown-it-container": "^3.0.0",
"mysql": "2.18.1",
"nanoid": "3.1.30",
"npm-run-all": "4.1.5",
"pg": "8.7.1",
"postcss": "^8.4.14",
"prettier": "2.6.2",
"seedrandom": "^3.0.5",
"simple-git-hooks": "2.8.0",
"sqlite3": "5.0.6",
"supertest": "6.1.6",
"tedious": "13.2.0",
"ts-jest": "27.1.3",
"ts-node": "10.4.0"
},
"optionalDependencies": {
"oracledb": "5.3.0"
},
"simple-git-hooks": {
"pre-commit": "npx lint-staged"
},
@@ -79,5 +32,36 @@
"volta": {
"node": "16.15.0",
"npm": "8.10.0"
},
"devDependencies": {
"@directus/shared": "workspace:*",
"@types/jest": "27.5.2",
"@types/listr": "^0.14.4",
"@types/lodash": "^4.14.182",
"@types/seedrandom": "^3.0.2",
"@types/supertest": "2.0.12",
"@types/uuid": "8.3.4",
"@typescript-eslint/eslint-plugin": "^5.30.5",
"@typescript-eslint/parser": "^5.30.5",
"axios": "^0.27.2",
"cross-env": "7.0.3",
"eslint": "^8.19.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-vue": "^9.2.0",
"globby": "^11.0.4",
"jest": "28.1.2",
"jest-environment-node": "^28.1.2",
"knex": "^2.1.0",
"lint-staged": "^13.0.3",
"listr": "^0.14.3",
"lodash": "^4.17.21",
"prettier": "2.4.1",
"seedrandom": "^3.0.5",
"simple-git-hooks": "^2.8.0",
"supertest": "^6.2.3",
"ts-jest": "28.0.5",
"typescript": "^4.7.4",
"uuid": "^8.3.2"
}
}

View File

@@ -28,7 +28,7 @@
"cleanup:coverage": "rimraf ./coverage",
"test:watch": "jest --coverage --watchAll",
"test": "jest --coverage",
"dev": "npm run build -- -w --preserveWatchOutput --incremental"
"dev": "pnpm build -w --preserveWatchOutput --incremental"
},
"author": "Robin Grundvåg <robgru52@gmail.com>",
"contributors": [
@@ -39,7 +39,7 @@
],
"dependencies": {
"@azure/storage-blob": "^12.6.0",
"@directus/drive": "9.14.1",
"@directus/drive": "workspace:*",
"normalize-path": "^3.0.0"
},
"devDependencies": {

View File

@@ -34,10 +34,10 @@
"cleanup:coverage": "rimraf ./coverage",
"test:watch": "jest --coverage --watchAll",
"test": "jest --coverage",
"dev": "npm run build -- -w --preserveWatchOutput --incremental"
"dev": "pnpm build -w --preserveWatchOutput --incremental"
},
"dependencies": {
"@directus/drive": "9.14.1",
"@directus/drive": "workspace:*",
"@google-cloud/storage": "^5.8.5",
"lodash": "4.17.21",
"normalize-path": "^3.0.0"
@@ -46,6 +46,7 @@
"@lukeed/uuid": "2.0.0",
"@types/fs-extra": "9.0.13",
"@types/jest": "27.0.3",
"@types/lodash": "^4.14.182",
"@types/node": "16.11.9",
"@types/normalize-path": "3.0.0",
"dotenv": "10.0.0",

View File

@@ -35,10 +35,10 @@
"cleanup:coverage": "rimraf ./coverage",
"test:watch": "jest --coverage --watchAll",
"test": "jest --coverage",
"dev": "npm run build -- -w --preserveWatchOutput --incremental"
"dev": "pnpm build -w --preserveWatchOutput --incremental"
},
"dependencies": {
"@directus/drive": "9.14.1",
"@directus/drive": "workspace:*",
"aws-sdk": "^2.928.0",
"normalize-path": "^3.0.0"
},

View File

@@ -36,7 +36,7 @@
"cleanup:coverage": "rimraf ./coverage",
"test:watch": "jest --coverage --watchAll",
"test": "jest --coverage",
"dev": "npm run build -- -w --preserveWatchOutput --incremental"
"dev": "pnpm build -w --preserveWatchOutput --incremental"
},
"dependencies": {
"fs-extra": "^10.0.0",

View File

@@ -20,11 +20,11 @@
"directus-extension": "cli.js"
},
"scripts": {
"build": "run-p \"build:* -- {@}\" --",
"build": "run-p \"build:* {@}\"",
"build:esm": "tsc --project ./tsconfig.json --module ES2015 --outDir ./dist/esm",
"build:cjs": "tsc --project ./tsconfig.json --module CommonJS --outDir ./dist/cjs",
"cleanup": "rimraf ./dist",
"dev": "npm run build -- -w --preserveWatchOutput --incremental"
"dev": "npm run build -w --preserveWatchOutput --incremental"
},
"engines": {
"node": ">=12.20.0"
@@ -50,6 +50,7 @@
"rollup-plugin-vue": "^6.0.0"
},
"devDependencies": {
"@types/fs-extra": "9.0.13",
"npm-run-all": "4.1.5",
"rimraf": "3.0.2",
"typescript": "4.5.2"

View File

@@ -47,6 +47,7 @@
"typescript": "4.5.2"
},
"dependencies": {
"knex": "^2.1.0",
"knex-schema-inspector": "^2.0.3",
"lodash": "^4.17.21"
},

View File

@@ -4,7 +4,9 @@ module.exports = {
preset: 'ts-jest',
verbose: true,
setupFiles: ['dotenv/config'],
testURL: process.env.TEST_URL || 'http://localhost',
testEnvironmentOptions: {
url: process.env.TEST_URL || 'http://localhost',
},
collectCoverageFrom: ['src/**/*.ts'],
testPathIgnorePatterns: ['dist'],
};

View File

@@ -35,14 +35,13 @@
},
"sideEffects": false,
"scripts": {
"build": "run-p \"build:* -- {@}\" --",
"build": "run-p \"build:* {@}\"",
"build:esm": "tsc --project ./tsconfig.json --module ES2015 --outDir ./dist/esm",
"build:cjs": "tsc --project ./tsconfig.json --module CommonJS --outDir ./dist/cjs",
"cleanup": "rimraf ./dist",
"dev": "npm run build -- -w --preserveWatchOutput --incremental",
"dev": "pnpm build -- -w --preserveWatchOutput --incremental",
"test": "jest",
"test:watch": "jest --watchAll",
"prepublishOnly": "npm run cleanup && npm run build"
"test:watch": "jest --watchAll"
},
"author": "Nicola Krumschmidt",
"maintainers": [
@@ -50,31 +49,35 @@
],
"gitHead": "24621f3934dc77eb23441331040ed13c676ceffd",
"dependencies": {
"axios": "^0.27.2",
"date-fns": "2.24.0",
"express": "^4.18.1",
"fs-extra": "10.0.0",
"geojson": "^0.5.0",
"joi": "17.4.2",
"knex": "^2.1.0",
"knex-schema-inspector": "^2.0.1",
"lodash": "4.17.21",
"micromustache": "^8.0.3"
},
"peerDependencies": {
"@types/express": "*",
"@types/geojson": "*",
"@types/pino": "*",
"axios": "*",
"express": "*",
"geojson": "*",
"knex": "*",
"knex-schema-inspector": "*",
"pino": "*",
"vue": "3",
"vue-i18n": "9",
"vue-router": "4"
"micromustache": "^8.0.3",
"pino": "6.13.3",
"vue": "3.2.36",
"vue-i18n": "9.1.10",
"vue-router": "4.0.15"
},
"devDependencies": {
"@jest/types": "^28.1.3",
"@types/express": "4.17.13",
"@types/fs-extra": "9.0.13",
"@types/geojson": "7946.0.8",
"@types/jest": "^28.1.4",
"@types/lodash": "^4.14.182",
"@types/pino": "6.3.12",
"@types/tmp": "^0.2.3",
"jest": "^28.1.2",
"npm-run-all": "4.1.5",
"rimraf": "3.0.2",
"tmp": "0.2.1",
"ts-jest": "^28.0.5",
"typescript": "4.5.2"
}
}

View File

@@ -44,6 +44,7 @@
"gitHead": "24621f3934dc77eb23441331040ed13c676ceffd",
"devDependencies": {
"npm-watch": "0.11.0",
"openapi-types": "^12.0.0",
"swagger-cli": "4.0.4",
"swagger-ui-watcher": "2.1.12"
},

15885
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

4
pnpm-workspace.yaml Normal file
View File

@@ -0,0 +1,4 @@
packages:
- app
- api
- packages/*

View File

@@ -13,7 +13,7 @@ declare global {
class CustomEnvironment extends NodeEnvironment {
constructor(config: any, context: any) {
super(config);
super(config, context);
this.global.testFilePath = String(context.testPath).split('tests-blackbox')[1]!;
}

View File

@@ -6,14 +6,14 @@ Make sure the containers for the databases are running by running `docker compos
## Running tests locally
Run `npm run test:e2e` to run the e2e tests for every supported database vendor.
Run `pnpm test:e2e` to run the e2e tests for every supported database vendor.
### Testing a specific database
Provide a csv of database drivers in the `TEST_DB` environment variable to test specific databases:
```
TEST_DB=cockroachdb npm run test:e2e
TEST_DB=cockroachdb pnpm test:e2e
```
### Using an existing Directus instance
@@ -22,7 +22,7 @@ The test suite will spin up a fresh copy of the Directus API from the current bu
Directus, set the `TEST_LOCAL` flag:
```
TEST_DB=cockroachdb TEST_LOCAL=true npm run test:e2e
TEST_DB=cockroachdb TEST_LOCAL=true pnpm test:e2e
```
This will use `localhost:8055` as the URL for every test. Note: make sure to connect your local Directus database
@@ -30,6 +30,6 @@ instance to the test database container found in docker-compose in this folder.
### Watching for (test) changes
Use `npm run test:e2e:watch` to enable Jest's `--watch` mode, especially useful in combination with the flags above.
Use `pnpm test:e2e:watch` to enable Jest's `--watch` mode, especially useful in combination with the flags above.
This _does not_ watch changes to Directus; it only watches changes to the tests.

View File

@@ -12,7 +12,7 @@ declare global {
class CustomEnvironment extends NodeEnvironment {
constructor(config: any, context: any) {
super(config);
super(config, context);
this.global.testFilePath = String(context.testPath).split('tests')[1]!;
}