Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DRAFT PNPM (other tries) #4934

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
42a0939
fix babel-loader using resolve
Oct 13, 2023
c2567d8
fix all loaders
Oct 13, 2023
3bd4691
fix test:umd for design-tokens
Oct 13, 2023
f73cdb9
fix jest script
Oct 13, 2023
f706b51
add jest-cli to scripts-core
Oct 13, 2023
d25413f
add types to assets-api, add babel-core to icons
Oct 13, 2023
18486f8
fix babel config
Oct 13, 2023
dd7cc38
fix babel config using resolve + fix all extends
Oct 13, 2023
b44a458
try to fix babel for angularjs-annotate
Oct 13, 2023
7386c97
remove @types/enzyme, add @types/jest to flow-designer + more missign…
Oct 13, 2023
4be00f4
add missing deps
Oct 13, 2023
94d475c
fix flow-designer test
Oct 13, 2023
577bd4e
fix test-setup
Oct 13, 2023
c137426
add tsconfig.build.json to components and flow-designer
Oct 13, 2023
b275322
fix components
Oct 13, 2023
23cbf8f
fix package stepper
Oct 13, 2023
87832ba
fix jest mock
Oct 13, 2023
bd24708
Merge 87832baad9070d4b4c8c7ec09163417393b501da into 9bc0d0050c6e9570a…
smouillour Oct 13, 2023
08efdcf
chore: pnpm-deduplicate
github-actions[bot] Oct 13, 2023
4c7f73d
fix test in dynamic-cdn and scripts-core
Oct 13, 2023
2d328e0
Remove ref to icons in assets-api
Oct 16, 2023
880d923
Merge 2d328e07488f7dd24a56658da312ddff233d21a8 into 9bc0d0050c6e9570a…
smouillour Oct 16, 2023
2f3ddd4
chore: pnpm-deduplicate
github-actions[bot] Oct 16, 2023
11976b7
fix pnpm version
Oct 16, 2023
f7222f9
fix design-tokens
Oct 16, 2023
44c2b3a
stream tests
Oct 16, 2023
32b0ef3
add missing jest + reduce usage of cache in GHA
Oct 16, 2023
cb20ef2
remove stream and --frozen-lockfile for test
Oct 16, 2023
82c1759
add console.log
Oct 16, 2023
22b9fb8
try to fix test in dynamic-cdn-webpack-plugin
Oct 17, 2023
4e86c12
revert change in dynamic-cdn-plugin
Oct 17, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions .github/actions/setup-node/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ runs:
- uses: pnpm/action-setup@v2
with:
version: 8

- name: Set up Node.js
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d #v3.8.1
with:
Expand All @@ -19,15 +18,15 @@ runs:
scope: '@talend'
cache: 'pnpm'

- name: Get pnpm cache directory path
id: pnpm-cache-dir-path
shell: bash
run: echo "dir=$(pnpm store path)" >> $GITHUB_OUTPUT
# - name: Get pnpm cache directory path
# id: pnpm-cache-dir-path
# shell: bash
# run: echo "dir=$(pnpm store path)" >> $GITHUB_OUTPUT

- uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 #v3.3.2
id: pnpm-cache # use this to check for `cache-hit` (`steps.pnpm-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.pnpm-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-
# - uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 #v3.3.2
# id: pnpm-cache # use this to check for `cache-hit` (`steps.pnpm-cache.outputs.cache-hit != 'true'`)
# with:
# path: ${{ steps.pnpm-cache-dir-path.outputs.dir }}
# key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
# restore-keys: |
# ${{ runner.os }}-pnpm-
13 changes: 13 additions & 0 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# How to run github action locally

Use the cli ACT: https://github.com/nektos/act

# How to run PR-TEST

```bash
act pull_request -j build -W .github/workflows/pr-test.yml
```

