@stoker-platform/cli 0.5.54 → 0.5.55
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/lib/package.json +4 -4
- package/lib/src/project/addProject.js +68 -26
- package/package.json +1 -1
package/lib/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stoker-platform/cli",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.54",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"main": "./lib/src/main.js",
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
"@google-cloud/secret-manager": "^6.1.1",
|
|
25
25
|
"@google-cloud/storage": "^7.19.0",
|
|
26
26
|
"@inquirer/prompts": "^8.3.2",
|
|
27
|
-
"@stoker-platform/node-client": "0.5.
|
|
28
|
-
"@stoker-platform/types": "0.5.
|
|
29
|
-
"@stoker-platform/utils": "0.5.
|
|
27
|
+
"@stoker-platform/node-client": "0.5.41",
|
|
28
|
+
"@stoker-platform/types": "0.5.28",
|
|
29
|
+
"@stoker-platform/utils": "0.5.35",
|
|
30
30
|
"algoliasearch": "^5.50.0",
|
|
31
31
|
"commander": "^14.0.0",
|
|
32
32
|
"cross-spawn": "^7.0.6",
|
|
@@ -638,6 +638,12 @@ export const addProject = async (options) => {
|
|
|
638
638
|
await updateProjectData(26);
|
|
639
639
|
}
|
|
640
640
|
if (getProgress() < 27) {
|
|
641
|
+
if (!smtpPasswordSecret?.name) {
|
|
642
|
+
const [existingSmtpPasswordSecret] = await secretManager.getSecret({
|
|
643
|
+
name: `projects/${projectId}/secrets/firestore-send-email-SMTP_PASSWORD`,
|
|
644
|
+
});
|
|
645
|
+
smtpPasswordSecret = existingSmtpPasswordSecret;
|
|
646
|
+
}
|
|
641
647
|
const [smtpPasswordSecretVersion] = await secretManager.addSecretVersion({
|
|
642
648
|
parent: smtpPasswordSecret.name,
|
|
643
649
|
payload: {
|
|
@@ -667,6 +673,12 @@ export const addProject = async (options) => {
|
|
|
667
673
|
}
|
|
668
674
|
if (getProgress() < 29) {
|
|
669
675
|
if (process.env.TWILIO_AUTH_TOKEN) {
|
|
676
|
+
if (!twilioPasswordSecret?.name) {
|
|
677
|
+
const [existingTwilioPasswordSecret] = await secretManager.getSecret({
|
|
678
|
+
name: `projects/${projectId}/secrets/TWILIO_AUTH_TOKEN`,
|
|
679
|
+
});
|
|
680
|
+
twilioPasswordSecret = existingTwilioPasswordSecret;
|
|
681
|
+
}
|
|
670
682
|
const [twilioPasswordSecretVersion] = await secretManager.addSecretVersion({
|
|
671
683
|
parent: twilioPasswordSecret.name,
|
|
672
684
|
payload: {
|
|
@@ -697,6 +709,12 @@ export const addProject = async (options) => {
|
|
|
697
709
|
}
|
|
698
710
|
if (getProgress() < 31) {
|
|
699
711
|
if (process.env.TWILIO_ACCOUNT_SID) {
|
|
712
|
+
if (!twilioAccountSidSecret?.name) {
|
|
713
|
+
const [existingTwilioAccountSidSecret] = await secretManager.getSecret({
|
|
714
|
+
name: `projects/${projectId}/secrets/TWILIO_ACCOUNT_SID`,
|
|
715
|
+
});
|
|
716
|
+
twilioAccountSidSecret = existingTwilioAccountSidSecret;
|
|
717
|
+
}
|
|
700
718
|
const [twilioAccountSidSecretVersion] = await secretManager.addSecretVersion({
|
|
701
719
|
parent: twilioAccountSidSecret.name,
|
|
702
720
|
payload: {
|
|
@@ -785,29 +803,53 @@ export const addProject = async (options) => {
|
|
|
785
803
|
await runChildProcess("gcloud", apiKeyUpdateArgs);
|
|
786
804
|
await updateProjectData(34);
|
|
787
805
|
}
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
displayName: "Firebase App Check",
|
|
797
|
-
webSettings: {
|
|
798
|
-
allowedDomains: [`${projectId}.web.app`, `${projectId}.firebaseapp.com`],
|
|
799
|
-
integrationType: "SCORE",
|
|
806
|
+
let recaptchaKeyId;
|
|
807
|
+
if (getProgress() < 35) {
|
|
808
|
+
const recaptchaResponse = await fetch(`https://recaptchaenterprise.googleapis.com/v1/projects/${projectId}/keys`, {
|
|
809
|
+
method: "POST",
|
|
810
|
+
headers: {
|
|
811
|
+
Authorization: `Bearer ${token}`,
|
|
812
|
+
"Content-Type": "application/json",
|
|
813
|
+
"X-Goog-User-Project": projectId,
|
|
800
814
|
},
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
815
|
+
body: JSON.stringify({
|
|
816
|
+
displayName: "Firebase App Check",
|
|
817
|
+
webSettings: {
|
|
818
|
+
allowedDomains: [`${projectId}.web.app`, `${projectId}.firebaseapp.com`],
|
|
819
|
+
integrationType: "SCORE",
|
|
820
|
+
},
|
|
821
|
+
}),
|
|
822
|
+
});
|
|
823
|
+
const recaptchaResponseJson = await recaptchaResponse.json();
|
|
824
|
+
console.log(recaptchaResponseJson);
|
|
825
|
+
if (!recaptchaResponse.ok) {
|
|
826
|
+
throw new Error("Failed to create Recaptcha key");
|
|
827
|
+
}
|
|
828
|
+
const recaptchaKey = recaptchaResponseJson.name;
|
|
829
|
+
recaptchaKeyId = recaptchaKey.split("/").pop();
|
|
830
|
+
await updateProjectData(35);
|
|
807
831
|
}
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
832
|
+
if (getProgress() < 36) {
|
|
833
|
+
if (!recaptchaKeyId) {
|
|
834
|
+
const listKeysResponse = await fetch(`https://recaptchaenterprise.googleapis.com/v1/projects/${projectId}/keys?pageSize=100`, {
|
|
835
|
+
method: "GET",
|
|
836
|
+
headers: {
|
|
837
|
+
Authorization: `Bearer ${token}`,
|
|
838
|
+
"Content-Type": "application/json",
|
|
839
|
+
"X-Goog-User-Project": projectId,
|
|
840
|
+
},
|
|
841
|
+
});
|
|
842
|
+
const listKeysJson = await listKeysResponse.json();
|
|
843
|
+
if (!listKeysResponse.ok) {
|
|
844
|
+
throw new Error("Failed to list Recaptcha keys");
|
|
845
|
+
}
|
|
846
|
+
const matchingKey = listKeysJson.keys.find((key) => key.displayName === "Firebase App Check");
|
|
847
|
+
const recaptchaKey = matchingKey?.name;
|
|
848
|
+
recaptchaKeyId = recaptchaKey ? recaptchaKey.split("/").pop() : undefined;
|
|
849
|
+
if (!recaptchaKeyId) {
|
|
850
|
+
throw new Error("Failed to recover Recaptcha key ID");
|
|
851
|
+
}
|
|
852
|
+
}
|
|
811
853
|
const recaptchaEnterpriseConfig = await fetch(`https://firebaseappcheck.googleapis.com/v1beta/projects/${projectId}/apps/${appId}/recaptchaEnterpriseConfig?updateMask=siteKey,tokenTtl,riskAnalysis`, {
|
|
812
854
|
method: "PATCH",
|
|
813
855
|
headers: {
|
|
@@ -830,9 +872,9 @@ export const addProject = async (options) => {
|
|
|
830
872
|
if (!recaptchaEnterpriseConfig.ok) {
|
|
831
873
|
throw new Error("Failed to create Recaptcha Enterprise config");
|
|
832
874
|
}
|
|
833
|
-
await updateProjectData(
|
|
875
|
+
await updateProjectData(36);
|
|
834
876
|
}
|
|
835
|
-
if (getProgress() <
|
|
877
|
+
if (getProgress() < 37) {
|
|
836
878
|
if (process.env.FB_ENABLE_APP_CHECK === "true") {
|
|
837
879
|
const servicesResponse = await fetch(`https://firebaseappcheck.googleapis.com/v1beta/projects/${projectId}/services:batchUpdate`, {
|
|
838
880
|
method: "POST",
|
|
@@ -887,7 +929,7 @@ export const addProject = async (options) => {
|
|
|
887
929
|
throw new Error("Failed to update App Check services");
|
|
888
930
|
}
|
|
889
931
|
}
|
|
890
|
-
await updateProjectData(
|
|
932
|
+
await updateProjectData(37);
|
|
891
933
|
}
|
|
892
934
|
const firebaseJson = JSON.parse(await readFile(join(process.cwd(), "firebase.json"), "utf8"));
|
|
893
935
|
const authPort = firebaseJson.emulators.auth.port;
|
|
@@ -924,9 +966,9 @@ STOKER_FB_EMULATOR_FUNCTIONS_PORT=${functionsPort}`;
|
|
|
924
966
|
// eslint-disable-next-line security/detect-non-literal-fs-filename
|
|
925
967
|
await writeFile(envFile, envContent);
|
|
926
968
|
dotenv.config({ path: join(process.cwd(), ".env", `.env.${projectId}`), quiet: true });
|
|
927
|
-
if (getProgress() <
|
|
969
|
+
if (getProgress() < 38) {
|
|
928
970
|
await runChildProcess("npx", ["stoker", "deploy", "--initial", "--retry"]);
|
|
929
|
-
await updateProjectData(
|
|
971
|
+
await updateProjectData(38);
|
|
930
972
|
}
|
|
931
973
|
await runChildProcess("npx", ["stoker", "set-project"]);
|
|
932
974
|
await addTenant();
|