Skip to content

Commit

Permalink
Fix pactlings ts errors
Browse files Browse the repository at this point in the history
  • Loading branch information
salamaashoush committed Apr 28, 2024
1 parent db2fcb8 commit 84e352f
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 115 deletions.
3 changes: 2 additions & 1 deletion apps/pactlings/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
"dependencies": {
"citty": "^0.1.6",
"defu": "^6.1.4",
"pathe": "^1.1.2"
"pathe": "^1.1.2",
"@pact-toolbox/utils": "workspace:*"
},
"devDependencies": {
"@pact-toolbox/tsconfig": "workspace:*",
Expand Down
4 changes: 4 additions & 0 deletions apps/pactlings/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ const main = defineCommand({
},
subCommands: {
watch: async () => (await import('./commands/watch')).watchCommand,
run: async () => (await import('./commands/run')).runCommand,
list: async () => (await import('./commands/list')).listCommand,
reset: async () => (await import('./commands/reset')).resetCommand,
hint: async () => (await import('./commands/hint')).hintCommand,
},
});

Expand Down
44 changes: 6 additions & 38 deletions apps/pactlings/src/commands/hint.ts
Original file line number Diff line number Diff line change
@@ -1,45 +1,13 @@
import { runScript } from '@pact-toolbox/script';
import { logger } from '@pact-toolbox/utils';
import { defineCommand } from 'citty';

export const runCommand = defineCommand({
export const hintCommand = defineCommand({
meta: {
name: 'run',
description: 'Run a script with the toolbox runtime',
name: 'hint',
description: 'Give a hint about an exercise',
},
args: {
script: {
type: 'positional',
name: 'script',
description: 'Script to run',
required: true,
},
start: {
type: 'boolean',
name: 'start',
alias: 's',
description: 'Start the network before running the script',
required: false,
default: true,
},
network: {
type: 'string',
name: 'network',
alias: 'n',
description: 'Network to use',
required: false,
default: 'local',
},
},
run: async ({ args }) => {
const { script, network, start, ...rest } = args;
logger.start(`Running script ${script} on network ${network}`);
await runScript(script, {
network,
args: rest,
scriptOptions: {
autoStartNetwork: start,
},
});
args: {},
run: async () => {
logger.error(`Hint command is not implemented yet.`);
},
});
13 changes: 13 additions & 0 deletions apps/pactlings/src/commands/list.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { logger } from '@pact-toolbox/utils';
import { defineCommand } from 'citty';

export const listCommand = defineCommand({
meta: {
name: 'list',
description: 'List all exercises',
},
args: {},
run: async () => {
logger.error(`List command is not implemented yet.`);
},
});
44 changes: 6 additions & 38 deletions apps/pactlings/src/commands/reset.ts
Original file line number Diff line number Diff line change
@@ -1,45 +1,13 @@
import { runScript } from '@pact-toolbox/script';
import { logger } from '@pact-toolbox/utils';
import { defineCommand } from 'citty';

export const runCommand = defineCommand({
export const resetCommand = defineCommand({
meta: {
name: 'run',
description: 'Run a script with the toolbox runtime',
name: 'reset',
description: 'Reset the an exercise',
},
args: {
script: {
type: 'positional',
name: 'script',
description: 'Script to run',
required: true,
},
start: {
type: 'boolean',
name: 'start',
alias: 's',
description: 'Start the network before running the script',
required: false,
default: true,
},
network: {
type: 'string',
name: 'network',
alias: 'n',
description: 'Network to use',
required: false,
default: 'local',
},
},
run: async ({ args }) => {
const { script, network, start, ...rest } = args;
logger.start(`Running script ${script} on network ${network}`);
await runScript(script, {
network,
args: rest,
scriptOptions: {
autoStartNetwork: start,
},
});
args: {},
run: async () => {
logger.error(`Reset command is not implemented yet.`);
},
});
40 changes: 4 additions & 36 deletions apps/pactlings/src/commands/run.ts
Original file line number Diff line number Diff line change
@@ -1,45 +1,13 @@
import { runScript } from '@pact-toolbox/script';
import { logger } from '@pact-toolbox/utils';
import { defineCommand } from 'citty';

export const runCommand = defineCommand({
meta: {
name: 'run',
description: 'Run a script with the toolbox runtime',
description: 'Run the exercise',
},
args: {
script: {
type: 'positional',
name: 'script',
description: 'Script to run',
required: true,
},
start: {
type: 'boolean',
name: 'start',
alias: 's',
description: 'Start the network before running the script',
required: false,
default: true,
},
network: {
type: 'string',
name: 'network',
alias: 'n',
description: 'Network to use',
required: false,
default: 'local',
},
},
run: async ({ args }) => {
const { script, network, start, ...rest } = args;
logger.start(`Running script ${script} on network ${network}`);
await runScript(script, {
network,
args: rest,
scriptOptions: {
autoStartNetwork: start,
},
});
args: {},
run: async ({}) => {
logger.error(`Run command is not implemented yet.`);
},
});
7 changes: 5 additions & 2 deletions apps/pactlings/src/commands/watch.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { logger } from '@pact-toolbox/utils';
import { defineCommand } from 'citty';

export const watchCommand = defineCommand({
meta: {
name: 'watch',
description: '',
description: 'Watch the exercise',
},
run: async () => {
logger.error(`Watch command is not implemented yet.`);
},
run: async () => {},
});
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

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

0 comments on commit 84e352f

Please sign in to comment.