-
Notifications
You must be signed in to change notification settings - Fork 10
feat: Add manifest import/export commands #135
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
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,17 @@ | ||
| monday-apps-cli | ||
| ================= | ||
| # monday-apps-cli | ||
|
|
||
| monday.com cli tool for monday apps management. | ||
|
|
||
| <!-- toc --> | ||
| * [Usage](#usage) | ||
| * [Commands](#commands) | ||
|
|
||
| - [Usage](#usage) | ||
| - [Commands](#commands) | ||
| <!-- tocstop --> | ||
|
|
||
| # Usage | ||
|
|
||
| <!-- usage --> | ||
|
|
||
| ```sh-session | ||
| $ npm install -g @mondaycom/apps-cli | ||
| $ mapps COMMAND | ||
|
|
@@ -22,39 +23,53 @@ USAGE | |
| $ mapps COMMAND | ||
| ... | ||
| ``` | ||
|
|
||
| <!-- usagestop --> | ||
|
|
||
| # Commands | ||
|
|
||
| <!-- commands --> | ||
| * [`mapps api:generate`](#mapps-apigenerate) | ||
| * [`mapps app-features:build`](#mapps-app-featuresbuild) | ||
| * [`mapps app-features:create`](#mapps-app-featurescreate) | ||
| * [`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 api:generate`](#mapps-apigenerate) | ||
| - [`mapps app-features:build`](#mapps-app-featuresbuild) | ||
| - [`mapps app-features:create`](#mapps-app-featurescreate) | ||
| - [`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 app:promote`](#mapps-apppromote) | ||
| * [`mapps autocomplete [SHELL]`](#mapps-autocomplete-shell) | ||
| * [`mapps code:env`](#mapps-codeenv) | ||
| * [`mapps code:logs`](#mapps-codelogs) | ||
| * [`mapps code:push`](#mapps-codepush) | ||
|
|
||
| - [`mapps autocomplete [SHELL]`](#mapps-autocomplete-shell) | ||
| - [`mapps code:env`](#mapps-codeenv) | ||
| - [`mapps code:logs`](#mapps-codelogs) | ||
| - [`mapps code:push`](#mapps-codepush) | ||
|
|
||
| * [`mapps code:secret`](#mapps-codesecret) | ||
| * [`mapps code:status`](#mapps-codestatus) | ||
|
|
||
| - [`mapps code:status`](#mapps-codestatus) | ||
|
|
||
| * [`mapps database:connection-string`](#mapps-databaseconnection-string) | ||
| * [`mapps help [COMMANDS]`](#mapps-help-commands) | ||
| * [`mapps init`](#mapps-init) | ||
|
|
||
| - [`mapps help [COMMANDS]`](#mapps-help-commands) | ||
| - [`mapps init`](#mapps-init) | ||
|
|
||
| * [`mapps scheduler:create`](#mapps-schedulercreate) | ||
| * [`mapps scheduler:delete`](#mapps-schedulerdelete) | ||
| * [`mapps scheduler:list`](#mapps-schedulerlist) | ||
| * [`mapps scheduler:run`](#mapps-schedulerrun) | ||
| * [`mapps scheduler:update`](#mapps-schedulerupdate) | ||
| * [`mapps storage:export`](#mapps-storageexport) | ||
|
|
||
| - [`mapps manifest:export`](#mapps-manifestexport) | ||
| - [`mapps manifest:import`](#mapps-manifestimport) | ||
| - [`mapps storage:export`](#mapps-storageexport) | ||
|
|
||
| * [`mapps storage:remove-data`](#mapps-storageremove-data) | ||
| * [`mapps storage:search`](#mapps-storagesearch) | ||
| * [`mapps tunnel:create`](#mapps-tunnelcreate) | ||
|
|
||
| - [`mapps storage:search`](#mapps-storagesearch) | ||
| - [`mapps tunnel:create`](#mapps-tunnelcreate) | ||
|
|
||
| ## `mapps api:generate` | ||
|
|
||
|
|
@@ -202,7 +217,7 @@ EXAMPLES | |
| $ mapps app-version:list | ||
| ``` | ||
|
|
||
| _See code: [src/commands/app-version/list.ts](https://github.com/mondaycom/monday-apps-cli/blob/v4.7.2/src/commands/app-version/list.ts)_ | ||
| _See code: [src/commands/app-version/list.ts](https://github.com/mondaycom/monday-apps-cli/blob/v4.3.2/src/commands/app-version/list.ts)_ | ||
|
oricho123 marked this conversation as resolved.
Outdated
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The link doesn't even work |
||
|
|
||
| ## `mapps app:create` | ||
|
|
||
|
|
@@ -567,6 +582,58 @@ EXAMPLES | |
|
|
||
| _See code: [src/commands/init/index.ts](https://github.com/mondaycom/monday-apps-cli/blob/v4.7.2/src/commands/init/index.ts)_ | ||
|
|
||
| ## `mapps manifest:export` | ||
|
|
||
| export manifest. | ||
|
|
||
| ``` | ||
| USAGE | ||
| $ mapps manifest:export [--verbose] [--print-command] [-a <value>] [-v <value>] | ||
|
|
||
| FLAGS | ||
| -a, --appId=<value> App id (will export the live version) | ||
| -v, --appVersionId=<value> App version id | ||
|
|
||
| GLOBAL FLAGS | ||
| --print-command Print the command that was executed (optional). | ||
| --verbose Print advanced logs (optional). | ||
|
|
||
| DESCRIPTION | ||
| export manifest. | ||
|
|
||
| EXAMPLES | ||
| $ mapps manifest:export | ||
| ``` | ||
|
|
||
| _See code: [src/commands/manifest/export.ts](https://github.com/mondaycom/monday-apps-cli/blob/v4.3.2/src/commands/manifest/export.ts)_ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here, replace the version with |
||
|
|
||
| ## `mapps manifest:import` | ||
|
|
||
| Import manifest. | ||
|
|
||
| ``` | ||
| USAGE | ||
| $ mapps manifest:import [--verbose] [--print-command] [-p <value>] [-a <value>] [-v <value>] [-n] | ||
|
|
||
| FLAGS | ||
| -a, --appId=<value> App id (will create new draft version) | ||
| -n, --newApp Create new app | ||
| -p, --manifestPath=<value> Path of you manifest file in your machine | ||
| -v, --appVersionId=<value> App version id to override | ||
|
|
||
| GLOBAL FLAGS | ||
| --print-command Print the command that was executed (optional). | ||
| --verbose Print advanced logs (optional). | ||
|
|
||
| DESCRIPTION | ||
| Import manifest. | ||
|
|
||
| EXAMPLES | ||
| $ mapps manifest:import | ||
| ``` | ||
|
|
||
| _See code: [src/commands/manifest/import.ts](https://github.com/mondaycom/monday-apps-cli/blob/v4.3.2/src/commands/manifest/import.ts)_ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here |
||
|
|
||
| ## `mapps scheduler:create` | ||
|
|
||
| Create a new scheduler job for an app | ||
|
|
@@ -830,4 +897,5 @@ EXAMPLES | |
| ``` | ||
|
|
||
| _See code: [src/commands/tunnel/create.ts](https://github.com/mondaycom/monday-apps-cli/blob/v4.7.2/src/commands/tunnel/create.ts)_ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And here |
||
|
|
||
| <!-- commandsstop --> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| import { Flags } from '@oclif/core'; | ||
| import { Listr } from 'listr2'; | ||
|
|
||
| import { AuthenticatedCommand } from 'commands-base/authenticated-command'; | ||
| import { DynamicChoicesService } from 'services/dynamic-choices-service'; | ||
| import * as exportService from 'services/export-manifest-service'; | ||
| import { ExportCommandTasksContext } from 'types/commands/manifest-export'; | ||
| import logger from 'utils/logger'; | ||
|
|
||
| const MESSAGES = { | ||
| appId: 'App id (will export the live version)', | ||
| appVersionId: 'App version id', | ||
| path: 'Path to export your app manifest files to', | ||
| }; | ||
|
|
||
| export default class ManifestExport extends AuthenticatedCommand { | ||
| static description = 'export app manifest.'; | ||
| static withPrintCommand = false; | ||
| static examples = [ | ||
| '<%= config.bin %> <%= command.id %>', | ||
| '<%= config.bin %> <%= command.id %> -p ./exports', | ||
| '<%= config.bin %> <%= command.id %> --manifestPath ./my-manifests', | ||
| ]; | ||
|
|
||
| static flags = ManifestExport.serializeFlags({ | ||
| manifestPath: Flags.string({ | ||
| char: 'p', | ||
| description: MESSAGES.path, | ||
| }), | ||
| appId: Flags.string({ | ||
| char: 'a', | ||
| description: MESSAGES.appId, | ||
| }), | ||
| appVersionId: Flags.integer({ | ||
| char: 'i', | ||
| aliases: ['v'], | ||
| description: MESSAGES.appVersionId, | ||
| }), | ||
| }); | ||
|
|
||
| DEBUG_TAG = 'manifest_export'; | ||
|
|
||
| async getAppVersionId(appVersionId: number | undefined, appId: number | undefined): Promise<number> { | ||
| if (appVersionId) return appVersionId; | ||
|
|
||
| const latestDraftVersion = await DynamicChoicesService.chooseAppAndAppVersion(false, true, { | ||
| appId: Number(appId), | ||
| autoSelectVersion: false, | ||
| }); | ||
|
|
||
| return latestDraftVersion.appVersionId; | ||
| } | ||
|
|
||
| public async run(): Promise<void> { | ||
| try { | ||
| const { flags } = await this.parse(ManifestExport); | ||
| const { manifestPath, appId: appIdAsString, appVersionId: appVersionIdAsString } = flags; | ||
|
|
||
| let appId = appIdAsString ? Number(appIdAsString) : undefined; | ||
| let appVersionId = appVersionIdAsString ? Number(appVersionIdAsString) : undefined; | ||
|
|
||
| if (appVersionId && !appId) { | ||
| logger.error('App id is required when app version id is provided'); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| if (!appId && !appVersionId) { | ||
| appId = Number(await DynamicChoicesService.chooseApp()); | ||
| appVersionId = await this.getAppVersionId(undefined, appId); | ||
| } | ||
|
|
||
| this.preparePrintCommand(this, flags); | ||
|
|
||
| const tasks = new Listr<ExportCommandTasksContext>( | ||
| [ | ||
| { title: 'Validate app before exporting manifest', task: exportService.validateManifestTask }, | ||
| { title: 'Export app manifest', task: exportService.downloadManifestTask }, | ||
| ], | ||
| { ctx: { appVersionId, appId: appId!, manifestPath } }, | ||
| ); | ||
|
|
||
| await tasks.run(); | ||
| } catch (error) { | ||
| logger.debug(error, this.DEBUG_TAG); | ||
| process.exit(1); | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Go through all and check for duplications