File tree 10 files changed +247
-0
lines changed
10 files changed +247
-0
lines changed Original file line number Diff line number Diff line change 8
8
dist /
9
9
** /ui-debug.log
10
10
.next
11
+ /template-test
12
+ .oops
Original file line number Diff line number Diff line change
1
+ # To learn more about how to use Nix to configure your environment
2
+ # see: https://developers.google.com/idx/guides/customize-idx-env
3
+ { pkgs , ... } : {
4
+ # Which nixpkgs channel to use.
5
+ channel = "stable-23.11" ; # or "unstable"
6
+
7
+ # Use https://search.nixos.org/packages to find packages
8
+ packages = [
9
+ # pkgs.go
10
+ # pkgs.python311
11
+ # pkgs.python311Packages.pip
12
+ # pkgs.nodejs_20
13
+ # pkgs.nodePackages.nodemon
14
+ ] ;
15
+
16
+ idx . internal . templates-cli . enable = true ;
17
+ # Sets environment variables in the workspace
18
+ env = { } ;
19
+ idx = {
20
+ # Search for the extensions you want on https://open-vsx.org/ and use "publisher.id"
21
+ extensions = [
22
+ # "vscodevim.vim"
23
+ ] ;
24
+
25
+ # Enable previews
26
+ previews = {
27
+ enable = true ;
28
+ previews = {
29
+ # web = {
30
+ # # Example: run "npm run dev" with PORT set to IDX's defined port for previews,
31
+ # # and show it in IDX's web preview panel
32
+ # command = ["npm" "run" "dev"];
33
+ # manager = "web";
34
+ # env = {
35
+ # # Environment variables to set for your server
36
+ # PORT = "$PORT";
37
+ # };
38
+ # };
39
+ } ;
40
+ } ;
41
+
42
+ # Workspace lifecycle hooks
43
+ workspace = {
44
+ # Runs when a workspace is first created
45
+ onCreate = {
46
+ # Example: install JS dependencies from NPM
47
+ # npm-install = "npm install";
48
+ } ;
49
+ # Runs when the workspace is (re)started
50
+ onStart = {
51
+ # Example: start a background task to watch and re-build backend code
52
+ # watch-backend = "npm run watch-backend";
53
+ } ;
54
+ } ;
55
+ } ;
56
+ }
Original file line number Diff line number Diff line change
1
+ {
2
+ "IDX.aI.enableInlineCompletion" : true ,
3
+ "IDX.aI.enableCodebaseIndexing" : true
4
+ }
Original file line number Diff line number Diff line change
1
+ { pkgs , ... } : {
2
+ channel = "stable-23.11" ;
3
+ packages = [
4
+ pkgs . nodejs_20
5
+ ] ;
6
+
7
+ env = {
8
+ POSTGRESQL_CONN_STRING = "postgresql://user:mypassword@localhost:5432/dataconnect?sslmode=disable" ;
9
+ } ;
10
+
11
+ idx . extensions = [
12
+ "mtxr.sqltools"
13
+ "mtxr.sqltools-driver-pg"
14
+ "GraphQL.vscode-graphql-syntax"
15
+ "GoogleCloudTools.firebase-dataconnect-vscode"
16
+ ] ;
17
+
18
+ services . postgres = {
19
+ extensions = [ "pgvector" ] ;
20
+ enable = true ;
21
+ } ;
22
+
23
+ idx = {
24
+ workspace = {
25
+ onCreate = {
26
+ update-firebase = "npm install -D firebase-tools" ;
27
+ postgres = ''
28
+ psql --dbname=postgres -c "ALTER USER \"user\" PASSWORD 'mypassword';"
29
+ psql --dbname=postgres -c "CREATE DATABASE dataconnect;"
30
+ psql --dbname=dataconnect -c "CREATE EXTENSION vector;"
31
+ '' ;
32
+ npm-install = "cd app && npm i && npm i firebase@latest" ;
33
+ } ;
34
+ } ;
35
+ previews = {
36
+ enable = true ;
37
+ previews = {
38
+ web = {
39
+ command = [ "npm" "run" "dev" "--prefix" "./app" "--" "--port" "$PORT" "--host" "0.0.0.0" ] ;
40
+ manager = "web" ;
41
+ } ;
42
+ } ;
43
+ } ;
44
+ } ;
45
+ }
Original file line number Diff line number Diff line change
1
+ {
2
+ "sqltools.connections" : [
3
+ {
4
+ "previewLimit" : 50 ,
5
+ "server" : " localhost" ,
6
+ "port" : 5432 ,
7
+ "driver" : " PostgreSQL" ,
8
+ "name" : " Main" ,
9
+ "database" : " dataconnect" ,
10
+ "username" : " user" ,
11
+ "password" : " mypassword"
12
+ }
13
+ ]
14
+ }
Original file line number Diff line number Diff line change
1
+ import { initializeApp , getApps } from "firebase/app" ;
2
+ import { getAuth } from "firebase/auth" ;
3
+ import {
4
+ connectDataConnectEmulator ,
5
+ getDataConnect ,
6
+ } from "firebase/data-connect" ;
7
+ import { connectorConfig } from '@movie/dataconnect' ;
8
+ import { createContext } from "react" ;
9
+
10
+ const firebaseConfig = {
11
+ apiKey : "API_KEY" ,
12
+ authDomain : "PROJECT_ID.firebaseapp.com" ,
13
+ projectId : "PROJECT_ID" ,
14
+ storageBucket : "PROJECT_ID.appspot.com" ,
15
+ messagingSenderId : "SENDER_ID" ,
16
+ appId : "APP_ID"
17
+ } ;
18
+
19
+ const firebaseApp =
20
+ getApps ( ) . length === 0 ? initializeApp ( firebaseConfig ) : getApps ( ) [ 0 ] ;
21
+
22
+ const auth = getAuth ( firebaseApp ) ;
23
+ const dataconnect = getDataConnect ( firebaseApp , connectorConfig ) ;
24
+
25
+ if ( process . env . NODE_ENV === "development" ) {
26
+ connectDataConnectEmulator (
27
+ dataconnect ,
28
+ window . location . hostname ,
29
+ undefined ,
30
+ true
31
+ ) ;
32
+ }
33
+
34
+ const AuthContext = createContext ( auth ) ;
35
+
36
+ function AuthProvider ( { children } : { children : React . ReactNode } ) {
37
+ return < AuthContext . Provider value = { auth } > { children } </ AuthContext . Provider > ;
38
+ }
39
+
40
+ export { AuthContext , AuthProvider } ;
Original file line number Diff line number Diff line change
1
+ import { defineConfig } from 'vite'
2
+ import react from '@vitejs/plugin-react'
3
+ import path from 'path' ;
4
+
5
+ // https://vitejs.dev/config/
6
+ export default defineConfig ( {
7
+ plugins : [ react ( ) ] ,
8
+ resolve : {
9
+ alias : {
10
+ '@' : path . resolve ( __dirname , 'src' ) ,
11
+ } ,
12
+ } ,
13
+ server : {
14
+ proxy : {
15
+ '/v1beta/projects' : {
16
+ target : 'http://127.0.0.1:9399' ,
17
+ changeOrigin : true ,
18
+ rewrite : ( path ) => path . replace ( / ^ \/ v 1 b e t a \/ p r o j e c t s / , '/v1beta/projects' ) ,
19
+ } ,
20
+ } ,
21
+ } ,
22
+ } )
Original file line number Diff line number Diff line change
1
+ import { defineConfig } from 'vite'
2
+ import react from '@vitejs/plugin-react'
3
+ import path from 'path' ;
4
+
5
+ // https://vitejs.dev/config/
6
+ export default defineConfig ( {
7
+ plugins : [ react ( ) ] ,
8
+ resolve : {
9
+ alias : {
10
+ '@' : path . resolve ( __dirname , 'src' ) ,
11
+ } ,
12
+ } ,
13
+ server : {
14
+ proxy : {
15
+ '/v1beta/projects' : {
16
+ target : 'http://127.0.0.1:9399' ,
17
+ changeOrigin : true ,
18
+ rewrite : ( path ) => path . replace ( / ^ \/ v 1 b e t a \/ p r o j e c t s / , '/v1beta/projects' ) ,
19
+ } ,
20
+ } ,
21
+ } ,
22
+ } )
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " Data Connect" ,
3
+ "description" : " Build a new web app using Data Connect" ,
4
+ "categories" : [
5
+ " Web app" ,
6
+ " Databases"
7
+ ],
8
+ "icon" : " https://www.gstatic.com/monospace/240513/logo_firebase.svg" ,
9
+ "publisher" : " Google LLC"
10
+ }
Original file line number Diff line number Diff line change
1
+ /*
2
+ idx-template \
3
+ --output-dir /home/user/quickstart-js/dataconnect \
4
+ -a '{}' \
5
+ --workspace-name 'dataconnect' \
6
+ /home/user/quickstart-js/template-test \
7
+ --failure-report
8
+
9
+ */
10
+
11
+ { pkgs , ... } : {
12
+ packages = [ ] ;
13
+ bootstrap = ''
14
+ mkdir "$out"
15
+ mkdir "$out"/.idx
16
+ mkdir "$out"/app
17
+ mkdir "$out"/dataconnect
18
+ mkdir "$out"/.vscode
19
+
20
+ cp ${ .idx/dev.nix } "$out"/.idx/dev.nix
21
+ cp -a ${ ./app } /* "$out"/app/
22
+ cp -a ${ ./dataconnect } /* "$out"/dataconnect/
23
+
24
+ cp ${ ./.vscode/settings.json } "$out"/.vscode/settings.json
25
+ cp ${ ./firebase.json } "$out"/firebase.json
26
+ cp ${ ./README.md } "$out"/README.md
27
+ cp ${ ./.gitignore } "$out"/.gitignore
28
+ chmod -R u+w "$out"
29
+ mv "$out"/app/src/lib/firebase.idx.tsx "$out"/app/src/lib/firebase.tsx
30
+ mv "$out"/app/vite.config.idx.ts "$out"/app/vite.config.ts
31
+ '' ;
32
+ }
You can’t perform that action at this time.
0 commit comments