Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(firebase): add the basis for python support #42

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Welcome to Cloud Functions for Firebase for Python!
# To get started, simply uncomment the below code or create your own.
# Deploy with `firebase deploy`

from firebase_functions import https_fn
from firebase_admin import initialize_app

# initialize_app()
#
#
# @https_fn.on_request()
# def on_request_example(req: https_fn.Request) -> https_fn.Response:
# return https_fn.Response("Hello world!")
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
firebase_functions~=0.1.0
2 changes: 2 additions & 0 deletions packages/firebase/src/generators/functions/schema.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export type FirebaseNodeRuntimeVersion = '14' | '16' | '18' | '20';
export type FirebaseRuntime = 'python' | 'nodejs';

export interface FirebaseGeneratorSchema {
name: string;
Expand All @@ -7,4 +8,5 @@ export interface FirebaseGeneratorSchema {
codebase?: string;
firebaseProject?: string;
nodeVersion: FirebaseNodeRuntimeVersion;
runtime: FirebaseRuntime;
}
19 changes: 19 additions & 0 deletions packages/firebase/src/generators/functions/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,25 @@
"description": "Firebase functions codebase",
"default": "default"
},
"runtime": {
"type": "string",
"description": "Firebase functions runtime e.g. Typescript or Python",
"default": "nodejs",
"x-prompt": {
"message": "What runtime would you like to use?",
"type": "list",
"items": [
{
"value": "nodejs",
"label": "Node.js"
},
{
"value": "python",
"label": "Python"
}
]
}
},
"nodeVersion": {
"type": "string",
"description": "Firebase functions node runtime version e.g. 14, 16, 18 and 20",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Tree, names, offsetFromRoot, generateFiles } from '@nx/devkit';
import path = require('path');
import { Tree, generateFiles, names, offsetFromRoot } from '@nx/devkit';
import { NormalizedSchema } from '../generator';
import path = require('path');

export default function addFiles(tree: Tree, options: NormalizedSchema) {
const templateOptions = {
Expand All @@ -14,9 +14,12 @@ export default function addFiles(tree: Tree, options: NormalizedSchema) {
.map(() => '..')
.join('/') + '/tsconfig.base.json',
};

const filesDir = options.runtime === 'python' ? 'files_python' : 'files';

generateFiles(
tree,
path.join(__dirname, '../files'),
path.join(__dirname, `../${filesDir}`),
options.projectRoot,
templateOptions
);
Expand Down