-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
819 additions
and
840 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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", | ||
|
@@ -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", | ||
|
@@ -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", | ||
|
@@ -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]" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
packages/gcp-functions/src/migrations/change-function-gen/change-function-gen.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
} | ||
} | ||
} | ||
})) | ||
}) | ||
}) |
36 changes: 36 additions & 0 deletions
36
packages/gcp-functions/src/migrations/change-function-gen/change-function-gen.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.