@@ -22,3 +22,3 @@ import { detectClaimUrl } from "./utils/detect-claim-url.js"; | ||
| if (envPrefix) { | ||
| const claimUrlKey = `${envPrefix}INSTAGRES_CLAIM_URL`; | ||
| const claimUrlKey = `${envPrefix}POSTGRES_CLAIM_URL`; | ||
| claimUrl = dotEnvContent[claimUrlKey]; | ||
@@ -25,0 +25,0 @@ if (!claimUrl) { |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"claim-command.js","names":[],"sources":["../../src/lib/claim-command.ts"],"sourcesContent":["import { log, outro } from \"@clack/prompts\";\nimport open from \"open\";\nimport { detectClaimUrl } from \"./utils/detect-claim-url.js\";\nimport { getDotEnvContent } from \"./utils/fs.js\";\n\nasync function openClaimUrl(claimUrl: string): Promise<void> {\n\ttry {\n\t\tlog.success(`URL located. Opening your default browser.`);\n\t\tawait open(claimUrl);\n\t\toutro(`You can also manually open: ${claimUrl}.`);\n\t\tprocess.exit(0);\n\t} catch (error) {\n\t\tlog.error(\n\t\t\terror instanceof Error ? error.message : \"Failed to open claim URL\",\n\t\t);\n\t\tprocess.exit(1);\n\t}\n}\n\nexport async function claim(\n\tdotEnvPath: string,\n\tenvPrefix?: string,\n): Promise<void> {\n\tconst dotEnvContent = getDotEnvContent(dotEnvPath);\n\tlet claimUrl: string | undefined;\n\n\tif (envPrefix) {\n\t\tconst claimUrlKey = `${envPrefix}INSTAGRES_CLAIM_URL`;\n\t\tclaimUrl = dotEnvContent[claimUrlKey];\n\n\t\tif (!claimUrl) {\n\t\t\tlog.error(`${claimUrlKey} not found in ${dotEnvPath}.`);\n\t\t\toutro(\n\t\t\t\t`Use \\`get-db claim -p <prefix>\\` to override URL auto-detection.`,\n\t\t\t);\n\t\t\tprocess.exit(1);\n\t\t} else {\n\t\t\tawait openClaimUrl(claimUrl);\n\t\t\treturn;\n\t\t}\n\t} else {\n\t\tclaimUrl = detectClaimUrl(dotEnvContent, dotEnvPath);\n\t\tawait openClaimUrl(claimUrl);\n\t\treturn;\n\t}\n}\n"],"mappings":";;;;;;AAKA,eAAe,aAAa,UAAiC;AAC5D,KAAI;AACH,MAAI,QAAQ,6CAA6C;AACzD,QAAM,KAAK,SAAS;AACpB,QAAM,+BAA+B,SAAS,GAAG;AACjD,UAAQ,KAAK,EAAE;UACP,OAAO;AACf,MAAI,MACH,iBAAiB,QAAQ,MAAM,UAAU,2BACzC;AACD,UAAQ,KAAK,EAAE;;;AAIjB,eAAsB,MACrB,YACA,WACgB;CAChB,MAAM,gBAAgB,iBAAiB,WAAW;CAClD,IAAI;AAEJ,KAAI,WAAW;EACd,MAAM,cAAc,GAAG,UAAU;AACjC,aAAW,cAAc;AAEzB,MAAI,CAAC,UAAU;AACd,OAAI,MAAM,GAAG,YAAY,gBAAgB,WAAW,GAAG;AACvD,SACC,mEACA;AACD,WAAQ,KAAK,EAAE;SACT;AACN,SAAM,aAAa,SAAS;AAC5B;;QAEK;AACN,aAAW,eAAe,eAAe,WAAW;AACpD,QAAM,aAAa,SAAS;AAC5B"} | ||
| {"version":3,"file":"claim-command.js","names":[],"sources":["../../src/lib/claim-command.ts"],"sourcesContent":["import { log, outro } from \"@clack/prompts\";\nimport open from \"open\";\nimport { detectClaimUrl } from \"./utils/detect-claim-url.js\";\nimport { getDotEnvContent } from \"./utils/fs.js\";\n\nasync function openClaimUrl(claimUrl: string): Promise<void> {\n\ttry {\n\t\tlog.success(`URL located. Opening your default browser.`);\n\t\tawait open(claimUrl);\n\t\toutro(`You can also manually open: ${claimUrl}.`);\n\t\tprocess.exit(0);\n\t} catch (error) {\n\t\tlog.error(\n\t\t\terror instanceof Error ? error.message : \"Failed to open claim URL\",\n\t\t);\n\t\tprocess.exit(1);\n\t}\n}\n\nexport async function claim(\n\tdotEnvPath: string,\n\tenvPrefix?: string,\n): Promise<void> {\n\tconst dotEnvContent = getDotEnvContent(dotEnvPath);\n\tlet claimUrl: string | undefined;\n\n\tif (envPrefix) {\n\t\tconst claimUrlKey = `${envPrefix}POSTGRES_CLAIM_URL`;\n\t\tclaimUrl = dotEnvContent[claimUrlKey];\n\n\t\tif (!claimUrl) {\n\t\t\tlog.error(`${claimUrlKey} not found in ${dotEnvPath}.`);\n\t\t\toutro(\n\t\t\t\t`Use \\`get-db claim -p <prefix>\\` to override URL auto-detection.`,\n\t\t\t);\n\t\t\tprocess.exit(1);\n\t\t} else {\n\t\t\tawait openClaimUrl(claimUrl);\n\t\t\treturn;\n\t\t}\n\t} else {\n\t\tclaimUrl = detectClaimUrl(dotEnvContent, dotEnvPath);\n\t\tawait openClaimUrl(claimUrl);\n\t\treturn;\n\t}\n}\n"],"mappings":";;;;;;AAKA,eAAe,aAAa,UAAiC;AAC5D,KAAI;AACH,MAAI,QAAQ,6CAA6C;AACzD,QAAM,KAAK,SAAS;AACpB,QAAM,+BAA+B,SAAS,GAAG;AACjD,UAAQ,KAAK,EAAE;UACP,OAAO;AACf,MAAI,MACH,iBAAiB,QAAQ,MAAM,UAAU,2BACzC;AACD,UAAQ,KAAK,EAAE;;;AAIjB,eAAsB,MACrB,YACA,WACgB;CAChB,MAAM,gBAAgB,iBAAiB,WAAW;CAClD,IAAI;AAEJ,KAAI,WAAW;EACd,MAAM,cAAc,GAAG,UAAU;AACjC,aAAW,cAAc;AAEzB,MAAI,CAAC,UAAU;AACd,OAAI,MAAM,GAAG,YAAY,gBAAgB,WAAW,GAAG;AACvD,SACC,mEACA;AACD,WAAQ,KAAK,EAAE;SACT;AACN,SAAM,aAAa,SAAS;AAC5B;;QAEK;AACN,aAAW,eAAe,eAAe,WAAW;AACpD,QAAM,aAAa,SAAS;AAC5B"} |
@@ -6,3 +6,3 @@ import { InstantPostgresParams } from "./types.js"; | ||
| /** | ||
| * Creates an instant Postgres connection string from Instagres by Neon | ||
| * Creates an instant Postgres connection string from Claimable Postgres by Neon | ||
| * if not already set in the specified .env file. | ||
@@ -9,0 +9,0 @@ * Prompts the user to optionally generate a connection string, |
| import { messages } from "./texts.js"; | ||
| import { writeToEnv } from "./utils/fs.js"; | ||
| import { seedDatabase } from "./seed-database.js"; | ||
| import { INSTAGRES_URLS } from "./utils/urls.js"; | ||
| import { CLAIMABLE_POSTGRES_URLS } from "./utils/urls.js"; | ||
| import { createClaimableDatabase } from "./utils/create-db.js"; | ||
@@ -12,3 +12,3 @@ import { getConnectionStrings } from "./utils/format.js"; | ||
| /** | ||
| * Creates an instant Postgres connection string from Instagres by Neon | ||
| * Creates an instant Postgres connection string from Claimable Postgres by Neon | ||
| * if not already set in the specified .env file. | ||
@@ -25,3 +25,3 @@ * Prompts the user to optionally generate a connection string, | ||
| const claimExpiresAt = new Date(Date.now() + 4320 * 60 * 1e3); | ||
| const claimUrl = new URL(INSTAGRES_URLS.CLAIM_DATABASE(dbId)); | ||
| const claimUrl = new URL(CLAIMABLE_POSTGRES_URLS.CLAIM_DATABASE(dbId)); | ||
| const { pooler: poolerString, direct: directString } = getConnectionStrings(await createClaimableDatabase({ | ||
@@ -28,0 +28,0 @@ dbId, |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"instant-postgres.js","names":[],"sources":["../../src/lib/instant-postgres.ts"],"sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport { log } from \"@clack/prompts\";\nimport { seedDatabase } from \"./seed-database.js\";\nimport { messages } from \"./texts.js\";\nimport type { InstantPostgresParams } from \"./types.js\";\nimport { createClaimableDatabase } from \"./utils/create-db.js\";\nimport { getConnectionStrings } from \"./utils/format.js\";\nimport { writeToEnv } from \"./utils/fs.js\";\nimport { INSTAGRES_URLS } from \"./utils/urls.js\";\n\n/**\n * Creates an instant Postgres connection string from Instagres by Neon\n * if not already set in the specified .env file.\n * Prompts the user to optionally generate a connection string,\n * saves it to the .env file, and returns the connection string.\n */\nexport const instantPostgres = async ({\n\tdotEnvFile = \".env\",\n\tdotEnvKey = \"DATABASE_URL\",\n\treferrer,\n\tseed = undefined,\n\tenvPrefix = \"PUBLIC_\",\n\tsettings: { logicalReplication = false } = {},\n}: InstantPostgresParams): Promise<{\n\tdatabaseUrlDirect: string;\n\tdatabaseUrl: string;\n\tclaimUrl: string;\n\tclaimExpiresAt: Date;\n}> => {\n\tif (!referrer || referrer.trim() === \"\") {\n\t\tconst { message, ...cause } = messages.errors.referrerIsRequired;\n\n\t\tthrow new Error(message, {\n\t\t\tcause,\n\t\t});\n\t}\n\n\tconst dbId = randomUUID();\n\tconst claimExpiresAt = new Date(Date.now() + 3 * 24 * 60 * 60 * 1000);\n\tconst claimUrl = new URL(INSTAGRES_URLS.CLAIM_DATABASE(dbId));\n\n\tconst connString = await createClaimableDatabase({\n\t\tdbId,\n\t\treferrer: `npm:get-db|${referrer}`,\n\t\tsettings: { logicalReplication },\n\t});\n\tconst { pooler: poolerString, direct: directString } =\n\t\tgetConnectionStrings(connString);\n\n\tawait writeToEnv(\n\t\tdotEnvFile,\n\t\tdotEnvKey,\n\t\tclaimExpiresAt,\n\t\tclaimUrl,\n\t\tdirectString,\n\t\tpoolerString,\n\t\tenvPrefix,\n\t);\n\n\tif (seed) {\n\t\tlog.step(\"Pushing schema to database\");\n\t\tawait seedDatabase(seed.path, directString);\n\t\tlog.success(\"Schema pushed to database\");\n\t}\n\n\treturn {\n\t\tdatabaseUrlDirect: directString,\n\t\tdatabaseUrl: poolerString,\n\t\tclaimUrl: claimUrl.href,\n\t\tclaimExpiresAt,\n\t} as const;\n};\n\n/**\n * @deprecated Use `instantPostgres` instead\n */\nexport const instantNeon = instantPostgres;\n\nexport type { InstantPostgresParams };\n\n/**\n * @deprecated Use `InstantPostgresParams` instead\n */\nexport type InstantNeonParams = InstantPostgresParams;\n"],"mappings":";;;;;;;;;;;;;;;;AAgBA,MAAa,kBAAkB,OAAO,EACrC,aAAa,QACb,YAAY,gBACZ,UACA,OAAO,QACP,YAAY,WACZ,UAAU,EAAE,qBAAqB,UAAU,EAAE,OAMxC;AACL,KAAI,CAAC,YAAY,SAAS,MAAM,KAAK,IAAI;EACxC,MAAM,EAAE,SAAS,GAAG,UAAU,SAAS,OAAO;AAE9C,QAAM,IAAI,MAAM,SAAS,EACxB,OACA,CAAC;;CAGH,MAAM,OAAO,YAAY;CACzB,MAAM,iBAAiB,IAAI,KAAK,KAAK,KAAK,GAAG,OAAc,KAAK,IAAK;CACrE,MAAM,WAAW,IAAI,IAAI,eAAe,eAAe,KAAK,CAAC;CAO7D,MAAM,EAAE,QAAQ,cAAc,QAAQ,iBACrC,qBANkB,MAAM,wBAAwB;EAChD;EACA,UAAU,cAAc;EACxB,UAAU,EAAE,oBAAoB;EAChC,CAAC,CAE+B;AAEjC,OAAM,WACL,YACA,WACA,gBACA,UACA,cACA,cACA,UACA;AAED,KAAI,MAAM;AACT,MAAI,KAAK,6BAA6B;AACtC,QAAM,aAAa,KAAK,MAAM,aAAa;AAC3C,MAAI,QAAQ,4BAA4B;;AAGzC,QAAO;EACN,mBAAmB;EACnB,aAAa;EACb,UAAU,SAAS;EACnB;EACA;;;;;AAMF,MAAa,cAAc"} | ||
| {"version":3,"file":"instant-postgres.js","names":[],"sources":["../../src/lib/instant-postgres.ts"],"sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport { log } from \"@clack/prompts\";\nimport { seedDatabase } from \"./seed-database.js\";\nimport { messages } from \"./texts.js\";\nimport type { InstantPostgresParams } from \"./types.js\";\nimport { createClaimableDatabase } from \"./utils/create-db.js\";\nimport { getConnectionStrings } from \"./utils/format.js\";\nimport { writeToEnv } from \"./utils/fs.js\";\nimport { CLAIMABLE_POSTGRES_URLS } from \"./utils/urls.js\";\n\n/**\n * Creates an instant Postgres connection string from Claimable Postgres by Neon\n * if not already set in the specified .env file.\n * Prompts the user to optionally generate a connection string,\n * saves it to the .env file, and returns the connection string.\n */\nexport const instantPostgres = async ({\n\tdotEnvFile = \".env\",\n\tdotEnvKey = \"DATABASE_URL\",\n\treferrer,\n\tseed = undefined,\n\tenvPrefix = \"PUBLIC_\",\n\tsettings: { logicalReplication = false } = {},\n}: InstantPostgresParams): Promise<{\n\tdatabaseUrlDirect: string;\n\tdatabaseUrl: string;\n\tclaimUrl: string;\n\tclaimExpiresAt: Date;\n}> => {\n\tif (!referrer || referrer.trim() === \"\") {\n\t\tconst { message, ...cause } = messages.errors.referrerIsRequired;\n\n\t\tthrow new Error(message, {\n\t\t\tcause,\n\t\t});\n\t}\n\n\tconst dbId = randomUUID();\n\tconst claimExpiresAt = new Date(Date.now() + 3 * 24 * 60 * 60 * 1000);\n\tconst claimUrl = new URL(CLAIMABLE_POSTGRES_URLS.CLAIM_DATABASE(dbId));\n\n\tconst connString = await createClaimableDatabase({\n\t\tdbId,\n\t\treferrer: `npm:get-db|${referrer}`,\n\t\tsettings: { logicalReplication },\n\t});\n\tconst { pooler: poolerString, direct: directString } =\n\t\tgetConnectionStrings(connString);\n\n\tawait writeToEnv(\n\t\tdotEnvFile,\n\t\tdotEnvKey,\n\t\tclaimExpiresAt,\n\t\tclaimUrl,\n\t\tdirectString,\n\t\tpoolerString,\n\t\tenvPrefix,\n\t);\n\n\tif (seed) {\n\t\tlog.step(\"Pushing schema to database\");\n\t\tawait seedDatabase(seed.path, directString);\n\t\tlog.success(\"Schema pushed to database\");\n\t}\n\n\treturn {\n\t\tdatabaseUrlDirect: directString,\n\t\tdatabaseUrl: poolerString,\n\t\tclaimUrl: claimUrl.href,\n\t\tclaimExpiresAt,\n\t} as const;\n};\n\n/**\n * @deprecated Use `instantPostgres` instead\n */\nexport const instantNeon = instantPostgres;\n\nexport type { InstantPostgresParams };\n\n/**\n * @deprecated Use `InstantPostgresParams` instead\n */\nexport type InstantNeonParams = InstantPostgresParams;\n"],"mappings":";;;;;;;;;;;;;;;;AAgBA,MAAa,kBAAkB,OAAO,EACrC,aAAa,QACb,YAAY,gBACZ,UACA,OAAO,QACP,YAAY,WACZ,UAAU,EAAE,qBAAqB,UAAU,EAAE,OAMxC;AACL,KAAI,CAAC,YAAY,SAAS,MAAM,KAAK,IAAI;EACxC,MAAM,EAAE,SAAS,GAAG,UAAU,SAAS,OAAO;AAE9C,QAAM,IAAI,MAAM,SAAS,EACxB,OACA,CAAC;;CAGH,MAAM,OAAO,YAAY;CACzB,MAAM,iBAAiB,IAAI,KAAK,KAAK,KAAK,GAAG,OAAc,KAAK,IAAK;CACrE,MAAM,WAAW,IAAI,IAAI,wBAAwB,eAAe,KAAK,CAAC;CAOtE,MAAM,EAAE,QAAQ,cAAc,QAAQ,iBACrC,qBANkB,MAAM,wBAAwB;EAChD;EACA,UAAU,cAAc;EACxB,UAAU,EAAE,oBAAoB;EAChC,CAAC,CAE+B;AAEjC,OAAM,WACL,YACA,WACA,gBACA,UACA,cACA,cACA,UACA;AAED,KAAI,MAAM;AACT,MAAI,KAAK,6BAA6B;AACtC,QAAM,aAAa,KAAK,MAAM,aAAa;AAC3C,MAAI,QAAQ,4BAA4B;;AAGzC,QAAO;EACN,mBAAmB;EACnB,aAAa;EACb,UAAU,SAAS;EACnB;EACA;;;;;AAMF,MAAa,cAAc"} |
@@ -34,3 +34,3 @@ //#region src/lib/texts.d.ts | ||
| readonly message: "referrer parameter is required"; | ||
| readonly description: "The referrer helps track usage for the Instagres Affiliates Program"; | ||
| readonly description: "The referrer helps track usage for the Open Source Program"; | ||
| readonly hint: "instantPostgres({ referrer: 'your-app-name' })"; | ||
@@ -37,0 +37,0 @@ readonly docs: "For more information, visit: https://neon.com/docs/reference/instagres"; |
@@ -42,3 +42,3 @@ import { DEFAULTS } from "./utils/args.js"; | ||
| message: "referrer parameter is required", | ||
| description: "The referrer helps track usage for the Instagres Affiliates Program", | ||
| description: "The referrer helps track usage for the Open Source Program", | ||
| hint: "instantPostgres({ referrer: 'your-app-name' })", | ||
@@ -45,0 +45,0 @@ docs: "For more information, visit: https://neon.com/docs/reference/instagres" |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"texts.js","names":[],"sources":["../../src/lib/texts.ts"],"sourcesContent":["import { bgBlack, bold, greenBright } from \"yoctocolors\";\nimport { DEFAULTS } from \"./utils/args.js\";\n\nexport const INTRO_ART = `\n\n\n ▟████████████▙\n ██ ██\n ██ ▗▅▖ ██ https://neon.com\n ██ ████▙ ██ ├── /docs\n ██ ██ ▜████ └── /discord\n ██ ██ ▜█▛\n ▜██████▛\n\n\n`;\n\nexport const messages = {\n\t/**\n\t * these messages must be short and concise\n\t * exceeding 2 lines trigger a rendering issue\n\t * in @clack/prompts\n\t *\n\t * @see https://github.com/bombshell-dev/clack/issues/132\n\t */\n\twelcome: `Let's get you set with a Postgres database on ${bgBlack(greenBright(bold(\" Neon \")))}.`,\n\tnonInteractive: \"`get-db --yes` for non-interactive flow with defaults.\",\n\tgenerating: \"Generating your database... \",\n\tenvKeyExistsExit:\n\t\t\"Please try again or select a different key for your connection string.\",\n\tquestions: {\n\t\tdotEnvFilePath: `Enter the path to your environment file (default: ${DEFAULTS.dotEnvPath})`,\n\t\tdotEnvKey: `Enter the key for the database connection string (default: ${DEFAULTS.dotEnvKey})`,\n\t\tseedPath: `Enter the path to your seed (.sql) file (default: ${\n\t\t\tDEFAULTS.seed?.path || \"none\"\n\t\t})`,\n\t\tprefix: `Enter the prefix for public environment variables (default: ${DEFAULTS.envPrefix})`,\n\t},\n\tinfo: {\n\t\tdotEnvFileNotFound: \"No .env file found, creating one.\",\n\t\tuserCancelled: \"Prompt cancelled by user.\",\n\t\tdefaultEnvKey: (dotEnvKey: string) =>\n\t\t\t`using ${dotEnvKey} as the environment variable key`,\n\t\tdefaultEnvFilePath: (dotEnvPath: string) =>\n\t\t\t`using ${dotEnvPath} as the .env file`,\n\t\tdefaultPrefix: (prefix: string) =>\n\t\t\t`using ${prefix} as the prefix for public environment variables`,\n\t},\n\n\terrors: {\n\t\tinvalidEnvFile: \"Invalid .env file format \\n\",\n\t\tenvKeyExists: (dotEnvKey: string, dotEnvFile: string) =>\n\t\t\t`${dotEnvKey} already exists in ${dotEnvFile}`,\n\t\tfailedToParseEnvFile: \"Failed to parse .env file\",\n\t\treferrerIsRequired: {\n\t\t\tmessage: \"referrer parameter is required\",\n\t\t\tdescription:\n\t\t\t\t\"The referrer helps track usage for the Instagres Affiliates Program\",\n\t\t\thint: \"instantPostgres({ referrer: 'your-app-name' })\",\n\t\t\tdocs: \"For more information, visit: https://neon.com/docs/reference/instagres\",\n\t\t},\n\t},\n} as const;\n"],"mappings":";;;;AAGA,MAAa,YAAY;;;;;;;;;;;;;AAczB,MAAa,WAAW;CAQvB,SAAS,iDAAiD,QAAQ,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC;CAC/F,gBAAgB;CAChB,YAAY;CACZ,kBACC;CACD,WAAW;EACV,gBAAgB,qDAAqD,SAAS,WAAW;EACzF,WAAW,8DAA8D,SAAS,UAAU;EAC5F,UAAU,qDACT,SAAS,MAAM,QAAQ,OACvB;EACD,QAAQ,+DAA+D,SAAS,UAAU;EAC1F;CACD,MAAM;EACL,oBAAoB;EACpB,eAAe;EACf,gBAAgB,cACf,SAAS,UAAU;EACpB,qBAAqB,eACpB,SAAS,WAAW;EACrB,gBAAgB,WACf,SAAS,OAAO;EACjB;CAED,QAAQ;EACP,gBAAgB;EAChB,eAAe,WAAmB,eACjC,GAAG,UAAU,qBAAqB;EACnC,sBAAsB;EACtB,oBAAoB;GACnB,SAAS;GACT,aACC;GACD,MAAM;GACN,MAAM;GACN;EACD;CACD"} | ||
| {"version":3,"file":"texts.js","names":[],"sources":["../../src/lib/texts.ts"],"sourcesContent":["import { bgBlack, bold, greenBright } from \"yoctocolors\";\nimport { DEFAULTS } from \"./utils/args.js\";\n\nexport const INTRO_ART = `\n\n\n ▟████████████▙\n ██ ██\n ██ ▗▅▖ ██ https://neon.com\n ██ ████▙ ██ ├── /docs\n ██ ██ ▜████ └── /discord\n ██ ██ ▜█▛\n ▜██████▛\n\n\n`;\n\nexport const messages = {\n\t/**\n\t * these messages must be short and concise\n\t * exceeding 2 lines trigger a rendering issue\n\t * in @clack/prompts\n\t *\n\t * @see https://github.com/bombshell-dev/clack/issues/132\n\t */\n\twelcome: `Let's get you set with a Postgres database on ${bgBlack(greenBright(bold(\" Neon \")))}.`,\n\tnonInteractive: \"`get-db --yes` for non-interactive flow with defaults.\",\n\tgenerating: \"Generating your database... \",\n\tenvKeyExistsExit:\n\t\t\"Please try again or select a different key for your connection string.\",\n\tquestions: {\n\t\tdotEnvFilePath: `Enter the path to your environment file (default: ${DEFAULTS.dotEnvPath})`,\n\t\tdotEnvKey: `Enter the key for the database connection string (default: ${DEFAULTS.dotEnvKey})`,\n\t\tseedPath: `Enter the path to your seed (.sql) file (default: ${\n\t\t\tDEFAULTS.seed?.path || \"none\"\n\t\t})`,\n\t\tprefix: `Enter the prefix for public environment variables (default: ${DEFAULTS.envPrefix})`,\n\t},\n\tinfo: {\n\t\tdotEnvFileNotFound: \"No .env file found, creating one.\",\n\t\tuserCancelled: \"Prompt cancelled by user.\",\n\t\tdefaultEnvKey: (dotEnvKey: string) =>\n\t\t\t`using ${dotEnvKey} as the environment variable key`,\n\t\tdefaultEnvFilePath: (dotEnvPath: string) =>\n\t\t\t`using ${dotEnvPath} as the .env file`,\n\t\tdefaultPrefix: (prefix: string) =>\n\t\t\t`using ${prefix} as the prefix for public environment variables`,\n\t},\n\n\terrors: {\n\t\tinvalidEnvFile: \"Invalid .env file format \\n\",\n\t\tenvKeyExists: (dotEnvKey: string, dotEnvFile: string) =>\n\t\t\t`${dotEnvKey} already exists in ${dotEnvFile}`,\n\t\tfailedToParseEnvFile: \"Failed to parse .env file\",\n\t\treferrerIsRequired: {\n\t\t\tmessage: \"referrer parameter is required\",\n\t\t\tdescription:\n\t\t\t\t\"The referrer helps track usage for the Open Source Program\",\n\t\t\thint: \"instantPostgres({ referrer: 'your-app-name' })\",\n\t\t\tdocs: \"For more information, visit: https://neon.com/docs/reference/instagres\",\n\t\t},\n\t},\n} as const;\n"],"mappings":";;;;AAGA,MAAa,YAAY;;;;;;;;;;;;;AAczB,MAAa,WAAW;CAQvB,SAAS,iDAAiD,QAAQ,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC;CAC/F,gBAAgB;CAChB,YAAY;CACZ,kBACC;CACD,WAAW;EACV,gBAAgB,qDAAqD,SAAS,WAAW;EACzF,WAAW,8DAA8D,SAAS,UAAU;EAC5F,UAAU,qDACT,SAAS,MAAM,QAAQ,OACvB;EACD,QAAQ,+DAA+D,SAAS,UAAU;EAC1F;CACD,MAAM;EACL,oBAAoB;EACpB,eAAe;EACf,gBAAgB,cACf,SAAS,UAAU;EACpB,qBAAqB,eACpB,SAAS,WAAW;EACrB,gBAAgB,WACf,SAAS,OAAO;EACjB;CAED,QAAQ;EACP,gBAAgB;EAChB,eAAe,WAAmB,eACjC,GAAG,UAAU,qBAAqB;EACnC,sBAAsB;EACtB,oBAAoB;GACnB,SAAS;GACT,aACC;GACD,MAAM;GACN,MAAM;GACN;EACD;CACD"} |
@@ -7,3 +7,3 @@ //#region src/lib/types.d.ts | ||
| /** | ||
| * Parameters for configuring Instagres database connection | ||
| * Parameters for configuring Postgres database connection | ||
| * @param {string} dotEnvFile - Path to the .env file where the connection string will be saved | ||
@@ -10,0 +10,0 @@ * @param {string} dotEnvKey - Environment variable name to store the connection string |
@@ -54,3 +54,3 @@ import { bold, underline } from "yoctocolors"; | ||
| defaultDescription: DEFAULTS.referrer | ||
| }).epilogue(`For more information: ${underline("https://instagres.com")}`).parseSync(); | ||
| }).epilogue(`For more information: ${underline("https://pg.new")}`).parseSync(); | ||
| const command = argv._[0]?.toString() || "create"; | ||
@@ -57,0 +57,0 @@ return { |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"args.js","names":[],"sources":["../../../src/lib/utils/args.ts"],"sourcesContent":["import yargs from \"yargs\";\nimport { hideBin } from \"yargs/helpers\";\nimport { bold, underline } from \"yoctocolors\";\nimport type { Defaults } from \"../types.js\";\n\nexport const DEFAULTS: Defaults = {\n\tdotEnvPath: \"./.env\",\n\tdotEnvKey: \"DATABASE_URL\",\n\tseed: undefined,\n\tenvPrefix: \"PUBLIC_\",\n\treferrer: \"npm:get-db/cli\",\n\tsettings: {\n\t\tlogicalReplication: false,\n\t},\n};\n\nexport interface ParsedArgs {\n\tyes?: boolean;\n\tenv?: string;\n\tkey?: string;\n\tseed?: string;\n\tprefix?: string;\n\tref?: string;\n\tlogicalReplication?: boolean;\n\thelp?: boolean;\n\tcommand: string;\n}\n\nexport function getArgs(): ParsedArgs | never {\n\tconst argv = yargs(hideBin(process.argv))\n\t\t.scriptName(\"get-db\")\n\t\t.usage(\"Usage: $0 [command] [options]\")\n\t\t.help()\n\t\t.version(false)\n\t\t.strict()\n\t\t.parserConfiguration({\n\t\t\t\"camel-case-expansion\": true,\n\t\t\t\"strip-aliased\": true,\n\t\t\t\"strip-dashed\": true,\n\t\t})\n\t\t.command(\"$0\", \"Create a new database (default command)\", {})\n\t\t.command(\"claim\", \"Open the claim URL from your .env file\", {})\n\t\t.group(\"logical-replication\", bold(\"Postgres Settings:\"))\n\t\t.option(\"logical-replication\", {\n\t\t\talias: \"L\",\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Enable logical replication\",\n\t\t\tdefault: false,\n\t\t})\n\t\t.option(\"yes\", {\n\t\t\talias: \"y\",\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Skip prompts / use defaults\",\n\t\t\tdefault: false,\n\t\t})\n\t\t.option(\"env\", {\n\t\t\talias: \"e\",\n\t\t\ttype: \"string\",\n\t\t\tdescription: \".env file path\",\n\t\t\tdefaultDescription: DEFAULTS.dotEnvPath,\n\t\t})\n\t\t.option(\"key\", {\n\t\t\talias: \"k\",\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"connection string key\",\n\t\t\tdefaultDescription: DEFAULTS.dotEnvKey,\n\t\t})\n\t\t.option(\"seed\", {\n\t\t\talias: \"s\",\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Path to the seed (.sql) file\",\n\t\t\tdefaultDescription: DEFAULTS.seed?.path || \"none\",\n\t\t})\n\t\t.option(\"prefix\", {\n\t\t\talias: \"p\",\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Public env_var prefix\",\n\t\t\tdefaultDescription: DEFAULTS.envPrefix,\n\t\t})\n\t\t.option(\"ref\", {\n\t\t\talias: \"r\",\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Referrer id\",\n\t\t\tdefaultDescription: DEFAULTS.referrer,\n\t\t})\n\t\t.epilogue(`For more information: ${underline(\"https://instagres.com\")}`)\n\t\t.parseSync();\n\n\tconst command = argv._[0]?.toString() || \"create\";\n\n\treturn {\n\t\tyes: argv.yes,\n\t\tenv: argv.env,\n\t\tkey: argv.key,\n\t\tseed: argv.seed,\n\t\tprefix: argv.prefix,\n\t\tref: argv.ref,\n\t\tlogicalReplication: argv.logicalReplication,\n\t\tcommand,\n\t};\n}\n"],"mappings":";;;;;AAKA,MAAa,WAAqB;CACjC,YAAY;CACZ,WAAW;CACX,MAAM;CACN,WAAW;CACX,UAAU;CACV,UAAU,EACT,oBAAoB,OACpB;CACD;AAcD,SAAgB,UAA8B;CAC7C,MAAM,OAAO,MAAM,QAAQ,QAAQ,KAAK,CAAC,CACvC,WAAW,SAAS,CACpB,MAAM,gCAAgC,CACtC,MAAM,CACN,QAAQ,MAAM,CACd,QAAQ,CACR,oBAAoB;EACpB,wBAAwB;EACxB,iBAAiB;EACjB,gBAAgB;EAChB,CAAC,CACD,QAAQ,MAAM,2CAA2C,EAAE,CAAC,CAC5D,QAAQ,SAAS,0CAA0C,EAAE,CAAC,CAC9D,MAAM,uBAAuB,KAAK,qBAAqB,CAAC,CACxD,OAAO,uBAAuB;EAC9B,OAAO;EACP,MAAM;EACN,aAAa;EACb,SAAS;EACT,CAAC,CACD,OAAO,OAAO;EACd,OAAO;EACP,MAAM;EACN,aAAa;EACb,SAAS;EACT,CAAC,CACD,OAAO,OAAO;EACd,OAAO;EACP,MAAM;EACN,aAAa;EACb,oBAAoB,SAAS;EAC7B,CAAC,CACD,OAAO,OAAO;EACd,OAAO;EACP,MAAM;EACN,aAAa;EACb,oBAAoB,SAAS;EAC7B,CAAC,CACD,OAAO,QAAQ;EACf,OAAO;EACP,MAAM;EACN,aAAa;EACb,oBAAoB,SAAS,MAAM,QAAQ;EAC3C,CAAC,CACD,OAAO,UAAU;EACjB,OAAO;EACP,MAAM;EACN,aAAa;EACb,oBAAoB,SAAS;EAC7B,CAAC,CACD,OAAO,OAAO;EACd,OAAO;EACP,MAAM;EACN,aAAa;EACb,oBAAoB,SAAS;EAC7B,CAAC,CACD,SAAS,yBAAyB,UAAU,wBAAwB,GAAG,CACvE,WAAW;CAEb,MAAM,UAAU,KAAK,EAAE,IAAI,UAAU,IAAI;AAEzC,QAAO;EACN,KAAK,KAAK;EACV,KAAK,KAAK;EACV,KAAK,KAAK;EACV,MAAM,KAAK;EACX,QAAQ,KAAK;EACb,KAAK,KAAK;EACV,oBAAoB,KAAK;EACzB;EACA"} | ||
| {"version":3,"file":"args.js","names":[],"sources":["../../../src/lib/utils/args.ts"],"sourcesContent":["import yargs from \"yargs\";\nimport { hideBin } from \"yargs/helpers\";\nimport { bold, underline } from \"yoctocolors\";\nimport type { Defaults } from \"../types.js\";\n\nexport const DEFAULTS: Defaults = {\n\tdotEnvPath: \"./.env\",\n\tdotEnvKey: \"DATABASE_URL\",\n\tseed: undefined,\n\tenvPrefix: \"PUBLIC_\",\n\treferrer: \"npm:get-db/cli\",\n\tsettings: {\n\t\tlogicalReplication: false,\n\t},\n};\n\nexport interface ParsedArgs {\n\tyes?: boolean;\n\tenv?: string;\n\tkey?: string;\n\tseed?: string;\n\tprefix?: string;\n\tref?: string;\n\tlogicalReplication?: boolean;\n\thelp?: boolean;\n\tcommand: string;\n}\n\nexport function getArgs(): ParsedArgs | never {\n\tconst argv = yargs(hideBin(process.argv))\n\t\t.scriptName(\"get-db\")\n\t\t.usage(\"Usage: $0 [command] [options]\")\n\t\t.help()\n\t\t.version(false)\n\t\t.strict()\n\t\t.parserConfiguration({\n\t\t\t\"camel-case-expansion\": true,\n\t\t\t\"strip-aliased\": true,\n\t\t\t\"strip-dashed\": true,\n\t\t})\n\t\t.command(\"$0\", \"Create a new database (default command)\", {})\n\t\t.command(\"claim\", \"Open the claim URL from your .env file\", {})\n\t\t.group(\"logical-replication\", bold(\"Postgres Settings:\"))\n\t\t.option(\"logical-replication\", {\n\t\t\talias: \"L\",\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Enable logical replication\",\n\t\t\tdefault: false,\n\t\t})\n\t\t.option(\"yes\", {\n\t\t\talias: \"y\",\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Skip prompts / use defaults\",\n\t\t\tdefault: false,\n\t\t})\n\t\t.option(\"env\", {\n\t\t\talias: \"e\",\n\t\t\ttype: \"string\",\n\t\t\tdescription: \".env file path\",\n\t\t\tdefaultDescription: DEFAULTS.dotEnvPath,\n\t\t})\n\t\t.option(\"key\", {\n\t\t\talias: \"k\",\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"connection string key\",\n\t\t\tdefaultDescription: DEFAULTS.dotEnvKey,\n\t\t})\n\t\t.option(\"seed\", {\n\t\t\talias: \"s\",\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Path to the seed (.sql) file\",\n\t\t\tdefaultDescription: DEFAULTS.seed?.path || \"none\",\n\t\t})\n\t\t.option(\"prefix\", {\n\t\t\talias: \"p\",\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Public env_var prefix\",\n\t\t\tdefaultDescription: DEFAULTS.envPrefix,\n\t\t})\n\t\t.option(\"ref\", {\n\t\t\talias: \"r\",\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Referrer id\",\n\t\t\tdefaultDescription: DEFAULTS.referrer,\n\t\t})\n\t\t.epilogue(`For more information: ${underline(\"https://pg.new\")}`)\n\t\t.parseSync();\n\n\tconst command = argv._[0]?.toString() || \"create\";\n\n\treturn {\n\t\tyes: argv.yes,\n\t\tenv: argv.env,\n\t\tkey: argv.key,\n\t\tseed: argv.seed,\n\t\tprefix: argv.prefix,\n\t\tref: argv.ref,\n\t\tlogicalReplication: argv.logicalReplication,\n\t\tcommand,\n\t};\n}\n"],"mappings":";;;;;AAKA,MAAa,WAAqB;CACjC,YAAY;CACZ,WAAW;CACX,MAAM;CACN,WAAW;CACX,UAAU;CACV,UAAU,EACT,oBAAoB,OACpB;CACD;AAcD,SAAgB,UAA8B;CAC7C,MAAM,OAAO,MAAM,QAAQ,QAAQ,KAAK,CAAC,CACvC,WAAW,SAAS,CACpB,MAAM,gCAAgC,CACtC,MAAM,CACN,QAAQ,MAAM,CACd,QAAQ,CACR,oBAAoB;EACpB,wBAAwB;EACxB,iBAAiB;EACjB,gBAAgB;EAChB,CAAC,CACD,QAAQ,MAAM,2CAA2C,EAAE,CAAC,CAC5D,QAAQ,SAAS,0CAA0C,EAAE,CAAC,CAC9D,MAAM,uBAAuB,KAAK,qBAAqB,CAAC,CACxD,OAAO,uBAAuB;EAC9B,OAAO;EACP,MAAM;EACN,aAAa;EACb,SAAS;EACT,CAAC,CACD,OAAO,OAAO;EACd,OAAO;EACP,MAAM;EACN,aAAa;EACb,SAAS;EACT,CAAC,CACD,OAAO,OAAO;EACd,OAAO;EACP,MAAM;EACN,aAAa;EACb,oBAAoB,SAAS;EAC7B,CAAC,CACD,OAAO,OAAO;EACd,OAAO;EACP,MAAM;EACN,aAAa;EACb,oBAAoB,SAAS;EAC7B,CAAC,CACD,OAAO,QAAQ;EACf,OAAO;EACP,MAAM;EACN,aAAa;EACb,oBAAoB,SAAS,MAAM,QAAQ;EAC3C,CAAC,CACD,OAAO,UAAU;EACjB,OAAO;EACP,MAAM;EACN,aAAa;EACb,oBAAoB,SAAS;EAC7B,CAAC,CACD,OAAO,OAAO;EACd,OAAO;EACP,MAAM;EACN,aAAa;EACb,oBAAoB,SAAS;EAC7B,CAAC,CACD,SAAS,yBAAyB,UAAU,iBAAiB,GAAG,CAChE,WAAW;CAEb,MAAM,UAAU,KAAK,EAAE,IAAI,UAAU,IAAI;AAEzC,QAAO;EACN,KAAK,KAAK;EACV,KAAK,KAAK;EACV,KAAK,KAAK;EACV,MAAM,KAAK;EACX,QAAQ,KAAK;EACb,KAAK,KAAK;EACV,oBAAoB,KAAK;EACzB;EACA"} |
@@ -1,2 +0,2 @@ | ||
| import { INSTAGRES_URLS } from "./urls.js"; | ||
| import { CLAIMABLE_POSTGRES_URLS } from "./urls.js"; | ||
@@ -6,3 +6,3 @@ //#region src/lib/utils/create-db.ts | ||
| const { logicalReplication = false } = settings; | ||
| if (!(await fetch(INSTAGRES_URLS.CREATE_DATABASE_POST(dbId, referrer), { | ||
| if (!(await fetch(CLAIMABLE_POSTGRES_URLS.CREATE_DATABASE_POST(dbId, referrer), { | ||
| method: "POST", | ||
@@ -12,3 +12,3 @@ headers: { "Content-Type": "application/json" }, | ||
| })).ok) throw new Error("Failed to create database"); | ||
| return (await fetch(INSTAGRES_URLS.GET_DATABASE_DATA(dbId), { | ||
| return (await fetch(CLAIMABLE_POSTGRES_URLS.GET_DATABASE_DATA(dbId), { | ||
| method: "GET", | ||
@@ -15,0 +15,0 @@ headers: { "Content-Type": "application/json" } |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"create-db.js","names":[],"sources":["../../../src/lib/utils/create-db.ts"],"sourcesContent":["import { INSTAGRES_URLS } from \"./urls.js\";\n\ninterface CreateClaimableDBParams {\n\tdbId: string;\n\treferrer: string;\n\tsettings?: {\n\t\tlogicalReplication?: boolean;\n\t};\n}\n\nexport async function createClaimableDatabase({\n\tdbId,\n\treferrer,\n\tsettings = {},\n}: CreateClaimableDBParams) {\n\tconst { logicalReplication = false } = settings;\n\n\tconst dbCreation = await fetch(\n\t\tINSTAGRES_URLS.CREATE_DATABASE_POST(dbId, referrer),\n\t\t{\n\t\t\tmethod: \"POST\",\n\t\t\theaders: {\n\t\t\t\t\"Content-Type\": \"application/json\",\n\t\t\t},\n\t\t\tbody: JSON.stringify({\n\t\t\t\tenable_logical_replication: logicalReplication || false,\n\t\t\t}),\n\t\t},\n\t);\n\n\tif (!dbCreation.ok) {\n\t\tthrow new Error(\"Failed to create database\");\n\t}\n\n\tconst dbInfo: { connection_string: string } = await fetch(\n\t\tINSTAGRES_URLS.GET_DATABASE_DATA(dbId),\n\t\t{\n\t\t\tmethod: \"GET\",\n\t\t\theaders: {\n\t\t\t\t\"Content-Type\": \"application/json\",\n\t\t\t},\n\t\t},\n\t).then((res) => res.json());\n\n\treturn dbInfo.connection_string;\n}\n"],"mappings":";;;AAUA,eAAsB,wBAAwB,EAC7C,MACA,UACA,WAAW,EAAE,IACc;CAC3B,MAAM,EAAE,qBAAqB,UAAU;AAevC,KAAI,EAbe,MAAM,MACxB,eAAe,qBAAqB,MAAM,SAAS,EACnD;EACC,QAAQ;EACR,SAAS,EACR,gBAAgB,oBAChB;EACD,MAAM,KAAK,UAAU,EACpB,4BAA4B,sBAAsB,OAClD,CAAC;EACF,CACD,EAEe,GACf,OAAM,IAAI,MAAM,4BAA4B;AAa7C,SAV8C,MAAM,MACnD,eAAe,kBAAkB,KAAK,EACtC;EACC,QAAQ;EACR,SAAS,EACR,gBAAgB,oBAChB;EACD,CACD,CAAC,MAAM,QAAQ,IAAI,MAAM,CAAC,EAEb"} | ||
| {"version":3,"file":"create-db.js","names":[],"sources":["../../../src/lib/utils/create-db.ts"],"sourcesContent":["import { CLAIMABLE_POSTGRES_URLS } from \"./urls.js\";\n\ninterface CreateClaimableDBParams {\n\tdbId: string;\n\treferrer: string;\n\tsettings?: {\n\t\tlogicalReplication?: boolean;\n\t};\n}\n\nexport async function createClaimableDatabase({\n\tdbId,\n\treferrer,\n\tsettings = {},\n}: CreateClaimableDBParams) {\n\tconst { logicalReplication = false } = settings;\n\n\tconst dbCreation = await fetch(\n\t\tCLAIMABLE_POSTGRES_URLS.CREATE_DATABASE_POST(dbId, referrer),\n\t\t{\n\t\t\tmethod: \"POST\",\n\t\t\theaders: {\n\t\t\t\t\"Content-Type\": \"application/json\",\n\t\t\t},\n\t\t\tbody: JSON.stringify({\n\t\t\t\tenable_logical_replication: logicalReplication || false,\n\t\t\t}),\n\t\t},\n\t);\n\n\tif (!dbCreation.ok) {\n\t\tthrow new Error(\"Failed to create database\");\n\t}\n\n\tconst dbInfo: { connection_string: string } = await fetch(\n\t\tCLAIMABLE_POSTGRES_URLS.GET_DATABASE_DATA(dbId),\n\t\t{\n\t\t\tmethod: \"GET\",\n\t\t\theaders: {\n\t\t\t\t\"Content-Type\": \"application/json\",\n\t\t\t},\n\t\t},\n\t).then((res) => res.json());\n\n\treturn dbInfo.connection_string;\n}\n"],"mappings":";;;AAUA,eAAsB,wBAAwB,EAC7C,MACA,UACA,WAAW,EAAE,IACc;CAC3B,MAAM,EAAE,qBAAqB,UAAU;AAevC,KAAI,EAbe,MAAM,MACxB,wBAAwB,qBAAqB,MAAM,SAAS,EAC5D;EACC,QAAQ;EACR,SAAS,EACR,gBAAgB,oBAChB;EACD,MAAM,KAAK,UAAU,EACpB,4BAA4B,sBAAsB,OAClD,CAAC;EACF,CACD,EAEe,GACf,OAAM,IAAI,MAAM,4BAA4B;AAa7C,SAV8C,MAAM,MACnD,wBAAwB,kBAAkB,KAAK,EAC/C;EACC,QAAQ;EACR,SAAS,EACR,gBAAgB,oBAChB;EACD,CACD,CAAC,MAAM,QAAQ,IAAI,MAAM,CAAC,EAEb"} |
@@ -5,6 +5,6 @@ import { log, outro } from "@clack/prompts"; | ||
| function detectClaimUrl(dotEnvContent, dotEnvPath) { | ||
| const claimUrlKey = Object.keys(dotEnvContent).find((key) => key.endsWith("INSTAGRES_CLAIM_URL")); | ||
| const claimUrlKey = Object.keys(dotEnvContent).find((key) => key.endsWith("POSTGRES_CLAIM_URL")); | ||
| if (!claimUrlKey) { | ||
| log.error(`Claim URL not found in ${dotEnvPath}.`); | ||
| log.info("Looking for any key ending with INSTAGRES_CLAIM_URL"); | ||
| log.info("Looking for any key ending with POSTGRES_CLAIM_URL"); | ||
| outro("No claim URL found. Have you created a database yet?"); | ||
@@ -16,3 +16,3 @@ process.exit(1); | ||
| log.error(`${claimUrlKey} found but empty.`); | ||
| outro("Use `get-db claim -p <prefix>` to override URL auto-detection. For example, use `get-db claim -p PROD_` if your key is `PROD_INSTAGRES_CLAIM_URL`."); | ||
| outro("Use `get-db claim -p <prefix>` to override URL auto-detection. For example, use `get-db claim -p PROD_` if your key is `PROD_POSTGRES_CLAIM_URL`."); | ||
| process.exit(1); | ||
@@ -19,0 +19,0 @@ } |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"detect-claim-url.js","names":[],"sources":["../../../src/lib/utils/detect-claim-url.ts"],"sourcesContent":["import { log, outro } from \"@clack/prompts\";\n\nexport function detectClaimUrl(\n\tdotEnvContent: Record<string, string>,\n\tdotEnvPath: string,\n) {\n\tconst claimUrlKey = Object.keys(dotEnvContent).find((key) =>\n\t\tkey.endsWith(\"INSTAGRES_CLAIM_URL\"),\n\t);\n\n\tif (!claimUrlKey) {\n\t\tlog.error(`Claim URL not found in ${dotEnvPath}.`);\n\t\tlog.info(\"Looking for any key ending with INSTAGRES_CLAIM_URL\");\n\t\toutro(\"No claim URL found. Have you created a database yet?\");\n\t\tprocess.exit(1);\n\t}\n\n\tconst claimUrl = dotEnvContent[claimUrlKey];\n\n\tif (!claimUrl) {\n\t\tlog.error(`${claimUrlKey} found but empty.`);\n\t\toutro(\n\t\t\t\"Use `get-db claim -p <prefix>` to override URL auto-detection. For example, use `get-db claim -p PROD_` if your key is `PROD_INSTAGRES_CLAIM_URL`.\",\n\t\t);\n\t\tprocess.exit(1);\n\t}\n\n\treturn claimUrl;\n}\n"],"mappings":";;;AAEA,SAAgB,eACf,eACA,YACC;CACD,MAAM,cAAc,OAAO,KAAK,cAAc,CAAC,MAAM,QACpD,IAAI,SAAS,sBAAsB,CACnC;AAED,KAAI,CAAC,aAAa;AACjB,MAAI,MAAM,0BAA0B,WAAW,GAAG;AAClD,MAAI,KAAK,sDAAsD;AAC/D,QAAM,uDAAuD;AAC7D,UAAQ,KAAK,EAAE;;CAGhB,MAAM,WAAW,cAAc;AAE/B,KAAI,CAAC,UAAU;AACd,MAAI,MAAM,GAAG,YAAY,mBAAmB;AAC5C,QACC,qJACA;AACD,UAAQ,KAAK,EAAE;;AAGhB,QAAO"} | ||
| {"version":3,"file":"detect-claim-url.js","names":[],"sources":["../../../src/lib/utils/detect-claim-url.ts"],"sourcesContent":["import { log, outro } from \"@clack/prompts\";\n\nexport function detectClaimUrl(\n\tdotEnvContent: Record<string, string>,\n\tdotEnvPath: string,\n) {\n\tconst claimUrlKey = Object.keys(dotEnvContent).find((key) =>\n\t\tkey.endsWith(\"POSTGRES_CLAIM_URL\"),\n\t);\n\n\tif (!claimUrlKey) {\n\t\tlog.error(`Claim URL not found in ${dotEnvPath}.`);\n\t\tlog.info(\"Looking for any key ending with POSTGRES_CLAIM_URL\");\n\t\toutro(\"No claim URL found. Have you created a database yet?\");\n\t\tprocess.exit(1);\n\t}\n\n\tconst claimUrl = dotEnvContent[claimUrlKey];\n\n\tif (!claimUrl) {\n\t\tlog.error(`${claimUrlKey} found but empty.`);\n\t\toutro(\n\t\t\t\"Use `get-db claim -p <prefix>` to override URL auto-detection. For example, use `get-db claim -p PROD_` if your key is `PROD_POSTGRES_CLAIM_URL`.\",\n\t\t);\n\t\tprocess.exit(1);\n\t}\n\n\treturn claimUrl;\n}\n"],"mappings":";;;AAEA,SAAgB,eACf,eACA,YACC;CACD,MAAM,cAAc,OAAO,KAAK,cAAc,CAAC,MAAM,QACpD,IAAI,SAAS,qBAAqB,CAClC;AAED,KAAI,CAAC,aAAa;AACjB,MAAI,MAAM,0BAA0B,WAAW,GAAG;AAClD,MAAI,KAAK,qDAAqD;AAC9D,QAAM,uDAAuD;AAC7D,UAAQ,KAAK,EAAE;;CAGhB,MAAM,WAAW,cAAc;AAE/B,KAAI,CAAC,UAAU;AACd,MAAI,MAAM,GAAG,YAAY,mBAAmB;AAC5C,QACC,oJACA;AACD,UAAQ,KAAK,EAAE;;AAGhB,QAAO"} |
| //#region src/lib/utils/fs.d.ts | ||
| declare function splitCommands(schema: string): string[]; | ||
| declare function getSqlCommands(path: string): string[]; | ||
@@ -7,3 +8,3 @@ declare function getDotEnvContent(dotEnvFile: string): Record<string, string>; | ||
| //#endregion | ||
| export { getDotEnvContent, getSqlCommands, prepEnv, writeToEnv }; | ||
| export { getDotEnvContent, getSqlCommands, prepEnv, splitCommands, writeToEnv }; | ||
| //# sourceMappingURL=fs.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"fs.d.ts","names":[],"sources":["../../../src/lib/utils/fs.ts"],"sourcesContent":[],"mappings":";iBA8BgB,cAAA;AAAA,iBAYA,gBAAA,CAZc,UAAA,EAAA,MAAA,CAAA,EAYwB,MAZxB,CAAA,MAAA,EAAA,MAAA,CAAA;AAYd,iBAcA,OAAA,CAdgB,UAA4B,EAAA,MAAA,EAAA,SAAA,EAAA,MAAA,CAAA,EAAA,IAAA;AAc5C,iBA0BM,UAAA,CA1BC,UAAA,EAAA,MAAA,EAAA,SAAA,EAAA,MAAA,EAAA,cAAA,EA6BN,IA7BM,EAAA,QAAA,EA8BZ,GA9BY,EAAA,UAAA,EAAA,MAAA,EAAA,YAAA,EAAA,MAAA,EAAA,SAAA,CAAA,EAAA,MAAA,CAAA,EAiCO,OAjCP,CAAA,IAAA,CAAA"} | ||
| {"version":3,"file":"fs.d.ts","names":[],"sources":["../../../src/lib/utils/fs.ts"],"sourcesContent":[],"mappings":";iBAcgB,aAAA;AAAA,iBAeA,cAAA,CAfa,IAAA,EAAA,MAAA,CAAA,EAAA,MAAA,EAAA;AAeb,iBAYA,gBAAA,CAZc,UAAA,EAAA,MAAA,CAAA,EAYwB,MAZxB,CAAA,MAAA,EAAA,MAAA,CAAA;AAYd,iBAcA,OAAA,CAdgB,UAA4B,EAAA,MAAA,EAAA,SAAA,EAAA,MAAA,CAAA,EAAA,IAAA;AAc5C,iBA0BM,UAAA,CA1BC,UAAA,EAAA,MAAA,EAAA,SAAA,EAAA,MAAA,EAAA,cAAA,EA6BN,IA7BM,EAAA,QAAA,EA8BZ,GA9BY,EAAA,UAAA,EAAA,MAAA,EAAA,YAAA,EAAA,MAAA,EAAA,SAAA,CAAA,EAAA,MAAA,CAAA,EAiCO,OAjCP,CAAA,IAAA,CAAA"} |
@@ -6,6 +6,8 @@ import { messages } from "../texts.js"; | ||
| import { parse } from "dotenv"; | ||
| import * as semicolons from "postgres-semicolons"; | ||
| //#region src/lib/utils/fs.ts | ||
| function splitCommands(schema) { | ||
| return schema.split(";").map((cmd) => cmd.trim()).filter(Boolean); | ||
| const splits = semicolons.parseSplits(schema, true); | ||
| return semicolons.nonEmptyStatements(schema, splits.positions); | ||
| } | ||
@@ -58,3 +60,3 @@ function validateSql(sql) { | ||
| # Claim it now to your account using the link below: | ||
| ${envPrefix}INSTAGRES_CLAIM_URL=${claimUrl.href} | ||
| ${envPrefix}POSTGRES_CLAIM_URL=${claimUrl.href} | ||
| `); | ||
@@ -65,3 +67,3 @@ closeSync(openedFile); | ||
| //#endregion | ||
| export { getDotEnvContent, getSqlCommands, prepEnv, writeToEnv }; | ||
| export { getDotEnvContent, getSqlCommands, prepEnv, splitCommands, writeToEnv }; | ||
| //# sourceMappingURL=fs.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"fs.js","names":[],"sources":["../../../src/lib/utils/fs.ts"],"sourcesContent":["import {\n\tcloseSync,\n\texistsSync,\n\tmkdirSync,\n\topenSync,\n\treadFileSync,\n\twriteSync,\n} from \"node:fs\";\nimport { dirname } from \"node:path\";\nimport { log, outro } from \"@clack/prompts\";\nimport { parse } from \"dotenv\";\nimport { messages } from \"../texts.js\";\n\nfunction splitCommands(schema: string) {\n\treturn schema\n\t\t.split(\";\")\n\t\t.map((cmd) => cmd.trim())\n\t\t.filter(Boolean);\n}\n\nfunction validateSql(sql: string) {\n\tconst openParens = (sql.match(/\\(/g) || []).length;\n\tconst closeParens = (sql.match(/\\)/g) || []).length;\n\tif (openParens !== closeParens) {\n\t\tthrow new Error(\"SQL has unbalanced parentheses\");\n\t}\n\n\treturn sql;\n}\n\nexport function getSqlCommands(path: string) {\n\ttry {\n\t\tconst sql = validateSql(readFileSync(path, \"utf8\"));\n\t\treturn splitCommands(sql);\n\t} catch (error) {\n\t\tlog.error(\n\t\t\terror instanceof Error ? error.message : \"Failed to read SQL file.\",\n\t\t);\n\t\tprocess.exit(1);\n\t}\n}\n\nexport function getDotEnvContent(dotEnvFile: string): Record<string, string> {\n\tif (!existsSync(dotEnvFile)) {\n\t\tlog.info(messages.info.dotEnvFileNotFound);\n\t\treturn {};\n\t}\n\n\ttry {\n\t\tconst content = readFileSync(dotEnvFile);\n\t\treturn parse(content);\n\t} catch {\n\t\tthrow new Error(messages.errors.failedToParseEnvFile);\n\t}\n}\n\nexport function prepEnv(dotEnvFile: string, dotEnvKey: string) {\n\ttry {\n\t\tconst dotEnvContent = getDotEnvContent(dotEnvFile);\n\n\t\tif (dotEnvContent[dotEnvKey]) {\n\t\t\tlog.warn(messages.errors.envKeyExists(dotEnvKey, dotEnvFile));\n\t\t\toutro(messages.envKeyExistsExit);\n\t\t\tprocess.exit(0);\n\t\t}\n\n\t\treturn;\n\t} catch (error) {\n\t\t// getDotEnvContent will create empty file if it doesn't exist\n\t\t// or throw if parsing fails\n\t\tif (\n\t\t\terror instanceof Error &&\n\t\t\terror.message === messages.errors.failedToParseEnvFile\n\t\t) {\n\t\t\tconsole.error(error);\n\t\t\tlog.error(messages.errors.invalidEnvFile);\n\n\t\t\tprocess.exit(1);\n\t\t}\n\t}\n}\n\nexport async function writeToEnv(\n\tdotEnvFile: string,\n\tdotEnvKey: string,\n\tclaimExpiresAt: Date,\n\tclaimUrl: URL,\n\tconnString: string,\n\tpoolerString: string,\n\tenvPrefix: string = \"PUBLIC_\",\n) {\n\tif (!existsSync(dirname(dotEnvFile))) {\n\t\tmkdirSync(dirname(dotEnvFile), { recursive: true });\n\t}\n\n\tconst openedFile = openSync(dotEnvFile, \"a\");\n\twriteSync(\n\t\topenedFile,\n\t\t`${dotEnvKey}=${poolerString}\n${dotEnvKey}_DIRECT=${connString}\n# Claimable DB expires at: ${claimExpiresAt.toUTCString()}\n# Claim it now to your account using the link below:\n${envPrefix}INSTAGRES_CLAIM_URL=${claimUrl.href}\n`,\n\t);\n\tcloseSync(openedFile);\n}\n"],"mappings":";;;;;;;AAaA,SAAS,cAAc,QAAgB;AACtC,QAAO,OACL,MAAM,IAAI,CACV,KAAK,QAAQ,IAAI,MAAM,CAAC,CACxB,OAAO,QAAQ;;AAGlB,SAAS,YAAY,KAAa;AAGjC,MAFoB,IAAI,MAAM,MAAM,IAAI,EAAE,EAAE,YACvB,IAAI,MAAM,MAAM,IAAI,EAAE,EAAE,OAE5C,OAAM,IAAI,MAAM,iCAAiC;AAGlD,QAAO;;AAGR,SAAgB,eAAe,MAAc;AAC5C,KAAI;AAEH,SAAO,cADK,YAAY,aAAa,MAAM,OAAO,CAAC,CAC1B;UACjB,OAAO;AACf,MAAI,MACH,iBAAiB,QAAQ,MAAM,UAAU,2BACzC;AACD,UAAQ,KAAK,EAAE;;;AAIjB,SAAgB,iBAAiB,YAA4C;AAC5E,KAAI,CAAC,WAAW,WAAW,EAAE;AAC5B,MAAI,KAAK,SAAS,KAAK,mBAAmB;AAC1C,SAAO,EAAE;;AAGV,KAAI;AAEH,SAAO,MADS,aAAa,WAAW,CACnB;SACd;AACP,QAAM,IAAI,MAAM,SAAS,OAAO,qBAAqB;;;AAIvD,SAAgB,QAAQ,YAAoB,WAAmB;AAC9D,KAAI;AAGH,MAFsB,iBAAiB,WAAW,CAEhC,YAAY;AAC7B,OAAI,KAAK,SAAS,OAAO,aAAa,WAAW,WAAW,CAAC;AAC7D,SAAM,SAAS,iBAAiB;AAChC,WAAQ,KAAK,EAAE;;AAGhB;UACQ,OAAO;AAGf,MACC,iBAAiB,SACjB,MAAM,YAAY,SAAS,OAAO,sBACjC;AACD,WAAQ,MAAM,MAAM;AACpB,OAAI,MAAM,SAAS,OAAO,eAAe;AAEzC,WAAQ,KAAK,EAAE;;;;AAKlB,eAAsB,WACrB,YACA,WACA,gBACA,UACA,YACA,cACA,YAAoB,WACnB;AACD,KAAI,CAAC,WAAW,QAAQ,WAAW,CAAC,CACnC,WAAU,QAAQ,WAAW,EAAE,EAAE,WAAW,MAAM,CAAC;CAGpD,MAAM,aAAa,SAAS,YAAY,IAAI;AAC5C,WACC,YACA,GAAG,UAAU,GAAG,aAAa;EAC7B,UAAU,UAAU,WAAW;6BACJ,eAAe,aAAa,CAAC;;EAExD,UAAU,sBAAsB,SAAS,KAAK;EAE9C;AACD,WAAU,WAAW"} | ||
| {"version":3,"file":"fs.js","names":[],"sources":["../../../src/lib/utils/fs.ts"],"sourcesContent":["import {\n\tcloseSync,\n\texistsSync,\n\tmkdirSync,\n\topenSync,\n\treadFileSync,\n\twriteSync,\n} from \"node:fs\";\nimport { dirname } from \"node:path\";\nimport { log, outro } from \"@clack/prompts\";\nimport { parse } from \"dotenv\";\nimport * as semicolons from \"postgres-semicolons\";\nimport { messages } from \"../texts.js\";\n\nexport function splitCommands(schema: string) {\n\tconst splits = semicolons.parseSplits(schema, true);\n\treturn semicolons.nonEmptyStatements(schema, splits.positions);\n}\n\nfunction validateSql(sql: string) {\n\tconst openParens = (sql.match(/\\(/g) || []).length;\n\tconst closeParens = (sql.match(/\\)/g) || []).length;\n\tif (openParens !== closeParens) {\n\t\tthrow new Error(\"SQL has unbalanced parentheses\");\n\t}\n\n\treturn sql;\n}\n\nexport function getSqlCommands(path: string) {\n\ttry {\n\t\tconst sql = validateSql(readFileSync(path, \"utf8\"));\n\t\treturn splitCommands(sql);\n\t} catch (error) {\n\t\tlog.error(\n\t\t\terror instanceof Error ? error.message : \"Failed to read SQL file.\",\n\t\t);\n\t\tprocess.exit(1);\n\t}\n}\n\nexport function getDotEnvContent(dotEnvFile: string): Record<string, string> {\n\tif (!existsSync(dotEnvFile)) {\n\t\tlog.info(messages.info.dotEnvFileNotFound);\n\t\treturn {};\n\t}\n\n\ttry {\n\t\tconst content = readFileSync(dotEnvFile);\n\t\treturn parse(content);\n\t} catch {\n\t\tthrow new Error(messages.errors.failedToParseEnvFile);\n\t}\n}\n\nexport function prepEnv(dotEnvFile: string, dotEnvKey: string) {\n\ttry {\n\t\tconst dotEnvContent = getDotEnvContent(dotEnvFile);\n\n\t\tif (dotEnvContent[dotEnvKey]) {\n\t\t\tlog.warn(messages.errors.envKeyExists(dotEnvKey, dotEnvFile));\n\t\t\toutro(messages.envKeyExistsExit);\n\t\t\tprocess.exit(0);\n\t\t}\n\n\t\treturn;\n\t} catch (error) {\n\t\t// getDotEnvContent will create empty file if it doesn't exist\n\t\t// or throw if parsing fails\n\t\tif (\n\t\t\terror instanceof Error &&\n\t\t\terror.message === messages.errors.failedToParseEnvFile\n\t\t) {\n\t\t\tconsole.error(error);\n\t\t\tlog.error(messages.errors.invalidEnvFile);\n\n\t\t\tprocess.exit(1);\n\t\t}\n\t}\n}\n\nexport async function writeToEnv(\n\tdotEnvFile: string,\n\tdotEnvKey: string,\n\tclaimExpiresAt: Date,\n\tclaimUrl: URL,\n\tconnString: string,\n\tpoolerString: string,\n\tenvPrefix: string = \"PUBLIC_\",\n) {\n\tif (!existsSync(dirname(dotEnvFile))) {\n\t\tmkdirSync(dirname(dotEnvFile), { recursive: true });\n\t}\n\n\tconst openedFile = openSync(dotEnvFile, \"a\");\n\twriteSync(\n\t\topenedFile,\n\t\t`${dotEnvKey}=${poolerString}\n${dotEnvKey}_DIRECT=${connString}\n# Claimable DB expires at: ${claimExpiresAt.toUTCString()}\n# Claim it now to your account using the link below:\n${envPrefix}POSTGRES_CLAIM_URL=${claimUrl.href}\n`,\n\t);\n\tcloseSync(openedFile);\n}\n"],"mappings":";;;;;;;;AAcA,SAAgB,cAAc,QAAgB;CAC7C,MAAM,SAAS,WAAW,YAAY,QAAQ,KAAK;AACnD,QAAO,WAAW,mBAAmB,QAAQ,OAAO,UAAU;;AAG/D,SAAS,YAAY,KAAa;AAGjC,MAFoB,IAAI,MAAM,MAAM,IAAI,EAAE,EAAE,YACvB,IAAI,MAAM,MAAM,IAAI,EAAE,EAAE,OAE5C,OAAM,IAAI,MAAM,iCAAiC;AAGlD,QAAO;;AAGR,SAAgB,eAAe,MAAc;AAC5C,KAAI;AAEH,SAAO,cADK,YAAY,aAAa,MAAM,OAAO,CAAC,CAC1B;UACjB,OAAO;AACf,MAAI,MACH,iBAAiB,QAAQ,MAAM,UAAU,2BACzC;AACD,UAAQ,KAAK,EAAE;;;AAIjB,SAAgB,iBAAiB,YAA4C;AAC5E,KAAI,CAAC,WAAW,WAAW,EAAE;AAC5B,MAAI,KAAK,SAAS,KAAK,mBAAmB;AAC1C,SAAO,EAAE;;AAGV,KAAI;AAEH,SAAO,MADS,aAAa,WAAW,CACnB;SACd;AACP,QAAM,IAAI,MAAM,SAAS,OAAO,qBAAqB;;;AAIvD,SAAgB,QAAQ,YAAoB,WAAmB;AAC9D,KAAI;AAGH,MAFsB,iBAAiB,WAAW,CAEhC,YAAY;AAC7B,OAAI,KAAK,SAAS,OAAO,aAAa,WAAW,WAAW,CAAC;AAC7D,SAAM,SAAS,iBAAiB;AAChC,WAAQ,KAAK,EAAE;;AAGhB;UACQ,OAAO;AAGf,MACC,iBAAiB,SACjB,MAAM,YAAY,SAAS,OAAO,sBACjC;AACD,WAAQ,MAAM,MAAM;AACpB,OAAI,MAAM,SAAS,OAAO,eAAe;AAEzC,WAAQ,KAAK,EAAE;;;;AAKlB,eAAsB,WACrB,YACA,WACA,gBACA,UACA,YACA,cACA,YAAoB,WACnB;AACD,KAAI,CAAC,WAAW,QAAQ,WAAW,CAAC,CACnC,WAAU,QAAQ,WAAW,EAAE,EAAE,WAAW,MAAM,CAAC;CAGpD,MAAM,aAAa,SAAS,YAAY,IAAI;AAC5C,WACC,YACA,GAAG,UAAU,GAAG,aAAa;EAC7B,UAAU,UAAU,WAAW;6BACJ,eAAe,aAAa,CAAC;;EAExD,UAAU,qBAAqB,SAAS,KAAK;EAE7C;AACD,WAAU,WAAW"} |
| //#region src/lib/utils/urls.d.ts | ||
| declare const INSTAGRES_URLS: { | ||
| declare const CLAIMABLE_POSTGRES_URLS: { | ||
| GET_DATABASE_DATA: (dbId: string) => string; | ||
@@ -9,3 +9,3 @@ CREATE_CLAIMABLE_DATABASE: (dbId: string, referrer?: string) => string; | ||
| //#endregion | ||
| export { INSTAGRES_URLS }; | ||
| export { CLAIMABLE_POSTGRES_URLS }; | ||
| //# sourceMappingURL=urls.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"urls.d.ts","names":[],"sources":["../../../src/lib/utils/urls.ts"],"sourcesContent":[],"mappings":";cAEa;EAAA,iBASZ,EAAA,CAAA,IAAA,EAAA,MAAA,EAAA,GAAA,MAAA"} | ||
| {"version":3,"file":"urls.d.ts","names":[],"sources":["../../../src/lib/utils/urls.ts"],"sourcesContent":[],"mappings":";cAEa;EAAA,iBAAA,EAAA,CAAA,IAAA,EAWZ,MAAA,EAAA,GAAA,MAAA"} |
| //#region src/lib/utils/urls.ts | ||
| const HOST = "https://neon.new"; | ||
| const INSTAGRES_URLS = { | ||
| const HOST = "https://pg.new"; | ||
| const CLAIMABLE_POSTGRES_URLS = { | ||
| GET_DATABASE_DATA: (dbId) => `${HOST}/api/v1/database/${dbId}`, | ||
@@ -11,3 +11,3 @@ CREATE_CLAIMABLE_DATABASE: (dbId, referrer) => `${HOST}/db?uuid=${dbId}${referrer ? `&ref=${encodeURIComponent(referrer)}` : ""}`, | ||
| //#endregion | ||
| export { INSTAGRES_URLS }; | ||
| export { CLAIMABLE_POSTGRES_URLS }; | ||
| //# sourceMappingURL=urls.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"urls.js","names":[],"sources":["../../../src/lib/utils/urls.ts"],"sourcesContent":["const HOST = \"https://neon.new\";\n\nexport const INSTAGRES_URLS = {\n\tGET_DATABASE_DATA: (dbId: string) => `${HOST}/api/v1/database/${dbId}`,\n\tCREATE_CLAIMABLE_DATABASE: (dbId: string, referrer?: string) =>\n\t\t`${HOST}/db?uuid=${dbId}${referrer ? `&ref=${encodeURIComponent(referrer)}` : \"\"}`,\n\tCLAIM_DATABASE: (dbId: string) => `${HOST}/database/${dbId}`,\n\tCREATE_DATABASE_POST: (dbId: string, referrer?: string) =>\n\t\t`${HOST}/api/v1/database/${dbId}${\n\t\t\treferrer ? `?referrer=${encodeURIComponent(referrer)}` : \"\"\n\t\t}`,\n};\n"],"mappings":";AAAA,MAAM,OAAO;AAEb,MAAa,iBAAiB;CAC7B,oBAAoB,SAAiB,GAAG,KAAK,mBAAmB;CAChE,4BAA4B,MAAc,aACzC,GAAG,KAAK,WAAW,OAAO,WAAW,QAAQ,mBAAmB,SAAS,KAAK;CAC/E,iBAAiB,SAAiB,GAAG,KAAK,YAAY;CACtD,uBAAuB,MAAc,aACpC,GAAG,KAAK,mBAAmB,OAC1B,WAAW,aAAa,mBAAmB,SAAS,KAAK;CAE3D"} | ||
| {"version":3,"file":"urls.js","names":[],"sources":["../../../src/lib/utils/urls.ts"],"sourcesContent":["const HOST = \"https://pg.new\";\n\nexport const CLAIMABLE_POSTGRES_URLS = {\n\tGET_DATABASE_DATA: (dbId: string) => `${HOST}/api/v1/database/${dbId}`,\n\tCREATE_CLAIMABLE_DATABASE: (dbId: string, referrer?: string) =>\n\t\t`${HOST}/db?uuid=${dbId}${\n\t\t\treferrer ? `&ref=${encodeURIComponent(referrer)}` : \"\"\n\t\t}`,\n\tCLAIM_DATABASE: (dbId: string) => `${HOST}/database/${dbId}`,\n\tCREATE_DATABASE_POST: (dbId: string, referrer?: string) =>\n\t\t`${HOST}/api/v1/database/${dbId}${\n\t\t\treferrer ? `?referrer=${encodeURIComponent(referrer)}` : \"\"\n\t\t}`,\n};\n"],"mappings":";AAAA,MAAM,OAAO;AAEb,MAAa,0BAA0B;CACtC,oBAAoB,SAAiB,GAAG,KAAK,mBAAmB;CAChE,4BAA4B,MAAc,aACzC,GAAG,KAAK,WAAW,OAClB,WAAW,QAAQ,mBAAmB,SAAS,KAAK;CAEtD,iBAAiB,SAAiB,GAAG,KAAK,YAAY;CACtD,uBAAuB,MAAc,aACpC,GAAG,KAAK,mBAAmB,OAC1B,WAAW,aAAa,mBAAmB,SAAS,KAAK;CAE3D"} |
+2
-1
| { | ||
| "name": "get-db", | ||
| "version": "0.12.1", | ||
| "version": "0.13.0", | ||
| "description": "create a claimable Neon database in seconds!", | ||
@@ -68,2 +68,3 @@ "keywords": [ | ||
| "p-wait-for": "^5.0.2", | ||
| "postgres-semicolons": "^0.1.2", | ||
| "yargs": "^18.0.0", | ||
@@ -70,0 +71,0 @@ "yoctocolors": "^2.1.2" |
+1
-1
@@ -95,3 +95,3 @@ <h1 align="center">get-db</h1> | ||
| | `DATABASE_URL_DIRECT` | The direct connection string | | ||
| | `{envPrefix}INSTAGRES_CLAIM_URL` | Claim URL (valid for 7 days) to take ownership of the DB | | ||
| | `{envPrefix}POSTGRES_CLAIM_URL` | Claim URL (valid for 72 hours) to take ownership of the DB | | ||
@@ -98,0 +98,0 @@ > **Note:** The pooler connection is now the default for `DATABASE_URL` (as of the latest version). The pooler provides connection pooling and is recommended for most use cases, especially serverless environments. |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
78896
0.65%706
0.43%9
12.5%+ Added
+ Added