Skip to content
This repository has been archived by the owner on Jan 5, 2022. It is now read-only.

Commit

Permalink
Move pipeline config to new location (#62)
Browse files Browse the repository at this point in the history
* Move pipeline config to new location

* Adapt snapshots and tests

* Adapt snapshots and tests

* compare arrays

* compare arrays

* Extract helper function

* also use helper for other test

* also use helper for other test

* also use helper for other test

* also use helper for other test

* Format code
  • Loading branch information
fgeck authored Mar 31, 2020
1 parent 83c5993 commit d04208d
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/templates/scaffold-readme/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ $ ./cx-server start
```

Point the new Jenkins to your repository and it will automatically run the pipeline.
If the pipeline should deploy your application as well, you need to modify the `pipeline_config.yml`.
If the pipeline should deploy your application as well, you need to modify the `.pipeline/config.yml`.

## NestJS

Expand Down
87 changes: 70 additions & 17 deletions test/utils/__snapshots__/templates.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,91 @@
exports[`Templates Utils should copy files locally 1`] = `
Array [
".npmrc",
".pipeline",
"Jenkinsfile",
"credentials.json",
"deployment",
"manifest.yml",
"pipeline_config.yml",
"s4hana_pipeline",
"systems.json",
]
`;

exports[`Templates Utils should return information which files to copy where 1`] = `
Array [
".gitkeep",
".gitkeep",
".gitkeep",
".gitkeep",
".gitkeep",
".npmrc",
"Jenkinsfile",
"credentials.json",
"manifest.yml",
"pipeline_config.yml",
"systems.json",
Array [
".npmrc",
],
Array [
".pipeline",
"config.yml",
],
Array [
"Jenkinsfile",
],
Array [
"credentials.json",
],
Array [
"deployment",
".gitkeep",
],
Array [
"manifest.yml",
],
Array [
"s4hana_pipeline",
"reports",
"backend-integration",
".gitkeep",
],
Array [
"s4hana_pipeline",
"reports",
"backend-unit",
".gitkeep",
],
Array [
"s4hana_pipeline",
"reports",
"coverage-reports",
"backend-integration",
".gitkeep",
],
Array [
"s4hana_pipeline",
"reports",
"coverage-reports",
"backend-unit",
".gitkeep",
],
Array [
"systems.json",
],
]
`;

exports[`Templates Utils should return information which files to copy where 2`] = `
Array [
".npmrc",
"manifest.yml",
"package.json",
"xs-app.json",
"xs-security.json",
Array [
".npmrc",
"approuter",
],
Array [
"approuter",
"manifest.yml",
],
Array [
"approuter",
"package.json",
],
Array [
"approuter",
"xs-app.json",
],
Array [
"approuter",
"xs-security.json",
],
]
`;
12 changes: 9 additions & 3 deletions test/utils/templates.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import * as fs from 'fs';
import * as path from 'path';
import * as rm from 'rimraf';
import { copyFiles, findConflicts, getCopyDescriptors, getTemplatePaths } from '../../src/utils';
import { copyFiles, findConflicts, getCopyDescriptors, getTemplatePaths, CopyDescriptor } from '../../src/utils';
import { getCleanProjectDir, getTestOutputDir } from '../test-utils';

const testOutputDir = getTestOutputDir(__filename);
Expand All @@ -16,10 +16,10 @@ describe('Templates Utils', () => {

it('should return information which files to copy where', () => {
const initCopyInfo = getCopyDescriptors('targetDir', getTemplatePaths(['init']));
expect(initCopyInfo.map(copyInfo => path.basename(copyInfo.fileName)).sort()).toMatchSnapshot();
expect(initCopyInfo.map(copyInfo => copyInfoToPathArray(copyInfo)).sort()).toMatchSnapshot();

const appRouterCopyInfo = getCopyDescriptors('targetDir', getTemplatePaths(['add-approuter']));
expect(appRouterCopyInfo.map(copyInfo => path.basename(copyInfo.fileName)).sort()).toMatchSnapshot();
expect(appRouterCopyInfo.map(appRouterCopyInfo => copyInfoToPathArray(appRouterCopyInfo).sort())).toMatchSnapshot();
});

it('should find conflicts', async () => {
Expand All @@ -39,4 +39,10 @@ describe('Templates Utils', () => {
// it('should copy files remotely', async () => {
// const projectDir = getCleanProjectDir(testOutputDir, 'copy-files-remotely');
// });

function copyInfoToPathArray(copyInfo: CopyDescriptor): string[] {
const filePathBeginnginFromTargetDir = path.relative(path.resolve('targetDir'), copyInfo.fileName);
const filePathAsList = filePathBeginnginFromTargetDir.split(path.sep);
return filePathAsList;
}
});

0 comments on commit d04208d

Please sign in to comment.