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/tsemach/support create app from template #83

Merged
merged 14 commits into from
Feb 13, 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
60 changes: 44 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ $ npm install -g @mondaycom/apps-cli
$ mapps COMMAND
running command...
$ mapps (--version)
@mondaycom/apps-cli/2.3.0 darwin-arm64 node-v18.12.1
@mondaycom/apps-cli/2.3.2 darwin-arm64 node-v18.12.1
$ mapps --help [COMMAND]
USAGE
$ mapps COMMAND
Expand All @@ -32,6 +32,7 @@ USAGE
* [`mapps app-features:list`](#mapps-app-featureslist)
* [`mapps app-version:builds`](#mapps-app-versionbuilds)
* [`mapps app-version:list`](#mapps-app-versionlist)
* [`mapps app:create`](#mapps-appcreate)
* [`mapps app:deploy`](#mapps-appdeploy)
* [`mapps app:list`](#mapps-applist)
* [`mapps autocomplete [SHELL]`](#mapps-autocomplete-shell)
Expand Down Expand Up @@ -73,7 +74,7 @@ EXAMPLES
$ mapps app-features:build -a APP_ID -i APP_VERSION_ID -d APP_FEATURE_ID -t BUILD_TYPE -u CUSTOM_URL
```

_See code: [src/commands/app-features/build.ts](https://github.com/mondaycom/monday-code-cli/blob/v2.3.0/src/commands/app-features/build.ts)_
_See code: [src/commands/app-features/build.ts](https://github.com/mondaycom/monday-code-cli/blob/v2.3.2/src/commands/app-features/build.ts)_

## `mapps app-features:create`

Expand All @@ -100,7 +101,7 @@ EXAMPLES
$ mapps app-features:create -a APP_ID -i APP_VERSION_ID -t APP-FEATURE-TYPE
```

_See code: [src/commands/app-features/create.ts](https://github.com/mondaycom/monday-code-cli/blob/v2.3.0/src/commands/app-features/create.ts)_
_See code: [src/commands/app-features/create.ts](https://github.com/mondaycom/monday-code-cli/blob/v2.3.2/src/commands/app-features/create.ts)_

## `mapps app-features:list`

Expand All @@ -125,7 +126,7 @@ EXAMPLES
$ mapps app-features:list -a APP_ID -i APP_VERSION_ID
```

_See code: [src/commands/app-features/list.ts](https://github.com/mondaycom/monday-code-cli/blob/v2.3.0/src/commands/app-features/list.ts)_
_See code: [src/commands/app-features/list.ts](https://github.com/mondaycom/monday-code-cli/blob/v2.3.2/src/commands/app-features/list.ts)_

## `mapps app-version:builds`

Expand All @@ -149,7 +150,7 @@ EXAMPLES
$ mapps app-version:builds -i APP_VERSION_ID
```

_See code: [src/commands/app-version/builds.ts](https://github.com/mondaycom/monday-code-cli/blob/v2.3.0/src/commands/app-version/builds.ts)_
_See code: [src/commands/app-version/builds.ts](https://github.com/mondaycom/monday-code-cli/blob/v2.3.2/src/commands/app-version/builds.ts)_

## `mapps app-version:list`

Expand All @@ -173,7 +174,34 @@ EXAMPLES
$ mapps app-version:list
```

_See code: [src/commands/app-version/list.ts](https://github.com/mondaycom/monday-code-cli/blob/v2.3.0/src/commands/app-version/list.ts)_
_See code: [src/commands/app-version/list.ts](https://github.com/mondaycom/monday-code-cli/blob/v2.3.2/src/commands/app-version/list.ts)_

## `mapps app:create`

Create an app.

```
USAGE
$ mapps app:create [--verbose] [--print-command] [-n <value>] [-d <value>]

FLAGS
-d, --targetDir=<value> Directory to create the app in.
-n, --name=<value> Name your new app.

GLOBAL FLAGS
--print-command Print the command that was executed (optional).
--verbose Print advanced logs (optional).

DESCRIPTION
Create an app.

EXAMPLES
$ mapps app:create

$ mapps app:create -n NEW_APP_NAME
```

_See code: [src/commands/app/create.ts](https://github.com/mondaycom/monday-code-cli/blob/v2.3.2/src/commands/app/create.ts)_

## `mapps app:deploy`

Expand Down Expand Up @@ -201,7 +229,7 @@ EXAMPLES
$ mapps app:deploy
```

_See code: [src/commands/app/deploy.ts](https://github.com/mondaycom/monday-code-cli/blob/v2.3.0/src/commands/app/deploy.ts)_
_See code: [src/commands/app/deploy.ts](https://github.com/mondaycom/monday-code-cli/blob/v2.3.2/src/commands/app/deploy.ts)_

## `mapps app:list`

Expand All @@ -222,7 +250,7 @@ EXAMPLES
$ mapps app:list
```

_See code: [src/commands/app/list.ts](https://github.com/mondaycom/monday-code-cli/blob/v2.3.0/src/commands/app/list.ts)_
_See code: [src/commands/app/list.ts](https://github.com/mondaycom/monday-code-cli/blob/v2.3.2/src/commands/app/list.ts)_

## `mapps autocomplete [SHELL]`

Expand Down Expand Up @@ -282,7 +310,7 @@ EXAMPLES
$ mapps code:env
```

_See code: [src/commands/code/env.ts](https://github.com/mondaycom/monday-code-cli/blob/v2.3.0/src/commands/code/env.ts)_
_See code: [src/commands/code/env.ts](https://github.com/mondaycom/monday-code-cli/blob/v2.3.2/src/commands/code/env.ts)_

## `mapps code:logs`

Expand Down Expand Up @@ -315,7 +343,7 @@ EXAMPLES
$ mapps code:logs -i APP_VERSION_ID -t LOGS_TYPE
```

_See code: [src/commands/code/logs.ts](https://github.com/mondaycom/monday-code-cli/blob/v2.3.0/src/commands/code/logs.ts)_
_See code: [src/commands/code/logs.ts](https://github.com/mondaycom/monday-code-cli/blob/v2.3.2/src/commands/code/logs.ts)_

## `mapps code:push`

Expand Down Expand Up @@ -347,7 +375,7 @@ EXAMPLES
$ mapps code:push -a APP_ID_TO_PUSH
```

_See code: [src/commands/code/push.ts](https://github.com/mondaycom/monday-code-cli/blob/v2.3.0/src/commands/code/push.ts)_
_See code: [src/commands/code/push.ts](https://github.com/mondaycom/monday-code-cli/blob/v2.3.2/src/commands/code/push.ts)_

## `mapps code:status`

Expand All @@ -371,7 +399,7 @@ EXAMPLES
$ mapps code:status -i APP_VERSION_ID
```

_See code: [src/commands/code/status.ts](https://github.com/mondaycom/monday-code-cli/blob/v2.3.0/src/commands/code/status.ts)_
_See code: [src/commands/code/status.ts](https://github.com/mondaycom/monday-code-cli/blob/v2.3.2/src/commands/code/status.ts)_

## `mapps help [COMMANDS]`

Expand Down Expand Up @@ -416,7 +444,7 @@ EXAMPLES
$ mapps init -t SECRET_TOKEN
```

_See code: [src/commands/init/index.ts](https://github.com/mondaycom/monday-code-cli/blob/v2.3.0/src/commands/init/index.ts)_
_See code: [src/commands/init/index.ts](https://github.com/mondaycom/monday-code-cli/blob/v2.3.2/src/commands/init/index.ts)_

## `mapps storage:export`

Expand All @@ -443,7 +471,7 @@ EXAMPLES
$ mapps storage:export -a APP_ID -c CLIENT_ACCOUNT_ID -d FILE_FULL_PATH -f FILE_FORMAT
```

_See code: [src/commands/storage/export.ts](https://github.com/mondaycom/monday-code-cli/blob/v2.3.0/src/commands/storage/export.ts)_
_See code: [src/commands/storage/export.ts](https://github.com/mondaycom/monday-code-cli/blob/v2.3.2/src/commands/storage/export.ts)_

## `mapps storage:search`

Expand All @@ -469,7 +497,7 @@ EXAMPLES
$ mapps storage:search -a APP_ID -c CLIENT_ACCOUNT_ID -t TERM
```

_See code: [src/commands/storage/search.ts](https://github.com/mondaycom/monday-code-cli/blob/v2.3.0/src/commands/storage/search.ts)_
_See code: [src/commands/storage/search.ts](https://github.com/mondaycom/monday-code-cli/blob/v2.3.2/src/commands/storage/search.ts)_

## `mapps tunnel:create`

Expand Down Expand Up @@ -500,5 +528,5 @@ EXAMPLES
$ mapps tunnel:create -p PORT_FOR_TUNNEL -a APP_ID_FOR_TUNNEL
```

_See code: [src/commands/tunnel/create.ts](https://github.com/mondaycom/monday-code-cli/blob/v2.3.0/src/commands/tunnel/create.ts)_
_See code: [src/commands/tunnel/create.ts](https://github.com/mondaycom/monday-code-cli/blob/v2.3.2/src/commands/tunnel/create.ts)_
<!-- commandsstop -->
2 changes: 1 addition & 1 deletion bin/minimal-package.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export default { name: "@mondaycom/apps-cli", version: "2.3.0" };
export default { name: "@mondaycom/apps-cli", version: "2.3.2" };
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mondaycom/apps-cli",
"version": "2.3.1",
"version": "2.3.2",
"description": "A cli tool to manage apps (and monday-code projects) in monday.com",
"author": "monday.com Apps Team",
"type": "module",
Expand Down Expand Up @@ -61,7 +61,9 @@
"date-fns": "^2.30.0",
"enquirer": "^2.3.6",
"figlet": "^1.5.2",
"fs-extra": "^11.2.0",
"fuzzy": "^0.1.3",
"git-clone": "^0.2.0",
"glob": "^8.1.0",
"http-status-codes": "^2.2.0",
"inquirer": "^8.2.6",
Expand All @@ -77,12 +79,15 @@
"pino-pretty": "^10.0.1",
"postinstall-postinstall": "^2.1.0",
"pusher-js": "^8.0.1",
"simple-git": "^3.22.0",
"update-notifier": "^6.0.2",
"zod": "^3.20.2"
},
"devDependencies": {
"@types/archiver": "^5.3.1",
"@types/figlet": "^1.5.5",
"@types/fs-extra": "^11.0.4",
"@types/git-clone": "^0.2.3",
"@types/glob": "^8.0.0",
"@types/inquirer": "^8.2.10",
"@types/inquirer-autocomplete-prompt": "^2.0.2",
Expand Down
111 changes: 106 additions & 5 deletions src/commands/app/__tests__/create.test.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,122 @@
import AppCreate from 'commands/app/create';
import { buildMockFlags, getStdout, mockRequestResolvedValueOnce } from 'test/cli-test-utils';
import { APP_TEMPLATES_CONFIG } from 'consts/app-templates-config';
import { APP_VERSION_STATUS } from 'consts/app-versions';
import {
createAppUrl,
getCreateAppFeatureReleaseUrl,
getCreateAppFeatureUrl,
getTunnelingDomainUrl,
listAppVersionsByAppIdUrl,
} from 'consts/urls';
import {
buildMockFlags,
getRequestSpy,
getStdout,
mockSelectionWithAutoCompleteImplementation,
resetMockSelectionWithAutoCompleteImplementation,
} from 'test/cli-test-utils';
import { getLastParam } from 'utils/urls-builder';

const requestSpy = getRequestSpy();

describe('app:create', () => {
jest.setTimeout(1_000_000);
const MOCK_BASE_RESPONSE = { headers: {} };
const MOCK_APP_ID = 1_000_000_001;
const MOCK_APP_VERSION_ID = 1_000_000_002;
const MOCK_APP_FEATURE_ID = 1_000_000_003;

const mockAppCreateResponse = {
app: {
id: 1_000_000_001,
id: MOCK_APP_ID,
name: 'New App by CLI',
},
};

const mockAppVersionsResponse = {
appVersions: [
{
id: MOCK_APP_VERSION_ID,
name: 'v1.0.0',
versionNumber: '1.0.0',
appId: MOCK_APP_ID,
status: APP_VERSION_STATUS.DRAFT,
},
],
};

const mockAppFeaturesResponse = {
app_feature: {

Check failure on line 49 in src/commands/app/__tests__/create.test.ts

View workflow job for this annotation

GitHub Actions / Run validations

Identifier 'app_feature' is not in camel case
id: MOCK_APP_FEATURE_ID,
appVersionId: MOCK_APP_VERSION_ID,
type: 'web',
name: 'New Feature',
state: 'active',
},
};

const mockAppFeatureBuildResponse = {
app_feature: {

Check failure on line 59 in src/commands/app/__tests__/create.test.ts

View workflow job for this annotation

GitHub Actions / Run validations

Identifier 'app_feature' is not in camel case
id: MOCK_APP_FEATURE_ID,
appVersionId: MOCK_APP_VERSION_ID,
type: 'web',
name: 'New Feature',
state: 'active',
kind: 'private',
},
};

const mockTunnelingDomainResponse = {
domain: 'abcdefgh.monday.mock',
};

afterEach(() => {
resetMockSelectionWithAutoCompleteImplementation();
});

it('should create app successfully', async () => {
const question = 'Select a template to start with';
const selectedTemplate = APP_TEMPLATES_CONFIG[0];
const answer = selectedTemplate.name;

const mockPushFlags = buildMockFlags(AppCreate, { name: 'New App by CLI' });
mockRequestResolvedValueOnce(mockAppCreateResponse);
mockSelectionWithAutoCompleteImplementation([{ question, answer }]);

requestSpy.mockImplementation(async config => {
if (config.url!.endsWith(createAppUrl())) {
return { data: mockAppCreateResponse, ...MOCK_BASE_RESPONSE };
}

if (config.url!.endsWith(getTunnelingDomainUrl())) {
return { data: mockTunnelingDomainResponse, ...MOCK_BASE_RESPONSE };
}

if (config.url!.endsWith(listAppVersionsByAppIdUrl(mockAppCreateResponse.app.id))) {
console.log('listAppVersionsByAppIdUrl mocked');
return { data: mockAppVersionsResponse, ...MOCK_BASE_RESPONSE };
}

if (
config.url!.endsWith(
getCreateAppFeatureUrl(mockAppCreateResponse.app.id, mockAppVersionsResponse.appVersions[0].id),
)
) {
return { data: mockAppFeaturesResponse, ...MOCK_BASE_RESPONSE };
}

if (
config.url!.endsWith(
getCreateAppFeatureReleaseUrl(
mockAppCreateResponse.app.id,
mockAppFeaturesResponse.app_feature.appVersionId,
mockAppFeaturesResponse.app_feature.id,
),
)
) {
return { data: mockAppFeatureBuildResponse, ...MOCK_BASE_RESPONSE };
}
});
await AppCreate.run(mockPushFlags);
const stdout = getStdout();
expect(stdout).toContain('App created successfully: New App by CLI (id: 1000000001)');
expect(stdout).toContain(`'cd ${getLastParam(selectedTemplate.folder)}' to see your app files.`);
});
});
2 changes: 2 additions & 0 deletions src/commands/app/__tests__/list.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ describe('app:list', () => {
it('should list apps if exists', async () => {
mockRequestResolvedValueOnce(mockAppListResponse);
await AppList.run();

// requires investigation - This should work with getStderr
const stdout = getStdout();
expect(stdout).toContain('app1');
expect(stdout).toContain('app2');
Expand Down
Loading
Loading