csv2gsheets
Advanced tools
Comparing version 1.0.1 to 1.0.2
import { OAuth2Client } from 'google-auth-library'; | ||
export declare const TOKEN_PATH: string; | ||
export interface CredentialsKey { | ||
client_id: string; | ||
project_id: string; | ||
auth_uri: string; | ||
token_uri: string; | ||
auth_provider_x509_cert_url: string; | ||
client_secret: string; | ||
redirect_uris: string[]; | ||
} | ||
export interface Credentials { | ||
installed?: CredentialsKey; | ||
web?: CredentialsKey; | ||
} | ||
/** | ||
@@ -11,3 +24,3 @@ * Check if the previously authorized token file exists. | ||
*/ | ||
export declare function loadSavedToken(): Promise<OAuth2Client | null>; | ||
export declare function loadSavedToken(): OAuth2Client | null; | ||
/** | ||
@@ -17,3 +30,3 @@ * Serialize credentials to a file compatible with GoogleAuth.fromJSON. | ||
*/ | ||
export declare function saveToken(client: OAuth2Client): Promise<void>; | ||
export declare function saveToken(client: OAuth2Client): void; | ||
/** | ||
@@ -20,0 +33,0 @@ * Load or request authorization to call Google APIs. |
@@ -32,13 +32,8 @@ // Handle authentication and authorization with Google Drive API | ||
*/ | ||
export async function loadSavedToken() { | ||
try { | ||
if (isAuthorized()) { | ||
const token = await fs.promises.readFile(TOKEN_PATH, 'utf8'); | ||
return google.auth.fromJSON(JSON.parse(token)); | ||
} | ||
else { | ||
return null; | ||
} | ||
export function loadSavedToken() { | ||
if (isAuthorized()) { | ||
const token = fs.readFileSync(TOKEN_PATH, 'utf8'); | ||
return google.auth.fromJSON(JSON.parse(token)); | ||
} | ||
catch (err) { | ||
else { | ||
return null; | ||
@@ -51,4 +46,4 @@ } | ||
*/ | ||
export async function saveToken(client) { | ||
const credentialsStr = await fs.promises.readFile(CREDENTIALS_PATH, 'utf8'); | ||
export function saveToken(client) { | ||
const credentialsStr = fs.readFileSync(CREDENTIALS_PATH, 'utf8'); | ||
const parsedCredentials = JSON.parse(credentialsStr); | ||
@@ -67,3 +62,3 @@ if ('installed' in parsedCredentials || 'web' in parsedCredentials) { | ||
}); | ||
await fs.promises.writeFile(TOKEN_PATH, payload); | ||
fs.writeFileSync(TOKEN_PATH, payload); | ||
} | ||
@@ -79,3 +74,3 @@ else { | ||
export async function authorize() { | ||
let client = await loadSavedToken(); | ||
let client = loadSavedToken(); | ||
if (!client) { | ||
@@ -87,3 +82,3 @@ client = await authenticate({ | ||
if (client?.credentials) { | ||
await saveToken(client); | ||
saveToken(client); | ||
} | ||
@@ -90,0 +85,0 @@ return client; |
@@ -96,3 +96,3 @@ // convert command | ||
}; | ||
if (utils.isRoot(config.targetDriveFolderId)) { | ||
if (!utils.isRoot(config.targetDriveFolderId)) { | ||
requestBody.parents = [config.targetDriveFolderId]; | ||
@@ -99,0 +99,0 @@ } |
@@ -159,2 +159,3 @@ // Utility functions | ||
supportsAllDrives: config.targetIsSharedDrive, | ||
includeItemsFromAllDrives: config.targetIsSharedDrive, | ||
q: `'${config.targetDriveFolderId}' in parents and mimeType = 'application/vnd.google-apps.spreadsheet' and trashed = false`, | ||
@@ -234,2 +235,3 @@ fields: 'nextPageToken, files(id, name)', | ||
supportsAllDrives: config.targetIsSharedDrive, | ||
includeItemsFromAllDrives: config.targetIsSharedDrive, | ||
q: `name = 'csv' and '${config.targetDriveFolderId}' in parents and mimeType = 'application/vnd.google-apps.folder' and trashed = false`, | ||
@@ -246,3 +248,3 @@ fields: 'files(id, name)', | ||
}; | ||
if (isRoot(config.targetDriveFolderId)) { | ||
if (!isRoot(config.targetDriveFolderId)) { | ||
newCsvFolderRequestBody.parents = [config.targetDriveFolderId]; | ||
@@ -249,0 +251,0 @@ } |
{ | ||
"name": "csv2gsheets", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "CLI tool to convert local CSV files into Google Sheets files in a designated Google Drive folder.", | ||
@@ -5,0 +5,0 @@ "type": "module", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
74955
935