Skip to content

Commit

Permalink
Strapi (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
TriPSs authored Nov 21, 2023
2 parents db2afbb + 3597866 commit cd25928
Show file tree
Hide file tree
Showing 36 changed files with 8,934 additions and 10,482 deletions.
42 changes: 32 additions & 10 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ env:

jobs:

pr:
prepare-env:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -18,16 +18,41 @@ jobs:

- name: Cache node modules
id: cache
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: |
**/node_modules
key: ${{ env.DEPENDENCIES_CACHE }}-${{ hashFiles('yarn.lock') }}
key: cache-node-modules-${{ hashFiles('yarn.lock') }}

- name: yarn install
if: steps.cache.outputs.cache-hit != 'true'
run: yarn install

pr:
needs: prepare-env
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target: [ 'build', 'e2e' ]
steps:
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: 20.x

- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Cache node modules
id: cache
uses: actions/cache@v3
with:
path: |
**/node_modules
key: cache-node-modules-${{ hashFiles('yarn.lock') }}

- name: Derive appropriate SHAs for base and head for `nx affected` commands
uses: ./actions/set-shas
with:
Expand All @@ -39,16 +64,13 @@ jobs:
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
- name: nx affected:version
if: matrix.target == 'build'
uses: ./actions/run-many
with:
target: version

- name: nx affected:build
uses: ./actions/run-many
with:
target: build

- name: nx affected:e2e
- name: nx affected:${{ matrix.target }}
uses: ./actions/run-many
with:
target: e2e
target: ${{ matrix.target }}
parallel: 1
9 changes: 5 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ jobs:

- name: Cache node modules
id: cache
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: |
**/node_modules
key: ${{ env.DEPENDENCIES_CACHE }}-${{ hashFiles('yarn.lock') }}
key: cache-node-modules-${{ hashFiles('yarn.lock') }}

- name: yarn install
if: steps.cache.outputs.cache-hit != 'true'
Expand All @@ -39,11 +39,12 @@ jobs:
fetch-depth: 0

- name: Cache node modules
uses: actions/cache@v2
id: cache
uses: actions/cache@v3
with:
path: |
**/node_modules
key: ${{ env.DEPENDENCIES_CACHE }}-${{ hashFiles('yarn.lock') }}
key: cache-node-modules-${{ hashFiles('yarn.lock') }}

- name: GIT/NPM config
run: |
Expand Down
546 changes: 0 additions & 546 deletions .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs

This file was deleted.

874 changes: 0 additions & 874 deletions .yarn/releases/yarn-3.6.4.cjs

This file was deleted.

893 changes: 893 additions & 0 deletions .yarn/releases/yarn-4.0.2.cjs

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
nodeLinker: node-modules
compressionLevel: mixed

enableGlobalCache: false

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: "@yarnpkg/plugin-interactive-tools"
nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-3.6.4.cjs
yarnPath: .yarn/releases/yarn-4.0.2.cjs
15 changes: 15 additions & 0 deletions e2e/strapi-e2e/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
displayName: 'strapi-e2e',
preset: '../../jest.preset.js',
globals: {},
transform: {
'^.+\\.[tj]s$': [
'ts-jest',
{
tsconfig: '<rootDir>/tsconfig.spec.json'
}
]
},
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: '../../coverage/e2e/strapi-e2e'
}
18 changes: 18 additions & 0 deletions e2e/strapi-e2e/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "strapi-e2e",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"projectType": "application",
"sourceRoot": "e2e/strapi-e2e/src",
"targets": {
"e2e": {
"executor": "@nx/jest:jest",
"options": {
"jestConfig": "e2e/strapi-e2e/jest.config.js",
"runInBand": true
},
"dependsOn": ["strapi:build"]
}
},
"tags": [],
"implicitDependencies": ["strapi"]
}
37 changes: 37 additions & 0 deletions e2e/strapi-e2e/tests/strapi.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import {
checkFilesExist,
rmDist,
runNxCommandAsync
} from '@nx/plugin/testing'
import { ensureNxProject } from '../../utils/workspace'

