UNPKG

longcelot-sheet-db

Version:

Google Sheets-backed staging database adapter for Node.js with schema-first design

57 lines 2.56 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.TOKENS_FILENAME = exports.CONFIG_FILENAME = void 0; exports.resolveConfigPath = resolveConfigPath; exports.resolveTokensPath = resolveTokensPath; const fs_1 = __importDefault(require("fs")); const path_1 = __importDefault(require("path")); const chalk_1 = __importDefault(require("chalk")); exports.CONFIG_FILENAME = 'lsdb.config.ts'; exports.TOKENS_FILENAME = '.lsdb-tokens.json'; const LEGACY_CONFIG_FILENAME = 'sheet-db.config.ts'; const LEGACY_TOKENS_FILENAME = '.sheet-db-tokens.json'; let warnedLegacyConfig = false; let warnedLegacyTokens = false; /** * Resolves the CLI config file path, preferring `lsdb.config.ts` over the * deprecated `sheet-db.config.ts`. Returns the canonical path if neither exists, * so callers' existing "not found" handling continues to work unchanged. */ function resolveConfigPath(cwd = process.cwd()) { const current = path_1.default.join(cwd, exports.CONFIG_FILENAME); if (fs_1.default.existsSync(current)) return current; const legacy = path_1.default.join(cwd, LEGACY_CONFIG_FILENAME); if (fs_1.default.existsSync(legacy)) { if (!warnedLegacyConfig) { console.warn(chalk_1.default.yellow(`⚠️ ${LEGACY_CONFIG_FILENAME} is deprecated — rename it to ${exports.CONFIG_FILENAME}. ` + 'Support for the old filename will be removed in a future release.')); warnedLegacyConfig = true; } return legacy; } return current; } /** * Resolves the OAuth tokens file path, preferring `.lsdb-tokens.json` over the * deprecated `.sheet-db-tokens.json`. Returns the canonical path if neither exists, * so callers' existing existence checks continue to work unchanged. */ function resolveTokensPath(cwd = process.cwd()) { const current = path_1.default.join(cwd, exports.TOKENS_FILENAME); if (fs_1.default.existsSync(current)) return current; const legacy = path_1.default.join(cwd, LEGACY_TOKENS_FILENAME); if (fs_1.default.existsSync(legacy)) { if (!warnedLegacyTokens) { console.warn(chalk_1.default.yellow(`⚠️ ${LEGACY_TOKENS_FILENAME} is deprecated — lsdb sync will save new tokens to ${exports.TOKENS_FILENAME}.`)); warnedLegacyTokens = true; } return legacy; } return current; } //# sourceMappingURL=cliFiles.js.map