Skip to content
Open
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
4 changes: 2 additions & 2 deletions packages/contentstack-bootstrap/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@contentstack/cli-cm-bootstrap",
"description": "Bootstrap contentstack apps",
"version": "2.0.0-beta.12",
"version": "2.0.0-beta.13",
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"scripts": {
Expand All @@ -16,7 +16,7 @@
"test:report": "nyc --reporter=lcov mocha \"test/**/*.test.js\""
},
"dependencies": {
"@contentstack/cli-cm-seed": "~2.0.0-beta.11",
"@contentstack/cli-cm-seed": "~2.0.0-beta.12",
"@contentstack/cli-command": "~2.0.0-beta.3",
"@contentstack/cli-utilities": "~2.0.0-beta.3",
"@contentstack/cli-config": "~2.0.0-beta.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-seed/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@contentstack/cli-cm-seed",
"description": "create a Stack from existing content types, entries, assets, etc.",
"version": "2.0.0-beta.11",
"version": "2.0.0-beta.12",
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"dependencies": {
Expand Down
2 changes: 0 additions & 2 deletions packages/contentstack-seed/src/seed/importer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as fs from 'fs';
import * as process from 'process';
import * as path from 'path';
import ImportCommand from '@contentstack/cli-cm-import';
import { pathValidator, sanitizePath } from '@contentstack/cli-utilities';
Expand Down Expand Up @@ -29,6 +28,5 @@ export async function run(options: ImporterOptions) {
? ['-k', options.api_key, '-d', importPath, '--alias', options.alias!]
: ['-k', options.api_key, '-d', importPath];

process.chdir(options.tmpPath);
await ImportCommand.run(args.concat('--skip-audit'));
}
4 changes: 2 additions & 2 deletions packages/contentstack-seed/test/seed/github/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ describe('GitHubClient', () => {
const mockExtract = new Stream();

(zlib.createUnzip as jest.Mock) = jest.fn().mockReturnValue(mockUnzip);
(tar.extract as jest.Mock) = jest.fn().mockReturnValue(mockExtract);
(tar.extract as unknown as jest.Mock) = jest.fn().mockReturnValue(mockExtract);

// Mock pipe chain
mockStream.pipe = jest.fn().mockReturnValue(mockUnzip);
Expand All @@ -222,7 +222,7 @@ describe('GitHubClient', () => {
const mockExtract = new Stream();

(zlib.createUnzip as jest.Mock) = jest.fn().mockReturnValue(mockUnzip);
(tar.extract as jest.Mock) = jest.fn().mockReturnValue(mockExtract);
(tar.extract as unknown as jest.Mock) = jest.fn().mockReturnValue(mockExtract);

mockStream.pipe = jest.fn().mockReturnValue(mockUnzip);
mockUnzip.pipe = jest.fn().mockReturnValue(mockExtract);
Expand Down
16 changes: 0 additions & 16 deletions packages/contentstack-seed/test/seed/importer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ import ImportCommand from '@contentstack/cli-cm-import';
import * as path from 'node:path';
import * as cliUtilities from '@contentstack/cli-utilities';

// Mock process.chdir
const mockChdir = jest.fn();
jest.spyOn(process, 'chdir').mockImplementation(mockChdir);

describe('Importer', () => {
const mockOptions = {
master_locale: 'en-us',
Expand Down Expand Up @@ -52,7 +48,6 @@ describe('Importer', () => {
const expectedPath = path.resolve(mockOptions.tmpPath, 'stack');
expect(cliUtilities.pathValidator).toHaveBeenCalledWith(expectedPath);
expect(cliUtilities.sanitizePath).toHaveBeenCalledWith(mockOptions.tmpPath);
expect(mockChdir).toHaveBeenCalledWith(mockOptions.tmpPath);
expect(ImportCommand.run).toHaveBeenCalledWith(['-k', mockOptions.api_key, '-d', expectedPath, '--skip-audit']);
});

Expand Down Expand Up @@ -124,7 +119,6 @@ describe('Importer', () => {

const expectedPath = path.resolve(testPath, 'stack');
expect(cliUtilities.pathValidator).toHaveBeenCalledWith(expectedPath);
expect(mockChdir).toHaveBeenCalledWith(testPath);
}
});

Expand Down Expand Up @@ -159,16 +153,6 @@ describe('Importer', () => {
expect(cliUtilities.pathValidator).toHaveBeenCalled();
});

it('should change directory before running import', async () => {
await importer.run(mockOptions);

// Verify chdir is called before ImportCommand.run
const chdirCallOrder = mockChdir.mock.invocationCallOrder[0];
const importCallOrder = (ImportCommand.run as jest.Mock).mock.invocationCallOrder[0];

expect(chdirCallOrder).toBeLessThan(importCallOrder);
});

it('should handle import command errors', async () => {
const mockError = new Error('Import failed');
(ImportCommand.run as jest.Mock) = jest.fn().mockRejectedValue(mockError);
Expand Down
5 changes: 4 additions & 1 deletion packages/contentstack-seed/test/seed/interactive.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ const mockInquirer = {
prompt: jest.fn(),
};

jest.mock('inquirer', () => mockInquirer);
jest.mock('inquirer', () => ({
__esModule: true,
default: mockInquirer,
}));

import * as interactive from '../../src/seed/interactive';
import { Organization, Stack } from '../../src/seed/contentstack/client';
Expand Down
Loading