Merge remote-tracking branch 'origin' into add-tasks-owner

* origin: (56 commits)
  scaffolder-backend: fix merge conflict in router
  scaffolder: disable global save button in template editor if no files are dirty
  scaffolder: update API report
  scaffolder: remove unnecessary TemplateFileSystemAccess interface
  scaffolder: wrap dry-run log body in an outer object
  scaffolder: fix life
  scaffolder: make dry-run secrets optional to match task execution
  scaffolder: rename dry-run contents -> directoryContents
  scaffolder-backend: refactor actions to use serializeDirectoryContents
  scaffolder-backend: clarifying comment about done
  scaffolder-backend: add dry-run request body validation
  scaffolder-backend: validate dry-run template input
  sfaffolder: switch /v2/dryrun to /v2/dry-run
  scaffolder,scaffolder-backend: fix API reports
  scaffolder: fix dryRun implementation in ScaffolderClient
  scaffolder: add test for TemplateEditorBrowser
  scaffolder: add test for TemplateEditorPage
  scaffolder: add test for DryRunResultsView
  scaffolder: memo methods in DryRunProvider
  scaffolder: add DryRunResultsList tests
  ...

Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
blam
2022-05-31 14:58:51 +02:00
163 changed files with 4092 additions and 722 deletions
+98
View File
@@ -0,0 +1,98 @@
---
'@backstage/backend-common': patch
'@backstage/backend-test-utils': patch
'@backstage/catalog-client': patch
'@backstage/cli': patch
'@backstage/config-loader': patch
'@backstage/core-app-api': patch
'@backstage/core-components': patch
'@backstage/core-plugin-api': patch
'@backstage/integration-react': patch
'@backstage/integration': patch
'@backstage/release-manifests': patch
'@backstage/test-utils': patch
'@backstage/plugin-adr-backend': patch
'@backstage/plugin-adr': patch
'@backstage/plugin-airbrake-backend': patch
'@backstage/plugin-airbrake': patch
'@backstage/plugin-allure': patch
'@backstage/plugin-analytics-module-ga': patch
'@backstage/plugin-apache-airflow': patch
'@backstage/plugin-api-docs': patch
'@backstage/plugin-app-backend': patch
'@backstage/plugin-auth-backend': patch
'@backstage/plugin-auth-node': patch
'@backstage/plugin-azure-devops-backend': patch
'@backstage/plugin-azure-devops': patch
'@backstage/plugin-badges': patch
'@backstage/plugin-bitrise': patch
'@backstage/plugin-catalog-backend-module-azure': patch
'@backstage/plugin-catalog-backend-module-bitbucket': patch
'@backstage/plugin-catalog-backend-module-gerrit': patch
'@backstage/plugin-catalog-backend-module-github': patch
'@backstage/plugin-catalog-backend-module-gitlab': patch
'@backstage/plugin-catalog-backend-module-msgraph': patch
'@backstage/plugin-catalog-backend': patch
'@backstage/plugin-catalog-graphql': patch
'@backstage/plugin-catalog-import': patch
'@backstage/plugin-circleci': patch
'@backstage/plugin-cloudbuild': patch
'@backstage/plugin-code-climate': patch
'@backstage/plugin-code-coverage-backend': patch
'@backstage/plugin-code-coverage': patch
'@backstage/plugin-codescene': patch
'@backstage/plugin-config-schema': patch
'@backstage/plugin-cost-insights': patch
'@backstage/plugin-explore-react': patch
'@backstage/plugin-explore': patch
'@backstage/plugin-firehydrant': patch
'@backstage/plugin-fossa': patch
'@backstage/plugin-gcalendar': patch
'@backstage/plugin-gcp-projects': patch
'@backstage/plugin-git-release-manager': patch
'@backstage/plugin-github-actions': patch
'@backstage/plugin-github-deployments': patch
'@backstage/plugin-github-pull-requests-board': patch
'@backstage/plugin-gitops-profiles': patch
'@backstage/plugin-gocd': patch
'@backstage/plugin-graphiql': patch
'@backstage/plugin-graphql-backend': patch
'@backstage/plugin-home': patch
'@backstage/plugin-ilert': patch
'@backstage/plugin-jenkins-backend': patch
'@backstage/plugin-jenkins': patch
'@backstage/plugin-kafka': patch
'@backstage/plugin-kubernetes': patch
'@backstage/plugin-lighthouse': patch
'@backstage/plugin-newrelic': patch
'@backstage/plugin-org': patch
'@backstage/plugin-pagerduty': patch
'@backstage/plugin-periskop-backend': patch
'@backstage/plugin-periskop': patch
'@backstage/plugin-permission-backend': patch
'@backstage/plugin-permission-common': patch
'@backstage/plugin-permission-node': patch
'@backstage/plugin-rollbar-backend': patch
'@backstage/plugin-rollbar': patch
'@backstage/plugin-scaffolder-backend-module-cookiecutter': patch
'@backstage/plugin-scaffolder-backend': patch
'@backstage/plugin-scaffolder': patch
'@backstage/plugin-search': patch
'@backstage/plugin-sentry': patch
'@backstage/plugin-shortcuts': patch
'@backstage/plugin-sonarqube': patch
'@backstage/plugin-splunk-on-call': patch
'@backstage/plugin-stack-overflow': patch
'@backstage/plugin-tech-insights': patch
'@backstage/plugin-tech-radar': patch
'@backstage/plugin-techdocs-addons-test-utils': patch
'@backstage/plugin-techdocs-backend': patch
'@backstage/plugin-techdocs-module-addons-contrib': patch
'@backstage/plugin-techdocs': patch
'@backstage/plugin-todo-backend': patch
'@backstage/plugin-todo': patch
'@backstage/plugin-user-settings': patch
'@backstage/plugin-xcmetrics': patch
---
Updated dependency `msw` to `^0.41.0`.
+1 -1
View File
@@ -112,7 +112,7 @@
"better-sqlite3": "^7.5.0",
"http-errors": "^2.0.0",
"mock-fs": "^5.1.0",
"msw": "^0.35.0",
"msw": "^0.42.0",
"mysql2": "^2.2.5",
"recursive-readdir": "^2.2.2",
"supertest": "^6.1.3"
+1 -1
View File
@@ -39,7 +39,7 @@
"@backstage/config": "^1.0.1",
"better-sqlite3": "^7.5.0",
"knex": "^1.0.2",
"msw": "^0.35.0",
"msw": "^0.42.0",
"mysql2": "^2.2.5",
"pg": "^8.3.0",
"testcontainers": "^8.1.2",
+1 -1
View File
@@ -40,7 +40,7 @@
"devDependencies": {
"@backstage/cli": "^0.17.2-next.0",
"@types/jest": "^26.0.7",
"msw": "^0.35.0"
"msw": "^0.42.0"
},
"files": [
"dist"
+1 -1
View File
@@ -152,7 +152,7 @@
"@types/yarnpkg__lockfile": "^1.1.4",
"del": "^6.0.0",
"mock-fs": "^5.1.0",
"msw": "^0.35.0",
"msw": "^0.42.0",
"nodemon": "^2.0.2",
"ts-node": "^10.0.0"
},
@@ -41,7 +41,7 @@
"@backstage/cli": "{{versionQuery '@backstage/cli'}}",
"@types/supertest": "{{versionQuery '@types/supertest' '2.0.8'}}",
"supertest": "{{versionQuery 'supertest' '4.0.2'}}",
"msw": "{{versionQuery 'msw' '0.35.0'}}"
"msw": "{{versionQuery 'msw' '0.42.0'}}"
},
"files": [
"dist"
@@ -49,7 +49,7 @@
"@testing-library/user-event": "{{versionQuery '@testing-library/user-event' '14.0.0'}}",
"@types/jest": "{{versionQuery '@types/jest' '26.0.7'}}",
"@types/node": "{{versionQuery '@types/node' '16.11.26'}}",
"msw": "{{versionQuery 'msw' '0.35.0'}}",
"msw": "{{versionQuery 'msw' '0.42.0'}}",
"cross-fetch": "{{versionQuery 'cross-fetch' '3.1.5'}}"
},
"files": [
+1 -1
View File
@@ -57,7 +57,7 @@
"@types/node": "^16.11.26",
"@types/yup": "^0.29.13",
"mock-fs": "^5.1.0",
"msw": "^0.35.0"
"msw": "^0.42.0"
},
"files": [
"dist"
+1 -1
View File
@@ -59,7 +59,7 @@
"@types/node": "^16.11.26",
"@types/zen-observable": "^0.8.0",
"cross-fetch": "^3.1.5",
"msw": "^0.35.0"
"msw": "^0.42.0"
},
"files": [
"dist",
+1 -1
View File
@@ -101,7 +101,7 @@
"@types/react-window": "^1.8.5",
"@types/zen-observable": "^0.8.0",
"cross-fetch": "^3.1.5",
"msw": "^0.35.0"
"msw": "^0.42.0"
},
"files": [
"dist"
+1 -1
View File
@@ -58,7 +58,7 @@
"@types/prop-types": "^15.7.3",
"@types/zen-observable": "^0.8.0",
"cross-fetch": "^3.1.5",
"msw": "^0.35.0"
"msw": "^0.42.0"
},
"files": [
"dist"
+1 -1
View File
@@ -46,7 +46,7 @@
"@testing-library/user-event": "^14.0.0",
"@types/jest": "^26.0.7",
"@types/node": "^16.11.26",
"msw": "^0.35.0",
"msw": "^0.42.0",
"cross-fetch": "^3.1.5"
},
"files": [
+1 -1
View File
@@ -48,7 +48,7 @@
"@backstage/test-utils": "^1.1.0",
"@types/jest": "^26.0.7",
"@types/luxon": "^2.0.4",
"msw": "^0.35.0"
"msw": "^0.42.0"
},
"files": [
"dist",
+1 -1
View File
@@ -37,7 +37,7 @@
},
"devDependencies": {
"@backstage/test-utils": "^1.1.0",
"msw": "^0.35.0",
"msw": "^0.42.0",
"@types/jest": "^26.0.7",
"@types/node": "^16.0.0"
},
+61 -59
View File
@@ -14,73 +14,75 @@
* limitations under the License.
*/
import { setupRequestMockHandlers } from '@backstage/test-utils';
import { getManifestByReleaseLine, getManifestByVersion } from './manifest';
import { setupServer } from 'msw/node';
import { rest } from 'msw';
import { setupRequestMockHandlers } from '@backstage/test-utils';
import { getManifestByReleaseLine, getManifestByVersion } from './manifest';
describe('getManifestByVersion', () => {
describe('Release Manifests', () => {
const worker = setupServer();
setupRequestMockHandlers(worker);
it('should return a list of packages in a release', async () => {
worker.use(
rest.get('*/v1/releases/0.0.0/manifest.json', (_, res, ctx) =>
res(
ctx.status(200),
ctx.json({
packages: [{ name: '@backstage/core', version: '1.2.3' }],
}),
describe('getManifestByVersion', () => {
it('should return a list of packages in a release', async () => {
worker.use(
rest.get('*/v1/releases/0.0.0/manifest.json', (_, res, ctx) =>
res(
ctx.status(200),
ctx.json({
packages: [{ name: '@backstage/core', version: '1.2.3' }],
}),
),
),
),
rest.get('*/v1/releases/999.0.1/manifest.json', (_, res, ctx) =>
res(ctx.status(404), ctx.json({})),
),
);
rest.get('*/v1/releases/999.0.1/manifest.json', (_, res, ctx) =>
res(ctx.status(404), ctx.json({})),
),
);
const pkgs = await getManifestByVersion({ version: '0.0.0' });
expect(pkgs.packages).toEqual([
{
name: '@backstage/core',
version: '1.2.3',
},
]);
const pkgs = await getManifestByVersion({ version: '0.0.0' });
expect(pkgs.packages).toEqual([
{
name: '@backstage/core',
version: '1.2.3',
},
]);
await expect(getManifestByVersion({ version: '999.0.1' })).rejects.toThrow(
'No release found for 999.0.1 version',
);
});
});
describe('getManifestByReleaseLine', () => {
const worker = setupServer();
setupRequestMockHandlers(worker);
it('should return a list of packages in a release', async () => {
worker.use(
rest.get('*/v1/tags/main/manifest.json', (_, res, ctx) =>
res(
ctx.status(200),
ctx.json({
packages: [{ name: '@backstage/core', version: '1.2.3' }],
}),
),
),
rest.get('*/v1/tags/foo/manifest.json', (_, res, ctx) =>
res(ctx.status(404), ctx.json({})),
),
);
const pkgs = await getManifestByReleaseLine({ releaseLine: 'main' });
expect(pkgs.packages).toEqual([
{
name: '@backstage/core',
version: '1.2.3',
},
]);
await expect(
getManifestByReleaseLine({ releaseLine: 'foo' }),
).rejects.toThrow("No 'foo' release line found");
await expect(
getManifestByVersion({ version: '999.0.1' }),
).rejects.toThrow('No release found for 999.0.1 version');
});
});
describe('getManifestByReleaseLine', () => {
it('should return a list of packages in a release', async () => {
worker.use(
rest.get(
'https://versions.backstage.io/v1/tags/main/manifest.json',
(_, res, ctx) =>
res(
ctx.status(200),
ctx.json({
packages: [{ name: '@backstage/core', version: '1.2.3' }],
}),
),
),
rest.get(
'https://versions.backstage.io/v1/tags/foo/manifest.json',
(_, res, ctx) => res(ctx.status(404), ctx.json({})),
),
);
const pkgs = await getManifestByReleaseLine({ releaseLine: 'main' });
expect(pkgs.packages).toEqual([
{
name: '@backstage/core',
version: '1.2.3',
},
]);
await expect(
getManifestByReleaseLine({ releaseLine: 'foo' }),
).rejects.toThrow("No 'foo' release line found");
});
});
});
+1 -1
View File
@@ -58,7 +58,7 @@
"@backstage/cli": "^0.17.2-next.0",
"@types/jest": "^26.0.7",
"@types/node": "^16.11.26",
"msw": "^0.35.0"
"msw": "^0.42.0"
},
"files": [
"dist"
+1 -1
View File
@@ -48,7 +48,7 @@
"@types/marked": "^4.0.0",
"@types/supertest": "^2.0.8",
"supertest": "^6.1.3",
"msw": "^0.35.0"
"msw": "^0.42.0"
},
"files": [
"dist"
+1 -1
View File
@@ -55,7 +55,7 @@
"@types/jest": "*",
"@types/node": "*",
"cross-fetch": "^3.1.5",
"msw": "^0.35.0"
"msw": "^0.42.0"
},
"files": [
"dist"
+1 -1
View File
@@ -37,7 +37,7 @@
"@types/http-proxy-middleware": "^0.19.3",
"@types/supertest": "^2.0.8",
"supertest": "^6.1.6",
"msw": "^0.35.0"
"msw": "^0.42.0"
},
"files": [
"dist",
+1 -1
View File
@@ -51,7 +51,7 @@
"@types/node": "^16.11.26",
"@types/object-hash": "^2.2.1",
"cross-fetch": "^3.1.5",
"msw": "^0.35.0",
"msw": "^0.42.0",
"react-router": "6.0.0-beta.0"
},
"files": [
+1 -1
View File
@@ -50,7 +50,7 @@
"@types/jest": "^26.0.7",
"@types/node": "^16.11.26",
"cross-fetch": "^3.1.5",
"msw": "^0.35.0"
"msw": "^0.42.0"
},
"files": [
"dist"
+1 -1
View File
@@ -48,7 +48,7 @@
"@types/jest": "^26.0.7",
"@types/node": "^16.11.26",
"cross-fetch": "^3.1.5",
"msw": "^0.35.0"
"msw": "^0.42.0"
},
"files": [
"dist",
+1 -1
View File
@@ -45,7 +45,7 @@
"@testing-library/user-event": "^14.0.0",
"@types/jest": "^26.0.7",
"@types/node": "^16.11.26",
"msw": "^0.35.0"
"msw": "^0.42.0"
},
"files": [
"dist",
+1 -1
View File
@@ -68,7 +68,7 @@
"@types/node": "^16.11.26",
"@types/swagger-ui-react": "^4.1.1",
"cross-fetch": "^3.1.5",
"msw": "^0.35.0"
"msw": "^0.42.0"
},
"files": [
"dist"
+1 -1
View File
@@ -55,7 +55,7 @@
"@backstage/types": "^1.0.0",
"@types/supertest": "^2.0.8",
"mock-fs": "^5.1.0",
"msw": "^0.35.0",
"msw": "^0.42.0",
"supertest": "^6.1.3"
},
"files": [
+1 -1
View File
@@ -88,7 +88,7 @@
"@types/passport-saml": "^1.1.3",
"@types/passport-strategy": "^0.2.35",
"@types/xml2js": "^0.4.7",
"msw": "^0.35.0",
"msw": "^0.42.0",
"supertest": "^6.1.3"
},
"files": [
+1 -1
View File
@@ -33,7 +33,7 @@
"devDependencies": {
"@backstage/cli": "^0.17.2-next.0",
"lodash": "^4.17.21",
"msw": "^0.35.0",
"msw": "^0.42.0",
"uuid": "^8.0.0"
},
"files": [
+1 -1
View File
@@ -38,7 +38,7 @@
"@backstage/cli": "^0.17.2-next.0",
"@types/supertest": "^2.0.8",
"supertest": "^6.1.6",
"msw": "^0.35.0"
"msw": "^0.42.0"
},
"files": [
"dist",
+1 -1
View File
@@ -59,7 +59,7 @@
"@types/jest": "^26.0.7",
"@types/node": "^16.11.26",
"cross-fetch": "^3.1.5",
"msw": "^0.35.0"
"msw": "^0.42.0"
},
"files": [
"dist"
+1 -1
View File
@@ -56,7 +56,7 @@
"@types/jest": "^26.0.7",
"@types/node": "^16.11.26",
"cross-fetch": "^3.1.5",
"msw": "^0.35.0"
"msw": "^0.42.0"
},
"files": [
"dist"
+1 -1
View File
@@ -53,7 +53,7 @@
"@types/jest": "^26.0.7",
"@types/node": "^16.11.26",
"@types/recharts": "^1.8.15",
"msw": "^0.35.0"
"msw": "^0.42.0"
},
"files": [
"dist"
@@ -41,7 +41,7 @@
"@backstage/plugin-catalog-backend": "^1.2.0-next.0",
"@backstage/types": "^1.0.0",
"lodash": "^4.17.21",
"msw": "^0.35.0",
"msw": "^0.42.0",
"node-fetch": "^2.6.7",
"winston": "^3.2.1"
},
@@ -42,7 +42,7 @@
"@backstage/plugin-catalog-backend": "^1.2.0-next.0",
"@backstage/types": "^1.0.0",
"lodash": "^4.17.21",
"msw": "^0.35.0",
"msw": "^0.42.0",
"node-fetch": "^2.6.7",
"winston": "^3.2.1"
},
@@ -36,7 +36,7 @@
"@backstage/integration": "^1.2.1-next.0",
"@backstage/plugin-catalog-backend": "^1.2.0-next.0",
"fs-extra": "10.1.0",
"msw": "^0.35.0",
"msw": "^0.42.0",
"node-fetch": "^2.6.7",
"uuid": "^8.0.0",
"winston": "^3.2.1"
@@ -43,7 +43,7 @@
"@backstage/types": "^1.0.0",
"@octokit/graphql": "^4.5.8",
"lodash": "^4.17.21",
"msw": "^0.35.0",
"msw": "^0.42.0",
"node-fetch": "^2.6.7",
"uuid": "^8.0.0",
"winston": "^3.2.1"
@@ -41,7 +41,7 @@
"@backstage/plugin-catalog-backend": "^1.2.0-next.0",
"@backstage/types": "^1.0.0",
"lodash": "^4.17.21",
"msw": "^0.35.0",
"msw": "^0.42.0",
"node-fetch": "^2.6.7",
"winston": "^3.2.1"
},
@@ -52,7 +52,7 @@
"@backstage/backend-test-utils": "^0.1.25-next.0",
"@backstage/cli": "^0.17.2-next.0",
"@types/lodash": "^4.14.151",
"msw": "^0.35.0"
"msw": "^0.42.0"
},
"files": [
"dist",
+1 -1
View File
@@ -78,7 +78,7 @@
"@types/supertest": "^2.0.8",
"@types/uuid": "^8.0.0",
"better-sqlite3": "^7.5.0",
"msw": "^0.35.0",
"msw": "^0.42.0",
"supertest": "^6.1.3",
"wait-for-expect": "^3.0.2",
"luxon": "^2.0.2"
+1 -1
View File
@@ -53,7 +53,7 @@
"@graphql-codegen/typescript": "^2.4.2",
"@graphql-codegen/typescript-resolvers": "^2.4.3",
"@graphql-tools/schema": "^8.3.1",
"msw": "^0.35.0"
"msw": "^0.42.0"
},
"files": [
"dist"
+1 -1
View File
@@ -70,7 +70,7 @@
"@testing-library/user-event": "^14.0.0",
"@types/jest": "^26.0.7",
"cross-fetch": "^3.1.5",
"msw": "^0.35.0"
"msw": "^0.42.0"
},
"files": [
"dist",
+1 -1
View File
@@ -66,7 +66,7 @@
"@types/jest": "^26.0.7",
"@types/node": "^16.11.26",
"cross-fetch": "^3.1.5",
"msw": "^0.35.0"
"msw": "^0.42.0"
},
"files": [
"dist"
+1 -1
View File
@@ -62,7 +62,7 @@
"@types/jest": "^26.0.7",
"@types/node": "^16.11.26",
"cross-fetch": "^3.1.5",
"msw": "^0.35.0"
"msw": "^0.42.0"
},
"files": [
"dist"
+1 -1
View File
@@ -51,7 +51,7 @@
"@types/luxon": "^2.0.9",
"@types/node": "^16.11.26",
"cross-fetch": "^3.1.5",
"msw": "^0.35.0"
"msw": "^0.42.0"
},
"files": [
"dist"
+1 -1
View File
@@ -42,7 +42,7 @@
"@backstage/cli": "^0.17.2-next.0",
"@types/express-xml-bodyparser": "^0.3.2",
"@types/supertest": "^2.0.8",
"msw": "^0.35.0",
"msw": "^0.42.0",
"supertest": "^6.1.6",
"xml2js": "^0.4.23"
},
+1 -1
View File
@@ -58,7 +58,7 @@
"@types/node": "^16.11.26",
"@types/recharts": "^1.8.15",
"cross-fetch": "^3.1.5",
"msw": "^0.35.0"
"msw": "^0.42.0"
},
"files": [
"dist"
+1 -1
View File
@@ -47,7 +47,7 @@
"@testing-library/user-event": "^14.0.0",
"@types/jest": "*",
"@types/node": "*",
"msw": "^0.35.0",
"msw": "^0.42.0",
"cross-fetch": "^3.1.5"
},
"files": [
+1 -1
View File
@@ -51,7 +51,7 @@
"@types/jest": "^26.0.7",
"@types/node": "^16.11.26",
"cross-fetch": "^3.1.5",
"msw": "^0.35.0"
"msw": "^0.42.0"
},
"files": [
"dist"
+1 -1
View File
@@ -75,7 +75,7 @@
"@types/yup": "^0.29.13",
"canvas": "^2.6.1",
"cross-fetch": "^3.1.5",
"msw": "^0.35.0"
"msw": "^0.42.0"
},
"files": [
"dist",
@@ -36,7 +36,7 @@
"@backstage/cli": "^0.17.2-next.0",
"@types/supertest": "^2.0.8",
"@types/uuid": "^8.0.0",
"msw": "^0.35.0",
"msw": "^0.42.0",
"supertest": "^6.1.6"
},
"files": [
@@ -31,7 +31,7 @@
"@backstage/dev-utils": "^1.0.3-next.0",
"@backstage/test-utils": "^1.1.0",
"@types/node": "^16.11.26",
"msw": "^0.35.0",
"msw": "^0.42.0",
"cross-fetch": "^3.1.5"
},
"files": [
+1 -1
View File
@@ -42,7 +42,7 @@
"@testing-library/user-event": "^14.0.0",
"@types/jest": "^26.0.7",
"@types/node": "^16.11.26",
"msw": "^0.35.0"
"msw": "^0.42.0"
},
"files": [
"dist"
+1 -1
View File
@@ -45,7 +45,7 @@
"@types/jest": "^26.0.7",
"@types/node": "^16.11.26",
"cross-fetch": "^3.1.5",
"msw": "^0.35.0"
"msw": "^0.42.0"
},
"files": [
"dist"
+1 -1
View File
@@ -63,7 +63,7 @@
"@types/jest": "^26.0.7",
"@types/node": "^16.11.26",
"cross-fetch": "^3.1.5",
"msw": "^0.35.0"
"msw": "^0.42.0"
},
"files": [
"dist"
+1 -1
View File
@@ -49,7 +49,7 @@
"@types/jest": "^26.0.7",
"@types/node": "^16.11.26",
"cross-fetch": "^3.1.5",
"msw": "^0.35.0"
"msw": "^0.42.0"
},
"files": [
"dist"
+1 -1
View File
@@ -62,7 +62,7 @@
"@testing-library/user-event": "^14.0.0",
"@types/jest": "^26.0.7",
"@types/node": "^16.11.26",
"msw": "^0.35.0"
"msw": "^0.42.0"
},
"files": [
"dist",
+1 -1
View File
@@ -55,7 +55,7 @@
"@types/node": "^16.11.26",
"@types/sanitize-html": "^2.6.2",
"cross-fetch": "^3.1.5",
"msw": "^0.35.0"
"msw": "^0.42.0"
},
"files": [
"dist"
+1 -1
View File
@@ -57,7 +57,7 @@
"@types/jest": "^26.0.7",
"@types/node": "^16.11.26",
"cross-fetch": "^3.1.5",
"msw": "^0.35.0"
"msw": "^0.42.0"
},
"files": [
"dist"
+1 -1
View File
@@ -55,7 +55,7 @@
"@types/node": "^16.11.26",
"@types/recharts": "^1.8.15",
"cross-fetch": "^3.1.5",
"msw": "^0.35.0"
"msw": "^0.42.0"
},
"files": [
"dist"
+1 -1
View File
@@ -65,7 +65,7 @@
"@types/jest": "^26.0.7",
"@types/node": "^16.11.26",
"cross-fetch": "^3.1.5",
"msw": "^0.35.0"
"msw": "^0.42.0"
},
"files": [
"dist"
+1 -1
View File
@@ -53,7 +53,7 @@
"@types/jest": "^26.0.7",
"@types/node": "^16.11.26",
"cross-fetch": "^3.1.5",
"msw": "^0.35.0"
"msw": "^0.42.0"
},
"files": [
"dist"
@@ -58,7 +58,7 @@
"@types/jest": "^26.0.7",
"@types/node": "^16.11.26",
"cross-fetch": "^3.1.5",
"msw": "^0.35.0"
"msw": "^0.42.0"
},
"peerDependencies": {
"@types/react": "^16.13.1 || ^17.0.0",
+1 -1
View File
@@ -58,7 +58,7 @@
"@types/jest": "^26.0.7",
"@types/node": "^16.11.26",
"cross-fetch": "^3.1.5",
"msw": "^0.35.0"
"msw": "^0.42.0"
},
"files": [
"dist"
+1 -1
View File
@@ -61,7 +61,7 @@
"@types/luxon": "^2.0.4",
"@types/node": "^16.11.26",
"cross-fetch": "^3.1.5",
"msw": "^0.35.0"
"msw": "^0.42.0"
},
"files": [
"dist",
+1 -1
View File
@@ -60,7 +60,7 @@
"@types/jest": "^26.0.7",
"@types/node": "^16.11.26",
"cross-fetch": "^3.1.5",
"msw": "^0.35.0",
"msw": "^0.42.0",
"react-router-dom": "6.0.0-beta.0"
},
"files": [
+1 -1
View File
@@ -53,7 +53,7 @@
"devDependencies": {
"@backstage/cli": "^0.17.2-next.0",
"@types/supertest": "^2.0.8",
"msw": "^0.35.0",
"msw": "^0.42.0",
"supertest": "^6.1.3"
},
"files": [
+1 -1
View File
@@ -63,7 +63,7 @@
"@types/jest": "^26.0.7",
"@types/node": "^16.11.26",
"cross-fetch": "^3.1.5",
"msw": "^0.35.0"
"msw": "^0.42.0"
},
"files": [
"dist"
+1 -1
View File
@@ -53,7 +53,7 @@
"@types/jest": "^26.0.7",
"@types/node": "^16.11.26",
"cross-fetch": "^3.1.5",
"msw": "^0.35.0"
"msw": "^0.42.0"
},
"files": [
"dist",
+1 -1
View File
@@ -44,7 +44,7 @@
"@backstage/cli": "^0.17.2-next.0",
"@types/jenkins": "^0.23.1",
"@types/supertest": "^2.0.8",
"msw": "^0.35.0",
"msw": "^0.42.0",
"supertest": "^6.1.6"
},
"files": [
+1 -1
View File
@@ -65,7 +65,7 @@
"@types/node": "^16.11.26",
"@types/testing-library__jest-dom": "^5.9.1",
"cross-fetch": "^3.1.5",
"msw": "^0.35.0"
"msw": "^0.42.0"
},
"files": [
"dist"
+1 -1
View File
@@ -51,7 +51,7 @@
"@types/node": "^16.11.26",
"cross-fetch": "^3.1.5",
"jest-when": "^3.1.0",
"msw": "^0.35.0"
"msw": "^0.42.0"
},
"files": [
"dist"
+1 -1
View File
@@ -68,7 +68,7 @@
"@types/jest": "^26.0.7",
"@types/node": "^16.11.26",
"cross-fetch": "^3.1.5",
"msw": "^0.35.0"
"msw": "^0.42.0"
},
"files": [
"dist"
+1 -1
View File
@@ -63,7 +63,7 @@
"@types/node": "^16.11.26",
"@types/react": "^16.13.1 || ^17.0.0",
"cross-fetch": "^3.1.5",
"msw": "^0.35.0"
"msw": "^0.42.0"
},
"files": [
"dist"
+1 -1
View File
@@ -57,7 +57,7 @@
"@types/jest": "^26.0.7",
"@types/node": "^16.11.26",
"cross-fetch": "^3.1.5",
"msw": "^0.35.0"
"msw": "^0.42.0"
},
"files": [
"dist"
+1 -1
View File
@@ -59,7 +59,7 @@
"@types/jest": "^26.0.7",
"@types/node": "^16.11.26",
"cross-fetch": "^3.1.5",
"msw": "^0.35.0"
"msw": "^0.42.0"
},
"files": [
"dist"
+1 -1
View File
@@ -62,7 +62,7 @@
"@types/jest": "^26.0.7",
"@types/node": "^16.11.26",
"cross-fetch": "^3.1.5",
"msw": "^0.35.0"
"msw": "^0.42.0"
},
"files": [
"dist"
+1 -1
View File
@@ -37,7 +37,7 @@
"devDependencies": {
"@backstage/cli": "^0.17.2-next.0",
"@types/supertest": "^2.0.8",
"msw": "^0.35.0",
"msw": "^0.42.0",
"supertest": "^6.1.6"
},
"files": [
+1 -1
View File
@@ -53,7 +53,7 @@
"@types/luxon": "^2.0.4",
"@types/node": "^16.11.26",
"cross-fetch": "^3.1.5",
"msw": "^0.35.0"
"msw": "^0.42.0"
},
"files": [
"dist",
+1 -1
View File
@@ -43,7 +43,7 @@
"@types/lodash": "^4.14.151",
"@types/supertest": "^2.0.8",
"supertest": "^6.1.6",
"msw": "^0.35.0"
"msw": "^0.42.0"
},
"files": [
"dist"
+1 -1
View File
@@ -50,6 +50,6 @@
"devDependencies": {
"@backstage/cli": "^0.17.2-next.0",
"@types/jest": "^26.0.7",
"msw": "^0.35.0"
"msw": "^0.42.0"
}
}
+1 -1
View File
@@ -46,7 +46,7 @@
"devDependencies": {
"@backstage/cli": "^0.17.2-next.0",
"@types/supertest": "^2.0.8",
"msw": "^0.35.0",
"msw": "^0.42.0",
"supertest": "^6.1.3"
},
"files": [
+1 -1
View File
@@ -53,7 +53,7 @@
"@backstage/backend-test-utils": "^0.1.25-next.0",
"@backstage/cli": "^0.17.2-next.0",
"@types/supertest": "^2.0.8",
"msw": "^0.36.3",
"msw": "^0.42.0",
"supertest": "^6.1.3"
},
"files": [
+1 -1
View File
@@ -65,7 +65,7 @@
"@types/node": "^16.11.26",
"@types/react": "^16.13.1 || ^17.0.0",
"cross-fetch": "^3.1.5",
"msw": "^0.35.0"
"msw": "^0.42.0"
},
"files": [
"dist",
@@ -41,7 +41,7 @@
"@types/jest": "^26.0.7",
"@types/command-exists": "^1.2.0",
"mock-fs": "^5.1.0",
"msw": "^0.35.0"
"msw": "^0.42.0"
},
"files": [
"dist"
+4
View File
@@ -40,6 +40,7 @@ export type ActionContext<Input extends JsonObject> = {
output(name: string, value: JsonValue): void;
createTemporaryDirectory(): Promise<string>;
templateInfo?: TemplateInfo;
isDryRun?: boolean;
};
// @public
@@ -554,6 +555,8 @@ export interface TaskContext {
// (undocumented)
getWorkspaceName(): Promise<string>;
// (undocumented)
isDryRun?: boolean;
// (undocumented)
secrets?: TaskSecrets;
// (undocumented)
spec: TaskSpec;
@@ -671,6 +674,7 @@ export class TaskWorker {
export type TemplateAction<Input extends JsonObject> = {
id: string;
description?: string;
supportsDryRun?: boolean;
schema?: {
input?: Schema;
output?: Schema;
+4 -2
View File
@@ -67,11 +67,13 @@
"nunjucks": "^3.2.3",
"octokit": "^1.7.1",
"octokit-plugin-create-pull-request": "^3.10.0",
"p-limit": "^3.1.0",
"uuid": "^8.2.0",
"winston": "^3.2.1",
"yaml": "^1.10.0",
"vm2": "^3.9.6",
"zen-observable": "^0.8.15"
"zen-observable": "^0.8.15",
"zod": "^3.11.6"
},
"devDependencies": {
"@backstage/backend-test-utils": "^0.1.25-next.0",
@@ -86,7 +88,7 @@
"esbuild": "^0.14.1",
"jest-when": "^3.1.0",
"mock-fs": "^5.1.0",
"msw": "^0.35.0",
"msw": "^0.42.0",
"supertest": "^6.1.3",
"yaml": "^1.10.0"
},
@@ -0,0 +1,81 @@
/*
* Copyright 2022 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import mockFs from 'mock-fs';
import { deserializeDirectoryContents } from './deserializeDirectoryContents';
import { serializeDirectoryContents } from './serializeDirectoryContents';
describe('deserializeDirectoryContents', () => {
beforeEach(() => {
mockFs({
root: {},
});
});
afterEach(() => {
mockFs.restore();
});
it('deserializes contents into a directory', async () => {
await deserializeDirectoryContents('root', [
{
path: 'a.txt',
content: Buffer.from('a', 'utf8'),
},
]);
await expect(serializeDirectoryContents('root')).resolves.toEqual([
{
path: 'a.txt',
content: Buffer.from('a', 'utf8'),
executable: false,
},
]);
});
it('deserializes contents into a deep directory structure', async () => {
await deserializeDirectoryContents('root', [
{
path: 'a.txt',
content: Buffer.from('a', 'utf8'),
},
{
path: 'a/b.txt',
content: Buffer.from('b', 'utf8'),
},
{
path: 'a/b/c.txt',
content: Buffer.from('c', 'utf8'),
},
]);
await expect(serializeDirectoryContents('root')).resolves.toEqual([
{
path: 'a.txt',
content: Buffer.from('a', 'utf8'),
executable: false,
},
{
path: 'a/b.txt',
content: Buffer.from('b', 'utf8'),
executable: false,
},
{
path: 'a/b/c.txt',
content: Buffer.from('c', 'utf8'),
executable: false,
},
]);
});
});
@@ -0,0 +1,39 @@
/*
* Copyright 2022 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import fs from 'fs-extra';
import { dirname } from 'path';
import { resolveSafeChildPath } from '@backstage/backend-common';
import { SerializedFile } from './types';
/**
* Deserializes a list of serialized files into the target directory.
*
* This method uses `resolveSafeChildPath` to make sure that files are
* not written outside of the target directory.
*
* @internal
*/
export async function deserializeDirectoryContents(
targetPath: string,
files: SerializedFile[],
): Promise<void> {
for (const file of files) {
const filePath = resolveSafeChildPath(targetPath, file.path);
await fs.ensureDir(dirname(filePath));
await fs.writeFile(filePath, file.content); // Ignore file mode
}
}
@@ -0,0 +1,19 @@
/*
* Copyright 2022 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export { serializeDirectoryContents } from './serializeDirectoryContents';
export { deserializeDirectoryContents } from './deserializeDirectoryContents';
export type { SerializedFile } from './types';
@@ -0,0 +1,179 @@
/*
* Copyright 2022 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { serializeDirectoryContents } from './serializeDirectoryContents';
import mockFs from 'mock-fs';
describe('serializeDirectoryContents', () => {
afterEach(() => {
mockFs.restore();
});
it('should list files in this directory', async () => {
await expect(serializeDirectoryContents(__dirname)).resolves.toEqual(
expect.arrayContaining([
{
path: 'index.ts',
executable: false,
content: expect.any(Buffer),
},
{
path: 'types.ts',
executable: false,
content: expect.any(Buffer),
},
{
path: 'serializeDirectoryContents.ts',
executable: false,
content: expect.any(Buffer),
},
{
path: 'serializeDirectoryContents.test.ts',
executable: false,
content: expect.any(Buffer),
},
]),
);
});
it('should list files in a mock directory', async () => {
mockFs({
root: {
'a.txt': 'a',
b: {
'b1.txt': 'b1',
'b2.txt': 'b2',
},
c: {
c1: {
'c11.txt': 'c11',
c11: {
'c111.txt': 'c111',
},
},
},
},
});
await expect(serializeDirectoryContents('root')).resolves.toEqual([
{
path: 'a.txt',
executable: false,
content: Buffer.from('a', 'utf8'),
},
{
path: 'b/b1.txt',
executable: false,
content: Buffer.from('b1', 'utf8'),
},
{
path: 'b/b2.txt',
executable: false,
content: Buffer.from('b2', 'utf8'),
},
{
path: 'c/c1/c11.txt',
executable: false,
content: Buffer.from('c11', 'utf8'),
},
{
path: 'c/c1/c11/c111.txt',
executable: false,
content: Buffer.from('c111', 'utf8'),
},
]);
});
it('should ignore gitignored files', async () => {
mockFs({
root: {
'.gitignore': '*.txt',
'a.txt': 'a',
'a.log': 'a',
},
});
await expect(
serializeDirectoryContents('root', {
gitignore: true,
}),
).resolves.toEqual([
{
path: '.gitignore',
executable: false,
content: Buffer.from('*.txt', 'utf8'),
},
{
path: 'a.log',
executable: false,
content: Buffer.from('a', 'utf8'),
},
]);
});
it('should use custom glob patterns', async () => {
mockFs({
root: {
'.a': 'a',
'a.log': 'a',
'a.txt': 'a',
b: {
'.b': 'b',
'b.log': 'b',
'b.txt': 'b',
},
c: {
'.c': 'c',
'c.log': 'c',
'c.txt': 'c',
},
},
});
await expect(
serializeDirectoryContents('root', {
gitignore: true,
globPatterns: ['**/*.txt', '*/.?', '*/*.log', '!c/**/.*', '!b/*.log'],
}).then(files => files.sort((a, b) => a.path.localeCompare(b.path))),
).resolves.toEqual([
{
path: 'a.txt',
executable: false,
content: Buffer.from('a', 'utf8'),
},
{
path: 'b/.b',
executable: false,
content: Buffer.from('b', 'utf8'),
},
{
path: 'b/b.txt',
executable: false,
content: Buffer.from('b', 'utf8'),
},
{
path: 'c/c.log',
executable: false,
content: Buffer.from('c', 'utf8'),
},
{
path: 'c/c.txt',
executable: false,
content: Buffer.from('c', 'utf8'),
},
]);
});
});
@@ -0,0 +1,62 @@
/*
* Copyright 2022 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import fs from 'fs-extra';
import globby from 'globby';
import limiterFactory from 'p-limit';
import { join as joinPath } from 'path';
import { SerializedFile } from './types';
const DEFAULT_GLOB_PATTERNS = ['./**', '!.git'];
export const isExecutable = (fileMode: number | undefined) => {
if (!fileMode) {
return false;
}
const executeBitMask = 0o000111;
const res = fileMode & executeBitMask;
return res > 0;
};
export async function serializeDirectoryContents(
sourcePath: string,
options?: {
gitignore?: boolean;
globPatterns?: string[];
},
): Promise<SerializedFile[]> {
const paths = await globby(options?.globPatterns ?? DEFAULT_GLOB_PATTERNS, {
cwd: sourcePath,
dot: true,
gitignore: options?.gitignore,
followSymbolicLinks: false,
objectMode: true,
stats: true,
});
const limiter = limiterFactory(10);
return Promise.all(
paths.map(async ({ path, stats }) => ({
path,
content: await limiter(async () =>
fs.readFile(joinPath(sourcePath, path)),
),
executable: isExecutable(stats?.mode),
})),
);
}
@@ -0,0 +1,21 @@
/*
* Copyright 2022 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export interface SerializedFile {
path: string;
content: Buffer;
executable?: boolean;
}
@@ -84,6 +84,18 @@ export function createCatalogRegisterAction(options: {
},
],
},
output: {
type: 'object',
required: ['catalogInfoUrl'],
properties: {
entityRef: {
type: 'string',
},
catalogInfoUrl: {
type: 'string',
},
},
},
},
async handler(ctx) {
const { input } = ctx;
@@ -46,6 +46,7 @@ export function createCatalogWriteAction() {
},
},
},
supportsDryRun: true,
async handler(ctx) {
ctx.logStream.write(`Writing catalog-info.yaml`);
const { filePath, entity } = ctx.input;
@@ -51,6 +51,7 @@ export function createDebugLogAction() {
},
},
},
supportsDryRun: true,
async handler(ctx) {
ctx.logger.info(JSON.stringify(ctx.input, null, 2));
@@ -54,6 +54,7 @@ export function createFetchPlainAction(options: {
},
},
},
supportsDryRun: true,
async handler(ctx) {
ctx.logger.info('Fetching plain content from remote URL');
@@ -101,6 +101,7 @@ export function createFetchTemplateAction(options: {
},
},
},
supportsDryRun: true,
async handler(ctx) {
ctx.logger.info('Fetching template content from remote URL');
@@ -153,6 +154,7 @@ export function createFetchTemplateAction(options: {
dot: true,
onlyFiles: false,
markDirectories: true,
followSymbolicLinks: false,
});
const nonTemplatedEntries = new Set(
@@ -164,6 +166,7 @@ export function createFetchTemplateAction(options: {
dot: true,
onlyFiles: false,
markDirectories: true,
followSymbolicLinks: false,
}),
),
)
@@ -42,6 +42,7 @@ export const createFilesystemDeleteAction = () => {
},
},
},
supportsDryRun: true,
async handler(ctx) {
if (!Array.isArray(ctx.input?.files)) {
throw new InputError('files must be an Array');
@@ -66,6 +66,7 @@ export const createFilesystemRenameAction = () => {
},
},
},
supportsDryRun: true,
async handler(ctx) {
if (!Array.isArray(ctx.input?.files)) {
throw new InputError('files must be an Array');
@@ -14,21 +14,19 @@
* limitations under the License.
*/
import fs from 'fs-extra';
import { parseRepoUrl, isExecutable } from './util';
import path from 'path';
import { parseRepoUrl } from './util';
import {
GithubCredentialsProvider,
ScmIntegrationRegistry,
} from '@backstage/integration';
import { zipObject } from 'lodash';
import { createTemplateAction } from '../../createTemplateAction';
import { Octokit } from 'octokit';
import { InputError, CustomErrorBase } from '@backstage/errors';
import { createPullRequest } from 'octokit-plugin-create-pull-request';
import globby from 'globby';
import { resolveSafeChildPath } from '@backstage/backend-common';
import { getOctokitOptions } from '../github/helpers';
import { serializeDirectoryContents } from '../../../../lib/files';
export type Encoding = 'utf-8' | 'base64';
@@ -219,56 +217,39 @@ export const createPublishGithubPullRequestAction = ({
? resolveSafeChildPath(ctx.workspacePath, sourcePath)
: ctx.workspacePath;
const localFilePaths = await globby(['./**', './**/.*', '!.git'], {
cwd: fileRoot,
const directoryContents = await serializeDirectoryContents(fileRoot, {
gitignore: true,
dot: true,
});
const fileContents = await Promise.all(
localFilePaths.map(filePath => {
const absPath = resolveSafeChildPath(fileRoot, filePath);
const base64EncodedContent = fs
.readFileSync(absPath)
.toString('base64');
const fileStat = fs.statSync(absPath);
// See the properties of tree items
// in https://docs.github.com/en/rest/reference/git#trees
const githubTreeItemMode = isExecutable(fileStat.mode)
? '100755'
: '100644';
// Always use base64 encoding to avoid doubling a binary file in size
// due to interpreting a binary file as utf-8 and sending github
// the utf-8 encoded content.
//
// For example, the original gradle-wrapper.jar is 57.8k in https://github.com/kennethzfeng/pull-request-test/pull/5/files.
// Its size could be doubled to 98.3K (See https://github.com/kennethzfeng/pull-request-test/pull/4/files)
const encoding: Encoding = 'base64';
return {
encoding: encoding,
content: base64EncodedContent,
mode: githubTreeItemMode,
};
}),
const files = Object.fromEntries(
directoryContents.map(file => [
targetPath ? path.posix.join(targetPath, file.path) : file.path,
{
// See the properties of tree items
// in https://docs.github.com/en/rest/reference/git#trees
mode: file.executable ? '100755' : '100644',
// Always use base64 encoding to avoid doubling a binary file in size
// due to interpreting a binary file as utf-8 and sending github
// the utf-8 encoded content.
//
// For example, the original gradle-wrapper.jar is 57.8k in https://github.com/kennethzfeng/pull-request-test/pull/5/files.
// Its size could be doubled to 98.3K (See https://github.com/kennethzfeng/pull-request-test/pull/4/files)
encoding: 'base64' as const,
content: file.content.toString('base64'),
},
]),
);
const repoFilePaths = localFilePaths.map(repoFilePath => {
return targetPath ? `${targetPath}/${repoFilePath}` : repoFilePath;
});
const changes = [
{
files: zipObject(repoFilePaths, fileContents),
commit: title,
},
];
try {
const response = await client.createPullRequest({
owner,
repo,
title,
changes,
changes: [
{
files,
commit: title,
},
],
body: description,
head: branchName,
draft,
@@ -14,15 +14,14 @@
* limitations under the License.
*/
import { createTemplateAction } from '../../createTemplateAction';
import { readFile } from 'fs-extra';
import { Gitlab } from '@gitbeaker/node';
import globby from 'globby';
import { Types } from '@gitbeaker/core';
import path from 'path';
import { ScmIntegrationRegistry } from '@backstage/integration';
import { InputError } from '@backstage/errors';
import { parseRepoUrl } from './util';
import { resolveSafeChildPath } from '@backstage/backend-common';
import { serializeDirectoryContents } from '../../../../lib/files';
/**
* Create a new action that creates a gitlab merge request.
@@ -106,8 +105,6 @@ export const createPublishGitlabMergeRequestAction = (options: {
const { host } = parseRepoUrl(repoUrl, integrations);
const integrationConfig = integrations.gitlab.byHost(host);
const actions: Types.CommitAction[] = [];
const destinationBranch = ctx.input.branchName;
if (!integrationConfig) {
@@ -128,28 +125,21 @@ export const createPublishGitlabMergeRequestAction = (options: {
[tokenType]: token,
});
const fileRoot = ctx.workspacePath;
const localFilePaths = await globby([`${ctx.input.targetPath}/**`], {
cwd: fileRoot,
gitignore: true,
dot: true,
});
const fileContents = await Promise.all(
localFilePaths.map(p => readFile(resolveSafeChildPath(fileRoot, p))),
const targetPath = resolveSafeChildPath(
ctx.workspacePath,
ctx.input.targetPath,
);
const repoFilePaths = localFilePaths.map(repoFilePath => {
return repoFilePath;
const fileContents = await serializeDirectoryContents(targetPath, {
gitignore: true,
});
for (let i = 0; i < repoFilePaths.length; i++) {
actions.push({
action: 'create',
filePath: repoFilePaths[i],
content: fileContents[i].toString(),
});
}
const actions: Types.CommitAction[] = fileContents.map(file => ({
action: 'create',
filePath: path.posix.join(ctx.input.targetPath, file.path),
encoding: 'base64',
content: file.content.toString('base64'),
execute_filemode: file.executable,
}));
const projects = await api.Projects.show(ctx.input.projectid);

Some files were not shown because too many files have changed in this diff Show More