Skip to content

Commit

Permalink
Fix typescript and errors
Browse files Browse the repository at this point in the history
  • Loading branch information
2can committed Jan 3, 2024
1 parent cdbc8d3 commit 54b6d4b
Show file tree
Hide file tree
Showing 14 changed files with 71 additions and 150 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
"fetch-repo-dir": "^1.0.6",
"fs-extra": "^11.2.0",
"git-url-parse": "^14.0.0",
"got": "^14.0.0",
"got": "^12.0.0",
"graphql": "^16.8.1",
"graphql-request": "^6.1.0",
"graphql-tag": "^2.12.6",
Expand Down
72 changes: 7 additions & 65 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/cli/configure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const builder: CommandBuilder = (_) =>
desc: 'skip additional prompts',
});

export const handler = async (argv: Arguments<Options>) => {
export const handler = async (argv: Arguments<any>) => {
debug('command arguments: %O', obfuscateArgv(argv));

const { token, force } = argv;
Expand Down
6 changes: 1 addition & 5 deletions src/cli/dev/prepare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,12 @@ import { Config } from '../../lib/config.js';
import { GitError, obfuscateArgv, printlnSuccess } from '../../lib/util.js';
import { useGithub } from '../../middleware/index.js';

interface Options {
branch?: string;
}

const debug = Debug('saleor-cli:dev:prepare');

export const command = 'prepare [branch|prURL]';
export const desc = 'Build cli from branch or pull request URL';

export const handler = async (argv: Arguments<Options>) => {
export const handler = async (argv: Arguments<any>) => {
debug('command arguments: %O', obfuscateArgv(argv));

const git = simpleGit();
Expand Down
86 changes: 40 additions & 46 deletions src/cli/env/cors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,42 +95,39 @@ export const handler = async (argv: Arguments<Options>) => {
}

// First form to check current
const { kind } = await Enquirer.prompt<{
kind: string;
}>([
{
type: 'select',
name: 'kind',
message: 'Choose allowed API origins ',
choices: [
{
message: 'Allow all origins',
name: 'all',
},
{
message: 'Selected Origins',
name: 'selected',
},
{
message: 'Dashboard only',
name: 'dashboard',
},
],
initial: () => {
if (allowedCorsOrigins === '*') {
return 1;
}
if (allowedCorsOrigins == null) {
return 2;
}
if (Array.isArray(allowedCorsOrigins)) {
return 3;
}

return 1;
const kindPrompt = new (Enquirer as any).Select({
name: 'kind',
message: 'Choose allowed API origins ',
choices: [
{
message: 'Allow all origins',
name: 'all',
},
{
message: 'Selected Origins',
name: 'selected',
},
{
message: 'Dashboard only',
name: 'dashboard',
},
],
initial: () => {
if (allowedCorsOrigins === '*') {
return 1;
}
if (allowedCorsOrigins == null) {
return 2;
}
if (Array.isArray(allowedCorsOrigins)) {
return 3;
}

return 1;
},
]);
});

const kind = (await kindPrompt.run()) as string;

// Trigger an update for all and dashboard
if (['all', 'dashboard'].includes(kind)) {
Expand All @@ -153,18 +150,15 @@ export const handler = async (argv: Arguments<Options>) => {

const addNewMsg = 'Add a new CORS origin';

const { origins } = await Enquirer.prompt<{
origins: string;
}>([
{
type: 'multiselect',
name: 'origins',
message:
'Define Selected Origins\n (use the arrows to navigate and the space bar to select)',
choices: [...selected, addNewMsg],
initial: selected,
},
]);
const originsPrompt = new (Enquirer as any).MultiSelect({
name: 'origins',
message:
'Define Trusted Origins\n (use the arrows to navigate and the space bar to select)',
choices: [...selected, addNewMsg],
initial: selected,
});

const origins = (await originsPrompt.run()) as string;

do {
if (origins.length === 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/cli/env/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ interface CommandOptions extends Options {
pass?: string;
restore: boolean;
restoreFrom: string;
skipWebhooksUpdate: boolean;
skipWebhooksUpdate?: boolean;
skipRestrict: boolean;
}

Expand Down
21 changes: 9 additions & 12 deletions src/cli/env/origins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,15 @@ export const handler = async (argv: Arguments<Options>) => {
const selected: string[] = (allowedClientOrigins as string[]) || [];
let addMore = true;

const { origins } = await Enquirer.prompt<{
origins: string;
}>([
{
type: 'multiselect',
name: 'origins',
message:
'Define Trusted Origins\n (use the arrows to navigate and the space bar to select)',
choices: [...selected, 'Add a new trusted origin'],
initial: selected,
},
]);
const originsPrompt = new (Enquirer as any).MultiSelect({
name: 'origins',
message:
'Define Trusted Origins\n (use the arrows to navigate and the space bar to select)',
choices: [...selected, 'Add a new trusted origin'],
initial: selected,
});

const origins = (await originsPrompt.run()) as string;

do {
if (origins.length === 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/cli/info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type { CommandBuilder } from 'yargs';
import { Config } from '../lib/config.js';
import { header } from '../lib/images.js';
import { API, GET, getEnvironment } from '../lib/index.js';
import { User } from '../types.js';
import { Options, User } from '../types.js';

const require = createRequire(import.meta.url);
const pkg = require('../package.json');
Expand Down
6 changes: 3 additions & 3 deletions src/cli/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
println,
successPage,
} from '../lib/util.js';
import { BaseOptions } from '../types.js';
import { Options } from '../types.js';

const environment = await getEnvironment();
const RedirectURI = `http://127.0.0.1:${SaleorCLIPort}/`;
Expand All @@ -49,7 +49,7 @@ export const builder: CommandBuilder = (_) =>
.example('saleor login --headless', '')
.example('saleor login --headless --token=TOKEN', '');

export const handler = async (argv: Arguments<BaseOptions>) => {
export const handler = async (argv: Arguments<any>) => {
if (argv.headless) {
const { ux: cli } = CliUx;
let { token } = argv;
Expand Down Expand Up @@ -155,7 +155,7 @@ export const doLogin = async () => {

const { token }: any = await POST(API.Token, {
token: `Bearer ${idToken}`,
});
} as Options);

await createConfig(token, secrets);
} catch (error) {
Expand Down
Loading

0 comments on commit 54b6d4b

Please sign in to comment.