Skip to content

Commit f89c6a3

Browse files
feat(compiler): allow ignore pattern for copy task (#5899)
* feat: allow ignore pattern for copy task * add tests to pipeline * fix code docs * remove unnecessary files * add workflow to pipeline * add missing script * fix end-to-end tests * prettier * revert some changes * set absolute flag * use rimraf for support in Windows * chore(deps): install Jest dependencies via TypeScript and Node * fix task for windows * make it relative to source path * tweak
1 parent 70c4e8a commit f89c6a3

21 files changed

+973
-58
lines changed

.github/workflows/main.yml

+5
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ jobs:
3838
needs: [build_core]
3939
uses: ./.github/workflows/test-bundlers.yml
4040

41+
copytask_tests:
42+
name: Copy Task Tests
43+
needs: [build_core]
44+
uses: ./.github/workflows/test-copytask.yml
45+
4146
component_starter_tests:
4247
name: Component Starter Smoke Test
4348
needs: [build_core]

.github/workflows/test-copytask.yml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Copy Task Tests
2+
3+
on:
4+
workflow_call:
5+
# Make this a reusable workflow, no value needed
6+
# https://docs.github.com/en/actions/using-workflows/reusing-workflows
7+
8+
jobs:
9+
bundler_tests:
10+
name: Verify Copy Task
11+
runs-on: 'ubuntu-22.04'
12+
steps:
13+
- name: Checkout Code
14+
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
15+
16+
- name: Get Core Dependencies
17+
uses: ./.github/workflows/actions/get-core-dependencies
18+
19+
- name: Download Build Archive
20+
uses: ./.github/workflows/actions/download-archive
21+
with:
22+
name: stencil-core
23+
path: .
24+
filename: stencil-core-build.zip
25+
26+
- name: Bundler Tests
27+
run: npm run test.copytask
28+
shell: bash
29+
30+
- name: Check Git Context
31+
uses: ./.github/workflows/actions/check-git-context

package-lock.json

+184-21
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+5-3
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@
9696
"build": "npm run clean && npm run tsc.prod && npm run ts scripts/index.ts -- --prod --ci",
9797
"build.watch": "npm run build -- --watch",
9898
"build.updateSelectorEngine": "npm run ts scripts/updateSelectorEngine.ts",
99-
"clean": "rm -rf build/ cli/ compiler/ dev-server/ internal/ mock-doc/ sys/ testing/ && npm run clean:scripts && npm run clean.screenshots",
100-
"clean.screenshots": "rm -rf test/end-to-end/screenshot/builds test/end-to-end/screenshot/images",
101-
"clean:scripts": "rm -rf scripts/build",
99+
"clean": "rimraf build/ cli/ compiler/ dev-server/ internal/ mock-doc/ sys/ testing/ && npm run clean:scripts && npm run clean.screenshots",
100+
"clean.screenshots": "rimraf test/end-to-end/screenshot/builds test/end-to-end/screenshot/images",
101+
"clean:scripts": "rimraf scripts/build",
102102
"lint": "eslint 'bin/*' 'scripts/*.ts' 'scripts/**/*.ts' 'src/*.ts' 'src/**/*.ts' 'src/**/*.tsx' 'test/wdio/**/*.tsx'",
103103
"install.jest": "npx tsx ./src/testing/jest/install-dependencies.mts",
104104
"prettier": "npm run prettier.base -- --write",
@@ -112,6 +112,7 @@
112112
"test": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js --coverage",
113113
"test.analysis": "cd test && npm run analysis.build-and-analyze",
114114
"test.bundlers": "cd test && npm run bundlers",
115+
"test.copytask": "cd test/copy-task && npm ci && npm run test",
115116
"test.dist": "npm run ts scripts/index.ts -- --validate-build",
116117
"test.end-to-end": "cd test/end-to-end && npm ci && npm test && npm run test.dist",
117118
"test.jest": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js",
@@ -184,6 +185,7 @@
184185
"prettier": "3.3.1",
185186
"prompts": "2.4.2",
186187
"puppeteer": "^21.0.0",
188+
"rimraf": "^6.0.1",
187189
"rollup": "2.56.3",
188190
"semver": "^7.3.7",
189191
"terser": "5.31.1",

src/compiler/output-targets/copy/assets-copy-tasks.ts

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export const getComponentAssetsCopyTasks = (
2727
src: assetsMeta.absolutePath,
2828
dest: join(dest, assetsMeta.cmpRelativePath),
2929
warn: false,
30+
ignore: undefined,
3031
keepDirStructure: false,
3132
});
3233
});
@@ -37,6 +38,7 @@ export const getComponentAssetsCopyTasks = (
3738
src: assetsMeta.absolutePath,
3839
dest: collectionDirDestination,
3940
warn: false,
41+
ignore: undefined,
4042
keepDirStructure: false,
4143
});
4244
});

src/compiler/output-targets/copy/output-copy.ts

+12
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@ import type * as d from '../../../declarations';
55
import { canSkipAssetsCopy, getComponentAssetsCopyTasks } from './assets-copy-tasks';
66
import { getDestAbsPath, getSrcAbsPath } from './local-copy-tasks';
77

8+
const DEFAULT_IGNORE = [
9+
'**/__mocks__/**',
10+
'**/__fixtures__/**',
11+
'**/dist/**',
12+
'**/.{idea,git,cache,output,temp}/**',
13+
'**/.ds_store',
14+
'**/.gitignore',
15+
'**/desktop.ini',
16+
'**/thumbs.db',
17+
];
18+
819
export const outputCopy = async (config: d.ValidatedConfig, compilerCtx: d.CompilerCtx, buildCtx: d.BuildCtx) => {
920
const outputTargets = config.outputTargets.filter(isOutputTargetCopy);
1021
if (outputTargets.length === 0) {
@@ -83,6 +94,7 @@ const transformToAbs = (copyTask: d.CopyTask, dest: string): Required<d.CopyTask
8394
return {
8495
src: copyTask.src,
8596
dest: getDestAbsPath(copyTask.src, dest, copyTask.dest),
97+
ignore: copyTask.ignore || DEFAULT_IGNORE,
8698
keepDirStructure:
8799
typeof copyTask.keepDirStructure === 'boolean' ? copyTask.keepDirStructure : copyTask.dest == null,
88100
warn: copyTask.warn !== false,

0 commit comments

Comments
 (0)