Skip to content

Commit

Permalink
Improvements v2 (#204)
Browse files Browse the repository at this point in the history
  • Loading branch information
TriPSs authored Dec 24, 2023
2 parents 88dba84 + 0b0f342 commit d018c63
Show file tree
Hide file tree
Showing 30 changed files with 913 additions and 506 deletions.
9 changes: 8 additions & 1 deletion .ncurc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,12 @@
"root": true,
"workspaces": true,
"packageManager": "yarn",
"format": ["group", "repo"]
"format": [
"group",
"repo"
],
"reject": [
"@nx/*",
"nx"
]
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
export default {
displayName: 'gcp-deployment-manager-e2e',
preset: '../../jest.preset.js',
globals: {},
Expand Down
2 changes: 1 addition & 1 deletion e2e/gcp-deployment-manager-e2e/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"e2e": {
"executor": "@nx/jest:jest",
"options": {
"jestConfig": "e2e/gcp-deployment-manager-e2e/jest.config.js",
"jestConfig": "e2e/gcp-deployment-manager-e2e/jest.config.ts",
"runInBand": true,
"passWithNoTests": false
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import {
checkFilesExist,
runNxCommandAsync
} from '@nx/plugin/testing'
import { checkFilesExist, runNxCommandAsync } from '@nx/plugin/testing'
import { ensureNxProject } from '../../utils/workspace'

describe('gcp-deployment-manager e2e', () => {
Expand All @@ -20,5 +17,5 @@ describe('gcp-deployment-manager e2e', () => {
expect(() => checkFilesExist(
`${appName}/src/deployment.yml`
)).not.toThrow()
}, 300000)
})
})
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
export default {
displayName: 'gcp-functions-e2e',
preset: '../../jest.preset.js',
globals: {},
Expand Down
2 changes: 1 addition & 1 deletion e2e/gcp-functions-e2e/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"e2e": {
"executor": "@nx/jest:jest",
"options": {
"jestConfig": "e2e/gcp-functions-e2e/jest.config.js",
"jestConfig": "e2e/gcp-functions-e2e/jest.config.ts",
"runInBand": true,
"passWithNoTests": false
},
Expand Down
15 changes: 6 additions & 9 deletions e2e/gcp-functions-e2e/tests/gcp-functions.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import {
checkFilesExist,
rmDist,
runNxCommandAsync
} from '@nx/plugin/testing'
import { checkFilesExist, rmDist } from '@nx/plugin/testing'
import { ensureNxProject } from '../../utils/workspace'
import { runNxCommandAsync } from '../../utils/run-nx-command-async'

describe('(e2e) gcp-functions', () => {
beforeAll(() => {
Expand All @@ -22,7 +19,7 @@ describe('(e2e) gcp-functions', () => {
`${appName}/src/main.ts`,
`${appName}/src/environments/production.yaml`
)).not.toThrow()
}, 300000)
})

it('should be able to build a function', async () => {
await runNxCommandAsync(`build ${appName}`)
Expand All @@ -31,7 +28,7 @@ describe('(e2e) gcp-functions', () => {
`dist/${appName}/main.js`,
`dist/${appName}/package.json`
)).not.toThrow()
}, 300000)
})

it('should be able to build a function and generate lock file', async () => {
rmDist()
Expand All @@ -42,7 +39,7 @@ describe('(e2e) gcp-functions', () => {
`dist/${appName}/package.json`,
`dist/${appName}/yarn.lock`
)).not.toThrow()
}, 300000)
})