describe('(e2e) strapi', () => {
beforeAll(() => ensureNxProject([
'@nx-extend/core:dist/packages/core',
'@nx-extend/strapi:dist/packages/strapi'
]))

const appName = 'test-strapi'

it('should be able to generate', async () => {
await runNxCommandAsync(`generate @nx-extend/strapi:init ${appName}`)

expect(() => checkFilesExist(
`${appName}/src/index.ts`
)).not.toThrow()
}, 300000)

it('should be able to build', async () => {
rmDist()
await runNxCommandAsync(`build ${appName}`)

expect(() => checkFilesExist(
`dist/${appName}/package.json`,
`dist/${appName}/config/admin.js`,
`dist/${appName}/config/api.js`,
`dist/${appName}/config/database.js`,
`dist/${appName}/src/index.js`,
`dist/${appName}/build/index.html`
)).not.toThrow()
}, 300000)
})
13 changes: 13 additions & 0 deletions e2e/strapi-e2e/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": "../../tsconfig.base.json",
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.e2e.json"
},
{
"path": "./tsconfig.spec.json"
}
]
}
9 changes: 9 additions & 0 deletions e2e/strapi-e2e/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["jest", "node"]
},
"include": ["**/*.spec.ts", "**/*.d.ts"]
}
17 changes: 10 additions & 7 deletions e2e/translations-e2e/tests/translations.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ import {
import { ensureNxProject } from '../../utils/workspace'

describe('translations e2e', () => {
beforeAll(() => {
ensureNxProject([
'@nx-extend/core:dist/packages/core',
'@nx-extend/translations:dist/packages/translations'
])
})

beforeAll(() => ensureNxProject([
'@nx-extend/core:dist/packages/core',
'@nx-extend/translations:dist/packages/translations'
]))

const appName = 'translations'
it('should be able to add', async () => {
Expand Down Expand Up @@ -81,7 +80,11 @@ describe('translations e2e', () => {
export default App
`)

await runNxCommandAsync(`extract-translations ${appName}`)
await runNxCommandAsync(`extract-translations ${appName}`, {
env: {
NX_EXTEND_COMMAND_USE_NPX: 'true'
}
})

expect(readJson(`${appName}/src/translations/en.json`)).toEqual({
'message-id': 'Message',
Expand Down
23 changes: 17 additions & 6 deletions e2e/utils/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import { mkdirSync } from 'fs'

function runNxNewCommand(localTmpDir: string) {
return execSync(
`node ${require.resolve(
'nx'
)} new proj --nx-workspace-root=${localTmpDir} --no-interactive --skip-install --collection=@nx/workspace --npmScope=proj --preset=apps`,
`npx nx new proj --nx-workspace-root=${localTmpDir} --no-interactive --skip-install --collection=@nx/workspace --npmScope=proj --preset=apps`,
{
cwd: localTmpDir
}
Expand All @@ -33,15 +31,28 @@ export function ensureNxProject(patchPlugins: string[] = []): void {
patchPackageJsonForPlugin(npmPackageName, pluginDistPath)
}

execSync('touch yarn.lock', {
execSync('rm -f yarn.lock package-lock.json && touch yarn.lock', {
cwd: tmpProjectPath,
stdio: 'inherit',
env: process.env
})
execSync('yarn', {

execSync('yarn set version berry', {
cwd: tmpProjectPath,
stdio: 'inherit',
env: process.env
})

// This fixes lock file changes in CI
execSync('yarn install --mode=update-lockfile', {
cwd: tmpProjectPath,
stdio: 'inherit',
env: process.env
})
}

execSync('yarn install --immutable', {
cwd: tmpProjectPath,
stdio: 'inherit',
env: process.env
})
}
26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
"@actions/core": "^1.10.1",
"@nx/devkit": "17.0.2",
"@nx/workspace": "17.0.2",
"@types/tar": "^6.1.7",
"axios": "^1.6.0",
"@types/tar": "^6.1.9",
"axios": "^1.6.2",
"crypto-js": "^4.2.0",
"deepmerge": "^4.3.1",
"rxjs-for-await": "^1.0.0",
Expand All @@ -46,7 +46,7 @@
"yargs": "^17.7.2"
},
"devDependencies": {
"@google-cloud/storage": "^7.5.0",
"@google-cloud/storage": "^7.6.0",
"@jamesives/github-pages-deploy-action": "^4.4.3",
"@jscutlery/semver": "^4.0.0",
"@nx/eslint-plugin": "17.0.2",
Expand All @@ -57,27 +57,27 @@
"@nx/react": "17.0.2",
"@nx/webpack": "17.0.2",
"@swc-node/register": "1.6.8",
"@swc/core": "1.3.95",
"@types/jest": "29.5.7",
"@types/node": "20.8.10",
"@types/shelljs": "^0.8.14",
"@types/yargs": "^17.0.29",
"@typescript-eslint/eslint-plugin": "6.9.1",
"@typescript-eslint/parser": "6.9.1",
"@swc/core": "1.3.96",
"@types/jest": "29.5.8",
"@types/node": "20.9.0",
"@types/shelljs": "^0.8.15",
"@types/yargs": "^17.0.31",
"@typescript-eslint/eslint-plugin": "6.11.0",
"@typescript-eslint/parser": "6.11.0",
"dotenv": "16.3.1",
"eslint": "8.52.0",
"eslint": "8.53.0",
"eslint-config-prettier": "9.0.0",
"eslint-plugin-simple-import-sort": "^10.0.0",
"express": "^4.18.2",
"husky": "^8.0.3",
"jest": "29.7.0",
"jest-environment-jsdom": "29.7.0",
"nx": "17.0.2",
"prettier": "3.0.3",
"prettier": "3.1.0",
"ts-jest": "29.1.1",
"ts-node": "10.9.1",
"tslint": "~6.1.3",
"typescript": "5.2.2"
},
"packageManager": "yarn@3.6.4"
"packageManager": "yarn@4.0.2"
}
14 changes: 14 additions & 0 deletions packages/core/src/utils/get-output-directory-from-build-target.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { ExecutorContext, parseTargetString, readTargetOptions } from '@nx/devkit'
import { readCachedProjectGraph } from '@nx/workspace/src/core/project-graph'

export function getOutputDirectoryFromBuildTarget(context: ExecutorContext, buildTarget: string): string | undefined {
const targetString = parseTargetString(buildTarget, readCachedProjectGraph())
const targetOptions = readTargetOptions(targetString, context)
const outputDirectory = targetOptions?.outputPath

if (!outputDirectory && targetOptions?.buildTarget) {
return getOutputDirectoryFromBuildTarget(context, targetOptions?.buildTarget)
}

return outputDirectory
}
1 change: 1 addition & 0 deletions packages/core/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ export * from './copy-file'
export * from './is-ci'
export * from './use-verbose-logging'
export * from './exec-package-manager-command'
export * from './get-output-directory-from-build-target'
2 changes: 1 addition & 1 deletion packages/firebase-hosting/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"license": "MIT",
"main": "src/index.js",
"dependencies": {
"firebase-tools": "^12.7.0"
"firebase-tools": "^12.9.0"
},
"builders": "./executors.json",
"generators": "./generators.json"
Expand Down
Loading

0 comments on commit cd25928

Please sign in to comment.