```bash
act --container-architecture linux/amd64 pull_request -j build -W .github/workflows/pr-test.yml
```
1 change: 1 addition & 0 deletions fork/dynamic-cdn-webpack-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"dependencies": {
"@talend/module-to-cdn": "^9.9.1",
"read-pkg-up": "^7.0.1",
"semver": "^7.5.4",
"webpack-sources": "^3.2.3"
},
"peerDependencies": {
Expand Down
40 changes: 16 additions & 24 deletions fork/dynamic-cdn-webpack-plugin/src/find.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ function findPackage(info) {
if (name.startsWith('@')) {
[scope, name] = info.name.split('/');
}
// eslint-disable-next-line no-use-before-define
return findPackages(scope, name).find(cwd => {
const {
packageJson: { version },
Expand All @@ -21,13 +22,9 @@ function findPackage(info) {
return semver.satisfies(version, range);
});
}
let warnPNPMonce = true;
let pnpmMaxSubLevel = 0;

function findPackagesFromScopeFolder(scope, name, scopeFolderPath) {
const isWantedScope = scopeFolderPath.endsWith(`${path.sep}${scope}`);
const isPNPMProcess =
process.env.npm_config_user_agent && process.env.npm_config_user_agent.includes('pnpm');
return fs
.readdirSync(scopeFolderPath, { withFileTypes: true })
.filter(f => f.isDirectory() || f.isSymbolicLink())
Expand All @@ -39,24 +36,12 @@ function findPackagesFromScopeFolder(scope, name, scopeFolderPath) {
return accu.concat(subFolderPath);
}

if ((isPNPMProcess && pnpmMaxSubLevel < 4) || !isPNPMProcess) {
if (isPNPMProcess) {
pnpmMaxSubLevel++;
console.warn('Executed with PNPM: !!');
}
// TODO NOT COMPATIBLE WITH PNPM
// the scope or package name is not the one we look for
// if there is a nested node modules folder, we dive into it for the search
const nestedNodeModulesPath = path.join(subFolderPath, 'node_modules');
if (fs.existsSync(nestedNodeModulesPath)) {
return accu.concat(
findPackagesFromNonScopeFolder(scope, name, nestedNodeModulesPath, []),
);
}
} else if (warnPNPMonce) {
warnPNPMonce = false;
console.warn('Executed with PNPM: Not compatible with deep search of dependencies!!');
console.warn('Executed with PNPM: Certainly due to circular dependencies');
// the scope or package name is not the one we look for
// if there is a nested node modules folder, we dive into it for the search
const nestedNodeModulesPath = path.join(subFolderPath, 'node_modules');
if (fs.existsSync(nestedNodeModulesPath)) {
// eslint-disable-next-line no-use-before-define
return accu.concat(findPackagesFromNonScopeFolder(scope, name, nestedNodeModulesPath, []));
}
return accu;
}, []);
Expand All @@ -70,7 +55,11 @@ function findPackagesFromNonScopeFolder(scope, name, nonScopeFolderPath) {
if (subFolder.name === '.bin') {
return accu;
}
if (subFolder.name.startsWith('@')) {
// TODO NOT COMPATIBLE WITH PNPM WHEN deps is @talend/scripts-...
if (
subFolder.name.startsWith('@') &&
!subFolder?.path?.endsWith('tools/scripts-core/node_modules')
) {
// for scope folders, we need a special treatment to avoid getting scoped packages when we don't want a scoped one.
// ex: search for `classnames`, we don't want to find `@types/classnames` in the result
return accu.concat(
Expand All @@ -94,7 +83,10 @@ function findPackages(scope, name, buff = []) {
if (roots === null) {
return buff;
}
return buff.concat(...roots.map(root => findPackagesFromNonScopeFolder(scope, name, root)));
const result = buff.concat(
...roots.map(root => findPackagesFromNonScopeFolder(scope, name, root)),
);
return [...new Set(result)];
}

module.exports = {
Expand Down
12 changes: 5 additions & 7 deletions fork/dynamic-cdn-webpack-plugin/src/find.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,22 @@ describe('findPackages', () => {
'/node_modules/react/index.js': 'console.log("react");',
'/node_modules/react/package.json': '{"name": "react", "version": "16.14.0"}',
'/node_modules/@types/classnames/index.js': 'console.log("@types/classnames");',
'/node_modules/@talend/react-components/index.js':
'console.log("@talend/react-components");',
'/node_modules/@talend/react-components/node_modules/react/index.js':
'console.log("react");',
'/node_modules/@talend/react-containers/index.js':
'console.log("@talend/react-containers");',
'/node_modules/@talend/react-components/index.js': 'console.log("@talend/react-components");',
'/node_modules/@talend/react-components/node_modules/react/index.js': 'console.log("react");',
'/node_modules/@talend/react-containers/index.js': 'console.log("@talend/react-containers");',
};

beforeEach(() => {
// Set up some mocked out file info before each test
require('fs').__setMockFiles(MOCK_FILE_INFO);
});

test('should find root and nested package', () => {
test.only('should find root and nested package', () => {
// when
const result = findPackages(undefined, 'react');

// then
console.log('LIST OF RESULT: ', result);
expect(result.length).toBe(2);
expect(result[0]).toBe('/node_modules/react');
expect(result[1]).toBe('/node_modules/@talend/react-components/node_modules/react');
Expand Down
2 changes: 1 addition & 1 deletion fork/react-bootstrap/.babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"extends": "@talend/scripts-config-babel/.babelrc.json"
"extends": "@talend/scripts-config-babel/babel.config.js"
}
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"lint-staged": "lint-staged",
"lint": "pnpm -r --no-bail run lint",
"lint-merge-report": "pnpm -r lint-merge-report",
"test": "cross-env TZ=Europe/Paris pnpm -r --no-bail run test --silent",
"test": "cross-env TZ=Europe/Paris pnpm -r --no-bail run test",
"test:update": "cross-env TZ=Europe/Paris pnpm -r --no-bail run test --silent -u",
"test:cov": "cross-env TZ=Europe/Paris pnpm -r --no-bail run test:cov",
"test:demo": "pnpm -r --no-bail run test:demo",
Expand All @@ -37,10 +37,11 @@
"start-forms": "pnpm --filter @talend/react-forms run start",
"start-theme": "pnpm --filter @talend/bootstrap-theme run start",
"changelog": "git log --pretty=\"format:%C(bold green)%ad%C(reset) %s\" --date=short --color",
"clean": "pnpm -r exec npx rimraf node_modules && npx rimraf node_modules",
"clean": "pnpm run clean:node_modules && pnpm run clean:dist && pnpm run clean:lib && pnpm run clean:cache ",
"clean:dist": "pnpm -r exec npx rimraf dist && npx rimraf dist",
"clean:lib": "pnpm -r exec npx rimraf lib && npx rimraf lib",
"clean:cache": "pnpm store prune",
"clean:node_modules": "pnpm -r exec npx rimraf node_modules && npx rimraf node_modules",
"prepare": "husky install",
"preinstall": "npx only-allow pnpm"
},
Expand All @@ -50,7 +51,7 @@
},
"version": "0.0.0",
"private": true,
"packageManager": "pnpm@8.8.0",
"packageManager": "pnpm@8.9.2",
"pnpm": {
"overrides": {
"@cypress/request@<=2.88.12": ">=3.0.0",
Expand Down
1 change: 1 addition & 0 deletions packages/a11y/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"@talend/scripts-config-typescript": "^11.1.0",
"@testing-library/react": "^12.1.5",
"@testing-library/user-event": "^13.5.0",
"@types/jest": "^29.5.5",
"react": "^17.0.2",
"react-dom": "^17.0.2"
},
Expand Down
2 changes: 2 additions & 0 deletions packages/assets-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
"@talend/scripts-core": "^15.0.0",
"@talend/scripts-config-react-webpack": "^16.0.0",
"@talend/scripts-config-typescript": "^11.1.0",
"@types/node": "^6.14.13",
"@types/jest": "^29.5.5",
"read-pkg-up": "^7.0.1"
},
"publishConfig": {
Expand Down
15 changes: 6 additions & 9 deletions packages/assets-api/src/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import readPackageUp from 'read-pkg-up';
import assetsApi, { Asset } from '.';

const iconsInfo = readPackageUp.sync({ cwd: require.resolve('@talend/icons') });
const currentInfo = readPackageUp.sync({ cwd: __dirname });
const bundlePath = '/dist/svg-bundles/all.svg';

Expand All @@ -12,17 +11,15 @@ describe('assets-api', () => {
});

it('should return unpkg url', () => {
const url = assetsApi.getURL(bundlePath, '@talend/icons', iconsInfo?.packageJson.version);
expect(url).toBe(
`https://unpkg.com/@talend/icons@${iconsInfo?.packageJson.version}${bundlePath}`,
);
const url = assetsApi.getURL(bundlePath, '@talend/icons', '6.60.1');
expect(url).toBe(`https://unpkg.com/@talend/[email protected]${bundlePath}`);
});

it('should return /cdn url', () => {
const original = window.Talend.CDN_URL;
window.Talend.CDN_URL = '/cdn';
const url = assetsApi.getURL(bundlePath, '@talend/icons', iconsInfo?.packageJson.version);
expect(url).toBe(`/cdn/@talend/icons/${iconsInfo?.packageJson.version}${bundlePath}`);
const url = assetsApi.getURL(bundlePath, '@talend/icons', '6.60.1');
expect(url).toBe(`/cdn/@talend/icons/6.60.1${bundlePath}`);
window.Talend.CDN_URL = original;
});

Expand All @@ -33,8 +30,8 @@ describe('assets-api', () => {
getAttribute: jest.fn().mockReturnValueOnce('/'),
} as unknown as Element;
jest.spyOn(document, 'querySelector').mockImplementation(() => mockedBaseElement);
const url = assetsApi.getURL(bundlePath, '@talend/icons', iconsInfo?.packageJson.version);
expect(url).toBe(`/cdn/@talend/icons/${iconsInfo?.packageJson.version}${bundlePath}`);
const url = assetsApi.getURL(bundlePath, '@talend/icons', '6.60.1');
expect(url).toBe(`/cdn/@talend/icons/6.60.1${bundlePath}`);
window.Talend.CDN_URL = original;
});

Expand Down
2 changes: 1 addition & 1 deletion packages/cmf-cqrs/.babelrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"extends": "@talend/scripts-config-babel/.babelrc.json"
"extends": "@talend/scripts-config-babel/babel.config.js"
}
2 changes: 1 addition & 1 deletion packages/cmf-router/.babelrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"extends": "@talend/scripts-config-babel/.babelrc.json"
"extends": "@talend/scripts-config-babel/babel.config.js"
}
2 changes: 1 addition & 1 deletion packages/cmf/.babelrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"extends": "@talend/scripts-config-babel/.babelrc.json"
"extends": "@talend/scripts-config-babel/babel.config.js"
}
2 changes: 1 addition & 1 deletion packages/components/.babelrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"extends": "@talend/scripts-config-babel/.babelrc.json"
"extends": "@talend/scripts-config-babel/babel.config.js"
}
10 changes: 5 additions & 5 deletions packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"build:prod": "talend-scripts build --umd --prod",
"pre-release": "pnpm build:dev && pnpm build:prod",
"build:lib": "talend-scripts build && pnpm run tsc",
"tsc": "tsc --emitDeclarationOnly --project ./tsconfig.json --outDir ./types",
"tsc": "tsc --emitDeclarationOnly --project ./tsconfig.build.json --outDir ./types",
"test": "cross-env TZ=Europe/Paris talend-scripts test",
"test:watch": "cross-env TZ=Europe/Paris talend-scripts test --watch",
"test:cov": "cross-env TZ=Europe/Paris talend-scripts test --coverage",
Expand Down Expand Up @@ -37,8 +37,9 @@
"@talend/assets-api": "^1.2.2",
"@talend/bootstrap-theme": "^8.2.0",
"@talend/design-tokens": "^2.9.0",
"@talend/react-a11y": "^1.1.0",
"@talend/icons": "^6.60.1",
"@talend/react-a11y": "^1.1.0",
"@talend/react-bootstrap": "^1.35.2",
"@talend/utils": "^2.6.0",
"ally.js": "^1.4.1",
"classnames": "^2.3.2",
Expand All @@ -52,7 +53,6 @@
"memoize-one": "^6.0.0",
"rc-slider": "^10.2.1",
"react-autowhatever": "10.2.0",
"@talend/react-bootstrap": "^1.35.2",
"react-debounce-input": "^3.3.0",
"react-draggable": "^4.4.5",
"react-grid-layout": "^1.4.1",
Expand Down Expand Up @@ -85,7 +85,7 @@
"@types/classnames": "^2.3.1",
"@types/d3": "^7.4.0",
"@types/date-fns": "^0.0.2",
"@types/enzyme": "^3.10.13",
"@types/jest": "^29.5.5",
"@types/lodash": "^4.14.198",
"@types/prop-types": "^15.7.5",
"@types/react": "^17.0.65",
Expand All @@ -103,7 +103,7 @@
"react-test-renderer": "^17.0.2"
},
"peerDependencies": {
"@talend/design-system": "^7.5.0",
"@talend/design-system": "^7.15.1",
"i18next": "^20.1.0",
"prop-types": "^15.5.10",
"react": ">= 16.14.0",
Expand Down
4 changes: 4 additions & 0 deletions packages/components/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "./tsconfig.json",
"exclude": ["src/**/*.test.*", "src/**/*.stories.*", "stories"]
}
2 changes: 1 addition & 1 deletion packages/containers/.babelrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"extends": "@talend/scripts-config-babel/.babelrc.json"
"extends": "@talend/scripts-config-babel/babel.config.js"
}
2 changes: 1 addition & 1 deletion packages/dataviz/.babelrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"extends": "@talend/scripts-config-babel/.babelrc.json"
"extends": "@talend/scripts-config-babel/babel.config.js"
}
2 changes: 1 addition & 1 deletion packages/dataviz/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"@testing-library/user-event": "^13.5.0",
"@types/classnames": "^2.3.1",
"@types/d3": "^7.4.0",
"@types/enzyme": "^3.10.13",
"@types/cypress": "^1.1.3",
"@types/geojson": "^7946.0.10",
"@types/lodash": "^4.14.198",
"@types/react": "^17.0.65",
Expand Down
2 changes: 1 addition & 1 deletion packages/design-docs/.babelrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"extends": "@talend/scripts-config-babel/.babelrc.json"
"extends": "@talend/scripts-config-babel/babel.config.js"
}
2 changes: 1 addition & 1 deletion packages/design-docs/.storybook/.babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"extends": "@talend/scripts-config-babel/.babelrc.json"
"extends": "@talend/scripts-config-babel/babel.config.js"
}
2 changes: 1 addition & 1 deletion packages/design-system/.babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"extends": "@talend/scripts-config-babel/.babelrc.json"
"extends": "@talend/scripts-config-babel/babel.config.js"
}
3 changes: 3 additions & 0 deletions packages/design-tokens/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
testRegex: '(/__tests__/.*|src/|scripts/).*\\.test.(js|ts|tsx)$',
};
1 change: 1 addition & 0 deletions packages/design-tokens/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"@talend/scripts-config-typescript": "^11.1.0",
"@talend/babel-plugin-import-from-index": "^1.5.1",
"@talend/babel-plugin-assets-api": "^1.1.0",
"jest": "^29.7.0",
"typeface-source-sans-pro": "^1.1.13"
},
"dependencies": {}
Expand Down
2 changes: 1 addition & 1 deletion packages/faceted-search/.babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"extends": "@talend/scripts-config-babel/.babelrc.json"
"extends": "@talend/scripts-config-babel/babel.config.js"
}
2 changes: 1 addition & 1 deletion packages/faceted-search/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"react-i18next": "^11.18.6"
},
"peerDependencies": {
"@talend/design-system": "^7.5.1",
"@talend/design-system": "^7.15.1",
"@talend/react-components": "^11.0.0",
"i18next": "^20.6.1",
"prop-types": "^15.5.10",
Expand Down
Loading
Loading