Skip to content

Commit

Permalink
fix: Issues in v2.1.0 release (#152)
Browse files Browse the repository at this point in the history
* Fix faulty import

* Cleanup & inline migrate

* Fix globs & environment files copy in migrate, refactor types

* Fix e2e tests for migrate

* More e2e fixes & refactors

* Fix assets glob sync

* Fix function deploy when renamed app

* esbuild shouldnt be a dependency

* clean messaging if not renaming primary config

* Improve hosting sync messaging + e2e test
  • Loading branch information
simondotm authored Sep 26, 2023
1 parent f5da4ea commit 184c9e2
Show file tree
Hide file tree
Showing 23 changed files with 413 additions and 260 deletions.
106 changes: 93 additions & 13 deletions e2e/nx-firebase-e2e/test-utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ export function addImport(mainTs: string, addition: string) {
}


export function expectedAppProjectTargets(projectDir: string, projectName: string) {
export function expectedAppProjectTargets(appProject: ProjectData) {
return {
build: {
executor: 'nx:run-commands',
Expand All @@ -227,19 +227,19 @@ export function expectedAppProjectTargets(projectDir: string, projectName: strin
watch: {
executor: 'nx:run-commands',
options: {
command: `nx run-many --targets=build --projects=tag:firebase:dep:${projectName} --parallel=100 --watch`,
command: `nx run-many --targets=build --projects=tag:firebase:dep:${appProject.projectName} --parallel=100 --watch`,
},
},
lint: {
executor: 'nx:run-commands',
options: {
command: `nx run-many --targets=lint --projects=tag:firebase:dep:${projectName} --parallel=100`,
command: `nx run-many --targets=lint --projects=tag:firebase:dep:${appProject.projectName} --parallel=100`,
},
},
test: {
executor: 'nx:run-commands',
options: {
command: `nx run-many --targets=test --projects=tag:firebase:dep:${projectName} --parallel=100`,
command: `nx run-many --targets=test --projects=tag:firebase:dep:${appProject.projectName} --parallel=100`,
},
},
firebase: {
Expand All @@ -262,15 +262,15 @@ export function expectedAppProjectTargets(projectDir: string, projectName: strin
getconfig: {
executor: 'nx:run-commands',
options: {
command: `nx run ${projectName}:firebase functions:config:get > ${projectDir}/environment/.runtimeconfig.json`,
command: `nx run ${appProject.projectName}:firebase functions:config:get > ${appProject.projectDir}/environment/.runtimeconfig.json`,
},
},
emulate: {
executor: 'nx:run-commands',
options: {
commands: [
`nx run ${projectName}:killports`,
`nx run ${projectName}:firebase emulators:start --import=${projectDir}/.emulators --export-on-exit`,
`nx run ${appProject.projectName}:killports`,
`nx run ${appProject.projectName}:firebase emulators:start --import=${appProject.projectDir}/.emulators --export-on-exit`,
],
parallel: false,
},
Expand All @@ -279,29 +279,109 @@ export function expectedAppProjectTargets(projectDir: string, projectName: strin
executor: '@simondotm/nx-firebase:serve',
options: {
commands: [
`nx run ${projectName}:watch`,
`nx run ${projectName}:emulate`,
`nx run ${appProject.projectName}:watch`,
`nx run ${appProject.projectName}:emulate`,
],
},
},
deploy: {
executor: 'nx:run-commands',
dependsOn: ['build'],
options: {
command: `nx run ${projectName}:firebase deploy`,
command: `nx run ${appProject.projectName}:firebase deploy`,
},
},
}
}

export function validateProjectConfig(projectDir: string, projectName: string) {

export function expectedFunctionProjectTargets(functionProject: ProjectData, appProject: ProjectData) {
return {
build: {
executor: "@nx/esbuild:esbuild",
outputs: [
"{options.outputPath}"
],
options: {
platform: "node",
outputPath: `dist/${functionProject.projectDir}`,
main: `${functionProject.projectDir}/src/main.ts`,
tsConfig: `${functionProject.projectDir}/tsconfig.app.json`,
assets: [
`${functionProject.projectDir}/src/assets`,
{ glob: "**/*", input: `${appProject.projectDir}/environment`, output: "."}
],
generatePackageJson: true,
bundle: true,
dependenciesFieldType: "dependencies",
format: [ 'esm' ],
thirdParty: false,
target: "node16",
esbuildOptions: {
logLevel: "info"
}
}
},
deploy: {
executor: "nx:run-commands",
options: {
command: `nx run ${appProject.projectName}:deploy --only functions:${functionProject.projectName}`
},
dependsOn: [
"build"
]
},
lint: {
executor: "@nx/linter:eslint",
outputs: [
"{options.outputFile}"
],
options: {
lintFilePatterns: [
`${functionProject.projectDir}/**/*.ts`
]
}
},
test: {
executor: "@nx/jest:jest",
outputs: [
`{workspaceRoot}/coverage/{projectRoot}`
],
options: {
jestConfig: `${functionProject.projectDir}/jest.config.ts`,
passWithNoTests: true
},
configurations: {
ci: {
ci: true,
codeCoverage: true,
},
},
}
}
}


export function validateProjectConfig(appProject: ProjectData) {
const project = readJson(
`${projectDir}/project.json`,
`${appProject.projectDir}/project.json`,
)
// expect(project.root).toEqual(`apps/${projectName}`)
expect(project.targets).toEqual(
expect.objectContaining(expectedAppProjectTargets(projectDir, projectName)),
expect.objectContaining(expectedAppProjectTargets(appProject)),
)
}


export function validateFunctionConfig(functionProject: ProjectData, appProject: ProjectData) {
const project = readJson(
`${functionProject.projectDir}/project.json`,
)
// expect(project.root).toEqual(`apps/${projectName}`)
expect(project.targets).toEqual(
expect.objectContaining(expectedFunctionProjectTargets(functionProject, appProject)),
)
}



Loading

0 comments on commit 184c9e2

Please sign in to comment.