Skip to content

Commit

Permalink
Improvements (#184)
Browse files Browse the repository at this point in the history
  • Loading branch information
TriPSs authored Dec 1, 2023
2 parents 7078440 + a9ede78 commit d021a3e
Show file tree
Hide file tree
Showing 14 changed files with 819 additions and 840 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
strategy:
fail-fast: false
matrix:
target: [ 'build', 'e2e' ]
target: [ 'build', 'e2e' , 'test']
steps:
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
Expand Down
24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@actions/core": "^1.10.1",
"@nx/devkit": "17.0.2",
"@nx/workspace": "17.0.2",
"@types/tar": "^6.1.9",
"@types/tar": "^6.1.10",
"axios": "^1.6.2",
"crypto-js": "^4.2.0",
"deepmerge": "^4.3.1",
Expand All @@ -46,9 +46,9 @@
"yargs": "^17.7.2"
},
"devDependencies": {
"@google-cloud/storage": "^7.6.0",
"@jamesives/github-pages-deploy-action": "^4.4.3",
"@jscutlery/semver": "^4.0.0",
"@google-cloud/storage": "^7.7.0",
"@jamesives/github-pages-deploy-action": "^4.5.0",
"@jscutlery/semver": "^4.1.0",
"@nx/eslint-plugin": "17.0.2",
"@nx/jest": "17.0.2",
"@nx/js": "17.0.2",
Expand All @@ -57,15 +57,15 @@
"@nx/react": "17.0.2",
"@nx/webpack": "17.0.2",
"@swc-node/register": "1.6.8",
"@swc/core": "1.3.96",
"@types/jest": "29.5.8",
"@types/node": "20.9.0",
"@swc/core": "1.3.100",
"@types/jest": "29.5.10",
"@types/node": "20.10.1",
"@types/shelljs": "^0.8.15",
"@types/yargs": "^17.0.31",
"@typescript-eslint/eslint-plugin": "6.11.0",
"@typescript-eslint/parser": "6.11.0",
"@types/yargs": "^17.0.32",
"@typescript-eslint/eslint-plugin": "6.13.1",
"@typescript-eslint/parser": "6.13.1",
"dotenv": "16.3.1",
"eslint": "8.53.0",
"eslint": "8.54.0",
"eslint-config-prettier": "9.0.0",
"eslint-plugin-simple-import-sort": "^10.0.0",
"express": "^4.18.2",
Expand All @@ -77,7 +77,7 @@
"ts-jest": "29.1.1",
"ts-node": "10.9.1",
"tslint": "~6.1.3",
"typescript": "5.2.2"
"typescript": "5.3.2"
},
"packageManager": "[email protected]"
}
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.9.0"
"firebase-tools": "^12.9.1"
},
"builders": "./executors.json",
"generators": "./generators.json"
Expand Down
21 changes: 13 additions & 8 deletions packages/gcp-cloud-run/src/executors/deploy/deploy.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ export function deployExecutor(
buildWith = 'artifact-registry',
autoCreateArtifactsRepo = true,
generateRepoInfoFile = false,
timeout = null
timeout = null,

cpu,
cpuBoost
} = options

const distDirectory = join(context.root, outputDirectory)
Expand Down Expand Up @@ -112,13 +115,11 @@ export function deployExecutor(
if (generateRepoInfoFile) {
logger.info('Generating repo info file')

execCommand(
buildCommand([
'gcloud debug source gen-repo-info-file',
`--source-directory=${sourceRoot}`,
`--output-directory=${distDirectory}`
])
)
execCommand(buildCommand([
'gcloud debug source gen-repo-info-file',
`--source-directory=${sourceRoot}`,
`--output-directory=${distDirectory}`
]))
}

let gcloudCommand = 'gcloud'
Expand Down Expand Up @@ -149,6 +150,10 @@ export function deployExecutor(
tagWithVersion && packageVersion && `--tag=${packageVersion}`,
validSecrets.length > 0 && `--set-secrets=${validSecrets.join(',')}`,

cpu && `--cpu=${cpu}`,
typeof cpuBoost === 'boolean' && cpuBoost && '--cpu-boost',
typeof cpuBoost === 'boolean' && !cpuBoost && '--no-cpu-boost',

// There can be a question if a repo should be created
buildWithArtifactRegistry && autoCreateArtifactsRepo && '--quiet'
])
Expand Down
2 changes: 2 additions & 0 deletions packages/gcp-cloud-run/src/executors/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ export interface ExecutorSchema {
noTraffic?: boolean
generateRepoInfoFile?: boolean
timeout?: number
cpu?: number
cpuBoost?: boolean
}
9 changes: 9 additions & 0 deletions packages/gcp-functions/migrations.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"generators": {
"change-executor-name": {
"version": "11.0.0",
"description": "Gen 2 functions are now default.",
"implementation": "./src/migrations/change-function-gen/change-function-gen"
}
}
}
12 changes: 9 additions & 3 deletions packages/gcp-functions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,14 @@
"generators": "./generators.json",
"devDependencies": {
"@google-cloud/functions-framework": "^3.3.0",
"@nestjs/common": "^10.2.8",
"@nestjs/core": "^10.2.8",
"@nestjs/platform-express": "^10.2.8"
"@nestjs/common": "^10.2.10",
"@nestjs/core": "^10.2.10",
"@nestjs/platform-express": "^10.2.10"
},
"nx-migrations": {
"migrations": "./migrations.json"
},
"dependencies": {
"@nx/devkit": "17.0.2"
}
}
10 changes: 9 additions & 1 deletion packages/gcp-functions/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
"lint": {
"executor": "@nrwl/linter:eslint",
"options": {
"lintFilePatterns": ["packages/gcp-functions/**/*.ts"]
"lintFilePatterns": [
"packages/gcp-functions/**/*.ts",
"packages/gcp-functions/migrations.json"
]
}
},
"test": {
Expand Down Expand Up @@ -50,6 +53,11 @@
"glob": "**/*.json",
"ignore": ["**/tsconfig*.json", "project.json"],
"output": "/"
},
{
"input": "./packages/gcp-functions",
"glob": "migrations.json",
"output": "."
}
],
"updateBuildableProjectDepsInPackageJson": true
Expand Down
4 changes: 2 additions & 2 deletions packages/gcp-functions/src/executors/deploy/deploy.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ export async function deployExecutor(
vpcConnector = null,
securityLevel = null,
secrets = [],
gen = 1,
gen = 2,
concurrency = 1,
cloudSqlInstance = null,
timeout = null,
cpu
cpu,
} = options

