From 5e04610bb62886fe8dc1c3779a0466529d415a41 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Fri, 22 Mar 2024 13:08:26 +0100 Subject: [PATCH 1/7] add script to check for a configurable length of paths --- .../devops/build/check-path-length.js | 44 +++++++++++++++++++ src/Umbraco.Web.UI.Client/package.json | 3 +- 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 src/Umbraco.Web.UI.Client/devops/build/check-path-length.js diff --git a/src/Umbraco.Web.UI.Client/devops/build/check-path-length.js b/src/Umbraco.Web.UI.Client/devops/build/check-path-length.js new file mode 100644 index 0000000000..72b05df3e3 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/devops/build/check-path-length.js @@ -0,0 +1,44 @@ +import { readdirSync, statSync } from 'fs'; +import { join } from 'path'; + +const PROJECT_DIR = process.argv[2] ?? '.'; +const MAX_PATH_LENGTH = process.argv[3] ?? 140; +const IS_CI = process.env.CI === 'true'; +const IS_AZURE_PIPELINES = process.env.SYSTEM_TEAMFOUNDATIONCOLLECTIONURI !== undefined; +const IS_GITHUB_ACTIONS = process.env.GITHUB_ACTIONS === 'true'; +const FILE_PATH_COLOR = '\x1b[36m%s\x1b[0m'; + +console.log(`Checking path length in ${PROJECT_DIR} for paths exceeding ${MAX_PATH_LENGTH}...`); +console.log('CI detected:', IS_CI); + +console.log('\n-----------------------------------'); +console.log('Results:'); +console.log('-----------------------------------\n'); + +function checkPathLength(dir) { + const files = readdirSync(dir); + + files.forEach(file => { + const filePath = join(dir, file); + if (filePath.length > MAX_PATH_LENGTH) { + + if (IS_CI) { + process.exitCode = 1; + } + + if (IS_AZURE_PIPELINES) { + console.error(`##vso[task.logissue type=warn;]Path exceeds maximum length of ${MAX_PATH_LENGTH} characters: ${filePath} with ${filePath.length} characters`); + } else if (IS_GITHUB_ACTIONS) { + console.error(`::warn file=${filePath}::Path exceeds maximum length of ${MAX_PATH_LENGTH} characters with ${filePath.length} characters`); + } else { + console.error(`Path exceeds maximum length of ${MAX_PATH_LENGTH} characters: ${FILE_PATH_COLOR}`, filePath, filePath.length); + } + } + + if (statSync(filePath).isDirectory()) { + checkPathLength(filePath, MAX_PATH_LENGTH); + } + }); +} + +checkPathLength(PROJECT_DIR, MAX_PATH_LENGTH); diff --git a/src/Umbraco.Web.UI.Client/package.json b/src/Umbraco.Web.UI.Client/package.json index 760ddaa09c..07d0a90027 100644 --- a/src/Umbraco.Web.UI.Client/package.json +++ b/src/Umbraco.Web.UI.Client/package.json @@ -122,8 +122,9 @@ "build:for:cms": "npm run build && node ./devops/build/copy-to-cms.js", "build:for:static": "vite build", "build:vite": "tsc && vite build --mode staging", - "build": "tsc --project ./src/tsconfig.build.json && rollup -c ./src/rollup.config.js && npm run package:validate && npm run generate:manifest", + "build": "tsc --project ./src/tsconfig.build.json && rollup -c ./src/rollup.config.js && npm run package:validate && npm run generate:manifest && npm run check:paths", "check": "npm run lint:errors && npm run compile && npm run build-storybook && npm run generate:jsonschema:dist", + "check:paths": "node ./devops/build/check-path-length.js src 140", "compile": "tsc", "dev": "vite", "dev:server": "VITE_UMBRACO_USE_MSW=off vite", From 7b6cd963a0f538a4e3e55b77d7f4415e96543b6c Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Fri, 22 Mar 2024 13:15:47 +0100 Subject: [PATCH 2/7] optimise github actions --- .../devops/build/check-path-length.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/devops/build/check-path-length.js b/src/Umbraco.Web.UI.Client/devops/build/check-path-length.js index 72b05df3e3..640fd3c5b0 100644 --- a/src/Umbraco.Web.UI.Client/devops/build/check-path-length.js +++ b/src/Umbraco.Web.UI.Client/devops/build/check-path-length.js @@ -8,6 +8,9 @@ const IS_AZURE_PIPELINES = process.env.SYSTEM_TEAMFOUNDATIONCOLLECTIONURI !== un const IS_GITHUB_ACTIONS = process.env.GITHUB_ACTIONS === 'true'; const FILE_PATH_COLOR = '\x1b[36m%s\x1b[0m'; +if (IS_CI) { + console.log('::group::Checking path length'); +} console.log(`Checking path length in ${PROJECT_DIR} for paths exceeding ${MAX_PATH_LENGTH}...`); console.log('CI detected:', IS_CI); @@ -27,9 +30,9 @@ function checkPathLength(dir) { } if (IS_AZURE_PIPELINES) { - console.error(`##vso[task.logissue type=warn;]Path exceeds maximum length of ${MAX_PATH_LENGTH} characters: ${filePath} with ${filePath.length} characters`); + console.error(`##vso[task.logissue type=warning;]Path exceeds maximum length of ${MAX_PATH_LENGTH} characters: ${filePath} with ${filePath.length} characters`); } else if (IS_GITHUB_ACTIONS) { - console.error(`::warn file=${filePath}::Path exceeds maximum length of ${MAX_PATH_LENGTH} characters with ${filePath.length} characters`); + console.error(`::warning file=${filePath},title=Path exceeds ${MAX_PATH_LENGTH}::Paths should not be longer than ${MAX_PATH_LENGTH} characters to support WIN32 systems. This file exceeds that with ${MAX_PATH_LENGTH - filePath.length} characters.`); } else { console.error(`Path exceeds maximum length of ${MAX_PATH_LENGTH} characters: ${FILE_PATH_COLOR}`, filePath, filePath.length); } @@ -42,3 +45,7 @@ function checkPathLength(dir) { } checkPathLength(PROJECT_DIR, MAX_PATH_LENGTH); + +if (IS_CI) { + console.log('::endgroup::'); +} From ccef52add47fe2f52ac792fedcf26ff007483fae Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Fri, 22 Mar 2024 13:19:02 +0100 Subject: [PATCH 3/7] optimise github actions --- src/Umbraco.Web.UI.Client/devops/build/check-path-length.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/devops/build/check-path-length.js b/src/Umbraco.Web.UI.Client/devops/build/check-path-length.js index 640fd3c5b0..0a2df34f3f 100644 --- a/src/Umbraco.Web.UI.Client/devops/build/check-path-length.js +++ b/src/Umbraco.Web.UI.Client/devops/build/check-path-length.js @@ -26,13 +26,13 @@ function checkPathLength(dir) { if (filePath.length > MAX_PATH_LENGTH) { if (IS_CI) { - process.exitCode = 1; + //process.exitCode = 1; // TODO: Uncomment this line to fail the build } if (IS_AZURE_PIPELINES) { console.error(`##vso[task.logissue type=warning;]Path exceeds maximum length of ${MAX_PATH_LENGTH} characters: ${filePath} with ${filePath.length} characters`); } else if (IS_GITHUB_ACTIONS) { - console.error(`::warning file=${filePath},title=Path exceeds ${MAX_PATH_LENGTH}::Paths should not be longer than ${MAX_PATH_LENGTH} characters to support WIN32 systems. This file exceeds that with ${MAX_PATH_LENGTH - filePath.length} characters.`); + console.error(`::warning file=${filePath},title=Path exceeds ${MAX_PATH_LENGTH}::Paths should not be longer than ${MAX_PATH_LENGTH} characters to support WIN32 systems. The file ${filePath} exceeds that with ${filePath.length - MAX_PATH_LENGTH} characters.`); } else { console.error(`Path exceeds maximum length of ${MAX_PATH_LENGTH} characters: ${FILE_PATH_COLOR}`, filePath, filePath.length); } From 8ea0c9c919360f68df8c19c731568620ab6e7142 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Fri, 22 Mar 2024 13:47:40 +0100 Subject: [PATCH 4/7] optimise github actions --- .../devops/build/check-path-length.js | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/devops/build/check-path-length.js b/src/Umbraco.Web.UI.Client/devops/build/check-path-length.js index 0a2df34f3f..5c49f0793c 100644 --- a/src/Umbraco.Web.UI.Client/devops/build/check-path-length.js +++ b/src/Umbraco.Web.UI.Client/devops/build/check-path-length.js @@ -8,9 +8,6 @@ const IS_AZURE_PIPELINES = process.env.SYSTEM_TEAMFOUNDATIONCOLLECTIONURI !== un const IS_GITHUB_ACTIONS = process.env.GITHUB_ACTIONS === 'true'; const FILE_PATH_COLOR = '\x1b[36m%s\x1b[0m'; -if (IS_CI) { - console.log('::group::Checking path length'); -} console.log(`Checking path length in ${PROJECT_DIR} for paths exceeding ${MAX_PATH_LENGTH}...`); console.log('CI detected:', IS_CI); @@ -32,9 +29,9 @@ function checkPathLength(dir) { if (IS_AZURE_PIPELINES) { console.error(`##vso[task.logissue type=warning;]Path exceeds maximum length of ${MAX_PATH_LENGTH} characters: ${filePath} with ${filePath.length} characters`); } else if (IS_GITHUB_ACTIONS) { - console.error(`::warning file=${filePath},title=Path exceeds ${MAX_PATH_LENGTH}::Paths should not be longer than ${MAX_PATH_LENGTH} characters to support WIN32 systems. The file ${filePath} exceeds that with ${filePath.length - MAX_PATH_LENGTH} characters.`); + console.error(`::warning file=${filePath},title=Path exceeds ${MAX_PATH_LENGTH} characters::Paths should not be longer than ${MAX_PATH_LENGTH} characters to support WIN32 systems.\nThe file ${filePath} exceeds that with ${filePath.length - MAX_PATH_LENGTH} characters.`); } else { - console.error(`Path exceeds maximum length of ${MAX_PATH_LENGTH} characters: ${FILE_PATH_COLOR}`, filePath, filePath.length); + console.error(`Path exceeds maximum length of ${MAX_PATH_LENGTH} characters: ${FILE_PATH_COLOR}`, filePath, filePath.length - MAX_PATH_LENGTH); } } @@ -45,7 +42,3 @@ function checkPathLength(dir) { } checkPathLength(PROJECT_DIR, MAX_PATH_LENGTH); - -if (IS_CI) { - console.log('::endgroup::'); -} From 824773d1b7dfb9ace9e7dd7cbdd4f267b96459e0 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Fri, 22 Mar 2024 13:49:53 +0100 Subject: [PATCH 5/7] optimise azure devops --- src/Umbraco.Web.UI.Client/devops/build/check-path-length.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Umbraco.Web.UI.Client/devops/build/check-path-length.js b/src/Umbraco.Web.UI.Client/devops/build/check-path-length.js index 5c49f0793c..4ec317375e 100644 --- a/src/Umbraco.Web.UI.Client/devops/build/check-path-length.js +++ b/src/Umbraco.Web.UI.Client/devops/build/check-path-length.js @@ -27,7 +27,7 @@ function checkPathLength(dir) { } if (IS_AZURE_PIPELINES) { - console.error(`##vso[task.logissue type=warning;]Path exceeds maximum length of ${MAX_PATH_LENGTH} characters: ${filePath} with ${filePath.length} characters`); + console.error(`##vso[task.logissue type=warning;sourcepath=${filePath};]Path exceeds maximum length of ${MAX_PATH_LENGTH} characters: ${filePath} with ${filePath.length} characters`); } else if (IS_GITHUB_ACTIONS) { console.error(`::warning file=${filePath},title=Path exceeds ${MAX_PATH_LENGTH} characters::Paths should not be longer than ${MAX_PATH_LENGTH} characters to support WIN32 systems.\nThe file ${filePath} exceeds that with ${filePath.length - MAX_PATH_LENGTH} characters.`); } else { From 8f1e88d036be0800b677dac3be9fa082f8c4381d Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Fri, 22 Mar 2024 14:01:42 +0100 Subject: [PATCH 6/7] optimise github actions --- src/Umbraco.Web.UI.Client/devops/build/check-path-length.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Umbraco.Web.UI.Client/devops/build/check-path-length.js b/src/Umbraco.Web.UI.Client/devops/build/check-path-length.js index 4ec317375e..be67dc9bb4 100644 --- a/src/Umbraco.Web.UI.Client/devops/build/check-path-length.js +++ b/src/Umbraco.Web.UI.Client/devops/build/check-path-length.js @@ -29,7 +29,7 @@ function checkPathLength(dir) { if (IS_AZURE_PIPELINES) { console.error(`##vso[task.logissue type=warning;sourcepath=${filePath};]Path exceeds maximum length of ${MAX_PATH_LENGTH} characters: ${filePath} with ${filePath.length} characters`); } else if (IS_GITHUB_ACTIONS) { - console.error(`::warning file=${filePath},title=Path exceeds ${MAX_PATH_LENGTH} characters::Paths should not be longer than ${MAX_PATH_LENGTH} characters to support WIN32 systems.\nThe file ${filePath} exceeds that with ${filePath.length - MAX_PATH_LENGTH} characters.`); + console.error(`::warning file=${filePath},title=Path exceeds ${MAX_PATH_LENGTH} characters::Paths should not be longer than ${MAX_PATH_LENGTH} characters to support WIN32 systems. The file ${filePath} exceeds that with ${filePath.length - MAX_PATH_LENGTH} characters.`); } else { console.error(`Path exceeds maximum length of ${MAX_PATH_LENGTH} characters: ${FILE_PATH_COLOR}`, filePath, filePath.length - MAX_PATH_LENGTH); } From 759d79361743f18ad80278251022e07423f23909 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Fri, 22 Mar 2024 14:03:02 +0100 Subject: [PATCH 7/7] optimise azure pipelines --- src/Umbraco.Web.UI.Client/devops/build/check-path-length.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Umbraco.Web.UI.Client/devops/build/check-path-length.js b/src/Umbraco.Web.UI.Client/devops/build/check-path-length.js index be67dc9bb4..d21097639b 100644 --- a/src/Umbraco.Web.UI.Client/devops/build/check-path-length.js +++ b/src/Umbraco.Web.UI.Client/devops/build/check-path-length.js @@ -4,7 +4,7 @@ import { join } from 'path'; const PROJECT_DIR = process.argv[2] ?? '.'; const MAX_PATH_LENGTH = process.argv[3] ?? 140; const IS_CI = process.env.CI === 'true'; -const IS_AZURE_PIPELINES = process.env.SYSTEM_TEAMFOUNDATIONCOLLECTIONURI !== undefined; +const IS_AZURE_PIPELINES = process.env.TF_BUILD === 'true'; const IS_GITHUB_ACTIONS = process.env.GITHUB_ACTIONS === 'true'; const FILE_PATH_COLOR = '\x1b[36m%s\x1b[0m';