@donotdev/cli 0.0.6 → 0.0.8
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/README.md +3 -18
- package/dependencies-matrix.json +64 -121
- package/dist/bin/commands/build.js +173 -161
- package/dist/bin/commands/bump.js +181 -156
- package/dist/bin/commands/cacheout.js +188 -171
- package/dist/bin/commands/create-app.js +213 -156
- package/dist/bin/commands/create-project.js +183 -154
- package/dist/bin/commands/deploy.js +491 -477
- package/dist/bin/commands/dev.js +176 -160
- package/dist/bin/commands/emu.js +181 -165
- package/dist/bin/commands/format.js +191 -174
- package/dist/bin/commands/lint.js +191 -171
- package/dist/bin/commands/preview.js +177 -161
- package/dist/bin/commands/sync-secrets.js +172 -158
- 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 -24
- package/dist/bin/donotdev.js +24 -24
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +661 -669
- package/dist/index.js.map +1 -1
- 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 +576 -0
- package/templates/root-consumer/entities/index.ts.example +15 -0
- package/templates/root-consumer/eslint.config.js.example +2 -80
- 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 +539 -0
- package/templates/root-consumer/guides/dndev/SETUP_FUNCTIONS.md.example +116 -0
- package/templates/root-consumer/guides/{SETUP_I18N.md.example → dndev/SETUP_I18N.md.example} +46 -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_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
|
@@ -797,6 +797,7 @@ ${import_picocolors2.default.gray(d2)} ${t}
|
|
|
797
797
|
});
|
|
798
798
|
|
|
799
799
|
// packages/tooling/src/utils/cli-output.ts
|
|
800
|
+
import "node:os";
|
|
800
801
|
function supportsColor() {
|
|
801
802
|
if (process.env.NO_COLOR) return false;
|
|
802
803
|
if (process.platform === "win32") {
|
|
@@ -942,155 +943,6 @@ var init_cli_output = __esm({
|
|
|
942
943
|
}
|
|
943
944
|
});
|
|
944
945
|
|
|
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
946
|
// node_modules/.bun/fast-glob@3.3.3/node_modules/fast-glob/out/utils/array.js
|
|
1095
947
|
var require_array = __commonJS({
|
|
1096
948
|
"node_modules/.bun/fast-glob@3.3.3/node_modules/fast-glob/out/utils/array.js"(exports) {
|
|
@@ -6675,70 +6527,229 @@ var require_out4 = __commonJS({
|
|
|
6675
6527
|
}
|
|
6676
6528
|
});
|
|
6677
6529
|
|
|
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
|
-
});
|
|
6530
|
+
// packages/core/config/constants.js
|
|
6531
|
+
function getPatternsFor(type, repoRoot = null) {
|
|
6532
|
+
const patterns = SCAN_PATTERNS[type];
|
|
6533
|
+
if (!patterns) {
|
|
6534
|
+
throw new Error(`Unknown pattern type: ${type}`);
|
|
6535
|
+
}
|
|
6536
|
+
if (repoRoot && patterns.framework) {
|
|
6537
|
+
return {
|
|
6538
|
+
...patterns,
|
|
6539
|
+
framework: patterns.framework.map((pattern) => `${repoRoot}/${pattern}`)
|
|
6540
|
+
};
|
|
6541
|
+
}
|
|
6542
|
+
return patterns;
|
|
6697
6543
|
}
|
|
6698
|
-
|
|
6699
|
-
|
|
6700
|
-
|
|
6544
|
+
function getGlobOptionsFor(type) {
|
|
6545
|
+
return GLOB_OPTIONS[type] || GLOB_OPTIONS.base;
|
|
6546
|
+
}
|
|
6547
|
+
var I18N_PATHS, SCAN_PATTERNS, GLOB_OPTIONS;
|
|
6548
|
+
var init_constants = __esm({
|
|
6549
|
+
"packages/core/config/constants.js"() {
|
|
6701
6550
|
"use strict";
|
|
6702
6551
|
init_utils();
|
|
6703
|
-
|
|
6704
|
-
|
|
6705
|
-
|
|
6706
|
-
|
|
6707
|
-
|
|
6708
|
-
|
|
6709
|
-
|
|
6552
|
+
I18N_PATHS = {
|
|
6553
|
+
// Monorepo source structure (locales at root, not in src/)
|
|
6554
|
+
SOURCE_ROOT: "packages/core/i18n",
|
|
6555
|
+
SOURCE_LOCALES: "packages/core/i18n/locales",
|
|
6556
|
+
SOURCE_EAGER: "packages/core/i18n/locales/eager",
|
|
6557
|
+
SOURCE_LAZY: "packages/core/i18n/locales/lazy",
|
|
6558
|
+
// Published structure (same as source - no flattening needed)
|
|
6559
|
+
PUBLISHED_ROOT: "i18n",
|
|
6560
|
+
PUBLISHED_LOCALES: "i18n/locales",
|
|
6561
|
+
PUBLISHED_EAGER: "i18n/locales/eager",
|
|
6562
|
+
PUBLISHED_LAZY: "i18n/locales/lazy"
|
|
6710
6563
|
};
|
|
6711
|
-
|
|
6712
|
-
|
|
6564
|
+
SCAN_PATTERNS = {
|
|
6565
|
+
routes: {
|
|
6566
|
+
consumer: ["src/**/*Page.tsx", "src/pages/**/*Page.tsx"],
|
|
6567
|
+
exclude: [
|
|
6568
|
+
"**/node_modules/**",
|
|
6569
|
+
"**/dist/**",
|
|
6570
|
+
"**/build/**",
|
|
6571
|
+
"**/*.test.tsx",
|
|
6572
|
+
"**/*.stories.tsx"
|
|
6573
|
+
],
|
|
6574
|
+
extensions: [".tsx"]
|
|
6713
6575
|
},
|
|
6714
|
-
|
|
6576
|
+
css: {
|
|
6577
|
+
consumer: ["src/**/*.css"],
|
|
6578
|
+
themes: ["src/**/*.css"],
|
|
6579
|
+
extensions: [".css", ".scss", ".sass"],
|
|
6580
|
+
framework: [
|
|
6581
|
+
"packages/ui/src/**/*.css",
|
|
6582
|
+
"packages/core/components/src/**/*.css",
|
|
6583
|
+
"packages/core/templates/src/**/*.css"
|
|
6584
|
+
]
|
|
6715
6585
|
},
|
|
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
|
-
|
|
6741
|
-
|
|
6586
|
+
i18n: {
|
|
6587
|
+
eager: ["src/locales/*_*.json"],
|
|
6588
|
+
lazy: [
|
|
6589
|
+
"src/**/locales/*_*.json",
|
|
6590
|
+
"!src/locales/*_*.json",
|
|
6591
|
+
// Auto-detect shared entity translations in monorepos (if exists, use it; if not, no problem)
|
|
6592
|
+
"../../entities/locales/*_*.json"
|
|
6593
|
+
],
|
|
6594
|
+
// Additional paths from workspace packages (e.g., shared entities)
|
|
6595
|
+
// Consumers can still configure via i18n.additionalPaths in dndev/vite config for custom paths
|
|
6596
|
+
// Example: ['../../packages/shared/locales/*_*.json']
|
|
6597
|
+
additional: [],
|
|
6598
|
+
framework: {
|
|
6599
|
+
eager: [`${I18N_PATHS.SOURCE_EAGER}/*_*.json`],
|
|
6600
|
+
lazy: [`${I18N_PATHS.SOURCE_LAZY}/*_*.json`]
|
|
6601
|
+
},
|
|
6602
|
+
extensions: [".json"]
|
|
6603
|
+
},
|
|
6604
|
+
assets: {
|
|
6605
|
+
consumer: ["public/**/*"],
|
|
6606
|
+
fallback: ["manifest.json"],
|
|
6607
|
+
modern: [
|
|
6608
|
+
"logo.svg",
|
|
6609
|
+
"favicon.svg",
|
|
6610
|
+
"apple-touch-icon.png",
|
|
6611
|
+
"android-chrome-192x192.png",
|
|
6612
|
+
"android-chrome-512x512.png"
|
|
6613
|
+
],
|
|
6614
|
+
patterns: [
|
|
6615
|
+
"favicon.svg",
|
|
6616
|
+
"favicon.ico",
|
|
6617
|
+
"favicon-*.png",
|
|
6618
|
+
"logo.svg",
|
|
6619
|
+
"logo.png",
|
|
6620
|
+
"logo.webp",
|
|
6621
|
+
"logo.avif",
|
|
6622
|
+
"apple-touch-icon*.png",
|
|
6623
|
+
"android-chrome-*.png",
|
|
6624
|
+
"manifest.json"
|
|
6625
|
+
],
|
|
6626
|
+
fonts: ["fonts/**/*.woff2", "fonts/**/*.woff", "fonts/**/*.ttf"],
|
|
6627
|
+
framework: ["packages/ui/assets/**/*"]
|
|
6628
|
+
},
|
|
6629
|
+
pwa: {
|
|
6630
|
+
consumer: [
|
|
6631
|
+
"public/manifest.json",
|
|
6632
|
+
"public/service-worker.js",
|
|
6633
|
+
"public/sw.js",
|
|
6634
|
+
"public/icon-192x192.png",
|
|
6635
|
+
"public/icon-512x512.png",
|
|
6636
|
+
"public/favicon.ico",
|
|
6637
|
+
"public/favicon.svg",
|
|
6638
|
+
"public/apple-touch-icon.png",
|
|
6639
|
+
"public/logo.svg"
|
|
6640
|
+
],
|
|
6641
|
+
exclude: ["**/node_modules/**", "**/dist/**", "**/build/**"],
|
|
6642
|
+
extensions: [".json", ".js", ".png", ".svg", ".ico"],
|
|
6643
|
+
framework: ["packages/ui/assets/**/*"]
|
|
6644
|
+
},
|
|
6645
|
+
globalIgnore: [
|
|
6646
|
+
"**/node_modules/**",
|
|
6647
|
+
"**/dist/**",
|
|
6648
|
+
"**/build/**",
|
|
6649
|
+
"**/.git/**",
|
|
6650
|
+
"**/coverage/**",
|
|
6651
|
+
"**/test/**"
|
|
6652
|
+
]
|
|
6653
|
+
};
|
|
6654
|
+
GLOB_OPTIONS = {
|
|
6655
|
+
base: {
|
|
6656
|
+
absolute: true,
|
|
6657
|
+
onlyFiles: true,
|
|
6658
|
+
ignore: SCAN_PATTERNS.globalIgnore
|
|
6659
|
+
},
|
|
6660
|
+
css: {
|
|
6661
|
+
absolute: true,
|
|
6662
|
+
onlyFiles: true,
|
|
6663
|
+
ignore: [...SCAN_PATTERNS.globalIgnore, "**/*.test.css"]
|
|
6664
|
+
},
|
|
6665
|
+
routes: {
|
|
6666
|
+
absolute: true,
|
|
6667
|
+
onlyFiles: true,
|
|
6668
|
+
ignore: [
|
|
6669
|
+
...SCAN_PATTERNS.globalIgnore,
|
|
6670
|
+
"**/*.test.tsx",
|
|
6671
|
+
"**/*.stories.tsx"
|
|
6672
|
+
]
|
|
6673
|
+
},
|
|
6674
|
+
i18n: {
|
|
6675
|
+
absolute: true,
|
|
6676
|
+
onlyFiles: true,
|
|
6677
|
+
ignore: SCAN_PATTERNS.globalIgnore
|
|
6678
|
+
},
|
|
6679
|
+
assets: {
|
|
6680
|
+
absolute: true,
|
|
6681
|
+
onlyFiles: true,
|
|
6682
|
+
ignore: SCAN_PATTERNS.globalIgnore
|
|
6683
|
+
}
|
|
6684
|
+
};
|
|
6685
|
+
}
|
|
6686
|
+
});
|
|
6687
|
+
|
|
6688
|
+
// packages/core/config/utils/PathResolver.ts
|
|
6689
|
+
import * as fs from "node:fs";
|
|
6690
|
+
import "node:fs";
|
|
6691
|
+
import { createRequire } from "node:module";
|
|
6692
|
+
import {
|
|
6693
|
+
resolve,
|
|
6694
|
+
join,
|
|
6695
|
+
dirname,
|
|
6696
|
+
relative,
|
|
6697
|
+
normalize,
|
|
6698
|
+
sep,
|
|
6699
|
+
extname
|
|
6700
|
+
} from "node:path";
|
|
6701
|
+
import { fileURLToPath } from "node:url";
|
|
6702
|
+
function safeExecuteAsync(fn, message) {
|
|
6703
|
+
return fn().catch((error2) => {
|
|
6704
|
+
throw new Error(
|
|
6705
|
+
`${message}: ${error2 instanceof Error ? error2.message : String(error2)}`
|
|
6706
|
+
);
|
|
6707
|
+
});
|
|
6708
|
+
}
|
|
6709
|
+
var import_fast_glob, constants, log2, PACKAGE_PATHS, PathResolver;
|
|
6710
|
+
var init_PathResolver = __esm({
|
|
6711
|
+
"packages/core/config/utils/PathResolver.ts"() {
|
|
6712
|
+
"use strict";
|
|
6713
|
+
init_utils();
|
|
6714
|
+
import_fast_glob = __toESM(require_out4(), 1);
|
|
6715
|
+
init_constants();
|
|
6716
|
+
constants = {
|
|
6717
|
+
getGlobOptionsFor: getGlobOptionsFor || void 0,
|
|
6718
|
+
SCAN_PATTERNS: SCAN_PATTERNS || void 0,
|
|
6719
|
+
getPatternsFor: getPatternsFor || void 0,
|
|
6720
|
+
I18N_PATHS: I18N_PATHS || void 0
|
|
6721
|
+
};
|
|
6722
|
+
log2 = {
|
|
6723
|
+
error: (message, error2) => {
|
|
6724
|
+
},
|
|
6725
|
+
warn: (message, error2) => {
|
|
6726
|
+
},
|
|
6727
|
+
info: (message) => {
|
|
6728
|
+
}
|
|
6729
|
+
};
|
|
6730
|
+
PACKAGE_PATHS = {
|
|
6731
|
+
CLI: "packages/cli",
|
|
6732
|
+
COMPONENTS: "packages/core/components",
|
|
6733
|
+
CONFIG: "packages/core/config",
|
|
6734
|
+
// I18n paths - single source of truth (use I18N_PATHS from constants.js)
|
|
6735
|
+
CORE: "packages/core",
|
|
6736
|
+
CRUD: "packages/core/crud",
|
|
6737
|
+
FEATURES: "packages/features",
|
|
6738
|
+
HOOKS: "packages/core/hooks",
|
|
6739
|
+
I18N: "packages/core/i18n",
|
|
6740
|
+
SCHEMAS: "packages/core/schemas",
|
|
6741
|
+
STORES: "packages/core/stores",
|
|
6742
|
+
TEMPLATES: "packages/templates",
|
|
6743
|
+
TOOLING: "packages/tooling",
|
|
6744
|
+
TYPES: "packages/core/types",
|
|
6745
|
+
UI: "packages/ui",
|
|
6746
|
+
UTILS: "packages/core/utils",
|
|
6747
|
+
AUTH: "packages/features/auth",
|
|
6748
|
+
BILLING: "packages/features/billing",
|
|
6749
|
+
OAUTH: "packages/features/oauth",
|
|
6750
|
+
FIREBASE: "packages/providers/firebase",
|
|
6751
|
+
FUNCTIONS: "packages/functions"
|
|
6752
|
+
};
|
|
6742
6753
|
PathResolver = class _PathResolver {
|
|
6743
6754
|
static _instance = null;
|
|
6744
6755
|
options;
|
|
@@ -7789,6 +7800,7 @@ var init_errors = __esm({
|
|
|
7789
7800
|
});
|
|
7790
7801
|
|
|
7791
7802
|
// packages/tooling/src/utils/pathResolver.ts
|
|
7803
|
+
import { createRequire as createRequire2 } from "node:module";
|
|
7792
7804
|
import {
|
|
7793
7805
|
join as join2,
|
|
7794
7806
|
dirname as dirname2,
|
|
@@ -7798,6 +7810,7 @@ import {
|
|
|
7798
7810
|
resolve as resolve2,
|
|
7799
7811
|
isAbsolute as pathIsAbsolute
|
|
7800
7812
|
} from "node:path";
|
|
7813
|
+
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
7801
7814
|
function readdirSync2(dirPath, options) {
|
|
7802
7815
|
return pathResolverInstance.readdirSync(dirPath, options);
|
|
7803
7816
|
}
|
|
@@ -7825,17 +7838,18 @@ var init_pathResolver = __esm({
|
|
|
7825
7838
|
});
|
|
7826
7839
|
|
|
7827
7840
|
// packages/tooling/src/bundler/utils.ts
|
|
7828
|
-
import { createRequire as createRequire2 } from "node:module";
|
|
7829
|
-
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
7830
|
-
import { dirname as dirname3, resolve as resolve3 } from "node:path";
|
|
7831
7841
|
import { Buffer as Buffer2 } from "node:buffer";
|
|
7842
|
+
import { readFileSync as readFileSync2, writeFileSync as writeFileSync2, mkdirSync as mkdirSync2 } from "node:fs";
|
|
7843
|
+
import { createRequire as createRequire3 } from "node:module";
|
|
7844
|
+
import { dirname as dirname3, resolve as resolve3 } from "node:path";
|
|
7832
7845
|
import process from "node:process";
|
|
7846
|
+
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
7833
7847
|
var require2, __filename, __dirname;
|
|
7834
7848
|
var init_utils = __esm({
|
|
7835
7849
|
"packages/tooling/src/bundler/utils.ts"() {
|
|
7836
7850
|
"use strict";
|
|
7837
|
-
require2 =
|
|
7838
|
-
__filename =
|
|
7851
|
+
require2 = createRequire3(import.meta.url);
|
|
7852
|
+
__filename = fileURLToPath3(import.meta.url);
|
|
7839
7853
|
__dirname = dirname3(__filename);
|
|
7840
7854
|
if (typeof globalThis !== "undefined") {
|
|
7841
7855
|
globalThis.require = require2;
|
|
@@ -8022,10 +8036,11 @@ function safeRemove(path, options = {}) {
|
|
|
8022
8036
|
|
|
8023
8037
|
// packages/tooling/src/apps/deploy.ts
|
|
8024
8038
|
init_utils();
|
|
8025
|
-
init_cli_output();
|
|
8026
|
-
init_cli_output();
|
|
8027
8039
|
import { execSync as execSync3 } from "node:child_process";
|
|
8028
8040
|
|
|
8041
|
+
// packages/tooling/src/apps/deploy-frontend.ts
|
|
8042
|
+
init_utils();
|
|
8043
|
+
|
|
8029
8044
|
// packages/tooling/src/utils/cli-tools.ts
|
|
8030
8045
|
init_utils();
|
|
8031
8046
|
init_dist2();
|
|
@@ -8275,40 +8290,269 @@ function requireCLI(tool, additionalContext) {
|
|
|
8275
8290
|
return true;
|
|
8276
8291
|
}
|
|
8277
8292
|
|
|
8278
|
-
// packages/tooling/src/apps/deploy.ts
|
|
8279
|
-
|
|
8280
|
-
|
|
8293
|
+
// packages/tooling/src/apps/deploy-frontend.ts
|
|
8294
|
+
async function deployFrontend(appDir, serviceAccountPath, projectId, config) {
|
|
8295
|
+
const s = Y2();
|
|
8296
|
+
s.start("Deploying frontend to Firebase Hosting...");
|
|
8297
|
+
const args = buildFirebaseDeployArgs("hosting", projectId, config.debug);
|
|
8298
|
+
const result = executeFirebaseCommand(args, {
|
|
8299
|
+
cwd: appDir,
|
|
8300
|
+
serviceAccountPath,
|
|
8301
|
+
projectId,
|
|
8302
|
+
debug: config.debug
|
|
8303
|
+
});
|
|
8304
|
+
if (result.error) {
|
|
8305
|
+
s.stop("Deployment failed");
|
|
8306
|
+
throw result.error;
|
|
8307
|
+
}
|
|
8308
|
+
if (!result.success) {
|
|
8309
|
+
s.stop("Deployment failed");
|
|
8310
|
+
handleDeploymentFailure(
|
|
8311
|
+
result,
|
|
8312
|
+
`firebase ${args.join(" ")}`,
|
|
8313
|
+
serviceAccountPath
|
|
8314
|
+
);
|
|
8315
|
+
}
|
|
8316
|
+
s.stop("Frontend deployed successfully");
|
|
8317
|
+
}
|
|
8281
8318
|
|
|
8282
|
-
// packages/tooling/src/apps/deploy-
|
|
8319
|
+
// packages/tooling/src/apps/deploy-functions.ts
|
|
8283
8320
|
init_utils();
|
|
8284
|
-
import {
|
|
8321
|
+
import { execSync as execSync2 } from "node:child_process";
|
|
8285
8322
|
init_pathResolver();
|
|
8286
|
-
function
|
|
8287
|
-
const
|
|
8288
|
-
const
|
|
8289
|
-
|
|
8290
|
-
|
|
8291
|
-
|
|
8292
|
-
|
|
8293
|
-
const
|
|
8294
|
-
|
|
8295
|
-
|
|
8296
|
-
|
|
8297
|
-
|
|
8298
|
-
|
|
8299
|
-
|
|
8300
|
-
}
|
|
8301
|
-
|
|
8302
|
-
|
|
8303
|
-
|
|
8304
|
-
|
|
8305
|
-
|
|
8306
|
-
|
|
8307
|
-
|
|
8308
|
-
|
|
8323
|
+
function backupFiles(functionsDir) {
|
|
8324
|
+
const backupDir = joinPath(functionsDir, ".deploy-backup");
|
|
8325
|
+
const packageJsonPath = joinPath(functionsDir, "package.json");
|
|
8326
|
+
const packageLockJsonPath = joinPath(functionsDir, "package-lock.json");
|
|
8327
|
+
try {
|
|
8328
|
+
ensureDirSync(backupDir);
|
|
8329
|
+
const backupPackageJson = joinPath(backupDir, "package.json");
|
|
8330
|
+
const backupPackageLockJson = joinPath(backupDir, "package-lock.json");
|
|
8331
|
+
if (pathExists(packageJsonPath)) {
|
|
8332
|
+
const content = readSync(packageJsonPath, { format: "text" });
|
|
8333
|
+
if (!content) {
|
|
8334
|
+
throw new Error(`Failed to read package.json: ${packageJsonPath}`);
|
|
8335
|
+
}
|
|
8336
|
+
writeSync(backupPackageJson, content, { overwrite: true });
|
|
8337
|
+
}
|
|
8338
|
+
if (pathExists(packageLockJsonPath)) {
|
|
8339
|
+
const content = readSync(packageLockJsonPath, { format: "text" });
|
|
8340
|
+
if (!content) {
|
|
8341
|
+
throw new Error(
|
|
8342
|
+
`Failed to read package-lock.json: ${packageLockJsonPath}`
|
|
8343
|
+
);
|
|
8344
|
+
}
|
|
8345
|
+
writeSync(backupPackageLockJson, content, { overwrite: true });
|
|
8346
|
+
}
|
|
8347
|
+
return {
|
|
8348
|
+
packageJson: backupPackageJson,
|
|
8349
|
+
packageLockJson: backupPackageLockJson
|
|
8350
|
+
};
|
|
8351
|
+
} catch (error2) {
|
|
8352
|
+
log.warn(
|
|
8353
|
+
`Failed to backup files: ${error2 instanceof Error ? error2.message : String(error2)}`
|
|
8309
8354
|
);
|
|
8355
|
+
return null;
|
|
8310
8356
|
}
|
|
8311
|
-
|
|
8357
|
+
}
|
|
8358
|
+
function generateCleanPackageJson(functionsDir) {
|
|
8359
|
+
const packageJsonPath = joinPath(functionsDir, "package.json");
|
|
8360
|
+
if (!pathExists(packageJsonPath)) {
|
|
8361
|
+
throw new DoNotDevError(
|
|
8362
|
+
`package.json not found: ${packageJsonPath}`,
|
|
8363
|
+
"file-not-found"
|
|
8364
|
+
);
|
|
8365
|
+
}
|
|
8366
|
+
const packageJson = readSync(packageJsonPath, { format: "json" });
|
|
8367
|
+
if (!packageJson) {
|
|
8368
|
+
throw new Error(
|
|
8369
|
+
`package.json is empty or invalid JSON at ${packageJsonPath}`
|
|
8370
|
+
);
|
|
8371
|
+
}
|
|
8372
|
+
const cleanPackageJson = { ...packageJson };
|
|
8373
|
+
if (cleanPackageJson.dependencies) {
|
|
8374
|
+
cleanPackageJson.dependencies = Object.fromEntries(
|
|
8375
|
+
Object.entries(cleanPackageJson.dependencies).filter(
|
|
8376
|
+
([, version]) => !String(version).startsWith("file:") && !String(version).startsWith("workspace:")
|
|
8377
|
+
)
|
|
8378
|
+
);
|
|
8379
|
+
}
|
|
8380
|
+
if (cleanPackageJson.devDependencies) {
|
|
8381
|
+
cleanPackageJson.devDependencies = Object.fromEntries(
|
|
8382
|
+
Object.entries(cleanPackageJson.devDependencies).filter(
|
|
8383
|
+
([, version]) => !String(version).startsWith("file:") && !String(version).startsWith("workspace:")
|
|
8384
|
+
)
|
|
8385
|
+
);
|
|
8386
|
+
}
|
|
8387
|
+
if (cleanPackageJson.scripts?.preinstall) {
|
|
8388
|
+
delete cleanPackageJson.scripts.preinstall;
|
|
8389
|
+
}
|
|
8390
|
+
const content = JSON.stringify(cleanPackageJson, null, 2) + "\n";
|
|
8391
|
+
writeSync(packageJsonPath, content, { overwrite: true });
|
|
8392
|
+
}
|
|
8393
|
+
function prepareFunctionsForDeployment(functionsDir, verbose = false) {
|
|
8394
|
+
const s = Y2();
|
|
8395
|
+
s.start("Preparing functions for deployment...");
|
|
8396
|
+
try {
|
|
8397
|
+
backupFiles(functionsDir);
|
|
8398
|
+
generateCleanPackageJson(functionsDir);
|
|
8399
|
+
safeRemove(joinPath(functionsDir, "package-lock.json"), {
|
|
8400
|
+
logSuccess: true,
|
|
8401
|
+
successMessage: "Removed package-lock.json - Firebase Cloud Build will generate its own"
|
|
8402
|
+
});
|
|
8403
|
+
s.stop("Functions prepared for deployment");
|
|
8404
|
+
} catch (error2) {
|
|
8405
|
+
s.stop("Preparation failed");
|
|
8406
|
+
throw error2;
|
|
8407
|
+
}
|
|
8408
|
+
}
|
|
8409
|
+
function restoreFunctionsAfterDeployment(functionsDir) {
|
|
8410
|
+
const backupDir = joinPath(functionsDir, ".deploy-backup");
|
|
8411
|
+
const backupPackageJson = joinPath(backupDir, "package.json");
|
|
8412
|
+
const backupPackageLockJson = joinPath(backupDir, "package-lock.json");
|
|
8413
|
+
const packageJsonPath = joinPath(functionsDir, "package.json");
|
|
8414
|
+
const packageLockJsonPath = joinPath(functionsDir, "package-lock.json");
|
|
8415
|
+
try {
|
|
8416
|
+
if (pathExists(backupPackageJson)) {
|
|
8417
|
+
const content = readSync(backupPackageJson, { format: "text" });
|
|
8418
|
+
if (!content) {
|
|
8419
|
+
throw new Error(
|
|
8420
|
+
`Failed to read backup package.json: ${backupPackageJson}`
|
|
8421
|
+
);
|
|
8422
|
+
}
|
|
8423
|
+
writeSync(packageJsonPath, content, { overwrite: true });
|
|
8424
|
+
}
|
|
8425
|
+
if (pathExists(backupPackageLockJson)) {
|
|
8426
|
+
const content = readSync(backupPackageLockJson, { format: "text" });
|
|
8427
|
+
if (!content) {
|
|
8428
|
+
throw new Error(
|
|
8429
|
+
`Failed to read backup package-lock.json: ${backupPackageLockJson}`
|
|
8430
|
+
);
|
|
8431
|
+
}
|
|
8432
|
+
writeSync(packageLockJsonPath, content, { overwrite: true });
|
|
8433
|
+
}
|
|
8434
|
+
safeRemove(backupDir, { silent: true });
|
|
8435
|
+
} catch (error2) {
|
|
8436
|
+
log.warn(
|
|
8437
|
+
`Failed to restore files: ${error2 instanceof Error ? error2.message : String(error2)}`
|
|
8438
|
+
);
|
|
8439
|
+
log.warn(` Backup directory: ${backupDir}`);
|
|
8440
|
+
}
|
|
8441
|
+
}
|
|
8442
|
+
async function deployFunctions(appDir, serviceAccountPath, projectId, config) {
|
|
8443
|
+
const functionsDir = joinPath(appDir, "functions");
|
|
8444
|
+
if (!pathExists(functionsDir)) {
|
|
8445
|
+
throw new DoNotDevError(
|
|
8446
|
+
`Functions directory not found: ${functionsDir}`,
|
|
8447
|
+
"file-not-found"
|
|
8448
|
+
);
|
|
8449
|
+
}
|
|
8450
|
+
const s = Y2();
|
|
8451
|
+
s.start("Validating function dependencies...");
|
|
8452
|
+
const requiredPackages = ["firebase-functions", "firebase-admin"];
|
|
8453
|
+
const missingPackages = requiredPackages.filter((pkg) => {
|
|
8454
|
+
try {
|
|
8455
|
+
resolvePackage(pkg, functionsDir);
|
|
8456
|
+
return false;
|
|
8457
|
+
} catch {
|
|
8458
|
+
return true;
|
|
8459
|
+
}
|
|
8460
|
+
});
|
|
8461
|
+
if (missingPackages.length > 0) {
|
|
8462
|
+
s.stop("Missing dependencies");
|
|
8463
|
+
throw new DoNotDevError(
|
|
8464
|
+
`Missing required dependencies: ${missingPackages.join(", ")}
|
|
8465
|
+
|
|
8466
|
+
To fix this, run:
|
|
8467
|
+
cd ${functionsDir}
|
|
8468
|
+
npm install --production`,
|
|
8469
|
+
"file-not-found",
|
|
8470
|
+
{ context: { missingPackages, functionsDir } }
|
|
8471
|
+
);
|
|
8472
|
+
}
|
|
8473
|
+
s.stop("Dependencies validated");
|
|
8474
|
+
prepareFunctionsForDeployment(functionsDir, config.verbose);
|
|
8475
|
+
log.debug("Waiting for file system sync...");
|
|
8476
|
+
await new Promise((resolve4) => setTimeout(resolve4, 1e3));
|
|
8477
|
+
try {
|
|
8478
|
+
if (!config.skipBuild) {
|
|
8479
|
+
const s2 = Y2();
|
|
8480
|
+
s2.start("Building functions...");
|
|
8481
|
+
try {
|
|
8482
|
+
execSync2("bun run build", {
|
|
8483
|
+
cwd: functionsDir,
|
|
8484
|
+
stdio: config.verbose ? "inherit" : "pipe"
|
|
8485
|
+
});
|
|
8486
|
+
s2.stop("Functions built");
|
|
8487
|
+
} catch (error2) {
|
|
8488
|
+
s2.stop("Build failed");
|
|
8489
|
+
throw error2;
|
|
8490
|
+
}
|
|
8491
|
+
}
|
|
8492
|
+
s.start("Deploying functions to Firebase...");
|
|
8493
|
+
const firebaseProjectDir = pathExists(joinPath(appDir, "firebase.json")) ? appDir : functionsDir;
|
|
8494
|
+
log.debug(`Using service account: ${serviceAccountPath}`);
|
|
8495
|
+
log.debug(`Firebase project directory: ${firebaseProjectDir}`);
|
|
8496
|
+
const args = buildFirebaseDeployArgs(
|
|
8497
|
+
"functions",
|
|
8498
|
+
projectId,
|
|
8499
|
+
config.debug,
|
|
8500
|
+
config.force
|
|
8501
|
+
);
|
|
8502
|
+
const result = executeFirebaseCommand(args, {
|
|
8503
|
+
cwd: firebaseProjectDir,
|
|
8504
|
+
serviceAccountPath,
|
|
8505
|
+
projectId,
|
|
8506
|
+
debug: config.debug
|
|
8507
|
+
});
|
|
8508
|
+
if (result.error) {
|
|
8509
|
+
s.stop("Deployment failed");
|
|
8510
|
+
throw result.error;
|
|
8511
|
+
}
|
|
8512
|
+
if (!result.success) {
|
|
8513
|
+
s.stop("Deployment failed");
|
|
8514
|
+
handleDeploymentFailure(
|
|
8515
|
+
result,
|
|
8516
|
+
`firebase ${args.join(" ")}`,
|
|
8517
|
+
serviceAccountPath
|
|
8518
|
+
);
|
|
8519
|
+
}
|
|
8520
|
+
s.stop("Functions deployed successfully");
|
|
8521
|
+
} finally {
|
|
8522
|
+
restoreFunctionsAfterDeployment(functionsDir);
|
|
8523
|
+
}
|
|
8524
|
+
}
|
|
8525
|
+
|
|
8526
|
+
// packages/tooling/src/apps/deploy-utils.ts
|
|
8527
|
+
init_utils();
|
|
8528
|
+
import { spawnSync as spawnSync3 } from "node:child_process";
|
|
8529
|
+
init_pathResolver();
|
|
8530
|
+
function detectAvailableApps() {
|
|
8531
|
+
const currentDir = process.cwd();
|
|
8532
|
+
const appsDir = joinPath(currentDir, "apps");
|
|
8533
|
+
if (!pathExists(appsDir)) {
|
|
8534
|
+
return [];
|
|
8535
|
+
}
|
|
8536
|
+
return readdirSync2(appsDir).filter((item) => {
|
|
8537
|
+
const itemPath = joinPath(appsDir, item);
|
|
8538
|
+
const stat = statSync2(itemPath);
|
|
8539
|
+
return stat?.isDirectory() === true;
|
|
8540
|
+
}).filter((app) => {
|
|
8541
|
+
const firebaseJsonPath = joinPath(appsDir, app, "firebase.json");
|
|
8542
|
+
return pathExists(firebaseJsonPath);
|
|
8543
|
+
}).sort();
|
|
8544
|
+
}
|
|
8545
|
+
function detectAppDir(appName) {
|
|
8546
|
+
const currentDir = process.cwd();
|
|
8547
|
+
const appDir = joinPath(currentDir, "apps", appName);
|
|
8548
|
+
if (!pathExists(appDir)) {
|
|
8549
|
+
throw new DoNotDevError(
|
|
8550
|
+
`App directory not found: ${appDir}`,
|
|
8551
|
+
"file-not-found",
|
|
8552
|
+
{ context: { appName, expectedPath: appDir } }
|
|
8553
|
+
);
|
|
8554
|
+
}
|
|
8555
|
+
return appDir;
|
|
8312
8556
|
}
|
|
8313
8557
|
function validateServiceAccount(appDir) {
|
|
8314
8558
|
const rootKeyPath = joinPath(appDir, "service-account-key.json");
|
|
@@ -8522,241 +8766,11 @@ function clearFirebaseCache(appDir) {
|
|
|
8522
8766
|
}
|
|
8523
8767
|
}
|
|
8524
8768
|
|
|
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
8769
|
// packages/tooling/src/apps/deploy.ts
|
|
8770
|
+
init_cli_output();
|
|
8771
|
+
init_cli_output();
|
|
8772
|
+
init_errors();
|
|
8773
|
+
init_pathResolver();
|
|
8760
8774
|
async function main(options = {}) {
|
|
8761
8775
|
const config = {
|
|
8762
8776
|
app: options.app,
|