Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2dfe6aac03 | ||
|
|
5e6b5d37d1 |
+36
-1
@@ -78,6 +78,33 @@ async function askOptionalPositiveInteger(ask, question, defaultValue) {
|
||||
}
|
||||
}
|
||||
|
||||
function extractSpreadsheetId(input) {
|
||||
const value = (input || '').trim();
|
||||
if (!value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const urlMatch = value.match(/\/spreadsheets\/d\/([a-zA-Z0-9-_]+)/i);
|
||||
if (urlMatch && urlMatch[1]) {
|
||||
return urlMatch[1];
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
async function askSpreadsheetIdOrUrl(ask, question) {
|
||||
while (true) {
|
||||
const answer = await ask(question);
|
||||
const documentId = extractSpreadsheetId(answer);
|
||||
|
||||
if (documentId) {
|
||||
return documentId;
|
||||
}
|
||||
|
||||
console.log('Please enter a Google Sheets URL or spreadsheet ID.');
|
||||
}
|
||||
}
|
||||
|
||||
async function pauseForEnter(ask) {
|
||||
await ask('Press Enter to close this window...');
|
||||
}
|
||||
@@ -132,6 +159,11 @@ async function runOnboarding() {
|
||||
]
|
||||
);
|
||||
|
||||
if (authMode === 'apiKeys') {
|
||||
console.log('Warning: when using API keys, the spreadsheet must be publicly accessible.');
|
||||
console.log('');
|
||||
}
|
||||
|
||||
const credentialCount = await askPositiveInteger(
|
||||
ask,
|
||||
`How many ${authMode === 'apiKeys' ? 'API keys' : 'service accounts'} do you want to add? `
|
||||
@@ -176,7 +208,10 @@ async function runOnboarding() {
|
||||
const documentCount = await askPositiveInteger(ask, 'How many documents do you want to pull from? ');
|
||||
|
||||
for (let documentIndex = 0; documentIndex < documentCount; documentIndex += 1) {
|
||||
const documentId = await askNonEmpty(ask, `Enter document ID ${documentIndex + 1}: `);
|
||||
const documentId = await askSpreadsheetIdOrUrl(
|
||||
ask,
|
||||
`Enter Google Sheets URL or document ID ${documentIndex + 1}: `
|
||||
);
|
||||
let documentTitle = documentId;
|
||||
|
||||
try {
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "google-sheets-rate-assistant",
|
||||
"version": "2.1.3",
|
||||
"version": "2.1.5",
|
||||
"description": "Pull Google Sheets data and export to CSV with configurable schedules and rate limiting.",
|
||||
"main": "index.js",
|
||||
"bin": "index.js",
|
||||
|
||||
Reference in New Issue
Block a user