Skip to content

Commit

Permalink
chore: upgrade dependencies (#382)
Browse files Browse the repository at this point in the history
* chore: upgrade dependencies

BREAKING CHANGE: node version updated to >= 18

* fix: test

* chore: update workflow

* chore: cleanup dependencies
  • Loading branch information
jroehl committed May 22, 2023
1 parent 7cd4b2a commit 47716eb
Show file tree
Hide file tree
Showing 16 changed files with 7,746 additions and 5,404 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v14.15.5
v18.16.0
12,988 changes: 7,667 additions & 5,321 deletions package-lock.json

Large diffs are not rendered by default.

39 changes: 18 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,26 @@
},
"bugs": "https://github.com/jroehl/google-sheet-cli/issues",
"dependencies": {
"@oclif/command": "^1.6.1",
"@oclif/config": "^1.15.1",
"@oclif/plugin-help": "^3.0.0",
"cli-ux": "^5.4.5",
"googleapis": "^84.0.0",
"husky": "^7.0.0",
"@oclif/core": "^2.8.5",
"@oclif/plugin-help": "^5.2.9",
"googleapis": "^118.0.0",
"husky": "^8.0.3",
"lodash.get": "^4.4.2",
"semantic-release": "^17.0.6",
"tslib": "^2.0.0"
"semantic-release": "^21.0.2",
"tslib": "^2.5.2"
},
"devDependencies": {
"@oclif/dev-cli": "^1.22.2",
"@oclif/test": "^1.2.5",
"@types/chai": "^4.2.11",
"@types/lodash.get": "^4.4.6",
"@types/mocha": "^9.0.0",
"@types/node": "^16.0.0",
"chai": "^4.2.0",
"mocha": "^9.0.1",
"nyc": "^15.0.1",
"source-map-support": "^0.5.19",
"ts-node": "^10.0.0",
"typescript": "^4.0.2"
"@oclif/test": "^2.3.21",
"@types/chai": "^4.3.5",
"@types/lodash.get": "^4.4.7",
"@types/mocha": "^10.0.1",
"@types/node": "^20.2.3",
"chai": "^4.3.7",
"mocha": "^10.2.0",
"nyc": "^15.1.0",
"source-map-support": "^0.5.21",
"ts-node": "^10.9.1",
"typescript": "^5.0.4"
},
"engines": {
"node": ">=8.0.0"
Expand Down Expand Up @@ -70,7 +67,7 @@
"repository": "jroehl/google-sheet-cli",
"scripts": {
"postpack": "rm -f oclif.manifest.json",
"version": "oclif-dev readme --multi && sh ./bin/clean.sh && git add README.md docs/*.md",
"version": "npx oclif readme --multi && sh ./bin/clean.sh && git add README.md docs/*.md",
"prepack": "rm -rf lib && tsc -b && oclif-dev manifest && oclif-dev readme --multi",
"test": "nyc mocha \"test/**/*.test.ts\"",
"semantic-release": "semantic-release",
Expand Down
12 changes: 6 additions & 6 deletions src/commands/data/append.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { flags } from '@oclif/command';
import Command, { worksheetTitle, spreadsheetId, data, valueInputOption } from '../../lib/base-class';
import { Flags } from '@oclif/core';
import Command, { data, spreadsheetId, valueInputOption, worksheetTitle } from '../../lib/base-class';

export default class UpdateData extends Command {
static description = 'Append cells with the specified data after the last row in starting col';
Expand All @@ -16,16 +16,16 @@ Data successfully appended to "<worksheetTitle>"
worksheetTitle,
spreadsheetId,
valueInputOption,
minCol: flags.integer({ description: 'The optional starting col of the operation', default: 1, required: false }),
minCol: Flags.integer({ description: 'The optional starting col of the operation', default: 1, required: false }),
};

static args = [data];
static args = { data };

async run() {
const {
args: { data },
flags: { minCol, worksheetTitle = '', spreadsheetId, valueInputOption },
} = this.parse(UpdateData);
} = await this.parse(UpdateData);

try {
this.start('Appending data');
Expand All @@ -44,7 +44,7 @@ Data successfully appended to "<worksheetTitle>"
if (error instanceof SyntaxError) {
throw `"data" input has to be valid JSON (${error.message || error})`;
}
throw error.message || error;
throw (error as Error).message || error;
}
}
}
23 changes: 11 additions & 12 deletions src/commands/data/get.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { flags } from '@oclif/command';
import cli from 'cli-ux';
import Command, { worksheetTitle, spreadsheetId } from '../../lib/base-class';
import { Flags, ux } from '@oclif/core';
import Command, { spreadsheetId, worksheetTitle } from '../../lib/base-class';