it('should be able the runner', async () => {
const runnerName = 'functions-runner'
Expand All @@ -51,5 +48,5 @@ describe('(e2e) gcp-functions', () => {
expect(() => checkFilesExist(
`${runnerName}/src/main.ts`
)).not.toThrow()
}, 300000)
})
})
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
export default {
displayName: 'gcp-secrets-e2e',
preset: '../../jest.preset.js',
globals: {},
Expand Down
2 changes: 1 addition & 1 deletion e2e/gcp-secrets-e2e/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"e2e": {
"executor": "@nx/jest:jest",
"options": {
"jestConfig": "e2e/gcp-secrets-e2e/jest.config.js",
"jestConfig": "e2e/gcp-secrets-e2e/jest.config.ts",
"runInBand": true,
"passWithNoTests": false
},
Expand Down
10 changes: 3 additions & 7 deletions e2e/gcp-secrets-e2e/tests/gcp-secrets.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import {
checkFilesExist,
runNxCommandAsync,
uniq
} from '@nx/plugin/testing'

import { checkFilesExist, uniq } from '@nx/plugin/testing'
import { runNxCommandAsync } from '../../utils/run-nx-command-async'
import { ensureNxProject } from '../../utils/workspace'

describe('gcp-secrets e2e', () => {
Expand All @@ -23,5 +19,5 @@ describe('gcp-secrets e2e', () => {
`${appName}/src/secret-one.json`,
`${appName}/src/secret-two.json`
)).not.toThrow()
}, 300000)
})
})
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
export default {
displayName: 'react-email-e2e',
preset: '../../jest.preset.js',
globals: {},
Expand Down
2 changes: 1 addition & 1 deletion e2e/react-email-e2e/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"e2e": {
"executor": "@nx/jest:jest",
"options": {
"jestConfig": "e2e/react-email-e2e/jest.config.js",
"jestConfig": "e2e/react-email-e2e/jest.config.ts",
"runInBand": true,
"passWithNoTests": false
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`react email e2e should be able to export 1`] = `"<!DOCTYPE html PUBLIC \\"-//W3C//DTD XHTML 1.0 Transitional//EN\\" \\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\\"><html dir=\\"ltr\\" lang=\\"en\\"><a href=\\"https://example.com\\" style=\\"background:#000;color:#fff;padding:12px 20px 12px 20px;line-height:100%;text-decoration:none;display:inline-block;max-width:100%\\" target=\\"_blank\\"><span><!--[if mso]><i style=\\"letter-spacing: 20px;mso-font-width:-100%;mso-text-raise:18\\" hidden>&nbsp;</i><![endif]--></span><span style=\\"max-width:100%;display:inline-block;line-height:120%;mso-padding-alt:0px;mso-text-raise:9px\\">Click me</span><span><!--[if mso]><i style=\\"letter-spacing: 20px;mso-font-width:-100%\\" hidden>&nbsp;</i><![endif]--></span></a></html>"`;
exports[`react email e2e should be able to export 1`] = `"<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html dir="ltr" lang="en"><a href="https://example.com" style="background:#000;color:#fff;padding:12px 20px 12px 20px;line-height:100%;text-decoration:none;display:inline-block;max-width:100%" target="_blank"><span><!--[if mso]><i style="letter-spacing: 20px;mso-font-width:-100%;mso-text-raise:18" hidden>&nbsp;</i><![endif]--></span><span style="max-width:100%;display:inline-block;line-height:120%;mso-padding-alt:0px;mso-text-raise:9px">Click me</span><span><!--[if mso]><i style="letter-spacing: 20px;mso-font-width:-100%" hidden>&nbsp;</i><![endif]--></span></a></html>"`;
13 changes: 5 additions & 8 deletions e2e/react-email-e2e/tests/react-email.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import {
runNxCommandAsync,
readJson,
updateFile, readFile
} from '@nx/plugin/testing'
import { readJson, readFile } from '@nx/plugin/testing'
import { ensureNxProject } from '../../utils/workspace'
import { runNxCommandAsync } from '../../utils/run-nx-command-async'

describe('react email e2e', () => {

Expand All @@ -13,7 +10,7 @@ describe('react email e2e', () => {
]))

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

expect(readJson(`${appName}/project.json`).targets).toEqual(
Expand All @@ -37,11 +34,11 @@ describe('react email e2e', () => {
}
})
)
}, 300000)
})

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

expect(readFile(`dist/${appName}/index.html`)).toMatchSnapshot()
}, 300000)
})
})
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
export default {
displayName: 'strapi-e2e',
preset: '../../jest.preset.js',
globals: {},
Expand Down
2 changes: 1 addition & 1 deletion e2e/strapi-e2e/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"e2e": {
"executor": "@nx/jest:jest",
"options": {
"jestConfig": "e2e/strapi-e2e/jest.config.js",
"jestConfig": "e2e/strapi-e2e/jest.config.ts",
"runInBand": true,
"passWithNoTests": false
},
Expand Down
11 changes: 4 additions & 7 deletions e2e/strapi-e2e/tests/strapi.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import {
checkFilesExist,
rmDist,
runNxCommandAsync
} from '@nx/plugin/testing'
import { checkFilesExist, rmDist } from '@nx/plugin/testing'
import { ensureNxProject } from '../../utils/workspace'
import { runNxCommandAsync } from '../../utils/run-nx-command-async'

describe('(e2e) strapi', () => {
beforeAll(() => ensureNxProject([
Expand All @@ -19,7 +16,7 @@ describe('(e2e) strapi', () => {
expect(() => checkFilesExist(
`${appName}/src/index.ts`
)).not.toThrow()
}, 300000)
})

it('should be able to build', async () => {
rmDist()
Expand All @@ -33,5 +30,5 @@ describe('(e2e) strapi', () => {
`dist/${appName}/src/index.js`,
`dist/${appName}/build/index.html`
)).not.toThrow()
}, 300000)
})
})
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
export default {
displayName: 'translations-e2e',
preset: '../../jest.preset.js',
globals: {},
Expand Down
2 changes: 1 addition & 1 deletion e2e/translations-e2e/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"e2e": {
"executor": "@nx/jest:jest",
"options": {
"jestConfig": "e2e/translations-e2e/jest.config.js",
"jestConfig": "e2e/translations-e2e/jest.config.ts",
"runInBand": true,
"passWithNoTests": false
},
Expand Down
11 changes: 4 additions & 7 deletions e2e/translations-e2e/tests/translations.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import {
runNxCommandAsync,
readJson,
updateFile
} from '@nx/plugin/testing'
import { readJson, updateFile } from '@nx/plugin/testing'
import { ensureNxProject } from '../../utils/workspace'
import { runNxCommandAsync } from '../../utils/run-nx-command-async'

describe('translations e2e', () => {

Expand Down Expand Up @@ -52,7 +49,7 @@ describe('translations e2e', () => {
translatorOptions: {},
languages: ['en']
})
}, 300000)
})

it('should be able to extract translations', async () => {
updateFile(
Expand Down Expand Up @@ -90,5 +87,5 @@ describe('translations e2e', () => {
'message-id': 'Message',
'message-id-2': 'Message 2'
})
}, 300000)
})
})
18 changes: 18 additions & 0 deletions e2e/utils/run-nx-command-async.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { runNxCommandAsync as _runNxCommandAsync } from '@nx/plugin/testing'

