Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
d047075
Feat: add command for generating app feature component
Feb 7, 2024
112ac16
Merge remote-tracking branch 'origin/master'
Feb 15, 2024
b0582dd
Merge remote-tracking branch 'origin/master'
Mar 13, 2024
55a7e98
Merge remote-tracking branch 'origin/master'
Mar 28, 2024
9a034ef
Merge remote-tracking branch 'origin/master'
May 26, 2024
c6d4a71
Merge remote-tracking branch 'origin/master'
Jun 18, 2024
4e51746
Merge remote-tracking branch 'origin/master'
Oct 1, 2024
f7718dc
Merge remote-tracking branch 'origin/master'
Dec 22, 2024
4f4fbbf
Feat: new command for importing app manifest
Dec 23, 2024
67b861c
Feat: new command for importing app manifest
Dec 23, 2024
750e8b4
Feat: new command for exporting app manifest
Dec 23, 2024
4aba485
[beta] Feat: new command for exporting app manifest
Dec 24, 2024
11bcb5d
[beta] Feat: new command for exporting app manifest
Dec 24, 2024
a393bb5
[beta] Feat: new command for exporting app manifest
Dec 24, 2024
beb70d0
[beta] Feat: new command for exporting app manifest
Dec 24, 2024
4a5ed0b
[beta] Feat: new command for exporting app manifest
Dec 24, 2024
d893002
[beta] Feat: bumping version
Dec 24, 2024
ba34576
Merge remote-tracking branch 'origin/master'
Dec 26, 2024
3805b5c
Merge branch 'refs/heads/master' into feat/tsemach/add-command-for-im…
Dec 26, 2024
95a7c0c
[beta] Feat: unzip manifest
Dec 26, 2024
228ca32
[beta] Feat: unzip manifest
Dec 26, 2024
890db85
[beta] Feat: unzip manifest
Dec 26, 2024
e9a3356
[beta] Feat: increase import timeout
Jan 2, 2025
7ea427c
Feat/tsemach/support dynamic fields for manifest (#117)
tsemachLi Feb 9, 2025
2f7b151
[beta] Add new validate task to export manifest command (#119)
Shaharshaki2 Feb 24, 2025
644c484
Feat/danieljak/support-flag-to-allow-missing-variables (#124)
dh94 May 25, 2025
7a0fa34
[beta] allow missing variables
Shaharshaki2 May 25, 2025
31f9011
[beta] Feat/shaharsh/support customize path for import and export man…
Shaharshaki2 Aug 14, 2025
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
250 changes: 198 additions & 52 deletions README.md

Large diffs are not rendered by default.

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.5" };
export default { name: '@mondaycom/apps-cli', version: '4.3.2' };
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mondaycom/apps-cli",
"version": "4.4.0",
"version": "4.4.0-beta.10",
"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 @@ -53,6 +53,7 @@
"@oclif/core": "^3.18.1",
"@oclif/plugin-autocomplete": "^3.0.5",
"@oclif/plugin-help": "^6.0.12",
"adm-zip": "^0.5.16",
"archiver": "^5.3.1",
"args-parser": "^1.3.0",
"axios": "^1.6.5",
Expand All @@ -65,6 +66,7 @@
"fs-extra": "^11.2.0",
"fuzzy": "^0.1.3",
"glob": "^8.1.0",
"handlebars": "^4.7.8",
"http-status-codes": "^2.2.0",
"inquirer": "^8.2.6",
"inquirer-autocomplete-prompt": "^2.0.0",
Expand All @@ -83,10 +85,12 @@
"zod": "^3.20.2"
},
"devDependencies": {
"@types/adm-zip": "^0.5.7",
"@types/archiver": "^5.3.1",
"@types/figlet": "^1.5.5",
"@types/fs-extra": "^11.0.4",
"@types/glob": "^8.0.0",
"@types/handlebars": "^4.1.0",
"@types/inquirer": "^8.2.10",
"@types/inquirer-autocomplete-prompt": "^2.0.2",
"@types/jest": "^29.5.6",
Expand Down
4 changes: 2 additions & 2 deletions src/commands/api/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default class ApiGenerate extends BaseCommand {
DEBUG_TAG = 'api:generate';

static description = `Prepares your environment for custom queries development. run it from your root directory!
Creates all neccesary files and scripts
Creates all necessary files and scripts
to start working with custom api queries and mutations.
Read the documentation at [@mondaydotcomorg/setup-api](https://github.com/mondaycom/monday-graphql-api/tree/main/packages/setup-api)`;

Expand All @@ -24,7 +24,7 @@ export default class ApiGenerate extends BaseCommand {

runSetupApi() {
return new Promise<void>((resolve, reject) => {
const setupApiProcess = spawn('npx', ['@mondaydotcomorg/setup-api@^1.0.0'], { stdio: 'inherit' });
const setupApiProcess = spawn('npx', ['@mondaydotcomorg/setup-api@^1.3.6'], { stdio: 'inherit' });

setupApiProcess.on('close', code => {
if (code === 0) {
Expand Down
88 changes: 88 additions & 0 deletions src/commands/manifest/export.ts
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);
}
}
}
121 changes: 121 additions & 0 deletions src/commands/manifest/import.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
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 importService from 'services/import-manifest-service';
import { PromptService } from 'services/prompt-service';
import { ImportCommandTasksContext } from 'types/commands/manifest-import';
import logger from 'utils/logger';

const MESSAGES = {
path: 'Path to your app manifest file on your machine',
appId: 'App id (will create a new draft version)',
appVersionId: 'App version id to override',
newApp: 'Create new app',
allowMissingVariables: 'Allow missing variables',
};

export default class ManifestImport extends AuthenticatedCommand {
static description = 'Import manifest with optional template variables.';
static withPrintCommand = false;
static examples = [
'<%= config.bin %> <%= command.id %>',
'<%= config.bin %> <%= command.id %> -p ./manifest.json',
'<%= config.bin %> <%= command.id %> --manifestPath ./manifest.json',
];

static flags = ManifestImport.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,
}),
newApp: Flags.boolean({
description: MESSAGES.newApp,
char: 'n',
aliases: ['new'],
default: false,
}),
allowMissingVariables: Flags.boolean({
description: MESSAGES.allowMissingVariables,
char: 'm',
aliases: ['allow-missing-variables'],
default: false,
}),
});

DEBUG_TAG = 'manifest_import';

async getAppVersionId(appVersionId: number | undefined, appId: number | undefined): Promise<number> {
if (appVersionId) return appVersionId;

const latestDraftVersion = await DynamicChoicesService.chooseAppAndAppVersion(false, false, {
appId: Number(appId),
autoSelectVersion: false,
});

return latestDraftVersion.appVersionId;
}

public async run(): Promise<void> {
try {
const { flags } = await this.parse(ManifestImport);
const { manifestPath: initialManifestPath } = flags;
const { appId: appIdAsString, appVersionId: appVersionIdAsString, newApp, allowMissingVariables } = flags;
let manifestPath = initialManifestPath;
let appId = appIdAsString ? Number(appIdAsString) : undefined;
let appVersionId = appVersionIdAsString ? Number(appVersionIdAsString) : undefined;

if (!manifestPath) {
manifestPath = await PromptService.promptFile(MESSAGES.path, ['json', 'yaml']);
}

const shouldCreateNewApp = await importService.shouldCreateNewApp({ appId, appVersionId, newApp });
if (!shouldCreateNewApp) {
appId = await DynamicChoicesService.chooseApp();
}

const shouldCreateNewAppVersion = await importService.shouldCreateNewAppVersion({
appId,
appVersionId,
newApp: shouldCreateNewApp,
});

if (!shouldCreateNewAppVersion && !shouldCreateNewApp) {
appVersionId = await this.getAppVersionId(appVersionId, appId);
}

if (appVersionId && !appId) {
logger.error('App id is required when app version id is provided', this.DEBUG_TAG);
process.exit(1);
}

this.preparePrintCommand(this, { appVersionId, manifestPath, appId, newApp: shouldCreateNewApp });

const ctx = {
appVersionId,
appId,
manifestFilePath: manifestPath,
allowMissingVariables,
};
const tasks = new Listr<ImportCommandTasksContext>(
[{ title: 'Importing app manifest', task: importService.uploadManifestTsk }],
{ ctx },
);

await tasks.run();
} catch (error) {
logger.debug(error, this.DEBUG_TAG);
process.exit(1);
}
}
}
16 changes: 16 additions & 0 deletions src/consts/urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,19 @@ export const promoteAppUrl = (appId: AppId): string => {
export const pullPromoteStatusUrl = (path: string): string => {
return `${BASE_URL}/${path}`;
};

export const createAppFromManifestUrl = (): string => {
return `${BASE_APPS_URL}/manifest`;
};

export const updateAppFromManifestUrl = (appId: AppId): string => {
return `${BASE_APPS_URL}/${appId}/manifest`;
};

export const exportAppManifestUrl = (appId: AppId): string => {
return `${BASE_APPS_URL}/${appId}/manifest?zipBase64=true`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you need the zipBase64=true?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default is getting the zip in the response as buffer, which is harder to "catch" it programatically.
Here we getting it as base64 string and we can easily dump it to a file

};

export const makeAppManifestExportableUrl = (appId: AppId): string => {
return `${BASE_APPS_URL}/${appId}/manifest/exportability`;
};
35 changes: 35 additions & 0 deletions src/services/__tests__/import-manifest-service.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { processManifestTemplate } from 'services/import-manifest-service';
import { loadFile } from 'utils/file-system';

jest.mock('utils/file-system');

describe('processManifestTemplate', () => {
const mockLoadFile = loadFile as jest.MockedFunction<typeof loadFile>;
const mockPath = 'path/to/manifest.json';

beforeEach(() => {
jest.clearAllMocks();
});

it('should process valid manifest with environment variables', async () => {
process.env.TEST_VAR = 'test-value';
mockLoadFile.mockResolvedValue('{"key": "{{TEST_VAR}}"}');

const result = await processManifestTemplate(mockPath);
expect(result).toEqual({ key: 'test-value' });
});

it('should throw TypeError for invalid JSON', async () => {
mockLoadFile.mockResolvedValue('invalid json');

await expect(processManifestTemplate(mockPath)).rejects.toThrow(TypeError);
await expect(processManifestTemplate(mockPath)).rejects.toThrow(/Failed to parse manifest file/);
});

it('should throw error for missing environment variables', async () => {
delete process.env.MISSING_VAR;
mockLoadFile.mockResolvedValue('{"key": "{{MISSING_VAR}}"}');

await expect(processManifestTemplate(mockPath)).rejects.toThrow(/Missing variable/);
});
});
12 changes: 6 additions & 6 deletions src/services/__tests__/mocks/invalid-manifest-mock.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
app:
scopes:
- name: "test"
type: "user"
- name: 'test'
type: 'user'
permissions:
- "read"
- "write"
- 'read'
- 'write'
hosting:
cdn:
type: upload
path: "./build"
path: './build'
server:
type: upload
path: "./server"
path: './server'
version: 1.0.0
4 changes: 2 additions & 2 deletions src/services/__tests__/mocks/manifest-mock.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ app:
hosting:
cdn:
type: upload
path: "./build"
path: './build'
server:
type: upload
path: "./server"
path: './server'
version: 1.0.0
2 changes: 1 addition & 1 deletion src/services/api-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export async function execute<T extends BaseResponseHttpMetaData>(
});

logger.debug({ res: response }, DEBUG_TAG);
const result = { ...response.data, statusCode: 200, headers: response.headers };
const result = { ...response.data, statusCode: 200, headers: response.headers, data: response.data };
const validatedResult = validateResponseIfError(result, schemaValidator);
return (validatedResult as T) || result;
} catch (error: any | Error | AxiosError) {
Expand Down
Loading
Loading