From a88aa8ff7137c4685772e61377ae3ec9095fbfd9 Mon Sep 17 00:00:00 2001 From: blam Date: Tue, 16 Aug 2022 13:44:53 +0200 Subject: [PATCH 1/5] chore: fix behaviour on windows for absolute paths Signed-off-by: blam --- .../src/scaffolder/actions/builtin/fetch/template.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/template.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/template.ts index 5e5b7052ed..bbba4f2fb3 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/template.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/template.ts @@ -301,12 +301,13 @@ export function createFetchTemplateAction(options: { } function containsSkippedContent(localOutputPath: string): boolean { - // if the path is absolute means that the root directory has been skipped // if the path is empty means that there is a file skipped in the root + // if the path is starts with a separator it means that the root directory has been skipped // if the path includes // means that there is a subdirectory skipped + // All paths returned are considered with / seperator because of globby returning the linux seperator for all os'. return ( localOutputPath === '' || - path.isAbsolute(localOutputPath) || - localOutputPath.includes(`${path.sep}${path.sep}`) + localOutputPath.startsWith('/') || + localOutputPath.includes('//') ); } From b10b6c4aa4c9d71a379a552c07bdba6065cec1ad Mon Sep 17 00:00:00 2001 From: blam Date: Tue, 16 Aug 2022 13:45:45 +0200 Subject: [PATCH 2/5] chore: add changeset Signed-off-by: blam --- .changeset/khaki-fans-brake.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/khaki-fans-brake.md diff --git a/.changeset/khaki-fans-brake.md b/.changeset/khaki-fans-brake.md new file mode 100644 index 0000000000..46d3cd518b --- /dev/null +++ b/.changeset/khaki-fans-brake.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder-backend': patch +--- + +Fix issue with absolute paths on windows hosts From 560fd1251a04329c0979ae63e9ea93b514b2e26a Mon Sep 17 00:00:00 2001 From: Ben Lambert Date: Tue, 16 Aug 2022 13:51:46 +0200 Subject: [PATCH 3/5] Update plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/template.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Fredrik Adelöw Signed-off-by: Ben Lambert --- .../src/scaffolder/actions/builtin/fetch/template.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/template.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/template.ts index bbba4f2fb3..18737a83f5 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/template.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/template.ts @@ -302,7 +302,7 @@ export function createFetchTemplateAction(options: { function containsSkippedContent(localOutputPath: string): boolean { // if the path is empty means that there is a file skipped in the root - // if the path is starts with a separator it means that the root directory has been skipped + // if the path starts with a separator it means that the root directory has been skipped // if the path includes // means that there is a subdirectory skipped // All paths returned are considered with / seperator because of globby returning the linux seperator for all os'. return ( From 387d5e9a721fc0645dfb42bd4cffe04444e060ec Mon Sep 17 00:00:00 2001 From: blam Date: Tue, 16 Aug 2022 13:51:55 +0200 Subject: [PATCH 4/5] chore: updating changeset messagingL: Signed-off-by: blam Signed-off-by: blam --- .changeset/khaki-fans-brake.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/khaki-fans-brake.md b/.changeset/khaki-fans-brake.md index 46d3cd518b..8460da3cc8 100644 --- a/.changeset/khaki-fans-brake.md +++ b/.changeset/khaki-fans-brake.md @@ -2,4 +2,4 @@ '@backstage/plugin-scaffolder-backend': patch --- -Fix issue with absolute paths on windows hosts +Fix issue on Windows where templated files where not properly skipped as intended. From 8fa852f2c864e0dd7cc285bc483c1efec01a950c Mon Sep 17 00:00:00 2001 From: blam Date: Tue, 16 Aug 2022 13:53:33 +0200 Subject: [PATCH 5/5] chore: `path` is no longer needed Signed-off-by: blam --- .../src/scaffolder/actions/builtin/fetch/template.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/template.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/template.ts index 18737a83f5..1ead7ebcd6 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/template.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/template.ts @@ -27,7 +27,6 @@ import { TemplateFilter, SecureTemplater, } from '../../../../lib/templating/SecureTemplater'; -import path from 'path'; /** * Downloads a skeleton, templates variables into file and directory names and content.