export async function runNxCommandAsync(command: string, options: { env?: object } = {}): Promise<void> {
const { stdout, stderr } = await _runNxCommandAsync(`${command} --verbose`, {
silenceError: true,
env: {
CI: 'true',
YARN_ENABLE_HARDENED_MODE: '0',
YARN_ENABLE_IMMUTABLE_INSTALLS: 'false',
...options.env
}
})

console.log(stdout)
if (stderr) {
console.log(stderr)
}
}
6 changes: 6 additions & 0 deletions e2e/utils/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,10 @@ export function ensureNxProject(patchPlugins: string[] = []): void {
stdio: 'inherit',
env: process.env
})

execSync('echo "enableHardenedMode: false" >> .yarnrc.yml', {
cwd: tmpProjectPath,
stdio: 'inherit',
env: process.env
})
}
13 changes: 3 additions & 10 deletions jest.preset.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,7 @@ const nxPreset = require('@nx/jest/preset').default

module.exports = {
...nxPreset,
/* TODO: Update to latest Jest snapshotFormat
* By default Nx has kept the older style of Jest Snapshot formats
* to prevent breaking of any existing tests with snapshots.
* It's recommend you update to the latest format.
* You can do this by removing snapshotFormat property
* and running tests with --update-snapshot flag.
* Example: "nx affected --targets=test --update-snapshot"
* More info: https://jestjs.io/docs/upgrading-to-jest29#snapshot-format
*/
snapshotFormat: { escapeString: true, printBasicPrototype: true }
testTimeout: 350_000,
maxWorkers: 1,
testEnvironment: 'node'
}
34 changes: 17 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
},
"dependencies": {
"@actions/core": "^1.10.1",
"@nx/devkit": "17.2.0",
"@nx/workspace": "17.2.0",
"@nx/devkit": "17.2.7",
"@nx/workspace": "17.2.7",
"@types/tar": "^6.1.10",
"axios": "^1.6.2",
"crypto-js": "^4.2.0",
Expand All @@ -48,32 +48,32 @@
"devDependencies": {
"@google-cloud/storage": "^7.7.0",
"@jamesives/github-pages-deploy-action": "^4.5.0",
"@jscutlery/semver": "^4.1.0",
"@nx/eslint-plugin": "17.2.0",
"@nx/jest": "17.2.0",
"@nx/js": "17.2.0",
"@nx/node": "17.2.0",
"@nx/plugin": "17.2.0",
"@nx/react": "17.2.0",
"@nx/webpack": "17.2.0",
"@jscutlery/semver": "^4.2.0",
"@nx/eslint-plugin": "17.2.7",
"@nx/jest": "17.2.7",
"@nx/js": "17.2.7",
"@nx/node": "17.2.7",
"@nx/plugin": "17.2.7",
"@nx/react": "17.2.7",
"@nx/webpack": "17.2.7",
"@swc-node/register": "1.6.8",
"@swc/core": "1.3.100",
"@swc/core": "1.3.101",
"@types/jest": "29.5.11",
"@types/node": "20.10.4",
"@types/node": "20.10.5",
"@types/shelljs": "^0.8.15",
"@types/yargs": "^17.0.32",
"@typescript-eslint/eslint-plugin": "6.13.2",
"@typescript-eslint/parser": "6.13.2",
"@typescript-eslint/eslint-plugin": "6.15.0",
"@typescript-eslint/parser": "6.15.0",
"dotenv": "16.3.1",
"eslint": "8.55.0",
"eslint": "8.56.0",
"eslint-config-prettier": "9.1.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.2.0",
"prettier": "3.1.0",
"nx": "17.2.7",
"prettier": "3.1.1",
"ts-jest": "29.1.1",
"ts-node": "10.9.2",
"tslint": "~6.1.3",
Expand Down
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": "^13.0.1"
"firebase-tools": "^13.0.2"
},
"builders": "./executors.json",
"generators": "./generators.json"
Expand Down
Loading

0 comments on commit d018c63

Please sign in to comment.