Skip to content
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
15 changes: 8 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,14 @@
"ajv": "^6.12.3",
"axios": "^0.21.1",
"chalk": "^2.4.2",
"dc-management-sdk-js": "^1.13.0",
"dc-management-sdk-js": "^1.14.0",
"lodash": "^4.17.21",
"node-fetch": "^2.6.1",
"promise-retry": "^2.0.1",
"rimraf": "^3.0.0",
"sanitize-filename": "^1.6.3",
"table": "^5.4.6",
"url-template": "^2.0.8",
"yargs": "^14.0.0"
},
"engines": {
Expand Down
1 change: 1 addition & 0 deletions src/__snapshots__/cli.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Commands:
dc-cli event Event
dc-cli extension Extension
dc-cli hub Hub
dc-cli search-index Search Index
dc-cli settings Settings

Options:
Expand Down
32 changes: 19 additions & 13 deletions src/commands/hub/clone.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import * as settings from './steps/settings-clone-step';
import * as schema from './steps/schema-clone-step';
import * as type from './steps/type-clone-step';
import * as extension from './steps/extension-clone-step';
import * as index from './steps/index-clone-step';

import rmdir from 'rimraf';
import { CloneHubBuilderOptions } from '../../interfaces/clone-hub-builder-options';
Expand All @@ -21,7 +22,7 @@ jest.mock('readline');

jest.mock('../../services/dynamic-content-client-factory');

let success = [true, true, true, true, true];
let success = [true, true, true, true, true, true];

// eslint-disable-next-line @typescript-eslint/no-explicit-any
function succeedOrFail(mock: any, succeed: () => boolean): jest.Mock {
Expand Down Expand Up @@ -55,8 +56,12 @@ jest.mock('./steps/type-clone-step', () => ({
TypeCloneStep: mockStep('Clone Content Types', 'types', () => success[3])
}));

jest.mock('./steps/index-clone-step', () => ({
IndexCloneStep: mockStep('Clone Indexes', 'index', () => success[4])
}));

jest.mock('./steps/content-clone-step', () => ({
ContentCloneStep: mockStep('Clone Content', 'content', () => success[4])
ContentCloneStep: mockStep('Clone Content', 'content', () => success[5])
}));

jest.mock('../../common/log-helpers', () => ({
Expand All @@ -76,6 +81,7 @@ function getMocks(): jest.Mock[] {
extension.ExtensionCloneStep as jest.Mock,
schema.SchemaCloneStep as jest.Mock,
type.TypeCloneStep as jest.Mock,
index.IndexCloneStep as jest.Mock,
content.ContentCloneStep as jest.Mock
];
}
Expand Down Expand Up @@ -264,7 +270,7 @@ describe('hub clone command', () => {

it('should call all steps in order with given parameters', async () => {
clearMocks();
success = [true, true, true, true, true];
success = [true, true, true, true, true, true];

const argv: Arguments<CloneHubBuilderOptions & ConfigurationParameters> = {
...yargArgs,
Expand Down Expand Up @@ -302,9 +308,9 @@ describe('hub clone command', () => {
});

it('should handle false returns from each of the steps by stopping the process', async () => {
for (let i = 0; i < 5; i++) {
for (let i = 0; i < 6; i++) {
clearMocks();
success = [i != 0, i != 1, i != 2, i != 3, i != 4];
success = [i != 0, i != 1, i != 2, i != 3, i != 4, i != 5];

const argv: Arguments<CloneHubBuilderOptions & ConfigurationParameters> = {
...yargArgs,
Expand Down Expand Up @@ -346,9 +352,9 @@ describe('hub clone command', () => {
});

it('should start from the step given as a parameter', async () => {
for (let i = 0; i < 5; i++) {
for (let i = 0; i < 6; i++) {
clearMocks();
success = [true, true, true, true, true];
success = [true, true, true, true, true, true];

const argv: Arguments<CloneHubBuilderOptions & ConfigurationParameters> = {
...yargArgs,
Expand Down Expand Up @@ -458,7 +464,7 @@ describe('hub clone command', () => {

it('should revert all steps in order with given parameters', async () => {
clearMocks();
success = [true, true, true, true, true];
success = [true, true, true, true, true, true];
await ensureDirectoryExists(`temp_${process.env.JEST_WORKER_ID}/clone-revert/`);
await prepareFakeLog(`temp_${process.env.JEST_WORKER_ID}/clone-revert/steps.log`);

Expand Down Expand Up @@ -498,9 +504,9 @@ describe('hub clone command', () => {
});

it('should handle exceptions from each of the revert steps by stopping the process', async () => {
for (let i = 0; i < 5; i++) {
for (let i = 0; i < 6; i++) {
clearMocks();
success = [i != 0, i != 1, i != 2, i != 3, i != 4];
success = [i != 0, i != 1, i != 2, i != 3, i != 4, i != 5];

await ensureDirectoryExists(`temp_${process.env.JEST_WORKER_ID}/clone-revert/`);
await prepareFakeLog(`temp_${process.env.JEST_WORKER_ID}/clone-revert/fail.log`);
Expand Down Expand Up @@ -547,7 +553,7 @@ describe('hub clone command', () => {

it('should exit early if revert log cannot be read', async () => {
clearMocks();
success = [true, true, true, true, true];
success = [true, true, true, true, true, true];
await ensureDirectoryExists(`temp_${process.env.JEST_WORKER_ID}/clone-revert/`);

const argv: Arguments<CloneHubBuilderOptions & ConfigurationParameters> = {
Expand Down Expand Up @@ -584,9 +590,9 @@ describe('hub clone command', () => {
});

it('should start reverting from the step given as a parameter (steps in decreasing order)', async () => {
for (let i = 0; i < 5; i++) {
for (let i = 0; i < 6; i++) {
clearMocks();
success = [true, true, true, true, true];
success = [true, true, true, true, true, true];

await ensureDirectoryExists(`temp_${process.env.JEST_WORKER_ID}/clone-revert/`);
await prepareFakeLog(`temp_${process.env.JEST_WORKER_ID}/clone-revert/step.log`);
Expand Down
3 changes: 3 additions & 0 deletions src/commands/hub/clone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { ContentCloneStep } from './steps/content-clone-step';
import { SchemaCloneStep } from './steps/schema-clone-step';
import { SettingsCloneStep } from './steps/settings-clone-step';
import { TypeCloneStep } from './steps/type-clone-step';
import { IndexCloneStep } from './steps/index-clone-step';
import { CloneHubState } from './model/clone-hub-state';
import { LogErrorLevel } from '../../common/archive/archive-log';
import { ExtensionCloneStep } from './steps/extension-clone-step';
Expand All @@ -28,6 +29,7 @@ export function getDefaultMappingPath(name: string, platform: string = process.p
// hub-*/extensions/
// hub-*/schemas/
// hub-*/types/
// hub-*/indexes/
// hub-*/content/
// hub-*/events/

Expand All @@ -44,6 +46,7 @@ export const steps = [
new ExtensionCloneStep(),
new SchemaCloneStep(),
new TypeCloneStep(),
new IndexCloneStep(),
new ContentCloneStep()
];

Expand Down
1 change: 1 addition & 0 deletions src/commands/hub/model/clone-hub-step.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export enum CloneHubStepId {
Extension = 'extension',
Schema = 'schema',
Type = 'type',
Index = 'index',
Content = 'content'
}

Expand Down
Loading