export default class UpdateData extends Command {
static description = 'Returns cell data';
Expand All @@ -17,21 +16,21 @@ A3 B3 C3

static flags = {
...Command.flags,
...cli.table.flags(),
...ux.table.flags(),
spreadsheetId,
worksheetTitle,
hasHeaderRow: flags.boolean({ char: 'w', description: 'If the first row should be treated as header row', default: false, required: false }),
range: flags.string({ description: 'The range to use to query the cells', required: false }),
minRow: flags.integer({ description: 'The optional starting row of the operation', default: 1, required: false }),
minCol: flags.integer({ description: 'The optional starting col of the operation', default: 1, required: false }),
maxRow: flags.integer({ description: 'The optional ending row of the operation', required: false }),
maxCol: flags.integer({ description: 'The optional ending col of the operation', required: false }),
hasHeaderRow: Flags.boolean({ char: 'w', description: 'If the first row should be treated as header row', default: false, required: false }),
range: Flags.string({ description: 'The range to use to query the cells', required: false }),
minRow: Flags.integer({ description: 'The optional starting row of the operation', default: 1, required: false }),
minCol: Flags.integer({ description: 'The optional starting col of the operation', default: 1, required: false }),
maxRow: Flags.integer({ description: 'The optional ending row of the operation', required: false }),
maxCol: Flags.integer({ description: 'The optional ending col of the operation', required: false }),
};

async run() {
const {
flags: { spreadsheetId, rawOutput, minRow, maxRow, minCol, maxCol, range, hasHeaderRow, worksheetTitle, ...tableOptions },
} = this.parse(UpdateData);
} = await this.parse(UpdateData);

this.start('Fetching data');
const res = await this.gsheet.getData({ minRow, maxRow, minCol, maxCol, range, hasHeaderRow, worksheetTitle }, spreadsheetId);
Expand All @@ -46,6 +45,6 @@ A3 B3 C3
return { ...red, [col]: {} };
}, {});
this.stop();
cli.table(formatted, columns, tableOptions);
ux.table(formatted, columns, tableOptions);
}
}
14 changes: 7 additions & 7 deletions src/commands/data/update.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { flags } from '@oclif/command';
import Command, { worksheetTitle, spreadsheetId, data, valueInputOption } from '../../lib/base-class';
import { Flags } from '@oclif/core';
import Command, { data, spreadsheetId, valueInputOption, worksheetTitle } from '../../lib/base-class';

export default class UpdateData extends Command {
static description = 'Updates cells with the specified data';
Expand All @@ -16,17 +16,17 @@ Data successfully updated in "<worksheetTitle>"
worksheetTitle,
spreadsheetId,
valueInputOption,
minRow: flags.integer({ description: 'The optional starting row of the operation', default: 1, required: false }),
minCol: flags.integer({ description: 'The optional starting col of the operation', default: 1, required: false }),
minRow: Flags.integer({ description: 'The optional starting row of the operation', default: 1, required: false }),
minCol: Flags.integer({ description: 'The optional starting col of the operation', default: 1, required: false }),
};

static args = [data];
static args = { data };

async run() {
const {
args: { data },
flags: { minRow, minCol, worksheetTitle = '', spreadsheetId, valueInputOption },
} = this.parse(UpdateData);
} = await this.parse(UpdateData);

try {
this.start('Updating data');
Expand All @@ -47,7 +47,7 @@ Data successfully updated in "<worksheetTitle>"
if (error instanceof SyntaxError) {
throw `"data" input has to be valid JSON (${error.message || error})`;
}
throw error.message || error;
throw (error as Error).message || error;
}
}
}
6 changes: 3 additions & 3 deletions src/commands/spreadsheet/add.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { flags } from '@oclif/command';
import { Flags } from '@oclif/core';
import Command from '../../lib/base-class';

