Skip to content

Commit

Permalink
@airtable/[email protected]
Browse files Browse the repository at this point in the history
  • Loading branch information
Airtable authored and ClementHoang-at committed Sep 27, 2024
1 parent 48a2f6d commit 6c0a2ed
Show file tree
Hide file tree
Showing 14 changed files with 54 additions and 42 deletions.
1 change: 0 additions & 1 deletion packages/cli-next/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ module.exports = {
],
},
],
'jsdoc/newline-after-description': 'error',
'jsdoc/no-types': 'error',

'import/first': 'error',
Expand Down
9 changes: 7 additions & 2 deletions packages/cli-next/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,14 @@ Not every commit needs to result in a change to this file (e.g. docs and chore c
commit that affects the code in a way that consumers might care about should include edits to the
'Unreleased' section though. Breaking changes should be prefixed with `**BREAKING:**`.

## [Unreleased](https://github.com/Airtable/blocks/compare/@airtable/[email protected].3...HEAD)
## [Unreleased](https://github.com/Airtable/blocks/compare/@airtable/[email protected].4...HEAD)

- No changes.
- Upgrade Typescript version to 5.4.5
- Perform routine version upgrade to various packages, including `eslint`

## [2.0.4](https://github.com/Airtable/blocks/compare/@airtable/[email protected]...@airtable/[email protected])

- Updated help text for the `set-api-key` command to prompt for personal access tokens.

## [2.0.3](https://github.com/Airtable/blocks/compare/@airtable/[email protected]...@airtable/[email protected])

Expand Down
10 changes: 5 additions & 5 deletions packages/cli-next/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ $ npm install -g @airtable/blocks-cli
$ block COMMAND
running command...
$ block (-v|--version|version)
@airtable/blocks-cli/2.0.3 darwin-arm64 node-v16.17.0
@airtable/blocks-cli/2.0.5 darwin-arm64 node-v18.20.1
$ block --help [COMMAND]
USAGE
$ block COMMAND
Expand Down Expand Up @@ -80,7 +80,7 @@ OPTIONS
```

_See code:
[@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v3.2.0/src/commands/help.ts)_
[@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v3.3.1/src/commands/help.ts)_

## `block init BLOCKIDENTIFIER BLOCKDIRPATH`

Expand Down Expand Up @@ -163,7 +163,7 @@ EXAMPLE

## `block set-api-key [APIKEY]`

Set an api key for an airtable account to upload to
Set a personal access token (with block:manage scope) for an Airtable account to upload to

```
USAGE
Expand All @@ -175,8 +175,8 @@ OPTIONS
EXAMPLE
$ block set-api-key
$ block set-api-key APIKEY
$ block set-api-key --location app APIKEY
$ block set-api-key TOKEN
$ block set-api-key --location app TOKEN
```

## `block submit`
Expand Down
24 changes: 12 additions & 12 deletions packages/cli-next/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@airtable/blocks-cli",
"description": "Official command line tool for Airtable blocks development",
"version": "2.0.3",
"version": "2.0.5",
"homepage": "https://airtable.com/developers/blocks",
"author": "Airtable",
"bin": {
Expand Down Expand Up @@ -31,7 +31,7 @@
"strip-ansi": "^6.0.0",
"tar": "^6.1.0",
"tslib": "^1.14.1",
"typescript": "3.7.5"
"typescript": "^5.4.5"
},
"devDependencies": {
"@airtable/eslint-plugin-blocks": "^1.0.2",
Expand All @@ -48,17 +48,17 @@
"@types/node": "^14.14.7",
"@types/node-fetch": "^2.5.7",
"@types/react": "^17.0.1",
"@typescript-eslint/eslint-plugin": "^4.9.1",
"@typescript-eslint/parser": "^4.9.1",
"@typescript-eslint/eslint-plugin": "^7.13.0",
"@typescript-eslint/parser": "^7.13.0",
"chai": "^4.3.0",
"delay": "^5.0.0",
"detect-port": "^1.3.0",
"eslint": "^7.15.0",
"eslint-plugin-airtable": "github:hyperbase/eslint-plugin-airtable#fc6746d7",
"eslint-plugin-import": "^2.19.1",
"eslint-plugin-jsdoc": "^15.12.0",
"eslint-plugin-react": "^7.17.0",
"eslint-plugin-react-hooks": "^2.3.0",
"eslint": "^9.5.0",
"eslint-plugin-airtable": "github:hyperbase/eslint-plugin-airtable#01bbfe0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsdoc": "^48.2.12",
"eslint-plugin-react": "^7.34.2",
"eslint-plugin-react-hooks": "^4.6.2",
"fs-extra": "^10.0.1",
"globby": "^11.0.1",
"inquirer": "^8.2.1",
Expand Down Expand Up @@ -96,8 +96,8 @@
},
"scripts": {
"build": "rm -rf lib && rm -f tsconfig.tsbuildinfo && tsc --build",
"ci": "yarn test",
"lint": "eslint . --ext .ts --config .eslintrc.js",
"ci": "echo '--- cli-next' && yarn test",
"lint": "ESLINT_USE_FLAT_CONFIG=false eslint . --ext .ts --config .eslintrc.js",
"pack:typescript": "yarn build",
"postpack": "rm -f oclif.manifest.json",
"prepack": "yarn install && yarn run pack:typescript && oclif-dev manifest && oclif-dev readme",
Expand Down
1 change: 1 addition & 0 deletions packages/cli-next/src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ const initCommandPackageJsonFilter = [
function filterKeysInPackageJson<T>(
packageJson: T,
): Pick<T, keyof T & typeof initCommandPackageJsonFilter[any]> {
// @ts-ignore
return Object.entries(packageJson)
.filter(([key]) => initCommandPackageJsonFilter.includes(key as any))
.reduce((carry, [key, value]) => {
Expand Down
24 changes: 14 additions & 10 deletions packages/cli-next/src/commands/set-api-key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ import {
} from '../helpers/system_api_key';

export default class SetApiKey extends AirtableCommand {
static description = 'Set an api key for an airtable account to upload to';
static description =
'Set a personal access token (with block:manage scope) for an Airtable account to upload to';

static examples = [
`$ block set-api-key
$ block set-api-key APIKEY
$ block set-api-key --location app APIKEY
$ block set-api-key TOKEN
$ block set-api-key --location app TOKEN
`,
];

Expand All @@ -33,7 +34,7 @@ $ block set-api-key --location app APIKEY
}),

'api-key-name': commandFlags.string({
description: 'The name of the API key to set',
description: 'The name of the personal access token to set',
hidden: true,
}),
};
Expand Down Expand Up @@ -61,17 +62,20 @@ $ block set-api-key --location app APIKEY
if (apiKey) {
this.logMessage({type: AirtableApiErrorName.AIRTABLE_API_KEY_MALFORMED});
}
apiKey = await cli.prompt('What is your Airtable API Key?', {
type: 'mask',
required: true,
});
apiKey = await cli.prompt(
'What is your Airtable personal access token (with block:manage scope)?',
{
type: 'mask',
required: true,
},
);
}

const locationPath = await findApiKeyConfigPathAsync(this.system, flags.location);
this.log(`Saving API Key to: ${locationPath}`);
this.log(`Saving personal access token to: ${locationPath}`);

await writeApiKeyAsync(this.system, flags.location, apiKey, apiKeyName);

this.log(`API Key${apiKeyName ? ` '${apiKeyName}'` : ''} saved.`);
this.log(`Personal access token${apiKeyName ? ` '${apiKeyName}'` : ''} saved.`);
}
}
8 changes: 4 additions & 4 deletions packages/cli-next/src/helpers/airtable_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,9 @@ export abstract class AirtableApi extends FetchApi {
};
}

abstract async createBuildAsync(options: CreateBuildOptions): Promise<CreateBuildResponseJson>;
abstract createBuildAsync(options: CreateBuildOptions): Promise<CreateBuildResponseJson>;

abstract async createReleaseAsync(options: CreateReleaseOptions): Promise<void>;
abstract createReleaseAsync(options: CreateReleaseOptions): Promise<void>;

async uploadSubmissionAsync({archiveBuffer}: UploadSubmissionOptions): Promise<string> {
const {presignedUploadUrl, codeUploadId} = await this._blockCreateCodeUploadAsync();
Expand All @@ -206,9 +206,9 @@ export abstract class AirtableApi extends FetchApi {
return message;
}

protected abstract async _blockCreateCodeUploadAsync(): Promise<CodeUploadResponse>;
protected abstract _blockCreateCodeUploadAsync(): Promise<CodeUploadResponse>;

protected abstract async _blockFinalizeCodeUploadAsync(
protected abstract _blockFinalizeCodeUploadAsync(
options: CodeUploadOptions,
): Promise<FinalizeCodeUploadResponse>;

Expand Down
4 changes: 2 additions & 2 deletions packages/cli-next/src/helpers/cli_ux.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function prompt(message: string, options?: PromptOptions) {
});
}

export const cli = {..._cli, prompt};
export const ux = cli;
export const cli = {..._cli, prompt} as any;
export const ux = cli as any;

export default cli;
1 change: 1 addition & 0 deletions packages/cli-next/src/helpers/private_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export function cast<T>(x: T): T {
*/
export function omitUndefinedValues<T>(obj: T): T {
const value = {} as T;
// @ts-ignore
for (const key of Object.keys(obj) as (keyof T)[]) {
if (obj[key] !== undefined) {
value[key] = obj[key];
Expand Down
2 changes: 2 additions & 0 deletions packages/cli-next/src/helpers/task_channels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ enum ApplicationMessageType {
}

type Values<R extends ObjectMap<string, any>> = R[keyof R];
// @ts-ignore TODO(richsinn#blocks_vuln_upgrade): We should fix these type definitions, but moving forward to unblock upgrade
type RequestArgs<R> = Parameters<Values<ChannelMethods<R>>> & any[];
// @ts-ignore TODO(richsinn#blocks_vuln_upgrade): We should fix these type definitions, but moving forward to unblock upgrade
type RequestResults<R> = ReturnType<Values<ChannelMethods<R>>> extends Promise<infer P> ? P : never;

type RequestMessage<H> = [
Expand Down
2 changes: 1 addition & 1 deletion packages/cli-next/test/commands/run.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function stubFindPortAsync(stubOptions: {inUsePorts?: number[]; nextPort?: numbe
return async function(port?, portOptions?) {
const ports = Number(portOptions?.adjacentPorts) || 0;
for (let i = 0; i < ports + 1; i++) {
if (stubOptions?.inUsePorts?.includes(port + i)) {
if (port && stubOptions?.inUsePorts?.includes(port + i)) {
return stubOptions?.nextPort ?? 44444;
}
}
Expand Down
6 changes: 3 additions & 3 deletions packages/cli-next/test/commands/set-api-key.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('set-api-key', () => {
.command(['set-api-key', 'keyAPI12345678910'])
.wroteUserConfigFile({airtableApiKey: {default: 'keyAPI12345678910'}})
.it('runs set-api-key keyAPI12345678910', ctx => {
expect(ctx.stdout).to.contain('API Key saved');
expect(ctx.stdout).to.contain('Personal access token saved');
});

test.stdout()
Expand All @@ -24,7 +24,7 @@ describe('set-api-key', () => {
},
})
.it('runs set-api-key pat1234567890abcd', ctx => {
expect(ctx.stdout).to.contain('API Key saved');
expect(ctx.stdout).to.contain('Personal access token saved');
});

test.stdout()
Expand All @@ -33,7 +33,7 @@ describe('set-api-key', () => {
.command(['set-api-key'])
.wroteUserConfigFile({airtableApiKey: {default: 'keyAPI12345678910'}})
.it('runs set-api-key', ctx => {
expect(ctx.stdout).to.contain('API Key saved');
expect(ctx.stdout).to.contain('Personal access token saved');
});

test.stdout()
Expand Down
2 changes: 1 addition & 1 deletion packages/cli-next/test/helpers/system_extra.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('system_extra', () => {
};
};
const triggerReadTimeUpdate = async (path: string) => {
const readPromise = new Promise(resolve => {
const readPromise = new Promise<void>(resolve => {
fs.watchFile(path, {persistent: false, interval: 100}, function listener() {
fs.unwatchFile(path, listener);
resolve();
Expand Down
2 changes: 1 addition & 1 deletion packages/cli-next/test/smoke_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const BLOCK_ID = 'blkDOYCZmdADueASi';
const BLOCK_INSTALLATION_ID = 'bipHcxcRpB0ObTAGo';
const DEFAULT_BLOCK_RUN_WAIT_MS = 10 * 1000;
const DEFAULT_BLOCK_RUN_PORT = 9000;
const BLOCK_RELEASE_URL = 'https://block---q-oxb-w7k6m-k0-eqd--suk0375.airtableblocks.com/';
const BLOCK_RELEASE_URL = 'https://block---q-oxb-w7k6m-k0-eqd--suk0375.alt.airtableblocks.com/';
const BLOCKS_CLI_PACKAGE = '@airtable/blocks-cli';
const BLOCK_DIR_NAME = 'smoke_test';

Expand Down

0 comments on commit 6c0a2ed

Please sign in to comment.