let runtime = options.runtime || 'nodejs20'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import { addProjectConfiguration, readProjectConfiguration } from '@nx/devkit'
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing'

import type { Tree } from '@nx/devkit'

import update from './change-function-gen'

describe('change-function-gen migration', () => {
let tree: Tree

beforeEach(() => {
tree = createTreeWithEmptyWorkspace()
})

it('should run successfully', async () => {
addProjectConfiguration(tree, 'genOne', {
root: 'genOne',
targets: {
deploy: {
executor: '@nx-extend/gcp-functions:deploy',
options: {
functionName: 'test',
envVarsFile: `test/src/environments/production.yaml`,
entryPoint: 'test'
}
}
}
})

addProjectConfiguration(tree, 'genTwo', {
root: 'genTwo',
targets: {
deploy: {
executor: '@nx-extend/gcp-functions:deploy',
options: {
functionName: 'test',
envVarsFile: `test/src/environments/production.yaml`,
entryPoint: 'test',
gen: 2
}
}
}
})

await update(tree)

expect(readProjectConfiguration(tree, 'genOne')).toEqual(expect.objectContaining({
root: 'genOne',
targets: {
deploy: {
executor: '@nx-extend/gcp-functions:deploy',
options: {
functionName: 'test',
envVarsFile: `test/src/environments/production.yaml`,
entryPoint: 'test',
gen: 1
}
}
}
}))

expect(readProjectConfiguration(tree, 'genTwo')).toEqual(expect.objectContaining({
root: 'genTwo',
targets: {
deploy: {
executor: '@nx-extend/gcp-functions:deploy',
options: {
functionName: 'test',
envVarsFile: `test/src/environments/production.yaml`,
entryPoint: 'test'
}
}
}
}))
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import { Tree, updateProjectConfiguration } from '@nx/devkit'
import { getProjects } from 'nx/src/generators/utils/project-configuration'

interface DeployOptions {
gen?: 1 | 2
}

/**
* Migrates all functions with @nx-extend/gcp-functions:deploy target to:
* - Delete "gen": 2, as this is the new default
* - Adds "gen": 1, to keep behavior as is
*/
export default function update(tree: Tree) {
const projects = getProjects(tree)

for (const [name, project] of projects) {
const deployTarget = Object.keys(project.targets).find((target) => (
project.targets[target].executor === '@nx-extend/gcp-functions:deploy'
))

if (deployTarget) {
const options = project.targets[deployTarget].options as DeployOptions

if (options.gen && options.gen === 2) {
delete options.gen
} else {
options.gen = 1
}

project.targets[deployTarget].options = options

updateProjectConfiguration(tree, name, project)
}
}
}
2 changes: 1 addition & 1 deletion packages/gcp-task-runner/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"version": "5.0.1",
"main": "src/index.js",
"dependencies": {
"@google-cloud/storage": "7.6.0"
"@google-cloud/storage": "7.7.0"
}
}
4 changes: 2 additions & 2 deletions packages/strapi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"license": "MIT",
"main": "src/index.js",
"dependencies": {
"@strapi/generate-new": "4.15.4",
"@strapi/strapi": "4.15.4"
"@strapi/generate-new": "4.15.5",
"@strapi/strapi": "4.15.5"
},
"builders": "./executors.json",
"generators": "./generators.json"
Expand Down
Loading

0 comments on commit d021a3e

Please sign in to comment.