@donotdev/cli 0.0.6 → 0.0.7
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/dependencies-matrix.json +25 -7
- package/dist/bin/commands/build.js +156 -158
- package/dist/bin/commands/bump.js +153 -153
- package/dist/bin/commands/cacheout.js +154 -154
- package/dist/bin/commands/create-app.js +184 -156
- package/dist/bin/commands/create-project.js +154 -154
- package/dist/bin/commands/deploy.js +470 -470
- package/dist/bin/commands/dev.js +155 -155
- package/dist/bin/commands/emu.js +155 -155
- package/dist/bin/commands/format.js +154 -154
- package/dist/bin/commands/lint.js +157 -154
- package/dist/bin/commands/preview.js +155 -155
- package/dist/bin/commands/sync-secrets.js +155 -155
- package/dist/bin/commands/wai.d.ts +11 -0
- package/dist/bin/commands/wai.d.ts.map +1 -0
- package/dist/bin/commands/wai.js +12 -0
- package/dist/bin/commands/wai.js.map +1 -0
- package/dist/bin/dndev.js +24 -8
- package/dist/bin/donotdev.js +24 -8
- package/dist/index.js +524 -497
- package/package.json +1 -1
- package/templates/app-demo/src/config/app.ts.example +12 -0
- package/templates/app-next/src/config/app.ts.example +75 -48
- package/templates/app-vite/index.html.example +71 -37
- package/templates/app-vite/src/config/app.ts.example +75 -47
- package/templates/app-vite/src/pages/FormPageExample.tsx.example +152 -0
- package/templates/app-vite/src/pages/HomePage.tsx.example +81 -134
- package/templates/app-vite/src/pages/ListPageExample.tsx.example +88 -0
- package/templates/functions-firebase/build.mjs.example +8 -1
- package/templates/functions-firebase/functions-firebase/build.mjs.example +8 -1
- package/templates/functions-firebase/functions-firebase/src/index.ts.example +19 -25
- package/templates/functions-firebase/functions.config.js.example +35 -0
- package/templates/root-consumer/entities/ExampleEntity.ts.example +223 -0
- package/templates/root-consumer/entities/demo.ts.example +562 -0
- package/templates/root-consumer/entities/index.ts.example +15 -0
- package/templates/root-consumer/guides/{AGENT_START_HERE.md.example → dndev/AGENT_START_HERE.md.example} +22 -0
- package/templates/root-consumer/guides/dndev/COMPONENTS_CRUD.md.example +231 -0
- package/templates/root-consumer/guides/{SETUP_AUTH.md.example → dndev/SETUP_AUTH.md.example} +30 -0
- package/templates/root-consumer/guides/dndev/SETUP_CRUD.md.example +473 -0
- package/templates/root-consumer/guides/dndev/SETUP_FUNCTIONS.md.example +116 -0
- package/templates/root-consumer/guides/wai-way/WAI_WAY_CLI.md.example +404 -0
- package/templates/root-consumer/guides/wai-way/agents/architect.md.example +78 -0
- package/templates/root-consumer/guides/wai-way/agents/builder.md.example +87 -0
- package/templates/root-consumer/guides/wai-way/agents/extractor.md.example +325 -0
- package/templates/root-consumer/guides/wai-way/agents/polisher.md.example +100 -0
- package/templates/root-consumer/guides/wai-way/blueprints/0_brainstorm.md.example +281 -0
- package/templates/root-consumer/guides/wai-way/blueprints/1_scaffold.md.example +77 -0
- package/templates/root-consumer/guides/wai-way/blueprints/2_entities.md.example +104 -0
- package/templates/root-consumer/guides/wai-way/blueprints/3_compose.md.example +124 -0
- package/templates/root-consumer/guides/wai-way/blueprints/4_configure.md.example +165 -0
- package/templates/root-consumer/guides/wai-way/context_map.json.example +95 -0
- package/templates/root-consumer/guides/wai-way/entity_patterns.md.example +840 -0
- package/templates/root-consumer/guides/wai-way/page_patterns.md.example +686 -0
- package/templates/root-consumer/guides/wai-way/presets_guide.md.example +217 -0
- package/templates/root-consumer/guides/wai-way/spec_template.md.example +312 -0
- package/templates/functions-firebase/functions-firebase/src/crud/createEntity.ts.example +0 -19
- package/templates/functions-firebase/functions-firebase/src/crud/deleteEntity.ts.example +0 -14
- package/templates/functions-firebase/functions-firebase/src/crud/getEntity.ts.example +0 -14
- package/templates/functions-firebase/functions-firebase/src/crud/index.ts.example +0 -12
- package/templates/functions-firebase/functions-firebase/src/crud/listEntities.ts.example +0 -14
- package/templates/functions-firebase/functions-firebase/src/crud/updateEntity.ts.example +0 -14
- package/templates/root-consumer/guides/COMPONENTS_CRUD.md.example +0 -70
- package/templates/root-consumer/guides/SETUP_CRUD.md.example +0 -1244
- package/templates/root-consumer/guides/SETUP_FUNCTIONS.md.example +0 -114
- /package/templates/root-consumer/guides/{COMPONENTS_ADV.md.example → dndev/COMPONENTS_ADV.md.example} +0 -0
- /package/templates/root-consumer/guides/{COMPONENTS_ATOMIC.md.example → dndev/COMPONENTS_ATOMIC.md.example} +0 -0
- /package/templates/root-consumer/guides/{COMPONENTS_UI.md.example → dndev/COMPONENTS_UI.md.example} +0 -0
- /package/templates/root-consumer/guides/{ENV_SETUP.md.example → dndev/ENV_SETUP.md.example} +0 -0
- /package/templates/root-consumer/guides/{INDEX.md.example → dndev/INDEX.md.example} +0 -0
- /package/templates/root-consumer/guides/{SETUP_APP_CONFIG.md.example → dndev/SETUP_APP_CONFIG.md.example} +0 -0
- /package/templates/root-consumer/guides/{SETUP_BILLING.md.example → dndev/SETUP_BILLING.md.example} +0 -0
- /package/templates/root-consumer/guides/{SETUP_I18N.md.example → dndev/SETUP_I18N.md.example} +0 -0
- /package/templates/root-consumer/guides/{SETUP_LAYOUTS.md.example → dndev/SETUP_LAYOUTS.md.example} +0 -0
- /package/templates/root-consumer/guides/{SETUP_OAUTH.md.example → dndev/SETUP_OAUTH.md.example} +0 -0
- /package/templates/root-consumer/guides/{SETUP_PAGES.md.example → dndev/SETUP_PAGES.md.example} +0 -0
- /package/templates/root-consumer/guides/{SETUP_PWA.md.example → dndev/SETUP_PWA.md.example} +0 -0
- /package/templates/root-consumer/guides/{SETUP_THEMES.md.example → dndev/SETUP_THEMES.md.example} +0 -0
- /package/templates/root-consumer/guides/{USE_ROUTING.md.example → dndev/USE_ROUTING.md.example} +0 -0
- /package/templates/root-consumer/guides/{advanced → dndev/advanced}/APP_CHECK.md.example +0 -0
- /package/templates/root-consumer/guides/{advanced → dndev/advanced}/COOKIE_REFERENCE.md.example +0 -0
- /package/templates/root-consumer/guides/{advanced → dndev/advanced}/EMULATORS.md.example +0 -0
- /package/templates/root-consumer/guides/{advanced → dndev/advanced}/VERSION_CONTROL.md.example +0 -0
|
@@ -942,155 +942,6 @@ var init_cli_output = __esm({
|
|
|
942
942
|
}
|
|
943
943
|
});
|
|
944
944
|
|
|
945
|
-
// packages/core/config/constants.js
|
|
946
|
-
function getPatternsFor(type, repoRoot = null) {
|
|
947
|
-
const patterns = SCAN_PATTERNS[type];
|
|
948
|
-
if (!patterns) {
|
|
949
|
-
throw new Error(`Unknown pattern type: ${type}`);
|
|
950
|
-
}
|
|
951
|
-
if (repoRoot && patterns.framework) {
|
|
952
|
-
return {
|
|
953
|
-
...patterns,
|
|
954
|
-
framework: patterns.framework.map((pattern) => `${repoRoot}/${pattern}`)
|
|
955
|
-
};
|
|
956
|
-
}
|
|
957
|
-
return patterns;
|
|
958
|
-
}
|
|
959
|
-
function getGlobOptionsFor(type) {
|
|
960
|
-
return GLOB_OPTIONS[type] || GLOB_OPTIONS.base;
|
|
961
|
-
}
|
|
962
|
-
var I18N_PATHS, SCAN_PATTERNS, GLOB_OPTIONS;
|
|
963
|
-
var init_constants = __esm({
|
|
964
|
-
"packages/core/config/constants.js"() {
|
|
965
|
-
"use strict";
|
|
966
|
-
init_utils();
|
|
967
|
-
I18N_PATHS = {
|
|
968
|
-
// Monorepo source structure (locales at root, not in src/)
|
|
969
|
-
SOURCE_ROOT: "packages/core/i18n",
|
|
970
|
-
SOURCE_LOCALES: "packages/core/i18n/locales",
|
|
971
|
-
SOURCE_EAGER: "packages/core/i18n/locales/eager",
|
|
972
|
-
SOURCE_LAZY: "packages/core/i18n/locales/lazy",
|
|
973
|
-
// Published structure (same as source - no flattening needed)
|
|
974
|
-
PUBLISHED_ROOT: "i18n",
|
|
975
|
-
PUBLISHED_LOCALES: "i18n/locales",
|
|
976
|
-
PUBLISHED_EAGER: "i18n/locales/eager",
|
|
977
|
-
PUBLISHED_LAZY: "i18n/locales/lazy"
|
|
978
|
-
};
|
|
979
|
-
SCAN_PATTERNS = {
|
|
980
|
-
routes: {
|
|
981
|
-
consumer: ["src/**/*Page.tsx", "src/pages/**/*Page.tsx"],
|
|
982
|
-
exclude: [
|
|
983
|
-
"**/node_modules/**",
|
|
984
|
-
"**/dist/**",
|
|
985
|
-
"**/build/**",
|
|
986
|
-
"**/*.test.tsx",
|
|
987
|
-
"**/*.stories.tsx"
|
|
988
|
-
],
|
|
989
|
-
extensions: [".tsx"]
|
|
990
|
-
},
|
|
991
|
-
css: {
|
|
992
|
-
consumer: ["src/**/*.css"],
|
|
993
|
-
themes: ["src/**/*.css"],
|
|
994
|
-
extensions: [".css", ".scss", ".sass"],
|
|
995
|
-
framework: [
|
|
996
|
-
"packages/ui/src/**/*.css",
|
|
997
|
-
"packages/core/components/src/**/*.css",
|
|
998
|
-
"packages/core/templates/src/**/*.css"
|
|
999
|
-
]
|
|
1000
|
-
},
|
|
1001
|
-
i18n: {
|
|
1002
|
-
eager: ["src/locales/*_*.json"],
|
|
1003
|
-
lazy: ["src/**/locales/*_*.json", "!src/locales/*_*.json"],
|
|
1004
|
-
framework: {
|
|
1005
|
-
eager: [`${I18N_PATHS.SOURCE_EAGER}/*_*.json`],
|
|
1006
|
-
lazy: [`${I18N_PATHS.SOURCE_LAZY}/*_*.json`]
|
|
1007
|
-
},
|
|
1008
|
-
extensions: [".json"]
|
|
1009
|
-
},
|
|
1010
|
-
assets: {
|
|
1011
|
-
consumer: ["public/**/*"],
|
|
1012
|
-
fallback: ["manifest.json"],
|
|
1013
|
-
modern: [
|
|
1014
|
-
"logo.svg",
|
|
1015
|
-
"favicon.svg",
|
|
1016
|
-
"apple-touch-icon.png",
|
|
1017
|
-
"android-chrome-192x192.png",
|
|
1018
|
-
"android-chrome-512x512.png"
|
|
1019
|
-
],
|
|
1020
|
-
patterns: [
|
|
1021
|
-
"favicon.svg",
|
|
1022
|
-
"favicon.ico",
|
|
1023
|
-
"favicon-*.png",
|
|
1024
|
-
"logo.svg",
|
|
1025
|
-
"logo.png",
|
|
1026
|
-
"logo.webp",
|
|
1027
|
-
"logo.avif",
|
|
1028
|
-
"apple-touch-icon*.png",
|
|
1029
|
-
"android-chrome-*.png",
|
|
1030
|
-
"manifest.json"
|
|
1031
|
-
],
|
|
1032
|
-
fonts: ["fonts/**/*.woff2", "fonts/**/*.woff", "fonts/**/*.ttf"],
|
|
1033
|
-
framework: ["packages/ui/assets/**/*"]
|
|
1034
|
-
},
|
|
1035
|
-
pwa: {
|
|
1036
|
-
consumer: [
|
|
1037
|
-
"public/manifest.json",
|
|
1038
|
-
"public/service-worker.js",
|
|
1039
|
-
"public/sw.js",
|
|
1040
|
-
"public/icon-192x192.png",
|
|
1041
|
-
"public/icon-512x512.png",
|
|
1042
|
-
"public/favicon.ico",
|
|
1043
|
-
"public/favicon.svg",
|
|
1044
|
-
"public/apple-touch-icon.png",
|
|
1045
|
-
"public/logo.svg"
|
|
1046
|
-
],
|
|
1047
|
-
exclude: ["**/node_modules/**", "**/dist/**", "**/build/**"],
|
|
1048
|
-
extensions: [".json", ".js", ".png", ".svg", ".ico"],
|
|
1049
|
-
framework: ["packages/ui/assets/**/*"]
|
|
1050
|
-
},
|
|
1051
|
-
globalIgnore: [
|
|
1052
|
-
"**/node_modules/**",
|
|
1053
|
-
"**/dist/**",
|
|
1054
|
-
"**/build/**",
|
|
1055
|
-
"**/.git/**",
|
|
1056
|
-
"**/coverage/**",
|
|
1057
|
-
"**/test/**"
|
|
1058
|
-
]
|
|
1059
|
-
};
|
|
1060
|
-
GLOB_OPTIONS = {
|
|
1061
|
-
base: {
|
|
1062
|
-
absolute: true,
|
|
1063
|
-
onlyFiles: true,
|
|
1064
|
-
ignore: SCAN_PATTERNS.globalIgnore
|
|
1065
|
-
},
|
|
1066
|
-
css: {
|
|
1067
|
-
absolute: true,
|
|
1068
|
-
onlyFiles: true,
|
|
1069
|
-
ignore: [...SCAN_PATTERNS.globalIgnore, "**/*.test.css"]
|
|
1070
|
-
},
|
|
1071
|
-
routes: {
|
|
1072
|
-
absolute: true,
|
|
1073
|
-
onlyFiles: true,
|
|
1074
|
-
ignore: [
|
|
1075
|
-
...SCAN_PATTERNS.globalIgnore,
|
|
1076
|
-
"**/*.test.tsx",
|
|
1077
|
-
"**/*.stories.tsx"
|
|
1078
|
-
]
|
|
1079
|
-
},
|
|
1080
|
-
i18n: {
|
|
1081
|
-
absolute: true,
|
|
1082
|
-
onlyFiles: true,
|
|
1083
|
-
ignore: SCAN_PATTERNS.globalIgnore
|
|
1084
|
-
},
|
|
1085
|
-
assets: {
|
|
1086
|
-
absolute: true,
|
|
1087
|
-
onlyFiles: true,
|
|
1088
|
-
ignore: SCAN_PATTERNS.globalIgnore
|
|
1089
|
-
}
|
|
1090
|
-
};
|
|
1091
|
-
}
|
|
1092
|
-
});
|
|
1093
|
-
|
|
1094
945
|
// node_modules/.bun/fast-glob@3.3.3/node_modules/fast-glob/out/utils/array.js
|
|
1095
946
|
var require_array = __commonJS({
|
|
1096
947
|
"node_modules/.bun/fast-glob@3.3.3/node_modules/fast-glob/out/utils/array.js"(exports) {
|
|
@@ -6675,69 +6526,218 @@ var require_out4 = __commonJS({
|
|
|
6675
6526
|
}
|
|
6676
6527
|
});
|
|
6677
6528
|
|
|
6678
|
-
// packages/core/config/
|
|
6679
|
-
|
|
6680
|
-
|
|
6681
|
-
|
|
6682
|
-
|
|
6683
|
-
|
|
6684
|
-
|
|
6685
|
-
|
|
6686
|
-
|
|
6687
|
-
|
|
6688
|
-
}
|
|
6689
|
-
|
|
6690
|
-
|
|
6691
|
-
function safeExecuteAsync(fn, message) {
|
|
6692
|
-
return fn().catch((error2) => {
|
|
6693
|
-
throw new Error(
|
|
6694
|
-
`${message}: ${error2 instanceof Error ? error2.message : String(error2)}`
|
|
6695
|
-
);
|
|
6696
|
-
});
|
|
6529
|
+
// packages/core/config/constants.js
|
|
6530
|
+
function getPatternsFor(type, repoRoot = null) {
|
|
6531
|
+
const patterns = SCAN_PATTERNS[type];
|
|
6532
|
+
if (!patterns) {
|
|
6533
|
+
throw new Error(`Unknown pattern type: ${type}`);
|
|
6534
|
+
}
|
|
6535
|
+
if (repoRoot && patterns.framework) {
|
|
6536
|
+
return {
|
|
6537
|
+
...patterns,
|
|
6538
|
+
framework: patterns.framework.map((pattern) => `${repoRoot}/${pattern}`)
|
|
6539
|
+
};
|
|
6540
|
+
}
|
|
6541
|
+
return patterns;
|
|
6697
6542
|
}
|
|
6698
|
-
|
|
6699
|
-
|
|
6700
|
-
|
|
6543
|
+
function getGlobOptionsFor(type) {
|
|
6544
|
+
return GLOB_OPTIONS[type] || GLOB_OPTIONS.base;
|
|
6545
|
+
}
|
|
6546
|
+
var I18N_PATHS, SCAN_PATTERNS, GLOB_OPTIONS;
|
|
6547
|
+
var init_constants = __esm({
|
|
6548
|
+
"packages/core/config/constants.js"() {
|
|
6701
6549
|
"use strict";
|
|
6702
6550
|
init_utils();
|
|
6703
|
-
|
|
6704
|
-
|
|
6705
|
-
|
|
6706
|
-
|
|
6707
|
-
|
|
6708
|
-
|
|
6709
|
-
|
|
6551
|
+
I18N_PATHS = {
|
|
6552
|
+
// Monorepo source structure (locales at root, not in src/)
|
|
6553
|
+
SOURCE_ROOT: "packages/core/i18n",
|
|
6554
|
+
SOURCE_LOCALES: "packages/core/i18n/locales",
|
|
6555
|
+
SOURCE_EAGER: "packages/core/i18n/locales/eager",
|
|
6556
|
+
SOURCE_LAZY: "packages/core/i18n/locales/lazy",
|
|
6557
|
+
// Published structure (same as source - no flattening needed)
|
|
6558
|
+
PUBLISHED_ROOT: "i18n",
|
|
6559
|
+
PUBLISHED_LOCALES: "i18n/locales",
|
|
6560
|
+
PUBLISHED_EAGER: "i18n/locales/eager",
|
|
6561
|
+
PUBLISHED_LAZY: "i18n/locales/lazy"
|
|
6710
6562
|
};
|
|
6711
|
-
|
|
6712
|
-
|
|
6563
|
+
SCAN_PATTERNS = {
|
|
6564
|
+
routes: {
|
|
6565
|
+
consumer: ["src/**/*Page.tsx", "src/pages/**/*Page.tsx"],
|
|
6566
|
+
exclude: [
|
|
6567
|
+
"**/node_modules/**",
|
|
6568
|
+
"**/dist/**",
|
|
6569
|
+
"**/build/**",
|
|
6570
|
+
"**/*.test.tsx",
|
|
6571
|
+
"**/*.stories.tsx"
|
|
6572
|
+
],
|
|
6573
|
+
extensions: [".tsx"]
|
|
6713
6574
|
},
|
|
6714
|
-
|
|
6575
|
+
css: {
|
|
6576
|
+
consumer: ["src/**/*.css"],
|
|
6577
|
+
themes: ["src/**/*.css"],
|
|
6578
|
+
extensions: [".css", ".scss", ".sass"],
|
|
6579
|
+
framework: [
|
|
6580
|
+
"packages/ui/src/**/*.css",
|
|
6581
|
+
"packages/core/components/src/**/*.css",
|
|
6582
|
+
"packages/core/templates/src/**/*.css"
|
|
6583
|
+
]
|
|
6715
6584
|
},
|
|
6716
|
-
|
|
6717
|
-
|
|
6718
|
-
|
|
6719
|
-
|
|
6720
|
-
|
|
6721
|
-
|
|
6722
|
-
|
|
6723
|
-
|
|
6724
|
-
|
|
6725
|
-
|
|
6726
|
-
|
|
6727
|
-
|
|
6728
|
-
|
|
6729
|
-
|
|
6730
|
-
|
|
6731
|
-
|
|
6732
|
-
|
|
6733
|
-
|
|
6734
|
-
|
|
6735
|
-
|
|
6736
|
-
|
|
6737
|
-
|
|
6738
|
-
|
|
6739
|
-
|
|
6740
|
-
|
|
6585
|
+
i18n: {
|
|
6586
|
+
eager: ["src/locales/*_*.json"],
|
|
6587
|
+
lazy: ["src/**/locales/*_*.json", "!src/locales/*_*.json"],
|
|
6588
|
+
framework: {
|
|
6589
|
+
eager: [`${I18N_PATHS.SOURCE_EAGER}/*_*.json`],
|
|
6590
|
+
lazy: [`${I18N_PATHS.SOURCE_LAZY}/*_*.json`]
|
|
6591
|
+
},
|
|
6592
|
+
extensions: [".json"]
|
|
6593
|
+
},
|
|
6594
|
+
assets: {
|
|
6595
|
+
consumer: ["public/**/*"],
|
|
6596
|
+
fallback: ["manifest.json"],
|
|
6597
|
+
modern: [
|
|
6598
|
+
"logo.svg",
|
|
6599
|
+
"favicon.svg",
|
|
6600
|
+
"apple-touch-icon.png",
|
|
6601
|
+
"android-chrome-192x192.png",
|
|
6602
|
+
"android-chrome-512x512.png"
|
|
6603
|
+
],
|
|
6604
|
+
patterns: [
|
|
6605
|
+
"favicon.svg",
|
|
6606
|
+
"favicon.ico",
|
|
6607
|
+
"favicon-*.png",
|
|
6608
|
+
"logo.svg",
|
|
6609
|
+
"logo.png",
|
|
6610
|
+
"logo.webp",
|
|
6611
|
+
"logo.avif",
|
|
6612
|
+
"apple-touch-icon*.png",
|
|
6613
|
+
"android-chrome-*.png",
|
|
6614
|
+
"manifest.json"
|
|
6615
|
+
],
|
|
6616
|
+
fonts: ["fonts/**/*.woff2", "fonts/**/*.woff", "fonts/**/*.ttf"],
|
|
6617
|
+
framework: ["packages/ui/assets/**/*"]
|
|
6618
|
+
},
|
|
6619
|
+
pwa: {
|
|
6620
|
+
consumer: [
|
|
6621
|
+
"public/manifest.json",
|
|
6622
|
+
"public/service-worker.js",
|
|
6623
|
+
"public/sw.js",
|
|
6624
|
+
"public/icon-192x192.png",
|
|
6625
|
+
"public/icon-512x512.png",
|
|
6626
|
+
"public/favicon.ico",
|
|
6627
|
+
"public/favicon.svg",
|
|
6628
|
+
"public/apple-touch-icon.png",
|
|
6629
|
+
"public/logo.svg"
|
|
6630
|
+
],
|
|
6631
|
+
exclude: ["**/node_modules/**", "**/dist/**", "**/build/**"],
|
|
6632
|
+
extensions: [".json", ".js", ".png", ".svg", ".ico"],
|
|
6633
|
+
framework: ["packages/ui/assets/**/*"]
|
|
6634
|
+
},
|
|
6635
|
+
globalIgnore: [
|
|
6636
|
+
"**/node_modules/**",
|
|
6637
|
+
"**/dist/**",
|
|
6638
|
+
"**/build/**",
|
|
6639
|
+
"**/.git/**",
|
|
6640
|
+
"**/coverage/**",
|
|
6641
|
+
"**/test/**"
|
|
6642
|
+
]
|
|
6643
|
+
};
|
|
6644
|
+
GLOB_OPTIONS = {
|
|
6645
|
+
base: {
|
|
6646
|
+
absolute: true,
|
|
6647
|
+
onlyFiles: true,
|
|
6648
|
+
ignore: SCAN_PATTERNS.globalIgnore
|
|
6649
|
+
},
|
|
6650
|
+
css: {
|
|
6651
|
+
absolute: true,
|
|
6652
|
+
onlyFiles: true,
|
|
6653
|
+
ignore: [...SCAN_PATTERNS.globalIgnore, "**/*.test.css"]
|
|
6654
|
+
},
|
|
6655
|
+
routes: {
|
|
6656
|
+
absolute: true,
|
|
6657
|
+
onlyFiles: true,
|
|
6658
|
+
ignore: [
|
|
6659
|
+
...SCAN_PATTERNS.globalIgnore,
|
|
6660
|
+
"**/*.test.tsx",
|
|
6661
|
+
"**/*.stories.tsx"
|
|
6662
|
+
]
|
|
6663
|
+
},
|
|
6664
|
+
i18n: {
|
|
6665
|
+
absolute: true,
|
|
6666
|
+
onlyFiles: true,
|
|
6667
|
+
ignore: SCAN_PATTERNS.globalIgnore
|
|
6668
|
+
},
|
|
6669
|
+
assets: {
|
|
6670
|
+
absolute: true,
|
|
6671
|
+
onlyFiles: true,
|
|
6672
|
+
ignore: SCAN_PATTERNS.globalIgnore
|
|
6673
|
+
}
|
|
6674
|
+
};
|
|
6675
|
+
}
|
|
6676
|
+
});
|
|
6677
|
+
|
|
6678
|
+
// packages/core/config/utils/PathResolver.ts
|
|
6679
|
+
import * as fs from "node:fs";
|
|
6680
|
+
import { createRequire } from "node:module";
|
|
6681
|
+
import {
|
|
6682
|
+
resolve,
|
|
6683
|
+
join,
|
|
6684
|
+
dirname,
|
|
6685
|
+
relative,
|
|
6686
|
+
normalize,
|
|
6687
|
+
sep,
|
|
6688
|
+
extname
|
|
6689
|
+
} from "node:path";
|
|
6690
|
+
import { fileURLToPath } from "node:url";
|
|
6691
|
+
function safeExecuteAsync(fn, message) {
|
|
6692
|
+
return fn().catch((error2) => {
|
|
6693
|
+
throw new Error(
|
|
6694
|
+
`${message}: ${error2 instanceof Error ? error2.message : String(error2)}`
|
|
6695
|
+
);
|
|
6696
|
+
});
|
|
6697
|
+
}
|
|
6698
|
+
var import_fast_glob, constants, log2, PACKAGE_PATHS, PathResolver;
|
|
6699
|
+
var init_PathResolver = __esm({
|
|
6700
|
+
"packages/core/config/utils/PathResolver.ts"() {
|
|
6701
|
+
"use strict";
|
|
6702
|
+
init_utils();
|
|
6703
|
+
import_fast_glob = __toESM(require_out4(), 1);
|
|
6704
|
+
init_constants();
|
|
6705
|
+
constants = {
|
|
6706
|
+
getGlobOptionsFor: getGlobOptionsFor || void 0,
|
|
6707
|
+
SCAN_PATTERNS: SCAN_PATTERNS || void 0,
|
|
6708
|
+
getPatternsFor: getPatternsFor || void 0,
|
|
6709
|
+
I18N_PATHS: I18N_PATHS || void 0
|
|
6710
|
+
};
|
|
6711
|
+
log2 = {
|
|
6712
|
+
error: (message, error2) => {
|
|
6713
|
+
},
|
|
6714
|
+
warn: (message, error2) => {
|
|
6715
|
+
},
|
|
6716
|
+
info: (message) => {
|
|
6717
|
+
}
|
|
6718
|
+
};
|
|
6719
|
+
PACKAGE_PATHS = {
|
|
6720
|
+
CLI: "packages/cli",
|
|
6721
|
+
COMPONENTS: "packages/core/components",
|
|
6722
|
+
CONFIG: "packages/core/config",
|
|
6723
|
+
// I18n paths - single source of truth (use I18N_PATHS from constants.js)
|
|
6724
|
+
CORE: "packages/core",
|
|
6725
|
+
CRUD: "packages/core/crud",
|
|
6726
|
+
FEATURES: "packages/features",
|
|
6727
|
+
HOOKS: "packages/core/hooks",
|
|
6728
|
+
I18N: "packages/core/i18n",
|
|
6729
|
+
SCHEMAS: "packages/core/schemas",
|
|
6730
|
+
STORES: "packages/core/stores",
|
|
6731
|
+
TEMPLATES: "packages/templates",
|
|
6732
|
+
TOOLING: "packages/tooling",
|
|
6733
|
+
TYPES: "packages/core/types",
|
|
6734
|
+
UI: "packages/ui",
|
|
6735
|
+
UTILS: "packages/core/utils",
|
|
6736
|
+
AUTH: "packages/features/auth",
|
|
6737
|
+
BILLING: "packages/features/billing",
|
|
6738
|
+
OAUTH: "packages/features/oauth",
|
|
6739
|
+
FIREBASE: "packages/providers/firebase",
|
|
6740
|
+
FUNCTIONS: "packages/functions"
|
|
6741
6741
|
};
|
|
6742
6742
|
PathResolver = class _PathResolver {
|
|
6743
6743
|
static _instance = null;
|
|
@@ -7825,11 +7825,11 @@ var init_pathResolver = __esm({
|
|
|
7825
7825
|
});
|
|
7826
7826
|
|
|
7827
7827
|
// packages/tooling/src/bundler/utils.ts
|
|
7828
|
+
import { Buffer as Buffer2 } from "node:buffer";
|
|
7828
7829
|
import { createRequire as createRequire2 } from "node:module";
|
|
7829
|
-
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
7830
7830
|
import { dirname as dirname3, resolve as resolve3 } from "node:path";
|
|
7831
|
-
import { Buffer as Buffer2 } from "node:buffer";
|
|
7832
7831
|
import process from "node:process";
|
|
7832
|
+
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
7833
7833
|
var require2, __filename, __dirname;
|
|
7834
7834
|
var init_utils = __esm({
|
|
7835
7835
|
"packages/tooling/src/bundler/utils.ts"() {
|
|
@@ -8022,10 +8022,11 @@ function safeRemove(path, options = {}) {
|
|
|
8022
8022
|
|
|
8023
8023
|
// packages/tooling/src/apps/deploy.ts
|
|
8024
8024
|
init_utils();
|
|
8025
|
-
init_cli_output();
|
|
8026
|
-
init_cli_output();
|
|
8027
8025
|
import { execSync as execSync3 } from "node:child_process";
|
|
8028
8026
|
|
|
8027
|
+
// packages/tooling/src/apps/deploy-frontend.ts
|
|
8028
|
+
init_utils();
|
|
8029
|
+
|
|
8029
8030
|
// packages/tooling/src/utils/cli-tools.ts
|
|
8030
8031
|
init_utils();
|
|
8031
8032
|
init_dist2();
|
|
@@ -8275,40 +8276,269 @@ function requireCLI(tool, additionalContext) {
|
|
|
8275
8276
|
return true;
|
|
8276
8277
|
}
|
|
8277
8278
|
|
|
8278
|
-
// packages/tooling/src/apps/deploy.ts
|
|
8279
|
-
|
|
8280
|
-
|
|
8279
|
+
// packages/tooling/src/apps/deploy-frontend.ts
|
|
8280
|
+
async function deployFrontend(appDir, serviceAccountPath, projectId, config) {
|
|
8281
|
+
const s = Y2();
|
|
8282
|
+
s.start("Deploying frontend to Firebase Hosting...");
|
|
8283
|
+
const args = buildFirebaseDeployArgs("hosting", projectId, config.debug);
|
|
8284
|
+
const result = executeFirebaseCommand(args, {
|
|
8285
|
+
cwd: appDir,
|
|
8286
|
+
serviceAccountPath,
|
|
8287
|
+
projectId,
|
|
8288
|
+
debug: config.debug
|
|
8289
|
+
});
|
|
8290
|
+
if (result.error) {
|
|
8291
|
+
s.stop("Deployment failed");
|
|
8292
|
+
throw result.error;
|
|
8293
|
+
}
|
|
8294
|
+
if (!result.success) {
|
|
8295
|
+
s.stop("Deployment failed");
|
|
8296
|
+
handleDeploymentFailure(
|
|
8297
|
+
result,
|
|
8298
|
+
`firebase ${args.join(" ")}`,
|
|
8299
|
+
serviceAccountPath
|
|
8300
|
+
);
|
|
8301
|
+
}
|
|
8302
|
+
s.stop("Frontend deployed successfully");
|
|
8303
|
+
}
|
|
8281
8304
|
|
|
8282
|
-
// packages/tooling/src/apps/deploy-
|
|
8305
|
+
// packages/tooling/src/apps/deploy-functions.ts
|
|
8283
8306
|
init_utils();
|
|
8284
|
-
import {
|
|
8307
|
+
import { execSync as execSync2 } from "node:child_process";
|
|
8285
8308
|
init_pathResolver();
|
|
8286
|
-
function
|
|
8287
|
-
const
|
|
8288
|
-
const
|
|
8289
|
-
|
|
8290
|
-
|
|
8309
|
+
function backupFiles(functionsDir) {
|
|
8310
|
+
const backupDir = joinPath(functionsDir, ".deploy-backup");
|
|
8311
|
+
const packageJsonPath = joinPath(functionsDir, "package.json");
|
|
8312
|
+
const packageLockJsonPath = joinPath(functionsDir, "package-lock.json");
|
|
8313
|
+
try {
|
|
8314
|
+
ensureDirSync(backupDir);
|
|
8315
|
+
const backupPackageJson = joinPath(backupDir, "package.json");
|
|
8316
|
+
const backupPackageLockJson = joinPath(backupDir, "package-lock.json");
|
|
8317
|
+
if (pathExists(packageJsonPath)) {
|
|
8318
|
+
const content = readSync(packageJsonPath, { format: "text" });
|
|
8319
|
+
if (!content) {
|
|
8320
|
+
throw new Error(`Failed to read package.json: ${packageJsonPath}`);
|
|
8321
|
+
}
|
|
8322
|
+
writeSync(backupPackageJson, content, { overwrite: true });
|
|
8323
|
+
}
|
|
8324
|
+
if (pathExists(packageLockJsonPath)) {
|
|
8325
|
+
const content = readSync(packageLockJsonPath, { format: "text" });
|
|
8326
|
+
if (!content) {
|
|
8327
|
+
throw new Error(
|
|
8328
|
+
`Failed to read package-lock.json: ${packageLockJsonPath}`
|
|
8329
|
+
);
|
|
8330
|
+
}
|
|
8331
|
+
writeSync(backupPackageLockJson, content, { overwrite: true });
|
|
8332
|
+
}
|
|
8333
|
+
return {
|
|
8334
|
+
packageJson: backupPackageJson,
|
|
8335
|
+
packageLockJson: backupPackageLockJson
|
|
8336
|
+
};
|
|
8337
|
+
} catch (error2) {
|
|
8338
|
+
log.warn(
|
|
8339
|
+
`Failed to backup files: ${error2 instanceof Error ? error2.message : String(error2)}`
|
|
8340
|
+
);
|
|
8341
|
+
return null;
|
|
8291
8342
|
}
|
|
8292
|
-
return readdirSync2(appsDir).filter((item) => {
|
|
8293
|
-
const itemPath = joinPath(appsDir, item);
|
|
8294
|
-
const stat = statSync2(itemPath);
|
|
8295
|
-
return stat?.isDirectory() === true;
|
|
8296
|
-
}).filter((app) => {
|
|
8297
|
-
const firebaseJsonPath = joinPath(appsDir, app, "firebase.json");
|
|
8298
|
-
return pathExists(firebaseJsonPath);
|
|
8299
|
-
}).sort();
|
|
8300
8343
|
}
|
|
8301
|
-
function
|
|
8302
|
-
const
|
|
8303
|
-
|
|
8304
|
-
if (!pathExists(appDir)) {
|
|
8344
|
+
function generateCleanPackageJson(functionsDir) {
|
|
8345
|
+
const packageJsonPath = joinPath(functionsDir, "package.json");
|
|
8346
|
+
if (!pathExists(packageJsonPath)) {
|
|
8305
8347
|
throw new DoNotDevError(
|
|
8306
|
-
`
|
|
8307
|
-
"file-not-found"
|
|
8308
|
-
{ context: { appName, expectedPath: appDir } }
|
|
8348
|
+
`package.json not found: ${packageJsonPath}`,
|
|
8349
|
+
"file-not-found"
|
|
8309
8350
|
);
|
|
8310
8351
|
}
|
|
8311
|
-
|
|
8352
|
+
const packageJson = readSync(packageJsonPath, { format: "json" });
|
|
8353
|
+
if (!packageJson) {
|
|
8354
|
+
throw new Error(
|
|
8355
|
+
`package.json is empty or invalid JSON at ${packageJsonPath}`
|
|
8356
|
+
);
|
|
8357
|
+
}
|
|
8358
|
+
const cleanPackageJson = { ...packageJson };
|
|
8359
|
+
if (cleanPackageJson.dependencies) {
|
|
8360
|
+
cleanPackageJson.dependencies = Object.fromEntries(
|
|
8361
|
+
Object.entries(cleanPackageJson.dependencies).filter(
|
|
8362
|
+
([, version]) => !String(version).startsWith("file:") && !String(version).startsWith("workspace:")
|
|
8363
|
+
)
|
|
8364
|
+
);
|
|
8365
|
+
}
|
|
8366
|
+
if (cleanPackageJson.devDependencies) {
|
|
8367
|
+
cleanPackageJson.devDependencies = Object.fromEntries(
|
|
8368
|
+
Object.entries(cleanPackageJson.devDependencies).filter(
|
|
8369
|
+
([, version]) => !String(version).startsWith("file:") && !String(version).startsWith("workspace:")
|
|
8370
|
+
)
|
|
8371
|
+
);
|
|
8372
|
+
}
|
|
8373
|
+
if (cleanPackageJson.scripts?.preinstall) {
|
|
8374
|
+
delete cleanPackageJson.scripts.preinstall;
|
|
8375
|
+
}
|
|
8376
|
+
const content = JSON.stringify(cleanPackageJson, null, 2) + "\n";
|
|
8377
|
+
writeSync(packageJsonPath, content, { overwrite: true });
|
|
8378
|
+
}
|
|
8379
|
+
function prepareFunctionsForDeployment(functionsDir, verbose = false) {
|
|
8380
|
+
const s = Y2();
|
|
8381
|
+
s.start("Preparing functions for deployment...");
|
|
8382
|
+
try {
|
|
8383
|
+
backupFiles(functionsDir);
|
|
8384
|
+
generateCleanPackageJson(functionsDir);
|
|
8385
|
+
safeRemove(joinPath(functionsDir, "package-lock.json"), {
|
|
8386
|
+
logSuccess: true,
|
|
8387
|
+
successMessage: "Removed package-lock.json - Firebase Cloud Build will generate its own"
|
|
8388
|
+
});
|
|
8389
|
+
s.stop("Functions prepared for deployment");
|
|
8390
|
+
} catch (error2) {
|
|
8391
|
+
s.stop("Preparation failed");
|
|
8392
|
+
throw error2;
|
|
8393
|
+
}
|
|
8394
|
+
}
|
|
8395
|
+
function restoreFunctionsAfterDeployment(functionsDir) {
|
|
8396
|
+
const backupDir = joinPath(functionsDir, ".deploy-backup");
|
|
8397
|
+
const backupPackageJson = joinPath(backupDir, "package.json");
|
|
8398
|
+
const backupPackageLockJson = joinPath(backupDir, "package-lock.json");
|
|
8399
|
+
const packageJsonPath = joinPath(functionsDir, "package.json");
|
|
8400
|
+
const packageLockJsonPath = joinPath(functionsDir, "package-lock.json");
|
|
8401
|
+
try {
|
|
8402
|
+
if (pathExists(backupPackageJson)) {
|
|
8403
|
+
const content = readSync(backupPackageJson, { format: "text" });
|
|
8404
|
+
if (!content) {
|
|
8405
|
+
throw new Error(
|
|
8406
|
+
`Failed to read backup package.json: ${backupPackageJson}`
|
|
8407
|
+
);
|
|
8408
|
+
}
|
|
8409
|
+
writeSync(packageJsonPath, content, { overwrite: true });
|
|
8410
|
+
}
|
|
8411
|
+
if (pathExists(backupPackageLockJson)) {
|
|
8412
|
+
const content = readSync(backupPackageLockJson, { format: "text" });
|
|
8413
|
+
if (!content) {
|
|
8414
|
+
throw new Error(
|
|
8415
|
+
`Failed to read backup package-lock.json: ${backupPackageLockJson}`
|
|
8416
|
+
);
|
|
8417
|
+
}
|
|
8418
|
+
writeSync(packageLockJsonPath, content, { overwrite: true });
|
|
8419
|
+
}
|
|
8420
|
+
safeRemove(backupDir, { silent: true });
|
|
8421
|
+
} catch (error2) {
|
|
8422
|
+
log.warn(
|
|
8423
|
+
`Failed to restore files: ${error2 instanceof Error ? error2.message : String(error2)}`
|
|
8424
|
+
);
|
|
8425
|
+
log.warn(` Backup directory: ${backupDir}`);
|
|
8426
|
+
}
|
|
8427
|
+
}
|
|
8428
|
+
async function deployFunctions(appDir, serviceAccountPath, projectId, config) {
|
|
8429
|
+
const functionsDir = joinPath(appDir, "functions");
|
|
8430
|
+
if (!pathExists(functionsDir)) {
|
|
8431
|
+
throw new DoNotDevError(
|
|
8432
|
+
`Functions directory not found: ${functionsDir}`,
|
|
8433
|
+
"file-not-found"
|
|
8434
|
+
);
|
|
8435
|
+
}
|
|
8436
|
+
const s = Y2();
|
|
8437
|
+
s.start("Validating function dependencies...");
|
|
8438
|
+
const requiredPackages = ["firebase-functions", "firebase-admin"];
|
|
8439
|
+
const missingPackages = requiredPackages.filter((pkg) => {
|
|
8440
|
+
try {
|
|
8441
|
+
resolvePackage(pkg, functionsDir);
|
|
8442
|
+
return false;
|
|
8443
|
+
} catch {
|
|
8444
|
+
return true;
|
|
8445
|
+
}
|
|
8446
|
+
});
|
|
8447
|
+
if (missingPackages.length > 0) {
|
|
8448
|
+
s.stop("Missing dependencies");
|
|
8449
|
+
throw new DoNotDevError(
|
|
8450
|
+
`Missing required dependencies: ${missingPackages.join(", ")}
|
|
8451
|
+
|
|
8452
|
+
To fix this, run:
|
|
8453
|
+
cd ${functionsDir}
|
|
8454
|
+
npm install --production`,
|
|
8455
|
+
"file-not-found",
|
|
8456
|
+
{ context: { missingPackages, functionsDir } }
|
|
8457
|
+
);
|
|
8458
|
+
}
|
|
8459
|
+
s.stop("Dependencies validated");
|
|
8460
|
+
prepareFunctionsForDeployment(functionsDir, config.verbose);
|
|
8461
|
+
log.debug("Waiting for file system sync...");
|
|
8462
|
+
await new Promise((resolve4) => setTimeout(resolve4, 1e3));
|
|
8463
|
+
try {
|
|
8464
|
+
if (!config.skipBuild) {
|
|
8465
|
+
const s2 = Y2();
|
|
8466
|
+
s2.start("Building functions...");
|
|
8467
|
+
try {
|
|
8468
|
+
execSync2("bun run build", {
|
|
8469
|
+
cwd: functionsDir,
|
|
8470
|
+
stdio: config.verbose ? "inherit" : "pipe"
|
|
8471
|
+
});
|
|
8472
|
+
s2.stop("Functions built");
|
|
8473
|
+
} catch (error2) {
|
|
8474
|
+
s2.stop("Build failed");
|
|
8475
|
+
throw error2;
|
|
8476
|
+
}
|
|
8477
|
+
}
|
|
8478
|
+
s.start("Deploying functions to Firebase...");
|
|
8479
|
+
const firebaseProjectDir = pathExists(joinPath(appDir, "firebase.json")) ? appDir : functionsDir;
|
|
8480
|
+
log.debug(`Using service account: ${serviceAccountPath}`);
|
|
8481
|
+
log.debug(`Firebase project directory: ${firebaseProjectDir}`);
|
|
8482
|
+
const args = buildFirebaseDeployArgs(
|
|
8483
|
+
"functions",
|
|
8484
|
+
projectId,
|
|
8485
|
+
config.debug,
|
|
8486
|
+
config.force
|
|
8487
|
+
);
|
|
8488
|
+
const result = executeFirebaseCommand(args, {
|
|
8489
|
+
cwd: firebaseProjectDir,
|
|
8490
|
+
serviceAccountPath,
|
|
8491
|
+
projectId,
|
|
8492
|
+
debug: config.debug
|
|
8493
|
+
});
|
|
8494
|
+
if (result.error) {
|
|
8495
|
+
s.stop("Deployment failed");
|
|
8496
|
+
throw result.error;
|
|
8497
|
+
}
|
|
8498
|
+
if (!result.success) {
|
|
8499
|
+
s.stop("Deployment failed");
|
|
8500
|
+
handleDeploymentFailure(
|
|
8501
|
+
result,
|
|
8502
|
+
`firebase ${args.join(" ")}`,
|
|
8503
|
+
serviceAccountPath
|
|
8504
|
+
);
|
|
8505
|
+
}
|
|
8506
|
+
s.stop("Functions deployed successfully");
|
|
8507
|
+
} finally {
|
|
8508
|
+
restoreFunctionsAfterDeployment(functionsDir);
|
|
8509
|
+
}
|
|
8510
|
+
}
|
|
8511
|
+
|
|
8512
|
+
// packages/tooling/src/apps/deploy-utils.ts
|
|
8513
|
+
init_utils();
|
|
8514
|
+
import { spawnSync as spawnSync3 } from "node:child_process";
|
|
8515
|
+
init_pathResolver();
|
|
8516
|
+
function detectAvailableApps() {
|
|
8517
|
+
const currentDir = process.cwd();
|
|
8518
|
+
const appsDir = joinPath(currentDir, "apps");
|
|
8519
|
+
if (!pathExists(appsDir)) {
|
|
8520
|
+
return [];
|
|
8521
|
+
}
|
|
8522
|
+
return readdirSync2(appsDir).filter((item) => {
|
|
8523
|
+
const itemPath = joinPath(appsDir, item);
|
|
8524
|
+
const stat = statSync2(itemPath);
|
|
8525
|
+
return stat?.isDirectory() === true;
|
|
8526
|
+
}).filter((app) => {
|
|
8527
|
+
const firebaseJsonPath = joinPath(appsDir, app, "firebase.json");
|
|
8528
|
+
return pathExists(firebaseJsonPath);
|
|
8529
|
+
}).sort();
|
|
8530
|
+
}
|
|
8531
|
+
function detectAppDir(appName) {
|
|
8532
|
+
const currentDir = process.cwd();
|
|
8533
|
+
const appDir = joinPath(currentDir, "apps", appName);
|
|
8534
|
+
if (!pathExists(appDir)) {
|
|
8535
|
+
throw new DoNotDevError(
|
|
8536
|
+
`App directory not found: ${appDir}`,
|
|
8537
|
+
"file-not-found",
|
|
8538
|
+
{ context: { appName, expectedPath: appDir } }
|
|
8539
|
+
);
|
|
8540
|
+
}
|
|
8541
|
+
return appDir;
|
|
8312
8542
|
}
|
|
8313
8543
|
function validateServiceAccount(appDir) {
|
|
8314
8544
|
const rootKeyPath = joinPath(appDir, "service-account-key.json");
|
|
@@ -8522,241 +8752,11 @@ function clearFirebaseCache(appDir) {
|
|
|
8522
8752
|
}
|
|
8523
8753
|
}
|
|
8524
8754
|
|
|
8525
|
-
// packages/tooling/src/apps/deploy-frontend.ts
|
|
8526
|
-
init_utils();
|
|
8527
|
-
async function deployFrontend(appDir, serviceAccountPath, projectId, config) {
|
|
8528
|
-
const s = Y2();
|
|
8529
|
-
s.start("Deploying frontend to Firebase Hosting...");
|
|
8530
|
-
const args = buildFirebaseDeployArgs("hosting", projectId, config.debug);
|
|
8531
|
-
const result = executeFirebaseCommand(args, {
|
|
8532
|
-
cwd: appDir,
|
|
8533
|
-
serviceAccountPath,
|
|
8534
|
-
projectId,
|
|
8535
|
-
debug: config.debug
|
|
8536
|
-
});
|
|
8537
|
-
if (result.error) {
|
|
8538
|
-
s.stop("Deployment failed");
|
|
8539
|
-
throw result.error;
|
|
8540
|
-
}
|
|
8541
|
-
if (!result.success) {
|
|
8542
|
-
s.stop("Deployment failed");
|
|
8543
|
-
handleDeploymentFailure(
|
|
8544
|
-
result,
|
|
8545
|
-
`firebase ${args.join(" ")}`,
|
|
8546
|
-
serviceAccountPath
|
|
8547
|
-
);
|
|
8548
|
-
}
|
|
8549
|
-
s.stop("Frontend deployed successfully");
|
|
8550
|
-
}
|
|
8551
|
-
|
|
8552
|
-
// packages/tooling/src/apps/deploy-functions.ts
|
|
8553
|
-
init_utils();
|
|
8554
|
-
import { execSync as execSync2 } from "node:child_process";
|
|
8555
|
-
init_pathResolver();
|
|
8556
|
-
function backupFiles(functionsDir) {
|
|
8557
|
-
const backupDir = joinPath(functionsDir, ".deploy-backup");
|
|
8558
|
-
const packageJsonPath = joinPath(functionsDir, "package.json");
|
|
8559
|
-
const packageLockJsonPath = joinPath(functionsDir, "package-lock.json");
|
|
8560
|
-
try {
|
|
8561
|
-
ensureDirSync(backupDir);
|
|
8562
|
-
const backupPackageJson = joinPath(backupDir, "package.json");
|
|
8563
|
-
const backupPackageLockJson = joinPath(backupDir, "package-lock.json");
|
|
8564
|
-
if (pathExists(packageJsonPath)) {
|
|
8565
|
-
const content = readSync(packageJsonPath, { format: "text" });
|
|
8566
|
-
if (!content) {
|
|
8567
|
-
throw new Error(`Failed to read package.json: ${packageJsonPath}`);
|
|
8568
|
-
}
|
|
8569
|
-
writeSync(backupPackageJson, content, { overwrite: true });
|
|
8570
|
-
}
|
|
8571
|
-
if (pathExists(packageLockJsonPath)) {
|
|
8572
|
-
const content = readSync(packageLockJsonPath, { format: "text" });
|
|
8573
|
-
if (!content) {
|
|
8574
|
-
throw new Error(
|
|
8575
|
-
`Failed to read package-lock.json: ${packageLockJsonPath}`
|
|
8576
|
-
);
|
|
8577
|
-
}
|
|
8578
|
-
writeSync(backupPackageLockJson, content, { overwrite: true });
|
|
8579
|
-
}
|
|
8580
|
-
return {
|
|
8581
|
-
packageJson: backupPackageJson,
|
|
8582
|
-
packageLockJson: backupPackageLockJson
|
|
8583
|
-
};
|
|
8584
|
-
} catch (error2) {
|
|
8585
|
-
log.warn(
|
|
8586
|
-
`Failed to backup files: ${error2 instanceof Error ? error2.message : String(error2)}`
|
|
8587
|
-
);
|
|
8588
|
-
return null;
|
|
8589
|
-
}
|
|
8590
|
-
}
|
|
8591
|
-
function generateCleanPackageJson(functionsDir) {
|
|
8592
|
-
const packageJsonPath = joinPath(functionsDir, "package.json");
|
|
8593
|
-
if (!pathExists(packageJsonPath)) {
|
|
8594
|
-
throw new DoNotDevError(
|
|
8595
|
-
`package.json not found: ${packageJsonPath}`,
|
|
8596
|
-
"file-not-found"
|
|
8597
|
-
);
|
|
8598
|
-
}
|
|
8599
|
-
const packageJson = readSync(packageJsonPath, { format: "json" });
|
|
8600
|
-
if (!packageJson) {
|
|
8601
|
-
throw new Error(
|
|
8602
|
-
`package.json is empty or invalid JSON at ${packageJsonPath}`
|
|
8603
|
-
);
|
|
8604
|
-
}
|
|
8605
|
-
const cleanPackageJson = { ...packageJson };
|
|
8606
|
-
if (cleanPackageJson.dependencies) {
|
|
8607
|
-
cleanPackageJson.dependencies = Object.fromEntries(
|
|
8608
|
-
Object.entries(cleanPackageJson.dependencies).filter(
|
|
8609
|
-
([, version]) => !String(version).startsWith("file:") && !String(version).startsWith("workspace:")
|
|
8610
|
-
)
|
|
8611
|
-
);
|
|
8612
|
-
}
|
|
8613
|
-
if (cleanPackageJson.devDependencies) {
|
|
8614
|
-
cleanPackageJson.devDependencies = Object.fromEntries(
|
|
8615
|
-
Object.entries(cleanPackageJson.devDependencies).filter(
|
|
8616
|
-
([, version]) => !String(version).startsWith("file:") && !String(version).startsWith("workspace:")
|
|
8617
|
-
)
|
|
8618
|
-
);
|
|
8619
|
-
}
|
|
8620
|
-
if (cleanPackageJson.scripts?.preinstall) {
|
|
8621
|
-
delete cleanPackageJson.scripts.preinstall;
|
|
8622
|
-
}
|
|
8623
|
-
const content = JSON.stringify(cleanPackageJson, null, 2) + "\n";
|
|
8624
|
-
writeSync(packageJsonPath, content, { overwrite: true });
|
|
8625
|
-
}
|
|
8626
|
-
function prepareFunctionsForDeployment(functionsDir, verbose = false) {
|
|
8627
|
-
const s = Y2();
|
|
8628
|
-
s.start("Preparing functions for deployment...");
|
|
8629
|
-
try {
|
|
8630
|
-
backupFiles(functionsDir);
|
|
8631
|
-
generateCleanPackageJson(functionsDir);
|
|
8632
|
-
safeRemove(joinPath(functionsDir, "package-lock.json"), {
|
|
8633
|
-
logSuccess: true,
|
|
8634
|
-
successMessage: "Removed package-lock.json - Firebase Cloud Build will generate its own"
|
|
8635
|
-
});
|
|
8636
|
-
s.stop("Functions prepared for deployment");
|
|
8637
|
-
} catch (error2) {
|
|
8638
|
-
s.stop("Preparation failed");
|
|
8639
|
-
throw error2;
|
|
8640
|
-
}
|
|
8641
|
-
}
|
|
8642
|
-
function restoreFunctionsAfterDeployment(functionsDir) {
|
|
8643
|
-
const backupDir = joinPath(functionsDir, ".deploy-backup");
|
|
8644
|
-
const backupPackageJson = joinPath(backupDir, "package.json");
|
|
8645
|
-
const backupPackageLockJson = joinPath(backupDir, "package-lock.json");
|
|
8646
|
-
const packageJsonPath = joinPath(functionsDir, "package.json");
|
|
8647
|
-
const packageLockJsonPath = joinPath(functionsDir, "package-lock.json");
|
|
8648
|
-
try {
|
|
8649
|
-
if (pathExists(backupPackageJson)) {
|
|
8650
|
-
const content = readSync(backupPackageJson, { format: "text" });
|
|
8651
|
-
if (!content) {
|
|
8652
|
-
throw new Error(
|
|
8653
|
-
`Failed to read backup package.json: ${backupPackageJson}`
|
|
8654
|
-
);
|
|
8655
|
-
}
|
|
8656
|
-
writeSync(packageJsonPath, content, { overwrite: true });
|
|
8657
|
-
}
|
|
8658
|
-
if (pathExists(backupPackageLockJson)) {
|
|
8659
|
-
const content = readSync(backupPackageLockJson, { format: "text" });
|
|
8660
|
-
if (!content) {
|
|
8661
|
-
throw new Error(
|
|
8662
|
-
`Failed to read backup package-lock.json: ${backupPackageLockJson}`
|
|
8663
|
-
);
|
|
8664
|
-
}
|
|
8665
|
-
writeSync(packageLockJsonPath, content, { overwrite: true });
|
|
8666
|
-
}
|
|
8667
|
-
safeRemove(backupDir, { silent: true });
|
|
8668
|
-
} catch (error2) {
|
|
8669
|
-
log.warn(
|
|
8670
|
-
`Failed to restore files: ${error2 instanceof Error ? error2.message : String(error2)}`
|
|
8671
|
-
);
|
|
8672
|
-
log.warn(` Backup directory: ${backupDir}`);
|
|
8673
|
-
}
|
|
8674
|
-
}
|
|
8675
|
-
async function deployFunctions(appDir, serviceAccountPath, projectId, config) {
|
|
8676
|
-
const functionsDir = joinPath(appDir, "functions");
|
|
8677
|
-
if (!pathExists(functionsDir)) {
|
|
8678
|
-
throw new DoNotDevError(
|
|
8679
|
-
`Functions directory not found: ${functionsDir}`,
|
|
8680
|
-
"file-not-found"
|
|
8681
|
-
);
|
|
8682
|
-
}
|
|
8683
|
-
const s = Y2();
|
|
8684
|
-
s.start("Validating function dependencies...");
|
|
8685
|
-
const requiredPackages = ["firebase-functions", "firebase-admin"];
|
|
8686
|
-
const missingPackages = requiredPackages.filter((pkg) => {
|
|
8687
|
-
try {
|
|
8688
|
-
resolvePackage(pkg, functionsDir);
|
|
8689
|
-
return false;
|
|
8690
|
-
} catch {
|
|
8691
|
-
return true;
|
|
8692
|
-
}
|
|
8693
|
-
});
|
|
8694
|
-
if (missingPackages.length > 0) {
|
|
8695
|
-
s.stop("Missing dependencies");
|
|
8696
|
-
throw new DoNotDevError(
|
|
8697
|
-
`Missing required dependencies: ${missingPackages.join(", ")}
|
|
8698
|
-
|
|
8699
|
-
To fix this, run:
|
|
8700
|
-
cd ${functionsDir}
|
|
8701
|
-
npm install --production`,
|
|
8702
|
-
"file-not-found",
|
|
8703
|
-
{ context: { missingPackages, functionsDir } }
|
|
8704
|
-
);
|
|
8705
|
-
}
|
|
8706
|
-
s.stop("Dependencies validated");
|
|
8707
|
-
prepareFunctionsForDeployment(functionsDir, config.verbose);
|
|
8708
|
-
log.debug("Waiting for file system sync...");
|
|
8709
|
-
await new Promise((resolve4) => setTimeout(resolve4, 1e3));
|
|
8710
|
-
try {
|
|
8711
|
-
if (!config.skipBuild) {
|
|
8712
|
-
const s2 = Y2();
|
|
8713
|
-
s2.start("Building functions...");
|
|
8714
|
-
try {
|
|
8715
|
-
execSync2("bun run build", {
|
|
8716
|
-
cwd: functionsDir,
|
|
8717
|
-
stdio: config.verbose ? "inherit" : "pipe"
|
|
8718
|
-
});
|
|
8719
|
-
s2.stop("Functions built");
|
|
8720
|
-
} catch (error2) {
|
|
8721
|
-
s2.stop("Build failed");
|
|
8722
|
-
throw error2;
|
|
8723
|
-
}
|
|
8724
|
-
}
|
|
8725
|
-
s.start("Deploying functions to Firebase...");
|
|
8726
|
-
const firebaseProjectDir = pathExists(joinPath(appDir, "firebase.json")) ? appDir : functionsDir;
|
|
8727
|
-
log.debug(`Using service account: ${serviceAccountPath}`);
|
|
8728
|
-
log.debug(`Firebase project directory: ${firebaseProjectDir}`);
|
|
8729
|
-
const args = buildFirebaseDeployArgs(
|
|
8730
|
-
"functions",
|
|
8731
|
-
projectId,
|
|
8732
|
-
config.debug,
|
|
8733
|
-
config.force
|
|
8734
|
-
);
|
|
8735
|
-
const result = executeFirebaseCommand(args, {
|
|
8736
|
-
cwd: firebaseProjectDir,
|
|
8737
|
-
serviceAccountPath,
|
|
8738
|
-
projectId,
|
|
8739
|
-
debug: config.debug
|
|
8740
|
-
});
|
|
8741
|
-
if (result.error) {
|
|
8742
|
-
s.stop("Deployment failed");
|
|
8743
|
-
throw result.error;
|
|
8744
|
-
}
|
|
8745
|
-
if (!result.success) {
|
|
8746
|
-
s.stop("Deployment failed");
|
|
8747
|
-
handleDeploymentFailure(
|
|
8748
|
-
result,
|
|
8749
|
-
`firebase ${args.join(" ")}`,
|
|
8750
|
-
serviceAccountPath
|
|
8751
|
-
);
|
|
8752
|
-
}
|
|
8753
|
-
s.stop("Functions deployed successfully");
|
|
8754
|
-
} finally {
|
|
8755
|
-
restoreFunctionsAfterDeployment(functionsDir);
|
|
8756
|
-
}
|
|
8757
|
-
}
|
|
8758
|
-
|
|
8759
8755
|
// packages/tooling/src/apps/deploy.ts
|
|
8756
|
+
init_cli_output();
|
|
8757
|
+
init_cli_output();
|
|
8758
|
+
init_errors();
|
|
8759
|
+
init_pathResolver();
|
|
8760
8760
|
async function main(options = {}) {
|
|
8761
8761
|
const config = {
|
|
8762
8762
|
app: options.app,
|