cli: fix failing create tests on windows

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2021-11-16 01:52:56 +01:00
parent ad3afc5ad6
commit 6f279f9b8e
6 changed files with 27 additions and 22 deletions
@@ -16,6 +16,7 @@
import fs from 'fs-extra';
import mockFs from 'mock-fs';
import { sep, resolve as resolvePath } from 'path';
import { paths } from '../../paths';
import { Task } from '../../tasks';
import { FactoryRegistry } from '../FactoryRegistry';
@@ -75,7 +76,7 @@ describe('backendPlugin factory', () => {
'',
'Creating backend plugin backstage-plugin-test-backend',
'Checking Prerequisites:',
'availability plugins/test-backend',
`availability plugins${sep}test-backend`,
'creating temp dir',
'Executing Template:',
'copying .eslintrc.js',
@@ -89,7 +90,7 @@ describe('backendPlugin factory', () => {
'copying router.ts',
'templating standaloneServer.ts.hbs',
'Installing:',
'moving plugins/test-backend',
`moving plugins${sep}test-backend`,
'backend adding dependency',
]);
@@ -103,11 +104,11 @@ describe('backendPlugin factory', () => {
expect(Task.forCommand).toHaveBeenCalledTimes(2);
expect(Task.forCommand).toHaveBeenCalledWith('yarn install', {
cwd: '/root/plugins/test-backend',
cwd: resolvePath('/root/plugins/test-backend'),
optional: true,
});
expect(Task.forCommand).toHaveBeenCalledWith('yarn lint --fix', {
cwd: '/root/plugins/test-backend',
cwd: resolvePath('/root/plugins/test-backend'),
optional: true,
});
});
@@ -16,6 +16,7 @@
import fs from 'fs-extra';
import mockFs from 'mock-fs';
import { sep } from 'path';
import { createMockOutputStream, mockPaths } from './testUtils';
import { CreateContext } from '../../types';
import { executePluginPackageTemplate } from './tasks';
@@ -88,14 +89,14 @@ some-package@^1.1.0:
expect(modified).toBe(true);
expect(output).toEqual([
'Checking Prerequisites:',
'availability /target',
`availability ..${sep}target`,
'creating temp dir',
'Executing Template:',
'templating package.json.hbs',
'copying not-templated.txt',
'templating templated.txt.hbs',
'Installing:',
'moving /target',
`moving ..${sep}target`,
]);
await expect(fs.readFile('/target/package.json', 'utf8')).resolves.toBe(`{
"name": "my-testing-plugin",
@@ -16,7 +16,7 @@
import fs from 'fs-extra';
import chalk from 'chalk';
import { resolve as resolvePath } from 'path';
import { resolve as resolvePath, relative as relativePath } from 'path';
import { paths } from '../../../paths';
import { Task, templatingTask } from '../../../tasks';
import { Lockfile } from '../../../versioning';
@@ -41,7 +41,7 @@ export async function executePluginPackageTemplate(
}
Task.section('Checking Prerequisites');
const shortPluginDir = targetDir.replace(`${paths.targetRoot}/`, '');
const shortPluginDir = relativePath(paths.targetRoot, targetDir);
await Task.forItem('availability', shortPluginDir, async () => {
if (await fs.pathExists(targetDir)) {
throw new Error(
@@ -16,6 +16,7 @@
import fs from 'fs-extra';
import mockFs from 'mock-fs';
import { sep, resolve as resolvePath } from 'path';
import { paths } from '../../paths';
import { Task } from '../../tasks';
import { FactoryRegistry } from '../FactoryRegistry';
@@ -88,7 +89,7 @@ describe('frontendPlugin factory', () => {
'',
'Creating backend plugin backstage-plugin-test',
'Checking Prerequisites:',
'availability plugins/test',
`availability plugins${sep}test`,
'creating temp dir',
'Executing Template:',
'copying .eslintrc.js',
@@ -108,7 +109,7 @@ describe('frontendPlugin factory', () => {
'templating ExampleFetchComponent.tsx.hbs',
'copying index.ts',
'Installing:',
'moving plugins/test',
`moving plugins${sep}test`,
'app adding dependency',
'app adding import',
]);
@@ -136,11 +137,11 @@ const router = (
expect(Task.forCommand).toHaveBeenCalledTimes(2);
expect(Task.forCommand).toHaveBeenCalledWith('yarn install', {
cwd: '/root/plugins/test',
cwd: resolvePath('/root/plugins/test'),
optional: true,
});
expect(Task.forCommand).toHaveBeenCalledWith('yarn lint --fix', {
cwd: '/root/plugins/test',
cwd: resolvePath('/root/plugins/test'),
optional: true,
});
});
@@ -205,11 +206,11 @@ const router = (
expect(Task.forCommand).toHaveBeenCalledTimes(2);
expect(Task.forCommand).toHaveBeenCalledWith('yarn install', {
cwd: '/root/plugins/test',
cwd: resolvePath('/root/plugins/test'),
optional: true,
});
expect(Task.forCommand).toHaveBeenCalledWith('yarn lint --fix', {
cwd: '/root/plugins/test',
cwd: resolvePath('/root/plugins/test'),
optional: true,
});
});
@@ -16,6 +16,7 @@
import fs from 'fs-extra';
import mockFs from 'mock-fs';
import { sep, resolve as resolvePath } from 'path';
import { paths } from '../../paths';
import { Task } from '../../tasks';
import { FactoryRegistry } from '../FactoryRegistry';
@@ -70,7 +71,7 @@ describe('pluginCommon factory', () => {
'',
'Creating backend plugin backstage-plugin-test-common',
'Checking Prerequisites:',
'availability plugins/test-common',
`availability plugins${sep}test-common`,
'creating temp dir',
'Executing Template:',
'copying .eslintrc.js',
@@ -80,7 +81,7 @@ describe('pluginCommon factory', () => {
'templating index.ts.hbs',
'copying setupTests.ts',
'Installing:',
'moving plugins/test-common',
`moving plugins${sep}test-common`,
]);
await expect(
@@ -96,11 +97,11 @@ describe('pluginCommon factory', () => {
expect(Task.forCommand).toHaveBeenCalledTimes(2);
expect(Task.forCommand).toHaveBeenCalledWith('yarn install', {
cwd: '/root/plugins/test-common',
cwd: resolvePath('/root/plugins/test-common'),
optional: true,
});
expect(Task.forCommand).toHaveBeenCalledWith('yarn lint --fix', {
cwd: '/root/plugins/test-common',
cwd: resolvePath('/root/plugins/test-common'),
optional: true,
});
});
@@ -16,6 +16,7 @@
import fs from 'fs-extra';
import mockFs from 'mock-fs';
import { sep, resolve as resolvePath } from 'path';
import { paths } from '../../paths';
import { Task } from '../../tasks';
import { FactoryRegistry } from '../FactoryRegistry';
@@ -70,7 +71,7 @@ describe('scaffolderModule factory', () => {
'',
'Creating module backstage-plugin-scaffolder-backend-module-test',
'Checking Prerequisites:',
'availability plugins/scaffolder-backend-module-test',
`availability plugins${sep}scaffolder-backend-module-test`,
'creating temp dir',
'Executing Template:',
'copying .eslintrc.js',
@@ -83,7 +84,7 @@ describe('scaffolderModule factory', () => {
'copying example.ts',
'copying index.ts',
'Installing:',
'moving plugins/scaffolder-backend-module-test',
`moving plugins${sep}scaffolder-backend-module-test`,
]);
await expect(
@@ -99,11 +100,11 @@ describe('scaffolderModule factory', () => {
expect(Task.forCommand).toHaveBeenCalledTimes(2);
expect(Task.forCommand).toHaveBeenCalledWith('yarn install', {
cwd: '/root/plugins/scaffolder-backend-module-test',
cwd: resolvePath('/root/plugins/scaffolder-backend-module-test'),
optional: true,
});
expect(Task.forCommand).toHaveBeenCalledWith('yarn lint --fix', {
cwd: '/root/plugins/scaffolder-backend-module-test',
cwd: resolvePath('/root/plugins/scaffolder-backend-module-test'),
optional: true,
});
});