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

Commit

Permalink
Create custom README for scaffolded projects (#46)
Browse files Browse the repository at this point in the history
* Create custom README for scaffolded projects

* Adjust test

* Update snapshot
  • Loading branch information
Florian Richter authored Jan 9, 2020
1 parent 06f1edb commit ff5d4b5
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,16 @@ export default class Init extends Command {

private getTemplateNames(isScaffold: boolean, addCds: boolean): string[] {
const templates = ['init'];

if (addCds) {
templates.push('add-cds');
if (isScaffold) {
templates.push('add-cds-scaffold');
}
}
if (isScaffold) {
templates.push('scaffold-readme');
}

return templates;
}
Expand Down
71 changes: 71 additions & 0 deletions src/templates/scaffold-readme/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<a href="https://community.sap.com/topics/cloud-sdk"><img src="https://help.sap.com/doc/2324e9c3b28748a4ae2ad08166d77675/1.0/en-US/logo-with-js.svg" alt="SAP Cloud SDK for JavaScript Logo" height="122.92" width="226.773"/></a>

# Welcome to Your Application!

This is your **SAP Cloud Platform Cloud Foundry** application powered by the [SAP Cloud SDK for JavaScript](https://community.sap.com/topics/cloud-sdk) and [NestJS](https://nestjs.com/).

## Getting started

Everything is ready to go.

```bash
# Run the application locally
$ npm run start:dev

# Open the application in your default browser
$ open http://localhost:3000/
```

If you have the [Cloud Foundry CLI](https://docs.cloudfoundry.org/cf-cli/install-go-cli.html) and are [logged in](https://docs.cloudfoundry.org/cf-cli/getting-started.html#login), you can deploy the application without any changes to the application.

```bash
# Deploy your application to SAP Cloud Platform Cloud Foundry
$ cf push
```

## Testing

The project comes with unit and end-to-end tests.
Unit tests are located in the `src/` folder next to the modules and controllers, while end-to-end tests are in the `test/` folder.

```bash
# Run unit tests
$ npm run test

# Run e2e tests
$ npm run test:e2e
```

## Continuous Integration

This project is preconfigured to run with the [SAP Cloud SDK Pipeline](https://github.com/SAP/cloud-s4-sdk-pipeline).
To get the installer follow the short [guide](https://github.com/SAP/cloud-s4-sdk-pipeline#download-and-installation).

```bash
# If you have the SAP Cloud SDK CLI installed, it can download the install script for you
sap-cloud-sdk add-cx-server

# Execute the script to start the Jenkins server
$ ./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`.

## NestJS

NestJS is a progressive [Node.js](http://nodejs.org) framework for building efficient and scalable server-side applications, heavily inspired by [Angular](https://angular.io).

The [Nest CLI](https://docs.nestjs.com/cli/usages) is a powerful tool and can help you create new controllers, modules and interfaces.

## Support

If you need support with the SAP Cloud SDK, the SAP Cloud SDK CLI or this project scaffold, feel free to open an issue on [GitHub](https://github.com/SAP/cloud-sdk-cli) or ask a question on [stackoverflow with tag [sap-cloud-sdk]](https://stackoverflow.com/questions/tagged/sap-cloud-sdk).

## License and Notice

The SAP Cloud SDK CLI is licensed under the [Apache Software License, v. 2](https://github.com/SAP/cloud-sdk-cli/blob/master/LICENSE).
Nest is [MIT licensed](https://github.com/nestjs/nest/blob/master/LICENSE).

The SAP Cloud SDK is in no way affiliated with or endorsed by Nest and its maintainers.
While Nest is our recommendation, the SAP Cloud SDK can be used with any framework, so you are free to choose what you are comfortable with.
1 change: 1 addition & 0 deletions src/utils/scaffold.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export async function buildScaffold(projectDir: string, verbose: boolean, addCds

await execa('npx', ['-p', '@nestjs/cli', 'nest', 'new', '.', '--skip-install', '--package-manager', 'npm'], options);

fs.unlinkSync(path.resolve(projectDir, 'README.md'));
modifyMainTs(path.resolve(projectDir, 'src', 'main.ts'));
if (addCds) {
addCatalogueModule(path.resolve(projectDir, 'src', 'app.module.ts'));
Expand Down
1 change: 1 addition & 0 deletions test/init.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ describe('Init', () => {
});

const reportsPath = path.resolve(projectDir, 's4hana_pipeline', 'reports');
expect(fs.readFileSync(path.resolve(projectDir, 'README.md'), { encoding: 'utf8' })).toInclude('SAP Cloud SDK');

// execute the ci scripts and check if the reports are written
await execa('npm', ['run', 'ci-backend-unit-test'], { cwd: projectDir, stdio: 'inherit' });
Expand Down
1 change: 0 additions & 1 deletion test/utils/__snapshots__/scaffold.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ exports[`Scaffold Utils should build the scaffold 1`] = `
Array [
".git",
".gitignore",
"README.md",
"nest-cli.json",
"package.json",
"src",
Expand Down

0 comments on commit ff5d4b5

Please sign in to comment.