Skip to content
This repository has been archived by the owner on Jun 28, 2024. It is now read-only.

Commit

Permalink
Merge branch 'release/x-cli-functionality' of github.com:superfaceai/…
Browse files Browse the repository at this point in the history
…cli into fix/polling-errors

# Conflicts:
#	src/commands/map.ts
  • Loading branch information
Jakub-Vacek committed Jul 17, 2023
2 parents 0094edf + b3113ef commit 6409c1a
Show file tree
Hide file tree
Showing 43 changed files with 1,060 additions and 209 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Wait for GH assets to be downloadable
- name: Wait for assets (10s)
run: sleep 10s
shell: bash

# Update Homebrew formula to the new version
# TODO: !!! Run only on stable releases
- name: Update Homebrew Formula
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,6 @@ yalc.lock

testground
/test/

# Superface Comlink artifacts
superface/
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@superfaceai/cli",
"version": "4.0.0-beta.8",
"version": "4.0.0-beta.14",
"description": "Superface CLI utility",
"main": "dist/index.js",
"repository": "https://github.com/superfaceai/cli.git",
Expand All @@ -15,6 +15,7 @@
"dist/"
],
"scripts": {
"prebuild": "rimraf dist",
"build": "tsc -p tsconfig.release.json --outDir dist",
"test": "yarn test:fast && yarn test:integration",
"test:clean": "jest --clear-cache && jest",
Expand Down Expand Up @@ -74,9 +75,6 @@
"oclif": {
"commands": "dist/commands",
"bin": "superface",
"hooks": {
"init": "dist/hooks/init"
},
"plugins": [
"@oclif/plugin-warn-if-update-available"
],
Expand Down
6 changes: 2 additions & 4 deletions src/commands/execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,12 @@ export default class Execute extends Command {
required: true,
},
{
// TODO: add language support
name: 'language',
description: 'Language which will use generated code. Default is `js`.',
// TODO: this will be required when we support more languages
required: false,
default: 'js',
options: Object.keys(SupportedLanguages),
// Hidden because we support only js for now
options: Object.values(SupportedLanguages),
// Hidden until we figure better language select DX
hidden: true,
},
];
Expand Down
36 changes: 31 additions & 5 deletions src/commands/map.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@ import { parseProfile, Source } from '@superfaceai/parser';

import { MockLogger } from '../common';
import { createUserError } from '../common/error';
import { fetchSDKToken } from '../common/http';
import { exists, readFile } from '../common/io';
import { OutputStream } from '../common/output-stream';
import { UX } from '../common/ux';
import type { NewDotenv } from '../logic';
import {
createNewDotenv,
SupportedLanguages,
writeApplicationCode,
} from '../logic/application-code/application-code';
} from '../logic/application-code';
import { mapProviderToProfile } from '../logic/map';
import { prepareProject } from '../logic/project';
import { mockProviderJson } from '../test/provider-json';
Expand All @@ -17,8 +20,10 @@ import Map from './map';

jest.mock('../common/io');
jest.mock('../common/output-stream');
jest.mock('../common/http');
jest.mock('../logic/map');
jest.mock('../logic/application-code/application-code');
jest.mock('../logic/application-code/dotenv');
jest.mock('../logic/project');

describe('MapCLI command', () => {
Expand All @@ -44,6 +49,11 @@ describe('MapCLI command', () => {
requiredParameters: ['TEST_PARAMETER'],
requiredSecurity: ['TEST_SECURITY'],
};
const mockDotenv: NewDotenv = {
content: 'TEST_PARAMETER=\nTEST_SECURITY=',
newEmptyEnvVariables: ['TEST_PARAMETER', 'TEST_SECURITY'],
};
const mockToken = { token: 'sfs_b31314b7fc8...8ec1930e' };
const providerJson = mockProviderJson({ name: providerName });
const userError = createUserError(false);
const ux = UX.create();
Expand Down Expand Up @@ -237,7 +247,8 @@ describe('MapCLI command', () => {

jest.mocked(prepareProject).mockResolvedValueOnce({
saved: true,
installationGuide: 'test',
dependencyInstallCommand: 'make install',
languageDependency: 'TestLang > 18',
path: 'test',
});

Expand All @@ -255,6 +266,9 @@ describe('MapCLI command', () => {
.mocked(writeApplicationCode)
.mockResolvedValueOnce(mockApplicationCode);

jest.mocked(fetchSDKToken).mockResolvedValueOnce(mockToken);
jest.mocked(createNewDotenv).mockReturnValueOnce(mockDotenv);

jest.mocked(mapProviderToProfile).mockResolvedValueOnce(mapSource);

await instance.execute({
Expand Down Expand Up @@ -292,7 +306,8 @@ describe('MapCLI command', () => {

jest.mocked(prepareProject).mockResolvedValueOnce({
saved: true,
installationGuide: 'test',
dependencyInstallCommand: 'make install',
languageDependency: 'TestLang > 18',
path: 'test',
});

Expand All @@ -310,6 +325,9 @@ describe('MapCLI command', () => {
.mocked(writeApplicationCode)
.mockResolvedValueOnce(mockApplicationCode);

jest.mocked(fetchSDKToken).mockResolvedValueOnce(mockToken);
jest.mocked(createNewDotenv).mockReturnValueOnce(mockDotenv);

jest.mocked(mapProviderToProfile).mockResolvedValueOnce(mapSource);

await instance.execute({
Expand Down Expand Up @@ -367,7 +385,8 @@ describe('MapCLI command', () => {

jest.mocked(prepareProject).mockResolvedValueOnce({
saved: true,
installationGuide: 'test',
dependencyInstallCommand: 'make install',
languageDependency: 'TestLang > 18',
path: 'test',
});

Expand All @@ -387,6 +406,9 @@ describe('MapCLI command', () => {
.mocked(writeApplicationCode)
.mockResolvedValueOnce(mockApplicationCode);

jest.mocked(fetchSDKToken).mockResolvedValueOnce(mockToken);
jest.mocked(createNewDotenv).mockReturnValueOnce(mockDotenv);

await instance.execute({
logger,
userError,
Expand Down Expand Up @@ -440,7 +462,8 @@ describe('MapCLI command', () => {

jest.mocked(prepareProject).mockResolvedValueOnce({
saved: true,
installationGuide: 'test',
dependencyInstallCommand: 'make install',
languageDependency: 'TestLang > 18',
path: 'test',
});

Expand All @@ -460,6 +483,9 @@ describe('MapCLI command', () => {
.mocked(writeApplicationCode)
.mockResolvedValueOnce(mockApplicationCode);

jest.mocked(fetchSDKToken).mockResolvedValueOnce(mockToken);
jest.mocked(createNewDotenv).mockReturnValueOnce(mockDotenv);

await instance.execute({
logger,
userError,
Expand Down
Loading

0 comments on commit 6409c1a

Please sign in to comment.