Skip to content

Commit c27a2c3

Browse files
authored
Merge pull request #2033 from umbraco/v14/chore/check-paths-in-dist-cms
Chore: Check path length in dist-cms instead of src
2 parents 968d722 + 16d56b5 commit c27a2c3

File tree

40 files changed

+163
-159
lines changed

40 files changed

+163
-159
lines changed

.github/workflows/build_test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ jobs:
3636
- run: npm ci --no-audit --no-fund --prefer-offline
3737
- run: npm run lint:errors
3838
- run: npm run build:for:cms
39+
- run: npm run check:paths
3940
- run: npm run generate:jsonschema:dist
4041

4142
test:

devops/build/check-path-length.js

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,28 @@ console.log('\n-----------------------------------');
1818
console.log('Results:');
1919
console.log('-----------------------------------\n');
2020

21+
const hasError = checkPathLength(PROJECT_DIR);
22+
23+
if (hasError) {
24+
console.log('\n-----------------------------------');
25+
console.log(ERROR_COLOR, 'Path length check failed');
26+
console.log('-----------------------------------\n');
27+
if (IS_CI && processExitCode) {
28+
process.exit(processExitCode);
29+
}
30+
} else {
31+
console.log('\n-----------------------------------');
32+
console.log(SUCCESS_COLOR, 'Path length check passed');
33+
console.log('-----------------------------------\n');
34+
}
35+
36+
// Functions
37+
38+
/**
39+
* Recursively check the path length of all files in a directory.
40+
* @param {string} dir - The directory to check for path lengths
41+
* @returns {boolean}
42+
*/
2143
function checkPathLength(dir) {
2244
const files = readdirSync(dir);
2345
let hasError = false;
@@ -28,11 +50,11 @@ function checkPathLength(dir) {
2850
hasError = true;
2951

3052
if (IS_AZURE_PIPELINES) {
31-
console.error(`##vso[task.logissue type=warning;sourcepath=${filePath};]Path exceeds maximum length of ${MAX_PATH_LENGTH} characters: ${filePath} with ${filePath.length} characters`);
53+
console.error(`##vso[task.logissue type=error;sourcepath=${mapFileToSourcePath(filePath)};]Path exceeds maximum length of ${MAX_PATH_LENGTH} characters: ${filePath} with ${filePath.length} characters`);
3254
} else if (IS_GITHUB_ACTIONS) {
33-
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.`);
55+
console.error(`::error file=${mapFileToSourcePath(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.`);
3456
} else {
35-
console.error(`Path exceeds maximum length of ${MAX_PATH_LENGTH} characters: ${FILE_PATH_COLOR}`, filePath, filePath.length - MAX_PATH_LENGTH);
57+
console.error(FILE_PATH_COLOR, mapFileToSourcePath(filePath), '(exceeds by', filePath.length - MAX_PATH_LENGTH, 'chars)');
3658
}
3759
}
3860

@@ -47,17 +69,12 @@ function checkPathLength(dir) {
4769
return hasError;
4870
}
4971

50-
const hasError = checkPathLength(PROJECT_DIR, MAX_PATH_LENGTH);
51-
52-
if (hasError) {
53-
console.error('\n-----------------------------------');
54-
console.error(ERROR_COLOR, 'Path length check failed');
55-
console.error('-----------------------------------\n');
56-
if (IS_CI && processExitCode) {
57-
process.exit(processExitCode);
58-
}
59-
} else {
60-
console.log('\n-----------------------------------');
61-
console.log(SUCCESS_COLOR, 'Path length check passed');
62-
console.log('-----------------------------------\n');
72+
/**
73+
* Maps a file path to a source path for CI logs.
74+
* @remark This might not always work as expected, especially on bundled files, but it's a best effort to map the file path to a source path.
75+
* @param {string} file - The file path to map to a source path
76+
* @returns {string}
77+
*/
78+
function mapFileToSourcePath(file) {
79+
return file.replace(PROJECT_DIR, 'src').replace('.js', '.ts');
6380
}

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,14 @@
151151
"backoffice:test:e2e": "npx playwright test",
152152
"build-storybook": "npm run wc-analyze && storybook build",
153153
"build:for:cms": "npm run build && npm run build:workspaces && npm run generate:manifest && npm run package:validate && node ./devops/build/copy-to-cms.js",
154-
"build:for:npm": "npm run build && npm run generate:manifest && npm run package:validate",
154+
"build:for:npm": "npm run build -- --declaration && npm run generate:manifest && npm run package:validate",
155155
"build:for:static": "vite build",
156156
"build:vite": "tsc && vite build --mode staging",
157157
"build:workspaces": "npm run build -ws --if-present",
158-
"build": "tsc --project ./src/tsconfig.build.json && rollup -c ./src/rollup.config.js",
158+
"build": "tsc --project ./src/tsconfig.build.json",
159+
"postbuild": "rollup -c ./src/rollup.config.js",
159160
"check": "npm run lint:errors && npm run compile && npm run build-storybook && npm run generate:jsonschema:dist",
160-
"check:paths": "node ./devops/build/check-path-length.js src 140",
161+
"check:paths": "node ./devops/build/check-path-length.js dist-cms 120",
161162
"compile": "tsc",
162163
"postinstall": "npm run generate:tsconfig",
163164
"dev": "vite",
@@ -190,7 +191,7 @@
190191
"wc-analyze": "wca **/*.element.ts --outFile dist-cms/custom-elements.json",
191192
"generate:tsconfig": "node ./devops/tsconfig/index.js",
192193
"generate:manifest": "node ./devops/build/create-umbraco-package.js",
193-
"package:validate": "node ./devops/package/validate-exports.js && npm run check:paths",
194+
"package:validate": "node ./devops/package/validate-exports.js",
194195
"generate:ui-api-docs": "typedoc --options typedoc.config.js"
195196
},
196197
"engines": {

src/packages/media/media/property-editors/image-crops-configuration/index.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/packages/media/media/property-editors/image-crops-configuration/property-editor-ui-image-crops-configuration.stories.ts

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/packages/media/media/property-editors/image-crops-configuration/property-editor-ui-image-crops-configuration.test.ts

Lines changed: 0 additions & 26 deletions
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './property-editor-ui-image-crops.element.js';

src/packages/media/media/property-editors/image-crops-configuration/manifests.ts renamed to src/packages/media/media/property-editors/image-crops/manifests.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import type { ManifestPropertyEditorUi } from '@umbraco-cms/backoffice/extension
33
export const manifest: ManifestPropertyEditorUi = {
44
type: 'propertyEditorUi',
55
alias: 'Umb.PropertyEditorUi.ImageCropsConfiguration',
6-
name: 'Image Crops Configuration Property Editor UI',
7-
element: () => import('./property-editor-ui-image-crops-configuration.element.js'),
6+
name: 'Image Crops Property Editor UI',
7+
element: () => import('./property-editor-ui-image-crops.element.js'),
88
meta: {
99
label: 'Image Crops Configuration',
1010
icon: 'icon-autofill',
Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,13 @@ export type UmbCrop = {
1313
};
1414

1515
/**
16-
* @element umb-property-editor-ui-image-crops-configuration
16+
* @element umb-property-editor-ui-image-crops
1717
*/
18-
@customElement('umb-property-editor-ui-image-crops-configuration')
19-
export class UmbPropertyEditorUIImageCropsConfigurationElement
20-
extends UmbLitElement
21-
implements UmbPropertyEditorUiElement
22-
{
18+
@customElement('umb-property-editor-ui-image-crops')
19+
export class UmbPropertyEditorUIImageCropsElement extends UmbLitElement implements UmbPropertyEditorUiElement {
2320
@query('#label')
2421
private _labelInput!: HTMLInputElement;
2522

26-
//TODO MAKE TYPE
2723
@property({ attribute: false })
2824
value: UmbCrop[] = [];
2925

@@ -188,7 +184,7 @@ export class UmbPropertyEditorUIImageCropsConfigurationElement
188184
`;
189185
}
190186

191-
static override styles = [
187+
static override readonly styles = [
192188
UmbTextStyles,
193189
css`
194190
:host {
@@ -244,10 +240,10 @@ export class UmbPropertyEditorUIImageCropsConfigurationElement
244240
];
245241
}
246242

247-
export default UmbPropertyEditorUIImageCropsConfigurationElement;
243+
export default UmbPropertyEditorUIImageCropsElement;
248244

249245
declare global {
250246
interface HTMLElementTagNameMap {
251-
'umb-property-editor-ui-image-crops-configuration': UmbPropertyEditorUIImageCropsConfigurationElement;
247+
'umb-property-editor-ui-image-crops': UmbPropertyEditorUIImageCropsElement;
252248
}
253249
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import type { UmbPropertyEditorUIImageCropsElement } from './property-editor-ui-image-crops.element.js';
2+
import type { Meta, StoryObj } from '@storybook/web-components';
3+
4+
import './property-editor-ui-image-crops.element.js';
5+
6+
const meta: Meta<UmbPropertyEditorUIImageCropsElement> = {
7+
title: 'Property Editor UIs/Image Crops',
8+
id: 'umb-property-editor-ui-image-crops',
9+
component: 'umb-property-editor-ui-image-crops',
10+
};
11+
12+
export default meta;
13+
type Story = StoryObj<UmbPropertyEditorUIImageCropsElement>;
14+
15+
export const Overview: Story = {};

0 commit comments

Comments
 (0)