Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/new flow fixes #92

Merged
merged 15 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 23 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@subsquid/cli",
"description": "squid cli tool",
"version": "3.0.0-beta.1",
"version": "3.0.0-beta.11",
"license": "GPL-3.0-or-later",
"repository": "git@github.com:subsquid/squid-cli.git",
"publishConfig": {
Expand Down Expand Up @@ -74,43 +74,44 @@
"testEnvironment": "node"
},
"dependencies": {
"@oclif/core": "3.26.0",
"@oclif/plugin-autocomplete": "3.0.13",
"@oclif/plugin-warn-if-update-available": "^3.1.6",
"@oclif/core": "3.27.0",
"@oclif/plugin-autocomplete": "3.2.2",
"@oclif/plugin-warn-if-update-available": "^3.1.13",
"@subsquid/commands": "^2.3.1",
"@subsquid/manifest": "^0.0.1-beta.17",
"@subsquid/manifest": "^2.0.0-beta.3",
"@subsquid/manifest-expr": "^0.0.1",
"@types/fast-levenshtein": "^0.0.4",
"@types/lodash": "^4.17.0",
"@types/lodash": "^4.17.7",
"@types/targz": "^1.0.4",
"async-retry": "^1.3.3",
"axios": "^1.6.8",
"axios-retry": "^4.1.0",
"axios": "^1.7.5",
"axios-retry": "^4.5.0",
"blessed-contrib": "^4.11.0",
"chalk": "^4.1.2",
"cli-diff": "^1.0.0",
"cli-select": "^1.1.2",
"cross-spawn": "^7.0.3",
"date-fns": "^3.6.0",
"dotenv": "^16.4.5",
"fast-levenshtein": "^3.0.0",
"figlet": "^1.7.0",
"form-data": "^4.0.0",
"glob": "^10.3.12",
"ignore": "^5.3.1",
"glob": "^10.4.5",
"ignore": "^5.3.2",
"inquirer": "^8.2.6",
"joi": "^17.13.3",
"js-yaml": "^4.1.0",
"lodash": "^4.17.21",
"ms": "^2.1.3",
"neo-blessed": "^0.2.0",
"open": "^8.1.0",
"pretty-bytes": "^5.6.0",
"qs": "^6.12.0",
"qs": "^6.13.0",
"reblessed": "^0.2.1",
"simple-git": "^3.24.0",
"simple-git": "^3.25.0",
"split2": "^4.2.0",
"targz": "^1.0.1",
"tree-kill": "^1.2.2",
"unique-names-generator": "^4.7.1"
"tree-kill": "^1.2.2"
},
"devDependencies": {
"@oclif/dev-cli": "^1.26.10",
Expand All @@ -123,12 +124,12 @@
"@types/jest": "^29.5.12",
"@types/js-yaml": "^4.0.9",
"@types/ms": "^0.7.34",
"@types/node": "^20.12.3",
"@types/qs": "^6.9.14",
"@types/node": "^20.16.2",
"@types/qs": "^6.9.15",
"@types/split2": "^3.2.1",
"@typescript-eslint/eslint-plugin": "^7.5.0",
"@typescript-eslint/eslint-plugin": "^7.18.0",
"@typescript-eslint/eslint-plugin-tslint": "^7.0.2",
"@typescript-eslint/parser": "^7.5.0",
"@typescript-eslint/parser": "^7.18.0",
"eslint": "8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-config-standard": "^17.1.0",
Expand All @@ -140,11 +141,11 @@
"jest": "^29.7.0",
"openapi-typescript": "^7.3.0",
"pkg": "^5.8.1",
"prettier": "^3.2.5",
"ts-jest": "^29.1.2",
"prettier": "^3.3.3",
"ts-jest": "^29.2.5",
"ts-node": "^10.9.2",
"type-fest": "^4.24.0",
"typescript": "~5.4.3"
"type-fest": "^4.26.0",
"typescript": "~5.5.4"
},
"packageManager": "yarn@4.1.1"
}
9 changes: 6 additions & 3 deletions src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import path from 'path';
import axios, { Method } from 'axios';
import axiosRetry, { IAxiosRetryConfig, isNetworkOrIdempotentRequestError } from 'axios-retry';
import chalk from 'chalk';
import { pickBy } from 'lodash';
import { isEmpty, pickBy } from 'lodash';
import ms from 'ms';
import qs from 'qs';

import { getConfig } from '../config';

Expand Down Expand Up @@ -58,6 +59,7 @@ export function debugLog(...args: any[]) {
}

export async function api<T = any>({
version = 'v1',
method,
path,
data,
Expand All @@ -68,6 +70,7 @@ export async function api<T = any>({
abortController,
retry,
}: {
version?: 'v1';
method: Method;
path: string;
query?: Record<string, string | string[] | boolean | number | undefined>;
Expand All @@ -82,7 +85,7 @@ export async function api<T = any>({

const started = Date.now();
// add the API_URL to the path if it's not a full url
const url = !path.startsWith('https') ? `${config.apiUrl}${path}` : path;
const url = !path.startsWith('https') ? `${config.apiUrl}/${version}${path}` : path;

const finalHeaders = {
authorization: url.startsWith(config.apiUrl) ? `token ${config.credentials}` : null,
Expand Down Expand Up @@ -111,7 +114,7 @@ export async function api<T = any>({
console.log(
chalk.dim(new Date().toISOString()),
chalk.cyan`[${method.toUpperCase()}]`,
response.config.url,
`${response.config.url}${!isEmpty(query) ? `?${qs.stringify(query)}` : ``}`,
chalk.cyan(response.status),
ms(Date.now() - started),
chalk.dim(JSON.stringify({ headers: response.headers })),
Expand Down
14 changes: 7 additions & 7 deletions src/api/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { api } from './api';
import { Deploy, DeployRequest, HttpResponse, OrganizationRequest } from './types';
import { Deployment, DeployRequest, HttpResponse, OrganizationRequest } from './types';

export async function getDeploy({ organization, deploy }: DeployRequest): Promise<Deploy> {
const { body } = await api<HttpResponse<Deploy>>({
export async function getDeploy({ organization, deploy }: DeployRequest): Promise<Deployment> {
const { body } = await api<HttpResponse<Deployment>>({
method: 'get',
path: `/orgs/${organization.code}/deploys/${deploy.id}`,
path: `/orgs/${organization.code}/deployments/${deploy.id}`,
});

return body.payload;
}

export async function getDeploys({ organization }: OrganizationRequest): Promise<Deploy[]> {
const { body } = await api<HttpResponse<Deploy[]>>({
export async function getDeploys({ organization }: OrganizationRequest): Promise<Deployment[]> {
const { body } = await api<HttpResponse<Deployment[]>>({
method: 'get',
path: `/orgs/${organization.code}/deploys`,
path: `/orgs/${organization.code}/deployments`,
});

return body.payload;
Expand Down
Loading
Loading