update with PR comments
Signed-off-by: Rogerio Angeliski <angeliski@hotmail.com>
This commit is contained in:
@@ -11,7 +11,10 @@ Here you can find all Rails related features to improve your scaffolder:
|
||||
|
||||
You need to configure the action in your backend:
|
||||
|
||||
## From your Backstage root directory
|
||||
|
||||
```
|
||||
cd packages/backend
|
||||
yarn add @backstage/plugin-scaffolder-backend-module-rails
|
||||
```
|
||||
|
||||
@@ -222,4 +225,25 @@ spec:
|
||||
entityRef: '{{ steps.register.output.entityRef }}'
|
||||
```
|
||||
|
||||
We have a [Docker image](https://github.com/backstage/backstage/blob/master/plugins/scaffolder-backend-module-rails/Rails.dockerfile) you can use to build your own.
|
||||
### What you need to run that action
|
||||
|
||||
The environment need to have a [rails](https://github.com/rails/rails#getting-started) installation, or you can build and provide a docker image in your template.
|
||||
|
||||
We have a [Dockerfile](https://github.com/backstage/backstage/blob/master/plugins/scaffolder-backend-module-rails/Rails.dockerfile) that you can use to build your image.
|
||||
|
||||
If you choose to provide a docker image, you need to update your template with `imageName` parameter:
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- id: fetch-base
|
||||
name: Fetch Base
|
||||
action: fetch:rails
|
||||
input:
|
||||
url: ./template
|
||||
imageName: repository/rails:tag
|
||||
values:
|
||||
name: '{{ parameters.name }}'
|
||||
owner: '{{ parameters.owner }}'
|
||||
system: '{{ parameters.system }}'
|
||||
railsArguments: '{{ json parameters.railsArguments }}'
|
||||
```
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
FROM ruby:3.0
|
||||
|
||||
RUN apt-get update -qq && \
|
||||
apt-get install -y \
|
||||
nodejs \
|
||||
postgresql-client \
|
||||
git
|
||||
apt-get install -y nodejs postgresql-client git && \
|
||||
rm -rf /var/lib/apt/lists/
|
||||
|
||||
RUN gem install rails
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
"main": "src/index.ts",
|
||||
"types": "src/index.ts",
|
||||
"license": "Apache-2.0",
|
||||
"private": false,
|
||||
"publishConfig": {
|
||||
"access": "public",
|
||||
"main": "dist/index.esm.js",
|
||||
|
||||
@@ -34,7 +34,7 @@ import {
|
||||
} from '@backstage/backend-common';
|
||||
import { ConfigReader } from '@backstage/config';
|
||||
import { ScmIntegrations } from '@backstage/integration';
|
||||
import mock from 'mock-fs';
|
||||
import mockFs from 'mock-fs';
|
||||
import os from 'os';
|
||||
import { resolve as resolvePath } from 'path';
|
||||
import { PassThrough } from 'stream';
|
||||
@@ -86,12 +86,12 @@ describe('fetch:rails', () => {
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
mock({ [`${mockContext.workspacePath}/result`]: {} });
|
||||
mockFs({ [`${mockContext.workspacePath}/result`]: {} });
|
||||
jest.restoreAllMocks();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
mock.restore();
|
||||
mockFs.restore();
|
||||
});
|
||||
|
||||
it('should call fetchContents with the correct values', async () => {
|
||||
|
||||
+8
-2
@@ -15,9 +15,12 @@
|
||||
*/
|
||||
|
||||
import { railsArgumentResolver } from './railsArgumentResolver';
|
||||
import { sep as separatorPath } from 'path';
|
||||
import os from 'os';
|
||||
|
||||
describe('railsArgumentResolver', () => {
|
||||
describe('when provide the parameter', () => {
|
||||
const root = os.platform() === 'win32' ? 'C:\\' : '/';
|
||||
test.each([
|
||||
[{}, []],
|
||||
[{ minimal: true }, ['--minimal']],
|
||||
@@ -27,7 +30,10 @@ describe('railsArgumentResolver', () => {
|
||||
[{ webpacker: 'vue' }, ['--webpack', 'vue']],
|
||||
[{ database: 'postgresql' }, ['--database', 'postgresql']],
|
||||
[{ railsVersion: 'dev' }, ['--dev']],
|
||||
[{ template: './rails.rb' }, ['--template', '/tmp/rails.rb']],
|
||||
[
|
||||
{ template: `.${separatorPath}rails.rb` },
|
||||
['--template', `${root}${separatorPath}rails.rb`],
|
||||
],
|
||||
])(
|
||||
'should include the argument to execution %p -> %p',
|
||||
(passedArguments: object, expected: Array<string>) => {
|
||||
@@ -40,7 +46,7 @@ describe('railsArgumentResolver', () => {
|
||||
|
||||
const { railsArguments } = values;
|
||||
|
||||
const argumentsToRun = railsArgumentResolver('/tmp', railsArguments);
|
||||
const argumentsToRun = railsArgumentResolver(root, railsArguments);
|
||||
|
||||
expect(argumentsToRun).toEqual(expected);
|
||||
},
|
||||
|
||||
+7
-1
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { sep as separatorPath } from 'path';
|
||||
|
||||
enum Webpacker {
|
||||
react = 'react',
|
||||
@@ -99,7 +100,12 @@ export const railsArgumentResolver = (
|
||||
|
||||
if (options?.template) {
|
||||
argumentsToRun.push('--template');
|
||||
argumentsToRun.push(options.template.replace('./', `${projectRoot}/`));
|
||||
argumentsToRun.push(
|
||||
options.template.replace(
|
||||
`.${separatorPath}`,
|
||||
`${projectRoot}${separatorPath}`,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return argumentsToRun;
|
||||
|
||||
@@ -10,5 +10,4 @@ spec:
|
||||
- ./create-react-app/template.yaml
|
||||
- ./springboot-grpc-template/template.yaml
|
||||
- ./v1beta2-demo/template.yaml
|
||||
- ./rails-demo/template.yaml
|
||||
- ./pull-request/template.yaml
|
||||
|
||||
@@ -16,4 +16,4 @@
|
||||
|
||||
export { createFetchPlainAction } from './plain';
|
||||
export { createFetchCookiecutterAction } from './cookiecutter';
|
||||
export * from './helpers';
|
||||
export { fetchContents } from './helpers';
|
||||
|
||||
Reference in New Issue
Block a user