export default class Add extends Command {
Expand All @@ -13,7 +13,7 @@ Spreadsheet "<spreadsheetTitle>" (<id>) successfully created > https://docs.goog

static flags = {
...Command.flags,
spreadsheetTitle: flags.string({
spreadsheetTitle: Flags.string({
description: 'Title of the spreadsheet',
required: true,
}),
Expand All @@ -22,7 +22,7 @@ Spreadsheet "<spreadsheetTitle>" (<id>) successfully created > https://docs.goog
async run() {
const {
flags: { spreadsheetTitle = '' },
} = this.parse(Add);
} = await this.parse(Add);

this.start('Adding spreadsheet');
const spreadsheet = await this.gsheet.addSpreadsheet(spreadsheetTitle);
Expand Down
2 changes: 1 addition & 1 deletion src/commands/spreadsheet/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Fetched "<spreadsheetTitle>" (<id>) > https://docs.google.com/spreadsheets/d/<id
async run() {
const {
flags: { spreadsheetId },
} = this.parse(Get);
} = await this.parse(Get);

this.start('Fetching spreadsheet');
const spreadsheet = await this.gsheet.getSpreadsheet(spreadsheetId);
Expand Down
5 changes: 3 additions & 2 deletions src/commands/worksheet/add.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Command, { worksheetTitle, spreadsheetId } from '../../lib/base-class';
import Command, { spreadsheetId, worksheetTitle } from '../../lib/base-class';

export default class Add extends Command {
static description = 'Add a worksheet with the specified title to the spreadsheet';
Expand All @@ -19,10 +19,11 @@ Worksheet "<worksheetTitle>" (<id>) successfully created
async run() {
const {
flags: { worksheetTitle = '', spreadsheetId },
} = this.parse(Add);
} = await this.parse(Add);

this.start('Adding worksheet');
const worksheet = await this.gsheet.addWorksheet(worksheetTitle, spreadsheetId);
if (!worksheet) throw new Error('Worksheet not created');
const { properties: { title = '', sheetId = '' } = {} } = worksheet;
this.stop();
this.logRaw(`Worksheet "${title}" (${sheetId}) successfully created`, { operation: this.id, ...worksheet });
Expand Down
4 changes: 2 additions & 2 deletions src/commands/worksheet/get.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Command, { worksheetTitle, spreadsheetId } from '../../lib/base-class';
import Command, { spreadsheetId, worksheetTitle } from '../../lib/base-class';

export default class Get extends Command {
static description = 'Get info for a specific worksheet';
Expand All @@ -19,7 +19,7 @@ Fetched "<worksheetTitle>" (<id>)
async run() {
const {
flags: { worksheetTitle = '', spreadsheetId },
} = this.parse(Get);
} = await this.parse(Get);

this.start('Fetching worksheet');
const worksheet = await this.gsheet.getWorksheet(worksheetTitle, spreadsheetId);
Expand Down
4 changes: 2 additions & 2 deletions src/commands/worksheet/remove.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Command, { worksheetTitle, spreadsheetId } from '../../lib/base-class';
import Command, { spreadsheetId, worksheetTitle } from '../../lib/base-class';

export default class Remove extends Command {
static description = 'Remove a worksheet with the specified title from the spreadsheet';
Expand All @@ -19,7 +19,7 @@ Worksheet "<worksheetTitle>" successfully removed
async run() {
const {
flags: { worksheetTitle = '', spreadsheetId },
} = this.parse(Remove);
} = await this.parse(Remove);

this.start('Removing worksheet');
await this.gsheet.removeWorksheet(worksheetTitle, spreadsheetId);
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { run } from '@oclif/core';
import GoogleSheet, { GoogleSheetCli } from './lib/google-sheet';
import { run } from '@oclif/command';
export { run, GoogleSheet, GoogleSheetCli };
27 changes: 13 additions & 14 deletions src/lib/base-class.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
import Command, { flags } from '@oclif/command';
import cli from 'cli-ux';
import { Args, Command, Flags, ux } from '@oclif/core';
import GoogleSheet, { GoogleSheetCli } from './google-sheet';

export const spreadsheetId = flags.string({
export const spreadsheetId = Flags.string({
char: 's',
description: 'ID of the spreadsheet to use',
required: true,
env: 'SPREADSHEET_ID',
});

export const worksheetTitle = flags.string({
export const worksheetTitle = Flags.string({
char: 't',
description: 'Title of the worksheet to use',
required: true,
env: 'WORKSHEET_TITLE',
});
export const valueInputOption = flags.string({
export const valueInputOption = Flags.string({
char: 'v',
description: 'The style of the input ("RAW" or "USER_ENTERED")',
required: false,
Expand All @@ -24,21 +23,21 @@ export const valueInputOption = flags.string({
env: 'VALUE_INPUT_OPTION',
});

export const data = {
export const data = Args.string({
name: 'data',
type: 'string',
description: 'The data to be used as a JSON string - nested array [["1", "2", "3"]]',
required: true,
env: 'DATA',
};
});

export default abstract class extends Command {
private rawLogs: boolean = false;
public gsheet!: GoogleSheet;

static flags = {
help: flags.help({ char: 'h' }),
rawOutput: flags.boolean({
help: Flags.help({ char: 'h' }),
rawOutput: Flags.boolean({
char: 'r',
description: 'Get the raw output as a JSON string',
default: false,
Expand All @@ -48,13 +47,13 @@ export default abstract class extends Command {

async start(message: string) {
if (!this.rawLogs) {
cli.action.start(message);
ux.action.start(message);
}
}

async stop(message?: string) {
if (!this.rawLogs) {
cli.action.stop(message);
ux.action.stop(message);
}
}

Expand All @@ -68,12 +67,12 @@ export default abstract class extends Command {

async init() {
// do some initialization
const { flags } = this.parse(<any>this.constructor);
const { flags } = await this.parse(<any>this.constructor);
this.rawLogs = flags && (flags as any).rawOutput;

const {
GSHEET_CLIENT_EMAIL = await cli.prompt('What is your client email?', { type: 'hide' }),
GSHEET_PRIVATE_KEY = await cli.prompt('What is your private key?', { type: 'hide' }),
GSHEET_CLIENT_EMAIL = await ux.prompt('What is your client email?', { type: 'hide' }),
GSHEET_PRIVATE_KEY = await ux.prompt('What is your private key?', { type: 'hide' }),
} = process.env;

const gsheet = new GoogleSheet();
Expand Down

0 comments on commit 47716eb

Please sign in to comment.