@popina/cli 5.1.1 → 5.1.2-20260910122156Z

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/build/index.js CHANGED
@@ -151,71 +151,7 @@ async function fetchEnv(email3) {
151
151
 
152
152
  // src/utils/gcloud/login-to-google.ts
153
153
  import * as p5 from "@clack/prompts";
154
- import { $ as $8 } from "zx/core";
155
- var emailRegex = /[\w.+-]+@[\w.-]+\.[a-z]{2,}/i;
156
- async function getActiveGoogleAccount() {
157
- try {
158
- const { stdout } = await $8`gcloud config get-value account`.quiet();
159
- return stdout.match(emailRegex)?.[0];
160
- } catch {
161
- return void 0;
162
- }
163
- }
164
- async function loginGoogle() {
165
- const activeAccount = await getActiveGoogleAccount();
166
- if (activeAccount) return activeAccount;
167
- await $8`gcloud auth login`;
168
- const authenticatedAccount = await getActiveGoogleAccount();
169
- if (!authenticatedAccount) {
170
- p5.log.warn(
171
- "Could not detect your Google account email. Add INITIAL_SUPER_ADMIN_EMAIL to .env manually after setup."
172
- );
173
- }
174
- return authenticatedAccount;
175
- }
176
-
177
- // src/utils/get-env-config.ts
178
- import fse2 from "fs-extra";
179
- import path from "path";
180
- var removeDirectory = (dir) => {
181
- try {
182
- fse2.rmSync(dir, { recursive: true });
183
- } catch (error51) {
184
- console.error(`Error removing directory: ${error51}`);
185
- process.exit(1);
186
- }
187
- };
188
- var copyDirectory = (source, destination) => {
189
- try {
190
- if (fse2.existsSync(destination)) {
191
- removeDirectory(destination);
192
- }
193
- fse2.mkdirSync(destination, { recursive: true });
194
- fse2.readdirSync(source).forEach((file2) => {
195
- const sourcePath = path.join(source, file2);
196
- const destinationPath = path.join(destination, file2);
197
- if (fse2.lstatSync(sourcePath).isDirectory()) {
198
- copyDirectory(sourcePath, destinationPath);
199
- } else {
200
- fse2.copyFileSync(sourcePath, destinationPath);
201
- }
202
- });
203
- } catch (error51) {
204
- console.error(`Error copying directory: ${error51}`);
205
- process.exit(1);
206
- }
207
- };
208
- var getEnvConfig = async (envConfigPath, envConfigCopyPath) => {
209
- copyDirectory(envConfigPath, envConfigCopyPath);
210
- const envConfig = await import(`${envConfigCopyPath}/index.mjs`).then((module) => module.envConfig).catch((error51) => {
211
- console.error(`Error importing env config: ${error51}`);
212
- process.exit(1);
213
- });
214
- return envConfig;
215
- };
216
- var removeEnvConfig = (envConfigCopyPath) => {
217
- removeDirectory(envConfigCopyPath);
218
- };
154
+ import { backOff } from "exponential-backoff";
219
155
 
220
156
  // ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/external.js
221
157
  var external_exports = {};
@@ -14731,8 +14667,103 @@ function date4(params) {
14731
14667
  // ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/external.js
14732
14668
  config(en_default());
14733
14669
 
14670
+ // src/utils/gcloud/login-to-google.ts
14671
+ import { $ as $8 } from "zx/core";
14672
+ var EMAIL_REGEX = /[\w.+-]+@[\w.-]+\.[a-z]{2,}/i;
14673
+ async function loginGoogle() {
14674
+ return await backOff(
14675
+ async () => await $8({
14676
+ input: process.stdin,
14677
+ quiet: true
14678
+ })`gcloud config get-value account`.then((processOutput) => {
14679
+ if (processOutput.stdout.length === 0) {
14680
+ throw new Error("new account");
14681
+ }
14682
+ return processOutput;
14683
+ }),
14684
+ {
14685
+ retry: async (error51, attemptNumber) => {
14686
+ if (attemptNumber > 3) {
14687
+ p5.log.error(
14688
+ `\u{1F534} Couldn't manually re-authenticate (exceeded max 3 attempts): ${error51.message}`
14689
+ );
14690
+ process.exit(1);
14691
+ }
14692
+ const isNewAccount = error51.message.includes("new account");
14693
+ const isTokenExpired = error51.message.includes(
14694
+ // cspell: disable-next-line
14695
+ "There was a problem refreshing your current auth tokens: Reauthentication failed"
14696
+ );
14697
+ if (!isNewAccount && !isTokenExpired) {
14698
+ p5.log.error(`\u{1F534} gcloud get-value account failed: ${error51.message}`);
14699
+ process.exit(1);
14700
+ }
14701
+ p5.log.info(`\u23F3 Auth tokens expired, manual re-authentication required`);
14702
+ await $8({ input: process.stdin, quiet: true })`gcloud auth login`.then(() => {
14703
+ p5.log.success("\u2705 Manual re-authentication succeeded");
14704
+ }).catch((error52) => {
14705
+ p5.log.error(`\u{1F534} Couldn't re-authenticate: ${error52.message}`);
14706
+ });
14707
+ return true;
14708
+ }
14709
+ }
14710
+ ).then(({ stdout }) => {
14711
+ const parsedEmail = external_exports.email({ pattern: EMAIL_REGEX }).safeParse(stdout);
14712
+ if (!parsedEmail.success) {
14713
+ p5.log.error(
14714
+ `\u{1F534} Couldn't parse user email (${stdout}): ${external_exports.prettifyError(parsedEmail.error)}`
14715
+ );
14716
+ process.exit(1);
14717
+ }
14718
+ return parsedEmail.data;
14719
+ });
14720
+ }
14721
+
14722
+ // src/utils/get-env-config.ts
14723
+ import fse2 from "fs-extra";
14724
+ import path from "path";
14725
+ var removeDirectory = (dir) => {
14726
+ try {
14727
+ fse2.rmSync(dir, { recursive: true });
14728
+ } catch (error51) {
14729
+ console.error(`Error removing directory: ${error51}`);
14730
+ process.exit(1);
14731
+ }
14732
+ };
14733
+ var copyDirectory = (source, destination) => {
14734
+ try {
14735
+ if (fse2.existsSync(destination)) {
14736
+ removeDirectory(destination);
14737
+ }
14738
+ fse2.mkdirSync(destination, { recursive: true });
14739
+ fse2.readdirSync(source).forEach((file2) => {
14740
+ const sourcePath = path.join(source, file2);
14741
+ const destinationPath = path.join(destination, file2);
14742
+ if (fse2.lstatSync(sourcePath).isDirectory()) {
14743
+ copyDirectory(sourcePath, destinationPath);
14744
+ } else {
14745
+ fse2.copyFileSync(sourcePath, destinationPath);
14746
+ }
14747
+ });
14748
+ } catch (error51) {
14749
+ console.error(`Error copying directory: ${error51}`);
14750
+ process.exit(1);
14751
+ }
14752
+ };
14753
+ var getEnvConfig = async (envConfigPath, envConfigCopyPath) => {
14754
+ copyDirectory(envConfigPath, envConfigCopyPath);
14755
+ const envConfig = await import(`${envConfigCopyPath}/index.mjs`).then((module) => module.envConfig).catch((error51) => {
14756
+ console.error(`Error importing env config: ${error51}`);
14757
+ process.exit(1);
14758
+ });
14759
+ return envConfig;
14760
+ };
14761
+ var removeEnvConfig = (envConfigCopyPath) => {
14762
+ removeDirectory(envConfigCopyPath);
14763
+ };
14764
+
14734
14765
  // package.json
14735
- var version2 = "5.1.1";
14766
+ var version2 = "5.1.2-20260910122156Z";
14736
14767
 
14737
14768
  // src/utils/get-package-info.ts
14738
14769
  async function getPackageInfo() {