@donotdev/core 0.2.1 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/functions/index.js +13 -13
- package/i18n/locales/eager/dndev_ar.json +4 -0
- package/i18n/locales/eager/dndev_da.json +4 -0
- package/i18n/locales/eager/dndev_de.json +4 -0
- package/i18n/locales/eager/dndev_en.json +4 -0
- package/i18n/locales/eager/dndev_es.json +4 -0
- package/i18n/locales/eager/dndev_fr.json +4 -0
- package/i18n/locales/eager/dndev_it.json +4 -0
- package/i18n/locales/eager/dndev_ja.json +4 -0
- package/i18n/locales/eager/dndev_ko.json +4 -0
- package/i18n/locales/eager/dndev_nl.json +4 -0
- package/i18n/locales/eager/dndev_pl.json +636 -0
- package/i18n/locales/eager/dndev_pt.json +4 -0
- package/i18n/locales/eager/dndev_zh.json +4 -0
- package/i18n/locales/lazy/auth_ar.json +5 -2
- package/i18n/locales/lazy/auth_da.json +5 -2
- package/i18n/locales/lazy/auth_de.json +5 -2
- package/i18n/locales/lazy/auth_en.json +5 -2
- package/i18n/locales/lazy/auth_es.json +5 -2
- package/i18n/locales/lazy/auth_fr.json +5 -2
- package/i18n/locales/lazy/auth_it.json +5 -2
- package/i18n/locales/lazy/auth_ja.json +5 -2
- package/i18n/locales/lazy/auth_ko.json +5 -2
- package/i18n/locales/lazy/auth_nl.json +5 -2
- package/i18n/locales/lazy/auth_pl.json +195 -0
- package/i18n/locales/lazy/auth_pt.json +5 -2
- package/i18n/locales/lazy/auth_zh.json +5 -2
- package/i18n/locales/lazy/billing_pl.json +93 -0
- package/i18n/locales/lazy/blog_pl.json +9 -0
- package/i18n/locales/lazy/cookies_pl.json +35 -0
- package/i18n/locales/lazy/crud_ar.json +40 -3
- package/i18n/locales/lazy/crud_da.json +39 -4
- package/i18n/locales/lazy/crud_de.json +40 -3
- package/i18n/locales/lazy/crud_en.json +38 -4
- package/i18n/locales/lazy/crud_es.json +40 -3
- package/i18n/locales/lazy/crud_fr.json +39 -3
- package/i18n/locales/lazy/crud_it.json +40 -3
- package/i18n/locales/lazy/crud_ja.json +40 -3
- package/i18n/locales/lazy/crud_ko.json +40 -3
- package/i18n/locales/lazy/crud_nl.json +39 -4
- package/i18n/locales/lazy/crud_pl.json +582 -0
- package/i18n/locales/lazy/crud_pt.json +39 -4
- package/i18n/locales/lazy/crud_zh.json +39 -4
- package/i18n/locales/lazy/homeTemplate_pl.json +52 -0
- package/i18n/locales/lazy/legalNotice_de.json +55 -0
- package/i18n/locales/lazy/legalNotice_pl.json +55 -0
- package/i18n/locales/lazy/oauth_pl.json +11 -0
- package/i18n/locales/lazy/privacy_pl.json +178 -0
- package/i18n/locales/lazy/terms_pl.json +200 -0
- package/index.d.ts +899 -165
- package/index.js +6 -6
- package/next/index.d.ts +129 -4
- package/next/index.js +527 -152
- package/next/runtime.js +3 -0
- package/package.json +5 -3
- package/server.d.ts +759 -139
- package/server.js +1 -1
- package/symbol-index.json +1 -1
- package/vite/index.js +68 -68
package/functions/index.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import
|
|
2
|
-
`:d=String(t);try{return await
|
|
3
|
-
`:d=String(t);try{return Buffer.isBuffer(d)?h.writeFileSync(l,d):h.writeFileSync(l,d,"utf8"),this._writtenPaths?.add(l),i&&v.info(`${c?"Updated":"Created"} file: ${l}`),!0}catch(m){throw new Error(`Failed to write file: ${l}: ${m instanceof Error?m.message:String(m)}`)}}async copy(e,t,o={}){let{overwrite:n=!1,dryRun:s=!1,verbose:r=!1}=o,i=this.normalizePath(t),l=this.pathExists(i);if(l&&!n)return r&&v.info(`Skipping existing file: ${i}`),!1;if(s)return v.info(`[DRY RUN] Would copy file: ${i}`),!0;let f=this.normalizePath(A(i));try{await h.promises.mkdir(f,{recursive:!0})}catch(c){if(c?.code!=="EEXIST")throw c}try{return await K(async()=>(await h.promises.copyFile(e,i),r&&v.info(`${l?"Updated":"Created"} file: ${i}`),!0),`Failed to copy file from ${e} to ${i}`)}catch{return!1}}copySync(e,t,o={}){let{overwrite:n=!1,dryRun:s=!1,verbose:r=!1}=o,i=this.normalizePath(t),l=this.pathExists(i);if(l&&!n)return r&&v.info(`Skipping existing file: ${i}`),!1;if(s)return v.info(`[DRY RUN] Would copy file: ${i}`),!0;let f=this.normalizePath(A(i));try{h.mkdirSync(f,{recursive:!0})}catch(c){if(c?.code!=="EEXIST")throw c}try{return h.copyFileSync(e,i),this._writtenPaths?.add(i),r&&v.info(`${l?"Updated":"Created"} file: ${i}`),!0}catch{return!1}}pathExists(e,t=!1){try{return h.existsSync(e)}catch(o){return t||v.error(`Error checking path existence: ${e}`,o),!1}}mkdir(e){try{let t=e.startsWith("/")||e.match(/^[A-Z]:/)?this.normalizePath(e):this.resolveAppPath(e);return h.existsSync(t)||h.mkdirSync(t,{recursive:!0}),!0}catch{return!1}}readdirSync(e,t){try{return h.readdirSync(e,t)}catch(o){return this.options.debug&&v.warn(`Failed to read directory: ${e}`,o),t&&typeof t=="object"&&"withFileTypes"in t&&t.withFileTypes?[]:[]}}statSync(e){try{return h.statSync(e)}catch(t){return this.options.debug&&v.warn(`Failed to stat file: ${e}`,t),null}}realpathSync(e){return h.realpathSync(e)}watch(e,t,o){return h.watch(e,t,o)}lstatSync(e){try{return h.lstatSync(e)}catch(t){return this.options.debug&&v.warn(`Failed to lstat file: ${e}`,t),null}}async ensureDir(e){try{await h.promises.mkdir(e,{recursive:!0})}catch(t){if(t?.code!=="EEXIST")throw t}}ensureDirSync(e){try{h.mkdirSync(e,{recursive:!0})}catch(t){if(t?.code!=="EEXIST")throw t}}async remove(e){await h.promises.rm(e,{recursive:!0,force:!0})}removeSync(e){h.rmSync(e,{recursive:!0,force:!0})}async readdir(e,t){return h.promises.readdir(e,t)}stripBom(e){return e.charCodeAt(0)===65279?e.slice(1):e}getRepoRoot(){return this._repoRoot||process.cwd()}startWriteRecording(){this._writtenPaths=new Set}stopWriteRecording(){if(!this._writtenPaths)throw new Error("stopWriteRecording() called without startWriteRecording()");let e=this._writtenPaths;return this._writtenPaths=null,e}getAppRoot(){return this._appRoot?this._appRoot:this._repoRoot}setAppRoot(e){if(!e)throw new Error("PathResolver.setAppRoot: root cannot be undefined or null");this._appRoot=this.normalizePath(e)}isMonorepo(){let e=_(this._repoRoot,"packages");return this.pathExists(e)}isWithinApp(e){let t=this.normalizePath(I(e)),o=this.getAppRoot(),n=V(o,t),s=this.normalizePath(n);return!s.startsWith("../")&&!s.startsWith("/")}async findFiles(e,t,o={}){let n=this.normalizePath(_(e,t)),s=this.getAppRoot(),r=this.normalizePath(s),i=n.startsWith(r)?n.slice(r.length+1):n,l={absolute:!0,onlyFiles:!0,braceExpansion:!0,extglob:!0,globstar:!0,cwd:s,ignore:$.SCAN_PATTERNS?.globalIgnore||["**/node_modules/**","**/dist/**","**/build/**","**/.git/**"]};return await this._globWithNormalization([i],{...l,...o})}clearCache(){}async _resolveFrameworkI18nPattern(e){let t=$.I18N_PATHS;if(!t)return null;let o=e.replace(t.SOURCE_ROOT+"/",""),n=this.resolveFrameworkPackage("@donotdev/core");if(!n)return null;let s=this.normalizePath(_(n,t.PUBLISHED_ROOT,o)),r=s.replace(/\/[^/]*\*.*$/,"");return this.pathExists(r),s}async _globWithNormalization(e,t){return(await pe(e,t)).map(n=>{let s=typeof n=="string"?n:n.path;return this.normalizePath(s)})}async resolveFiles(e,t="css"){if(!e||typeof e!="object")return{frameworkFiles:[],consumerFiles:[]};if(t==="i18n")return{frameworkFiles:[],consumerFiles:[]};if(Array.isArray(e.framework)||(e.framework=[]),!Array.isArray(e.consumer))return{frameworkFiles:[],consumerFiles:[]};let o=[...e.framework,...e.consumer];for(let c of o)if(typeof c!="string"||c.trim()==="")return{frameworkFiles:[],consumerFiles:[]};let n=this.getAppRoot(),s=$.getGlobOptionsFor?$.getGlobOptionsFor(t):{ignore:["**/node_modules/**","**/dist/**","**/build/**"]},r=this.normalizePath(n),i=e.framework.map(c=>{let u=this.normalizePath(c);return u.startsWith(r)?u.slice(r.length+1):u}),l=e.consumer.map(c=>{let u=this.normalizePath(c);return u.startsWith(r)?u.slice(r.length+1):u}),f={...s,onlyFiles:!0,absolute:!0,braceExpansion:!0,extglob:!0,globstar:!0,cwd:n};try{let c=i.length>0?await this._globWithNormalization(i,f):[],u=await this._globWithNormalization(l,f);return{frameworkFiles:c,consumerFiles:u}}catch{return this.options.debug,{frameworkFiles:[],consumerFiles:[]}}}async resolvePatterns(e){if(!$.getPatternsFor)return{framework:[],consumer:[],all:[]};let t=this.getAppRoot(),o=this.getRepoRoot();if(e==="i18n"&&(!t||t===o))throw new Error(`Cannot resolve i18n patterns: appRoot not set (appRoot: ${t}, repoRoot: ${o}). Ensure configResolved hook has run before discovery.`);let n=$.getPatternsFor(e),s=this.isMonorepo();if(e==="i18n"){let l=n,f={eager:l.eager.map(c=>c.startsWith("!")?"!"+this.resolveAppPath(c.slice(1)):this.resolveAppPath(c)),lazy:l.lazy.map(c=>c.startsWith("!")?"!"+this.resolveAppPath(c.slice(1)):this.resolveAppPath(c)),framework:{eager:s?(l.framework?.eager||[]).map(c=>this.resolveRepoPath(c)).filter(Boolean):await Promise.all((l.framework?.eager||[]).map(c=>this._resolveFrameworkI18nPattern(c))).then(c=>c.filter(Boolean)),lazy:s?(l.framework?.lazy||[]).map(c=>this.resolveRepoPath(c)).filter(Boolean):await Promise.all((l.framework?.lazy||[]).map(c=>this._resolveFrameworkI18nPattern(c))).then(c=>c.filter(Boolean))},all:[]};return f.all=[...f.eager,...f.lazy,...f.framework.eager,...f.framework.lazy],f}let r=n,i={framework:s?(r.framework||[]).map(l=>this.resolveRepoPath(l)).filter(Boolean):[],consumer:(r.consumer||[]).map(l=>this.resolveAppPath(l)),all:[]};return i.all=[...i.consumer,...i.framework],i}getEmptyModulePath(){return this.getEmptyCjsModulePath().replace(/\.cjs$/,".js")}getEmptyFlagModulePath(){let e=A(ue(import.meta.url));return this.normalizePath(I(e,"emptyFlag.js"))}getEmptyCjsModulePath(){let e=this.resolvePackage("@donotdev/core/empty");if(!e)throw new Error("Cannot resolve @donotdev/core/empty \u2014 package setup is broken");return e}_findRepoRoot(e){let t=this.normalizePath(e),o=0,n=this.options.maxLevels;for(;o<n;){let s=this.normalizePath(_(t,q.TOOLING)),r=this.normalizePath(_(t,q.CORE));if(this.pathExists(s)&&this.pathExists(r))return t;let i=_(t,"apps");if(this.pathExists(i)&&this.statSync(i)?.isDirectory())return this.normalizePath(t);let l=this.normalizePath(_(t,"package.json"));if(this.pathExists(l)&&this.normalizePath(A(t))===t)return t;let f=this.normalizePath(A(t));if(f===t)break;t=f,o++}return this.normalizePath(e)}};function C(a={}){let{entry:e="src/index.ts",outDir:t="lib",minify:o=!1,sourcemap:n=!0,platform:s="firebase",workspace:r,bundleWorkspaceDeps:i=!1,importFramework:l=!1,external:f=!1,...c}=a,u=x.getInstance(),d=M(r),m={entryPoints:[e],bundle:!0,platform:"node",target:"node20",format:"esm",outdir:t,outExtension:{".js":".js"},minify:o,sourcemap:n,metafile:!0,logLevel:"info",loader:{".ts":"ts",".tsx":"tsx",".css":"empty"},keepNames:!0,treeShaking:!0,...c};i&&Object.keys(d).length>0&&(m.alias=Object.fromEntries(Object.entries(d).map(([y,p])=>[y,u.normalizePath(p)]))),m.mainFields=["module","main"],m.conditions=["import","module","node"];let R=["fs","path","crypto","util","stream","events","buffer","url","querystring","http","https","zlib","os","child_process","assert","constants","domain","punycode","string_decoder","timers","tty","vm","worker_threads","perf_hooks","async_hooks"],z=[];if(i)try{let y=r?.root||process.cwd(),p=process.cwd(),g=10;for(let k=0;k<g;k++){let S=u.normalizePath(`${p}/package.json`);if(u.pathExists(S)){let w=u.readSync(S,{format:"json"});if(w&&Array.isArray(w.workspaces)){y=u.normalizePath(p);for(let O of w.workspaces)O==="apps/*"||O==="functions"||!O.includes("*")&&!O.includes("/")&&z.push(O);break}}let E=u.getDirname(p);if(E===p)break;p=E}}catch{}let B={name:"external-node-modules",setup(y){y.onResolve({filter:/^firebase($|\/)/},p=>{if(p.path==="firebase-admin"||p.path.startsWith("firebase-admin/")||p.path==="firebase-functions"||p.path.startsWith("firebase-functions/"))return null;let g;if(r?.type==="dndev"&&r.root)g=u.normalizePath(`${r.root}/packages/core/config/functions/firebase-stub.js`);else{let k=import.meta.url,E=new URL(k).pathname.replace(/^\/([A-Z]:)/i,"$1"),w=u.getDirname(E);g=u.normalizePath(`${w}/firebase-stub.js`)}return{path:g}}),y.onResolve({filter:/.*/},p=>{if(p.kind==="entry-point")return null;if(p.path.match(/@donotdev\/functions\/.+/)&&i&&r?.type==="dndev"){let g=p.path.replace("@donotdev/functions/","");return{path:u.normalizePath(`${r.root}/packages/functions/src/${g}/index.ts`)}}if(p.path==="@donotdev/utils")return r?.type==="dndev"?{path:u.normalizePath(`${r.root}/packages/core/utils/src/server/index.ts`)}:y.resolve("@donotdev/utils/server",{kind:p.kind,resolveDir:p.resolveDir});if(p.path.match(/@donotdev\/utils\/.+/)&&r?.type==="dndev"){let g=p.path.replace("@donotdev/utils/","");return{path:u.normalizePath(`${r.root}/packages/core/utils/src/${g}/index.ts`)}}if(p.path==="@donotdev/supabase")return r?.type==="dndev"?{path:u.normalizePath(`${r.root}/packages/providers/supabase/src/server/index.ts`)}:y.resolve("@donotdev/supabase/server",{kind:p.kind,resolveDir:p.resolveDir});if(p.path==="@donotdev/core")return r?.type==="dndev"?{path:u.normalizePath(`${r.root}/packages/core/server.ts`)}:y.resolve("@donotdev/core/server",{kind:p.kind,resolveDir:p.resolveDir});if(p.path.match(/@donotdev\/core\/.+/)&&i&&r?.type==="dndev"){let g=p.path.replace("@donotdev/core/","");return{path:u.normalizePath(`${r.root}/packages/core/${g}.ts`)}}if(p.path==="firebase-admin"||p.path.startsWith("firebase-admin/")||p.path==="firebase-functions"||p.path.startsWith("firebase-functions/"))return{path:p.path,external:!0};if(p.path.match(/@donotdev\/core\/.+/)&&i&&r?.type==="dndev"){let g=p.path.replace("@donotdev/core/","");return{path:u.normalizePath(`${r.root}/packages/core/${g}.ts`)}}if(p.path.startsWith("@donotdev/")||p.path==="valibot"||p.path.startsWith("valibot/"))return null;if(z.length>0){let g=p.path.split("/")[0];if(z.includes(g))return null}return p.path.startsWith(".")||p.path.startsWith("/")?null:{path:p.path,external:!0}})}};if(m.external=[...R,"firebase-admin","firebase-functions"],m.plugins=[B,...m.plugins||[]],m.define={"process.env.NODE_ENV":JSON.stringify(process.env.NODE_ENV||"production"),...m.define||{}},l&&r.type==="dndev"){let y=r.root,p=u.normalizePath(`${y}/functions/lib`);m.alias={...m.alias,"@donotdev/functions":p}}if(s==="framework"){let y=x.getInstance(),p=r?.root?y.normalizePath(`${r.root}/packages/functions`):process.cwd(),g=y.normalizePath(`${p}/package.json`),k=y.readSync(g,{format:"json"});if(k?.exports){let S={};for(let[,E]of Object.entries(k.exports)){let w=E?.import||E?.default||(typeof E=="string"?E:null);if(!w||!w.endsWith(".ts"))continue;let O=w.replace(/^\.\/src\//,"").replace(/\.ts$/,"");S[O]=w}Object.keys(S).length>0&&(m.entryPoints=S,m.splitting=!0,m.chunkNames="chunks/[name]-[hash]")}}return m}var b=x.getInstance(),L=["create","get","list","listCard","update","delete","bulk"];function X(a,e=0){let t=" ".repeat(e),o="";for(let[n,s]of Object.entries(a))if(s!=null)if(typeof s=="object"&&!Array.isArray(s))Object.keys(s).length===0?o+=`${t}${n}: {}
|
|
1
|
+
import D from"node:fs";import P from"node:path";import{fileURLToPath as oe}from"node:url";var ne=oe(import.meta.url),Pe=P.dirname(ne);function T(){let i=process.cwd(),e=10;for(let t=0;t<e;t++){let o=P.join(i,"package.json");if(D.existsSync(o))try{let s=JSON.parse(D.readFileSync(o,"utf8")),r=s.workspaces&&Array.isArray(s.workspaces);if(r&&s.workspaces.some(c=>c==="packages/**"||c.startsWith("packages/"))&&(D.existsSync(P.join(i,"packages","core"))||D.existsSync(P.join(i,"packages","functions"))))return{type:"dndev",root:i};if(r&&s.workspaces.some(c=>c.includes("dndev/packages"))){let u=s.workspaces.find(m=>m.includes("dndev/packages")).replace(/\/packages.*$/,""),d=P.resolve(i,u);if(D.existsSync(P.join(d,"packages","core")))return{type:"dndev",root:d}}}catch{}let n=P.dirname(i);if(n===i)break;i=n}return{type:"npm",root:process.cwd()}}function ie(i){return i.type==="dndev"?i.root:null}function G(i){let e={};if(i.type==="dndev"){let t=ie(i);t&&(e["@donotdev/types"]=P.join(t,"packages","core","types","src"),e["@donotdev/functions"]=P.join(t,"packages","functions","src"),e["@donotdev/utils"]=P.join(t,"packages","core","utils","src"),e["@donotdev/schemas"]=P.join(t,"packages","core","schemas","src"),e["@donotdev/core"]=P.join(t,"packages","core"))}return e}import*as h from"node:fs";import"node:fs";import{createRequire as ce}from"node:module";import{resolve as I,join as _,dirname as A,relative as J,normalize as le,sep as K,extname as ue}from"node:path";import{fileURLToPath as pe}from"node:url";import fe from"fast-glob";var C={SOURCE_ROOT:"packages/core/i18n",SOURCE_LOCALES:"packages/core/i18n/locales",SOURCE_EAGER:"packages/core/i18n/locales/eager",SOURCE_LAZY:"packages/core/i18n/locales/lazy",PUBLISHED_ROOT:"i18n",PUBLISHED_LOCALES:"i18n/locales",PUBLISHED_EAGER:"i18n/locales/eager",PUBLISHED_LAZY:"i18n/locales/lazy"},F={routes:{consumer:["src/**/*Page.tsx","src/pages/**/*Page.tsx"],exclude:["**/node_modules/**","**/dist/**","**/build/**","**/*.test.tsx","**/*.stories.tsx"],extensions:[".tsx"]},css:{consumer:["src/**/*.css"],themes:["src/**/*.css"],extensions:[".css",".scss",".sass"],framework:["packages/ui/src/**/*.css","packages/core/components/src/**/*.css","packages/core/templates/src/**/*.css"]},i18n:{eager:["src/locales/*_*.json"],lazy:["src/**/locales/*_*.json","!src/locales/*_*.json","../../entities/locales/*_*.json"],additional:[],framework:{eager:[`${C.SOURCE_EAGER}/*_*.json`],lazy:[`${C.SOURCE_LAZY}/*_*.json`]},extensions:[".json"]},assets:{consumer:["public/**/*"],fallback:["manifest.json"],modern:["logo.svg","favicon.svg","apple-touch-icon.png","android-chrome-192x192.png","android-chrome-512x512.png"],patterns:["favicon.svg","favicon.ico","favicon-*.png","logo.svg","logo.png","logo.webp","logo.avif","apple-touch-icon*.png","android-chrome-*.png","manifest.json"],fonts:["fonts/**/*.woff2","fonts/**/*.woff","fonts/**/*.ttf"],framework:["packages/ui/assets/**/*"]},pwa:{consumer:["public/manifest.json","public/service-worker.js","public/sw.js","public/icon-192x192.png","public/icon-512x512.png","public/favicon.ico","public/favicon.svg","public/apple-touch-icon.png","public/logo.svg"],exclude:["**/node_modules/**","**/dist/**","**/build/**"],extensions:[".json",".js",".png",".svg",".ico"],framework:["packages/ui/assets/**/*"]},globalIgnore:["**/node_modules/**","**/dist/**","**/build/**","**/.git/**","**/coverage/**","**/test/**"]};var H={base:{absolute:!0,onlyFiles:!0,ignore:F.globalIgnore},css:{absolute:!0,onlyFiles:!0,ignore:[...F.globalIgnore,"**/*.test.css"]},routes:{absolute:!0,onlyFiles:!0,ignore:[...F.globalIgnore,"**/*.test.tsx","**/*.stories.tsx"]},i18n:{absolute:!0,onlyFiles:!0,ignore:F.globalIgnore},assets:{absolute:!0,onlyFiles:!0,ignore:F.globalIgnore}};function Y(i,e=null){let t=F[i];if(!t)throw new Error(`Unknown pattern type: ${i}`);return e&&t.framework?{...t,framework:t.framework.map(o=>`${e}/${o}`)}:t}function V(i){return H[i]||H.base}var $={getGlobOptionsFor:V||void 0,SCAN_PATTERNS:F||void 0,getPatternsFor:Y||void 0,I18N_PATHS:C||void 0},v={error:(i,e)=>{},warn:(i,e)=>{},info:i=>{}};function z(i){return typeof i=="object"&&i!==null&&"code"in i&&i.code==="EEXIST"}function q(i,e){return i().catch(t=>{throw new Error(`${e}: ${t instanceof Error?t.message:String(t)}`)})}var Z={CLI:"packages/cli",COMPONENTS:"packages/core/components",CONFIG:"packages/core/config",CORE:"packages/core",CRUD:"packages/core/crud",FEATURES:"packages/features",HOOKS:"packages/core/hooks",I18N:"packages/core/i18n",SCHEMAS:"packages/core/schemas",STORES:"packages/core/stores",TEMPLATES:"packages/templates",TOOLING:"packages/tooling",TYPES:"packages/core/types",UI:"packages/ui",UTILS:"packages/core/utils",AUTH:"packages/features/auth",BILLING:"packages/features/billing",OAUTH:"packages/features/oauth",FIREBASE:"packages/providers/firebase",FUNCTIONS:"packages/functions"},S=class i{static _instance=null;options;_repoRoot;_appRoot=null;_writtenPaths=null;static getInstance(e={}){return i._instance||(i._instance=new i(e)),i._instance}static _reset(){i._instance=null}constructor(e={}){if(i._instance)return i._instance;this.options={maxLevels:e.maxLevels??10,customMarkers:e.customMarkers||[],cache:e.cache??!1,debug:e.debug??!1};try{let t=process.cwd();if(!t)throw new Error("PathResolver: process.cwd() returned undefined. This should never happen.");this._repoRoot=this._findRepoRoot(t)}catch(t){throw new Error(`PathResolver constructor failed: ${t instanceof Error?t.message:String(t)}. cwd: ${process.cwd()}`)}this._appRoot=null,i._instance=this}normalizePath(e){if(!e)return"";try{return le(e).split(K).join("/")}catch{return String(e).split(K).join("/")}}getRelativePath(e){let t=this.getAppRoot(),o=J(t,e);return this.normalizePath(o)}getBasename(e){if(!e)return"";let o=this.normalizePath(e).split("/");return o[o.length-1]||""}getDirname(e){return e?this.normalizePath(A(e)):""}resolvePackage(e,t=null){try{let o=t||this.getAppRoot(),s=ce(_(o,"package.json")).resolve(e);return this.normalizePath(s)}catch{return null}}resolveFrameworkPackage(e,t=null){let o=this.resolvePackage(`${e}/package.json`,t);if(o)return this.getDirname(o);if(this.isMonorepo()&&e.startsWith("@donotdev/")){let r=e.replace("@donotdev/",""),a=this.resolveRepoPath(`packages/${r}`);if(this.pathExists(a))return a;if(["auth","billing","crud","oauth"].includes(r)){let l=this.resolveRepoPath(`packages/features/${r}`);if(this.pathExists(l))return l}if(r==="firebase"){let l=this.resolveRepoPath(`packages/providers/${r}`);if(this.pathExists(l))return l}}let n=this.resolveAppPath(`node_modules/${e}`);if(this.pathExists(n))return n;let s=this.resolveRepoPath(`node_modules/${e}`);return this.pathExists(s)?s:null}resolvePackageAsset(e,t=null){return this.resolvePackage(e,t)}resolveAppPath(e){let t=this.getAppRoot(),o=I(t,e);return this.normalizePath(o)}resolveRepoPath(e){let t=this.getRepoRoot(),o=this.normalizePath(e),n=I(t,o);return this.normalizePath(n)}resolvePath(e,t){let o=this.normalizePath(t),n=this.normalizePath(e),s=I(o,n);return this.normalizePath(s)}createImportPath(e){return"./"+this.getRelativePath(e)}getFileInfo(e){try{let t=h.statSync(e);return{absolutePath:this.normalizePath(e),relativePath:this.getRelativePath(e),importPath:this.createImportPath(e),size:t.size,isFile:t.isFile(),isDirectory:t.isDirectory()}}catch{return null}}_detectFormat(e,t){return t&&t!=="auto"?t:ue(e).toLowerCase()===".json"?"json":"text"}async read(e,t={}){let{format:o="auto",encoding:n="utf8"}=t,s=this._detectFormat(e,o);try{if(s==="buffer")return await h.promises.readFile(e);let r=await h.promises.readFile(e,n),a=this.stripBom(r);return s==="json"?JSON.parse(a):a}catch(r){return this.options.debug&&v.warn(`Failed to read file: ${e}`,r),null}}readSync(e,t={}){let{format:o="auto",encoding:n="utf8"}=t,s=this._detectFormat(e,o);try{if(s==="buffer")return h.readFileSync(e);let r=h.readFileSync(e,n),a=this.stripBom(r);return s==="json"?JSON.parse(a):a}catch(r){return this.options.debug&&v.warn(`Failed to read file: ${e}`,r),null}}async write(e,t,o={}){let{format:n="auto",overwrite:s=!1,dryRun:r=!1,verbose:a=!1}=o,l=this.normalizePath(e),f=this.normalizePath(A(l)),c=this.pathExists(l);if(c&&!s)return a&&v.info(`Skipping existing file: ${l}`),!1;if(r)return v.info(`[DRY RUN] Would write file: ${l}`),!0;try{await h.promises.mkdir(f,{recursive:!0})}catch(m){if(!z(m))throw m}let u=this._detectFormat(e,n),d;Buffer.isBuffer(t)?d=t:u==="json"&&typeof t=="object"?d=`${JSON.stringify(t,null,2)}
|
|
2
|
+
`:d=String(t);try{return await q(async()=>(Buffer.isBuffer(d)?await h.promises.writeFile(l,d):await h.promises.writeFile(l,d,"utf8"),a&&v.info(`${c?"Updated":"Created"} file: ${l}`),!0),`Failed to write file: ${l}`)}catch{return!1}}writeSync(e,t,o={}){let{format:n="auto",overwrite:s=!1,dryRun:r=!1,verbose:a=!1}=o,l=this.normalizePath(e),f=this.normalizePath(A(l)),c=this.pathExists(l);if(c&&!s)return a&&v.info(`Skipping existing file: ${l}`),!1;if(r)return v.info(`[DRY RUN] Would write file: ${l}`),!0;try{h.mkdirSync(f,{recursive:!0})}catch(m){if(!z(m))throw m}let u=this._detectFormat(e,n),d;Buffer.isBuffer(t)?d=t:u==="json"&&typeof t=="object"?d=`${JSON.stringify(t,null,2)}
|
|
3
|
+
`:d=String(t);try{return Buffer.isBuffer(d)?h.writeFileSync(l,d):h.writeFileSync(l,d,"utf8"),this._writtenPaths?.add(l),a&&v.info(`${c?"Updated":"Created"} file: ${l}`),!0}catch(m){throw new Error(`Failed to write file: ${l}: ${m instanceof Error?m.message:String(m)}`)}}async copy(e,t,o={}){let{overwrite:n=!1,dryRun:s=!1,verbose:r=!1}=o,a=this.normalizePath(t),l=this.pathExists(a);if(l&&!n)return r&&v.info(`Skipping existing file: ${a}`),!1;if(s)return v.info(`[DRY RUN] Would copy file: ${a}`),!0;let f=this.normalizePath(A(a));try{await h.promises.mkdir(f,{recursive:!0})}catch(c){if(!z(c))throw c}try{return await q(async()=>(await h.promises.copyFile(e,a),r&&v.info(`${l?"Updated":"Created"} file: ${a}`),!0),`Failed to copy file from ${e} to ${a}`)}catch{return!1}}copySync(e,t,o={}){let{overwrite:n=!1,dryRun:s=!1,verbose:r=!1}=o,a=this.normalizePath(t),l=this.pathExists(a);if(l&&!n)return r&&v.info(`Skipping existing file: ${a}`),!1;if(s)return v.info(`[DRY RUN] Would copy file: ${a}`),!0;let f=this.normalizePath(A(a));try{h.mkdirSync(f,{recursive:!0})}catch(c){if(!z(c))throw c}try{return h.copyFileSync(e,a),this._writtenPaths?.add(a),r&&v.info(`${l?"Updated":"Created"} file: ${a}`),!0}catch{return!1}}pathExists(e,t=!1){try{return h.existsSync(e)}catch(o){return t||v.error(`Error checking path existence: ${e}`,o),!1}}mkdir(e){try{let t=e.startsWith("/")||e.match(/^[A-Z]:/)?this.normalizePath(e):this.resolveAppPath(e);return h.existsSync(t)||h.mkdirSync(t,{recursive:!0}),!0}catch{return!1}}readdirSync(e,t){try{return h.readdirSync(e,t)}catch(o){return this.options.debug&&v.warn(`Failed to read directory: ${e}`,o),t&&typeof t=="object"&&"withFileTypes"in t&&t.withFileTypes?[]:[]}}statSync(e){try{return h.statSync(e)}catch(t){return this.options.debug&&v.warn(`Failed to stat file: ${e}`,t),null}}realpathSync(e){return h.realpathSync(e)}watch(e,t,o){return h.watch(e,t,o)}lstatSync(e){try{return h.lstatSync(e)}catch(t){return this.options.debug&&v.warn(`Failed to lstat file: ${e}`,t),null}}async ensureDir(e){try{await h.promises.mkdir(e,{recursive:!0})}catch(t){if(!z(t))throw t}}ensureDirSync(e){try{h.mkdirSync(e,{recursive:!0})}catch(t){if(!z(t))throw t}}async remove(e){await h.promises.rm(e,{recursive:!0,force:!0})}removeSync(e){h.rmSync(e,{recursive:!0,force:!0})}async readdir(e,t){return h.promises.readdir(e,t)}stripBom(e){return e.charCodeAt(0)===65279?e.slice(1):e}getRepoRoot(){return this._repoRoot||process.cwd()}startWriteRecording(){this._writtenPaths=new Set}stopWriteRecording(){if(!this._writtenPaths)throw new Error("stopWriteRecording() called without startWriteRecording()");let e=this._writtenPaths;return this._writtenPaths=null,e}getAppRoot(){return this._appRoot?this._appRoot:this._repoRoot}setAppRoot(e){if(!e)throw new Error("PathResolver.setAppRoot: root cannot be undefined or null");this._appRoot=this.normalizePath(e)}isMonorepo(){let e=_(this._repoRoot,"packages");return this.pathExists(e)}isWithinApp(e){let t=this.normalizePath(I(e)),o=this.getAppRoot(),n=J(o,t),s=this.normalizePath(n);return!s.startsWith("../")&&!s.startsWith("/")}async findFiles(e,t,o={}){let n=this.normalizePath(_(e,t)),s=this.getAppRoot(),r=this.normalizePath(s),a=n.startsWith(r)?n.slice(r.length+1):n,l={absolute:!0,onlyFiles:!0,braceExpansion:!0,extglob:!0,globstar:!0,cwd:s,ignore:$.SCAN_PATTERNS?.globalIgnore||["**/node_modules/**","**/dist/**","**/build/**","**/.git/**"]};return await this._globWithNormalization([a],{...l,...o})}clearCache(){}async _resolveFrameworkI18nPattern(e){let t=$.I18N_PATHS;if(!t)return null;let o=e.replace(t.SOURCE_ROOT+"/",""),n=this.resolveFrameworkPackage("@donotdev/core");if(!n)return null;let s=this.normalizePath(_(n,t.PUBLISHED_ROOT,o)),r=s.replace(/\/[^/]*\*.*$/,"");return this.pathExists(r),s}async _globWithNormalization(e,t){return(await fe(e,t)).map(n=>{let s=typeof n=="string"?n:n.path;return this.normalizePath(s)})}async resolveFiles(e,t="css"){if(!e||typeof e!="object")return{frameworkFiles:[],consumerFiles:[]};if(t==="i18n")return{frameworkFiles:[],consumerFiles:[]};if(Array.isArray(e.framework)||(e.framework=[]),!Array.isArray(e.consumer))return{frameworkFiles:[],consumerFiles:[]};let o=[...e.framework,...e.consumer];for(let c of o)if(typeof c!="string"||c.trim()==="")return{frameworkFiles:[],consumerFiles:[]};let n=this.getAppRoot(),s=$.getGlobOptionsFor?$.getGlobOptionsFor(t):{ignore:["**/node_modules/**","**/dist/**","**/build/**"]},r=this.normalizePath(n),a=e.framework.map(c=>{let u=this.normalizePath(c);return u.startsWith(r)?u.slice(r.length+1):u}),l=e.consumer.map(c=>{let u=this.normalizePath(c);return u.startsWith(r)?u.slice(r.length+1):u}),f={...s,onlyFiles:!0,absolute:!0,braceExpansion:!0,extglob:!0,globstar:!0,cwd:n};try{let c=a.length>0?await this._globWithNormalization(a,f):[],u=await this._globWithNormalization(l,f);return{frameworkFiles:c,consumerFiles:u}}catch{return this.options.debug,{frameworkFiles:[],consumerFiles:[]}}}async resolvePatterns(e){if(!$.getPatternsFor)return{framework:[],consumer:[],all:[]};let t=this.getAppRoot(),o=this.getRepoRoot();if(e==="i18n"&&(!t||t===o))throw new Error(`Cannot resolve i18n patterns: appRoot not set (appRoot: ${t}, repoRoot: ${o}). Ensure configResolved hook has run before discovery.`);let n=$.getPatternsFor(e),s=this.isMonorepo();if(e==="i18n"){let l=n,f={eager:l.eager.map(c=>c.startsWith("!")?"!"+this.resolveAppPath(c.slice(1)):this.resolveAppPath(c)),lazy:l.lazy.map(c=>c.startsWith("!")?"!"+this.resolveAppPath(c.slice(1)):this.resolveAppPath(c)),framework:{eager:s?(l.framework?.eager||[]).map(c=>this.resolveRepoPath(c)).filter(Boolean):await Promise.all((l.framework?.eager||[]).map(c=>this._resolveFrameworkI18nPattern(c))).then(c=>c.filter(Boolean)),lazy:s?(l.framework?.lazy||[]).map(c=>this.resolveRepoPath(c)).filter(Boolean):await Promise.all((l.framework?.lazy||[]).map(c=>this._resolveFrameworkI18nPattern(c))).then(c=>c.filter(Boolean))},all:[]};return f.all=[...f.eager,...f.lazy,...f.framework.eager,...f.framework.lazy],f}let r=n,a={framework:s?(r.framework||[]).map(l=>this.resolveRepoPath(l)).filter(Boolean):[],consumer:(r.consumer||[]).map(l=>this.resolveAppPath(l)),all:[]};return a.all=[...a.consumer,...a.framework],a}getEmptyModulePath(){return this.getEmptyCjsModulePath().replace(/\.cjs$/,".js")}getEmptyFlagModulePath(){let e=A(pe(import.meta.url));return this.normalizePath(I(e,"emptyFlag.js"))}getEmptyCjsModulePath(){let e=this.resolvePackage("@donotdev/core/empty");if(!e)throw new Error("Cannot resolve @donotdev/core/empty \u2014 package setup is broken");return e}_findRepoRoot(e){let t=this.normalizePath(e),o=0,n=this.options.maxLevels;for(;o<n;){let s=this.normalizePath(_(t,Z.TOOLING)),r=this.normalizePath(_(t,Z.CORE));if(this.pathExists(s)&&this.pathExists(r))return t;let a=_(t,"apps");if(this.pathExists(a)&&this.statSync(a)?.isDirectory())return this.normalizePath(t);let l=this.normalizePath(_(t,"package.json"));if(this.pathExists(l)&&this.normalizePath(A(t))===t)return t;let f=this.normalizePath(A(t));if(f===t)break;t=f,o++}return this.normalizePath(e)}};function L(i={}){let{entry:e="src/index.ts",outDir:t="lib",minify:o=!1,sourcemap:n=!0,platform:s="firebase",workspace:r,bundleWorkspaceDeps:a=!1,importFramework:l=!1,external:f=!1,...c}=i,u=S.getInstance(),d=G(r),m={entryPoints:[e],bundle:!0,platform:"node",target:"node20",format:"esm",outdir:t,outExtension:{".js":".js"},minify:o,sourcemap:n,metafile:!0,logLevel:"info",loader:{".ts":"ts",".tsx":"tsx",".css":"empty"},keepNames:!0,treeShaking:!0,...c};a&&Object.keys(d).length>0&&(m.alias=Object.fromEntries(Object.entries(d).map(([y,p])=>[y,u.normalizePath(p)]))),m.mainFields=["module","main"],m.conditions=["react-server","import","module","node"];let R=["fs","path","crypto","util","stream","events","buffer","url","querystring","http","https","zlib","os","child_process","assert","constants","domain","punycode","string_decoder","timers","tty","vm","worker_threads","perf_hooks","async_hooks"],j=[];if(a)try{let y=r?.root||process.cwd(),p=process.cwd(),g=10;for(let k=0;k<g;k++){let x=u.normalizePath(`${p}/package.json`);if(u.pathExists(x)){let w=u.readSync(x,{format:"json"});if(w&&Array.isArray(w.workspaces)){y=u.normalizePath(p);for(let O of w.workspaces)O==="apps/*"||O==="functions"||!O.includes("*")&&!O.includes("/")&&j.push(O);break}}let E=u.getDirname(p);if(E===p)break;p=E}}catch{}let M={name:"external-node-modules",setup(y){y.onResolve({filter:/^firebase($|\/)/},p=>{if(p.path==="firebase-admin"||p.path.startsWith("firebase-admin/")||p.path==="firebase-functions"||p.path.startsWith("firebase-functions/"))return null;let g;if(r?.type==="dndev"&&r.root)g=u.normalizePath(`${r.root}/packages/core/config/functions/firebase-stub.js`);else{let k=import.meta.url,E=new URL(k).pathname.replace(/^\/([A-Z]:)/i,"$1"),w=u.getDirname(E);g=u.normalizePath(`${w}/firebase-stub.js`)}return{path:g}}),y.onResolve({filter:/.*/},p=>{if(p.kind==="entry-point")return null;if(p.path.match(/@donotdev\/functions\/.+/)&&a&&r?.type==="dndev"){let g=p.path.replace("@donotdev/functions/","");return{path:u.normalizePath(`${r.root}/packages/functions/src/${g}/index.ts`)}}if(p.path==="@donotdev/utils")return r?.type==="dndev"?{path:u.normalizePath(`${r.root}/packages/core/utils/src/server/index.ts`)}:y.resolve("@donotdev/utils/server",{kind:p.kind,resolveDir:p.resolveDir});if(p.path.match(/@donotdev\/utils\/.+/)&&r?.type==="dndev"){let g=p.path.replace("@donotdev/utils/","");return{path:u.normalizePath(`${r.root}/packages/core/utils/src/${g}/index.ts`)}}if(p.path==="@donotdev/supabase")return r?.type==="dndev"?{path:u.normalizePath(`${r.root}/packages/providers/supabase/src/server/index.ts`)}:y.resolve("@donotdev/supabase/server",{kind:p.kind,resolveDir:p.resolveDir});if(p.path==="@donotdev/core")return r?.type==="dndev"?{path:u.normalizePath(`${r.root}/packages/core/server.ts`)}:y.resolve("@donotdev/core/server",{kind:p.kind,resolveDir:p.resolveDir});if(p.path.match(/@donotdev\/core\/.+/)&&a&&r?.type==="dndev"){let g=p.path.replace("@donotdev/core/","");return{path:u.normalizePath(`${r.root}/packages/core/${g}.ts`)}}if(p.path==="firebase-admin"||p.path.startsWith("firebase-admin/")||p.path==="firebase-functions"||p.path.startsWith("firebase-functions/"))return{path:p.path,external:!0};if(p.path.match(/@donotdev\/core\/.+/)&&a&&r?.type==="dndev"){let g=p.path.replace("@donotdev/core/","");return{path:u.normalizePath(`${r.root}/packages/core/${g}.ts`)}}if(p.path.startsWith("@donotdev/")||p.path==="valibot"||p.path.startsWith("valibot/"))return null;if(j.length>0){let g=p.path.split("/")[0];if(j.includes(g))return null}return p.path.startsWith(".")||p.path.startsWith("/")?null:{path:p.path,external:!0}})}};if(m.external=[...R,"firebase-admin","firebase-functions"],m.plugins=[M,...m.plugins||[]],m.define={"process.env.NODE_ENV":JSON.stringify(process.env.NODE_ENV||"production"),...m.define||{}},l&&r.type==="dndev"){let y=r.root,p=u.normalizePath(`${y}/functions/lib`);m.alias={...m.alias,"@donotdev/functions":p}}if(s==="framework"){let y=S.getInstance(),p=r?.root?y.normalizePath(`${r.root}/packages/functions`):process.cwd(),g=y.normalizePath(`${p}/package.json`),k=y.readSync(g,{format:"json"});if(k?.exports){let x={};for(let[,E]of Object.entries(k.exports)){let w=E?.import||E?.default||(typeof E=="string"?E:null);if(!w||!w.endsWith(".ts"))continue;let O=w.replace(/^\.\/src\//,"").replace(/\.ts$/,"");x[O]=w}Object.keys(x).length>0&&(m.entryPoints=x,m.splitting=!0,m.chunkNames="chunks/[name]-[hash]")}}return m}var b=S.getInstance(),W=["create","get","list","listCard","update","delete","bulk"];function X(i,e=0){let t=" ".repeat(e),o="";for(let[n,s]of Object.entries(i))if(s!=null)if(typeof s=="object"&&!Array.isArray(s))Object.keys(s).length===0?o+=`${t}${n}: {}
|
|
4
4
|
`:o+=`${t}${n}:
|
|
5
5
|
${X(s,e+1)}`;else if(Array.isArray(s))if(s.length===0)o+=`${t}${n}: []
|
|
6
6
|
`;else{o+=`${t}${n}:
|
|
7
|
-
`;for(let r of s)if(typeof r=="object"&&r!==null){let
|
|
8
|
-
`;for(let c=1;c<
|
|
7
|
+
`;for(let r of s)if(typeof r=="object"&&r!==null){let a=Object.entries(r),[l,f]=a[0];o+=`${t} - ${l}: ${f}
|
|
8
|
+
`;for(let c=1;c<a.length;c++){let[u,d]=a[c];o+=`${t} ${u}: ${d}
|
|
9
9
|
`}}else o+=`${t} - ${r}
|
|
10
10
|
`}else o+=`${t}${n}: ${s}
|
|
11
|
-
`;return o}var
|
|
11
|
+
`;return o}var de=["X_GOOGLE_","FIREBASE_","EXT_","GCLOUD_"],he=["FIREBASE_REGION","FIREBASE_PROJECT_ID","FIREBASE_AUTH_DOMAIN","ENABLE_RATE_LIMITING","DISABLE_RATE_LIMITING","ENABLE_METRICS","DISABLE_METRICS","ENFORCE_APP_CHECK"];function Q(i){if(!b.pathExists(i))return[];let e=b.readSync(i,{format:"text"}),t=[],o=e.matchAll(/export\s*\{([^}]+)\}/g);for(let s of o)if(s[1]){let r=s[1].split(",").map(a=>{let l=a.trim().split(/\s+as\s+/);return(l[1]||l[0]||"").trim()}).filter(Boolean);t.push(...r)}let n=e.matchAll(/export\s+const\s+(\w+)/g);for(let s of n)s[1]&&t.push(s[1]);return[...new Set(t)]}function N(i=".env"){if(!b.pathExists(i))return[];let e=b.readSync(i),t=[];for(let o of e.split(/\r?\n/)){let n=o.trim();if(!n||n.startsWith("#"))continue;let s=n.indexOf("=");if(s<=0)continue;let r=n.substring(0,s).trim();he.includes(r)||de.some(a=>r.startsWith(a))||t.push(r)}return t}function ee(i){return W.some(e=>i.startsWith(`${e}_`))}function te(i,e={}){let t=i.defaults||{},o=t.labels||{},n={},s=e.envPath?N(e.envPath):N(),r=s.length>0?s.map(u=>({key:u})):void 0,a=e.entryFile?Q(e.entryFile):[],l=i.functions||{},f=new Set(Object.keys(l));for(let u of a)!ee(u)&&!f.has(u)&&f.add(u);for(let u of f){let d=l[u]||{},m={...o,...d.labels};d.category&&(m.category=d.category),n[u]={region:d.region||t.region||["europe-west1"],platform:d.platform||t.platform||"gcfv2",entryPoint:d.entryPoint||u,labels:m},d.trigger==="http"?n[u].httpsTrigger={}:n[u].callableTrigger={},d.secrets?.length?n[u].secretEnvironmentVariables=d.secrets.map(R=>({key:R})):r&&(n[u].secretEnvironmentVariables=r)}if(i.crud?.entities)for(let u of i.crud.entities)for(let d of W){let m=`${d}_${u}`;n[m]={region:t.region||["europe-west1"],platform:t.platform||"gcfv2",callableTrigger:{},entryPoint:m,labels:{...o,category:"crud"}},r&&(n[m].secretEnvironmentVariables=r)}return`# Firebase Functions Configuration
|
|
12
12
|
# Generated by @donotdev/core/functions - DO NOT EDIT MANUALLY
|
|
13
13
|
# Generated at: ${new Date().toISOString()}
|
|
14
14
|
|
|
15
|
-
`+X({endpoints:n,specVersion:"v1alpha1",requiredAPIs:[]})}function
|
|
15
|
+
`+X({endpoints:n,specVersion:"v1alpha1",requiredAPIs:[]})}function re(i){let e=i.crud?.entities||[],o=[`// Auto-generated CRUD exports - DO NOT EDIT MANUALLY
|
|
16
16
|
// Generated by @donotdev/core/functions at ${new Date().toISOString()}
|
|
17
17
|
|
|
18
18
|
import * as entities from 'entities';
|
|
19
19
|
import { createCrudFunctions } from '@donotdev/functions/firebase';
|
|
20
20
|
|
|
21
21
|
const crud = createCrudFunctions(entities);
|
|
22
|
-
`];for(let n of e){let s=[""];for(let r of
|
|
22
|
+
`];for(let n of e){let s=[""];for(let r of W){let a=`${r}_${n}`;s.push(`export const ${a} = crud['${a}'];`)}o.push(s.join(`
|
|
23
23
|
`))}return o.join(`
|
|
24
24
|
`)+`
|
|
25
|
-
`}function
|
|
26
|
-
`));let
|
|
25
|
+
`}function U(i,e={}){let t=Object.keys(i.functions||{}),o=[];if(i.crud?.entities)for(let l of i.crud.entities)for(let f of W)o.push(`${f}_${l}`);let s=(e.entryFile?Q(e.entryFile):[]).filter(l=>!ee(l)&&!t.includes(l)),r=[...t,...s],a=e.envPath?N(e.envPath):N();return{yaml:te(i,e),functions:[...r,...o],staticFunctions:r,crudFunctions:o,autoDetected:s,autoSecrets:a}}function B(i){let e=new Set;for(let f of Object.values(i.functions||{}))if(f.secrets)for(let c of f.secrets)e.add(c);let t=N();for(let f of t)e.add(f);if(e.size===0||!b.pathExists(".env"))return{stripped:[],kept:0};let n=b.readSync(".env").split(/\r?\n/),s=[],r=[];for(let f of n){let c=f.trim();if(!c||c.startsWith("#")){s.push(f);continue}let u=c.indexOf("="),d=u>0?c.substring(0,u).trim():"";e.has(d)?r.push(f):s.push(f)}if(r.length===0)return{stripped:[],kept:s.length};b.writeSync(".env",s.join(`
|
|
26
|
+
`));let a=`# Secrets managed by sync-secrets (auto-filtered by build)
|
|
27
27
|
`;if(b.pathExists(".env.local")){let f=b.readSync(".env.local"),c=new Set(f.split(/\r?\n/).filter(d=>d.trim()&&!d.trim().startsWith("#")).map(d=>d.split("=")[0].trim())),u=r.filter(d=>!c.has(d.split("=")[0].trim()));u.length>0&&b.writeSync(".env.local",f.trimEnd()+`
|
|
28
|
-
`+
|
|
28
|
+
`+a+u.join(`
|
|
29
29
|
`)+`
|
|
30
|
-
`)}else b.writeSync(".env.local",
|
|
30
|
+
`)}else b.writeSync(".env.local",a+r.join(`
|
|
31
31
|
`)+`
|
|
32
|
-
`);return{stripped:r.map(f=>f.split("=")[0].trim()),kept:s.length}}function
|
|
32
|
+
`);return{stripped:r.map(f=>f.split("=")[0].trim()),kept:s.length}}function me(i={}){let e=T();return L({...i,platform:"firebase",bundleWorkspaceDeps:!0,importFramework:!0,workspace:e})}async function ge(i,e={}){let{entry:t="src/index.ts",outDir:o="lib",minify:n=process.env.NODE_ENV==="production",sourcemap:s=!0,analyze:r=!1,entryFile:a="src/index.ts",envPath:l=".env",...f}=e;try{let c=S.getInstance(),u=re(i);c.writeSync("src/.generated/crud-exports.ts",u,{overwrite:!0});let{build:d}=await import("esbuild"),m=me({entry:t,outDir:o,minify:n,sourcemap:s,...f}),R=await d(m);R.errors.length>0&&process.exit(1),R.warnings.length>0;let{yaml:j,staticFunctions:M,crudFunctions:y,autoDetected:p,autoSecrets:g}=U(i,{entryFile:a,envPath:l});c.writeSync("functions.yaml",j,{overwrite:!0}),p.length>0,g.length>0;let{stripped:k}=B(i);if(k.length>0,r&&R.metafile){let{analyzeMetafile:x}=await import("esbuild"),E=await x(R.metafile)}}catch{process.exit(1)}}function se(i={}){let{entry:e="src/index.ts",outDir:t="lib",minify:o=!1,sourcemap:n=!0,platform:s="firebase",...r}=i,a=T();return L({entry:e,outDir:t,minify:o,sourcemap:n,platform:s,workspace:a,...r})}function Be(i={}){return se({...i,platform:"framework",bundleWorkspaceDeps:!0})}function Me(i={}){return se({...i,platform:"firebase",bundleWorkspaceDeps:!0,importFramework:!0})}export{ge as buildFunctions,Me as createAppFunctionsConfig,se as createFunctionsEsbuildConfig,Be as createRootFunctionsConfig,B as filterEnvSecrets,te as generateFunctionsYaml,U as generateFunctionsYamlWithInfo};
|